@lincle/react-web-interactive 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 (37) hide show
  1. package/COPYING.LESSER.md +157 -0
  2. package/COPYING.md +675 -0
  3. package/README.md +297 -0
  4. package/dist/base.d.ts +1 -0
  5. package/dist/base.js +12 -0
  6. package/dist/components/Edge/index.d.ts +1 -0
  7. package/dist/components/Edge/index.js +5 -0
  8. package/dist/components/Edges/index.d.ts +1 -0
  9. package/dist/components/Edges/index.js +5 -0
  10. package/dist/components/Graph/index.d.ts +4 -0
  11. package/dist/components/Graph/index.js +18 -0
  12. package/dist/components/GraphContexts/index.d.ts +4 -0
  13. package/dist/components/GraphContexts/index.js +167 -0
  14. package/dist/components/Grid/index.d.ts +4 -0
  15. package/dist/components/Grid/index.js +13 -0
  16. package/dist/components/Interaction/index.d.ts +4 -0
  17. package/dist/components/Interaction/index.js +202 -0
  18. package/dist/components/Node/MoveNode/index.d.ts +4 -0
  19. package/dist/components/Node/MoveNode/index.js +164 -0
  20. package/dist/components/Node/PullNode/index.d.ts +4 -0
  21. package/dist/components/Node/PullNode/index.js +90 -0
  22. package/dist/components/Node/index.d.ts +4 -0
  23. package/dist/components/Node/index.js +127 -0
  24. package/dist/components/Nodes/index.d.ts +1 -0
  25. package/dist/components/Nodes/index.js +5 -0
  26. package/dist/components/Path/index.d.ts +1 -0
  27. package/dist/components/Path/index.js +5 -0
  28. package/dist/components/Pull/index.d.ts +4 -0
  29. package/dist/components/Pull/index.js +153 -0
  30. package/dist/components/index.d.ts +9 -0
  31. package/dist/components/index.js +24 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +18 -0
  34. package/dist/shared.d.ts +48 -0
  35. package/dist/shared.js +18 -0
  36. package/dist/styles.g.css +162 -0
  37. package/package.json +102 -0
@@ -0,0 +1,202 @@
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_map_interaction_1 = require("react-map-interaction");
7
+ const CLICK_TIME = 500;
8
+ const PRESS_TIME = 350;
9
+ const Interaction = ({ children, onMouseDown, onMouseUp, onTouchEnd, onTouchStart }) => {
10
+ const { givenMode, onMode } = (0, react_1.useContext)(shared_1.ModeContext);
11
+ const { onNodeSelect } = (0, react_1.useContext)(shared_1.NodeContext);
12
+ const { disablePan, disableScale, maxScale, minScale } = (0, react_1.useContext)(shared_1.TransformContext);
13
+ const { onScale, scale } = (0, react_1.useContext)(shared_1.ScaleContext);
14
+ const { onTranslate, translate } = (0, react_1.useContext)(shared_1.TranslateContext);
15
+ const clickTimeout = (0, react_1.useRef)();
16
+ const pressTimeout = (0, react_1.useRef)();
17
+ const keypress = (0, react_1.useRef)(false);
18
+ const privateMode = (0, react_1.useRef)(givenMode);
19
+ const handleMode = (0, react_1.useCallback)((mode) => {
20
+ if (onMode &&
21
+ privateMode.current !== mode) {
22
+ privateMode.current = mode;
23
+ onMode(mode);
24
+ }
25
+ }, [
26
+ onMode
27
+ ]);
28
+ (0, react_1.useEffect)(() => {
29
+ if (givenMode) {
30
+ return () => {
31
+ };
32
+ }
33
+ const onKeyDown = (event) => {
34
+ keypress.current = true;
35
+ if (event.shiftKey) {
36
+ handleMode('pull');
37
+ }
38
+ else if (event.ctrlKey) {
39
+ handleMode('select');
40
+ }
41
+ };
42
+ const onKeyUp = (event) => {
43
+ keypress.current = false;
44
+ if (!event.shiftKey) {
45
+ handleMode('move');
46
+ }
47
+ else if (!event.ctrlKey) {
48
+ handleMode('move');
49
+ }
50
+ };
51
+ window.addEventListener('keydown', onKeyDown);
52
+ window.addEventListener('keyup', onKeyUp);
53
+ return () => {
54
+ keypress.current = false;
55
+ if (clickTimeout.current) {
56
+ clearTimeout(clickTimeout.current);
57
+ }
58
+ if (pressTimeout.current) {
59
+ clearTimeout(pressTimeout.current);
60
+ }
61
+ window.removeEventListener('keydown', onKeyDown);
62
+ window.removeEventListener('keyup', onKeyUp);
63
+ };
64
+ }, [
65
+ givenMode,
66
+ handleMode
67
+ ]);
68
+ const defaultTranslation = (0, react_1.useMemo)(() => {
69
+ return {
70
+ x: Math.round(translate.x),
71
+ y: Math.round(translate.y)
72
+ };
73
+ }, []);
74
+ const handleChange = (0, react_1.useCallback)(({ scale: z, translation: { x, y } }) => {
75
+ if (pressTimeout.current) {
76
+ clearTimeout(pressTimeout.current);
77
+ pressTimeout.current = undefined;
78
+ }
79
+ if (clickTimeout.current) {
80
+ clearTimeout(clickTimeout.current);
81
+ clickTimeout.current = undefined;
82
+ }
83
+ if (onTranslate) {
84
+ onTranslate({
85
+ x,
86
+ y
87
+ });
88
+ }
89
+ if (onScale) {
90
+ onScale(z);
91
+ }
92
+ }, [
93
+ onScale,
94
+ onTranslate
95
+ ]);
96
+ const handlePressStart = (0, react_1.useCallback)(() => {
97
+ if (!givenMode &&
98
+ onNodeSelect &&
99
+ !clickTimeout.current) {
100
+ pressTimeout.current = setTimeout(() => {
101
+ pressTimeout.current = undefined;
102
+ handleMode('select');
103
+ }, PRESS_TIME);
104
+ }
105
+ }, [
106
+ givenMode,
107
+ handleMode,
108
+ onNodeSelect
109
+ ]);
110
+ const handleTapStart = (0, react_1.useCallback)(() => {
111
+ if (!givenMode) {
112
+ if (clickTimeout.current) {
113
+ clearTimeout(clickTimeout.current);
114
+ clickTimeout.current = setTimeout(() => {
115
+ clickTimeout.current = undefined;
116
+ handleMode('pull');
117
+ }, PRESS_TIME);
118
+ }
119
+ else {
120
+ clickTimeout.current = setTimeout(() => {
121
+ clickTimeout.current = undefined;
122
+ }, CLICK_TIME);
123
+ }
124
+ }
125
+ }, [
126
+ givenMode,
127
+ handleMode
128
+ ]);
129
+ const handleTapEnd = (0, react_1.useCallback)(() => {
130
+ if (!givenMode) {
131
+ if (pressTimeout.current) {
132
+ clearTimeout(pressTimeout.current);
133
+ pressTimeout.current = undefined;
134
+ }
135
+ handleMode('move');
136
+ }
137
+ }, [
138
+ givenMode,
139
+ handleMode
140
+ ]);
141
+ const handleMouseDown = (0, react_1.useCallback)((event) => {
142
+ if (onMouseDown) {
143
+ onMouseDown(event);
144
+ }
145
+ }, [
146
+ onMouseDown
147
+ ]);
148
+ const handleMouseUp = (0, react_1.useCallback)((event) => {
149
+ if (onMouseUp) {
150
+ onMouseUp(event);
151
+ }
152
+ }, [
153
+ onMouseUp
154
+ ]);
155
+ const handleTouchStart = (0, react_1.useCallback)((event) => {
156
+ if (keypress.current === false) {
157
+ handlePressStart();
158
+ handleTapStart();
159
+ }
160
+ if (onTouchStart) {
161
+ onTouchStart(event);
162
+ }
163
+ }, [
164
+ handlePressStart,
165
+ handleTapStart,
166
+ onTouchStart
167
+ ]);
168
+ const handleTouchEnd = (0, react_1.useCallback)((event) => {
169
+ if (keypress.current === false) {
170
+ handleTapEnd();
171
+ }
172
+ if (onTouchEnd) {
173
+ onTouchEnd(event);
174
+ }
175
+ }, [
176
+ handleTapEnd,
177
+ onTouchEnd
178
+ ]);
179
+ const transform = (0, react_1.useMemo)(() => {
180
+ return {
181
+ scale,
182
+ translation: translate
183
+ };
184
+ }, [
185
+ scale,
186
+ translate
187
+ ]);
188
+ const style = (0, react_1.useMemo)(() => {
189
+ const { x, y } = translate;
190
+ return {
191
+ transform: `translateX(${x}px) translateY(${y}px) scale(${scale}) translateZ(0)`
192
+ };
193
+ }, [
194
+ scale,
195
+ translate
196
+ ]);
197
+ return ((0, jsx_runtime_1.jsx)(react_map_interaction_1.MapInteraction, { defaultScale: scale, defaultTranslation: defaultTranslation, disablePan: disablePan, disableZoom: disableScale, maxScale: maxScale, minScale: minScale, onChange: handleChange, value: transform, children: () => {
198
+ return ((0, jsx_runtime_1.jsx)("div", { className: 'lincle-interactive-graph', onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onTouchEnd: handleTouchEnd, onTouchStart: handleTouchStart, role: 'none', children: (0, jsx_runtime_1.jsx)("div", { className: 'lincle-interactive-transform', style: style, children: children }) }));
199
+ } }));
200
+ };
201
+ Interaction.displayName = 'LincleInteractiveInteraction';
202
+ exports.default = Interaction;
@@ -0,0 +1,4 @@
1
+ import { type MoveNodeProps } from '../../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const MoveNode: FunctionComponent<MoveNodeProps>;
4
+ export default MoveNode;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const base_1 = require("../../../base");
5
+ const shared_1 = require("../../../shared");
6
+ const react_1 = require("react");
7
+ const react_draggable_1 = require("react-draggable");
8
+ const PRESS_TIME = 500;
9
+ const emptySnap = [
10
+ 1,
11
+ 1
12
+ ];
13
+ const MoveNode = ({ children, className, disabled, height, id, mode, onDrag, onSelect, onStart, onStop, shape, snap, style, width, x, y }) => {
14
+ const { scale } = (0, react_1.useContext)(shared_1.ScaleContext);
15
+ const [snapX, snapY] = snap !== null && snap !== void 0 ? snap : emptySnap;
16
+ const [position, setPosition] = (0, react_1.useState)({
17
+ x,
18
+ y
19
+ });
20
+ const mouseDown = (0, react_1.useRef)(false);
21
+ const initialPos = (0, react_1.useRef)(position);
22
+ if (!mouseDown.current && (x !== initialPos.current.x ||
23
+ y !== initialPos.current.y) && (x !== position.x ||
24
+ y !== position.y)) {
25
+ setPosition({
26
+ x,
27
+ y
28
+ });
29
+ }
30
+ const pos = (0, react_1.useRef)(position);
31
+ const snapped = (0, react_1.useRef)(position);
32
+ snapped.current = position;
33
+ const moved = (0, react_1.useRef)(false);
34
+ const press = (0, react_1.useRef)();
35
+ (0, react_1.useEffect)(() => {
36
+ return () => {
37
+ if (press.current) {
38
+ clearTimeout(press.current);
39
+ }
40
+ };
41
+ }, []);
42
+ const handleOnSelect = (0, react_1.useCallback)(() => {
43
+ if (onSelect) {
44
+ onSelect(id);
45
+ }
46
+ }, [
47
+ id,
48
+ onSelect
49
+ ]);
50
+ const handlePressStart = (0, react_1.useCallback)(() => {
51
+ if (mode !== 'select' &&
52
+ !press.current) {
53
+ press.current = setTimeout(() => {
54
+ handleOnSelect();
55
+ press.current = undefined;
56
+ }, PRESS_TIME);
57
+ }
58
+ }, [
59
+ handleOnSelect,
60
+ mode
61
+ ]);
62
+ const handlePressStop = (0, react_1.useCallback)(() => {
63
+ if (press.current) {
64
+ clearTimeout(press.current);
65
+ press.current = undefined;
66
+ }
67
+ }, []);
68
+ const handleStart = (0, react_1.useCallback)((event) => {
69
+ event.stopPropagation();
70
+ mouseDown.current = true;
71
+ if (onSelect) {
72
+ handlePressStart();
73
+ }
74
+ if (onStart) {
75
+ onStart(event);
76
+ }
77
+ }, [
78
+ handlePressStart,
79
+ onSelect,
80
+ onStart
81
+ ]);
82
+ const handleDrag = (0, react_1.useCallback)((event, data) => {
83
+ event.stopPropagation();
84
+ const currentX = pos.current.x;
85
+ const currentY = pos.current.y;
86
+ if (!disabled &&
87
+ (currentX || currentX === 0) &&
88
+ (currentY || currentY === 0)) {
89
+ if (onSelect) {
90
+ handlePressStop();
91
+ }
92
+ pos.current = {
93
+ x: currentX + data.deltaX,
94
+ y: currentY + data.deltaY
95
+ };
96
+ const adjustedPosition = {
97
+ x: Math.floor((currentX + snapX / 2) / snapX) * snapX,
98
+ y: Math.floor((currentY + snapY / 2) / snapY) * snapY
99
+ };
100
+ setPosition(adjustedPosition);
101
+ if (onDrag) {
102
+ onDrag(event, Object.assign(Object.assign({}, data), adjustedPosition), snapped.current);
103
+ }
104
+ if (moved.current === false) {
105
+ moved.current = true;
106
+ }
107
+ }
108
+ }, [
109
+ disabled,
110
+ handlePressStop,
111
+ onDrag,
112
+ onSelect,
113
+ snapX,
114
+ snapY
115
+ ]);
116
+ const handleStop = (0, react_1.useCallback)((event, data) => {
117
+ mouseDown.current = false;
118
+ if (onSelect && !press.current ||
119
+ mode === 'select' ||
120
+ moved.current) {
121
+ event.stopPropagation();
122
+ }
123
+ if (!disabled) {
124
+ if (moved.current === false &&
125
+ mode === 'select') {
126
+ handleOnSelect();
127
+ }
128
+ if (onSelect) {
129
+ handlePressStop();
130
+ }
131
+ const addX = snapped.current.x || snapped.current.x === 0 ?
132
+ snapped.current.x + data.deltaX :
133
+ 0;
134
+ const addY = snapped.current.y || snapped.current.y === 0 ?
135
+ snapped.current.y + data.deltaY :
136
+ 0;
137
+ const adjustedPosition = {
138
+ x: addX - addX % snapX,
139
+ y: addY - addY % snapY
140
+ };
141
+ setPosition({
142
+ x: adjustedPosition.x,
143
+ y: adjustedPosition.y
144
+ });
145
+ if (onStop) {
146
+ onStop(event, Object.assign(Object.assign({}, data), adjustedPosition));
147
+ }
148
+ moved.current = false;
149
+ }
150
+ }, [
151
+ disabled,
152
+ handleOnSelect,
153
+ handlePressStop,
154
+ mode,
155
+ onSelect,
156
+ onStop,
157
+ snapX,
158
+ snapY
159
+ ]);
160
+ const nodeRef = (0, react_1.useRef)(null);
161
+ return ((0, jsx_runtime_1.jsx)(react_draggable_1.DraggableCore, { disabled: disabled, nodeRef: nodeRef, onDrag: handleDrag, onStart: handleStart, onStop: handleStop, scale: scale, children: (0, jsx_runtime_1.jsx)(base_1.Node, { className: className, height: height, id: id, ref: nodeRef, shape: shape, style: style, width: width, x: position.x, y: position.y, children: children }) }));
162
+ };
163
+ MoveNode.displayName = 'LincleInteractiveMoveNode';
164
+ exports.default = MoveNode;
@@ -0,0 +1,4 @@
1
+ import { type PullNodeProps } from '../../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const PullNode: FunctionComponent<PullNodeProps>;
4
+ export default PullNode;
@@ -0,0 +1,90 @@
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 Pull_1 = __importDefault(require("../../Pull"));
9
+ const react_1 = require("react");
10
+ const react_draggable_1 = require("react-draggable");
11
+ const PullNode = ({ className, disabled, height, line, onDrag, onEdgeDrop: givenOnEdgeDrop, onStart, onStop, shape, sourceId, style, width, x, y }) => {
12
+ var _a, _b;
13
+ const diagramId = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.diagramId;
14
+ const nodePositions = (_b = (0, react_1.useContext)(shared_1.GraphContext)) === null || _b === void 0 ? void 0 : _b.nodePositions;
15
+ const { onEdgeDrop: defaultOnEdgeDrop } = (0, react_1.useContext)(shared_1.NodeContext);
16
+ const onEdgeDrop = givenOnEdgeDrop !== null && givenOnEdgeDrop !== void 0 ? givenOnEdgeDrop : defaultOnEdgeDrop;
17
+ const { scale } = (0, react_1.useContext)(shared_1.ScaleContext);
18
+ const [position, setPosition] = (0, react_1.useState)({
19
+ x,
20
+ y
21
+ });
22
+ const pos = (0, react_1.useRef)(position);
23
+ pos.current = position;
24
+ const handleStart = (0, react_1.useCallback)((event) => {
25
+ event.stopPropagation();
26
+ if (onStart) {
27
+ onStart(event);
28
+ }
29
+ }, [
30
+ onStart
31
+ ]);
32
+ const handleDrag = (0, react_1.useCallback)((event, data) => {
33
+ event.stopPropagation();
34
+ if (!disabled) {
35
+ setPosition({
36
+ x: data.x,
37
+ y: data.y
38
+ });
39
+ if (onDrag) {
40
+ onDrag(event, data);
41
+ }
42
+ }
43
+ }, [
44
+ disabled,
45
+ onDrag
46
+ ]);
47
+ const handleStop = (0, react_1.useCallback)((event, data) => {
48
+ event.stopPropagation();
49
+ if (!disabled) {
50
+ setPosition({
51
+ x: data.x,
52
+ y: data.y
53
+ });
54
+ }
55
+ if (onStop) {
56
+ onStop(event, data);
57
+ }
58
+ if (onEdgeDrop &&
59
+ nodePositions &&
60
+ position.x &&
61
+ position.y) {
62
+ nodePositions.match(position.x, position.y).then((match) => {
63
+ onEdgeDrop(sourceId, Boolean(match) || match === 0 ?
64
+ match :
65
+ undefined);
66
+ }).catch(() => {
67
+ });
68
+ }
69
+ setPosition({
70
+ x,
71
+ y
72
+ });
73
+ }, [
74
+ disabled,
75
+ nodePositions,
76
+ onEdgeDrop,
77
+ onStop,
78
+ position.x,
79
+ position.y,
80
+ sourceId,
81
+ x,
82
+ y
83
+ ]);
84
+ const nodeRef = (0, react_1.useRef)(null);
85
+ return diagramId ?
86
+ ((0, jsx_runtime_1.jsx)(react_draggable_1.DraggableCore, { disabled: disabled, nodeRef: nodeRef, onDrag: handleDrag, onStart: handleStart, onStop: handleStop, scale: scale, children: (0, jsx_runtime_1.jsx)(Pull_1.default, { className: className, diagramId: diagramId, height: height, line: line, ref: nodeRef, shape: shape, sourceId: sourceId, style: style, width: width, x: position.x, y: position.y }) })) :
87
+ null;
88
+ };
89
+ PullNode.displayName = 'LincleInteractivePullNode';
90
+ exports.default = PullNode;
@@ -0,0 +1,4 @@
1
+ import { type NodeProps } from '../../shared';
2
+ import { type FunctionComponent } from 'react';
3
+ declare const Node: FunctionComponent<NodeProps>;
4
+ export default Node;
@@ -0,0 +1,127 @@
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 MoveNode_1 = __importDefault(require("./MoveNode"));
9
+ const PullNode_1 = __importDefault(require("./PullNode"));
10
+ const react_1 = require("react");
11
+ const emptySnap = [
12
+ 1,
13
+ 1
14
+ ];
15
+ const Node = ({ children, className = '', disableMove: givenDisableMove, disablePull: givenDisablePull, height: givenHeight, id, line: givenLine, mode: givenMode, onDrag, onEdgeDrop: givenOnEdgeDrop, onSelect: givenOnSelect, onStart, onStop, shape: givenShape, style, width: givenWidth, x, y }) => {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
17
+ const defaultHeight = (_b = (_a = (0, react_1.useContext)(shared_1.GraphContext)) === null || _a === void 0 ? void 0 : _a.defaultSettings) === null || _b === void 0 ? void 0 : _b.height;
18
+ 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;
19
+ const defaultShape = (_f = (_e = (0, react_1.useContext)(shared_1.GraphContext)) === null || _e === void 0 ? void 0 : _e.defaultSettings) === null || _f === void 0 ? void 0 : _f.shape;
20
+ const defaultWidth = (_h = (_g = (0, react_1.useContext)(shared_1.GraphContext)) === null || _g === void 0 ? void 0 : _g.defaultSettings) === null || _h === void 0 ? void 0 : _h.width;
21
+ const snap = (0, react_1.useContext)(shared_1.SnapContext);
22
+ const [snapX, snapY] = snap !== null && snap !== void 0 ? snap : emptySnap;
23
+ const { disableMove: graphDisableMove, disablePull: graphDisablePull, givenMode: graphGivenMode, mode: graphMode } = (0, react_1.useContext)(shared_1.ModeContext);
24
+ const mode = (_j = givenMode !== null && givenMode !== void 0 ? givenMode : graphGivenMode) !== null && _j !== void 0 ? _j : graphMode;
25
+ const { onEdgeDrop: defaultOnEdgeDrop, onNodeDrag, onNodeSelect, onNodeStart, onNodeStop } = (0, react_1.useContext)(shared_1.NodeContext);
26
+ const disableMove = givenDisableMove !== null && givenDisableMove !== void 0 ? givenDisableMove : graphDisableMove;
27
+ const disablePull = givenDisablePull !== null && givenDisablePull !== void 0 ? givenDisablePull : graphDisablePull;
28
+ const onEdgeDrop = givenOnEdgeDrop !== null && givenOnEdgeDrop !== void 0 ? givenOnEdgeDrop : defaultOnEdgeDrop;
29
+ const onSelect = givenOnSelect !== null && givenOnSelect !== void 0 ? givenOnSelect : onNodeSelect;
30
+ const pullPosition = (0, react_1.useRef)({
31
+ x,
32
+ y
33
+ });
34
+ const { height, line, shape, width } = (0, react_1.useMemo)(() => {
35
+ return {
36
+ height: givenHeight !== null && givenHeight !== void 0 ? givenHeight : defaultHeight,
37
+ line: givenLine !== null && givenLine !== void 0 ? givenLine : defaultLine,
38
+ shape: givenShape !== null && givenShape !== void 0 ? givenShape : defaultShape,
39
+ width: givenWidth !== null && givenWidth !== void 0 ? givenWidth : defaultWidth
40
+ };
41
+ }, [
42
+ defaultHeight,
43
+ defaultLine,
44
+ defaultShape,
45
+ defaultWidth,
46
+ givenHeight,
47
+ givenLine,
48
+ givenShape,
49
+ givenWidth
50
+ ]);
51
+ const handleOnStart = (0, react_1.useCallback)((event) => {
52
+ if (onStart) {
53
+ onStart(event);
54
+ }
55
+ else if (onNodeStart) {
56
+ onNodeStart(event, id);
57
+ }
58
+ }, [
59
+ id,
60
+ onNodeStart,
61
+ onStart
62
+ ]);
63
+ const handleOnDrag = (0, react_1.useCallback)((event, data) => {
64
+ if (onDrag) {
65
+ onDrag(event, data);
66
+ }
67
+ else if (onNodeDrag) {
68
+ onNodeDrag(event, id, data);
69
+ }
70
+ }, [
71
+ id,
72
+ onDrag,
73
+ onNodeDrag
74
+ ]);
75
+ const handleOnStop = (0, react_1.useCallback)((event, data) => {
76
+ if (onStop) {
77
+ onStop(event, data);
78
+ }
79
+ else if (onNodeStop) {
80
+ onNodeStop(event, id, data);
81
+ }
82
+ }, [
83
+ id,
84
+ onNodeStop,
85
+ onStop
86
+ ]);
87
+ const handleMoveStart = (0, react_1.useCallback)((event) => {
88
+ handleOnStart(event);
89
+ }, [
90
+ handleOnStart
91
+ ]);
92
+ const handleMoveDrag = (0, react_1.useCallback)((event, data, position) => {
93
+ pullPosition.current = {
94
+ x: position.x,
95
+ y: position.y
96
+ };
97
+ handleOnDrag(event, data);
98
+ }, [
99
+ handleOnDrag
100
+ ]);
101
+ const handleMoveStop = (0, react_1.useCallback)((event, data) => {
102
+ handleOnStop(event, data);
103
+ }, [
104
+ handleOnStop
105
+ ]);
106
+ const pullNode = (0, react_1.useMemo)(() => {
107
+ return mode === 'pull' && !disablePull ?
108
+ ((0, jsx_runtime_1.jsx)(PullNode_1.default, { disabled: disablePull !== null && disablePull !== void 0 ? disablePull : mode !== 'pull', height: height, line: line, mode: mode, onEdgeDrop: onEdgeDrop, shape: shape, sourceId: id, style: style, width: width, x: pullPosition.current.x, y: pullPosition.current.y })) :
109
+ null;
110
+ }, [
111
+ mode
112
+ ]);
113
+ const test = (0, react_1.useMemo)(() => {
114
+ return {
115
+ x: Math.ceil((x !== null && x !== void 0 ? x : 0) / snapX) * snapX,
116
+ y: Math.ceil((y !== null && y !== void 0 ? y : 0) / snapY) * snapY
117
+ };
118
+ }, [
119
+ snapX,
120
+ snapY,
121
+ x,
122
+ y
123
+ ]);
124
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MoveNode_1.default, { className: className, disabled: disableMove !== null && disableMove !== void 0 ? disableMove : mode === 'pull', height: height, id: id, mode: mode, onDrag: handleMoveDrag, onSelect: onSelect, onStart: handleMoveStart, onStop: handleMoveStop, shape: shape, snap: snap, style: style, width: width, x: test.x, y: test.y, children: children }), pullNode] }));
125
+ };
126
+ Node.displayName = 'LincleInteractiveNode';
127
+ exports.default = Node;
@@ -0,0 +1 @@
1
+ export { Nodes as default } from '../../base';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ var base_1 = require("../../base");
5
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return base_1.Nodes; } });
@@ -0,0 +1 @@
1
+ export { Path as default } from '../../base';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ var base_1 = require("../../base");
5
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return base_1.Path; } });
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { type PullProps } from '../../shared';
3
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<PullProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default _default;