@bemedev/mind-flow 0.1.0 → 0.3.0
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/README.md +10 -10
- package/lib/helpers/createContext.d.ts +7 -2
- package/lib/helpers/createContext.d.ts.map +1 -1
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +556 -510
- package/lib/output.css +1 -1
- package/lib/server.cjs.js +653 -397
- package/lib/server.es.js +657 -401
- package/lib/services/main.machine.d.ts +4857 -218
- package/lib/services/main.machine.d.ts.map +1 -1
- package/lib/{ui/components/FlowChart.data.d.ts → services/main.machine.data.d.ts} +8 -3
- package/lib/services/main.machine.data.d.ts.map +1 -0
- package/lib/services/main.machine.helpers.d.ts +32 -0
- package/lib/services/main.machine.helpers.d.ts.map +1 -0
- package/lib/services/main.machine.typings.d.ts +126 -0
- package/lib/services/main.machine.typings.d.ts.map +1 -0
- package/lib/ui/Flow.d.ts +2 -0
- package/lib/ui/Flow.d.ts.map +1 -1
- package/lib/ui/components/Bounds.d.ts +2 -0
- package/lib/ui/components/Bounds.d.ts.map +1 -1
- package/lib/ui/components/EdgeComponent.d.ts +3 -2
- package/lib/ui/components/EdgeComponent.d.ts.map +1 -1
- package/lib/ui/components/EdgesBoard.d.ts +2 -0
- package/lib/ui/components/EdgesBoard.d.ts.map +1 -1
- package/lib/ui/components/FlowChart.context.d.ts +5608 -996
- package/lib/ui/components/FlowChart.context.d.ts.map +1 -1
- package/lib/ui/components/FlowChart.d.ts +3 -1
- package/lib/ui/components/FlowChart.d.ts.map +1 -1
- package/lib/ui/components/NodeComponent.d.ts +2 -10
- package/lib/ui/components/NodeComponent.d.ts.map +1 -1
- package/lib/ui/components/NodesBoard.d.ts +2 -0
- package/lib/ui/components/NodesBoard.d.ts.map +1 -1
- package/package.json +9 -15
- package/src/helpers/createContext.ts +7 -2
- package/src/{ui/components/FlowChart.data.ts → services/main.machine.data.ts} +7 -2
- package/src/services/main.machine.helpers.ts +55 -0
- package/src/services/main.machine.ts +288 -70
- package/src/services/main.machine.typings.ts +98 -0
- package/src/ui/Flow.tsx +2 -0
- package/src/ui/components/Bounds.tsx +13 -8
- package/src/ui/components/EdgeComponent.tsx +78 -56
- package/src/ui/components/EdgesBoard.tsx +13 -36
- package/src/ui/components/FlowChart.context.ts +204 -291
- package/src/ui/components/FlowChart.tsx +16 -16
- package/src/ui/components/NodeComponent.tsx +60 -104
- package/src/ui/components/NodesBoard.tsx +85 -47
- package/src/ui/components/classes.ts +1 -1
- package/lib/services/main.typings.d.ts +0 -68
- package/lib/services/main.typings.d.ts.map +0 -1
- package/lib/ui/components/FlowChart.data.d.ts.map +0 -1
- package/src/services/main.typings.ts +0 -50
package/lib/index.es.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import { classList as e, createComponent as t, delegateEvents as n, effect as r, getNextElement as i, getNextMarker as a, insert as o, runHydrationEvents as s, setAttribute as c, setStyleProperty as l, template as u, use as d } from "solid-js/web";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useState as E } from "@bemedev/app-solidjs";
|
|
2
|
+
import { createState as f } from "@bemedev/app-solidjs";
|
|
3
|
+
import { For as p, Show as m, createContext as h, createEffect as g, createSignal as _, on as v, onCleanup as y, onMount as b, useContext as x } from "solid-js";
|
|
4
|
+
import { createMachine as S, interpret as C, toArray as w } from "@bemedev/app";
|
|
5
|
+
import { toArray as T, type as E } from "@bemedev/app/bemedev";
|
|
7
6
|
import { DragDropProvider as D, DragDropSensors as O, DragOverlay as k, createDraggable as A, useDragDropContext as j } from "@thisbeyond/solid-dnd";
|
|
8
7
|
//#region src/ui/components/classes.ts
|
|
9
|
-
var M = /* @__PURE__ */ "fill-transparent cursor-pointer relative stroke-[rgba(168,168,168,0.4)] stroke-3 stroke-[rgba(168,168,168,1)] stroke-4 z-100 stroke-[rgba(168,168,168,0.8)] pointer-events-all w-[100px] h-[100px] bg-white fill-white pointer-events-none absolute top-0 w-full h-full overflow-hidden overflow-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
var M = /* @__PURE__ */ "fill-transparent cursor-pointer relative stroke-[rgba(168,168,168,0.4)] stroke-3 stroke-[rgba(168,168,168,1)] stroke-4 z-100 stroke-[rgba(168,168,168,0.8)] pointer-events-all w-[100px] h-[100px] bg-white fill-white pointer-events-none absolute top-0 w-full h-full overflow-hidden overflow-auto h-[150vh] w-[2160px] bg-size-[30px_30px] flex flex-col cursor-grab rounded-md shadow-[1px_1px_11px_-6px_rgba(0,0,0,0.75)] select-none transition-[border,box-shadow] duration-200 ease-in-out hover:shadow-[2px_2px_12px_-6px_rgba(0,0,0,0.75)] draggable border border-[#e38c29] z-[100] border-[#e6d4be] z-[1] items-center justify-end -top-[30px] right-0 transition-all space-x-2 opacity-100 w-0 -right-3 opacity-0 w-6 h-6 fill-[#a11111] rounded-full size-6 bg-green-500 p-0.5 hover:bg-green-600 font-bold text-center overflow-visible bg-blue-500 text-white rounded-lg hover:bg-blue-600 justify-center p-3 border-b border-[#f0f0f0] cursor-default z-[-3] -left-[18px] bg-[#e38b29] w-3 h-3 my-3 -right-[18px] cursor-crosshair mt-3".split(" "), N = 10.5, P = {
|
|
9
|
+
x: -10.5,
|
|
10
|
+
y: 18
|
|
11
|
+
}, F = (e = 0) => ({
|
|
12
|
+
x: e + N,
|
|
13
|
+
y: 18
|
|
14
|
+
}), I = {
|
|
15
|
+
horizontal: 55,
|
|
16
|
+
vertical: 40
|
|
17
|
+
}, L = [{
|
|
18
|
+
id: "node-0",
|
|
19
|
+
data: {
|
|
20
|
+
content: "Some text",
|
|
21
|
+
label: "Root node"
|
|
22
|
+
},
|
|
23
|
+
input: !1,
|
|
24
|
+
position: {
|
|
25
|
+
x: 350,
|
|
26
|
+
y: 100
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/helpers/createContext.ts
|
|
29
|
-
var F = (e, t) => {
|
|
30
|
-
let n = m(e(), t);
|
|
28
|
+
}], R = (e, t) => {
|
|
29
|
+
let n = h(e(), t);
|
|
31
30
|
return [
|
|
32
31
|
({ children: e }) => n.Provider({
|
|
33
32
|
value: n.defaultValue,
|
|
@@ -36,45 +35,76 @@ var F = (e, t) => {
|
|
|
36
35
|
() => x(n),
|
|
37
36
|
n
|
|
38
37
|
];
|
|
39
|
-
},
|
|
38
|
+
}, z = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", ee = (e = 21) => {
|
|
40
39
|
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
41
|
-
for (; e--;) t +=
|
|
40
|
+
for (; e--;) t += z[n[e] & 63];
|
|
42
41
|
return t;
|
|
43
|
-
},
|
|
42
|
+
}, B = (e, t) => `edge = ${e} => ${t}`, V = (e) => `node-${e}`, te = (e, t = {
|
|
43
|
+
width: 192,
|
|
44
|
+
height: 50,
|
|
45
|
+
inputOffset: P
|
|
46
|
+
}) => {
|
|
47
|
+
let n = t.width, r = t.height, i = t.outputOffset ?? F(n), a = t.inputOffset;
|
|
48
|
+
return {
|
|
49
|
+
width: n,
|
|
50
|
+
height: r,
|
|
51
|
+
output: {
|
|
52
|
+
x: e.x + i.x,
|
|
53
|
+
y: e.y + i.y
|
|
54
|
+
},
|
|
55
|
+
input: {
|
|
56
|
+
x: e.x + a.x,
|
|
57
|
+
y: e.y + a.y
|
|
58
|
+
},
|
|
59
|
+
outputOffset: i,
|
|
60
|
+
inputOffset: a
|
|
61
|
+
};
|
|
62
|
+
}, H = E({
|
|
44
63
|
x: "number",
|
|
45
64
|
y: "number"
|
|
46
65
|
});
|
|
47
|
-
|
|
48
|
-
input: e(t(
|
|
49
|
-
output: t(
|
|
66
|
+
E(({ optional: e, use: t }) => ({
|
|
67
|
+
input: e(t(H)),
|
|
68
|
+
output: t(H)
|
|
50
69
|
}));
|
|
51
|
-
var
|
|
70
|
+
var U = E({
|
|
52
71
|
from: "string",
|
|
53
72
|
to: "string"
|
|
54
|
-
}),
|
|
55
|
-
position: t(
|
|
73
|
+
}), W = E(({ optional: e, use: t }) => ({
|
|
74
|
+
position: t(H),
|
|
56
75
|
data: {
|
|
57
76
|
label: e("string"),
|
|
58
77
|
content: "string"
|
|
59
78
|
},
|
|
60
79
|
input: "boolean"
|
|
61
|
-
})),
|
|
62
|
-
T(({ optional: e, use: t }) => ({
|
|
80
|
+
})), G = U, K = E(({ optional: e, use: t }) => ({
|
|
63
81
|
width: "number",
|
|
64
82
|
height: "number",
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
output: t(H),
|
|
84
|
+
input: e(t(H)),
|
|
85
|
+
inputOffset: e(t(H)),
|
|
86
|
+
outputOffset: e(t(H))
|
|
87
|
+
})), q = E({
|
|
69
88
|
x0: "number",
|
|
70
89
|
y0: "number",
|
|
71
90
|
x1: "number",
|
|
72
91
|
y1: "number"
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
}), ne = E(({ intersection: e, use: t }) => e({ from: "string" }, t(q))), J = E(({ optional: e }) => ({
|
|
93
|
+
self: {
|
|
94
|
+
left: "number",
|
|
95
|
+
top: "number",
|
|
96
|
+
width: "number",
|
|
97
|
+
height: "number"
|
|
98
|
+
},
|
|
99
|
+
parent: e({
|
|
100
|
+
scrollLeft: "number",
|
|
101
|
+
scrollTop: "number",
|
|
102
|
+
height: "number",
|
|
103
|
+
width: "number"
|
|
104
|
+
})
|
|
105
|
+
})), re = S({
|
|
77
106
|
initial: "idle",
|
|
107
|
+
on: { SET_BOARD: { actions: ["setBoard"] } },
|
|
78
108
|
states: {
|
|
79
109
|
idle: { on: {
|
|
80
110
|
CONFIGURE: {
|
|
@@ -89,7 +119,7 @@ var H = (e, t) => `edge = ${e} => ${t}`, U = (e) => `node-${e}`, ee = S({
|
|
|
89
119
|
} },
|
|
90
120
|
working: { on: {
|
|
91
121
|
MOVE_IMMEDIATE: { actions: [{
|
|
92
|
-
name: "
|
|
122
|
+
name: "buildUI",
|
|
93
123
|
description: "Must be in the ui"
|
|
94
124
|
}] },
|
|
95
125
|
ADD_CHILD: {
|
|
@@ -114,6 +144,7 @@ var H = (e, t) => `edge = ${e} => ${t}`, U = (e) => `node-${e}`, ee = S({
|
|
|
114
144
|
],
|
|
115
145
|
target: "/construction"
|
|
116
146
|
},
|
|
147
|
+
ADD_DIMENSION: { actions: ["addDimension"] },
|
|
117
148
|
ADD_SIBLING: {
|
|
118
149
|
actions: [
|
|
119
150
|
"generateID",
|
|
@@ -133,20 +164,27 @@ var H = (e, t) => `edge = ${e} => ${t}`, U = (e) => `node-${e}`, ee = S({
|
|
|
133
164
|
actions: ["addEdge"],
|
|
134
165
|
target: "/construction"
|
|
135
166
|
},
|
|
167
|
+
START_NEW_EDGE: { actions: ["startNewEdge"] },
|
|
168
|
+
MOVE_NEW_EDGE: { actions: ["moveNewEdge"] },
|
|
169
|
+
CLEAR_NEW_EDGE: { actions: ["clearNewEdge"] },
|
|
136
170
|
DELETE: {
|
|
137
171
|
actions: ["delete"],
|
|
138
172
|
target: "/construction"
|
|
139
173
|
},
|
|
140
174
|
SELECT: { actions: ["select"] },
|
|
141
|
-
DESELECT: { actions: ["deselect"] }
|
|
175
|
+
DESELECT: { actions: ["deselect"] },
|
|
176
|
+
ZOOM: { actions: ["zoom"] },
|
|
177
|
+
TOGGLE_ZOOM: { actions: ["toggleZoom"] },
|
|
178
|
+
SET_BOARD: { actions: ["setBoard"] }
|
|
142
179
|
} }
|
|
143
180
|
}
|
|
144
181
|
}, {
|
|
145
|
-
eventsMap:
|
|
182
|
+
eventsMap: E(({ intersection: e, use: t, array: n }) => ({
|
|
146
183
|
CONFIGURE: {
|
|
147
|
-
nodes: n(e(t(
|
|
148
|
-
edges: n(e(t(
|
|
184
|
+
nodes: n(e(t(W), { id: "string" })),
|
|
185
|
+
edges: n(e(t(G), { id: "string" }))
|
|
149
186
|
},
|
|
187
|
+
SET_BOARD: t(J),
|
|
150
188
|
CONFIGURE_EMPTY: "never",
|
|
151
189
|
MOVE: {
|
|
152
190
|
id: "string",
|
|
@@ -164,288 +202,288 @@ var H = (e, t) => `edge = ${e} => ${t}`, U = (e) => `node-${e}`, ee = S({
|
|
|
164
202
|
DELETE: "string",
|
|
165
203
|
SELECT: "string",
|
|
166
204
|
DESELECT: "never",
|
|
167
|
-
ADD_EDGE: t(
|
|
205
|
+
ADD_EDGE: t(U),
|
|
206
|
+
START_NEW_EDGE: "string",
|
|
207
|
+
MOVE_NEW_EDGE: t(H),
|
|
208
|
+
CLEAR_NEW_EDGE: "never",
|
|
209
|
+
ZOOM: "number",
|
|
210
|
+
TOGGLE_ZOOM: "never",
|
|
211
|
+
ADD_DIMENSION: {
|
|
212
|
+
id: "string",
|
|
213
|
+
dimension: t(K)
|
|
214
|
+
}
|
|
168
215
|
})),
|
|
169
216
|
sync: !0,
|
|
170
|
-
pContext:
|
|
171
|
-
|
|
217
|
+
pContext: E(({ union: e, optional: t, record: n, use: r, custom: i }) => ({
|
|
218
|
+
generatedId: e("string", "null"),
|
|
219
|
+
previousZoom: t("number"),
|
|
220
|
+
dimensions: n(r(K)),
|
|
221
|
+
getBoardPosition: i(),
|
|
222
|
+
clampPosition: i(),
|
|
223
|
+
calculateDimensions: i()
|
|
224
|
+
})),
|
|
225
|
+
context: E(({ optional: e, use: t, array: n, record: r }) => ({
|
|
172
226
|
data: e({
|
|
173
227
|
nodes: n({
|
|
174
|
-
...t(
|
|
228
|
+
...t(W),
|
|
175
229
|
id: "string"
|
|
176
230
|
}),
|
|
177
231
|
edges: n({
|
|
178
|
-
...t(
|
|
232
|
+
...t(G),
|
|
179
233
|
id: "string"
|
|
180
234
|
})
|
|
181
235
|
}),
|
|
236
|
+
board: e(t(J)),
|
|
237
|
+
edgesPositions: r(t(q)),
|
|
238
|
+
newEdge: e(t(ne)),
|
|
182
239
|
selected: e("string"),
|
|
183
|
-
updatingUI: e("boolean")
|
|
240
|
+
updatingUI: e("boolean"),
|
|
241
|
+
zoom: "number",
|
|
242
|
+
bounds: t(H)
|
|
184
243
|
}))
|
|
185
|
-
}).provideOptions(({ assign: e, batch: t, erase: n }) => ({ actions: {
|
|
186
|
-
configure: t(e("
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
244
|
+
}).provideOptions(({ assign: e, batch: t, erase: n, filter: r, action: i }) => ({ actions: {
|
|
245
|
+
configure: t(e("data", { CONFIGURE: ({ payload: e }) => e }), e("newEdge", () => void 0), e("updatingUI", () => !1), i(({ pContext: e }) => {
|
|
246
|
+
e.generatedId = null;
|
|
247
|
+
}), i({ CONFIGURE: ({ payload: { nodes: e }, pContext: { dimensions: t } }) => {
|
|
248
|
+
e.forEach(({ id: e, position: n }) => {
|
|
249
|
+
t[e] = te(n);
|
|
250
|
+
});
|
|
251
|
+
} })),
|
|
252
|
+
startNewEdge: e("newEdge", { START_NEW_EDGE: ({ payload: e, pContext: { dimensions: t } }) => {
|
|
253
|
+
let { x: n, y: r } = t[e].output;
|
|
254
|
+
return {
|
|
255
|
+
from: e,
|
|
256
|
+
x0: n,
|
|
257
|
+
y0: r,
|
|
258
|
+
x1: n,
|
|
259
|
+
y1: r
|
|
260
|
+
};
|
|
261
|
+
} }),
|
|
262
|
+
setBoard: e("board", { SET_BOARD: ({ payload: e }) => e }),
|
|
263
|
+
buildUI: t(e("edgesPositions", {
|
|
264
|
+
MOVE: ({ context: { data: e, edgesPositions: t }, payload: n, pContext: { dimensions: r } }) => {
|
|
265
|
+
let i = e?.edges, a = r[n.id], o = a?.outputOffset ?? F(a?.width), s = a?.inputOffset ?? P, c = {
|
|
266
|
+
x: n.x + o.x,
|
|
267
|
+
y: n.y + o.y
|
|
268
|
+
}, l = {
|
|
269
|
+
x: n.x + s.x,
|
|
270
|
+
y: n.y + s.y
|
|
271
|
+
};
|
|
272
|
+
return a && (a.output = c, a.input = l), i?.forEach(({ from: e, to: r, id: i }) => {
|
|
273
|
+
e === n.id && (t[i].x0 = c.x, t[i].y0 = c.y), r === n.id && (t[i].x1 = l.x, t[i].y1 = l.y);
|
|
274
|
+
}), t;
|
|
275
|
+
},
|
|
276
|
+
MOVE_IMMEDIATE: ({ context: { data: e, edgesPositions: t }, payload: n, pContext: { dimensions: r } }) => ((e?.edges)?.forEach(({ from: e, to: i, id: a }) => {
|
|
277
|
+
if (e === n.id) {
|
|
278
|
+
let e = r[n.id], i = e?.outputOffset ?? F(e?.width), o = n.x + i.x, s = n.y + i.y;
|
|
279
|
+
t[a].x0 = o, t[a].y0 = s, e && (e.output.x = o, e.output.y = s);
|
|
280
|
+
}
|
|
281
|
+
if (i === n.id) {
|
|
282
|
+
let e = r[n.id], i = e?.inputOffset ?? P, o = n.x + i.x, s = n.y + i.y;
|
|
283
|
+
t[a].x1 = o, t[a].y1 = s, e && (e.input = {
|
|
284
|
+
x: o,
|
|
285
|
+
y: s
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}), t),
|
|
289
|
+
else: ({ context: { data: e, edgesPositions: t }, pContext: { dimensions: n } }) => {
|
|
290
|
+
let r = e?.edges ?? [];
|
|
291
|
+
return t = {}, r.forEach(({ from: e, id: r, to: i }) => {
|
|
292
|
+
let a = n[e]?.output, o = n[i]?.input;
|
|
293
|
+
a && o ? t[r] = {
|
|
294
|
+
x0: a.x,
|
|
295
|
+
y0: a.y,
|
|
296
|
+
x1: o.x,
|
|
297
|
+
y1: o.y
|
|
298
|
+
} : delete t[r];
|
|
299
|
+
}), t;
|
|
300
|
+
}
|
|
301
|
+
}), e("updatingUI", () => !0)),
|
|
302
|
+
addDimension: i({ ADD_DIMENSION: ({ payload: { id: e, dimension: t }, pContext: { dimensions: n } }) => {
|
|
303
|
+
n[e] = t;
|
|
304
|
+
} }),
|
|
305
|
+
generateID: i(({ pContext: e }) => {
|
|
306
|
+
e.generatedId = ee();
|
|
307
|
+
}),
|
|
308
|
+
linkChild: t(e("data.edges", { ADD_CHILD: ({ context: { data: e }, pContext: t, payload: n }) => {
|
|
309
|
+
let r = T.typed(e?.edges), i = n, a = t?.generatedId, o = V(a), s = B(i, o);
|
|
310
|
+
return r.push({
|
|
194
311
|
id: s,
|
|
195
312
|
from: i,
|
|
196
313
|
to: o
|
|
197
|
-
}
|
|
198
|
-
} }), e("
|
|
199
|
-
linkSibling: t(e("
|
|
200
|
-
let r = n
|
|
201
|
-
if (!
|
|
202
|
-
let
|
|
203
|
-
return
|
|
204
|
-
from:
|
|
205
|
-
to:
|
|
206
|
-
id:
|
|
207
|
-
}),
|
|
208
|
-
} }), e("
|
|
209
|
-
selectParent: e("
|
|
210
|
-
moveNode: e("
|
|
314
|
+
}), r;
|
|
315
|
+
} }), e("selected", ({ pContext: { generatedId: e } }) => V(e))),
|
|
316
|
+
linkSibling: t(e("data.edges", { ADD_SIBLING: ({ pContext: e, payload: t, context: { data: n } }) => {
|
|
317
|
+
let r = T.typed(n?.edges), i = e?.generatedId, a = r.find(({ to: e }) => e === t)?.from;
|
|
318
|
+
if (!a) return r;
|
|
319
|
+
let o = V(i), s = B(a, o);
|
|
320
|
+
return r.push({
|
|
321
|
+
from: a,
|
|
322
|
+
to: o,
|
|
323
|
+
id: s
|
|
324
|
+
}), r;
|
|
325
|
+
} }), e("selected", ({ pContext: { generatedId: e } }) => V(e))),
|
|
326
|
+
selectParent: e("selected", ({ pContext: { generatedId: e } }) => V(e)),
|
|
327
|
+
moveNode: e("data.nodes", { MOVE: ({ context: { data: e }, payload: t }) => {
|
|
211
328
|
let { id: n, x: r, y: i } = t;
|
|
212
|
-
return
|
|
329
|
+
return e?.nodes?.map((e) => e.id === n ? {
|
|
213
330
|
...e,
|
|
214
331
|
position: {
|
|
215
332
|
x: r,
|
|
216
333
|
y: i
|
|
217
334
|
}
|
|
218
|
-
} : e) ?? []
|
|
335
|
+
} : e) ?? [];
|
|
219
336
|
} }),
|
|
220
|
-
select: e("
|
|
221
|
-
delete:
|
|
222
|
-
addEdge: e("
|
|
223
|
-
let r = e.data?.edges ?? [], i =
|
|
337
|
+
select: e("selected", { SELECT: ({ payload: e }) => e }),
|
|
338
|
+
delete: t(r("data.edges", { DELETE: ({ id: e, from: t, to: n }, r, { payload: i }) => e !== i && t !== i && n !== i }), r("data.nodes", { DELETE: ({ id: e }, t, { payload: n }) => e !== n })),
|
|
339
|
+
addEdge: t(e("data.edges", { ADD_EDGE: ({ context: e, payload: { from: t, to: n } }) => {
|
|
340
|
+
let r = e.data?.edges ?? [], i = B(t, n);
|
|
224
341
|
return r.some((e) => e.id === i) ? r : [...r, {
|
|
225
342
|
id: i,
|
|
226
343
|
from: t,
|
|
227
344
|
to: n
|
|
228
345
|
}];
|
|
346
|
+
} }), n("newEdge")),
|
|
347
|
+
clearNewEdge: n("newEdge"),
|
|
348
|
+
deselect: n("selected"),
|
|
349
|
+
zoom: e("zoom", { ZOOM: ({ context: { zoom: e }, payload: t, pContext: n }) => {
|
|
350
|
+
let r = e + t, i = Math.min(Math.max(Number(r.toFixed(2)), .2), 3);
|
|
351
|
+
return n.previousZoom = void 0, i;
|
|
229
352
|
} }),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
353
|
+
toggleZoom: e("zoom", { TOGGLE_ZOOM: ({ context: { zoom: e }, pContext: t }) => {
|
|
354
|
+
let n = t.previousZoom;
|
|
355
|
+
return n === void 0 ? (t.previousZoom = e, 1) : (t.previousZoom = void 0, n);
|
|
356
|
+
} })
|
|
357
|
+
} })), [ie, Y] = R(() => {
|
|
358
|
+
let e = C(re, {
|
|
359
|
+
context: {
|
|
360
|
+
zoom: 1,
|
|
361
|
+
edgesPositions: {},
|
|
362
|
+
bounds: {
|
|
363
|
+
x: 0,
|
|
364
|
+
y: 0
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
pContext: {
|
|
368
|
+
generatedId: null,
|
|
369
|
+
dimensions: {},
|
|
370
|
+
getBoardPosition(t, n, r) {
|
|
371
|
+
if (!r) return {
|
|
372
|
+
x: t,
|
|
373
|
+
y: n
|
|
374
|
+
};
|
|
375
|
+
let i = e.state.context.zoom;
|
|
376
|
+
return {
|
|
377
|
+
x: (t - r.self.left) / i,
|
|
378
|
+
y: (n - r.self.top) / i
|
|
379
|
+
};
|
|
380
|
+
},
|
|
381
|
+
clampPosition(t, n, r, i = 192, a = 50) {
|
|
382
|
+
let o = t?.parent;
|
|
383
|
+
if (!o) return {
|
|
384
|
+
x: n,
|
|
385
|
+
y: r
|
|
386
|
+
};
|
|
387
|
+
let s = e.state.context.zoom ?? 1, c = o.scrollLeft / s + I.horizontal, l = Math.max(c, (o.scrollLeft + o.width) / s - I.horizontal - i), u = o.scrollTop / s + I.vertical, d = Math.max(u, (o.scrollTop + o.height) / s - I.vertical - a);
|
|
388
|
+
return {
|
|
389
|
+
x: Math.min(Math.max(n, c), l),
|
|
390
|
+
y: Math.min(Math.max(r, u), d)
|
|
391
|
+
};
|
|
392
|
+
},
|
|
393
|
+
calculateDimensions: (e, t = {
|
|
394
|
+
width: 192,
|
|
395
|
+
height: 50,
|
|
396
|
+
inputOffset: P
|
|
397
|
+
}) => {
|
|
398
|
+
let n = t.width, r = t.height, i = t.outputOffset ?? F(n), a = t.inputOffset;
|
|
399
|
+
return {
|
|
400
|
+
width: n,
|
|
401
|
+
height: r,
|
|
402
|
+
output: {
|
|
403
|
+
x: e.x + i.x,
|
|
404
|
+
y: e.y + i.y
|
|
405
|
+
},
|
|
406
|
+
input: {
|
|
407
|
+
x: e.x + a.x,
|
|
408
|
+
y: e.y + a.y
|
|
409
|
+
},
|
|
410
|
+
outputOffset: i,
|
|
411
|
+
inputOffset: a
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
return e.addOptions(({ assign: e }) => ({ actions: {
|
|
417
|
+
placeChild: e("data.nodes", { ADD_CHILD: ({ payload: e, context: { data: t, board: n }, pContext: r }) => {
|
|
418
|
+
if (!n) return t?.nodes;
|
|
419
|
+
let i = t?.nodes;
|
|
420
|
+
if (!e) return i;
|
|
421
|
+
let a = i?.find((t) => t.id === e);
|
|
422
|
+
if (!a) return i;
|
|
423
|
+
let o = r.dimensions[e], s = `node-${r.generatedId}`, c = o?.width ?? 192, l = o?.height ?? 50, u = a.position.x + c + 100, d = a.position.y, f = r.clampPosition(n, u, d, c, l), p = r.calculateDimensions(f, o);
|
|
424
|
+
return i?.push({
|
|
425
|
+
id: s,
|
|
287
426
|
data: { content: "<Nouveau nœud>" },
|
|
288
427
|
input: !0,
|
|
289
428
|
position: f
|
|
290
|
-
}];
|
|
429
|
+
}), r.dimensions[s] = p, i;
|
|
291
430
|
} }),
|
|
292
|
-
placeParent:
|
|
293
|
-
|
|
294
|
-
|
|
431
|
+
placeParent: e("data.nodes", { ADD_PARENT: ({ context: { data: e, zoom: t = 1, board: n }, pContext: r }) => {
|
|
432
|
+
if (!n) return e?.nodes;
|
|
433
|
+
let i = e?.nodes, a = `node-${r.generatedId}`, o = n.parent, s = o?.scrollLeft ?? 0, c = o?.scrollTop ?? 0, l = o?.width ?? 0, u = o?.height ?? 0, d = t, f = (s + l / 2) / d, p = (c + u / 2) / d, m = r.clampPosition(n, f, p), h = r.calculateDimensions(m);
|
|
434
|
+
return i?.push({
|
|
295
435
|
id: a,
|
|
296
436
|
data: { content: "<Nouveau nœud>" },
|
|
297
437
|
input: !1,
|
|
298
|
-
position:
|
|
299
|
-
|
|
300
|
-
y: p
|
|
301
|
-
}
|
|
302
|
-
}];
|
|
438
|
+
position: m
|
|
439
|
+
}), r.dimensions[a] = h, i;
|
|
303
440
|
} }),
|
|
304
|
-
placeSibling:
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
441
|
+
placeSibling: e("data.nodes", { ADD_SIBLING: ({ payload: e, context: { data: t, board: n }, pContext: r }) => {
|
|
442
|
+
if (!n) return t?.nodes;
|
|
443
|
+
let i = t?.edges, a = t?.nodes, o = i?.find((t) => t.to === e)?.from;
|
|
444
|
+
if (!o) return a;
|
|
445
|
+
let s = a?.find((e) => e.id === o);
|
|
446
|
+
if (!s) return a;
|
|
447
|
+
let c = r.dimensions[o], l = `node-${r.generatedId}`, u = c?.width ?? 192, d = c?.height ?? 50, f = s.position.x + u + 100, p = s.position.y + 100, m = r.clampPosition(n, f, p, u, d), h = r.calculateDimensions(m, c);
|
|
448
|
+
return a?.push({
|
|
449
|
+
id: l,
|
|
312
450
|
data: { content: "<Nouveau nœud>" },
|
|
313
451
|
input: !0,
|
|
314
452
|
position: m
|
|
315
|
-
}];
|
|
453
|
+
}), r.dimensions[l] = h, a;
|
|
316
454
|
} }),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
let t = e?.edges ?? [];
|
|
326
|
-
l(w((e) => {
|
|
327
|
-
t?.forEach(({ from: t, id: n, to: r }) => {
|
|
328
|
-
let i = a()[t]?.output, o = a()[r]?.input;
|
|
329
|
-
i && o && (e[n] = {
|
|
330
|
-
x0: i.x,
|
|
331
|
-
y0: i.y,
|
|
332
|
-
x1: o.x,
|
|
333
|
-
y1: o.y
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
}));
|
|
337
|
-
},
|
|
338
|
-
MOVE: ({ context: { data: e }, payload: t }) => {
|
|
339
|
-
let n = e?.edges ?? [];
|
|
340
|
-
l(w((e) => {
|
|
341
|
-
n?.forEach(({ from: n, to: r, id: i }) => {
|
|
342
|
-
if (n === t.id) {
|
|
343
|
-
let n = a()[t.id]?.outputOffset ?? K(a()[t.id]?.width), r = t.x + n.x, s = t.y + n.y;
|
|
344
|
-
e[i] = {
|
|
345
|
-
...e[i],
|
|
346
|
-
x0: r,
|
|
347
|
-
y0: s
|
|
348
|
-
}, o(w((e) => {
|
|
349
|
-
e[t.id] && (e[t.id] = {
|
|
350
|
-
...e[t.id],
|
|
351
|
-
output: {
|
|
352
|
-
x: r,
|
|
353
|
-
y: s
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
if (r === t.id) {
|
|
359
|
-
let n = a()[t.id]?.inputOffset ?? G, r = t.x + n.x, s = t.y + n.y;
|
|
360
|
-
e[i] = {
|
|
361
|
-
...e[i],
|
|
362
|
-
x1: r,
|
|
363
|
-
y1: s
|
|
364
|
-
}, o(w((e) => {
|
|
365
|
-
e[t.id] && (e[t.id] = {
|
|
366
|
-
...e[t.id],
|
|
367
|
-
input: {
|
|
368
|
-
x: r,
|
|
369
|
-
y: s
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}));
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
}), i("context.updatingUI", () => !0)),
|
|
378
|
-
buildImmediateUI: e({ MOVE_IMMEDIATE: ({ context: { data: e }, payload: t }) => {
|
|
379
|
-
let n = e?.edges ?? [];
|
|
380
|
-
l(w((e) => {
|
|
381
|
-
n?.forEach(({ from: n, to: r, id: i }) => {
|
|
382
|
-
if (n === t.id) {
|
|
383
|
-
let n = a()[t.id]?.outputOffset ?? K(a()[t.id]?.width), r = t.x + n.x, s = t.y + n.y;
|
|
384
|
-
e[i] = {
|
|
385
|
-
...e[i],
|
|
386
|
-
x0: r,
|
|
387
|
-
y0: s
|
|
388
|
-
}, o(w((e) => {
|
|
389
|
-
e[t.id] && (e[t.id] = {
|
|
390
|
-
...e[t.id],
|
|
391
|
-
output: {
|
|
392
|
-
x: r,
|
|
393
|
-
y: s
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}));
|
|
397
|
-
}
|
|
398
|
-
if (r === t.id) {
|
|
399
|
-
let n = a()[t.id]?.inputOffset ?? G, r = t.x + n.x, s = t.y + n.y;
|
|
400
|
-
e[i] = {
|
|
401
|
-
...e[i],
|
|
402
|
-
x1: r,
|
|
403
|
-
y1: s
|
|
404
|
-
}, o(w((e) => {
|
|
405
|
-
e[t.id] && (e[t.id] = {
|
|
406
|
-
...e[t.id],
|
|
407
|
-
input: {
|
|
408
|
-
x: r,
|
|
409
|
-
y: s
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
}));
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}));
|
|
455
|
+
moveNewEdge: e("newEdge", { MOVE_NEW_EDGE: ({ context: { newEdge: e, board: t }, payload: n, pContext: r }) => {
|
|
456
|
+
if (!t || !e) return;
|
|
457
|
+
let { x: i, y: a } = r.getBoardPosition(n.x, n.y, t);
|
|
458
|
+
return {
|
|
459
|
+
...e,
|
|
460
|
+
x1: i,
|
|
461
|
+
y1: a
|
|
462
|
+
};
|
|
416
463
|
} })
|
|
417
|
-
} })), e.start(),
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
getBoardPoint: s,
|
|
422
|
-
edgesPositions: [c, l],
|
|
423
|
-
service: e,
|
|
424
|
-
zoom: t,
|
|
425
|
-
clampPosition: u
|
|
426
|
-
};
|
|
427
|
-
}, { name: "FlowContext" }), Y = Object.prototype.hasOwnProperty;
|
|
428
|
-
function X(e, t, n) {
|
|
429
|
-
for (n of e.keys()) if (Z(n, t)) return n;
|
|
464
|
+
} })), e.start(), e;
|
|
465
|
+
}, { name: "FlowContext" }), X = Object.prototype.hasOwnProperty;
|
|
466
|
+
function Z(e, t, n) {
|
|
467
|
+
for (n of e.keys()) if (Q(n, t)) return n;
|
|
430
468
|
}
|
|
431
|
-
function
|
|
469
|
+
function Q(e, t) {
|
|
432
470
|
var n, r, i;
|
|
433
471
|
if (e === t) return !0;
|
|
434
472
|
if (e && t && (n = e.constructor) === t.constructor) {
|
|
435
473
|
if (n === Date) return e.getTime() === t.getTime();
|
|
436
474
|
if (n === RegExp) return e.toString() === t.toString();
|
|
437
475
|
if (n === Array) {
|
|
438
|
-
if ((r = e.length) === t.length) for (; r-- &&
|
|
476
|
+
if ((r = e.length) === t.length) for (; r-- && Q(e[r], t[r]););
|
|
439
477
|
return r === -1;
|
|
440
478
|
}
|
|
441
479
|
if (n === Set) {
|
|
442
480
|
if (e.size !== t.size) return !1;
|
|
443
|
-
for (r of e) if (i = r, i && typeof i == "object" && (i =
|
|
481
|
+
for (r of e) if (i = r, i && typeof i == "object" && (i = Z(t, i), !i) || !t.has(i)) return !1;
|
|
444
482
|
return !0;
|
|
445
483
|
}
|
|
446
484
|
if (n === Map) {
|
|
447
485
|
if (e.size !== t.size) return !1;
|
|
448
|
-
for (r of e) if (i = r[0], i && typeof i == "object" && (i =
|
|
486
|
+
for (r of e) if (i = r[0], i && typeof i == "object" && (i = Z(t, i), !i) || !Q(r[1], t.get(i))) return !1;
|
|
449
487
|
return !0;
|
|
450
488
|
}
|
|
451
489
|
if (n === ArrayBuffer) e = new Uint8Array(e), t = new Uint8Array(t);
|
|
@@ -458,7 +496,7 @@ function Z(e, t) {
|
|
|
458
496
|
return r === -1;
|
|
459
497
|
}
|
|
460
498
|
if (!n || typeof e == "object") {
|
|
461
|
-
for (n in r = 0, e) if (
|
|
499
|
+
for (n in r = 0, e) if (X.call(e, n) && ++r && !X.call(t, n) || !(n in t) || !Q(e[n], t[n])) return !1;
|
|
462
500
|
return Object.keys(t).length === r;
|
|
463
501
|
}
|
|
464
502
|
}
|
|
@@ -466,236 +504,220 @@ function Z(e, t) {
|
|
|
466
504
|
}
|
|
467
505
|
//#endregion
|
|
468
506
|
//#region src/ui/components/Bounds.tsx
|
|
469
|
-
var
|
|
470
|
-
let
|
|
507
|
+
var ae = () => {
|
|
508
|
+
let e = Y(), t = f(e, { selector: ({ context: e }) => e.zoom }), n = f(e, { selector: ({ context: e }) => e.board }), [r, { addTransformer: i, removeTransformer: a, onDragStart: o, onDragEnd: s }] = j(), c = {
|
|
471
509
|
id: "clamp-to-container",
|
|
472
510
|
order: 100,
|
|
473
|
-
callback: (
|
|
474
|
-
let i =
|
|
475
|
-
if (!i || !a) return
|
|
511
|
+
callback: (e) => {
|
|
512
|
+
let i = n()?.self, a = r.active.draggable;
|
|
513
|
+
if (!i || !a) return e;
|
|
476
514
|
let o = a.node;
|
|
477
|
-
if (!o) return
|
|
478
|
-
let s = t(), c =
|
|
515
|
+
if (!o) return e;
|
|
516
|
+
let s = t(), c = I.horizontal, l = Math.max(c, i.width / s - o.offsetWidth - I.horizontal), u = I.vertical, d = Math.max(u, i.height / s - o.offsetHeight - I.vertical), f = (c - o.offsetLeft) * s, p = (l - o.offsetLeft) * s, m = (u - o.offsetTop) * s, h = (d - o.offsetTop) * s;
|
|
479
517
|
return {
|
|
480
|
-
x: Math.min(Math.max(
|
|
481
|
-
y: Math.min(Math.max(
|
|
518
|
+
x: Math.min(Math.max(e.x, f), p),
|
|
519
|
+
y: Math.min(Math.max(e.y, m), h)
|
|
482
520
|
};
|
|
483
521
|
}
|
|
484
522
|
};
|
|
485
|
-
return
|
|
486
|
-
|
|
487
|
-
}),
|
|
488
|
-
|
|
523
|
+
return o(({ draggable: e }) => {
|
|
524
|
+
i("draggables", e.id, c);
|
|
525
|
+
}), s(({ draggable: e }) => {
|
|
526
|
+
a("draggables", e.id, c.id);
|
|
489
527
|
}), null;
|
|
490
|
-
},
|
|
491
|
-
let
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
e: void 0,
|
|
517
|
-
t: void 0,
|
|
518
|
-
a: void 0
|
|
519
|
-
}), s(), t;
|
|
520
|
-
})(), t(p, {
|
|
528
|
+
}, oe = /*#__PURE__*/ u("<svg><path class=\"relative cursor-pointer fill-transparent\"></svg>", !1, !0, !1), se = /*#__PURE__*/ u("<svg><g cursor=pointer style=pointer-events:all;z-index:30><circle cx=0 cy=0 r=12 fill=\"rgba(168, 168, 168, 1)\"></circle><svg fill=currentColor stroke-width=0 xmlns=http://www.w3.org/2000/svg class=\"h-25 w-25 bg-white fill-white\"width=20 height=20 viewBox=\"0 0 20 20\"color=white x=-10 y=-10><path d=\"M10.185,1.417c-4.741,0-8.583,3.842-8.583,8.583c0,4.74,3.842,8.582,8.583,8.582S18.768,14.74,18.768,10C18.768,5.259,14.926,1.417,10.185,1.417 M10.185,17.68c-4.235,0-7.679-3.445-7.679-7.68c0-4.235,3.444-7.679,7.679-7.679S17.864,5.765,17.864,10C17.864,14.234,14.42,17.68,10.185,17.68 M10.824,10l2.842-2.844c0.178-0.176,0.178-0.46,0-0.637c-0.177-0.178-0.461-0.178-0.637,0l-2.844,2.841L7.341,6.52c-0.176-0.178-0.46-0.178-0.637,0c-0.178,0.176-0.178,0.461,0,0.637L9.546,10l-2.841,2.844c-0.178,0.176-0.178,0.461,0,0.637c0.178,0.178,0.459,0.178,0.637,0l2.844-2.841l2.844,2.841c0.178,0.178,0.459,0.178,0.637,0c0.178-0.176,0.178-0.461,0-0.637L10.824,10z\"></svg>", !1, !0, !1), $ = (e) => e * 100 / 200, ce = ({ x0: e, y0: t, x1: n, y1: r }) => `M ${e} ${t} C ${e + $(Math.abs(n - e))} ${t}, ${n - $(Math.abs(n - e))} ${r}, ${n} ${r}`, le = (n) => {
|
|
529
|
+
let a = Y(), o = f(a, {
|
|
530
|
+
selector: ({ context: e }) => {
|
|
531
|
+
if (n.isNew) {
|
|
532
|
+
let t = e.newEdge;
|
|
533
|
+
return t ? {
|
|
534
|
+
x0: t.x0,
|
|
535
|
+
y0: t.y0,
|
|
536
|
+
x1: t.x1,
|
|
537
|
+
y1: t.y1
|
|
538
|
+
} : void 0;
|
|
539
|
+
}
|
|
540
|
+
return e.edgesPositions[n.id];
|
|
541
|
+
},
|
|
542
|
+
equals: Q
|
|
543
|
+
}), u = f(a, { selector: (e) => e.context.selected === n.id }), d = () => {
|
|
544
|
+
let e = o();
|
|
545
|
+
return e ? {
|
|
546
|
+
x: e.x0 + (e.x1 - e.x0) / 2,
|
|
547
|
+
y: e.y0 + (e.y1 - e.y0) / 2
|
|
548
|
+
} : {
|
|
549
|
+
x: 0,
|
|
550
|
+
y: 0
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
return t(m, {
|
|
521
554
|
get when() {
|
|
522
|
-
return
|
|
555
|
+
return o();
|
|
523
556
|
},
|
|
524
|
-
|
|
525
|
-
var
|
|
526
|
-
return
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
557
|
+
children: (o) => [(() => {
|
|
558
|
+
var t = i(oe);
|
|
559
|
+
return t.$$mousedown = (e) => (e.stopPropagation(), a.send({
|
|
560
|
+
type: "SELECT",
|
|
561
|
+
payload: n.id
|
|
562
|
+
})), r((r) => {
|
|
563
|
+
var i = {
|
|
564
|
+
"stroke-[rgba(168,168,168,0.4)] stroke-3 z-200": !!n.isNew,
|
|
565
|
+
"stroke-[rgba(168,168,168,1)] stroke-4 z-100": u() && !n.isNew,
|
|
566
|
+
"stroke-[rgba(168,168,168,0.8)] stroke-3": !u() && !n.isNew
|
|
567
|
+
}, a = n.isNew ? "none" : "all", s = ce(o());
|
|
568
|
+
return r.e = e(t, i, r.e), a !== r.t && l(t, "pointer-events", r.t = a), s !== r.a && c(t, "d", r.a = s), r;
|
|
569
|
+
}, {
|
|
570
|
+
e: void 0,
|
|
571
|
+
t: void 0,
|
|
572
|
+
a: void 0
|
|
573
|
+
}), s(), t;
|
|
574
|
+
})(), t(m, {
|
|
575
|
+
get when() {
|
|
576
|
+
return u();
|
|
577
|
+
},
|
|
578
|
+
get children() {
|
|
579
|
+
var e = i(se);
|
|
580
|
+
return e.$$mousedown = (e) => {
|
|
581
|
+
e.stopPropagation(), a.send({
|
|
582
|
+
type: "DELETE",
|
|
583
|
+
payload: n.id
|
|
584
|
+
});
|
|
585
|
+
}, r(() => c(e, "transform", `translate(${d().x}, ${d().y})`)), s(), e;
|
|
586
|
+
}
|
|
587
|
+
})]
|
|
588
|
+
});
|
|
534
589
|
};
|
|
535
|
-
n(["mousedown"
|
|
590
|
+
n(["mousedown"]);
|
|
536
591
|
//#endregion
|
|
537
592
|
//#region src/ui/components/EdgesBoard.tsx
|
|
538
|
-
var
|
|
539
|
-
let
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
})
|
|
543
|
-
return
|
|
544
|
-
e()
|
|
545
|
-
|
|
546
|
-
var e = i(ce), n = e.firstChild, [s, l] = a(n.nextSibling), u = s.nextSibling, [d, m] = a(u.nextSibling);
|
|
547
|
-
return o(e, t(p, {
|
|
593
|
+
var ue = /*#__PURE__*/ u("<svg class=\"pointer-events-none h-full w-full overflow-visible\"><!$><!/><!$><!/>"), de = () => {
|
|
594
|
+
let e = Y(), n = f(e, { selector: (e) => !!e.context.newEdge }), r = f(e, {
|
|
595
|
+
selector: ({ context: e }) => Object.keys(e.edgesPositions),
|
|
596
|
+
equals: (e, t) => e.length === t.length
|
|
597
|
+
});
|
|
598
|
+
return (() => {
|
|
599
|
+
var e = i(ue), s = e.firstChild, [c, l] = a(s.nextSibling), u = c.nextSibling, [d, f] = a(u.nextSibling);
|
|
600
|
+
return o(e, t(m, {
|
|
548
601
|
get when() {
|
|
549
|
-
return
|
|
602
|
+
return n();
|
|
550
603
|
},
|
|
551
|
-
children
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return e().y0;
|
|
559
|
-
},
|
|
560
|
-
get x1() {
|
|
561
|
-
return e().x1;
|
|
562
|
-
},
|
|
563
|
-
get y1() {
|
|
564
|
-
return e().y1;
|
|
565
|
-
}
|
|
566
|
-
})
|
|
567
|
-
}), s, l), o(e, t(f, {
|
|
604
|
+
get children() {
|
|
605
|
+
return t(le, {
|
|
606
|
+
id: "__#new-edge#__TEMP",
|
|
607
|
+
isNew: !0
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
}), c, l), o(e, t(p, {
|
|
568
611
|
get each() {
|
|
569
|
-
return
|
|
612
|
+
return r();
|
|
570
613
|
},
|
|
571
|
-
children:
|
|
572
|
-
}), d,
|
|
614
|
+
children: (e) => t(le, { id: e })
|
|
615
|
+
}), d, f), e;
|
|
573
616
|
})();
|
|
574
|
-
},
|
|
575
|
-
let u
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
y: n.y + p
|
|
585
|
-
};
|
|
586
|
-
v(w((e) => {
|
|
587
|
-
e[n.id] = {
|
|
588
|
-
width: h,
|
|
589
|
-
height: g,
|
|
590
|
-
output: _,
|
|
591
|
-
input: y,
|
|
592
|
-
outputOffset: {
|
|
593
|
-
x: c,
|
|
594
|
-
y: l
|
|
595
|
-
},
|
|
596
|
-
inputOffset: {
|
|
597
|
-
x: d,
|
|
598
|
-
y: p
|
|
599
|
-
}
|
|
617
|
+
}, fe = /*#__PURE__*/ u("<svg class=\"cursor-pointer overflow-visible rounded-full bg-green-500 p-0.5 text-center font-bold hover:bg-green-600\"viewBox=\"0 0 1024 1024\"preserveAspectRatio=xMaxYMax xmlns=http://www.w3.org/2000/svg fill=white style=pointer-events:all;fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2><g id=background><path d=\"M467.40667,277.66696c-0.05948,-14.53055 5.75527,-22.95613 -8.62044,-20.90487c-112.55699,16.0607 -222.1609,112.14558 -245.06161,239.85765c-46.52056,259.43466 231.33083,443.06705 449.51209,316.97506c117.31668,-67.80002 160.95215,-190.43324 151.34416,-288.29849c-5.92276,-60.32819 -27.80273,-107.95668 -53.44246,-144.25469l59.39269,-42.05363c111.72214,156.309 73.11535,351.55635 -25.06953,459.45565c-184.18877,202.4124 -470.46624,145.52064 -592.95027,-32.92123c-156.18269,-227.53604 -27.15324,-543.64371 261.18883,-582.44416c5.0579,-0.68061 3.56556,-7.04079 3.56442,-8.58985c-0.05594,-76.3354 -0.11021,-76.7687 1.10909,-77.24589c2.06886,-0.80969 151.41433,118.4561 151.92482,118.95524c4.65592,4.55233 -0.99548,7.829 -29.07828,30.50907c-120.49369,97.31245 -120.4977,98.55675 -123.0691,97.87586c-0.43639,-0.11555 -0.80698,-0.31322 -0.74442,-66.91571Z\"></path><path d=\"M316.61562,611.03414c0.11517,-90.16257 -0.25516,-99.92912 0.64739,-101.78856c1.56486,-3.22393 131.99102,0.91032 134.6959,-1.89763c2.21336,-2.2977 -0.59362,-129.97807 1.1376,-132.37034c0.7253,-1.00225 11.10552,-0.99175 12.07474,-0.99077c104.50336,0.10564 104.90098,-0.37811 105.967,0.85765c1.56461,1.81373 0.25596,114.18436 0.67852,129.81412c0.1322,4.88975 3.22386,3.28152 99.72028,3.4563c33.0841,0.05992 36.14259,-1.40368 36.21852,4.50462c0.11713,9.11348 1.41954,110.45369 -0.40274,113.92715c-1.81106,3.45208 -130.39967,-0.42618 -134.48289,1.62075c-2.29035,1.14816 -0.36989,101.12392 -1.11542,130.51904c-0.09548,3.76459 -2.13506,3.20617 -47.84854,3.17365c-69.30253,-0.0493 -69.31099,-0.25627 -69.65762,-0.42191c-3.77927,-1.80595 0.16287,-129.33555 -2.24266,-132.58994c-1.79931,-2.43424 -124.06108,-0.29118 -132.80252,-0.97392c-3.81102,-0.29766 -2.58229,-14.8847 -2.58758,-16.8402Z\">"), pe = /*#__PURE__*/ u("<div id=outputs class=\"pointer-events-none absolute top-0 z-10 flex cursor-default flex-col\"><div class=\"cursor-default rounded-full bg-[#e38b29] shadow-md\"style=pointer-events:all>"), me = /*#__PURE__*/ u("<div class=min-w-48><div><svg class=\"cursor-pointer rounded-full fill-[#a11111] opacity-100 transition-all duration-200 ease-in-out\"fill=currentColor stroke-width=2 viewBox=\"4 4 16 16\"style=overflow:visible;pointer-events:all><path d=\"M12 4c-4.419 0-8 3.582-8 8s3.581 8 8 8 8-3.582 8-8-3.581-8-8-8zm3.707 10.293a.999.999 0 11-1.414 1.414L12 13.414l-2.293 2.293a.997.997 0 01-1.414 0 .999.999 0 010-1.414L10.586 12 8.293 9.707a.999.999 0 111.414-1.414L12 10.586l2.293-2.293a.999.999 0 111.414 1.414L13.414 12l2.293 2.293z\"></path></svg><!$><!/><svg class=\"flex cursor-pointer items-center justify-center rounded-lg bg-blue-500 p-0.5 text-center font-bold text-white hover:bg-blue-600\"viewBox=\"0 0 24 24\"stroke=currentColor stroke-width=2 style=pointer-events:all><path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"></path></svg></div><!$><!/><!$><!/><!$><!/><div id=inputs class=\"pointer-events-none absolute top-0 z-10 flex flex-col\"><div class=\"cursor-crosshair rounded-full bg-[#e38b29] shadow-md\"style=pointer-events:all>"), he = /*#__PURE__*/ u("<span class=\"min-w-max border-b border-[#f0f0f0] p-3 whitespace-nowrap text-red-600 select-none\">"), ge = /*#__PURE__*/ u("<div class=\"p-3 select-none\">"), _e = (n) => {
|
|
618
|
+
let u = Y(), p = f(u, {
|
|
619
|
+
selector: ({ context: e }) => {
|
|
620
|
+
let t = w.typed(e.data?.nodes).find((e) => e.id === n.id);
|
|
621
|
+
if (t) return {
|
|
622
|
+
x: t.position.x,
|
|
623
|
+
y: t.position.y,
|
|
624
|
+
label: t.data.label,
|
|
625
|
+
content: t.data.content ?? "",
|
|
626
|
+
input: t.input
|
|
600
627
|
};
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
628
|
+
},
|
|
629
|
+
equals: Q
|
|
630
|
+
}), h = f(u, { selector: (e) => e.context.newEdge }), g = f(u, { selector: (e) => e.context.selected === n.id }), _ = f(u, { selector: ({ context: { data: e } }) => {
|
|
604
631
|
let t = e?.edges;
|
|
605
632
|
return t ? t.some(({ to: e }) => e === n.id) : !1;
|
|
606
|
-
} }),
|
|
633
|
+
} }), v = A(n.id);
|
|
607
634
|
return (() => {
|
|
608
|
-
var
|
|
609
|
-
return
|
|
610
|
-
e.stopPropagation(),
|
|
635
|
+
var f = i(me), y = f.firstChild, b = y.firstChild, x = b.nextSibling, [S, C] = a(x.nextSibling), w = S.nextSibling, T = y.nextSibling, [E, D] = a(T.nextSibling), O = E.nextSibling, [k, A] = a(O.nextSibling), j = k.nextSibling, [M, N] = a(j.nextSibling), P = M.nextSibling, F = P.firstChild;
|
|
636
|
+
return f.$$mousedown = (e) => {
|
|
637
|
+
e.stopPropagation(), u.send({
|
|
611
638
|
type: "SELECT",
|
|
612
639
|
payload: n.id
|
|
613
640
|
});
|
|
614
|
-
}, d(
|
|
615
|
-
e.stopPropagation(),
|
|
641
|
+
}, d(v, f, () => ({ skipTransform: !0 })), b.$$click = (e) => {
|
|
642
|
+
e.stopPropagation(), u.send({
|
|
616
643
|
type: "DELETE",
|
|
617
644
|
payload: n.id
|
|
618
645
|
});
|
|
619
|
-
}, l(
|
|
646
|
+
}, l(b, "width", "24px"), l(b, "height", "24px"), o(y, t(m, {
|
|
620
647
|
get when() {
|
|
621
|
-
return
|
|
648
|
+
return _();
|
|
622
649
|
},
|
|
623
650
|
get children() {
|
|
624
|
-
var e = i(
|
|
625
|
-
return e.$$click = () =>
|
|
651
|
+
var e = i(fe);
|
|
652
|
+
return e.$$click = () => u.send({
|
|
626
653
|
type: "ADD_SIBLING",
|
|
627
654
|
payload: n.id
|
|
628
655
|
}), l(e, "width", "24px"), l(e, "height", "24px"), s(), e;
|
|
629
656
|
}
|
|
630
|
-
}),
|
|
657
|
+
}), S, C), w.$$click = () => u.send({
|
|
631
658
|
type: "ADD_CHILD",
|
|
632
659
|
payload: n.id
|
|
633
|
-
}), l(
|
|
660
|
+
}), l(w, "width", "24px"), l(w, "height", "24px"), o(f, t(m, {
|
|
634
661
|
get when() {
|
|
635
|
-
return
|
|
662
|
+
return p()?.label;
|
|
636
663
|
},
|
|
637
664
|
keyed: !0,
|
|
638
665
|
children: (e) => (() => {
|
|
639
|
-
var t = i(
|
|
666
|
+
var t = i(he);
|
|
640
667
|
return o(t, e), t;
|
|
641
668
|
})()
|
|
642
|
-
}),
|
|
669
|
+
}), E, D), o(f, t(m, {
|
|
643
670
|
get when() {
|
|
644
|
-
return
|
|
671
|
+
return p()?.content;
|
|
645
672
|
},
|
|
646
673
|
keyed: !0,
|
|
647
674
|
children: (e) => (() => {
|
|
648
|
-
var t = i(
|
|
675
|
+
var t = i(ge);
|
|
649
676
|
return o(t, e), t;
|
|
650
677
|
})()
|
|
651
|
-
}),
|
|
678
|
+
}), k, A), o(f, t(m, {
|
|
652
679
|
get when() {
|
|
653
|
-
return
|
|
680
|
+
return p()?.input || _();
|
|
654
681
|
},
|
|
655
682
|
get children() {
|
|
656
|
-
var e = i(
|
|
683
|
+
var e = i(pe), t = e.firstChild;
|
|
657
684
|
return l(e, "left", "-18px"), t.$$mouseup = (e) => {
|
|
658
685
|
e.stopPropagation();
|
|
659
|
-
let t =
|
|
660
|
-
t
|
|
686
|
+
let t = h()?.from;
|
|
687
|
+
t ? u.send({
|
|
661
688
|
type: "ADD_EDGE",
|
|
662
689
|
payload: {
|
|
663
690
|
from: t,
|
|
664
691
|
to: n.id
|
|
665
692
|
}
|
|
666
|
-
})
|
|
693
|
+
}) : u.send("CLEAR_NEW_EDGE");
|
|
667
694
|
}, t.$$mousedown = (e) => {
|
|
668
695
|
e.stopPropagation();
|
|
669
|
-
},
|
|
696
|
+
}, l(t, "width", "12px"), l(t, "height", "12px"), l(t, "margin-top", "12px"), s(), e;
|
|
670
697
|
}
|
|
671
|
-
}),
|
|
672
|
-
e.stopPropagation(),
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
x0: t.x,
|
|
676
|
-
y0: t.y,
|
|
677
|
-
x1: r.x,
|
|
678
|
-
y1: r.y,
|
|
679
|
-
from: n.id
|
|
698
|
+
}), M, N), l(P, "right", "-18px"), F.$$mousedown = (e) => {
|
|
699
|
+
e.stopPropagation(), u.send("DESELECT"), u.send({
|
|
700
|
+
type: "START_NEW_EDGE",
|
|
701
|
+
payload: n.id
|
|
680
702
|
});
|
|
681
|
-
},
|
|
682
|
-
var r =
|
|
703
|
+
}, l(F, "width", "12px"), l(F, "height", "12px"), l(F, "margin-top", "12px"), r((t) => {
|
|
704
|
+
var r = {
|
|
683
705
|
"flex flex-col absolute cursor-grab bg-white rounded-md shadow-md select-none transition-[border,box-shadow] duration-200 ease-in-out hover:shadow-lg draggable": !0,
|
|
684
|
-
"border border-[#e38c29] z-[100]":
|
|
685
|
-
"border border-[#e6d4be] z-[1]": !
|
|
686
|
-
},
|
|
706
|
+
"border border-[#e38c29] z-[100]": g(),
|
|
707
|
+
"border border-[#e6d4be] z-[1]": !g()
|
|
708
|
+
}, i = `${p()?.y ?? 0}px`, a = `${p()?.x ?? 0}px`, o = n.id, s = {
|
|
687
709
|
"pointer-events-none absolute flex items-center justify-end -top-7.5 right-0 transition-all duration-200 ease-in-out space-x-2": !0,
|
|
688
|
-
"w-full opacity-100":
|
|
689
|
-
"w-0 -right-3 opacity-0 overflow-hidden": !
|
|
710
|
+
"w-full opacity-100": g(),
|
|
711
|
+
"w-0 -right-3 opacity-0 overflow-hidden": !g()
|
|
690
712
|
};
|
|
691
|
-
return
|
|
713
|
+
return t.e = e(f, r, t.e), i !== t.t && l(f, "top", t.t = i), a !== t.a && l(f, "left", t.a = a), o !== t.o && c(f, "id", t.o = o), t.i = e(y, s, t.i), t;
|
|
692
714
|
}, {
|
|
693
715
|
e: void 0,
|
|
694
716
|
t: void 0,
|
|
695
717
|
a: void 0,
|
|
696
718
|
o: void 0,
|
|
697
719
|
i: void 0
|
|
698
|
-
}), s(),
|
|
720
|
+
}), s(), f;
|
|
699
721
|
})();
|
|
700
722
|
};
|
|
701
723
|
n([
|
|
@@ -705,66 +727,86 @@ n([
|
|
|
705
727
|
]);
|
|
706
728
|
//#endregion
|
|
707
729
|
//#region src/ui/components/NodesBoard.tsx
|
|
708
|
-
var
|
|
709
|
-
let e, [n, c] = _(!1), [u,
|
|
730
|
+
var ve = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-auto rounded-lg border-2 border-gray-600\"><!$><!/><div class=\"relative cursor-crosshair overflow-hidden\"><div class=\"relative h-full w-full\"style=\"transform-origin:top left\"><!$><!/><!$><!/><!$><!/>"), ye = /*#__PURE__*/ u("<div class=\"absolute right-4 bottom-4 z-50 flex items-center gap-2 rounded-xl border border-gray-200 bg-white/90 p-2 shadow-lg backdrop-blur-md\"><button type=button class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-gray-100 text-lg font-bold text-gray-700 shadow-sm transition-all duration-150 hover:bg-gray-200 active:scale-95\"title=\"Zoom out\"aria-label=\"Zoom out\">-</button><button type=button class=\"h-9 cursor-pointer rounded-lg px-2 text-xs font-semibold text-gray-700 transition-colors hover:bg-gray-100\"title=\"Reset zoom\"aria-label=\"Reset zoom\"><!$><!/>%</button><button type=button class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-gray-100 text-lg font-bold text-gray-700 shadow-sm transition-all duration-150 hover:bg-gray-200 active:scale-95\"title=\"Zoom in\"aria-label=\"Zoom in\">+</button><div class=\"h-5 w-px bg-gray-300\"></div><button type=button class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-blue-600 text-white shadow transition-all duration-150 hover:bg-blue-700 active:scale-95\"title=\"Add parent node\"aria-label=\"Add parent node\"><svg class=size-5 viewBox=\"0 0 24 24\"fill=currentColor><path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\">"), be = /*#__PURE__*/ u("<div class=\"relative mx-auto h-[calc(100vh-64px)] w-[calc(100vw-32px)] overflow-hidden\">"), xe = () => {
|
|
731
|
+
let e, [n, c] = _(!1), [u, h] = _({
|
|
710
732
|
x: 0,
|
|
711
733
|
y: 0
|
|
712
|
-
}), [
|
|
734
|
+
}), [y, x] = _(""), [S, C] = _(), T = 0, E = 0, A = Y(), j = f(A, {
|
|
735
|
+
selector: (e) => e.context.newEdge,
|
|
736
|
+
equals: Q
|
|
737
|
+
}), M = f(A, { selector: (e) => e.context.zoom ?? 1 }), N = () => {
|
|
738
|
+
let e = S();
|
|
739
|
+
if (!e) return;
|
|
740
|
+
let t = e.getBoundingClientRect(), n = () => S()?.parentElement, r = {
|
|
741
|
+
self: {
|
|
742
|
+
left: t.left,
|
|
743
|
+
top: t.top,
|
|
744
|
+
width: e.clientWidth,
|
|
745
|
+
height: e.clientHeight
|
|
746
|
+
},
|
|
747
|
+
parent: n() ? {
|
|
748
|
+
scrollLeft: n().scrollLeft,
|
|
749
|
+
scrollTop: n().scrollTop,
|
|
750
|
+
height: n().clientHeight,
|
|
751
|
+
width: n().clientWidth
|
|
752
|
+
} : void 0
|
|
753
|
+
};
|
|
754
|
+
A.send({
|
|
755
|
+
type: "SET_BOARD",
|
|
756
|
+
payload: r
|
|
757
|
+
});
|
|
758
|
+
}, P = () => {
|
|
713
759
|
let t = e.scrollWidth - e.clientWidth, n = e.scrollHeight - e.clientHeight;
|
|
714
|
-
|
|
760
|
+
T = t > 0 ? e.scrollLeft / t : 0, E = n > 0 ? e.scrollTop / n : 0, N();
|
|
715
761
|
};
|
|
716
|
-
|
|
762
|
+
g(v(M, () => {
|
|
717
763
|
let t = e.scrollWidth - e.clientWidth, n = e.scrollHeight - e.clientHeight;
|
|
718
|
-
t > 0 && (e.scrollLeft =
|
|
719
|
-
}, { defer: !0 }));
|
|
720
|
-
let
|
|
721
|
-
selector: (e) => (e.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
y: e.position.y,
|
|
725
|
-
label: e.data.label,
|
|
726
|
-
content: e.data.content ?? "",
|
|
727
|
-
input: e.input
|
|
728
|
-
})),
|
|
729
|
-
equals: Z
|
|
730
|
-
}), L = () => `calc((500vw - 265px) * ${j()})`, R = () => `calc((500vh - 425px) * ${j()})`;
|
|
764
|
+
t > 0 && (e.scrollLeft = T * t), n > 0 && (e.scrollTop = E * n);
|
|
765
|
+
}, { defer: !0 })), b(N);
|
|
766
|
+
let F = f(A, { selector: (e) => e.context?.selected }), I = (e) => F() === e, L = f(A, {
|
|
767
|
+
selector: ({ context: e }) => w.typed(e.data?.nodes).map((e) => e.id),
|
|
768
|
+
equals: (e, t) => e.length === t.length
|
|
769
|
+
}), R = () => `calc((500vw - 265px) * ${M()})`, z = () => `calc((500vh - 425px) * ${M()})`;
|
|
731
770
|
return (() => {
|
|
732
|
-
var
|
|
733
|
-
return
|
|
771
|
+
var f = i(be);
|
|
772
|
+
return f.addEventListener("wheel", (e) => {
|
|
734
773
|
if (e.ctrlKey || e.metaKey) {
|
|
735
|
-
e.preventDefault(),
|
|
774
|
+
e.preventDefault(), P();
|
|
736
775
|
let t = e.deltaY < 0 ? .1 : -.1;
|
|
737
|
-
|
|
776
|
+
A.send({
|
|
777
|
+
type: "ZOOM",
|
|
778
|
+
payload: t
|
|
779
|
+
});
|
|
738
780
|
}
|
|
739
|
-
}), o(
|
|
781
|
+
}), o(f, t(D, {
|
|
740
782
|
onDragMove: ({ draggable: { transform: e, node: t, id: n } }) => {
|
|
741
|
-
if (
|
|
742
|
-
let r = t.parentElement?.parentElement, i =
|
|
743
|
-
t.style.setProperty("transform", `translate3d(${d}px, ${f}px, 0)`),
|
|
783
|
+
if (x(n), I(n)) {
|
|
784
|
+
let r = t.parentElement?.parentElement, i = M(), a = r ? Math.max(0, r.clientWidth / i - t.offsetWidth) : Infinity, o = r ? Math.max(0, r.clientHeight / i - t.offsetHeight) : Infinity, s = t.offsetLeft + e.x / i, c = t.offsetTop + e.y / i, l = Math.min(Math.max(s, 0), a), u = Math.min(Math.max(c, 0), o), d = l - t.offsetLeft, f = u - t.offsetTop;
|
|
785
|
+
t.style.setProperty("transform", `translate3d(${d}px, ${f}px, 0)`), A.send({
|
|
744
786
|
type: "MOVE_IMMEDIATE",
|
|
745
787
|
payload: {
|
|
746
788
|
id: `${n}`,
|
|
747
789
|
x: l,
|
|
748
790
|
y: u
|
|
749
791
|
}
|
|
750
|
-
}),
|
|
792
|
+
}), h({
|
|
751
793
|
x: d * i,
|
|
752
794
|
y: f * i
|
|
753
795
|
});
|
|
754
796
|
}
|
|
755
797
|
},
|
|
756
798
|
onDragEnd: ({ draggable: { node: e, id: t } }) => {
|
|
757
|
-
if (!
|
|
758
|
-
let n = e.parentElement?.parentElement, r =
|
|
759
|
-
e.style.setProperty("top", l + "px"), e.style.setProperty("left", c + "px"), e.style.removeProperty("transform"),
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
799
|
+
if (!I(t)) return;
|
|
800
|
+
let n = e.parentElement?.parentElement, r = M(), i = n ? Math.max(0, n.clientWidth / r - e.offsetWidth) : Infinity, a = n ? Math.max(0, n.clientHeight / r - e.offsetHeight) : Infinity, o = e.offsetLeft + u().x / r, s = e.offsetTop + u().y / r, c = Math.min(Math.max(o, 0), i), l = Math.min(Math.max(s, 0), a);
|
|
801
|
+
e.style.setProperty("top", l + "px"), e.style.setProperty("left", c + "px"), e.style.removeProperty("transform"), A.send({
|
|
802
|
+
type: "MOVE",
|
|
803
|
+
payload: {
|
|
804
|
+
id: `${t}`,
|
|
805
|
+
x: c,
|
|
806
|
+
y: l
|
|
807
|
+
}
|
|
808
|
+
}), setTimeout(() => {
|
|
809
|
+
h({
|
|
768
810
|
x: 0,
|
|
769
811
|
y: 0
|
|
770
812
|
});
|
|
@@ -773,26 +815,26 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
773
815
|
get children() {
|
|
774
816
|
return [
|
|
775
817
|
(() => {
|
|
776
|
-
var u = i(
|
|
777
|
-
return u.addEventListener("scroll",
|
|
778
|
-
if (
|
|
779
|
-
|
|
818
|
+
var u = i(ve), f = u.firstChild, [m, h] = a(f.nextSibling), g = m.nextSibling, _ = g.firstChild, v = _.firstChild, [y, b] = a(v.nextSibling), x = y.nextSibling, [S, w] = a(x.nextSibling), T = S.nextSibling, [E, D] = a(T.nextSibling);
|
|
819
|
+
return u.addEventListener("scroll", P), d((t) => e = t, u), o(u, t(O, {}), m, h), g.$$mousedown = (t) => {
|
|
820
|
+
if (j() || t.button !== 0) return;
|
|
821
|
+
A.send("DESELECT");
|
|
780
822
|
let n = t.clientX, r = t.clientY, i = e.scrollLeft, a = e.scrollTop;
|
|
781
823
|
c(!0);
|
|
782
824
|
let o = (t) => {
|
|
783
825
|
let o = t.clientX - n, s = t.clientY - r;
|
|
784
|
-
e.scrollLeft = i - o * 3, e.scrollTop = a - s * 3,
|
|
826
|
+
e.scrollLeft = i - o * 3, e.scrollTop = a - s * 3, P();
|
|
785
827
|
}, s = () => {
|
|
786
828
|
window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", s), setTimeout(() => c(!1), 200);
|
|
787
829
|
};
|
|
788
830
|
window.addEventListener("mousemove", o), window.addEventListener("mouseup", s);
|
|
789
|
-
}, d(
|
|
831
|
+
}, g.addEventListener("scroll", () => {}), d(C, g), o(_, t(ae, {}), y, b), o(_, t(de, {}), S, w), o(_, t(p, {
|
|
790
832
|
get each() {
|
|
791
|
-
return
|
|
833
|
+
return L();
|
|
792
834
|
},
|
|
793
|
-
children:
|
|
794
|
-
}),
|
|
795
|
-
var t = !!n(), r =
|
|
835
|
+
children: (e) => t(_e, { id: e })
|
|
836
|
+
}), E, D), r((e) => {
|
|
837
|
+
var t = !!n(), r = z(), i = R(), a = M();
|
|
796
838
|
return t !== e.e && g.classList.toggle("cursor-grabbing", e.e = t), r !== e.t && l(g, "height", e.t = r), i !== e.a && l(g, "width", e.a = i), a !== e.o && l(_, "scale", e.o = a), e;
|
|
797
839
|
}, {
|
|
798
840
|
e: void 0,
|
|
@@ -802,20 +844,26 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
802
844
|
}), s(), u;
|
|
803
845
|
})(),
|
|
804
846
|
(() => {
|
|
805
|
-
var e = i(
|
|
847
|
+
var e = i(ye), t = e.firstChild, n = t.nextSibling, r = n.firstChild, [c, l] = a(r.nextSibling);
|
|
806
848
|
c.nextSibling;
|
|
807
849
|
var u = n.nextSibling, d = u.nextSibling.nextSibling;
|
|
808
850
|
return t.$$click = () => {
|
|
809
|
-
|
|
851
|
+
P(), A.send({
|
|
852
|
+
type: "ZOOM",
|
|
853
|
+
payload: -.1
|
|
854
|
+
});
|
|
810
855
|
}, n.$$click = () => {
|
|
811
|
-
|
|
812
|
-
}, o(n, () => Math.round(
|
|
813
|
-
|
|
814
|
-
|
|
856
|
+
P(), A.send("TOGGLE_ZOOM");
|
|
857
|
+
}, o(n, () => Math.round(M() * 100), c, l), u.$$click = () => {
|
|
858
|
+
P(), A.send({
|
|
859
|
+
type: "ZOOM",
|
|
860
|
+
payload: .1
|
|
861
|
+
});
|
|
862
|
+
}, d.$$click = () => A.send("ADD_PARENT"), s(), e;
|
|
815
863
|
})(),
|
|
816
|
-
t(
|
|
864
|
+
t(m, {
|
|
817
865
|
get when() {
|
|
818
|
-
return !
|
|
866
|
+
return !y() || !I(y());
|
|
819
867
|
},
|
|
820
868
|
get children() {
|
|
821
869
|
return t(k, { children: "" });
|
|
@@ -823,42 +871,40 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
823
871
|
})
|
|
824
872
|
];
|
|
825
873
|
}
|
|
826
|
-
})),
|
|
874
|
+
})), f;
|
|
827
875
|
})();
|
|
828
876
|
};
|
|
829
877
|
n(["mousedown", "click"]);
|
|
830
878
|
//#endregion
|
|
831
879
|
//#region src/ui/components/FlowChart.tsx
|
|
832
|
-
var
|
|
833
|
-
let n = e.config?.nodes ??
|
|
880
|
+
var Se = /*#__PURE__*/ u("<div class=\"relative h-full w-full\"><div class=\"relative h-full w-full bg-white bg-size-[30px_30px]\"style=\"background-image:radial-gradient(circle, #b8b8b8bf 1px, rgba(0, 0, 0, 0) 1px)\">"), Ce = (e) => {
|
|
881
|
+
let n = e.config?.nodes ?? L, a = e.config?.edges, c = Y(), u = f(c, { selector: (e) => !!e.context.newEdge });
|
|
834
882
|
return b(() => {
|
|
835
|
-
c.
|
|
883
|
+
c.resume(), c.send({
|
|
836
884
|
type: "CONFIGURE",
|
|
837
885
|
payload: {
|
|
838
886
|
nodes: n,
|
|
839
887
|
edges: a ?? []
|
|
840
888
|
}
|
|
841
889
|
});
|
|
842
|
-
}), y(c.
|
|
843
|
-
var e = i(
|
|
890
|
+
}), y(c.pause), (() => {
|
|
891
|
+
var e = i(Se), n = e.firstChild;
|
|
844
892
|
return e.$$mousemove = (e) => {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
}, e.$$mouseup = () => d(), o(n, t(ye, {})), r((e) => l(n, "cursor", u() ? "inherit" : "crosshair")), s(), e;
|
|
893
|
+
c.send({
|
|
894
|
+
type: "MOVE_NEW_EDGE",
|
|
895
|
+
payload: {
|
|
896
|
+
x: e.clientX,
|
|
897
|
+
y: e.clientY
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}, e.$$mouseup = () => c.send("CLEAR_NEW_EDGE"), o(n, t(xe, {})), r((e) => l(n, "cursor", u() ? "inherit" : "crosshair")), s(), e;
|
|
855
901
|
})();
|
|
856
902
|
};
|
|
857
903
|
n(["mouseup", "mousemove"]);
|
|
858
904
|
//#endregion
|
|
859
905
|
//#region src/ui/Flow.tsx
|
|
860
|
-
var
|
|
861
|
-
return t(
|
|
906
|
+
var we = (e) => t(ie, { get children() {
|
|
907
|
+
return t(Ce, e);
|
|
862
908
|
} });
|
|
863
909
|
//#endregion
|
|
864
|
-
export { M as CLASSES,
|
|
910
|
+
export { M as CLASSES, we as Flow };
|