@lincle/react-native-base 0.0.1 → 0.4.0-next.2

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 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/lincle/lincle/commits/master"><img alt="Build Status" src="https://gitlab.com/lincle/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/lincle/lincle/badges/master/coverage.svg" /></a>
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/lincle/lincle/-/raw/master/static/simple.png">
49
- <img src="https://gitlab.com/lincle/lincle/-/raw/master/static/simple.png" alt="resulting screenshot of simple example" style="max-width:100%;">
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
 
@@ -0,0 +1,4 @@
1
+ import { type EdgeProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Edge: FunctionComponent<EdgeProps>;
4
+ export default Edge;
@@ -0,0 +1,40 @@
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 shared_1 = require("../../shared");
8
+ const Path_1 = __importDefault(require("../Path"));
9
+ const react_1 = require("react");
10
+ const Edge = ({ children, id: edgeId, line: givenLine, markerEnd, markerStart, path, sourceId, targetId }) => {
11
+ var _a, _b, _c, _d;
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
+ const line = givenLine !== null && givenLine !== void 0 ? givenLine : defaultLine;
16
+ const [source, setSource] = (0, react_1.useState)();
17
+ const [target, setTarget] = (0, react_1.useState)();
18
+ (0, react_1.useEffect)(() => {
19
+ setSource(edgeSubscriber === null || edgeSubscriber === void 0 ? void 0 : edgeSubscriber.register(edgeId, sourceId, setSource));
20
+ setTarget(edgeSubscriber === null || edgeSubscriber === void 0 ? void 0 : edgeSubscriber.register(edgeId, targetId, setTarget));
21
+ return () => {
22
+ edgeSubscriber === null || edgeSubscriber === void 0 ? void 0 : edgeSubscriber.unregister(edgeId, sourceId);
23
+ edgeSubscriber === null || edgeSubscriber === void 0 ? void 0 : edgeSubscriber.unregister(edgeId, targetId);
24
+ };
25
+ }, []);
26
+ const pathSource = source ? Object.assign(Object.assign({}, source), { x: source.x, y: source.y }) :
27
+ undefined;
28
+ const pathTarget = target ? Object.assign(Object.assign({}, target), { x: target.x, y: target.y }) :
29
+ undefined;
30
+ if (source &&
31
+ target) {
32
+ if (path) {
33
+ return path(pathSource, pathTarget, children);
34
+ }
35
+ return ((0, jsx_runtime_1.jsx)(Path_1.default, { diagramId: diagramId, id: edgeId, line: line, markerEnd: markerEnd, markerStart: markerStart, source: pathSource, target: pathTarget, children: children }));
36
+ }
37
+ return null;
38
+ };
39
+ Edge.displayName = 'LincleEdge';
40
+ exports.default = Edge;
@@ -0,0 +1,5 @@
1
+ import { type EdgesProps as EdgesPartialProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Edges: FunctionComponent<EdgesProps>;
4
+ export default Edges;
5
+ export type EdgesProps = EdgesPartialProps & {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const jsx_runtime_1 = require("react/jsx-runtime");
27
+ const shared_1 = require("../../shared");
28
+ const react_1 = require("react");
29
+ const react_native_svg_1 = __importStar(require("react-native-svg"));
30
+ const styles = {
31
+ edges: {
32
+ backfaceVisibility: 'hidden',
33
+ overflow: 'visible',
34
+ zIndex: -1
35
+ }
36
+ };
37
+ const Edges = ({ children }) => {
38
+ var _a;
39
+ const id = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
40
+ const markerId = (0, react_1.useMemo)(() => {
41
+ return id ?
42
+ `${id}-` :
43
+ '';
44
+ }, [
45
+ id
46
+ ]);
47
+ return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { style: styles.edges, children: [(0, jsx_runtime_1.jsxs)(react_native_svg_1.Defs, { children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Marker, { id: `diagram-${markerId}marker-arrow`, markerHeight: '10', markerUnits: 'strokeWidth', markerWidth: '10', orient: 'auto', refX: '9', refY: '5', children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Path, { d: 'M 0 0 L 10 5 L 0 10 z', fill: 'black' }) }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Marker, { id: `diagram-${markerId}marker-circle`, markerHeight: '10', markerUnits: 'strokeWidth', markerWidth: '10', orient: 'auto', refX: '5', refY: '5', children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: '5', cy: '5', fill: 'black', r: '3' }) })] }), children] }));
48
+ };
49
+ Edges.displayName = 'LincleEdges';
50
+ exports.default = Edges;
@@ -0,0 +1,4 @@
1
+ import { type GraphProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Graph: FunctionComponent<GraphProps>;
4
+ export default Graph;
@@ -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;
@@ -0,0 +1,4 @@
1
+ import { type GraphContextsProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const GraphContexts: FunctionComponent<GraphContextsProps>;
4
+ export default GraphContexts;
@@ -0,0 +1,45 @@
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 shared_1 = require("../../shared");
8
+ const Grid_1 = __importDefault(require("../Grid"));
9
+ const react_1 = require("react");
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
+ const diagramId = (0, react_1.useMemo)(() => {
12
+ return id;
13
+ }, []);
14
+ const permanent = (0, react_1.useMemo)(() => {
15
+ return {
16
+ diagramId,
17
+ edgeSubscriber: new shared_1.EdgeSubscriber(edgeFrequency),
18
+ nodePositions: new shared_1.NodePositions()
19
+ };
20
+ }, []);
21
+ const provides = (0, react_1.useMemo)(() => {
22
+ return Object.assign(Object.assign({}, permanent), { defaultSettings: {
23
+ edgeFrequency,
24
+ height: nodeHeight,
25
+ line,
26
+ nodeFrequency,
27
+ shape,
28
+ width: nodeWidth
29
+ } });
30
+ }, [
31
+ edgeFrequency,
32
+ line,
33
+ nodeFrequency,
34
+ nodeHeight,
35
+ nodeWidth,
36
+ permanent,
37
+ shape
38
+ ]);
39
+ const hiddenGrid = grid === false ?
40
+ children :
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 }));
43
+ };
44
+ GraphContexts.displayName = 'LincleGraphContexts';
45
+ exports.default = GraphContexts;
@@ -0,0 +1,4 @@
1
+ import { type GridProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Grid: FunctionComponent<GridProps>;
4
+ export default Grid;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const jsx_runtime_1 = require("react/jsx-runtime");
27
+ const shared_1 = require("../../shared");
28
+ const react_1 = require("react");
29
+ const react_native_svg_1 = __importStar(require("react-native-svg"));
30
+ const styles = {
31
+ grid: {
32
+ height: '100%',
33
+ position: 'absolute',
34
+ width: '100%'
35
+ }
36
+ };
37
+ const SIZE = 0.4;
38
+ const Circle = ((0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: SIZE, cy: SIZE, fill: 'black', r: SIZE }));
39
+ const Grid = ({ children, scale = 1, xOffset: givenXOffset = 0, yOffset: givenYOffset = 0 }) => {
40
+ var _a;
41
+ const diagramId = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
42
+ const [givenGridX, givenGridY] = (0, react_1.useContext)(shared_1.GridContext) || shared_1.defaultSettings.grid;
43
+ const id = `lincle-grid-${diagramId}`;
44
+ const gridX = (0, react_1.useMemo)(() => {
45
+ return givenGridX * scale;
46
+ }, [
47
+ givenGridX,
48
+ scale
49
+ ]);
50
+ const gridY = (0, react_1.useMemo)(() => {
51
+ return givenGridY * scale;
52
+ }, [
53
+ givenGridY,
54
+ scale
55
+ ]);
56
+ const xOffset = (0, react_1.useMemo)(() => {
57
+ return givenXOffset % gridX;
58
+ }, [
59
+ givenXOffset,
60
+ gridX
61
+ ]);
62
+ const yOffset = (0, react_1.useMemo)(() => {
63
+ return givenYOffset % gridY;
64
+ }, [
65
+ givenYOffset,
66
+ gridY
67
+ ]);
68
+ return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { style: styles.grid, children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.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)(react_native_svg_1.Rect, { fill: `url(#${id})`, height: '100%', width: '100%', x: '0', y: '0' })] }));
69
+ };
70
+ Grid.displayName = 'LincleGrid';
71
+ exports.default = Grid;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { type NodeProps } from '../../shared';
3
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<NodeProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default _default;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const shared_1 = require("../../shared");
16
+ const react_1 = require("react");
17
+ const react_native_1 = require("react-native");
18
+ const Node = (_a, ref) => {
19
+ var _b, _c, _d, _e, _f, _g;
20
+ var { children, height: givenHeight, id: nodeId, shape: givenShape, style: { node: nodeStyle } = {}, track = true, width: givenWidth, x: givenX = 0, y: givenY = 0 } = _a, additionalProperties = __rest(_a, ["children", "height", "id", "shape", "style", "track", "width", "x", "y"]);
21
+ const graphContext = (0, react_1.useContext)(shared_1.GraphContext);
22
+ const defaultHeight = (_b = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _b === void 0 ? void 0 : _b.width;
23
+ const defaultShape = (_c = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _c === void 0 ? void 0 : _c.shape;
24
+ const defaultWidth = (_d = graphContext === null || graphContext === void 0 ? void 0 : graphContext.defaultSettings) === null || _d === void 0 ? void 0 : _d.width;
25
+ const edgeSubscriber = graphContext === null || graphContext === void 0 ? void 0 : graphContext.edgeSubscriber;
26
+ const nodePositions = graphContext === null || graphContext === void 0 ? void 0 : graphContext.nodePositions;
27
+ const height = (_e = givenHeight !== null && givenHeight !== void 0 ? givenHeight : defaultHeight) !== null && _e !== void 0 ? _e : 0;
28
+ const shape = (_f = givenShape !== null && givenShape !== void 0 ? givenShape : defaultShape) !== null && _f !== void 0 ? _f : 'oval';
29
+ const width = (_g = givenWidth !== null && givenWidth !== void 0 ? givenWidth : defaultWidth) !== null && _g !== void 0 ? _g : 0;
30
+ const { x, y } = (0, react_1.useMemo)(() => {
31
+ var _a;
32
+ if (!(givenX || givenY)) {
33
+ const getNumber = /(-?\d+(\.\d+)?)/ug;
34
+ const transform = nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.transform;
35
+ const [translateX, translateY] = transform ?
36
+ (_a = transform.match(getNumber)) !== null && _a !== void 0 ? _a : [
37
+ undefined,
38
+ undefined
39
+ ] :
40
+ [
41
+ undefined,
42
+ undefined
43
+ ];
44
+ const left = (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.left) ?
45
+ nodeStyle.left :
46
+ undefined;
47
+ const top = (nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.top) ?
48
+ nodeStyle.top :
49
+ undefined;
50
+ return {
51
+ x: Number(translateX) || Number(left) || 0,
52
+ y: Number(translateY) || Number(top) || 0
53
+ };
54
+ }
55
+ return {
56
+ x: givenX,
57
+ y: givenY
58
+ };
59
+ }, [
60
+ givenX,
61
+ givenY,
62
+ nodeStyle
63
+ ]);
64
+ (0, react_1.useEffect)(() => {
65
+ nodePositions === null || nodePositions === void 0 ? void 0 : nodePositions.register({
66
+ height,
67
+ id: nodeId,
68
+ shape,
69
+ width,
70
+ x,
71
+ y
72
+ });
73
+ return () => {
74
+ nodePositions === null || nodePositions === void 0 ? void 0 : nodePositions.unregister(nodeId);
75
+ };
76
+ }, []);
77
+ (0, react_1.useEffect)(() => {
78
+ nodePositions === null || nodePositions === void 0 ? void 0 : nodePositions.update({
79
+ height,
80
+ id: nodeId,
81
+ shape,
82
+ width,
83
+ x,
84
+ y
85
+ });
86
+ }, [
87
+ height,
88
+ nodeId,
89
+ nodePositions,
90
+ shape,
91
+ width,
92
+ x,
93
+ y
94
+ ]);
95
+ (0, react_1.useEffect)(() => {
96
+ edgeSubscriber === null || edgeSubscriber === void 0 ? void 0 : edgeSubscriber.update({
97
+ height,
98
+ id: nodeId,
99
+ shape,
100
+ width,
101
+ x,
102
+ y
103
+ });
104
+ }, [
105
+ edgeSubscriber,
106
+ height,
107
+ nodeId,
108
+ shape,
109
+ width,
110
+ x,
111
+ y
112
+ ]);
113
+ const adjustedStyle = (0, react_1.useMemo)(() => {
114
+ return Object.assign(Object.assign({}, nodeStyle), { height, position: track ?
115
+ 'absolute' :
116
+ 'relative', transform: track ?
117
+ ((nodeStyle === null || nodeStyle === void 0 ? void 0 : nodeStyle.transform) ?
118
+ nodeStyle.transform :
119
+ `translate(${x}px, ${y}px)`) :
120
+ 'translate(0px, 0px)', transformOrigin: '0 0', width });
121
+ }, [
122
+ height,
123
+ nodeStyle,
124
+ track,
125
+ width,
126
+ x,
127
+ y
128
+ ]);
129
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, Object.assign({ "data-testid": `node-${nodeId}`, ref: ref, role: 'none', style: adjustedStyle }, additionalProperties, { children: children })));
130
+ };
131
+ Node.displayName = 'LincleNode';
132
+ exports.default = (0, react_1.forwardRef)(Node);
@@ -0,0 +1,4 @@
1
+ import { type NodesProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Nodes: FunctionComponent<NodesProps>;
4
+ export default Nodes;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Nodes = ({ children }) => {
4
+ return children;
5
+ };
6
+ Nodes.displayName = 'LincleNodes';
7
+ exports.default = Nodes;
@@ -0,0 +1,4 @@
1
+ import { type PathProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Path: FunctionComponent<PathProps>;
4
+ export default Path;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const shared_1 = require("../../shared");
5
+ const react_1 = require("react");
6
+ const react_native_svg_1 = require("react-native-svg");
7
+ const Path = ({ children, diagramId, line, markerEnd, markerStart, source, style: { center: centerStyle } = {}, target }) => {
8
+ const hasChildren = Boolean(children);
9
+ const origins = (0, react_1.useMemo)(() => {
10
+ if (source &&
11
+ target &&
12
+ line) {
13
+ return (0, shared_1.generateOrigins)(source, target, line, hasChildren);
14
+ }
15
+ return undefined;
16
+ }, [
17
+ hasChildren,
18
+ line,
19
+ source,
20
+ target
21
+ ]);
22
+ const center = (0, react_1.useMemo)(() => {
23
+ var _a, _b;
24
+ return (origins === null || origins === void 0 ? void 0 : origins.center) ?
25
+ ((0, jsx_runtime_1.jsx)(react_native_svg_1.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 })) :
26
+ undefined;
27
+ }, [
28
+ children,
29
+ origins === null || origins === void 0 ? void 0 : origins.center,
30
+ centerStyle
31
+ ]);
32
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_native_svg_1.G, { children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Path, { d: origins === null || origins === void 0 ? void 0 : origins.path, fill: 'transparent', id: diagramId + '1', opacity: 0, pointerEvents: 'auto', stroke: 'black', strokeWidth: 30 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Path, { d: origins === null || origins === void 0 ? void 0 : origins.path, fill: 'transparent', id: diagramId + '2', markerEnd: markerEnd ?
33
+ markerEnd :
34
+ `url(#diagram-${diagramId ?
35
+ `${diagramId}-` :
36
+ ''}marker-arrow)`, markerStart: markerStart ?
37
+ markerStart :
38
+ `url(#diagram-${diagramId ?
39
+ `${diagramId}-` :
40
+ ''}marker-circle)`, stroke: 'black' })] }), center] }));
41
+ };
42
+ Path.displayName = 'LinclePath';
43
+ 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; } });
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './shared';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components"), exports);
18
+ __exportStar(require("./shared"), exports);
@@ -0,0 +1,19 @@
1
+ import { type EdgeProps as SharedEdgeProps, type NodeProps as SharedNodeProps, type PathProps as SharedPathProps } from '@lincle/react-shared';
2
+ import { type ViewStyle } from 'react-native';
3
+ export type EdgeProps = SharedEdgeProps & {
4
+ style?: {
5
+ edge?: ViewStyle;
6
+ };
7
+ };
8
+ export type NodeProps = SharedNodeProps & {
9
+ style?: {
10
+ node?: ViewStyle;
11
+ };
12
+ };
13
+ export type PathProps = SharedPathProps & {
14
+ style?: {
15
+ center?: ViewStyle;
16
+ path?: ViewStyle;
17
+ };
18
+ };
19
+ export { defaultSettings, type EdgeNodeProps, type EdgesProps, EdgeSubscriber, generateOrigins, GraphContext, type GraphContextsProps, type GraphProps, GridContext, type GridProps, type Line, NodePositions, type NodesProps } from '@lincle/react-shared';
package/dist/shared.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodePositions = exports.GridContext = exports.GraphContext = exports.generateOrigins = exports.EdgeSubscriber = exports.defaultSettings = void 0;
4
+ var react_shared_1 = require("@lincle/react-shared");
5
+ Object.defineProperty(exports, "defaultSettings", { enumerable: true, get: function () { return react_shared_1.defaultSettings; } });
6
+ Object.defineProperty(exports, "EdgeSubscriber", { enumerable: true, get: function () { return react_shared_1.EdgeSubscriber; } });
7
+ Object.defineProperty(exports, "generateOrigins", { enumerable: true, get: function () { return react_shared_1.generateOrigins; } });
8
+ Object.defineProperty(exports, "GraphContext", { enumerable: true, get: function () { return react_shared_1.GraphContext; } });
9
+ Object.defineProperty(exports, "GridContext", { enumerable: true, get: function () { return react_shared_1.GridContext; } });
10
+ Object.defineProperty(exports, "NodePositions", { enumerable: true, get: function () { return react_shared_1.NodePositions; } });
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "name": "@lincle/react-native-base",
3
3
  "title": "lincle react native base",
4
4
  "license": "LGPL-3.0-or-later",
5
- "version": "0.0.1",
5
+ "version": "0.4.0-next.2",
6
+ "private": false,
6
7
  "description": "A 'reactive' React node and edge generator",
7
8
  "author": "wallzero @wallzeroblog (http://wallzero.com)",
8
9
  "contributors": [
@@ -19,20 +20,19 @@
19
20
  "COPYING.md",
20
21
  "COPYING.LESSER.md"
21
22
  ],
22
- "homepage": "https://gitlab.com/lincle/lincle/tree/master/packages/react-native-base/",
23
+ "homepage": "https://gitlab.com/digested/lincle/tree/master/packages/react-native-base/",
23
24
  "repository": {
24
25
  "type": "git",
25
- "url": "https://gitlab.com/lincle/lincle.git"
26
+ "url": "https://gitlab.com/digested/lincle.git"
26
27
  },
27
28
  "bugs": {
28
- "url": "https://gitlab.com/lincle/lincle/issues"
29
+ "url": "https://gitlab.com/digested/lincle/issues"
29
30
  },
30
31
  "scripts": {
31
- "build": "run-s clean:dist build:prod build:styles",
32
+ "build": "run-s clean:dist build:prod",
32
33
  "build:prod": "tsc -p ./tsconfig.json",
33
- "build:watch": "run-s clean:dist build:prod build:styles build:watch:tsc",
34
+ "build:watch": "run-s clean:dist build:prod build:watch:tsc",
34
35
  "build:watch:tsc": "tsc -p ./tsconfig.json --watch --pretty --preserveWatchOutput",
35
- "build:styles": "ncp src/styles.g.css dist/styles.g.css",
36
36
  "----------------------------------------------------------------": "",
37
37
  "build:prod:config": "",
38
38
  "---------------------------------------------------------------": "",
@@ -43,40 +43,42 @@
43
43
  "clean:dist": "rimraf dist"
44
44
  },
