@bemedev/mind-flow 0.1.1 → 0.3.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.
- 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 +520 -493
- package/lib/output.css +1 -1
- package/lib/server.cjs.js +621 -413
- package/lib/server.es.js +625 -417
- 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} +4 -2
- 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 +10 -10
- package/src/helpers/createContext.ts +7 -2
- package/src/{ui/components/FlowChart.data.ts → services/main.machine.data.ts} +3 -1
- 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 +30 -18
- package/src/ui/components/EdgesBoard.tsx +13 -36
- package/src/ui/components/FlowChart.context.ts +204 -310
- package/src/ui/components/FlowChart.tsx +16 -16
- package/src/ui/components/NodeComponent.tsx +59 -104
- package/src/ui/components/NodesBoard.tsx +74 -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,201 @@ 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
|
-
let d = E(u, { selector: (e) => e.context.selected === n.id });
|
|
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: { newEdge: e, edgesPositions: t } }) => n.isNew ? e : t[n.id],
|
|
531
|
+
equals: Q
|
|
532
|
+
}), u = f(a, { selector: (e) => e.context.selected === n.id }), d = () => {
|
|
533
|
+
let e = o();
|
|
534
|
+
return {
|
|
535
|
+
x: e.x0 + (e.x1 - e.x0) / 2,
|
|
536
|
+
y: e.y0 + (e.y1 - e.y0) / 2
|
|
537
|
+
};
|
|
538
|
+
};
|
|
503
539
|
return [(() => {
|
|
504
|
-
var t = i(
|
|
505
|
-
return t.$$
|
|
540
|
+
var t = i(oe);
|
|
541
|
+
return t.$$mousedown = (e) => (e.stopPropagation(), a.send({
|
|
506
542
|
type: "SELECT",
|
|
507
543
|
payload: n.id
|
|
508
|
-
})
|
|
544
|
+
})), r((r) => {
|
|
509
545
|
var i = {
|
|
510
546
|
"stroke-[rgba(168,168,168,0.4)] stroke-3 z-200": !!n.isNew,
|
|
511
|
-
"stroke-[rgba(168,168,168,1)] stroke-4 z-100":
|
|
512
|
-
"stroke-[rgba(168,168,168,0.8)] stroke-3": !
|
|
513
|
-
}, a = n.isNew ? "none" : "all",
|
|
514
|
-
return r.e = e(t, i, r.e), a !== r.t && l(t, "pointer-events", r.t = a),
|
|
547
|
+
"stroke-[rgba(168,168,168,1)] stroke-4 z-100": u() && !n.isNew,
|
|
548
|
+
"stroke-[rgba(168,168,168,0.8)] stroke-3": !u() && !n.isNew
|
|
549
|
+
}, a = n.isNew ? "none" : "all", s = ce(o());
|
|
550
|
+
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;
|
|
515
551
|
}, {
|
|
516
552
|
e: void 0,
|
|
517
553
|
t: void 0,
|
|
518
554
|
a: void 0
|
|
519
555
|
}), s(), t;
|
|
520
|
-
})(), t(
|
|
556
|
+
})(), t(m, {
|
|
521
557
|
get when() {
|
|
522
|
-
return
|
|
558
|
+
return u();
|
|
523
559
|
},
|
|
524
560
|
get children() {
|
|
525
|
-
var e = i(
|
|
561
|
+
var e = i(se);
|
|
526
562
|
return e.$$mousedown = (e) => {
|
|
527
|
-
e.stopPropagation(),
|
|
563
|
+
e.stopPropagation(), a.send({
|
|
528
564
|
type: "DELETE",
|
|
529
565
|
payload: n.id
|
|
530
566
|
});
|
|
531
|
-
}, r(() => c(e, "transform", `translate(${
|
|
567
|
+
}, r(() => c(e, "transform", `translate(${d().x}, ${d().y})`)), s(), e;
|
|
532
568
|
}
|
|
533
569
|
})];
|
|
534
570
|
};
|
|
535
|
-
n(["mousedown"
|
|
571
|
+
n(["mousedown"]);
|
|
536
572
|
//#endregion
|
|
537
573
|
//#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, {
|
|
574
|
+
var ue = /*#__PURE__*/ u("<svg class=\"pointer-events-none h-full w-full overflow-visible\"><!$><!/><!$><!/>"), de = () => {
|
|
575
|
+
let e = Y(), n = f(e, { selector: (e) => !!e.context.newEdge }), r = f(e, {
|
|
576
|
+
selector: ({ context: e }) => Object.keys(e.edgesPositions),
|
|
577
|
+
equals: (e, t) => e.length === t.length
|
|
578
|
+
});
|
|
579
|
+
return (() => {
|
|
580
|
+
var e = i(ue), s = e.firstChild, [c, l] = a(s.nextSibling), u = c.nextSibling, [d, f] = a(u.nextSibling);
|
|
581
|
+
return o(e, t(m, {
|
|
548
582
|
get when() {
|
|
549
|
-
return
|
|
583
|
+
return n();
|
|
550
584
|
},
|
|
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, {
|
|
585
|
+
get children() {
|
|
586
|
+
return t(le, {
|
|
587
|
+
id: "__#new-edge#__TEMP",
|
|
588
|
+
isNew: !0
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
}), c, l), o(e, t(p, {
|
|
568
592
|
get each() {
|
|
569
|
-
return
|
|
593
|
+
return r();
|
|
570
594
|
},
|
|
571
|
-
children:
|
|
572
|
-
}), d,
|
|
595
|
+
children: (e) => t(le, { id: e })
|
|
596
|
+
}), d, f), e;
|
|
573
597
|
})();
|
|
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
|
-
}
|
|
598
|
+
}, 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) => {
|
|
599
|
+
let u = Y(), p = f(u, {
|
|
600
|
+
selector: ({ context: e }) => {
|
|
601
|
+
let t = w.typed(e.data?.nodes).find((e) => e.id === n.id);
|
|
602
|
+
return {
|
|
603
|
+
x: t.position.x,
|
|
604
|
+
y: t.position.y,
|
|
605
|
+
label: t.data.label,
|
|
606
|
+
content: t.data.content ?? "",
|
|
607
|
+
input: t.input
|
|
600
608
|
};
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
609
|
+
},
|
|
610
|
+
equals: Q
|
|
611
|
+
}), 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
612
|
let t = e?.edges;
|
|
605
613
|
return t ? t.some(({ to: e }) => e === n.id) : !1;
|
|
606
|
-
} }),
|
|
614
|
+
} }), v = A(n.id);
|
|
607
615
|
return (() => {
|
|
608
|
-
var
|
|
609
|
-
return
|
|
610
|
-
e.stopPropagation(),
|
|
616
|
+
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;
|
|
617
|
+
return f.$$mousedown = (e) => {
|
|
618
|
+
e.stopPropagation(), u.send({
|
|
611
619
|
type: "SELECT",
|
|
612
620
|
payload: n.id
|
|
613
621
|
});
|
|
614
|
-
}, d(
|
|
615
|
-
e.stopPropagation(),
|
|
622
|
+
}, d(v, f, () => ({ skipTransform: !0 })), b.$$click = (e) => {
|
|
623
|
+
e.stopPropagation(), u.send({
|
|
616
624
|
type: "DELETE",
|
|
617
625
|
payload: n.id
|
|
618
626
|
});
|
|
619
|
-
}, l(
|
|
627
|
+
}, l(b, "width", "24px"), l(b, "height", "24px"), o(y, t(m, {
|
|
620
628
|
get when() {
|
|
621
|
-
return
|
|
629
|
+
return _();
|
|
622
630
|
},
|
|
623
631
|
get children() {
|
|
624
|
-
var e = i(
|
|
625
|
-
return e.$$click = () =>
|
|
632
|
+
var e = i(fe);
|
|
633
|
+
return e.$$click = () => u.send({
|
|
626
634
|
type: "ADD_SIBLING",
|
|
627
635
|
payload: n.id
|
|
628
636
|
}), l(e, "width", "24px"), l(e, "height", "24px"), s(), e;
|
|
629
637
|
}
|
|
630
|
-
}),
|
|
638
|
+
}), S, C), w.$$click = () => u.send({
|
|
631
639
|
type: "ADD_CHILD",
|
|
632
640
|
payload: n.id
|
|
633
|
-
}), l(
|
|
641
|
+
}), l(w, "width", "24px"), l(w, "height", "24px"), o(f, t(m, {
|
|
634
642
|
get when() {
|
|
635
|
-
return
|
|
643
|
+
return p().label;
|
|
636
644
|
},
|
|
637
645
|
keyed: !0,
|
|
638
646
|
children: (e) => (() => {
|
|
639
|
-
var t = i(
|
|
647
|
+
var t = i(he);
|
|
640
648
|
return o(t, e), t;
|
|
641
649
|
})()
|
|
642
|
-
}),
|
|
650
|
+
}), E, D), o(f, t(m, {
|
|
643
651
|
get when() {
|
|
644
|
-
return
|
|
652
|
+
return p().content;
|
|
645
653
|
},
|
|
646
654
|
keyed: !0,
|
|
647
655
|
children: (e) => (() => {
|
|
648
|
-
var t = i(
|
|
656
|
+
var t = i(ge);
|
|
649
657
|
return o(t, e), t;
|
|
650
658
|
})()
|
|
651
|
-
}),
|
|
659
|
+
}), k, A), o(f, t(m, {
|
|
652
660
|
get when() {
|
|
653
|
-
return
|
|
661
|
+
return p().input || _();
|
|
654
662
|
},
|
|
655
663
|
get children() {
|
|
656
|
-
var e = i(
|
|
664
|
+
var e = i(pe), t = e.firstChild;
|
|
657
665
|
return l(e, "left", "-18px"), t.$$mouseup = (e) => {
|
|
658
666
|
e.stopPropagation();
|
|
659
|
-
let t =
|
|
660
|
-
t
|
|
667
|
+
let t = h()?.from;
|
|
668
|
+
t ? u.send({
|
|
661
669
|
type: "ADD_EDGE",
|
|
662
670
|
payload: {
|
|
663
671
|
from: t,
|
|
664
672
|
to: n.id
|
|
665
673
|
}
|
|
666
|
-
})
|
|
674
|
+
}) : u.send("CLEAR_NEW_EDGE");
|
|
667
675
|
}, t.$$mousedown = (e) => {
|
|
668
676
|
e.stopPropagation();
|
|
669
|
-
},
|
|
677
|
+
}, l(t, "width", "12px"), l(t, "height", "12px"), l(t, "margin-top", "12px"), s(), e;
|
|
670
678
|
}
|
|
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
|
|
679
|
+
}), M, N), l(P, "right", "-18px"), F.$$mousedown = (e) => {
|
|
680
|
+
e.stopPropagation(), u.send("DESELECT"), u.send({
|
|
681
|
+
type: "START_NEW_EDGE",
|
|
682
|
+
payload: n.id
|
|
680
683
|
});
|
|
681
|
-
},
|
|
682
|
-
var r =
|
|
684
|
+
}, l(F, "width", "12px"), l(F, "height", "12px"), l(F, "margin-top", "12px"), r((t) => {
|
|
685
|
+
var r = {
|
|
683
686
|
"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
|
-
},
|
|
687
|
+
"border border-[#e38c29] z-[100]": g(),
|
|
688
|
+
"border border-[#e6d4be] z-[1]": !g()
|
|
689
|
+
}, i = `${p().y}px`, a = `${p().x}px`, o = n.id, s = {
|
|
687
690
|
"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": !
|
|
691
|
+
"w-full opacity-100": g(),
|
|
692
|
+
"w-0 -right-3 opacity-0 overflow-hidden": !g()
|
|
690
693
|
};
|
|
691
|
-
return
|
|
694
|
+
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
695
|
}, {
|
|
693
696
|
e: void 0,
|
|
694
697
|
t: void 0,
|
|
695
698
|
a: void 0,
|
|
696
699
|
o: void 0,
|
|
697
700
|
i: void 0
|
|
698
|
-
}), s(),
|
|
701
|
+
}), s(), f;
|
|
699
702
|
})();
|
|
700
703
|
};
|
|
701
704
|
n([
|
|
@@ -705,66 +708,86 @@ n([
|
|
|
705
708
|
]);
|
|
706
709
|
//#endregion
|
|
707
710
|
//#region src/ui/components/NodesBoard.tsx
|
|
708
|
-
var
|
|
709
|
-
let e, [n, c] = _(!1), [u,
|
|
711
|
+
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 = () => {
|
|
712
|
+
let e, [n, c] = _(!1), [u, h] = _({
|
|
710
713
|
x: 0,
|
|
711
714
|
y: 0
|
|
712
|
-
}), [
|
|
715
|
+
}), [y, x] = _(""), [S, C] = _(), T = 0, E = 0, A = Y(), j = f(A, {
|
|
716
|
+
selector: (e) => e.context.newEdge,
|
|
717
|
+
equals: Q
|
|
718
|
+
}), M = f(A, { selector: (e) => e.context.zoom ?? 1 }), N = () => {
|
|
719
|
+
let e = S();
|
|
720
|
+
if (!e) return;
|
|
721
|
+
let t = e.getBoundingClientRect(), n = () => S()?.parentElement, r = {
|
|
722
|
+
self: {
|
|
723
|
+
left: t.left,
|
|
724
|
+
top: t.top,
|
|
725
|
+
width: e.clientWidth,
|
|
726
|
+
height: e.clientHeight
|
|
727
|
+
},
|
|
728
|
+
parent: n() ? {
|
|
729
|
+
scrollLeft: n().scrollLeft,
|
|
730
|
+
scrollTop: n().scrollTop,
|
|
731
|
+
height: n().clientHeight,
|
|
732
|
+
width: n().clientWidth
|
|
733
|
+
} : void 0
|
|
734
|
+
};
|
|
735
|
+
A.send({
|
|
736
|
+
type: "SET_BOARD",
|
|
737
|
+
payload: r
|
|
738
|
+
});
|
|
739
|
+
}, P = () => {
|
|
713
740
|
let t = e.scrollWidth - e.clientWidth, n = e.scrollHeight - e.clientHeight;
|
|
714
|
-
|
|
741
|
+
T = t > 0 ? e.scrollLeft / t : 0, E = n > 0 ? e.scrollTop / n : 0, N();
|
|
715
742
|
};
|
|
716
|
-
|
|
743
|
+
g(v(M, () => {
|
|
717
744
|
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()})`;
|
|
745
|
+
t > 0 && (e.scrollLeft = T * t), n > 0 && (e.scrollTop = E * n);
|
|
746
|
+
}, { defer: !0 })), b(N);
|
|
747
|
+
let F = f(A, { selector: (e) => e.context?.selected }), I = (e) => F() === e, L = f(A, {
|
|
748
|
+
selector: ({ context: e }) => w.typed(e.data?.nodes).map((e) => e.id),
|
|
749
|
+
equals: (e, t) => e.length === t.length
|
|
750
|
+
}), R = () => `calc((500vw - 265px) * ${M()})`, z = () => `calc((500vh - 425px) * ${M()})`;
|
|
731
751
|
return (() => {
|
|
732
|
-
var
|
|
733
|
-
return
|
|
752
|
+
var f = i(be);
|
|
753
|
+
return f.addEventListener("wheel", (e) => {
|
|
734
754
|
if (e.ctrlKey || e.metaKey) {
|
|
735
|
-
e.preventDefault(),
|
|
755
|
+
e.preventDefault(), P();
|
|
736
756
|
let t = e.deltaY < 0 ? .1 : -.1;
|
|
737
|
-
|
|
757
|
+
A.send({
|
|
758
|
+
type: "ZOOM",
|
|
759
|
+
payload: t
|
|
760
|
+
});
|
|
738
761
|
}
|
|
739
|
-
}), o(
|
|
762
|
+
}), o(f, t(D, {
|
|
740
763
|
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)`),
|
|
764
|
+
if (x(n), I(n)) {
|
|
765
|
+
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;
|
|
766
|
+
t.style.setProperty("transform", `translate3d(${d}px, ${f}px, 0)`), A.send({
|
|
744
767
|
type: "MOVE_IMMEDIATE",
|
|
745
768
|
payload: {
|
|
746
769
|
id: `${n}`,
|
|
747
770
|
x: l,
|
|
748
771
|
y: u
|
|
749
772
|
}
|
|
750
|
-
}),
|
|
773
|
+
}), h({
|
|
751
774
|
x: d * i,
|
|
752
775
|
y: f * i
|
|
753
776
|
});
|
|
754
777
|
}
|
|
755
778
|
},
|
|
756
779
|
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
|
-
|
|
780
|
+
if (!I(t)) return;
|
|
781
|
+
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);
|
|
782
|
+
e.style.setProperty("top", l + "px"), e.style.setProperty("left", c + "px"), e.style.removeProperty("transform"), A.send({
|
|
783
|
+
type: "MOVE",
|
|
784
|
+
payload: {
|
|
785
|
+
id: `${t}`,
|
|
786
|
+
x: c,
|
|
787
|
+
y: l
|
|
788
|
+
}
|
|
789
|
+
}), setTimeout(() => {
|
|
790
|
+
h({
|
|
768
791
|
x: 0,
|
|
769
792
|
y: 0
|
|
770
793
|
});
|
|
@@ -773,26 +796,26 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
773
796
|
get children() {
|
|
774
797
|
return [
|
|
775
798
|
(() => {
|
|
776
|
-
var u = i(
|
|
777
|
-
return u.addEventListener("scroll",
|
|
778
|
-
if (
|
|
779
|
-
|
|
799
|
+
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);
|
|
800
|
+
return u.addEventListener("scroll", P), d((t) => e = t, u), o(u, t(O, {}), m, h), g.$$mousedown = (t) => {
|
|
801
|
+
if (j() || t.button !== 0) return;
|
|
802
|
+
A.send("DESELECT");
|
|
780
803
|
let n = t.clientX, r = t.clientY, i = e.scrollLeft, a = e.scrollTop;
|
|
781
804
|
c(!0);
|
|
782
805
|
let o = (t) => {
|
|
783
806
|
let o = t.clientX - n, s = t.clientY - r;
|
|
784
|
-
e.scrollLeft = i - o * 3, e.scrollTop = a - s * 3,
|
|
807
|
+
e.scrollLeft = i - o * 3, e.scrollTop = a - s * 3, P();
|
|
785
808
|
}, s = () => {
|
|
786
809
|
window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", s), setTimeout(() => c(!1), 200);
|
|
787
810
|
};
|
|
788
811
|
window.addEventListener("mousemove", o), window.addEventListener("mouseup", s);
|
|
789
|
-
}, d(
|
|
812
|
+
}, g.addEventListener("scroll", () => {}), d(C, g), o(_, t(ae, {}), y, b), o(_, t(de, {}), S, w), o(_, t(p, {
|
|
790
813
|
get each() {
|
|
791
|
-
return
|
|
814
|
+
return L();
|
|
792
815
|
},
|
|
793
|
-
children:
|
|
794
|
-
}),
|
|
795
|
-
var t = !!n(), r =
|
|
816
|
+
children: (e) => t(_e, { id: e })
|
|
817
|
+
}), E, D), r((e) => {
|
|
818
|
+
var t = !!n(), r = z(), i = R(), a = M();
|
|
796
819
|
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
820
|
}, {
|
|
798
821
|
e: void 0,
|
|
@@ -802,20 +825,26 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
802
825
|
}), s(), u;
|
|
803
826
|
})(),
|
|
804
827
|
(() => {
|
|
805
|
-
var e = i(
|
|
828
|
+
var e = i(ye), t = e.firstChild, n = t.nextSibling, r = n.firstChild, [c, l] = a(r.nextSibling);
|
|
806
829
|
c.nextSibling;
|
|
807
830
|
var u = n.nextSibling, d = u.nextSibling.nextSibling;
|
|
808
831
|
return t.$$click = () => {
|
|
809
|
-
|
|
832
|
+
P(), A.send({
|
|
833
|
+
type: "ZOOM",
|
|
834
|
+
payload: -.1
|
|
835
|
+
});
|
|
810
836
|
}, n.$$click = () => {
|
|
811
|
-
|
|
812
|
-
}, o(n, () => Math.round(
|
|
813
|
-
|
|
814
|
-
|
|
837
|
+
P(), A.send("TOGGLE_ZOOM");
|
|
838
|
+
}, o(n, () => Math.round(M() * 100), c, l), u.$$click = () => {
|
|
839
|
+
P(), A.send({
|
|
840
|
+
type: "ZOOM",
|
|
841
|
+
payload: .1
|
|
842
|
+
});
|
|
843
|
+
}, d.$$click = () => A.send("ADD_PARENT"), s(), e;
|
|
815
844
|
})(),
|
|
816
|
-
t(
|
|
845
|
+
t(m, {
|
|
817
846
|
get when() {
|
|
818
|
-
return !
|
|
847
|
+
return !y() || !I(y());
|
|
819
848
|
},
|
|
820
849
|
get children() {
|
|
821
850
|
return t(k, { children: "" });
|
|
@@ -823,42 +852,40 @@ var ge = /*#__PURE__*/ u("<div class=\"relative h-full w-full overflow-scroll ro
|
|
|
823
852
|
})
|
|
824
853
|
];
|
|
825
854
|
}
|
|
826
|
-
})),
|
|
855
|
+
})), f;
|
|
827
856
|
})();
|
|
828
857
|
};
|
|
829
858
|
n(["mousedown", "click"]);
|
|
830
859
|
//#endregion
|
|
831
860
|
//#region src/ui/components/FlowChart.tsx
|
|
832
|
-
var
|
|
833
|
-
let n = e.config?.nodes ??
|
|
861
|
+
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) => {
|
|
862
|
+
let n = e.config?.nodes ?? L, a = e.config?.edges, c = Y(), u = f(c, { selector: (e) => !!e.context.newEdge });
|
|
834
863
|
return b(() => {
|
|
835
|
-
c.
|
|
864
|
+
c.resume(), c.send({
|
|
836
865
|
type: "CONFIGURE",
|
|
837
866
|
payload: {
|
|
838
867
|
nodes: n,
|
|
839
868
|
edges: a ?? []
|
|
840
869
|
}
|
|
841
870
|
});
|
|
842
|
-
}), y(c.
|
|
843
|
-
var e = i(
|
|
871
|
+
}), y(c.pause), (() => {
|
|
872
|
+
var e = i(Se), n = e.firstChild;
|
|
844
873
|
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;
|
|
874
|
+
c.send({
|
|
875
|
+
type: "MOVE_NEW_EDGE",
|
|
876
|
+
payload: {
|
|
877
|
+
x: e.clientX,
|
|
878
|
+
y: e.clientY
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
}, e.$$mouseup = () => c.send("CLEAR_NEW_EDGE"), o(n, t(xe, {})), r((e) => l(n, "cursor", u() ? "inherit" : "crosshair")), s(), e;
|
|
855
882
|
})();
|
|
856
883
|
};
|
|
857
884
|
n(["mouseup", "mousemove"]);
|
|
858
885
|
//#endregion
|
|
859
886
|
//#region src/ui/Flow.tsx
|
|
860
|
-
var
|
|
861
|
-
return t(
|
|
887
|
+
var we = (e) => t(ie, { get children() {
|
|
888
|
+
return t(Ce, e);
|
|
862
889
|
} });
|
|
863
890
|
//#endregion
|
|
864
|
-
export { M as CLASSES,
|
|
891
|
+
export { M as CLASSES, we as Flow };
|