@lincle/react-shared 0.0.1 → 0.4.0-next.10

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 (70) hide show
  1. package/LICENSE.md +165 -0
  2. package/dist/Contexts/EdgesContext.d.ts +22 -0
  3. package/dist/Contexts/EdgesContext.js +9 -0
  4. package/dist/Contexts/GraphContext.d.ts +17 -0
  5. package/dist/Contexts/GraphContext.js +19 -0
  6. package/dist/Contexts/index.d.ts +2 -0
  7. package/dist/Contexts/index.js +18 -0
  8. package/dist/Hooks/index.d.ts +13 -0
  9. package/dist/Hooks/index.js +29 -0
  10. package/dist/Hooks/useDefaultLine.d.ts +2 -0
  11. package/dist/Hooks/useDefaultLine.js +10 -0
  12. package/dist/Hooks/useDefaultNodeHeight.d.ts +2 -0
  13. package/dist/Hooks/useDefaultNodeHeight.js +10 -0
  14. package/dist/Hooks/useDefaultNodeWidth.d.ts +2 -0
  15. package/dist/Hooks/useDefaultNodeWidth.js +10 -0
  16. package/dist/Hooks/useDefaultShape.d.ts +2 -0
  17. package/dist/Hooks/useDefaultShape.js +10 -0
  18. package/dist/Hooks/useDiagramId.d.ts +2 -0
  19. package/dist/Hooks/useDiagramId.js +10 -0
  20. package/dist/Hooks/useEdge.d.ts +2 -0
  21. package/dist/Hooks/useEdge.js +10 -0
  22. package/dist/Hooks/useEdgeFrequency.d.ts +2 -0
  23. package/dist/Hooks/useEdgeFrequency.js +10 -0
  24. package/dist/Hooks/useEdgeSubscriber.d.ts +2 -0
  25. package/dist/Hooks/useEdgeSubscriber.js +10 -0
  26. package/dist/Hooks/useEdges.d.ts +2 -0
  27. package/dist/Hooks/useEdges.js +10 -0
  28. package/dist/Hooks/useGrid.d.ts +2 -0
  29. package/dist/Hooks/useGrid.js +10 -0
  30. package/dist/Hooks/useNodePositions.d.ts +2 -0
  31. package/dist/Hooks/useNodePositions.js +10 -0
  32. package/dist/Hooks/useRemoveEdge.d.ts +2 -0
  33. package/dist/Hooks/useRemoveEdge.js +10 -0
  34. package/dist/Hooks/useUpdateEdge.d.ts +2 -0
  35. package/dist/Hooks/useUpdateEdge.js +10 -0
  36. package/dist/Providers/EdgesProvider.d.ts +4 -0
  37. package/dist/Providers/EdgesProvider.js +46 -0
  38. package/dist/Providers/GraphProvider.d.ts +5 -0
  39. package/dist/Providers/GraphProvider.js +42 -0
  40. package/dist/Providers/Providers.d.ts +2 -0
  41. package/dist/Providers/Providers.js +18 -0
  42. package/dist/Providers/index.d.ts +5 -0
  43. package/dist/Providers/index.js +14 -0
  44. package/dist/defaultSettings.d.ts +12 -0
  45. package/dist/defaultSettings.js +15 -0
  46. package/dist/index.d.ts +5 -0
  47. package/dist/index.js +27 -0
  48. package/dist/types.d.ts +82 -0
  49. package/dist/types.js +2 -0
  50. package/dist/utils/EdgeSubscriber.d.ts +15 -0
  51. package/dist/utils/EdgeSubscriber.js +52 -0
  52. package/dist/utils/NodePositions.d.ts +31 -0
  53. package/dist/utils/NodePositions.js +226 -0
  54. package/dist/utils/Path/generateOrigins.d.ts +4 -0
  55. package/dist/utils/Path/generateOrigins.js +18 -0
  56. package/dist/utils/Path/lines/generateCurve.d.ts +17 -0
  57. package/dist/utils/Path/lines/generateCurve.js +50 -0
  58. package/dist/utils/Path/lines/generateDirect.d.ts +16 -0
  59. package/dist/utils/Path/lines/generateDirect.js +32 -0
  60. package/dist/utils/Path/lines/generatePoints.d.ts +15 -0
  61. package/dist/utils/Path/lines/generatePoints.js +111 -0
  62. package/dist/utils/Path/lines/generateStep.d.ts +17 -0
  63. package/dist/utils/Path/lines/generateStep.js +63 -0
  64. package/dist/utils/Path/lines/index.d.ts +4 -0
  65. package/dist/utils/Path/lines/index.js +12 -0
  66. package/dist/utils/Path/lines/types.d.ts +34 -0
  67. package/dist/utils/Path/lines/types.js +2 -0
  68. package/dist/utils/round.d.ts +2 -0
  69. package/dist/utils/round.js +9 -0
  70. package/package.json +29 -27
