@ts-graphviz/react 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -63
  4. package/example/example.tsx +14 -12
  5. package/lib/react.cjs +457 -0
  6. package/lib/react.d.ts +230 -0
  7. package/lib/react.js +457 -0
  8. package/package.json +55 -65
  9. package/src/components/Digraph.spec.tsx +18 -0
  10. package/src/components/Digraph.tsx +41 -0
  11. package/src/components/Edge.tsx +17 -0
  12. package/src/components/Graph.spec.tsx +18 -0
  13. package/src/components/Graph.tsx +36 -0
  14. package/src/components/GraphPortal.tsx +22 -0
  15. package/src/components/Node.spec.tsx +101 -0
  16. package/src/components/Node.tsx +21 -0
  17. package/src/components/Subgraph.tsx +30 -0
  18. package/src/contexts/CurrentGraph.ts +5 -0
  19. package/src/contexts/GraphContainer.ts +5 -0
  20. package/src/contexts/GraphMap.ts +5 -0
  21. package/src/contexts/GraphvizContext.ts +11 -0
  22. package/src/hooks/__tests__/wrapper.tsx +58 -0
  23. package/src/hooks/useCurrentGraph.spec.ts +56 -0
  24. package/src/hooks/useCurrentGraph.ts +18 -0
  25. package/src/hooks/useDigraph.spec.ts +15 -0
  26. package/src/hooks/useDigraph.ts +33 -0
  27. package/src/hooks/useEdge.spec.ts +46 -0
  28. package/src/hooks/useEdge.ts +35 -0
  29. package/src/hooks/useGraph.spec.ts +15 -0
  30. package/src/hooks/useGraph.ts +33 -0
  31. package/src/hooks/useGraphAttributes.ts +32 -0
  32. package/src/hooks/useGraphContainer.spec.ts +45 -0
  33. package/src/hooks/useGraphContainer.ts +10 -0
  34. package/src/hooks/useGraphMap.ts +7 -0
  35. package/src/hooks/useGraphvizContext.spec.ts +26 -0
  36. package/src/hooks/useGraphvizContext.ts +16 -0
  37. package/src/hooks/useHasAttributes.ts +16 -0
  38. package/src/hooks/useHasComment.ts +8 -0
  39. package/src/hooks/useNode.spec.ts +16 -0
  40. package/src/hooks/useNode.ts +29 -0
  41. package/src/hooks/useRenderedID.spec.tsx +28 -0
  42. package/src/hooks/useRenderedID.ts +6 -0
  43. package/src/hooks/useSubgraph.spec.ts +41 -0
  44. package/src/hooks/useSubgraph.ts +39 -0
  45. package/src/react.ts +16 -0
  46. package/src/reconciler.ts +272 -0
  47. package/src/render.test.tsx +71 -0
  48. package/src/render.ts +142 -0
  49. package/src/renderHTMLLike.ts +9 -0
  50. package/src/renderId.ts +9 -0
  51. package/src/types.ts +107 -0
  52. package/tsconfig.json +8 -0
  53. package/typedoc.json +5 -0
  54. package/vite.config.ts +32 -0
  55. package/.all-contributorsrc +0 -47
  56. package/.devcontainer/Dockerfile +0 -16
  57. package/.devcontainer/devcontainer.json +0 -35
  58. package/.eslintignore +0 -2
  59. package/lib/index.d.ts +0 -368
  60. package/lib/index.js +0 -1
  61. package/lib/index.mjs +0 -1
  62. package/rollup.config.js +0 -55
