@ts-graphviz/react 0.9.1 → 0.10.0
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.
- package/CHANGELOG.md +76 -0
- package/LICENSE +1 -1
- package/README.md +25 -63
- package/example/example.tsx +14 -12
- package/lib/react.cjs +457 -0
- package/lib/react.d.ts +230 -0
- package/lib/react.js +457 -0
- package/package.json +55 -65
- package/src/components/Digraph.spec.tsx +18 -0
- package/src/components/Digraph.tsx +41 -0
- package/src/components/Edge.tsx +17 -0
- package/src/components/Graph.spec.tsx +18 -0
- package/src/components/Graph.tsx +36 -0
- package/src/components/GraphPortal.tsx +22 -0
- package/src/components/Node.spec.tsx +101 -0
- package/src/components/Node.tsx +21 -0
- package/src/components/Subgraph.tsx +30 -0
- package/src/contexts/CurrentGraph.ts +5 -0
- package/src/contexts/GraphContainer.ts +5 -0
- package/src/contexts/GraphMap.ts +5 -0
- package/src/contexts/GraphvizContext.ts +11 -0
- package/src/hooks/__tests__/wrapper.tsx +58 -0
- package/src/hooks/useCurrentGraph.spec.ts +56 -0
- package/src/hooks/useCurrentGraph.ts +18 -0
- package/src/hooks/useDigraph.spec.ts +15 -0
- package/src/hooks/useDigraph.ts +33 -0
- package/src/hooks/useEdge.spec.ts +46 -0
- package/src/hooks/useEdge.ts +35 -0
- package/src/hooks/useGraph.spec.ts +15 -0
- package/src/hooks/useGraph.ts +33 -0
- package/src/hooks/useGraphAttributes.ts +32 -0
- package/src/hooks/useGraphContainer.spec.ts +45 -0
- package/src/hooks/useGraphContainer.ts +10 -0
- package/src/hooks/useGraphMap.ts +7 -0
- package/src/hooks/useGraphvizContext.spec.ts +26 -0
- package/src/hooks/useGraphvizContext.ts +16 -0
- package/src/hooks/useHasAttributes.ts +16 -0
- package/src/hooks/useHasComment.ts +8 -0
- package/src/hooks/useNode.spec.ts +16 -0
- package/src/hooks/useNode.ts +29 -0
- package/src/hooks/useRenderedID.spec.tsx +28 -0
- package/src/hooks/useRenderedID.ts +6 -0
- package/src/hooks/useSubgraph.spec.ts +41 -0
- package/src/hooks/useSubgraph.ts +39 -0
- package/src/react.ts +16 -0
- package/src/reconciler.ts +272 -0
- package/src/render.test.tsx +71 -0
- package/src/render.ts +142 -0
- package/src/renderHTMLLike.ts +9 -0
- package/src/renderId.ts +9 -0
- package/src/types.ts +107 -0
- package/tsconfig.json +8 -0
- package/typedoc.json +5 -0
- package/vite.config.ts +31 -0
- package/.all-contributorsrc +0 -47
- package/.devcontainer/Dockerfile +0 -16
- package/.devcontainer/devcontainer.json +0 -35
- package/.eslintignore +0 -2
- package/lib/index.d.ts +0 -368
- package/lib/index.js +0 -1
- package/lib/index.mjs +0 -1
- package/rollup.config.js +0 -55
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @ts-graphviz/react
|
|
2
|
+
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
### Overview
|
|
10
|
+
|
|
11
|
+
- Imported source code from `@ts-graphviz/react` repository and integrated it into the monorepo.
|
|
12
|
+
- Emphasized code quality through component tests and updated function signatures.
|
|
13
|
+
- Renamed functions and types for readability and consistency throughout the ts-graphviz project.
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
- Support React 18 and remove `prop-types` as a dependency.
|
|
18
|
+
- `prop-types` is removed because TypeScript can cover the same functionality.
|
|
19
|
+
- Moved `react-dom` to `peerDependencies` for streamlined dependency management.
|
|
20
|
+
- Improved file naming conventions for better codebase organization.
|
|
21
|
+
|
|
22
|
+
### New Features
|
|
23
|
+
|
|
24
|
+
#### New HTMLLike label syntax
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { Digraph, Node, Edge, render } from "@ts-graphviz/react";
|
|
28
|
+
|
|
29
|
+
const dot = render(
|
|
30
|
+
<Digraph>
|
|
31
|
+
<Node
|
|
32
|
+
id="A"
|
|
33
|
+
label={
|
|
34
|
+
<dot:table>
|
|
35
|
+
<dot:tr>
|
|
36
|
+
<dot:td>left</dot:td>
|
|
37
|
+
<dot:td>right</dot:td>
|
|
38
|
+
</dot:tr>
|
|
39
|
+
</dot:table>
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
</Digraph>
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### `renderHTMLLike` function
|
|
47
|
+
|
|
48
|
+
The `renderHTMLLike` function is introduced for rendering HTML-like labels.
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { renderHTMLLike } from "@ts-graphviz/react";
|
|
52
|
+
|
|
53
|
+
const htmlLike = renderHTMLLike(
|
|
54
|
+
<dot:table>
|
|
55
|
+
<dot:tr>
|
|
56
|
+
<dot:td>left</dot:td>
|
|
57
|
+
<dot:td>right</dot:td>
|
|
58
|
+
</dot:tr>
|
|
59
|
+
</dot:table>
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Other Changes
|
|
64
|
+
|
|
65
|
+
- Added the `provenance` flag in `package.json` for enhanced publishing traceability.
|
|
66
|
+
- Enhanced TypeScript support and type definitions, including moving types to `@ts-graphviz/common`.
|
|
67
|
+
|
|
68
|
+
- Move HTMLLike type to `@ts-graphviz/common`.
|
|
69
|
+
|
|
70
|
+
- Refactor JSX syntax for better compatibility and custom JSX-like syntax for HTMLLike.
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 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)]:
|
|
75
|
+
- ts-graphviz@2.1.0
|
|
76
|
+
- @ts-graphviz/common@2.1.0
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
[](https://github.com/ts-graphviz/react/actions?workflow=NodeCI)
|
|
2
|
-
[](https://badge.fury.io/js/%40ts-graphviz%2Freact)
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](http://makeapullrequest.com)
|
|
5
|
-
[](https://github.com/facebook/jest)
|
|
6
|
-
[](https://github.com/prettier/prettier)
|
|
7
|
-
[](https://open.vscode.dev/ts-graphviz/react)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
8
|
-
[](#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
|
|
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
|
-
<
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
</
|
|
58
|
-
</
|
|
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={<
|
|
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 = <<
|
|
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 = <<
|
|
89
|
+
label = <<b>A to B</b>>;
|
|
100
90
|
];
|
|
101
91
|
}
|
|
102
92
|
```
|
|
103
93
|
|
|
104
94
|

|
|
105
95
|
|
|
106
|
-
##
|
|
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
|
-
|
|
98
|
+
Contributions to the ts-graphviz project are welcome.
|
|
136
99
|
|
|
137
|
-
|
|
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
|
|
104
|
+
This software is released under the MIT License.
|
package/example/example.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
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
|
|
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
|
-
<
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
</
|
|
25
|
-
</
|
|
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
|
|
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);
|