45
45
  "devDependencies": {
46
- "@digest/eslint-config-jest": "^4.2.5",
47
- "@digest/eslint-config-react": "^4.2.5",
48
- "@digest/eslint-config-typescript": "^4.2.5",
49
- "@digest/jest-junit": "^4.2.5",
50
- "@digest/jest-react": "^4.2.5",
51
- "@digest/jest-typescript": "^4.2.5",
52
- "@digest/typescript": "^4.2.5",
53
- "@types/bezier-js": "^4.1.0",
54
- "@types/jest": "^29.5.4",
55
- "@types/lodash.throttle": "^4.1.6",
56
- "@types/lodash.debounce": "^4.0.6",
57
- "@types/node": "^20.5.9",
58
- "@types/react": "^18.2.21",
59
- "@types/react-native": "^0.72.3",
60
- "@types/react-test-renderer": "^18.0.1",
46
+ "@digest/eslint-config-jest": "^4.3.1",
47
+ "@digest/eslint-config-react": "^4.3.1",
48
+ "@digest/eslint-config-typescript": "^4.3.1",
49
+ "@digest/jest-junit": "^4.3.1",
50
+ "@digest/jest-react": "^4.3.1",
51
+ "@digest/jest-typescript": "^4.3.1",
52
+ "@digest/typescript": "^4.3.1",
53
+ "@types/bezier-js": "^4.1.3",
54
+ "@types/jest": "^29.5.12",
55
+ "@types/lodash.debounce": "^4.0.9",
56
+ "@types/lodash.throttle": "^4.1.9",
57
+ "@types/node": "^20.12.12",
58
+ "@types/react": "^18.3.2",
59
+ "@types/react-native": "^0.73.0",
60
+ "@types/react-test-renderer": "^18.3.0",
61
61
  "cross-env": "^7.0.3",
62
- "jest-environment-jsdom": "^29.6.2",
62
+ "jest-environment-jsdom": "^29.7.0",
63
63
  "jest-environment-jsdom-global": "^4.0.0",
64
64
  "ncp": "^2.0.0",
65
65
  "npm-run-all": "^4.1.5",
66
- "react": "^18.2.0",
67
- "react-native": "^0.72.5",
68
- "react-test-renderer": "^18.2.0",
69
- "rimraf": "^5.0.1"
66
+ "react": "^18.3.1",
67
+ "react-native": "^0.74.1",
68
+ "react-native-svg": "^15.3.0",
69
+ "react-test-renderer": "^18.3.1",
70
+ "rimraf": "^5.0.7"
70
71
  },
71
72
  "dependencies": {
72
- "@lincle/react-shared": "^0.0.1",
73
- "bezier-js": "^5.1.0",
73
+ "@lincle/react-shared": "^0.4.0-next.2",
74
+ "bezier-js": "^6.1.4",
74
75
  "lodash.debounce": "^4.0.8",
75
76
  "lodash.throttle": "^4.1.1"
76
77
  },
77
78
  "peerDependencies": {
78
79
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
79
- "react-native": "^0.72.5"
80
+ "react-native": "^0.72.0",
81
+ "react-native-svg": "^13.0.0"
80
82
  },
81
83
  "keywords": [
82
84
  "library",
@@ -92,5 +94,6 @@
92
94
  "dag",
93
95
  "acyclical graph",
94
96
  "cyclical graph"
95
- ]
97
+ ],
98
+ "gitHead": "c00bcd56556ee5599505cbeeebfdab06e4a8c552"
96
99
  }