@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.
Files changed (40) hide show
  1. package/LICENSE.md +165 -0
  2. package/README.md +4 -4
  3. package/dist/{Edge → components/Edge}/index.d.ts +1 -1
  4. package/dist/{Edge → components/Edge}/index.js +4 -4
  5. package/dist/{Edges → components/Edges}/index.d.ts +1 -1
  6. package/dist/{Edges → components/Edges}/index.js +3 -3
  7. package/dist/{Graph → components/Graph}/index.d.ts +1 -1
  8. package/dist/components/Graph/index.js +16 -0
  9. package/dist/{GraphContexts → components/GraphContexts}/index.d.ts +1 -1
  10. package/dist/{GraphContexts → components/GraphContexts}/index.js +10 -11
  11. package/dist/{Grid → components/Grid}/index.d.ts +1 -1
  12. package/dist/{Grid → components/Grid}/index.js +7 -7
  13. package/dist/{Node → components/Node}/index.d.ts +1 -1
  14. package/dist/{Node → components/Node}/index.js +16 -16
  15. package/dist/{Nodes → components/Nodes}/index.d.ts +1 -1
  16. package/dist/{Path → components/Path}/index.d.ts +1 -1
  17. package/dist/{Path → components/Path}/index.js +9 -8
  18. package/dist/components/index.d.ts +8 -0
  19. package/dist/components/index.js +22 -0
  20. package/dist/index.d.ts +2 -99
  21. package/dist/index.js +15 -27
  22. package/dist/shared.d.ts +22 -0
  23. package/dist/shared.js +10 -0
  24. package/package.json +25 -24
  25. package/dist/Graph/index.js +0 -22
  26. package/dist/Path/generateOrigins.d.ts +0 -5
  27. package/dist/Path/generateOrigins.js +0 -18
  28. package/dist/Path/lines/generateCurve.d.ts +0 -17
  29. package/dist/Path/lines/generateCurve.js +0 -50
  30. package/dist/Path/lines/generateDirect.d.ts +0 -16
  31. package/dist/Path/lines/generateDirect.js +0 -32
  32. package/dist/Path/lines/generatePoints.d.ts +0 -15
  33. package/dist/Path/lines/generatePoints.js +0 -111
  34. package/dist/Path/lines/generateStep.d.ts +0 -17
  35. package/dist/Path/lines/generateStep.js +0 -63
  36. package/dist/Path/lines/index.d.ts +0 -4
  37. package/dist/Path/lines/index.js +0 -12
  38. package/dist/Path/lines/types.d.ts +0 -34
  39. package/dist/Path/lines/types.js +0 -2
  40. /package/dist/{Nodes → components/Nodes}/index.js +0 -0
package/dist/index.js CHANGED
@@ -1,30 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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);
4
15
  };
5
16
  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
- const Edge_1 = __importDefault(require("./Edge"));
8
- const Edges_1 = __importDefault(require("./Edges"));
9
- const Graph_1 = __importDefault(require("./Graph"));
10
- const GraphContexts_1 = __importDefault(require("./GraphContexts"));
11
- const Grid_1 = __importDefault(require("./Grid"));
12
- const Node_1 = __importDefault(require("./Node"));
13
- const Nodes_1 = __importDefault(require("./Nodes"));
14
- const Path_1 = __importDefault(require("./Path"));
15
- const Edge = Edge_1.default;
16
- exports.Edge = Edge;
17
- const Edges = Edges_1.default;
18
- exports.Edges = Edges;
19
- const Graph = Graph_1.default;
20
- exports.Graph = Graph;
21
- const GraphContexts = GraphContexts_1.default;
22
- exports.GraphContexts = GraphContexts;
23
- const Grid = Grid_1.default;
24
- exports.Grid = Grid;
25
- const Node = Node_1.default;
26
- exports.Node = Node;
27
- const Nodes = Nodes_1.default;
28
- exports.Nodes = Nodes;
29
- const Path = Path_1.default;
30
- exports.Path = Path;
17
+ __exportStar(require("./components"), exports);
18
+ __exportStar(require("./shared"), exports);
@@ -0,0 +1,22 @@
1
+ import { type EdgeProps as SharedEdgeProps, type NodeProps as SharedNodeProps, type PathProps as SharedPathProps } from '@lincle/react-shared';
2
+ import { type CSSProperties } from 'react';
3
+ export type EdgeProps = SharedEdgeProps & {
4
+ className?: string;
5
+ style?: {
6
+ edge?: CSSProperties;
7
+ };
8
+ };
9
+ export type NodeProps = SharedNodeProps & {
10
+ className?: string;
11
+ style?: {
12
+ node?: CSSProperties;
13
+ };
14
+ };
15
+ export type PathProps = SharedPathProps & {
16
+ className?: string;
17
+ style?: {
18
+ center?: CSSProperties;
19
+ path?: CSSProperties;
20
+ };
21
+ };
22
+ 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-web-base",
3
3
  "title": "lincle react web base",
