@bemedev/mind-flow 0.0.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/lib/helpers/createContext.d.ts +21 -0
- package/lib/helpers/createContext.d.ts.map +1 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.es.js +859 -0
- package/lib/output.css +2 -0
- package/lib/server.cjs.js +1058 -0
- package/lib/server.es.js +1056 -0
- package/lib/services/main.machine.d.ts +1198 -0
- package/lib/services/main.machine.d.ts.map +1 -0
- package/lib/services/main.typings.d.ts +68 -0
- package/lib/services/main.typings.d.ts.map +1 -0
- package/lib/ui/Flow.d.ts +13 -0
- package/lib/ui/Flow.d.ts.map +1 -0
- package/lib/ui/components/Bounds.d.ts +10 -0
- package/lib/ui/components/Bounds.d.ts.map +1 -0
- package/lib/ui/components/EdgeComponent.d.ts +20 -0
- package/lib/ui/components/EdgeComponent.d.ts.map +1 -0
- package/lib/ui/components/EdgesBoard.d.ts +9 -0
- package/lib/ui/components/EdgesBoard.d.ts.map +1 -0
- package/lib/ui/components/FlowChart.context.d.ts +1228 -0
- package/lib/ui/components/FlowChart.context.d.ts.map +1 -0
- package/lib/ui/components/FlowChart.d.ts +63 -0
- package/lib/ui/components/FlowChart.d.ts.map +1 -0
- package/lib/ui/components/FlowChart.data.d.ts +67 -0
- package/lib/ui/components/FlowChart.data.d.ts.map +1 -0
- package/lib/ui/components/NodeComponent.d.ts +34 -0
- package/lib/ui/components/NodeComponent.d.ts.map +1 -0
- package/lib/ui/components/NodesBoard.d.ts +9 -0
- package/lib/ui/components/NodesBoard.d.ts.map +1 -0
- package/lib/ui/components/classes.d.ts +6 -0
- package/lib/ui/components/classes.d.ts.map +1 -0
- package/package.json +146 -0
- package/src/README.md +36 -0
- package/src/helpers/createContext.ts +37 -0
- package/src/index.ts +3 -0
- package/src/input.css +15 -0
- package/src/services/main.machine.ts +247 -0
- package/src/services/main.typings.ts +50 -0
- package/src/ui/Flow.tsx +18 -0
- package/src/ui/components/Bounds.tsx +87 -0
- package/src/ui/components/EdgeComponent.tsx +106 -0
- package/src/ui/components/EdgesBoard.tsx +56 -0
- package/src/ui/components/FlowChart.context.ts +373 -0
- package/src/ui/components/FlowChart.data.ts +89 -0
- package/src/ui/components/FlowChart.tsx +112 -0
- package/src/ui/components/NodeComponent.tsx +288 -0
- package/src/ui/components/NodesBoard.tsx +298 -0
- package/src/ui/components/classes.ts +85 -0
package/lib/index.es.js
ADDED
|
@@ -0,0 +1,859 @@
|
|
|
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 { For as f, Show as p, createContext as m, createEffect as h, createMemo as g, createSignal as _, on as v, onCleanup as y, onMount as b, useContext as x } from "solid-js";
|
|
3
|
+
import { createMachine as S, interpret as C } from "@bemedev/app";
|
|
4
|
+
import { produce as w } from "solid-js/store";
|
|
5
|
+
import { type as T } from "@bemedev/app/bemedev";
|
|
6
|
+
import { useState as E } from "@bemedev/app-solidjs";
|
|
7
|
+
import { DragDropProvider as D, DragDropSensors as O, DragOverlay as k, createDraggable as A, useDragDropContext as j } from "@thisbeyond/solid-dnd";
|
|
8
|
+
//#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-scroll 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 = Object.prototype.hasOwnProperty;
|
|
10
|
+
function P(e, t) {
|
|
11
|
+
var n, r;
|
|
12
|
+
if (e === t) return !0;
|
|
13
|
+
if (e && t && (n = e.constructor) === t.constructor) {
|
|
14
|
+
if (n === Date) return e.getTime() === t.getTime();
|
|
15
|
+
if (n === RegExp) return e.toString() === t.toString();
|
|
16
|
+
if (n === Array) {
|
|
17
|
+
if ((r = e.length) === t.length) for (; r-- && P(e[r], t[r]););
|
|
18
|
+
return r === -1;
|
|
19
|
+
}
|
|
20
|
+
if (!n || typeof e == "object") {
|
|
21
|
+
for (n in r = 0, e) if (N.call(e, n) && ++r && !N.call(t, n) || !(n in t) || !P(e[n], t[n])) return !1;
|
|
22
|
+
return Object.keys(t).length === r;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return e !== e && t !== t;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/helpers/createContext.ts
|
|
29
|
+
var F = (e, t) => {
|
|
30
|
+
let n = m(e(), t);
|
|
31
|
+
return [
|
|
32
|
+
({ children: e }) => n.Provider({
|
|
33
|
+
value: n.defaultValue,
|
|
34
|
+
children: e
|
|
35
|
+
}),
|
|
36
|
+
() => x(n),
|
|
37
|
+
n
|
|
38
|
+
];
|
|
39
|
+
}, I = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = (e = 21) => {
|
|
40
|
+
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
41
|
+
for (; e--;) t += I[n[e] & 63];
|
|
42
|
+
return t;
|
|
43
|
+
}, R = T({
|
|
44
|
+
x: "number",
|
|
45
|
+
y: "number"
|
|
46
|
+
});
|
|
47
|
+
T(({ optional: e, use: t }) => ({
|
|
48
|
+
input: e(t(R)),
|
|
49
|
+
output: t(R)
|
|
50
|
+
}));
|
|
51
|
+
var z = T({
|
|
52
|
+
from: "string",
|
|
53
|
+
to: "string"
|
|
54
|
+
}), B = T(({ optional: e, use: t }) => ({
|
|
55
|
+
position: t(R),
|
|
56
|
+
data: {
|
|
57
|
+
label: e("string"),
|
|
58
|
+
content: "string"
|
|
59
|
+
},
|
|
60
|
+
input: "boolean"
|
|
61
|
+
})), V = z;
|
|
62
|
+
T(({ optional: e, use: t }) => ({
|
|
63
|
+
width: "number",
|
|
64
|
+
height: "number",
|
|
65
|
+
id: "string",
|
|
66
|
+
output: t(R),
|
|
67
|
+
input: e(t(R))
|
|
68
|
+
})), T({
|
|
69
|
+
x0: "number",
|
|
70
|
+
y0: "number",
|
|
71
|
+
x1: "number",
|
|
72
|
+
y1: "number"
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/services/main.machine.ts
|
|
76
|
+
var H = (e, t) => `edge = ${e} => ${t}`, U = (e) => `node-${e}`, W = S({
|
|
77
|
+
initial: "idle",
|
|
78
|
+
states: {
|
|
79
|
+
idle: { on: {
|
|
80
|
+
CONFIGURE: {
|
|
81
|
+
actions: ["configure"],
|
|
82
|
+
target: "/working"
|
|
83
|
+
},
|
|
84
|
+
CONFIGURE_EMPTY: "/working"
|
|
85
|
+
} },
|
|
86
|
+
construction: { always: {
|
|
87
|
+
actions: ["buildUI"],
|
|
88
|
+
target: "/working"
|
|
89
|
+
} },
|
|
90
|
+
working: { on: {
|
|
91
|
+
MOVE: {
|
|
92
|
+
actions: ["moveNode", "buildUI"],
|
|
93
|
+
target: "/construction"
|
|
94
|
+
},
|
|
95
|
+
MOVE_IMMEDIATE: { actions: [{
|
|
96
|
+
name: "buildImmediateUI",
|
|
97
|
+
description: "Must be in the ui"
|
|
98
|
+
}] },
|
|
99
|
+
UPDATE_UI: "/construction",
|
|
100
|
+
ADD_CHILD: {
|
|
101
|
+
actions: [
|
|
102
|
+
"generateID",
|
|
103
|
+
{
|
|
104
|
+
name: "placeChild",
|
|
105
|
+
description: "Must be in the ui"
|
|
106
|
+
},
|
|
107
|
+
"linkChild"
|
|
108
|
+
],
|
|
109
|
+
target: "/construction"
|
|
110
|
+
},
|
|
111
|
+
ADD_PARENT: {
|
|
112
|
+
actions: [
|
|
113
|
+
"generateID",
|
|
114
|
+
{
|
|
115
|
+
name: "placeParent",
|
|
116
|
+
description: "Must be in the ui"
|
|
117
|
+
},
|
|
118
|
+
"selectParent"
|
|
119
|
+
],
|
|
120
|
+
target: "/construction"
|
|
121
|
+
},
|
|
122
|
+
ADD_SIBLING: {
|
|
123
|
+
actions: [
|
|
124
|
+
"generateID",
|
|
125
|
+
{
|
|
126
|
+
name: "placeSibling",
|
|
127
|
+
description: "Must be in the ui"
|
|
128
|
+
},
|
|
129
|
+
"linkSibling"
|
|
130
|
+
],
|
|
131
|
+
target: "/construction"
|
|
132
|
+
},
|
|
133
|
+
ADD_EDGE: {
|
|
134
|
+
actions: ["addEdge"],
|
|
135
|
+
target: "/construction"
|
|
136
|
+
},
|
|
137
|
+
DELETE: {
|
|
138
|
+
actions: ["delete"],
|
|
139
|
+
target: "/construction"
|
|
140
|
+
},
|
|
141
|
+
SELECT: { actions: ["select"] },
|
|
142
|
+
DESELECT: { actions: ["deselect"] }
|
|
143
|
+
} }
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
eventsMap: T(({ intersection: e, use: t, array: n }) => ({
|
|
147
|
+
CONFIGURE: {
|
|
148
|
+
nodes: n(e(t(B), { id: "string" })),
|
|
149
|
+
edges: n(e(t(V), { id: "string" }))
|
|
150
|
+
},
|
|
151
|
+
CONFIGURE_EMPTY: "never",
|
|
152
|
+
MOVE: {
|
|
153
|
+
id: "string",
|
|
154
|
+
x: "number",
|
|
155
|
+
y: "number"
|
|
156
|
+
},
|
|
157
|
+
MOVE_IMMEDIATE: {
|
|
158
|
+
id: "string",
|
|
159
|
+
x: "number",
|
|
160
|
+
y: "number"
|
|
161
|
+
},
|
|
162
|
+
ADD_CHILD: "string",
|
|
163
|
+
ADD_PARENT: "never",
|
|
164
|
+
ADD_SIBLING: "string",
|
|
165
|
+
DELETE: "string",
|
|
166
|
+
SELECT: "string",
|
|
167
|
+
DESELECT: "never",
|
|
168
|
+
ADD_EDGE: t(z)
|
|
169
|
+
})),
|
|
170
|
+
pContext: T(({ union: e }) => ({ generatedId: e("string", "null") })),
|
|
171
|
+
context: T(({ optional: e, use: t, array: n }) => ({
|
|
172
|
+
data: e({
|
|
173
|
+
nodes: n({
|
|
174
|
+
...t(B),
|
|
175
|
+
id: "string"
|
|
176
|
+
}),
|
|
177
|
+
edges: n({
|
|
178
|
+
...t(V),
|
|
179
|
+
id: "string"
|
|
180
|
+
})
|
|
181
|
+
}),
|
|
182
|
+
selected: e("string"),
|
|
183
|
+
updatingUI: e("boolean")
|
|
184
|
+
})),
|
|
185
|
+
sync: !0
|
|
186
|
+
}).provideOptions(({ assign: e, batch: t, erase: n }) => ({ actions: {
|
|
187
|
+
configure: t(e("context.data", () => ({
|
|
188
|
+
nodes: [],
|
|
189
|
+
edges: []
|
|
190
|
+
})), e("context.data.nodes", { CONFIGURE: ({ payload: { nodes: e } }) => e }), e("context.data.edges", { CONFIGURE: ({ payload: { edges: e } }) => e }), e("context.updatingUI", () => !1), e("pContext.generatedId", () => null)),
|
|
191
|
+
generateID: e("pContext.generatedId", () => L()),
|
|
192
|
+
linkChild: t(e("context.data.edges", { ADD_CHILD: ({ context: e, pContext: t, payload: n }) => {
|
|
193
|
+
let r = e.data, i = n, a = t?.generatedId, o = U(a), s = H(i, o);
|
|
194
|
+
return [...r?.edges ?? [], {
|
|
195
|
+
id: s,
|
|
196
|
+
from: i,
|
|
197
|
+
to: o
|
|
198
|
+
}];
|
|
199
|
+
} }), e("context.selected", ({ pContext: { generatedId: e } }) => U(e))),
|
|
200
|
+
linkSibling: t(e("context.data.edges", { ADD_SIBLING: ({ pContext: e, payload: t, context: n }) => {
|
|
201
|
+
let r = n.data?.edges, i = e?.generatedId, a = [...r ?? []], o = r?.find(({ to: e }) => e === t)?.from;
|
|
202
|
+
if (!o) return a;
|
|
203
|
+
let s = U(i), c = H(o, s);
|
|
204
|
+
return a.push({
|
|
205
|
+
from: o,
|
|
206
|
+
to: s,
|
|
207
|
+
id: c
|
|
208
|
+
}), a;
|
|
209
|
+
} }), e("context.selected", ({ pContext: { generatedId: e } }) => U(e))),
|
|
210
|
+
selectParent: e("context.selected", ({ pContext: { generatedId: e } }) => U(e)),
|
|
211
|
+
moveNode: e("context.data.nodes", { MOVE: ({ context: { data: e }, payload: t }) => {
|
|
212
|
+
let { id: n, x: r, y: i } = t;
|
|
213
|
+
return n ? e?.nodes?.map((e) => e.id === n ? {
|
|
214
|
+
...e,
|
|
215
|
+
position: {
|
|
216
|
+
x: r,
|
|
217
|
+
y: i
|
|
218
|
+
}
|
|
219
|
+
} : e) ?? [] : e?.nodes ?? [];
|
|
220
|
+
} }),
|
|
221
|
+
select: e("context.selected", { SELECT: ({ payload: e }) => e }),
|
|
222
|
+
delete: e(["context.data.nodes", "context.data.edges"], { DELETE: ({ context: { data: e }, payload: t }) => [e?.nodes?.filter(({ id: e }) => e !== t), e?.edges?.filter(({ id: e, from: n, to: r }) => e !== t && n !== t && r !== t)] }),
|
|
223
|
+
addEdge: e("context.data.edges", { ADD_EDGE: ({ context: e, payload: { from: t, to: n } }) => {
|
|
224
|
+
let r = e.data?.edges ?? [], i = H(t, n);
|
|
225
|
+
return r.some((e) => e.id === i) ? r : [...r, {
|
|
226
|
+
id: i,
|
|
227
|
+
from: t,
|
|
228
|
+
to: n
|
|
229
|
+
}];
|
|
230
|
+
} }),
|
|
231
|
+
deselect: n("context.selected")
|
|
232
|
+
} })), G = 10.5, K = -10.5, q = {
|
|
233
|
+
x: K,
|
|
234
|
+
y: 18
|
|
235
|
+
}, J = (e = 0) => ({
|
|
236
|
+
x: e + G,
|
|
237
|
+
y: 18
|
|
238
|
+
}), Y = {
|
|
239
|
+
horizontal: 20,
|
|
240
|
+
vertical: 35
|
|
241
|
+
}, ee = [{
|
|
242
|
+
id: "node-0",
|
|
243
|
+
data: {
|
|
244
|
+
content: "Some text",
|
|
245
|
+
label: "Root node"
|
|
246
|
+
},
|
|
247
|
+
input: !1,
|
|
248
|
+
position: {
|
|
249
|
+
x: 350,
|
|
250
|
+
y: 100
|
|
251
|
+
}
|
|
252
|
+
}], X = C(W, {
|
|
253
|
+
context: {},
|
|
254
|
+
pContext: { generatedId: null }
|
|
255
|
+
}), [te, Z] = F(() => {
|
|
256
|
+
let e = _(1), t = _(), [n, r] = _(), [i, a] = _({}, { equals: P }), o = (t, r) => {
|
|
257
|
+
let i = n();
|
|
258
|
+
if (!i) return {
|
|
259
|
+
x: t,
|
|
260
|
+
y: r
|
|
261
|
+
};
|
|
262
|
+
let a = i.getBoundingClientRect(), o = e[0]();
|
|
263
|
+
return {
|
|
264
|
+
x: (t - a.left) / o,
|
|
265
|
+
y: (r - a.top) / o
|
|
266
|
+
};
|
|
267
|
+
}, [s, c] = _({}, { equals: !1 }), l = (t, r, i = 192, a = 50) => {
|
|
268
|
+
let o = n()?.parentElement;
|
|
269
|
+
if (!o) return {
|
|
270
|
+
x: t,
|
|
271
|
+
y: r
|
|
272
|
+
};
|
|
273
|
+
let s = e[0](), c = o.scrollLeft / s + Y.horizontal, l = Math.max(c, (o.scrollLeft + o.clientWidth) / s - Y.horizontal - i), u = o.scrollTop / s + Y.vertical, d = Math.max(u, (o.scrollTop + o.clientHeight) / s - Y.vertical - a);
|
|
274
|
+
return {
|
|
275
|
+
x: Math.min(Math.max(t, c), l),
|
|
276
|
+
y: Math.min(Math.max(r, u), d)
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
return X.addOptions(({ voidAction: t, batch: r, assign: o }) => ({ actions: {
|
|
280
|
+
placeChild: o("context.data.nodes", { ADD_CHILD: ({ payload: e, context: { data: t }, pContext: { generatedId: n } }) => {
|
|
281
|
+
let r = t?.nodes ?? [];
|
|
282
|
+
if (!e) return r;
|
|
283
|
+
let a = r.find((t) => t.id === e);
|
|
284
|
+
if (!a) return r;
|
|
285
|
+
let o = `node-${n}`, s = i()[e]?.width ?? 0, c = i()[e]?.height ?? 0, u = a.position.x + s + 100, d = a.position.y, f = l(u, d, s, c);
|
|
286
|
+
return [...r, {
|
|
287
|
+
id: o,
|
|
288
|
+
data: { content: "<Nouveau nœud>" },
|
|
289
|
+
input: !0,
|
|
290
|
+
position: f
|
|
291
|
+
}];
|
|
292
|
+
} }),
|
|
293
|
+
placeParent: o("context.data.nodes", { ADD_PARENT: ({ context: { data: t }, pContext: { generatedId: r } }) => {
|
|
294
|
+
let i = t?.nodes ?? [], a = `node-${r}`, o = n()?.parentElement, s = o?.scrollLeft ?? 0, c = o?.scrollTop ?? 0, l = o?.clientWidth ?? 0, u = o?.clientHeight ?? 0, d = e[0](), f = (s + l / 2) / d, p = (c + u / 2) / d;
|
|
295
|
+
return [...i, {
|
|
296
|
+
id: a,
|
|
297
|
+
data: { content: "<Nouveau nœud>" },
|
|
298
|
+
input: !1,
|
|
299
|
+
position: {
|
|
300
|
+
x: f,
|
|
301
|
+
y: p
|
|
302
|
+
}
|
|
303
|
+
}];
|
|
304
|
+
} }),
|
|
305
|
+
placeSibling: o("context.data.nodes", { ADD_SIBLING: ({ payload: e, context: { data: t }, pContext: { generatedId: n } }) => {
|
|
306
|
+
let r = t?.edges ?? [], a = t?.nodes ?? [], o = r.find((t) => t.to === e)?.from;
|
|
307
|
+
if (!o) return a;
|
|
308
|
+
let s = a.find((e) => e.id === o);
|
|
309
|
+
if (!s) return a;
|
|
310
|
+
let c = `node-${n}`, u = i()[o]?.width ?? 0, d = i()[o]?.height ?? 0, f = s.position.x + u + 100, p = s.position.y + 100, m = l(f, p, u, d);
|
|
311
|
+
return [...a, {
|
|
312
|
+
id: c,
|
|
313
|
+
data: { content: "<Nouveau nœud>" },
|
|
314
|
+
input: !0,
|
|
315
|
+
position: m
|
|
316
|
+
}];
|
|
317
|
+
} }),
|
|
318
|
+
buildUI: r(t(({ context: { data: e } }) => {
|
|
319
|
+
let t = e?.edges ?? [];
|
|
320
|
+
c((e) => {
|
|
321
|
+
let n = Object.entries({ ...e }).filter(([e]) => t?.some((t) => t.id === e));
|
|
322
|
+
return Object.fromEntries(n);
|
|
323
|
+
});
|
|
324
|
+
}), t({
|
|
325
|
+
else: ({ context: { data: e } }) => {
|
|
326
|
+
let t = e?.edges ?? [];
|
|
327
|
+
c(w((e) => {
|
|
328
|
+
t?.forEach(({ from: t, id: n, to: r }) => {
|
|
329
|
+
let a = i()[t]?.output, o = i()[r]?.input;
|
|
330
|
+
a && o && (e[n] = {
|
|
331
|
+
x0: a.x,
|
|
332
|
+
y0: a.y,
|
|
333
|
+
x1: o.x,
|
|
334
|
+
y1: o.y
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}));
|
|
338
|
+
},
|
|
339
|
+
MOVE: ({ context: { data: e }, payload: t }) => {
|
|
340
|
+
let n = e?.edges ?? [];
|
|
341
|
+
c(w((e) => {
|
|
342
|
+
n?.forEach(({ from: n, to: r, id: o }) => {
|
|
343
|
+
if (n === t.id) {
|
|
344
|
+
let n = i()[t.id]?.outputOffset ?? J(i()[t.id]?.width), r = t.x + n.x, s = t.y + n.y;
|
|
345
|
+
e[o] = {
|
|
346
|
+
...e[o],
|
|
347
|
+
x0: r,
|
|
348
|
+
y0: s
|
|
349
|
+
}, a(w((e) => {
|
|
350
|
+
e[t.id] && (e[t.id] = {
|
|
351
|
+
...e[t.id],
|
|
352
|
+
output: {
|
|
353
|
+
x: r,
|
|
354
|
+
y: s
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
if (r === t.id) {
|
|
360
|
+
let n = i()[t.id]?.inputOffset ?? q, r = t.x + n.x, s = t.y + n.y;
|
|
361
|
+
e[o] = {
|
|
362
|
+
...e[o],
|
|
363
|
+
x1: r,
|
|
364
|
+
y1: s
|
|
365
|
+
}, a(w((e) => {
|
|
366
|
+
e[t.id] && (e[t.id] = {
|
|
367
|
+
...e[t.id],
|
|
368
|
+
input: {
|
|
369
|
+
x: r,
|
|
370
|
+
y: s
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}));
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
}), o("context.updatingUI", () => !0)),
|
|
379
|
+
buildImmediateUI: t({ MOVE_IMMEDIATE: ({ context: { data: e }, payload: t }) => {
|
|
380
|
+
let n = e?.edges ?? [];
|
|
381
|
+
c(w((e) => {
|
|
382
|
+
n?.forEach(({ from: n, to: r, id: o }) => {
|
|
383
|
+
if (n === t.id) {
|
|
384
|
+
let n = i()[t.id]?.outputOffset ?? J(i()[t.id]?.width), r = t.x + n.x, s = t.y + n.y;
|
|
385
|
+
e[o] = {
|
|
386
|
+
...e[o],
|
|
387
|
+
x0: r,
|
|
388
|
+
y0: s
|
|
389
|
+
}, a(w((e) => {
|
|
390
|
+
e[t.id] && (e[t.id] = {
|
|
391
|
+
...e[t.id],
|
|
392
|
+
output: {
|
|
393
|
+
x: r,
|
|
394
|
+
y: s
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
399
|
+
if (r === t.id) {
|
|
400
|
+
let n = i()[t.id]?.inputOffset ?? q, r = t.x + n.x, s = t.y + n.y;
|
|
401
|
+
e[o] = {
|
|
402
|
+
...e[o],
|
|
403
|
+
x1: r,
|
|
404
|
+
y1: s
|
|
405
|
+
}, a(w((e) => {
|
|
406
|
+
e[t.id] && (e[t.id] = {
|
|
407
|
+
...e[t.id],
|
|
408
|
+
input: {
|
|
409
|
+
x: r,
|
|
410
|
+
y: s
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}));
|
|
417
|
+
} })
|
|
418
|
+
} })), X.start(), {
|
|
419
|
+
dimensions: [i, a],
|
|
420
|
+
newEdge: t,
|
|
421
|
+
board: [n, r],
|
|
422
|
+
getBoardPoint: o,
|
|
423
|
+
edgesPositions: [s, c],
|
|
424
|
+
service: X,
|
|
425
|
+
zoom: e
|
|
426
|
+
};
|
|
427
|
+
}, { name: "FlowContext" }), Q = Object.prototype.hasOwnProperty;
|
|
428
|
+
function ne(e, t, n) {
|
|
429
|
+
for (n of e.keys()) if ($(n, t)) return n;
|
|
430
|
+
}
|
|
431
|
+
function $(e, t) {
|
|
432
|
+
var n, r, i;
|
|
433
|
+
if (e === t) return !0;
|
|
434
|
+
if (e && t && (n = e.constructor) === t.constructor) {
|
|
435
|
+
if (n === Date) return e.getTime() === t.getTime();
|
|
436
|
+
if (n === RegExp) return e.toString() === t.toString();
|
|
437
|
+
if (n === Array) {
|
|
438
|
+
if ((r = e.length) === t.length) for (; r-- && $(e[r], t[r]););
|
|
439
|
+
return r === -1;
|
|
440
|
+
}
|
|
441
|
+
if (n === Set) {
|
|
442
|
+
if (e.size !== t.size) return !1;
|
|
443
|
+
for (r of e) if (i = r, i && typeof i == "object" && (i = ne(t, i), !i) || !t.has(i)) return !1;
|
|
444
|
+
return !0;
|
|
445
|
+
}
|
|
446
|
+
if (n === Map) {
|
|
447
|
+
if (e.size !== t.size) return !1;
|
|
448
|
+
for (r of e) if (i = r[0], i && typeof i == "object" && (i = ne(t, i), !i) || !$(r[1], t.get(i))) return !1;
|
|
449
|
+
return !0;
|
|
450
|
+
}
|
|
451
|
+
if (n === ArrayBuffer) e = new Uint8Array(e), t = new Uint8Array(t);
|
|
452
|
+
else if (n === DataView) {
|
|
453
|
+
if ((r = e.byteLength) === t.byteLength) for (; r-- && e.getInt8(r) === t.getInt8(r););
|
|
454
|
+
return r === -1;
|
|
455
|
+
}
|
|
456
|
+
if (ArrayBuffer.isView(e)) {
|
|
457
|
+
if ((r = e.byteLength) === t.byteLength) for (; r-- && e[r] === t[r];);
|
|
458
|
+
return r === -1;
|
|
459
|
+
}
|
|
460
|
+
if (!n || typeof e == "object") {
|
|
461
|
+
for (n in r = 0, e) if (Q.call(e, n) && ++r && !Q.call(t, n) || !(n in t) || !$(e[n], t[n])) return !1;
|
|
462
|
+
return Object.keys(t).length === r;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return e !== e && t !== t;
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/ui/components/Bounds.tsx
|
|
469
|
+
var re = () => {
|
|
470
|
+
let { board: [e], zoom: [t] } = Z(), [n, { addTransformer: r, removeTransformer: i, onDragStart: a, onDragEnd: o }] = j(), s = {
|
|
471
|
+
id: "clamp-to-container",
|
|
472
|
+
order: 100,
|
|
473
|
+
callback: (r) => {
|
|
474
|
+
let i = e()?.parentElement, a = n.active.draggable;
|
|
475
|
+
if (!i || !a) return r;
|
|
476
|
+
let o = a.layout, s = i.getBoundingClientRect(), c = s.left + i.clientLeft, l = s.top + i.clientTop, u = c + i.clientWidth, d = l + i.clientHeight, f = t(), p = c - o.left + Y.horizontal * f, m = Math.max(p, u - o.right - Y.horizontal * f), h = l - o.top + Y.vertical * f, g = Math.max(h, d - o.bottom - Y.vertical * f);
|
|
477
|
+
return {
|
|
478
|
+
x: Math.min(Math.max(r.x, p), m),
|
|
479
|
+
y: Math.min(Math.max(r.y, h), g)
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
return a(({ draggable: e }) => {
|
|
484
|
+
r("draggables", e.id, s);
|
|
485
|
+
}), o(({ draggable: e }) => {
|
|
486
|
+
i("draggables", e.id, s.id);
|
|
487
|
+
}), null;
|
|
488
|
+
}, ie = /*#__PURE__*/ u("<svg><path class=\"relative cursor-pointer fill-transparent\"></svg>", !1, !0, !1), ae = /*#__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), oe = (e) => e * 100 / 200, se = ({ x0: e, y0: t, x1: n, y1: r }) => `M ${e} ${t} C ${e + oe(Math.abs(n - e))} ${t}, ${n - oe(Math.abs(n - e))} ${r}, ${n} ${r}`, ce = (n) => {
|
|
489
|
+
let [a, o] = _({
|
|
490
|
+
x: n.x0 + (n.x1 - n.x0) / 2,
|
|
491
|
+
y: n.y0 + (n.y1 - n.y0) / 2
|
|
492
|
+
}), { service: u } = Z();
|
|
493
|
+
h(() => {
|
|
494
|
+
let e = n.x0 + (n.x1 - n.x0) / 2, t = n.y0 + (n.y1 - n.y0) / 2;
|
|
495
|
+
o({
|
|
496
|
+
x: e,
|
|
497
|
+
y: t
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
let d = E(u, { selector: (e) => e.context.selected === n.id });
|
|
501
|
+
return [(() => {
|
|
502
|
+
var t = i(ie);
|
|
503
|
+
return t.$$click = () => u.send({
|
|
504
|
+
type: "SELECT",
|
|
505
|
+
payload: n.id
|
|
506
|
+
}), t.$$mousedown = (e) => e.stopPropagation(), r((r) => {
|
|
507
|
+
var i = {
|
|
508
|
+
"stroke-[rgba(168,168,168,0.4)] stroke-3 z-200": !!n.isNew,
|
|
509
|
+
"stroke-[rgba(168,168,168,1)] stroke-4 z-100": d() && !n.isNew,
|
|
510
|
+
"stroke-[rgba(168,168,168,0.8)] stroke-3": !d() && !n.isNew
|
|
511
|
+
}, a = n.isNew ? "none" : "all", o = se(n);
|
|
512
|
+
return r.e = e(t, i, r.e), a !== r.t && l(t, "pointer-events", r.t = a), o !== r.a && c(t, "d", r.a = o), r;
|
|
513
|
+
}, {
|
|
514
|
+
e: void 0,
|
|
515
|
+
t: void 0,
|
|
516
|
+
a: void 0
|
|
517
|
+
}), s(), t;
|
|
518
|
+
})(), t(p, {
|
|
519
|
+
get when() {
|
|
520
|
+
return d();
|
|
521
|
+
},
|
|
522
|
+
get children() {
|
|
523
|
+
var e = i(ae);
|
|
524
|
+
return e.$$mousedown = (e) => {
|
|
525
|
+
e.stopPropagation(), u.send({
|
|
526
|
+
type: "DELETE",
|
|
527
|
+
payload: n.id
|
|
528
|
+
});
|
|
529
|
+
}, r(() => c(e, "transform", `translate(${a().x}, ${a().y})`)), s(), e;
|
|
530
|
+
}
|
|
531
|
+
})];
|
|
532
|
+
};
|
|
533
|
+
n(["mousedown", "click"]);
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/ui/components/EdgesBoard.tsx
|
|
536
|
+
var le = /*#__PURE__*/ u("<svg class=\"pointer-events-none h-full w-full overflow-visible\"><!$><!/><!$><!/>"), ue = () => {
|
|
537
|
+
let [e, n] = _(), { newEdge: [r], edgesPositions: [s] } = Z(), c = g(() => Object.entries(s()).map(([e, t]) => ({
|
|
538
|
+
id: e,
|
|
539
|
+
...t
|
|
540
|
+
})));
|
|
541
|
+
return h(() => {
|
|
542
|
+
e() && r() && n();
|
|
543
|
+
}), (() => {
|
|
544
|
+
var e = i(le), n = e.firstChild, [s, l] = a(n.nextSibling), u = s.nextSibling, [d, m] = a(u.nextSibling);
|
|
545
|
+
return o(e, t(p, {
|
|
546
|
+
get when() {
|
|
547
|
+
return r();
|
|
548
|
+
},
|
|
549
|
+
children: (e) => t(ce, {
|
|
550
|
+
id: "__#new-edge#__TEMP",
|
|
551
|
+
isNew: !0,
|
|
552
|
+
get x0() {
|
|
553
|
+
return e().x0;
|
|
554
|
+
},
|
|
555
|
+
get y0() {
|
|
556
|
+
return e().y0;
|
|
557
|
+
},
|
|
558
|
+
get x1() {
|
|
559
|
+
return e().x1;
|
|
560
|
+
},
|
|
561
|
+
get y1() {
|
|
562
|
+
return e().y1;
|
|
563
|
+
}
|
|
564
|
+
})
|
|
565
|
+
}), s, l), o(e, t(f, {
|
|
566
|
+
get each() {
|
|
567
|
+
return c();
|
|
568
|
+
},
|
|
569
|
+
children: ce
|
|
570
|
+
}), d, m), e;
|
|
571
|
+
})();
|
|
572
|
+
}, de = /*#__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\">"), fe = /*#__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>"), pe = /*#__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>"), me = /*#__PURE__*/ u("<span class=\"min-w-max border-b border-[#f0f0f0] p-3 whitespace-nowrap text-red-600 select-none\">"), he = /*#__PURE__*/ u("<div class=\"p-3 select-none\">"), ge = (n) => {
|
|
573
|
+
let u, f, [m, g] = _(), { dimensions: [v, y], newEdge: [b, x], getBoardPoint: S, service: C, zoom: [T] } = Z(), D = E(C, { selector: (e) => e.context.selected === n.id });
|
|
574
|
+
h(() => {
|
|
575
|
+
let e = u, t = f, r = m(), i = T();
|
|
576
|
+
if (!t || !r) return;
|
|
577
|
+
let a = r.getBoundingClientRect(), o = t.getBoundingClientRect(), s = e?.getBoundingClientRect(), c = (o.left - a.left + o.width / 2) / i, l = (o.top - a.top + o.height / 2) / i, d = s ? (s.left - a.left + s.width / 2) / i : K, p = s ? (s.top - a.top + s.height / 2) / i : 18, h = a.width / i, g = a.height / i, _ = {
|
|
578
|
+
x: n.x + c,
|
|
579
|
+
y: n.y + l
|
|
580
|
+
}, v = {
|
|
581
|
+
x: n.x + d,
|
|
582
|
+
y: n.y + p
|
|
583
|
+
};
|
|
584
|
+
y(w((e) => {
|
|
585
|
+
e[n.id] = {
|
|
586
|
+
width: h,
|
|
587
|
+
height: g,
|
|
588
|
+
output: _,
|
|
589
|
+
input: v,
|
|
590
|
+
outputOffset: {
|
|
591
|
+
x: c,
|
|
592
|
+
y: l
|
|
593
|
+
},
|
|
594
|
+
inputOffset: {
|
|
595
|
+
x: d,
|
|
596
|
+
y: p
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}));
|
|
600
|
+
});
|
|
601
|
+
let O = E(C, { selector: ({ context: { data: e } }) => {
|
|
602
|
+
let t = e?.edges;
|
|
603
|
+
return t ? Object.values(t).some((e) => e.to === n.id) : !1;
|
|
604
|
+
} }), k = A(n.id);
|
|
605
|
+
return (() => {
|
|
606
|
+
var m = i(pe), h = m.firstChild, _ = h.firstChild, y = _.nextSibling, [w, T] = a(y.nextSibling), E = w.nextSibling, A = h.nextSibling, [j, M] = a(A.nextSibling), N = j.nextSibling, [P, F] = a(N.nextSibling), I = P.nextSibling, [L, R] = a(I.nextSibling), z = L.nextSibling, B = z.firstChild;
|
|
607
|
+
return d(k, m, () => ({ skipTransform: !0 })), m.$$mousedown = (e) => {
|
|
608
|
+
e.stopPropagation(), e.stopImmediatePropagation(), C.send({
|
|
609
|
+
type: "SELECT",
|
|
610
|
+
payload: n.id
|
|
611
|
+
});
|
|
612
|
+
}, d(g, m), _.$$click = (e) => {
|
|
613
|
+
e.stopPropagation(), C.send({
|
|
614
|
+
type: "DELETE",
|
|
615
|
+
payload: n.id
|
|
616
|
+
});
|
|
617
|
+
}, l(_, "width", "24px"), l(_, "height", "24px"), o(h, t(p, {
|
|
618
|
+
get when() {
|
|
619
|
+
return O();
|
|
620
|
+
},
|
|
621
|
+
get children() {
|
|
622
|
+
var e = i(de);
|
|
623
|
+
return e.$$click = () => C.send({
|
|
624
|
+
type: "ADD_SIBLING",
|
|
625
|
+
payload: n.id
|
|
626
|
+
}), l(e, "width", "24px"), l(e, "height", "24px"), s(), e;
|
|
627
|
+
}
|
|
628
|
+
}), w, T), E.$$click = () => C.send({
|
|
629
|
+
type: "ADD_CHILD",
|
|
630
|
+
payload: n.id
|
|
631
|
+
}), l(E, "width", "24px"), l(E, "height", "24px"), o(m, t(p, {
|
|
632
|
+
get when() {
|
|
633
|
+
return n.label;
|
|
634
|
+
},
|
|
635
|
+
keyed: !0,
|
|
636
|
+
children: (e) => (() => {
|
|
637
|
+
var t = i(me);
|
|
638
|
+
return o(t, e), t;
|
|
639
|
+
})()
|
|
640
|
+
}), j, M), o(m, t(p, {
|
|
641
|
+
get when() {
|
|
642
|
+
return n.content;
|
|
643
|
+
},
|
|
644
|
+
keyed: !0,
|
|
645
|
+
children: (e) => (() => {
|
|
646
|
+
var t = i(he);
|
|
647
|
+
return o(t, e), t;
|
|
648
|
+
})()
|
|
649
|
+
}), P, F), o(m, t(p, {
|
|
650
|
+
get when() {
|
|
651
|
+
return n.input || O();
|
|
652
|
+
},
|
|
653
|
+
get children() {
|
|
654
|
+
var e = i(fe), t = e.firstChild;
|
|
655
|
+
return l(e, "left", "-18px"), t.$$mouseup = (e) => {
|
|
656
|
+
e.stopPropagation();
|
|
657
|
+
let t = b()?.from;
|
|
658
|
+
t && C.send({
|
|
659
|
+
type: "ADD_EDGE",
|
|
660
|
+
payload: {
|
|
661
|
+
from: t,
|
|
662
|
+
to: n.id
|
|
663
|
+
}
|
|
664
|
+
}), x();
|
|
665
|
+
}, t.$$mousedown = (e) => {
|
|
666
|
+
e.stopPropagation();
|
|
667
|
+
}, d((e) => u = e, t), l(t, "width", "12px"), l(t, "height", "12px"), l(t, "margin-top", "12px"), s(), e;
|
|
668
|
+
}
|
|
669
|
+
}), L, R), l(z, "right", "-18px"), B.$$mousedown = (e) => {
|
|
670
|
+
e.stopPropagation(), C.send("DESELECT");
|
|
671
|
+
let t = v()[n.id]?.output, r = S(e.clientX, e.clientY);
|
|
672
|
+
t && x({
|
|
673
|
+
x0: t.x,
|
|
674
|
+
y0: t.y,
|
|
675
|
+
x1: r.x,
|
|
676
|
+
y1: r.y,
|
|
677
|
+
from: n.id
|
|
678
|
+
});
|
|
679
|
+
}, d((e) => f = e, B), l(B, "width", "12px"), l(B, "height", "12px"), l(B, "margin-top", "12px"), r((t) => {
|
|
680
|
+
var r = n.id, i = {
|
|
681
|
+
"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,
|
|
682
|
+
"border border-[#e38c29] z-[100]": D(),
|
|
683
|
+
"border border-[#e6d4be] z-[1]": !D()
|
|
684
|
+
}, a = `${n.y}px`, o = `${n.x}px`, s = {
|
|
685
|
+
"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,
|
|
686
|
+
"w-full opacity-100": D(),
|
|
687
|
+
"w-0 -right-3 opacity-0 overflow-hidden": !D()
|
|
688
|
+
};
|
|
689
|
+
return r !== t.e && c(m, "id", t.e = r), t.t = e(m, i, t.t), a !== t.a && l(m, "top", t.a = a), o !== t.o && l(m, "left", t.o = o), t.i = e(h, s, t.i), t;
|
|
690
|
+
}, {
|
|
691
|
+
e: void 0,
|
|
692
|
+
t: void 0,
|
|
693
|
+
a: void 0,
|
|
694
|
+
o: void 0,
|
|
695
|
+
i: void 0
|
|
696
|
+
}), s(), m;
|
|
697
|
+
})();
|
|
698
|
+
};
|
|
699
|
+
n([
|
|
700
|
+
"mousedown",
|
|
701
|
+
"click",
|
|
702
|
+
"mouseup"
|
|
703
|
+
]);
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/ui/components/NodesBoard.tsx
|
|
706
|
+
var _e = /*#__PURE__*/ u("<div class=\"relative mx-auto h-[calc(100vh-64px)] w-[calc(100vw-32px)]\"><div class=\"relative h-full w-full overflow-scroll rounded-lg border-2 border-gray-600\"><!$><!/><!$><!/><div class=\"relative cursor-crosshair\"style=\"transform-origin:top left\"><!$><!/><!$><!/></div></div><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\">"), ve = () => {
|
|
707
|
+
let e, [n, c] = _(!1), [u, m] = _({
|
|
708
|
+
x: 0,
|
|
709
|
+
y: 0
|
|
710
|
+
}), [g, b] = _(""), [x, S] = _(), C = () => {};
|
|
711
|
+
y(C);
|
|
712
|
+
let w = 0, T = 0, { board: [, A], service: j, newEdge: [M], zoom: [N, P] } = Z(), F = () => {
|
|
713
|
+
if (!e) return;
|
|
714
|
+
let t = e.scrollWidth - e.clientWidth, n = e.scrollHeight - e.clientHeight;
|
|
715
|
+
w = t > 0 ? e.scrollLeft / t : 0, T = n > 0 ? e.scrollTop / n : 0;
|
|
716
|
+
};
|
|
717
|
+
h(v(N, () => {
|
|
718
|
+
if (!e) return;
|
|
719
|
+
let t = e.scrollWidth - e.clientWidth, n = e.scrollHeight - e.clientHeight;
|
|
720
|
+
t > 0 && (e.scrollLeft = w * t), n > 0 && (e.scrollTop = T * n);
|
|
721
|
+
}, { defer: !0 }));
|
|
722
|
+
let I = E(j, { selector: (e) => e.context?.selected }), L = (e) => I() === e, R = E(j, {
|
|
723
|
+
selector: (e) => (e.context.data?.nodes ?? []).map((e) => ({
|
|
724
|
+
id: e.id,
|
|
725
|
+
x: e.position.x,
|
|
726
|
+
y: e.position.y,
|
|
727
|
+
label: e.data.label,
|
|
728
|
+
content: e.data.content ?? "",
|
|
729
|
+
input: e.input
|
|
730
|
+
})),
|
|
731
|
+
equals: $
|
|
732
|
+
}), z = () => {
|
|
733
|
+
let e = N();
|
|
734
|
+
return e < 1 ? 500 * e : 500;
|
|
735
|
+
};
|
|
736
|
+
return t(D, {
|
|
737
|
+
onDragMove: ({ draggable: { transform: e, node: t, id: n }, overlay: r }) => {
|
|
738
|
+
if (b(n), L(n)) {
|
|
739
|
+
let i = t.offsetLeft + e.x / N(), a = t.offsetTop + e.y / N();
|
|
740
|
+
r?.node.style.setProperty("top", a * 2 + "px"), r?.node.style.setProperty("left", i * 2 + "px");
|
|
741
|
+
let o = e.x / N(), s = e.y / N();
|
|
742
|
+
t.style.setProperty("transform", `translate3d(${o}px, ${s}px, 0)`), j.send({
|
|
743
|
+
type: "MOVE_IMMEDIATE",
|
|
744
|
+
payload: {
|
|
745
|
+
id: `${n}`,
|
|
746
|
+
x: i,
|
|
747
|
+
y: a
|
|
748
|
+
}
|
|
749
|
+
}), m({ ...e });
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
onDragEnd: ({ draggable: { node: e, id: t } }) => {
|
|
753
|
+
if (!L(t)) return;
|
|
754
|
+
let n = e.offsetLeft + u().x / N(), r = e.offsetTop + u().y / N();
|
|
755
|
+
e.style.setProperty("top", r + "px"), e.style.setProperty("left", n + "px"), e.style.removeProperty("transform"), setTimeout(() => {
|
|
756
|
+
j.send({
|
|
757
|
+
type: "MOVE",
|
|
758
|
+
payload: {
|
|
759
|
+
id: `${t}`,
|
|
760
|
+
x: n,
|
|
761
|
+
y: r
|
|
762
|
+
}
|
|
763
|
+
}), m({
|
|
764
|
+
x: 0,
|
|
765
|
+
y: 0
|
|
766
|
+
});
|
|
767
|
+
}, 0);
|
|
768
|
+
},
|
|
769
|
+
get children() {
|
|
770
|
+
return [(() => {
|
|
771
|
+
var u = i(_e), p = u.firstChild, m = p.firstChild, [h, g] = a(m.nextSibling), _ = h.nextSibling, [v, y] = a(_.nextSibling), b = v.nextSibling, w = b.firstChild, [T, E] = a(w.nextSibling), D = T.nextSibling, [k, I] = a(D.nextSibling), L = p.nextSibling.firstChild, B = L.nextSibling, V = B.firstChild, [H, U] = a(V.nextSibling);
|
|
772
|
+
H.nextSibling;
|
|
773
|
+
var W = B.nextSibling, G = W.nextSibling.nextSibling;
|
|
774
|
+
return u.addEventListener("wheel", (e) => {
|
|
775
|
+
if (e.ctrlKey || e.metaKey) {
|
|
776
|
+
e.preventDefault(), F();
|
|
777
|
+
let t = e.deltaY < 0 ? .1 : -.1;
|
|
778
|
+
P((e) => Math.min(Math.max(Number((e + t).toFixed(2)), .2), 3));
|
|
779
|
+
}
|
|
780
|
+
}), p.addEventListener("scroll", F), d((t) => e = t, p), o(p, t(O, {}), h, g), o(p, t(re, {}), v, y), b.$$mousedown = (t) => {
|
|
781
|
+
if (M() || t.button !== 0 || !e) return;
|
|
782
|
+
j.send("DESELECT");
|
|
783
|
+
let n = t.clientX, r = t.clientY, i = e.scrollLeft, a = e.scrollTop;
|
|
784
|
+
c(!0);
|
|
785
|
+
let o = (t) => {
|
|
786
|
+
if (!e) return;
|
|
787
|
+
let o = t.clientX - n, s = t.clientY - r;
|
|
788
|
+
e.scrollLeft = i - o * 3, e.scrollTop = a - s * 3, F();
|
|
789
|
+
}, s = () => {
|
|
790
|
+
window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", s), setTimeout(() => c(!1), 200), C = void 0;
|
|
791
|
+
};
|
|
792
|
+
C = s, window.addEventListener("mousemove", o), window.addEventListener("mouseup", s);
|
|
793
|
+
}, d(A, b), o(b, t(ue, {}), T, E), o(b, t(f, {
|
|
794
|
+
get each() {
|
|
795
|
+
return R();
|
|
796
|
+
},
|
|
797
|
+
children: ge
|
|
798
|
+
}), k, I), L.$$click = () => {
|
|
799
|
+
F(), S(void 0), P((e) => Math.max(.2, Number((e - .1).toFixed(2))));
|
|
800
|
+
}, B.$$click = () => {
|
|
801
|
+
F(), x() ? (P(x()), S(void 0)) : (S(N()), P(1));
|
|
802
|
+
}, o(B, () => Math.round(N() * 100), H, U), W.$$click = () => {
|
|
803
|
+
F(), S(void 0), P((e) => Math.min(3, Number((e + .1).toFixed(2))));
|
|
804
|
+
}, G.$$click = () => j.send("ADD_PARENT"), r((e) => {
|
|
805
|
+
var t = !!n(), r = `calc(${z()}vh - 85px)`, i = `calc(${z()}vw - 53px)`, a = N();
|
|
806
|
+
return t !== e.e && b.classList.toggle("cursor-grabbing", e.e = t), r !== e.t && l(b, "height", e.t = r), i !== e.a && l(b, "width", e.a = i), a !== e.o && l(b, "scale", e.o = a), e;
|
|
807
|
+
}, {
|
|
808
|
+
e: void 0,
|
|
809
|
+
t: void 0,
|
|
810
|
+
a: void 0,
|
|
811
|
+
o: void 0
|
|
812
|
+
}), s(), u;
|
|
813
|
+
})(), t(p, {
|
|
814
|
+
get when() {
|
|
815
|
+
return !g() || !L(g());
|
|
816
|
+
},
|
|
817
|
+
get children() {
|
|
818
|
+
return t(k, { children: "" });
|
|
819
|
+
}
|
|
820
|
+
})];
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
n(["mousedown", "click"]);
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/ui/components/FlowChart.tsx
|
|
827
|
+
var ye = /*#__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)\">"), be = (e) => {
|
|
828
|
+
let n = e.config?.nodes ?? ee, a = e.config?.edges, { service: c, newEdge: [u, d], getBoardPoint: f } = Z();
|
|
829
|
+
return b(() => {
|
|
830
|
+
c.start(), c.send({
|
|
831
|
+
type: "CONFIGURE",
|
|
832
|
+
payload: {
|
|
833
|
+
nodes: n,
|
|
834
|
+
edges: a ?? []
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
}), y(c.stop), (() => {
|
|
838
|
+
var e = i(ye), n = e.firstChild;
|
|
839
|
+
return e.$$mousemove = (e) => {
|
|
840
|
+
let t = u();
|
|
841
|
+
if (t) {
|
|
842
|
+
let n = f(e.clientX, e.clientY);
|
|
843
|
+
d({
|
|
844
|
+
...t,
|
|
845
|
+
x1: n.x,
|
|
846
|
+
y1: n.y
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}, e.$$mouseup = () => d(), o(n, t(ve, {})), r((e) => l(n, "cursor", u() ? "inherit" : "crosshair")), s(), e;
|
|
850
|
+
})();
|
|
851
|
+
};
|
|
852
|
+
n(["mouseup", "mousemove"]);
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/ui/Flow.tsx
|
|
855
|
+
var xe = (e) => t(te, { get children() {
|
|
856
|
+
return t(be, e);
|
|
857
|
+
} });
|
|
858
|
+
//#endregion
|
|
859
|
+
export { M as CLASSES, xe as Flow };
|