package/CHANGELOG.md ADDED
@@ -0,0 +1,86 @@
1
+ # @ts-graphviz/react
2
+
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1004](https://github.com/ts-graphviz/ts-graphviz/pull/1004) [`fabb8c8`](https://github.com/ts-graphviz/ts-graphviz/commit/fabb8c8b9f3ded57d41d7d4f1d669084ab4e91c9) Thanks [@kamiazya](https://github.com/kamiazya)! - Fix documentation build failed
8
+
9
+ - Updated dependencies [[`24f4174`](https://github.com/ts-graphviz/ts-graphviz/commit/24f4174a76eaef50fc7d30ae3401c1b23b00789b), [`fabb8c8`](https://github.com/ts-graphviz/ts-graphviz/commit/fabb8c8b9f3ded57d41d7d4f1d669084ab4e91c9)]:
10
+ - ts-graphviz@2.1.1
11
+ - @ts-graphviz/common@2.1.1
12
+
13
+ ## 0.10.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#992](https://github.com/ts-graphviz/ts-graphviz/pull/992) [`391e98e`](https://github.com/ts-graphviz/ts-graphviz/commit/391e98edf70bb43c1feb4a00f832fa9d96dd9d39) Thanks [@kamiazya](https://github.com/kamiazya)! - ## `@ts-graphviz/react` integrate with ts-graphviz monorepo
18
+
19
+ ### Overview
20
+
21
+ - Imported source code from `@ts-graphviz/react` repository and integrated it into the monorepo.
22
+ - Emphasized code quality through component tests and updated function signatures.
23
+ - Renamed functions and types for readability and consistency throughout the ts-graphviz project.
24
+
25
+ ### Dependencies
26
+
27
+ - Support React 18 and remove `prop-types` as a dependency.
28
+ - `prop-types` is removed because TypeScript can cover the same functionality.
29
+ - Moved `react-dom` to `peerDependencies` for streamlined dependency management.
30
+ - Improved file naming conventions for better codebase organization.
31
+
32
+ ### New Features
33
+
34
+ #### New HTMLLike label syntax
35
+
36
+ ```tsx
37
+ import { Digraph, Node, Edge, render } from "@ts-graphviz/react";
38
+
39
+ const dot = render(
40
+ <Digraph>
41
+ <Node
42
+ id="A"
43
+ label={
44
+ <dot:table>
45
+ <dot:tr>
46
+ <dot:td>left</dot:td>
47
+ <dot:td>right</dot:td>
48
+ </dot:tr>
49
+ </dot:table>
50
+ }
51
+ />
52
+ </Digraph>
53
+ );
54
+ ```
55
+
56
+ #### `renderHTMLLike` function
57
+
58
+ The `renderHTMLLike` function is introduced for rendering HTML-like labels.
59
+
60
+ ```tsx
61
+ import { renderHTMLLike } from "@ts-graphviz/react";
62
+
63
+ const htmlLike = renderHTMLLike(
64
+ <dot:table>
65
+ <dot:tr>
66
+ <dot:td>left</dot:td>
67
+ <dot:td>right</dot:td>
68
+ </dot:tr>
69
+ </dot:table>
70
+ );
71
+ ```
72
+
73
+ ### Other Changes
74
+
75
+ - Added the `provenance` flag in `package.json` for enhanced publishing traceability.
76
+ - Enhanced TypeScript support and type definitions, including moving types to `@ts-graphviz/common`.
77
+
78
+ - Move HTMLLike type to `@ts-graphviz/common`.
79
+
80
+ - Refactor JSX syntax for better compatibility and custom JSX-like syntax for HTMLLike.
81
+
82
+ ### Patch Changes
83
+
84
+ - Updated dependencies [[`cb5517a`](https://github.com/ts-graphviz/ts-graphviz/commit/cb5517a0236ce33527d200df9770390f4eb40064), [`0589b4f`](https://github.com/ts-graphviz/ts-graphviz/commit/0589b4f8849290d2c4a39beceb9b633f059f2e3f), [`5ce6b59`](https://github.com/ts-graphviz/ts-graphviz/commit/5ce6b59fa395bc344de2bfb15061b158a9ea5586), [`122336b`](https://github.com/ts-graphviz/ts-graphviz/commit/122336bede1033f73a2a94c82d499fda238f6b2e), [`b5f36fa`](https://github.com/ts-graphviz/ts-graphviz/commit/b5f36faf9cf70dfc263130c4480dc21770475c5a), [`c55f2d0`](https://github.com/ts-graphviz/ts-graphviz/commit/c55f2d0dfa851d318cc16a36499c69c0a34f1588), [`81a50ff`](https://github.com/ts-graphviz/ts-graphviz/commit/81a50ff94b461f44256f2eea5b86af5eb26afd94), [`a16f047`](https://github.com/ts-graphviz/ts-graphviz/commit/a16f047dfdd5db73f3e25847cf3fb2f8075aaf11), [`391e98e`](https://github.com/ts-graphviz/ts-graphviz/commit/391e98edf70bb43c1feb4a00f832fa9d96dd9d39), [`a16f047`](https://github.com/ts-graphviz/ts-graphviz/commit/a16f047dfdd5db73f3e25847cf3fb2f8075aaf11), [`a16f047`](https://github.com/ts-graphviz/ts-graphviz/commit/a16f047dfdd5db73f3e25847cf3fb2f8075aaf11)]:
85
+ - ts-graphviz@2.1.0
86
+ - @ts-graphviz/common@2.1.0
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2020 Yuki Yamazaki
4
+ Copyright (c) 2019-2024 Yuki Yamazaki
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,16 +1,7 @@
1
- [![NodeCI](https://github.com/ts-graphviz/react/workflows/NodeCI/badge.svg)](https://github.com/ts-graphviz/react/actions?workflow=NodeCI)
2
- [![npm version](https://badge.fury.io/js/%40ts-graphviz%2Freact.svg)](https://badge.fury.io/js/%40ts-graphviz%2Freact)
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
5
- [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
6
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
7
- [![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/ts-graphviz/react)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
8
- [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
9
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
10
-
11
-
12
1
  # @ts-graphviz/react
13
2
 
3
+ > It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
4
+
14
5
  Graphviz-dot Renderer using React.
15
6
 
16
7
  ## Installation
@@ -21,18 +12,17 @@ The module can then be installed using [npm](https://www.npmjs.com/):
21
12
 
22
13
  ```bash
23
14
  # yarn
24
- $ yarn add @ts-graphviz/react react
15
+ $ yarn add @ts-graphviz/react react react-dom
25
16
  # or npm
26
- $ npm install -S @ts-graphviz/react react
17
+ $ npm install -S @ts-graphviz/react react react-dom
27
18
  ```
28
19
 
29
- > Install [React](https://github.com/facebook/react/) as peerDependencies at the same time.
20
+ > Install [React and React DOM](https://github.com/facebook/react/) as peerDependencies at the same time.
30
21
 
31
22
  ## Example
32
23
 
33
24
  ```jsx
34
- import React from 'react';
35
- import { Digraph, Node, Subgraph, Edge, DOT, renderToDot } from '@ts-graphviz/react';
25
+ import { Digraph, Node, Subgraph, Edge, renderToDot } from '@ts-graphviz/react';
36
26
 
37
27
  const Example = () => (
38
28
  <Digraph
@@ -49,20 +39,20 @@ const Example = () => (
49
39
  id="nodeA"
50
40
  shape="none"
51
41
  label={
52
- <DOT.TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
53
- <DOT.TR>
54
- <DOT.TD>left</DOT.TD>
55
- <DOT.TD PORT="m">middle</DOT.TD>
56
- <DOT.TD PORT="r">right</DOT.TD>
57
- </DOT.TR>
58
- </DOT.TABLE>
42
+ <dot:table border="0" cellborder="1" cellspacing="0">
43
+ <dot:tr>
44
+ <dot:td>left</dot:td>
45
+ <dot:td port="m">middle</dot:td>
46
+ <dot:td port="r">right</dot:td>
47
+ </dot:tr>
48
+ </dot:table>
59
49
  }
60
50
  />
61
51
 
62
52
  <Subgraph id="cluster" label="Cluster" labeljust="l">
63
53
  <Node id="nodeB" label="This is label for nodeB." />
64
54
  </Subgraph>
65
- <Edge targets={['nodeB', 'nodeA:m']} comment="Edge from node A to B" label={<DOT.B>A to B</DOT.B>} />
55
+ <Edge targets={['nodeB', 'nodeA:m']} comment="Edge from node A to B" label={<dot:b>A to B</dot:b>} />
66
56
  </Digraph>
67
57
  );
68
58
 
@@ -77,66 +67,38 @@ console.log(dot);
77
67
  digraph {
78
68
  rankdir = "TB";
79
69
  edge [
80
- color = "blue",
81
- fontcolor = "blue",
70
+ color = "blue";
71
+ fontcolor = "blue";
82
72
  ];
83
73
  node [
84
- shape = "none",
74
+ shape = "none";
85
75
  ];
86
76
  "nodeA" [
87
- shape = "none",
88
- label = <<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"><TR><TD>left</TD><TD PORT="m">middle</TD><TD PORT="r">right</TD></TR></TABLE>>,
77
+ shape = "none";
78
+ label = <<table border="0" cellborder="1" cellSpacing="0"><tr><td>left</td><td port="m">middle</td><td port="r">right</td></tr></table>>;
89
79
  ];
90
80
  subgraph "cluster" {
91
81
  labeljust = "l";
92
82
  label = "Cluster";
93
83
  "nodeB" [
94
- label = "This is label for nodeB.",
84
+ label = "This is label for nodeB.";
95
85
  ];
96
86
  }
97
87
  // Edge from node A to B
98
88
  "nodeB" -> "nodeA":"m" [
99
- label = <<B>A to B</B>>,
89
+ label = <<b>A to B</b>>;
100
90
  ];
101
91
  }
102
92
  ```
103
93
 
104
94
  ![dot](./example/example.svg)
105
95
 
106
- ## See Also
107
-
108
- Graphviz-dot Test and Integration
109
-
110
- - [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz)
111
- - Graphviz library for TypeScript.
112
- - [jest-graphviz](https://github.com/ts-graphviz/jest-graphviz)
113
- - Jest matchers that supports graphviz integration.
114
- - [setup-graphviz](https://github.com/ts-graphviz/setup-graphviz)
115
- - GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).
116
-
117
- ## Contributors
118
-
119
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
120
-
121
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
122
- <!-- prettier-ignore-start -->
123
- <!-- markdownlint-disable -->
124
- <table>
125
- <tr>
126
- <td align="center"><a href="http://blog.kamiazya.tech/"><img src="https://avatars0.githubusercontent.com/u/35218186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yuki Yamazaki</b></sub></a><br /><a href="https://github.com/ts-graphviz/react/commits?author=kamiazya" title="Code">💻</a> <a href="https://github.com/ts-graphviz/react/commits?author=kamiazya" title="Tests">⚠️</a> <a href="#ideas-kamiazya" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ts-graphviz/react/commits?author=kamiazya" title="Documentation">📖</a></td>
127
- <td align="center"><a href="https://github.com/nagasawaryoya"><img src="https://avatars.githubusercontent.com/u/53528726?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nagasawaryoya</b></sub></a><br /><a href="https://github.com/ts-graphviz/react/commits?author=nagasawaryoya" title="Code">💻</a> <a href="https://github.com/ts-graphviz/react/commits?author=nagasawaryoya" title="Tests">⚠️</a></td>
128
- <td align="center"><a href="https://github.com/tokidrill"><img src="https://avatars.githubusercontent.com/u/42460318?v=4?s=100" width="100px;" alt=""/><br /><sub><b>YukiSasaki</b></sub></a><br /><a href="https://github.com/ts-graphviz/react/commits?author=tokidrill" title="Code">💻</a> <a href="https://github.com/ts-graphviz/react/commits?author=tokidrill" title="Tests">⚠️</a></td>
129
- </tr>
130
- </table>
131
-
132
- <!-- markdownlint-restore -->
133
- <!-- prettier-ignore-end -->
96
+ ## Contributing
134
97
 
135
- <!-- ALL-CONTRIBUTORS-LIST:END -->
98
+ Contributions to the ts-graphviz project are welcome.
136
99
 
137
- This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
138
- specification. Contributions of any kind welcome!
100
+ Please refer to the main ts-graphviz repository for guidelines on how to contribute.
139
101
 
140
102
  ## License
141
103
 
142
- This software is released under the MIT License, see [LICENSE](./LICENSE).
104
+ This software is released under the MIT License.
@@ -1,7 +1,6 @@
1
- import React, { FC } from 'react';
2
- import { Digraph, Node, Subgraph, renderToDot, Edge, DOT } from '../src';
1
+ import { Digraph, Edge, Node, Subgraph, renderToDot } from '@ts-graphviz/react';
3
2
 
4
- const Example: FC = () => (
3
+ const Example = () => (
5
4
  <Digraph
6
5
  rankdir="TB"
7
6
  edge={{
@@ -16,24 +15,27 @@ const Example: FC = () => (
16
15
  id="nodeA"
17
16
  shape="none"
18
17
  label={
19
- <DOT.TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
20
- <DOT.TR>
21
- <DOT.TD>left</DOT.TD>
22
- <DOT.TD PORT="m">middle</DOT.TD>
23
- <DOT.TD PORT="r">right</DOT.TD>
24
- </DOT.TR>
25
- </DOT.TABLE>
18
+ <dot:table border={0} cellborder={1} cellSpacing={0}>
19
+ <dot:tr>
20
+ <dot:td>left</dot:td>
21
+ <dot:td port="m">middle</dot:td>
22
+ <dot:td port="r">right</dot:td>
23
+ </dot:tr>
24
+ </dot:table>
26
25
  }
27
26
  />
28
27
 
29
28
  <Subgraph id="cluster" label="Cluster" labeljust="l">
30
29
  <Node id="nodeB" label="This is label for nodeB." />
31
30
  </Subgraph>
32
- <Edge targets={['nodeB', 'nodeA:m']} comment="Edge from node A to B" label={<DOT.B>A to B</DOT.B>} />
31
+ <Edge
32
+ targets={['nodeB', 'nodeA:m']}
33
+ comment="Edge from node A to B"
34
+ label={<dot:b>A to B</dot:b>}
35
+ />
33
36
  </Digraph>
34
37
  );
35
38
 
36
39
  const dot = renderToDot(<Example />);
37
40
 
38
- // eslint-disable-next-line no-console
39
41
  console.log(dot);