4
4
  "license": "LGPL-3.0-or-later",
5
- "version": "0.0.1",
5
+ "version": "0.4.0-next.1",
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,13 +20,13 @@
19
20
  "COPYING.md",
20
21
  "COPYING.LESSER.md"
21
22
  ],
22
- "homepage": "https://gitlab.com/lincle/lincle/tree/master/packages/react-web-base/",
23
+ "homepage": "https://gitlab.com/digested/lincle/tree/master/packages/react-web-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
32
  "build": "run-s clean:dist build:prod build:styles",
@@ -43,34 +44,33 @@
43
44
  "clean:dist": "rimraf dist"
44
45
  },
45
46
  "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-dom": "^18.2.7",
60
- "@types/react-test-renderer": "^18.0.1",
47
+ "@digest/eslint-config-jest": "^4.3.0",
48
+ "@digest/eslint-config-react": "^4.3.0",
49
+ "@digest/eslint-config-typescript": "^4.3.0",
50
+ "@digest/jest-junit": "^4.3.0",
51
+ "@digest/jest-react": "^4.3.0",
52
+ "@digest/jest-typescript": "^4.3.0",
53
+ "@digest/typescript": "^4.3.0",
54
+ "@types/bezier-js": "^4.1.3",
55
+ "@types/jest": "^29.5.12",
56
+ "@types/lodash.debounce": "^4.0.9",
57
+ "@types/lodash.throttle": "^4.1.9",
58
+ "@types/node": "^20.12.4",
59
+ "@types/react": "^18.2.74",
60
+ "@types/react-dom": "^18.2.24",
61
+ "@types/react-test-renderer": "^18.0.7",
61
62
  "cross-env": "^7.0.3",
62
- "jest-environment-jsdom": "^29.6.2",
63
+ "jest-environment-jsdom": "^29.7.0",
63
64
  "jest-environment-jsdom-global": "^4.0.0",
64
65
  "ncp": "^2.0.0",
65
66
  "npm-run-all": "^4.1.5",
66
67
  "react": "^18.2.0",
67
68
  "react-dom": "^18.2.0",
68
69
  "react-test-renderer": "^18.2.0",
69
- "rimraf": "^5.0.1"
70
+ "rimraf": "^5.0.5"
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.1",
74
74
  "lodash.debounce": "^4.0.8",
75
75
  "lodash.throttle": "^4.1.1"
76
76
  },
@@ -92,5 +92,6 @@
92
92
  "dag",
93
93
  "acyclical graph",
94
94
  "cyclical graph"
95
- ]
95
+ ],
96
+ "gitHead": "7c1adb4075c272515a8d04b45a9ba829c1c1b1e6"
96
97
  }