@@ -0,0 +1,14 @@
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.Providers = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const defaultSettings_1 = __importDefault(require("../defaultSettings"));
9
+ const Providers_1 = require("./Providers");
10
+ const Providers = ({ children, edgeFrequency = defaultSettings_1.default.edgeFrequency, grid = defaultSettings_1.default.grid, id, line = defaultSettings_1.default.line, nodeFrequency = defaultSettings_1.default.nodeFrequency, nodeHeight = defaultSettings_1.default.height, nodeWidth = defaultSettings_1.default.width, shape = defaultSettings_1.default.shape }) => {
11
+ return ((0, jsx_runtime_1.jsx)(Providers_1.GraphProvider, { edgeFrequency: edgeFrequency, grid: grid, id: id, line: line, nodeFrequency: nodeFrequency, nodeHeight: nodeHeight, nodeWidth: nodeWidth, shape: shape, children: (0, jsx_runtime_1.jsx)(Providers_1.EdgesProvider, { children: children }) }));
12
+ };
13
+ exports.Providers = Providers;
14
+ Providers.displayName = 'LincleProviders';
@@ -0,0 +1,12 @@
1
+ import { type Line, type Shape } from './types';
2
+ declare const _default: {
3
+ edgeFrequency: number;
4
+ grid: [number, number];
5
+ height: number;
6
+ line: Line;
7
+ nodeFrequency: number;
8
+ shape: Shape;
9
+ showGrid: boolean;
10
+ width: number;
11
+ };
12
+ export default _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ edgeFrequency: 16,
5
+ grid: [
6
+ 16,
7
+ 16
8
+ ],
9
+ height: 50,
10
+ line: 'step',
11
+ nodeFrequency: 16,
12
+ shape: 'oval',
13
+ showGrid: true,
14
+ width: 50
15
+ };
@@ -0,0 +1,5 @@
1
+ export { default as defaultSettings } from './defaultSettings';
2
+ export * from './Hooks';
3
+ export * from './Providers';
4
+ export * from './types';
5
+ export { default as generateOrigins } from './utils/Path/generateOrigins';
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.generateOrigins = exports.defaultSettings = void 0;
21
+ var defaultSettings_1 = require("./defaultSettings");
22
+ Object.defineProperty(exports, "defaultSettings", { enumerable: true, get: function () { return __importDefault(defaultSettings_1).default; } });
23
+ __exportStar(require("./Hooks"), exports);
24
+ __exportStar(require("./Providers"), exports);
25
+ __exportStar(require("./types"), exports);
26
+ var generateOrigins_1 = require("./utils/Path/generateOrigins");
27
+ Object.defineProperty(exports, "generateOrigins", { enumerable: true, get: function () { return __importDefault(generateOrigins_1).default; } });
@@ -0,0 +1,82 @@
1
+ import { type ProvidersProps } from './Providers';
2
+ import { type PropsWithChildren, type ReactElement, type ReactNode } from 'react';
3
+ export type GridType = [
4
+ number,
5
+ number
6
+ ];
7
+ export type Line = 'curve' | 'direct' | 'step';
8
+ export type Shape = 'oval' | 'rectangle';
9
+ export type EdgeNodeProps = {
10
+ height: number;
11
+ id: number | string;
12
+ shape: Shape;
13
+ width: number;
14
+ x: number;
15
+ y: number;
16
+ };
17
+ export type Size = {
18
+ bottom: number;
19
+ height: number;
20
+ left: number;
21
+ right: number;
22
+ top: number;
23
+ width: number;
24
+ };
25
+ export type NodesDimensions = {
26
+ [key: string]: Dimensions;
27
+ };
28
+ export type Dimensions = {
29
+ height: number;
30
+ id: number | string;
31
+ shape: Shape;
32
+ width: number;
33
+ x: number;
34
+ y: number;
35
+ };
36
+ export type GridContextProps = GridType;
37
+ export type EdgeProps = PropsWithChildren<{
38
+ dash?: boolean;
39
+ id: number | string;
40
+ line?: Line;
41
+ markerEnd?: string;
42
+ markerStart?: string;
43
+ path?: (source?: EdgeNodeProps, target?: EdgeNodeProps, children?: ReactNode) => ReactElement;
44
+ sourceId: number | string;
45
+ targetId: number | string;
46
+ }>;
47
+ export type EdgesProps = PropsWithChildren<{
48
+ readonly dash?: boolean;
49
+ readonly scale?: number;
50
+ readonly translate?: {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ }>;
55
+ export type PathProps = {
56
+ center?: boolean;
57
+ edgeId: string | number;
58
+ line?: Line;
59
+ markerEnd?: string;
60
+ markerStart?: string;
61
+ source?: EdgeNodeProps;
62
+ target?: EdgeNodeProps;
63
+ };
64
+ export type NodeProps = PropsWithChildren<{
65
+ height?: number;
66
+ id: number | string;
67
+ ref?: React.MutableRefObject<HTMLDivElement | null> | ((instance: HTMLDivElement | null) => void) | null;
68
+ shape?: Shape;
69
+ track?: boolean;
70
+ width?: number;
71
+ x?: number;
72
+ y?: number;
73
+ }>;
74
+ export type NodesProps = PropsWithChildren<{}>;
75
+ export type GridProps = PropsWithChildren<{
76
+ scale?: number;
77
+ xOffset?: number;
78
+ yOffset?: number;
79
+ }>;
80
+ export type GraphProps = ProvidersProps & {
81
+ showGrid?: boolean;
82
+ };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { type EdgeNodeProps } from '../types';
2
+ declare class EdgeSubscriber {
3
+ private frequency;
4
+ constructor(frequency?: number);
5
+ getFrequency: () => number;
6
+ setFrequency: (frequency: number) => number;
7
+ private nodes;
8
+ private propsCache;
9
+ register: <T>(edgeId: number | string, nodeId: number | string, updateFn: (update: T) => void) => EdgeNodeProps;
10
+ unregister: (edgeId: number | string, nodeId: number | string) => void;
11
+ private readonly updateEdges;
12
+ private throttleUpdates;
13
+ update: (props: EdgeNodeProps) => void;
14
+ }
15
+ export default EdgeSubscriber;
@@ -0,0 +1,52 @@
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 defaultSettings_1 = __importDefault(require("../defaultSettings"));
7
+ const lodash_throttle_1 = __importDefault(require("lodash.throttle"));
8
+ const FREQUENCY = defaultSettings_1.default.edgeFrequency;
9
+ class EdgeSubscriber {
10
+ constructor(frequency = FREQUENCY) {
11
+ this.getFrequency = () => {
12
+ return this.frequency;
13
+ };
14
+ this.setFrequency = (frequency) => {
15
+ this.frequency = frequency;
16
+ return this.frequency;
17
+ };
18
+ this.nodes = {};
19
+ this.propsCache = {};
20
+ this.register = (edgeId, nodeId, updateFn) => {
21
+ if (!this.nodes[nodeId]) {
22
+ this.nodes[nodeId] = {};
23
+ }
24
+ this.nodes[nodeId][edgeId] = updateFn;
25
+ return this.propsCache[nodeId];
26
+ };
27
+ this.unregister = (edgeId, nodeId) => {
28
+ delete this.nodes[nodeId][edgeId];
29
+ delete this.throttleUpdates[nodeId];
30
+ };
31
+ this.updateEdges = (props) => {
32
+ if (this.nodes[props.id]) {
33
+ for (const [_edgeId, update] of Object.entries(this.nodes[props.id])) {
34
+ update(props);
35
+ }
36
+ }
37
+ this.propsCache[props.id] = props;
38
+ };
39
+ this.throttleUpdates = {};
40
+ this.update = (props) => {
41
+ const { id } = props;
42
+ if (!this.throttleUpdates[id]) {
43
+ this.throttleUpdates[id] = (0, lodash_throttle_1.default)(this.updateEdges, this.frequency, {
44
+ trailing: true
45
+ });
46
+ }
47
+ this.throttleUpdates[id](props);
48
+ };
49
+ this.frequency = frequency;
50
+ }
51
+ }
52
+ exports.default = EdgeSubscriber;
@@ -0,0 +1,31 @@
1
+ import { type Dimensions, type NodesDimensions, type Size } from '../types';
2
+ declare class NodePositions {
3
+ private frequency;
4
+ private subscriptions;
5
+ getFrequency: () => number;
6
+ setFrequency: (frequency: number) => number;
7
+ private nodes;
8
+ constructor(frequency?: number);
9
+ subscribe: (id: string, callback: (size?: Size, nodes?: NodesDimensions) => void) => void;
10
+ unsubscribe: (id: string) => void;
11
+ register: (node: Dimensions, { maxWait }?: {
12
+ maxWait?: number | undefined;
13
+ }) => void;
14
+ unregister: (id: number | string) => void;
15
+ private top;
16
+ private readonly getTop;
17
+ private right;
18
+ private readonly getRight;
19
+ private bottom;
20
+ private readonly getBottom;
21
+ private left;
22
+ private readonly getLeft;
23
+ private readonly getSize;
24
+ private readonly privateUpdate;
25
+ private readonly notify;
26
+ private debounceUpdates;
27
+ update: (node: Dimensions) => void;
28
+ match: (x: number, y: number) => Promise<number | string | undefined>;
29
+ size: () => Size;
30
+ }
31
+ export default NodePositions;
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const defaultSettings_1 = __importDefault(require("../defaultSettings"));
16
+ const lodash_debounce_1 = __importDefault(require("lodash.debounce"));
17
+ const FREQUENCY = defaultSettings_1.default.nodeFrequency;
18
+ const MAX_WAIT = defaultSettings_1.default.nodeFrequency;
19
+ class NodePositions {
20
+ constructor(frequency = FREQUENCY) {
21
+ this.subscriptions = {};
22
+ this.getFrequency = () => {
23
+ return this.frequency;
24
+ };
25
+ this.setFrequency = (frequency) => {
26
+ this.frequency = frequency;
27
+ return this.frequency;
28
+ };
29
+ this.nodes = {};
30
+ this.subscribe = (id, callback) => {
31
+ this.subscriptions[id] = callback;
32
+ callback(this.size(), this.nodes);
33
+ };
34
+ this.unsubscribe = (id) => {
35
+ delete this.subscriptions[id];
36
+ };
37
+ this.register = (node, { maxWait = MAX_WAIT } = {}) => {
38
+ this.nodes[node.id] = node;
39
+ this.debounceUpdates[node.id] = (0, lodash_debounce_1.default)(this.privateUpdate, this.frequency, {
40
+ maxWait,
41
+ trailing: true
42
+ });
43
+ };
44
+ this.unregister = (id) => {
45
+ var _a, _b, _c, _d;
46
+ delete this.nodes[id];
47
+ delete this.debounceUpdates[id];
48
+ if (((_a = this.top) === null || _a === void 0 ? void 0 : _a.id) === id) {
49
+ this.top = undefined;
50
+ for (const nodeId of Object.keys(this.nodes)) {
51
+ if (!this.top ||
52
+ this.nodes[nodeId].y < this.top.y) {
53
+ this.top = this.nodes[nodeId];
54
+ }
55
+ }
56
+ }
57
+ if (((_b = this.right) === null || _b === void 0 ? void 0 : _b.id) === id) {
58
+ this.right = undefined;
59
+ for (const nodeId of Object.keys(this.nodes)) {
60
+ if (!this.right ||
61
+ this.nodes[nodeId].x + this.nodes[nodeId].height > this.right.x + this.right.width) {
62
+ this.right = this.nodes[nodeId];
63
+ }
64
+ }
65
+ }
66
+ if (((_c = this.bottom) === null || _c === void 0 ? void 0 : _c.id) === id) {
67
+ this.bottom = undefined;
68
+ for (const nodeId of Object.keys(this.nodes)) {
69
+ if (!this.bottom ||
70
+ this.nodes[nodeId].y + this.nodes[nodeId].height > this.bottom.y + this.bottom.height) {
71
+ this.bottom = this.nodes[nodeId];
72
+ }
73
+ }
74
+ }
75
+ if (((_d = this.left) === null || _d === void 0 ? void 0 : _d.id) === id) {
76
+ this.left = undefined;
77
+ for (const nodeId of Object.keys(this.nodes)) {
78
+ if (!this.left ||
79
+ this.nodes[nodeId].x < this.left.x) {
80
+ this.left = this.nodes[nodeId];
81
+ }
82
+ }
83
+ }
84
+ this.notify();
85
+ };
86
+ this.getTop = (node) => {
87
+ if (this.top &&
88
+ this.top.id === node.id) {
89
+ if (node.y > this.top.y) {
90
+ this.top = node;
91
+ for (const id of Object.keys(this.nodes)) {
92
+ if (this.top && this.nodes[id].y < this.top.y) {
93
+ this.top = this.nodes[id];
94
+ }
95
+ }
96
+ }
97
+ else {
98
+ this.top = node;
99
+ }
100
+ }
101
+ else if (!this.top ||
102
+ node.y < this.top.y) {
103
+ this.top = node;
104
+ }
105
+ };
106
+ this.getRight = (node) => {
107
+ const nodeX = node.x + node.width;
108
+ const rightNodeX = this.right ?
109
+ this.right.x + this.right.width :
110
+ undefined;
111
+ if (this.right &&
112
+ this.right.id === node.id) {
113
+ if (!rightNodeX ||
114
+ nodeX < rightNodeX) {
115
+ this.right = node;
116
+ for (const id of Object.keys(this.nodes)) {
117
+ if (this.nodes[id].x + this.nodes[id].width > this.right.x + this.right.width) {
118
+ this.right = this.nodes[id];
119
+ }
120
+ }
121
+ }
122
+ else {
123
+ this.right = node;
124
+ }
125
+ }
126
+ else if (!this.right ||
127
+ rightNodeX &&
128
+ nodeX > rightNodeX) {
129
+ this.right = node;
130
+ }
131
+ };
132
+ this.getBottom = (node) => {
133
+ const nodeY = node.y + node.height;
134
+ const bottomNodeY = this.bottom ?
135
+ this.bottom.y + this.bottom.height :
136
+ undefined;
137
+ if (this.bottom &&
138
+ this.bottom.id === node.id) {
139
+ if (!bottomNodeY ||
140
+ nodeY < bottomNodeY) {
141
+ this.bottom = node;
142
+ for (const id of Object.keys(this.nodes)) {
143
+ if (this.nodes[id].y + this.nodes[id].height > this.bottom.y + this.bottom.height) {
144
+ this.bottom = this.nodes[id];
145
+ }
146
+ }
147
+ }
148
+ else {
149
+ this.bottom = node;
150
+ }
151
+ }
152
+ else if (!this.bottom ||
153
+ bottomNodeY &&
154
+ nodeY > bottomNodeY) {
155
+ this.bottom = node;
156
+ }
157
+ };
158
+ this.getLeft = (node) => {
159
+ if (this.left &&
160
+ this.left.id === node.id) {
161
+ if (node.x > this.left.x) {
162
+ this.left = node;
163
+ for (const id of Object.keys(this.nodes)) {
164
+ if (this.nodes[id].x < this.left.x) {
165
+ this.left = this.nodes[id];
166
+ }
167
+ }
168
+ }
169
+ else {
170
+ this.left = node;
171
+ }
172
+ }
173
+ else if (!this.left ||
174
+ node.x < this.left.x) {
175
+ this.left = node;
176
+ }
177
+ };
178
+ this.getSize = (node) => {
179
+ this.getTop(node);
180
+ this.getRight(node);
181
+ this.getBottom(node);
182
+ this.getLeft(node);
183
+ };
184
+ this.privateUpdate = (node) => {
185
+ this.register(node);
186
+ this.getSize(node);
187
+ this.notify();
188
+ };
189
+ this.notify = () => {
190
+ for (const [_id, update] of Object.entries(this.subscriptions)) {
191
+ update(this.size(), this.nodes);
192
+ }
193
+ };
194
+ this.debounceUpdates = {};
195
+ this.update = (node) => {
196
+ this.debounceUpdates[node.id](node);
197
+ };
198
+ this.match = (x, y) => __awaiter(this, void 0, void 0, function* () {
199
+ const ids = yield Promise.resolve(Object.keys(this.nodes).find((id) => {
200
+ const node = this.nodes[id];
201
+ return x > node.x &&
202
+ x < node.x + node.width &&
203
+ y > node.y &&
204
+ y < node.y + node.height;
205
+ }));
206
+ return ids ?
207
+ ids :
208
+ undefined;
209
+ });
210
+ this.size = () => {
211
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
212
+ return {
213
+ bottom: ((_b = (_a = this.bottom) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = this.bottom) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0),
214
+ height: (((_f = (_e = this.bottom) === null || _e === void 0 ? void 0 : _e.y) !== null && _f !== void 0 ? _f : 0) +
215
+ ((_h = (_g = this.bottom) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : 0)) - ((_k = (_j = this.top) === null || _j === void 0 ? void 0 : _j.y) !== null && _k !== void 0 ? _k : 0),
216
+ left: (_m = (_l = this.left) === null || _l === void 0 ? void 0 : _l.x) !== null && _m !== void 0 ? _m : 0,
217
+ right: ((_p = (_o = this.right) === null || _o === void 0 ? void 0 : _o.x) !== null && _p !== void 0 ? _p : 0) + ((_r = (_q = this.right) === null || _q === void 0 ? void 0 : _q.width) !== null && _r !== void 0 ? _r : 0),
218
+ top: (_t = (_s = this.top) === null || _s === void 0 ? void 0 : _s.y) !== null && _t !== void 0 ? _t : 0,
219
+ width: (((_v = (_u = this.right) === null || _u === void 0 ? void 0 : _u.x) !== null && _v !== void 0 ? _v : 0) +
220
+ ((_x = (_w = this.right) === null || _w === void 0 ? void 0 : _w.width) !== null && _x !== void 0 ? _x : 0)) - ((_z = (_y = this.left) === null || _y === void 0 ? void 0 : _y.x) !== null && _z !== void 0 ? _z : 0)
221
+ };
222
+ };
223
+ this.frequency = frequency;
224
+ }
225
+ }
226
+ exports.default = NodePositions;
@@ -0,0 +1,4 @@
1
+ import { type EdgeNodeProps, type Line } from '../../types';
2
+ import { type Coordinates } from './lines';
3
+ declare const generateOrigins: (target: EdgeNodeProps, source: EdgeNodeProps, line: Line, center?: boolean) => Coordinates;
4
+ export default generateOrigins;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lines_1 = require("./lines");
4
+ const generateOrigins = (target, source, line, center) => {
5
+ switch (line) {
6
+ case 'curve': {
7
+ return (0, lines_1.generateCurve)(source, target, center);
8
+ }
9
+ case 'direct': {
10
+ return (0, lines_1.generateDirect)(source, target, center);
11
+ }
12
+ case 'step':
13
+ default: {
14
+ return (0, lines_1.generateStep)(source, target, center);
15
+ }
16
+ }
17
+ };
18
+ exports.default = generateOrigins;
@@ -0,0 +1,17 @@
1
+ import { type Coordinates, type Line } from './types';
2
+ export declare const curveHorizontal: (rx1: number, ry1: number, rx2: number, ry2: number, center?: boolean) => Line;
3
+ export declare const curveVertical: (rx1: number, ry1: number, rx2: number, ry2: number, center?: boolean) => Line;
4
+ declare const _default: (source: {
5
+ height: number;
6
+ shape: "oval" | "rectangle";
7
+ width: number;
8
+ x: number;
9
+ y: number;
10
+ }, target: {
11
+ height: number;
12
+ shape: "oval" | "rectangle";
13
+ width: number;
14
+ x: number;
15
+ y: number;
16
+ }, center?: boolean) => Coordinates;
17
+ export default _default;
@@ -0,0 +1,50 @@
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.curveVertical = exports.curveHorizontal = void 0;
7
+ const generatePoints_1 = __importDefault(require("./generatePoints"));
8
+ const bezier_js_1 = require("bezier-js");
9
+ const curveHorizontal = (rx1, ry1, rx2, ry2, center) => {
10
+ const x1 = Math.round(rx1);
11
+ const y1 = Math.round(ry1);
12
+ const x2 = Math.round(rx2);
13
+ const y2 = Math.round(ry2);
14
+ const d = [];
15
+ const mx = Math.round(x1 + (x2 - x1) / 2);
16
+ const c = center ?
17
+ new bezier_js_1.Bezier(x1, y1, mx, y1, mx, y2, x2, y2).compute(0.5) :
18
+ undefined;
19
+ d.push('M', x1, y1);
20
+ d.push('C', mx, y1, mx, y2, x2, y2);
21
+ return {
22
+ center: c,
23
+ path: d.join(' ')
24
+ };
25
+ };
26
+ exports.curveHorizontal = curveHorizontal;
27
+ const curveVertical = (rx1, ry1, rx2, ry2, center) => {
28
+ const x1 = Math.round(rx1);
29
+ const y1 = Math.round(ry1);
30
+ const x2 = Math.round(rx2);
31
+ const y2 = Math.round(ry2);
32
+ const d = [];
33
+ const my = Math.round(y1 + (y2 - y1) / 2);
34
+ const c = center ?
35
+ new bezier_js_1.Bezier(x1, y1, x1, my, x2, my, x2, y2).compute(0.5) :
36
+ undefined;
37
+ d.push('M', x1, y1);
38
+ d.push('C', x1, my, x2, my, x2, y2);
39
+ return {
40
+ center: c,
41
+ path: d.join(' ')
42
+ };
43
+ };
44
+ exports.curveVertical = curveVertical;
45
+ exports.default = (source, target, center) => {
46
+ const { orientation, source: sourcePoints, target: targetPoints } = (0, generatePoints_1.default)(source, target);
47
+ return Object.assign(Object.assign({}, (orientation === 'horizontal' ?
48
+ (0, exports.curveHorizontal)(sourcePoints.x, sourcePoints.y, targetPoints.x, targetPoints.y, center) :
49
+ (0, exports.curveVertical)(sourcePoints.x, sourcePoints.y, targetPoints.x, targetPoints.y, center))), { source: sourcePoints, target: targetPoints });
50
+ };
@@ -0,0 +1,16 @@
1
+ import { type Coordinates, type Line } from './types';
2
+ export declare const direct: (rx1: number, ry1: number, rx2: number, ry2: number, center?: boolean) => Line;
3
+ declare const _default: (source: {
4
+ height: number;
5
+ shape: "oval" | "rectangle";
6
+ width: number;
7
+ x: number;
8
+ y: number;
9
+ }, target: {
10
+ height: number;
11
+ shape: "oval" | "rectangle";
12
+ width: number;
13
+ x: number;
14
+ y: number;
15
+ }, center?: boolean) => Coordinates;
16
+ export default _default;
@@ -0,0 +1,32 @@
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.direct = void 0;
7
+ const generatePoints_1 = __importDefault(require("./generatePoints"));
8
+ const direct = (rx1, ry1, rx2, ry2, center) => {
9
+ const x1 = Math.round(rx1);
10
+ const y1 = Math.round(ry1);
11
+ const x2 = Math.round(rx2);
12
+ const y2 = Math.round(ry2);
13
+ const cx = Math.round((x2 + x1) / 2);
14
+ const cy = Math.round((y2 + y1) / 2);
15
+ const d = [];
16
+ d.push('M', x1, y1);
17
+ d.push('L', x2, y2);
18
+ return {
19
+ center: center ?
20
+ {
21
+ x: cx,
22
+ y: cy
23
+ } :
24
+ undefined,
25
+ path: d.join(' ')
26
+ };
27
+ };
28
+ exports.direct = direct;
29
+ exports.default = (source, target, center) => {
30
+ const { source: sourcePoints, target: targetPoints } = (0, generatePoints_1.default)(source, target);
31
+ return Object.assign(Object.assign({}, (0, exports.direct)(sourcePoints.x, sourcePoints.y, targetPoints.x, targetPoints.y, center)), { source: sourcePoints, target: targetPoints });
32
+ };
@@ -0,0 +1,15 @@
1
+ import { type Points } from './types';
2
+ declare const _default: (source: {
3
+ height: number;
4
+ shape: "oval" | "rectangle";
5
+ width: number;
6
+ x: number;
7
+ y: number;
8
+ }, target: {
9
+ height: number;
10
+ shape: "oval" | "rectangle";
11
+ width: number;
12
+ x: number;
13
+ y: number;
14
+ }) => Points;
15
+ export default _default;