@lincle/react-web-base 0.0.1 → 0.4.0-next.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.
- package/LICENSE.md +165 -0
- package/README.md +4 -4
- package/dist/{Edge → components/Edge}/index.d.ts +1 -1
- package/dist/{Edge → components/Edge}/index.js +4 -4
- package/dist/{Edges → components/Edges}/index.d.ts +1 -1
- package/dist/{Edges → components/Edges}/index.js +3 -3
- package/dist/{Graph → components/Graph}/index.d.ts +1 -1
- package/dist/components/Graph/index.js +16 -0
- package/dist/{GraphContexts → components/GraphContexts}/index.d.ts +1 -1
- package/dist/{GraphContexts → components/GraphContexts}/index.js +10 -11
- package/dist/{Grid → components/Grid}/index.d.ts +1 -1
- package/dist/{Grid → components/Grid}/index.js +7 -7
- package/dist/{Node → components/Node}/index.d.ts +1 -1
- package/dist/{Node → components/Node}/index.js +16 -16
- package/dist/{Nodes → components/Nodes}/index.d.ts +1 -1
- package/dist/{Path → components/Path}/index.d.ts +1 -1
- package/dist/{Path → components/Path}/index.js +9 -8
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +22 -0
- package/dist/index.d.ts +2 -99
- package/dist/index.js +15 -27
- package/dist/shared.d.ts +22 -0
- package/dist/shared.js +10 -0
- package/package.json +25 -24
- package/dist/Graph/index.js +0 -22
- package/dist/Path/generateOrigins.d.ts +0 -5
- package/dist/Path/generateOrigins.js +0 -18
- package/dist/Path/lines/generateCurve.d.ts +0 -17
- package/dist/Path/lines/generateCurve.js +0 -50
- package/dist/Path/lines/generateDirect.d.ts +0 -16
- package/dist/Path/lines/generateDirect.js +0 -32
- package/dist/Path/lines/generatePoints.d.ts +0 -15
- package/dist/Path/lines/generatePoints.js +0 -111
- package/dist/Path/lines/generateStep.d.ts +0 -17
- package/dist/Path/lines/generateStep.js +0 -63
- package/dist/Path/lines/index.d.ts +0 -4
- package/dist/Path/lines/index.js +0 -12
- package/dist/Path/lines/types.d.ts +0 -34
- package/dist/Path/lines/types.js +0 -2
- /package/dist/{Nodes → components/Nodes}/index.js +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
17
|
<div align="center">
|
|
18
|
-
<a href="https://gitlab.com/
|
|
19
|
-
<a href="https://lincle.gitlab.io/lincle/stats/react-web-base/coverage/lcov-report/"><img alt="Coverage Report" src="https://gitlab.com/
|
|
18
|
+
<a href="https://gitlab.com/digested/lincle/commits/master"><img alt="Build Status" src="https://gitlab.com/digested/lincle/badges/master/pipeline.svg" /></a>
|
|
19
|
+
<a href="https://lincle.gitlab.io/lincle/stats/react-web-base/coverage/lcov-report/"><img alt="Coverage Report" src="https://gitlab.com/digested/lincle/badges/master/coverage.svg" /></a>
|
|
20
20
|
<a href="https://lincle.gitlab.io/lincle/stats/react-web-base/webpack/"><img alt="Build Analysis" src="https://img.shields.io/badge/webpack-stats-blue.svg" /></a>
|
|
21
21
|
</div>
|
|
22
22
|
|
|
@@ -45,8 +45,8 @@ import '@lincle/react-web-base/dist/main.min.css';
|
|
|
45
45
|
The following example will generate this diagram:
|
|
46
46
|
|
|
47
47
|
<div align="center">
|
|
48
|
-
<a href="https://gitlab.com/
|
|
49
|
-
<img src="https://gitlab.com/
|
|
48
|
+
<a href="https://gitlab.com/digested/lincle/-/raw/master/static/simple.png">
|
|
49
|
+
<img src="https://gitlab.com/digested/lincle/-/raw/master/static/simple.png" alt="resulting screenshot of simple example" style="max-width:100%;">
|
|
50
50
|
</a>
|
|
51
51
|
</div>
|
|
52
52
|
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const shared_1 = require("../../shared");
|
|
7
8
|
const Path_1 = __importDefault(require("../Path"));
|
|
8
|
-
const react_shared_1 = require("@lincle/react-shared");
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const Edge = ({ children, className = '', dash, id: edgeId, line: givenLine, markerEnd, markerStart, path, sourceId, targetId }) => {
|
|
11
11
|
var _a, _b, _c, _d;
|
|
12
|
-
const diagramId = (_a = (0, react_1.useContext)(
|
|
13
|
-
const edgeSubscriber = (_b = (0, react_1.useContext)(
|
|
14
|
-
const defaultLine = (_d = (_c = (0, react_1.useContext)(
|
|
12
|
+
const diagramId = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
|
|
13
|
+
const edgeSubscriber = (_b = (0, react_1.useContext)(shared_1.GraphContext)) === null || _b === void 0 ? void 0 : _b.edgeSubscriber;
|
|
14
|
+
const defaultLine = (_d = (_c = (0, react_1.useContext)(shared_1.GraphContext)) === null || _c === void 0 ? void 0 : _c.defaultSettings) === null || _d === void 0 ? void 0 : _d.line;
|
|
15
15
|
const line = givenLine !== null && givenLine !== void 0 ? givenLine : defaultLine;
|
|
16
16
|
const [source, setSource] = (0, react_1.useState)();
|
|
17
17
|
const [target, setTarget] = (0, react_1.useState)();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EdgesProps as EdgesPartialProps } from '
|
|
1
|
+
import { type EdgesProps as EdgesPartialProps } from '../../shared';
|
|
2
2
|
import { type CSSProperties, type FunctionComponent } from 'react';
|
|
3
3
|
declare const Edges: FunctionComponent<EdgesProps>;
|
|
4
4
|
export default Edges;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const Edges = ({ className = '',
|
|
6
|
+
const Edges = ({ children, className = '', dash, style }) => {
|
|
7
7
|
var _a;
|
|
8
|
-
const id = (_a = (0, react_1.useContext)(
|
|
8
|
+
const id = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
|
|
9
9
|
const markerId = (0, react_1.useMemo)(() => {
|
|
10
10
|
return id ?
|
|
11
11
|
`${id}-` :
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const GraphContexts_1 = __importDefault(require("../GraphContexts"));
|
|
8
|
+
const Graph = ({ children, edgeFrequency, grid, id, line, nodeFrequency, nodeHeight, nodeWidth, shape }) => {
|
|
9
|
+
if (!id) {
|
|
10
|
+
console.error('No ID provided to @lincle/base Graph!');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(GraphContexts_1.default, { edgeFrequency: edgeFrequency, grid: grid, id: id, line: line, nodeFrequency: nodeFrequency, nodeHeight: nodeHeight, nodeWidth: nodeWidth, shape: shape, children: children }));
|
|
14
|
+
};
|
|
15
|
+
Graph.displayName = 'LincleGraph';
|
|
16
|
+
exports.default = Graph;
|
|
@@ -4,19 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const shared_1 = require("../../shared");
|
|
7
8
|
const Grid_1 = __importDefault(require("../Grid"));
|
|
8
|
-
const react_shared_1 = require("@lincle/react-shared");
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
-
const GraphContexts = ({ children, edgeFrequency =
|
|
10
|
+
const GraphContexts = ({ children, edgeFrequency = shared_1.defaultSettings.edgeFrequency, grid = shared_1.defaultSettings.grid, id, line = shared_1.defaultSettings.line, nodeFrequency = shared_1.defaultSettings.nodeFrequency, nodeHeight = shared_1.defaultSettings.height, nodeWidth = shared_1.defaultSettings.width, shape = shared_1.defaultSettings.shape }) => {
|
|
11
11
|
const diagramId = (0, react_1.useMemo)(() => {
|
|
12
12
|
return id;
|
|
13
13
|
}, []);
|
|
14
14
|
const permanent = (0, react_1.useMemo)(() => {
|
|
15
|
-
console.log(react_shared_1.EdgeSubscriber);
|
|
16
15
|
return {
|
|
17
16
|
diagramId,
|
|
18
|
-
edgeSubscriber: new
|
|
19
|
-
nodePositions: new
|
|
17
|
+
edgeSubscriber: new shared_1.EdgeSubscriber(edgeFrequency),
|
|
18
|
+
nodePositions: new shared_1.NodePositions()
|
|
20
19
|
};
|
|
21
20
|
}, []);
|
|
22
21
|
const provides = (0, react_1.useMemo)(() => {
|
|
@@ -29,18 +28,18 @@ const GraphContexts = ({ children, edgeFrequency = react_shared_1.defaultSetting
|
|
|
29
28
|
width: nodeWidth
|
|
30
29
|
} });
|
|
31
30
|
}, [
|
|
32
|
-
permanent,
|
|
33
31
|
edgeFrequency,
|
|
34
|
-
nodeHeight,
|
|
35
32
|
line,
|
|
36
33
|
nodeFrequency,
|
|
37
|
-
|
|
38
|
-
nodeWidth
|
|
34
|
+
nodeHeight,
|
|
35
|
+
nodeWidth,
|
|
36
|
+
permanent,
|
|
37
|
+
shape
|
|
39
38
|
]);
|
|
40
39
|
const hiddenGrid = grid === false ?
|
|
41
40
|
children :
|
|
42
|
-
((0, jsx_runtime_1.jsxs)(
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
41
|
+
((0, jsx_runtime_1.jsxs)(shared_1.GridContext.Provider, { value: grid, children: [(0, jsx_runtime_1.jsx)(Grid_1.default, {}), children] }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(shared_1.GraphContext.Provider, { value: provides, children: hiddenGrid }));
|
|
44
43
|
};
|
|
45
44
|
GraphContexts.displayName = 'LincleGraphContexts';
|
|
46
45
|
exports.default = GraphContexts;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const SIZE = 0.4;
|
|
7
7
|
const Circle = ((0, jsx_runtime_1.jsx)("circle", { cx: SIZE, cy: SIZE, fill: 'black', r: SIZE }));
|
|
8
8
|
const Grid = ({ children, scale = 1, xOffset: givenXOffset = 0, yOffset: givenYOffset = 0 }) => {
|
|
9
9
|
var _a;
|
|
10
|
-
const diagramId = (_a = (0, react_1.useContext)(
|
|
11
|
-
const [givenGridX, givenGridY] = (0, react_1.useContext)(
|
|
10
|
+
const diagramId = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
|
|
11
|
+
const [givenGridX, givenGridY] = (0, react_1.useContext)(shared_1.GridContext) || shared_1.defaultSettings.grid;
|
|
12
12
|
const id = `lincle-grid-${diagramId}`;
|
|
13
13
|
const gridX = (0, react_1.useMemo)(() => {
|
|
14
14
|
return givenGridX * scale;
|
|
@@ -25,14 +25,14 @@ const Grid = ({ children, scale = 1, xOffset: givenXOffset = 0, yOffset: givenYO
|
|
|
25
25
|
const xOffset = (0, react_1.useMemo)(() => {
|
|
26
26
|
return givenXOffset % gridX;
|
|
27
27
|
}, [
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
givenXOffset,
|
|
29
|
+
gridX
|
|
30
30
|
]);
|
|
31
31
|
const yOffset = (0, react_1.useMemo)(() => {
|
|
32
32
|
return givenYOffset % gridY;
|
|
33
33
|
}, [
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
givenYOffset,
|
|
35
|
+
gridY
|
|
36
36
|
]);
|
|
37
37
|
return ((0, jsx_runtime_1.jsxs)("svg", { className: 'lincle-base-grid', children: [(0, jsx_runtime_1.jsx)("pattern", { height: gridY, id: id, patternUnits: 'userSpaceOnUse', width: gridX, x: xOffset, y: yOffset, children: children !== null && children !== void 0 ? children : Circle }), (0, jsx_runtime_1.jsx)("rect", { fill: `url(#${id})`, height: '100%', width: '100%', x: '0', y: '0' })] }));
|
|
38
38
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type NodeProps } from '
|
|
2
|
+
import { type NodeProps } from '../../shared';
|
|
3
3
|
declare const _default: import("react").ForwardRefExoticComponent<Omit<NodeProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
4
|
export default _default;
|
|
@@ -12,12 +12,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
const
|
|
15
|
+
const shared_1 = require("../../shared");
|
|
16
16
|
const react_1 = require("react");
|
|
17
17
|
const Node = (_a, ref) => {
|
|
18
18
|
var _b, _c, _d, _e, _f, _g;
|
|
19
|
-
var { className = '',
|
|
20
|
-
const graphContext = (0, react_1.useContext)(
|
|
19
|
+
var { children, className = '', height: givenHeight, id: nodeId, shape: givenShape, style: { node: nodeStyle } = {}, width: givenWidth, x: givenX = 0, y: givenY = 0 } = _a, additionalProperties = __rest(_a, ["children", "className", "height", "id", "shape", "style", "width", "x", "y"]);
|
|
20
|
+
const graphContext = (0, react_1.useContext)(shared_1.GraphContext);
|
|
21
21
|
const defaultHeight = (_b = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _b === void 0 ? void 0 : _b.width;
|
|
22
22
|
const defaultShape = (_c = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _c === void 0 ? void 0 : _c.shape;
|
|
23
23
|
const defaultWidth = (_d = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _d === void 0 ? void 0 : _d.width;
|
|
@@ -30,8 +30,8 @@ const Node = (_a, ref) => {
|
|
|
30
30
|
var _a;
|
|
31
31
|
if (!(givenX || givenY)) {
|
|
32
32
|
const getNumber = /(-?\d+(\.\d+)?)/ug;
|
|
33
|
-
const [translateX, translateY] = (
|
|
34
|
-
(_a =
|
|
33
|
+
const [translateX, translateY] = (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.transform) ?
|
|
34
|
+
(_a = nodeStyle.transform.match(getNumber)) !== null && _a !== void 0 ? _a : [
|
|
35
35
|
undefined,
|
|
36
36
|
undefined
|
|
37
37
|
] :
|
|
@@ -39,11 +39,11 @@ const Node = (_a, ref) => {
|
|
|
39
39
|
undefined,
|
|
40
40
|
undefined
|
|
41
41
|
];
|
|
42
|
-
const left = (
|
|
43
|
-
|
|
42
|
+
const left = (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.left) ?
|
|
43
|
+
nodeStyle.left :
|
|
44
44
|
undefined;
|
|
45
|
-
const top = (
|
|
46
|
-
|
|
45
|
+
const top = (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.top) ?
|
|
46
|
+
nodeStyle.top :
|
|
47
47
|
undefined;
|
|
48
48
|
return {
|
|
49
49
|
x: Number(translateX) || Number(left) || 0,
|
|
@@ -57,7 +57,7 @@ const Node = (_a, ref) => {
|
|
|
57
57
|
}, [
|
|
58
58
|
givenX,
|
|
59
59
|
givenY,
|
|
60
|
-
|
|
60
|
+
nodeStyle
|
|
61
61
|
]);
|
|
62
62
|
(0, react_1.useEffect)(() => {
|
|
63
63
|
nodePositions === null || nodePositions === void 0 ? void 0 : nodePositions.register({
|
|
@@ -101,20 +101,20 @@ const Node = (_a, ref) => {
|
|
|
101
101
|
});
|
|
102
102
|
}, [
|
|
103
103
|
edgeSubscriber,
|
|
104
|
-
nodeId,
|
|
105
104
|
height,
|
|
105
|
+
nodeId,
|
|
106
|
+
shape,
|
|
106
107
|
width,
|
|
107
108
|
x,
|
|
108
|
-
y
|
|
109
|
-
shape
|
|
109
|
+
y
|
|
110
110
|
]);
|
|
111
111
|
const adjustedStyle = (0, react_1.useMemo)(() => {
|
|
112
|
-
return Object.assign(Object.assign({},
|
|
113
|
-
|
|
112
|
+
return Object.assign(Object.assign({}, nodeStyle), { height, transform: (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.transform) ?
|
|
113
|
+
nodeStyle.transform :
|
|
114
114
|
`translate(${x}px, ${y}px) translateZ(0)`, width });
|
|
115
115
|
}, [
|
|
116
|
-
style,
|
|
117
116
|
height,
|
|
117
|
+
nodeStyle,
|
|
118
118
|
width,
|
|
119
119
|
x,
|
|
120
120
|
y
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
8
5
|
const react_1 = require("react");
|
|
9
|
-
const Path = ({ children,
|
|
6
|
+
const Path = ({ children, className = '', diagramId, line, markerEnd, markerStart, source, style: { center: centerStyle, path: pathStyle } = {
|
|
7
|
+
center: {},
|
|
8
|
+
path: {}
|
|
9
|
+
}, target }) => {
|
|
10
10
|
const hasChildren = Boolean(children);
|
|
11
11
|
const origins = (0, react_1.useMemo)(() => {
|
|
12
12
|
if (source &&
|
|
13
13
|
target &&
|
|
14
14
|
line) {
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, shared_1.generateOrigins)(source, target, line, hasChildren);
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
}, [
|
|
@@ -24,9 +24,10 @@ const Path = ({ children, diagramId, className = '', line, markerEnd, markerStar
|
|
|
24
24
|
const center = (0, react_1.useMemo)(() => {
|
|
25
25
|
var _a, _b;
|
|
26
26
|
return (origins === null || origins === void 0 ? void 0 : origins.center) ?
|
|
27
|
-
((0, jsx_runtime_1.jsx)("g", { height: '1px', transform: `translate(${(_a = origins === null || origins === void 0 ? void 0 : origins.center) === null || _a === void 0 ? void 0 : _a.x},${(_b = origins === null || origins === void 0 ? void 0 : origins.center) === null || _b === void 0 ? void 0 : _b.y})`, width: '1px', children: children })) :
|
|
27
|
+
((0, jsx_runtime_1.jsx)("g", { height: '1px', style: centerStyle, transform: `translate(${(_a = origins === null || origins === void 0 ? void 0 : origins.center) === null || _a === void 0 ? void 0 : _a.x},${(_b = origins === null || origins === void 0 ? void 0 : origins.center) === null || _b === void 0 ? void 0 : _b.y})`, width: '1px', children: children })) :
|
|
28
28
|
undefined;
|
|
29
29
|
}, [
|
|
30
|
+
centerStyle,
|
|
30
31
|
children,
|
|
31
32
|
origins === null || origins === void 0 ? void 0 : origins.center
|
|
32
33
|
]);
|
|
@@ -38,7 +39,7 @@ const Path = ({ children, diagramId, className = '', line, markerEnd, markerStar
|
|
|
38
39
|
markerStart :
|
|
39
40
|
`url(#diagram-${diagramId ?
|
|
40
41
|
`${diagramId}-` :
|
|
41
|
-
''}marker-circle)
|
|
42
|
+
''}marker-circle)`, style: pathStyle })] }), center] }));
|
|
42
43
|
};
|
|
43
44
|
Path.displayName = 'LinclePath';
|
|
44
45
|
exports.default = Path;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Edge } from './Edge';
|
|
2
|
+
export { default as Edges } from './Edges';
|
|
3
|
+
export { default as Graph } from './Graph';
|
|
4
|
+
export { default as GraphContexts } from './GraphContexts';
|
|
5
|
+
export { default as Grid } from './Grid';
|
|
6
|
+
export { default as Node } from './Node';
|
|
7
|
+
export { default as Nodes } from './Nodes';
|
|
8
|
+
export { default as Path } from './Path';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Path = exports.Nodes = exports.Node = exports.Grid = exports.GraphContexts = exports.Graph = exports.Edges = exports.Edge = void 0;
|
|
7
|
+
var Edge_1 = require("./Edge");
|
|
8
|
+
Object.defineProperty(exports, "Edge", { enumerable: true, get: function () { return __importDefault(Edge_1).default; } });
|
|
9
|
+
var Edges_1 = require("./Edges");
|
|
10
|
+
Object.defineProperty(exports, "Edges", { enumerable: true, get: function () { return __importDefault(Edges_1).default; } });
|
|
11
|
+
var Graph_1 = require("./Graph");
|
|
12
|
+
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return __importDefault(Graph_1).default; } });
|
|
13
|
+
var GraphContexts_1 = require("./GraphContexts");
|
|
14
|
+
Object.defineProperty(exports, "GraphContexts", { enumerable: true, get: function () { return __importDefault(GraphContexts_1).default; } });
|
|
15
|
+
var Grid_1 = require("./Grid");
|
|
16
|
+
Object.defineProperty(exports, "Grid", { enumerable: true, get: function () { return __importDefault(Grid_1).default; } });
|
|
17
|
+
var Node_1 = require("./Node");
|
|
18
|
+
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return __importDefault(Node_1).default; } });
|
|
19
|
+
var Nodes_1 = require("./Nodes");
|
|
20
|
+
Object.defineProperty(exports, "Nodes", { enumerable: true, get: function () { return __importDefault(Nodes_1).default; } });
|
|
21
|
+
var Path_1 = require("./Path");
|
|
22
|
+
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return __importDefault(Path_1).default; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,99 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const Edge: FunctionComponent<EdgeProps>;
|
|
4
|
-
declare const Edges: FunctionComponent<EdgesProps>;
|
|
5
|
-
declare const Graph: FunctionComponent<GraphProps>;
|
|
6
|
-
declare const GraphContexts: FunctionComponent<GraphContextsProps>;
|
|
7
|
-
declare const Grid: FunctionComponent<GridProps>;
|
|
8
|
-
declare const Node: FunctionComponent<NodeProps>;
|
|
9
|
-
declare const Nodes: FunctionComponent<NodesProps>;
|
|
10
|
-
declare const Path: FunctionComponent<PathProps>;
|
|
11
|
-
export type Line = 'curve' | 'direct' | 'step';
|
|
12
|
-
export type Shape = 'oval' | 'rectangle';
|
|
13
|
-
export type EdgeProps = {
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
className?: string;
|
|
16
|
-
dash?: Boolean;
|
|
17
|
-
id: number | string;
|
|
18
|
-
line?: Line;
|
|
19
|
-
markerEnd?: string;
|
|
20
|
-
markerStart?: string;
|
|
21
|
-
path?: (source?: EdgeNodeProps, target?: EdgeNodeProps, children?: ReactNode) => ReactElement;
|
|
22
|
-
sourceId: number | string;
|
|
23
|
-
targetId: number | string;
|
|
24
|
-
};
|
|
25
|
-
export type EdgesProps = {
|
|
26
|
-
children: Array<ReactElement<EdgeProps>> | ReactElement<EdgeProps>;
|
|
27
|
-
dash?: Boolean;
|
|
28
|
-
};
|
|
29
|
-
export type PathProps = {
|
|
30
|
-
children?: ReactNode;
|
|
31
|
-
className?: string;
|
|
32
|
-
diagramId?: number | string;
|
|
33
|
-
id: number | string;
|
|
34
|
-
line?: Line;
|
|
35
|
-
markerEnd?: string;
|
|
36
|
-
markerStart?: string;
|
|
37
|
-
source?: EdgeNodeProps;
|
|
38
|
-
target?: EdgeNodeProps;
|
|
39
|
-
};
|
|
40
|
-
export type NodeProps = {
|
|
41
|
-
children?: ReactElement | ReactElement[];
|
|
42
|
-
className?: string;
|
|
43
|
-
height?: number;
|
|
44
|
-
id: number | string;
|
|
45
|
-
ref?: React.MutableRefObject<HTMLDivElement | null> | ((instance: HTMLDivElement | null) => void) | null;
|
|
46
|
-
shape?: Shape;
|
|
47
|
-
style?: CSSProperties;
|
|
48
|
-
width?: number;
|
|
49
|
-
x?: number;
|
|
50
|
-
y?: number;
|
|
51
|
-
};
|
|
52
|
-
export type NodesProps = {
|
|
53
|
-
children: Array<ReactElement<NodeProps>> | ReactElement<NodeProps>;
|
|
54
|
-
};
|
|
55
|
-
export type GridType = [
|
|
56
|
-
number,
|
|
57
|
-
number
|
|
58
|
-
];
|
|
59
|
-
export type GridContextProps = GridType;
|
|
60
|
-
export type GridProps = {
|
|
61
|
-
children?: ReactNode;
|
|
62
|
-
scale?: number;
|
|
63
|
-
xOffset?: number;
|
|
64
|
-
yOffset?: number;
|
|
65
|
-
};
|
|
66
|
-
export type GraphProps = {
|
|
67
|
-
children?: ReactNode | ReactNode[];
|
|
68
|
-
edgeFrequency?: number;
|
|
69
|
-
grid?: GridType | false;
|
|
70
|
-
id: number | string;
|
|
71
|
-
line?: Line;
|
|
72
|
-
nodeFrequency?: number;
|
|
73
|
-
nodeHeight?: number;
|
|
74
|
-
nodeWidth?: number;
|
|
75
|
-
shape?: Shape;
|
|
76
|
-
};
|
|
77
|
-
export type Dimensions = {
|
|
78
|
-
height: number;
|
|
79
|
-
id: number | string;
|
|
80
|
-
shape: Shape;
|
|
81
|
-
width: number;
|
|
82
|
-
x: number;
|
|
83
|
-
y: number;
|
|
84
|
-
};
|
|
85
|
-
export type Size = {
|
|
86
|
-
bottom: number;
|
|
87
|
-
height: number;
|
|
88
|
-
left: number;
|
|
89
|
-
right: number;
|
|
90
|
-
top: number;
|
|
91
|
-
width: number;
|
|
92
|
-
};
|
|
93
|
-
export type NodesDimensions = {
|
|
94
|
-
[key: string]: Dimensions;
|
|
95
|
-
};
|
|
96
|
-
export type GraphContextsProps = Omit<GraphProps, 'children'> & {
|
|
97
|
-
children: ReactElement<GraphProps> | ReactNode | ReactNode[];
|
|
98
|
-
};
|
|
99
|
-
export { Edge, Edges, Graph, GraphContexts, Grid, Node, Nodes, Path };
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './shared';
|