@@ -1,22 +0,0 @@
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 react_shared_1 = require("@lincle/react-shared");
9
- const react_1 = require("react");
10
- const Graph = ({ children, edgeFrequency, grid, id, line, nodeFrequency, nodeHeight, nodeWidth, shape }) => {
11
- var _a;
12
- const diagramId = (_a = (0, react_1.useContext)(react_shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
13
- if (!diagramId && !id) {
14
- console.error('No ID provided to @lincle/base Graph!');
15
- return null;
16
- }
17
- return diagramId ?
18
- ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })) :
19
- ((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 }));
20
- };
21
- Graph.displayName = 'LincleGraph';
22
- exports.default = Graph;
@@ -1,5 +0,0 @@
1
- import { type Line } from '..';
2
- import { type Coordinates } from './lines';
3
- import { type EdgeNodeProps } from '@lincle/react-shared';
4
- declare const generateOrigins: (target: EdgeNodeProps, source: EdgeNodeProps, line: Line, center?: boolean) => Coordinates;
5
- export default generateOrigins;
@@ -1,18 +0,0 @@
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;
@@ -1,17 +0,0 @@
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;
@@ -1,50 +0,0 @@
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
- };
@@ -1,16 +0,0 @@
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;
@@ -1,32 +0,0 @@
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
- };
@@ -1,15 +0,0 @@
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;
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (source, target) => {
4
- const sx = Math.round(source.x);
5
- const sy = Math.round(source.y);
6
- const tx = Math.round(target.x);
7
- const ty = Math.round(target.y);
8
- const halfTargetWidth = Math.round(target.width / 2);
9
- const halfTargetHeight = Math.round(target.height / 2);
10
- const halfSourceWidth = Math.round(source.width / 2);
11
- const halfSourceHeight = Math.round(source.height / 2);
12
- const sourceAngle = Math.atan2(tx + halfTargetWidth - (sx + halfSourceWidth), ty + halfTargetHeight - (sy + halfSourceHeight));
13
- const targetAngle = Math.atan2(sx + halfSourceWidth - (tx + halfTargetWidth), sy + halfSourceHeight - (ty + halfTargetHeight));
14
- const sourceEdgeX = Math.sin(sourceAngle) * halfSourceWidth + halfSourceWidth;
15
- const sourceEdgeY = Math.cos(sourceAngle) * halfSourceHeight + halfSourceHeight;
16
- const targetEdgeX = Math.sin(targetAngle) * halfTargetWidth + halfTargetWidth;
17
- const targetEdgeY = Math.cos(targetAngle) * halfTargetHeight + halfTargetHeight;
18
- const sourceDX = sx + sourceEdgeX - tx - targetEdgeX;
19
- const sourceDY = sy + sourceEdgeY - ty - targetEdgeY;
20
- const sourceROR = sourceDX / sourceDY;
21
- let orientation;
22
- let targetPoints = {
23
- x: sourceEdgeX,
24
- y: sourceEdgeY
25
- };
26
- if (sourceROR < 1 && sourceROR > -1) {
27
- orientation = 'vertical';
28
- if (sourceDY > 0) {
29
- targetPoints = {
30
- x: sx + sourceEdgeX,
31
- y: sy + (source.shape === 'oval' ?
32
- sourceEdgeY :
33
- 0)
34
- };
35
- }
36
- else {
37
- targetPoints = {
38
- x: sx + sourceEdgeX,
39
- y: sy + (source.shape === 'oval' ?
40
- sourceEdgeY :
41
- source.height)
42
- };
43
- }
44
- }
45
- else {
46
- orientation = 'horizontal';
47
- if (sourceDX > 0) {
48
- targetPoints = {
49
- x: sx + (source.shape === 'oval' ?
50
- sourceEdgeX :
51
- 0),
52
- y: sy + sourceEdgeY
53
- };
54
- }
55
- else {
56
- targetPoints = {
57
- x: sx + (source.shape === 'oval' ?
58
- sourceEdgeX :
59
- source.width),
60
- y: sy + sourceEdgeY
61
- };
62
- }
63
- }
64
- const targetDX = tx - targetEdgeX - sx - sourceEdgeX;
65
- const targetDY = ty - targetEdgeY - sy - sourceEdgeY;
66
- let sourcePoints = {
67
- x: targetEdgeX,
68
- y: targetEdgeY
69
- };
70
- if (orientation === 'vertical') {
71
- if (targetDY > 0) {
72
- sourcePoints = {
73
- x: tx + targetEdgeX,
74
- y: ty + (target.shape === 'oval' ?
75
- targetEdgeY :
76
- 0)
77
- };
78
- }
79
- else {
80
- sourcePoints = {
81
- x: tx + targetEdgeX,
82
- y: ty + (target.shape === 'oval' ?
83
- targetEdgeY :
84
- target.height)
85
- };
86
- }
87
- }
88
- else {
89
- if (targetDX > 0) {
90
- sourcePoints = {
91
- x: tx + (target.shape === 'oval' ?
92
- targetEdgeX :
93
- 0),
94
- y: ty + targetEdgeY
95
- };
96
- }
97
- else {
98
- sourcePoints = {
99
- x: tx + (target.shape === 'oval' ?
100
- targetEdgeX :
101
- target.width),
102
- y: ty + targetEdgeY
103
- };
104
- }
105
- }
106
- return {
107
- orientation,
108
- source: sourcePoints,
109
- target: targetPoints
110
- };
111
- };
@@ -1,17 +0,0 @@
1
- import { type Coordinates, type Line } from './types';
2
- export declare const stepHorizontal: (rx1: number, ry1: number, rx2: number, ry2: number, center?: boolean) => Line;
3
- export declare const stepVertical: (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;
@@ -1,63 +0,0 @@
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.stepVertical = exports.stepHorizontal = void 0;
7
- const generatePoints_1 = __importDefault(require("./generatePoints"));
8
- const stepHorizontal = (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 d = [];
14
- const mx = Math.round(x1 + (x2 - x1) / 2);
15
- const my = Math.round(y1 + (y2 - y1) / 2);
16
- const cx = Math.round((x2 + x1) / 2);
17
- const cy = my;
18
- d.push('M', x1, y1);
19
- d.push('L', mx, y1);
20
- d.push('L', mx, y2);
21
- d.push('L', x2, y2);
22
- return {
23
- center: center ?
24
- {
25
- x: cx,
26
- y: cy
27
- } :
28
- undefined,
29
- path: d.join(' ')
30
- };
31
- };
32
- exports.stepHorizontal = stepHorizontal;
33
- const stepVertical = (rx1, ry1, rx2, ry2, center) => {
34
- const x1 = Math.round(rx1);
35
- const y1 = Math.round(ry1);
36
- const x2 = Math.round(rx2);
37
- const y2 = Math.round(ry2);
38
- const d = [];
39
- const mx = Math.round(x1 + (x2 - x1) / 2);
40
- const my = Math.round(y1 + (y2 - y1) / 2);
41
- const cx = mx;
42
- const cy = Math.round((y2 + y1) / 2);
43
- d.push('M', x1, y1);
44
- d.push('L', x1, my);
45
- d.push('L', x2, my);
46
- d.push('L', x2, y2);
47
- return {
48
- center: center ?
49
- {
50
- x: cx,
51
- y: cy
52
- } :
53
- undefined,
54
- path: d.join(' ')
55
- };
56
- };
57
- exports.stepVertical = stepVertical;
58
- exports.default = (source, target, center) => {
59
- const { orientation, source: sourcePoints, target: targetPoints } = (0, generatePoints_1.default)(source, target);
60
- return Object.assign(Object.assign({}, (orientation === 'horizontal' ?
61
- (0, exports.stepHorizontal)(sourcePoints.x, sourcePoints.y, targetPoints.x, targetPoints.y, center) :
62
- (0, exports.stepVertical)(sourcePoints.x, sourcePoints.y, targetPoints.x, targetPoints.y, center))), { source: sourcePoints, target: targetPoints });
63
- };
@@ -1,4 +0,0 @@
1
- export { default as generateCurve } from './generateCurve';
2
- export { default as generateDirect } from './generateDirect';
3
- export { default as generateStep } from './generateStep';
4
- export type { Coordinates, Line, Points } from './types';
@@ -1,12 +0,0 @@
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.generateStep = exports.generateDirect = exports.generateCurve = void 0;
7
- var generateCurve_1 = require("./generateCurve");
8
- Object.defineProperty(exports, "generateCurve", { enumerable: true, get: function () { return __importDefault(generateCurve_1).default; } });
9
- var generateDirect_1 = require("./generateDirect");
10
- Object.defineProperty(exports, "generateDirect", { enumerable: true, get: function () { return __importDefault(generateDirect_1).default; } });
11
- var generateStep_1 = require("./generateStep");
12
- Object.defineProperty(exports, "generateStep", { enumerable: true, get: function () { return __importDefault(generateStep_1).default; } });
@@ -1,34 +0,0 @@
1
- export type Line = {
2
- center?: {
3
- x: number;
4
- y: number;
5
- };
6
- path: string;
7
- };
8
- export type Orientation = 'horizontal' | 'vertical';
9
- export type Points = {
10
- orientation: Orientation;
11
- source: {
12
- x: number;
13
- y: number;
14
- };
15
- target: {
16
- x: number;
17
- y: number;
18
- };
19
- };
20
- export type Coordinates = {
21
- center?: {
22
- x: number;
23
- y: number;
24
- };
25
- path: string;
26
- source: {
27
- x: number;
28
- y: number;
29
- };
30
- target: {
31
- x: number;
32
- y: number;
33
- };
34
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes