@cascivo/flow 0.1.16 → 0.1.17
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/dist/index.js +254 -254
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn as e, useComputed as t, useControllableSignal as n, useDraggable as r,
|
|
3
|
-
import { useId as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { builtin as
|
|
2
|
+
import { cn as e, useComputed as t, useControllableSignal as n, useDraggable as r, useEffectPropSignal as i, useResizeObserver as a, useSignal as o, useSignalEffect as s, useSignals as c } from "@cascivo/core";
|
|
3
|
+
import { useId as l, useRef as u } from "react";
|
|
4
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
import { builtin as m, t as h } from "@cascivo/i18n";
|
|
6
6
|
//#region src/engine/types.ts
|
|
7
|
-
var
|
|
7
|
+
var g = {
|
|
8
8
|
width: 150,
|
|
9
9
|
height: 40
|
|
10
|
-
},
|
|
10
|
+
}, _ = {
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0,
|
|
13
13
|
zoom: 1
|
|
14
14
|
};
|
|
15
|
-
function
|
|
15
|
+
function v(e = {}) {
|
|
16
16
|
let [t, r] = n({
|
|
17
17
|
value: e.nodes,
|
|
18
18
|
defaultValue: e.defaultNodes ?? [],
|
|
@@ -23,7 +23,7 @@ function _(e = {}) {
|
|
|
23
23
|
onChange: e.onEdgesChange
|
|
24
24
|
}), [o, s] = n({
|
|
25
25
|
value: e.viewport,
|
|
26
|
-
defaultValue: e.defaultViewport ??
|
|
26
|
+
defaultValue: e.defaultViewport ?? _,
|
|
27
27
|
onChange: e.onViewportChange
|
|
28
28
|
});
|
|
29
29
|
return {
|
|
@@ -46,16 +46,16 @@ function _(e = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/engine/transform.ts
|
|
49
|
-
function
|
|
49
|
+
function y(e, t = .2, n = 2) {
|
|
50
50
|
return Math.min(n, Math.max(t, e));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function b(e, t) {
|
|
53
53
|
return {
|
|
54
54
|
x: (e.x - t.x) / t.zoom,
|
|
55
55
|
y: (e.y - t.y) / t.zoom
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function x(e, t) {
|
|
59
59
|
return {
|
|
60
60
|
x: e.x * t.zoom + t.x,
|
|
61
61
|
y: e.y * t.zoom + t.y
|
|
@@ -63,14 +63,14 @@ function b(e, t) {
|
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/engine/geometry.ts
|
|
66
|
-
function
|
|
66
|
+
function S(e) {
|
|
67
67
|
return {
|
|
68
|
-
width: e.width ??
|
|
69
|
-
height: e.height ??
|
|
68
|
+
width: e.width ?? g.width,
|
|
69
|
+
height: e.height ?? g.height
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
let { width: t, height: n } =
|
|
72
|
+
function C(e) {
|
|
73
|
+
let { width: t, height: n } = S(e);
|
|
74
74
|
return {
|
|
75
75
|
x: e.position.x,
|
|
76
76
|
y: e.position.y,
|
|
@@ -78,8 +78,8 @@ function S(e) {
|
|
|
78
78
|
height: n
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
let { x: n, y: r, width: i, height: a } =
|
|
81
|
+
function w(e, t) {
|
|
82
|
+
let { x: n, y: r, width: i, height: a } = C(e);
|
|
83
83
|
switch (t) {
|
|
84
84
|
case "top": return {
|
|
85
85
|
x: n + i / 2,
|
|
@@ -99,11 +99,11 @@ function C(e, t) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function T(e) {
|
|
103
103
|
if (e.length === 0) return null;
|
|
104
104
|
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
|
|
105
105
|
for (let a of e) {
|
|
106
|
-
let e =
|
|
106
|
+
let e = C(a);
|
|
107
107
|
t = Math.min(t, e.x), n = Math.min(n, e.y), r = Math.max(r, e.x + e.width), i = Math.max(i, e.y + e.height);
|
|
108
108
|
}
|
|
109
109
|
return {
|
|
@@ -113,14 +113,14 @@ function w(e) {
|
|
|
113
113
|
height: i - n
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function E(e, t, n = {}) {
|
|
117
117
|
let { padding: r = .1, minZoom: i = .2, maxZoom: a = 2 } = n;
|
|
118
118
|
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0) return {
|
|
119
119
|
x: t.width / 2 - e.x,
|
|
120
120
|
y: t.height / 2 - e.y,
|
|
121
121
|
zoom: 1
|
|
122
122
|
};
|
|
123
|
-
let o = t.width / (e.width * (1 + r * 2)), s = t.height / (e.height * (1 + r * 2)), c =
|
|
123
|
+
let o = t.width / (e.width * (1 + r * 2)), s = t.height / (e.height * (1 + r * 2)), c = y(Math.min(o, s), i, a);
|
|
124
124
|
return {
|
|
125
125
|
x: t.width / 2 - (e.x + e.width / 2) * c,
|
|
126
126
|
y: t.height / 2 - (e.y + e.height / 2) * c,
|
|
@@ -129,11 +129,11 @@ function T(e, t, n = {}) {
|
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/engine/path.ts
|
|
132
|
-
var
|
|
132
|
+
var D = (e) => Number.isInteger(e) ? String(e) : e.toFixed(2).replace(/\.?0+$/, ""), O = (e, t) => ({
|
|
133
133
|
x: (e.x + t.x) / 2,
|
|
134
134
|
y: (e.y + t.y) / 2
|
|
135
135
|
});
|
|
136
|
-
function
|
|
136
|
+
function k(e) {
|
|
137
137
|
switch (e) {
|
|
138
138
|
case "top": return {
|
|
139
139
|
x: 0,
|
|
@@ -153,14 +153,14 @@ function O(e) {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function A({ source: e, target: t }) {
|
|
157
157
|
return {
|
|
158
|
-
d: `M${
|
|
159
|
-
mid:
|
|
158
|
+
d: `M${D(e.x)},${D(e.y)} L${D(t.x)},${D(t.y)}`,
|
|
159
|
+
mid: O(e, t)
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
let { source: t, target: n, curvature: r = .25 } = e, i = e.sourcePosition ?? "right", a = e.targetPosition ?? "left", o = Math.hypot(n.x - t.x, n.y - t.y), s = Math.max(r * o, 20), c =
|
|
162
|
+
function j(e) {
|
|
163
|
+
let { source: t, target: n, curvature: r = .25 } = e, i = e.sourcePosition ?? "right", a = e.targetPosition ?? "left", o = Math.hypot(n.x - t.x, n.y - t.y), s = Math.max(r * o, 20), c = k(i), l = k(a), u = {
|
|
164
164
|
x: t.x + c.x * s,
|
|
165
165
|
y: t.y + c.y * s
|
|
166
166
|
}, d = {
|
|
@@ -171,31 +171,31 @@ function A(e) {
|
|
|
171
171
|
y: (t.y + 3 * u.y + 3 * d.y + n.y) / 8
|
|
172
172
|
};
|
|
173
173
|
return {
|
|
174
|
-
d: `M${
|
|
174
|
+
d: `M${D(t.x)},${D(t.y)} C${D(u.x)},${D(u.y)} ${D(d.x)},${D(d.y)} ${D(n.x)},${D(n.y)}`,
|
|
175
175
|
mid: f
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function M(e, t) {
|
|
179
179
|
return Math.hypot(t.x - e.x, t.y - e.y);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
182
|
-
let r =
|
|
181
|
+
function N(e, t, n) {
|
|
182
|
+
let r = M(e, t) || 1;
|
|
183
183
|
return {
|
|
184
184
|
x: e.x + (t.x - e.x) / r * n,
|
|
185
185
|
y: e.y + (t.y - e.y) / r * n
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function P(e, t) {
|
|
189
189
|
if (e.length < 2) return "";
|
|
190
|
-
let n = e[0], r = `M${
|
|
190
|
+
let n = e[0], r = `M${D(n.x)},${D(n.y)}`;
|
|
191
191
|
for (let n = 1; n < e.length - 1; n++) {
|
|
192
|
-
let i = e[n - 1], a = e[n], o = e[n + 1], s = Math.min(t,
|
|
193
|
-
r += ` L${
|
|
192
|
+
let i = e[n - 1], a = e[n], o = e[n + 1], s = Math.min(t, M(i, a) / 2, M(a, o) / 2), c = N(a, i, s), l = N(a, o, s);
|
|
193
|
+
r += ` L${D(c.x)},${D(c.y)} Q${D(a.x)},${D(a.y)} ${D(l.x)},${D(l.y)}`;
|
|
194
194
|
}
|
|
195
195
|
let i = e[e.length - 1];
|
|
196
|
-
return r += ` L${
|
|
196
|
+
return r += ` L${D(i.x)},${D(i.y)}`, r;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function F(e) {
|
|
199
199
|
let { source: t, target: n, borderRadius: r = 8 } = e, i = e.sourcePosition ?? "right", a = i === "left" || i === "right", o = [t];
|
|
200
200
|
if (a) {
|
|
201
201
|
let e = (t.x + n.x) / 2;
|
|
@@ -217,21 +217,21 @@ function P(e) {
|
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
return o.push(n), {
|
|
220
|
-
d:
|
|
221
|
-
mid:
|
|
220
|
+
d: P(o, r),
|
|
221
|
+
mid: O(t, n)
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function I(e, t) {
|
|
225
225
|
switch (e) {
|
|
226
|
-
case "straight": return
|
|
227
|
-
case "smoothstep": return
|
|
228
|
-
case "bezier": return
|
|
226
|
+
case "straight": return A(t);
|
|
227
|
+
case "smoothstep": return F(t);
|
|
228
|
+
case "bezier": return j(t);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
//#endregion
|
|
232
232
|
//#region src/engine/layout.ts
|
|
233
|
-
function
|
|
234
|
-
let n = t.gap ?? 40, r = t.nodeWidth ??
|
|
233
|
+
function L(e, t = {}) {
|
|
234
|
+
let n = t.gap ?? 40, r = t.nodeWidth ?? g.width, i = t.nodeHeight ?? g.height, a = t.columns ?? Math.max(1, Math.ceil(Math.sqrt(e.length)));
|
|
235
235
|
return e.map((e, t) => {
|
|
236
236
|
let o = t % a, s = Math.floor(t / a);
|
|
237
237
|
return {
|
|
@@ -243,8 +243,8 @@ function I(e, t = {}) {
|
|
|
243
243
|
};
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
let r = n.direction ?? "LR", i = n.gap ?? 60, a = n.nodeWidth ??
|
|
246
|
+
function R(e, t, n = {}) {
|
|
247
|
+
let r = n.direction ?? "LR", i = n.gap ?? 60, a = n.nodeWidth ?? g.width, o = n.nodeHeight ?? g.height, s = new Set(e.map((e) => e.id)), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
248
248
|
for (let t of e) l.set(t.id, 0);
|
|
249
249
|
for (let e of t) !s.has(e.source) || !s.has(e.target) || (c.set(e.source, [...c.get(e.source) ?? [], e.target]), l.set(e.target, (l.get(e.target) ?? 0) + 1));
|
|
250
250
|
let u = /* @__PURE__ */ new Map(), d = e.filter((e) => (l.get(e.id) ?? 0) === 0).map((e) => e.id);
|
|
@@ -278,21 +278,21 @@ function L(e, t, n = {}) {
|
|
|
278
278
|
};
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
return n === "grid" ?
|
|
281
|
+
function z(e, t, n) {
|
|
282
|
+
return n === "grid" ? L(e) : n === "layered" ? R(e, t) : n(e, t);
|
|
283
283
|
}
|
|
284
284
|
//#endregion
|
|
285
285
|
//#region src/engine/script.ts
|
|
286
|
-
function
|
|
286
|
+
function B(e) {
|
|
287
287
|
return "edge" in e;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function ee(e, t) {
|
|
290
290
|
let n = {
|
|
291
291
|
label: e.label,
|
|
292
292
|
description: e.description,
|
|
293
293
|
duration: e.duration
|
|
294
294
|
};
|
|
295
|
-
if (
|
|
295
|
+
if (B(e)) {
|
|
296
296
|
let r = t.find((t) => t.id === e.edge);
|
|
297
297
|
if (!r) throw Error(`FlowStory: step references unknown edge "${e.edge}"`);
|
|
298
298
|
return {
|
|
@@ -316,13 +316,13 @@ function B(e, t) {
|
|
|
316
316
|
throw Error(`FlowStory: no edge connects "${e.from}" and "${e.to}"`);
|
|
317
317
|
}
|
|
318
318
|
function V(e, t) {
|
|
319
|
-
return e.map((e) =>
|
|
319
|
+
return e.map((e) => ee(e, t));
|
|
320
320
|
}
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/core/use-viewport.ts
|
|
323
323
|
var H = 1.2;
|
|
324
324
|
function U(e, t = {}) {
|
|
325
|
-
let { minZoom: n = .2, maxZoom:
|
|
325
|
+
let { minZoom: n = .2, maxZoom: i = 2, panOnDrag: o = !0, zoomOnScroll: c = !0, fitPadding: l = .1, fitOnInit: d = !1 } = t, { viewport: f, setViewport: p } = e, { ref: m, size: h } = a(), { handleRef: g, offset: _, isDragging: v } = r({ isDisabled: !o }), x = (e, t) => {
|
|
326
326
|
let n = f.peek();
|
|
327
327
|
p({
|
|
328
328
|
x: n.x + e,
|
|
@@ -330,20 +330,20 @@ function U(e, t = {}) {
|
|
|
330
330
|
zoom: n.zoom
|
|
331
331
|
});
|
|
332
332
|
}, S = (e, t) => {
|
|
333
|
-
let r = f.peek(),
|
|
333
|
+
let r = f.peek(), a = y(e, n, i);
|
|
334
334
|
if (!t) {
|
|
335
335
|
p({
|
|
336
336
|
x: r.x,
|
|
337
337
|
y: r.y,
|
|
338
|
-
zoom:
|
|
338
|
+
zoom: a
|
|
339
339
|
});
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
|
-
let o =
|
|
342
|
+
let o = b(t, r);
|
|
343
343
|
p({
|
|
344
|
-
x: t.x - o.x *
|
|
345
|
-
y: t.y - o.y *
|
|
346
|
-
zoom:
|
|
344
|
+
x: t.x - o.x * a,
|
|
345
|
+
y: t.y - o.y * a,
|
|
346
|
+
zoom: a
|
|
347
347
|
});
|
|
348
348
|
}, C = () => {
|
|
349
349
|
let e = m.current;
|
|
@@ -351,7 +351,7 @@ function U(e, t = {}) {
|
|
|
351
351
|
x: e.clientWidth / 2,
|
|
352
352
|
y: e.clientHeight / 2
|
|
353
353
|
};
|
|
354
|
-
},
|
|
354
|
+
}, w = () => S(f.peek().zoom * H, C()), D = () => S(f.peek().zoom / H, C()), O = () => {
|
|
355
355
|
let e = h.peek();
|
|
356
356
|
if (e && e.width > 0 && e.height > 0) return e;
|
|
357
357
|
let t = m.current;
|
|
@@ -360,18 +360,18 @@ function U(e, t = {}) {
|
|
|
360
360
|
height: t.clientHeight
|
|
361
361
|
} : null;
|
|
362
362
|
}, k = (t) => {
|
|
363
|
-
let r =
|
|
363
|
+
let r = T(e.nodes.peek());
|
|
364
364
|
if (!r) return;
|
|
365
|
-
let
|
|
366
|
-
|
|
367
|
-
padding:
|
|
365
|
+
let a = t ?? O();
|
|
366
|
+
a && p(E(r, a, {
|
|
367
|
+
padding: l,
|
|
368
368
|
minZoom: n,
|
|
369
|
-
maxZoom:
|
|
369
|
+
maxZoom: i
|
|
370
370
|
}));
|
|
371
|
-
}, A =
|
|
372
|
-
|
|
373
|
-
let e =
|
|
374
|
-
if (!
|
|
371
|
+
}, A = u(null);
|
|
372
|
+
s(() => {
|
|
373
|
+
let e = v.value, t = _.value;
|
|
374
|
+
if (!o) return;
|
|
375
375
|
if (!e) {
|
|
376
376
|
A.current = null;
|
|
377
377
|
return;
|
|
@@ -386,7 +386,7 @@ function U(e, t = {}) {
|
|
|
386
386
|
y: n.vp.y + (t.y - n.off.y),
|
|
387
387
|
zoom: n.vp.zoom
|
|
388
388
|
});
|
|
389
|
-
}),
|
|
389
|
+
}), s(() => {
|
|
390
390
|
if (!c || typeof window > "u") return;
|
|
391
391
|
let e = m.current;
|
|
392
392
|
if (!e) return;
|
|
@@ -400,8 +400,8 @@ function U(e, t = {}) {
|
|
|
400
400
|
};
|
|
401
401
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
402
402
|
});
|
|
403
|
-
let j =
|
|
404
|
-
return
|
|
403
|
+
let j = u(!1);
|
|
404
|
+
return s(() => {
|
|
405
405
|
if (!d || j.current) return;
|
|
406
406
|
let e = h.value;
|
|
407
407
|
!e || e.width === 0 || (j.current = !0, k(e));
|
|
@@ -411,36 +411,36 @@ function U(e, t = {}) {
|
|
|
411
411
|
viewport: f,
|
|
412
412
|
pan: x,
|
|
413
413
|
zoomTo: S,
|
|
414
|
-
zoomIn:
|
|
414
|
+
zoomIn: w,
|
|
415
415
|
zoomOut: D,
|
|
416
416
|
fitView: k
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
//#endregion
|
|
420
420
|
//#region src/core/use-connection.ts
|
|
421
|
-
var
|
|
421
|
+
var te = "[data-flow-handle][data-handle-type=\"source\"]", ne = "[data-flow-handle][data-handle-type=\"target\"]";
|
|
422
422
|
function W(e) {
|
|
423
|
-
let { containerRef: t } = e, n =
|
|
423
|
+
let { containerRef: t } = e, n = o(null), r = u(e.onConnect);
|
|
424
424
|
r.current = e.onConnect;
|
|
425
|
-
let
|
|
426
|
-
|
|
427
|
-
let
|
|
428
|
-
|
|
429
|
-
let
|
|
430
|
-
return
|
|
431
|
-
if (!
|
|
425
|
+
let a = u(e.isValid);
|
|
426
|
+
a.current = e.isValid;
|
|
427
|
+
let c = u(e.clientToFlow);
|
|
428
|
+
c.current = e.clientToFlow;
|
|
429
|
+
let l = i(e.enabled ?? !0);
|
|
430
|
+
return s(() => {
|
|
431
|
+
if (!l.value || typeof window > "u") return;
|
|
432
432
|
let e = t.current;
|
|
433
433
|
if (!e) return;
|
|
434
|
-
let
|
|
434
|
+
let i = (e) => {
|
|
435
435
|
let t = n.peek();
|
|
436
436
|
t && (n.value = {
|
|
437
437
|
...t,
|
|
438
|
-
to:
|
|
438
|
+
to: c.current(e.clientX, e.clientY)
|
|
439
439
|
});
|
|
440
440
|
}, o = (e) => {
|
|
441
441
|
let t = n.peek();
|
|
442
|
-
if (window.removeEventListener("pointermove",
|
|
443
|
-
let s = e.target, c = s instanceof Element ? s.closest(
|
|
442
|
+
if (window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), n.value = null, !t) return;
|
|
443
|
+
let s = e.target, c = s instanceof Element ? s.closest(ne) : null, l = c?.closest("[data-node-id]");
|
|
444
444
|
if (!l) return;
|
|
445
445
|
let u = {
|
|
446
446
|
source: t.source,
|
|
@@ -448,33 +448,33 @@ function W(e) {
|
|
|
448
448
|
sourceHandle: t.sourceHandle,
|
|
449
449
|
targetHandle: c?.getAttribute("data-handle-id") ?? void 0
|
|
450
450
|
};
|
|
451
|
-
!u.target || u.source === u.target ||
|
|
452
|
-
},
|
|
451
|
+
!u.target || u.source === u.target || a.current && !a.current(u) || r.current?.(u);
|
|
452
|
+
}, s = (e) => {
|
|
453
453
|
let t = e.target;
|
|
454
454
|
if (!(t instanceof Element)) return;
|
|
455
|
-
let r = t.closest(
|
|
455
|
+
let r = t.closest(te);
|
|
456
456
|
if (!r) return;
|
|
457
|
-
let
|
|
458
|
-
if (!
|
|
457
|
+
let a = r.closest("[data-node-id]");
|
|
458
|
+
if (!a) return;
|
|
459
459
|
e.stopPropagation();
|
|
460
|
-
let
|
|
460
|
+
let s = r.getBoundingClientRect();
|
|
461
461
|
n.value = {
|
|
462
|
-
source:
|
|
462
|
+
source: a.getAttribute("data-node-id") ?? "",
|
|
463
463
|
sourceHandle: r.getAttribute("data-handle-id") ?? void 0,
|
|
464
|
-
from:
|
|
465
|
-
to:
|
|
466
|
-
}, window.addEventListener("pointermove",
|
|
464
|
+
from: c.current(s.left + s.width / 2, s.top + s.height / 2),
|
|
465
|
+
to: c.current(e.clientX, e.clientY)
|
|
466
|
+
}, window.addEventListener("pointermove", i), window.addEventListener("pointerup", o);
|
|
467
467
|
};
|
|
468
|
-
return e.addEventListener("pointerdown",
|
|
469
|
-
e.removeEventListener("pointerdown",
|
|
468
|
+
return e.addEventListener("pointerdown", s), () => {
|
|
469
|
+
e.removeEventListener("pointerdown", s), window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o);
|
|
470
470
|
};
|
|
471
471
|
}), { connection: n };
|
|
472
472
|
}
|
|
473
473
|
//#endregion
|
|
474
474
|
//#region src/core/use-story.ts
|
|
475
|
-
var
|
|
476
|
-
function
|
|
477
|
-
let { steps: r, loop: i = !0, stepDuration: a =
|
|
475
|
+
var re = 1500;
|
|
476
|
+
function ie(e) {
|
|
477
|
+
let { steps: r, loop: i = !0, stepDuration: a = re, stepGap: o = 0 } = e, [c, l] = n({
|
|
478
478
|
value: e.currentStep,
|
|
479
479
|
defaultValue: e.defaultCurrentStep ?? 0,
|
|
480
480
|
onChange: e.onStepChange
|
|
@@ -482,9 +482,9 @@ function re(e) {
|
|
|
482
482
|
value: e.playing,
|
|
483
483
|
defaultValue: e.defaultPlaying ?? !0,
|
|
484
484
|
onChange: e.onPlayingChange
|
|
485
|
-
}), p = t(() => r[c.value] ?? null), m =
|
|
485
|
+
}), p = t(() => r[c.value] ?? null), m = u(e.clock);
|
|
486
486
|
m.current = e.clock;
|
|
487
|
-
let h =
|
|
487
|
+
let h = u(r);
|
|
488
488
|
h.current = r;
|
|
489
489
|
let g = () => m.current ?? {
|
|
490
490
|
setTimeout: (e, t) => window.setTimeout(e, t),
|
|
@@ -493,17 +493,17 @@ function re(e) {
|
|
|
493
493
|
let t = h.current.length;
|
|
494
494
|
if (t === 0) return;
|
|
495
495
|
let n = c.peek() + e;
|
|
496
|
-
|
|
496
|
+
l(i ? (n % t + t) % t : Math.max(0, Math.min(t - 1, n)));
|
|
497
497
|
};
|
|
498
|
-
return
|
|
498
|
+
return s(() => {
|
|
499
499
|
if (!d.value) return;
|
|
500
500
|
let e = c.value, t = r.length;
|
|
501
501
|
if (t === 0 || typeof window > "u" && !m.current) return;
|
|
502
|
-
let n = (r[e]?.duration ?? a) +
|
|
502
|
+
let n = (r[e]?.duration ?? a) + o, s = g(), u = s.setTimeout(() => {
|
|
503
503
|
let n = e + 1;
|
|
504
|
-
n >= t ? i ?
|
|
504
|
+
n >= t ? i ? l(0) : f(!1) : l(n);
|
|
505
505
|
}, n);
|
|
506
|
-
return () =>
|
|
506
|
+
return () => s.clearTimeout(u);
|
|
507
507
|
}), {
|
|
508
508
|
currentStep: c,
|
|
509
509
|
playing: d,
|
|
@@ -514,7 +514,7 @@ function re(e) {
|
|
|
514
514
|
next: () => _(1),
|
|
515
515
|
prev: () => _(-1),
|
|
516
516
|
restart: () => {
|
|
517
|
-
|
|
517
|
+
l(0), f(!0);
|
|
518
518
|
}
|
|
519
519
|
};
|
|
520
520
|
}
|
|
@@ -525,32 +525,32 @@ var G = {
|
|
|
525
525
|
};
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region src/core/flow-canvas/flow-canvas.tsx
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
let b =
|
|
528
|
+
function ae({ children: t, flow: n, viewport: r, defaultViewport: i, onViewportChange: a, minZoom: o, maxZoom: s, panOnDrag: l = !0, zoomOnScroll: u = !0, fitView: d = !1, controller: m, chrome: h, className: g, role: _ = "application", ...y }) {
|
|
529
|
+
c();
|
|
530
|
+
let b = v({
|
|
531
531
|
viewport: r,
|
|
532
532
|
defaultViewport: i,
|
|
533
533
|
onViewportChange: a
|
|
534
534
|
}), x = n ?? b, S = U(x, {
|
|
535
535
|
minZoom: o,
|
|
536
|
-
maxZoom:
|
|
536
|
+
maxZoom: s,
|
|
537
537
|
panOnDrag: l,
|
|
538
538
|
zoomOnScroll: u,
|
|
539
|
-
fitOnInit:
|
|
539
|
+
fitOnInit: d
|
|
540
540
|
}), C = m ?? S, w = x.viewport.value;
|
|
541
|
-
return /* @__PURE__ */
|
|
541
|
+
return /* @__PURE__ */ p("div", {
|
|
542
542
|
ref: C.containerRef,
|
|
543
543
|
className: e(G.canvas, g),
|
|
544
|
-
role:
|
|
544
|
+
role: _,
|
|
545
545
|
...y,
|
|
546
|
-
children: [/* @__PURE__ */
|
|
546
|
+
children: [/* @__PURE__ */ p("div", {
|
|
547
547
|
className: G.pane,
|
|
548
548
|
style: {
|
|
549
549
|
"--flow-tx": `${w.x}px`,
|
|
550
550
|
"--flow-ty": `${w.y}px`,
|
|
551
551
|
"--flow-scale": String(w.zoom)
|
|
552
552
|
},
|
|
553
|
-
children: [/* @__PURE__ */
|
|
553
|
+
children: [/* @__PURE__ */ f("div", {
|
|
554
554
|
ref: C.panHandleRef,
|
|
555
555
|
className: G.panSurface,
|
|
556
556
|
"aria-hidden": "true"
|
|
@@ -558,14 +558,14 @@ function ie({ children: t, flow: n, viewport: r, defaultViewport: i, onViewportC
|
|
|
558
558
|
}), h]
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
|
-
var
|
|
561
|
+
var oe = { background: "_background_1pu9x_2" };
|
|
562
562
|
//#endregion
|
|
563
563
|
//#region src/flows/flow-background/flow-background.tsx
|
|
564
|
-
function
|
|
565
|
-
return /* @__PURE__ */
|
|
564
|
+
function se({ variant: t = "dots", gap: n = 20, size: r = 1, color: i, className: a, style: o, ...s }) {
|
|
565
|
+
return /* @__PURE__ */ f("div", {
|
|
566
566
|
"data-variant": t,
|
|
567
567
|
"aria-hidden": "true",
|
|
568
|
-
className: e(
|
|
568
|
+
className: e(oe.background, a),
|
|
569
569
|
style: {
|
|
570
570
|
"--flow-bg-gap": `${n}px`,
|
|
571
571
|
"--flow-bg-size": `${r}px`,
|
|
@@ -576,22 +576,22 @@ function oe({ variant: t = "dots", gap: n = 20, size: r = 1, color: i, className
|
|
|
576
576
|
...s
|
|
577
577
|
});
|
|
578
578
|
}
|
|
579
|
-
var
|
|
579
|
+
var ce = { node: "_node_9zyg4_2" };
|
|
580
580
|
//#endregion
|
|
581
581
|
//#region src/flows/flow-node/flow-node.tsx
|
|
582
|
-
function
|
|
583
|
-
|
|
582
|
+
function le({ id: t, position: i, defaultPosition: a, onPositionChange: o, onMeasure: l, zoom: d = 1, selected: p = !1, draggable: m = !0, interactive: h = !0, onSelect: g, children: _, className: v, onClick: y, onKeyDown: b, ...x }) {
|
|
583
|
+
c();
|
|
584
584
|
let S = m && h, [C, w] = n({
|
|
585
585
|
value: i,
|
|
586
586
|
defaultValue: a ?? i ?? {
|
|
587
587
|
x: 0,
|
|
588
588
|
y: 0
|
|
589
589
|
},
|
|
590
|
-
onChange:
|
|
591
|
-
}), { handleRef: T, targetRef: E, offset: D, isDragging: O } = r({ isDisabled: !S }), k =
|
|
590
|
+
onChange: o
|
|
591
|
+
}), { handleRef: T, targetRef: E, offset: D, isDragging: O } = r({ isDisabled: !S }), k = u(null), A = (e) => {
|
|
592
592
|
k.current = e, T.current = e, E.current = e;
|
|
593
|
-
}, j = l
|
|
594
|
-
j.current =
|
|
593
|
+
}, j = u(l);
|
|
594
|
+
j.current = l, s(() => {
|
|
595
595
|
let e = k.current;
|
|
596
596
|
if (!e || typeof ResizeObserver > "u") return;
|
|
597
597
|
let t = () => {
|
|
@@ -605,10 +605,10 @@ function ce({ id: t, position: i, defaultPosition: a, onPositionChange: c, onMea
|
|
|
605
605
|
let n = new ResizeObserver(t);
|
|
606
606
|
return n.observe(e), () => n.disconnect();
|
|
607
607
|
});
|
|
608
|
-
let M =
|
|
609
|
-
M.current =
|
|
610
|
-
let N =
|
|
611
|
-
|
|
608
|
+
let M = u(d);
|
|
609
|
+
M.current = d;
|
|
610
|
+
let N = u(null);
|
|
611
|
+
s(() => {
|
|
612
612
|
let e = O.value, t = D.value;
|
|
613
613
|
if (!S) return;
|
|
614
614
|
if (!e) {
|
|
@@ -626,7 +626,7 @@ function ce({ id: t, position: i, defaultPosition: a, onPositionChange: c, onMea
|
|
|
626
626
|
});
|
|
627
627
|
});
|
|
628
628
|
let P = C.value;
|
|
629
|
-
return /* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ f("div", {
|
|
630
630
|
ref: A,
|
|
631
631
|
"data-node-id": t,
|
|
632
632
|
"data-selected": p || void 0,
|
|
@@ -634,7 +634,7 @@ function ce({ id: t, position: i, defaultPosition: a, onPositionChange: c, onMea
|
|
|
634
634
|
"data-static": !h || void 0,
|
|
635
635
|
role: "group",
|
|
636
636
|
tabIndex: h ? 0 : void 0,
|
|
637
|
-
className: e(
|
|
637
|
+
className: e(ce.node, v),
|
|
638
638
|
style: {
|
|
639
639
|
"--flow-x": `${P.x}px`,
|
|
640
640
|
"--flow-y": `${P.y}px`
|
|
@@ -649,27 +649,27 @@ function ce({ id: t, position: i, defaultPosition: a, onPositionChange: c, onMea
|
|
|
649
649
|
children: _
|
|
650
650
|
});
|
|
651
651
|
}
|
|
652
|
-
var
|
|
652
|
+
var ue = {
|
|
653
653
|
handle: "_handle_8a1xa_2",
|
|
654
654
|
dot: "_dot_8a1xa_41"
|
|
655
655
|
};
|
|
656
656
|
//#endregion
|
|
657
657
|
//#region src/flows/flow-handle/flow-handle.tsx
|
|
658
|
-
function
|
|
658
|
+
function de(e) {
|
|
659
659
|
return e === "source" ? "right" : "left";
|
|
660
660
|
}
|
|
661
661
|
function K({ type: t, position: n, id: r, isConnectable: i = !0, className: a, ...o }) {
|
|
662
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ f("div", {
|
|
663
663
|
"data-handle-type": t,
|
|
664
|
-
"data-handle-pos": n ??
|
|
664
|
+
"data-handle-pos": n ?? de(t),
|
|
665
665
|
"data-handle-id": r,
|
|
666
666
|
"data-connectable": i || void 0,
|
|
667
667
|
"data-flow-handle": "",
|
|
668
668
|
tabIndex: i ? 0 : -1,
|
|
669
|
-
className: e(
|
|
669
|
+
className: e(ue.handle, a),
|
|
670
670
|
...o,
|
|
671
|
-
children: /* @__PURE__ */
|
|
672
|
-
className:
|
|
671
|
+
children: /* @__PURE__ */ f("span", {
|
|
672
|
+
className: ue.dot,
|
|
673
673
|
"aria-hidden": "true"
|
|
674
674
|
})
|
|
675
675
|
});
|
|
@@ -684,8 +684,8 @@ var q = {
|
|
|
684
684
|
};
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region src/flows/flow-edge/flow-edge.tsx
|
|
687
|
-
function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePosition: o = "right", targetPosition: s = "left", type:
|
|
688
|
-
let x =
|
|
687
|
+
function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePosition: o = "right", targetPosition: s = "left", type: c = "bezier", animated: u = !1, label: m, selected: h = !1, markerStart: g = !1, markerEnd: _ = !0, direction: v = "forward", active: y, className: b }) {
|
|
688
|
+
let x = l(), S = `flow-arrow-${t ?? x}`, C = g || _, { d: w, mid: T } = I(c, {
|
|
689
689
|
source: {
|
|
690
690
|
x: n,
|
|
691
691
|
y: r
|
|
@@ -697,16 +697,16 @@ function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePositi
|
|
|
697
697
|
sourcePosition: o,
|
|
698
698
|
targetPosition: s
|
|
699
699
|
});
|
|
700
|
-
return /* @__PURE__ */
|
|
700
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("svg", {
|
|
701
701
|
className: e(q.edgeSvg, b),
|
|
702
702
|
"data-edge-id": t,
|
|
703
|
-
"data-animated":
|
|
703
|
+
"data-animated": u || void 0,
|
|
704
704
|
"data-selected": h || void 0,
|
|
705
705
|
"data-active": y || void 0,
|
|
706
706
|
"data-direction": v,
|
|
707
707
|
"aria-hidden": "true",
|
|
708
708
|
children: [
|
|
709
|
-
C && /* @__PURE__ */
|
|
709
|
+
C && /* @__PURE__ */ f("defs", { children: /* @__PURE__ */ f("marker", {
|
|
710
710
|
id: S,
|
|
711
711
|
viewBox: "0 0 10 10",
|
|
712
712
|
refX: "9",
|
|
@@ -714,23 +714,23 @@ function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePositi
|
|
|
714
714
|
markerWidth: "7",
|
|
715
715
|
markerHeight: "7",
|
|
716
716
|
orient: "auto-start-reverse",
|
|
717
|
-
children: /* @__PURE__ */
|
|
717
|
+
children: /* @__PURE__ */ f("path", {
|
|
718
718
|
className: q.arrow,
|
|
719
719
|
d: "M0,0 L10,5 L0,10 z"
|
|
720
720
|
})
|
|
721
721
|
}) }),
|
|
722
|
-
/* @__PURE__ */
|
|
722
|
+
/* @__PURE__ */ f("path", {
|
|
723
723
|
className: q.hit,
|
|
724
724
|
d: w
|
|
725
725
|
}),
|
|
726
|
-
/* @__PURE__ */
|
|
726
|
+
/* @__PURE__ */ f("path", {
|
|
727
727
|
className: q.edgePath,
|
|
728
728
|
d: w,
|
|
729
729
|
markerStart: g ? `url(#${S})` : void 0,
|
|
730
730
|
markerEnd: _ ? `url(#${S})` : void 0
|
|
731
731
|
})
|
|
732
732
|
]
|
|
733
|
-
}), m != null && /* @__PURE__ */
|
|
733
|
+
}), m != null && /* @__PURE__ */ f("div", {
|
|
734
734
|
className: q.label,
|
|
735
735
|
style: {
|
|
736
736
|
"--flow-label-x": `${T.x}px`,
|
|
@@ -749,47 +749,47 @@ var Y = {
|
|
|
749
749
|
fill: "none",
|
|
750
750
|
"aria-hidden": !0
|
|
751
751
|
};
|
|
752
|
-
function
|
|
753
|
-
return
|
|
752
|
+
function fe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0, onZoomIn: i, onZoomOut: a, onFitView: o, labels: s, className: l, ...u }) {
|
|
753
|
+
return c(), /* @__PURE__ */ p("div", {
|
|
754
754
|
"data-position": t,
|
|
755
755
|
className: e(Y.controls, l),
|
|
756
|
-
...
|
|
757
|
-
children: [n && /* @__PURE__ */
|
|
756
|
+
...u,
|
|
757
|
+
children: [n && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
|
|
758
758
|
type: "button",
|
|
759
759
|
className: Y.button,
|
|
760
|
-
"aria-label":
|
|
760
|
+
"aria-label": s?.zoomIn ?? h(m.flow.zoomIn),
|
|
761
761
|
onClick: i,
|
|
762
|
-
children: /* @__PURE__ */
|
|
762
|
+
children: /* @__PURE__ */ f("svg", {
|
|
763
763
|
...X,
|
|
764
|
-
children: /* @__PURE__ */
|
|
764
|
+
children: /* @__PURE__ */ f("path", {
|
|
765
765
|
d: "M12 5v14M5 12h14",
|
|
766
766
|
stroke: "currentColor",
|
|
767
767
|
strokeWidth: "2",
|
|
768
768
|
strokeLinecap: "round"
|
|
769
769
|
})
|
|
770
770
|
})
|
|
771
|
-
}), /* @__PURE__ */
|
|
771
|
+
}), /* @__PURE__ */ f("button", {
|
|
772
772
|
type: "button",
|
|
773
773
|
className: Y.button,
|
|
774
|
-
"aria-label":
|
|
774
|
+
"aria-label": s?.zoomOut ?? h(m.flow.zoomOut),
|
|
775
775
|
onClick: a,
|
|
776
|
-
children: /* @__PURE__ */
|
|
776
|
+
children: /* @__PURE__ */ f("svg", {
|
|
777
777
|
...X,
|
|
778
|
-
children: /* @__PURE__ */
|
|
778
|
+
children: /* @__PURE__ */ f("path", {
|
|
779
779
|
d: "M5 12h14",
|
|
780
780
|
stroke: "currentColor",
|
|
781
781
|
strokeWidth: "2",
|
|
782
782
|
strokeLinecap: "round"
|
|
783
783
|
})
|
|
784
784
|
})
|
|
785
|
-
})] }), r && /* @__PURE__ */
|
|
785
|
+
})] }), r && /* @__PURE__ */ f("button", {
|
|
786
786
|
type: "button",
|
|
787
787
|
className: Y.button,
|
|
788
|
-
"aria-label":
|
|
788
|
+
"aria-label": s?.fitView ?? h(m.flow.fitView),
|
|
789
789
|
onClick: o,
|
|
790
|
-
children: /* @__PURE__ */
|
|
790
|
+
children: /* @__PURE__ */ f("svg", {
|
|
791
791
|
...X,
|
|
792
|
-
children: /* @__PURE__ */
|
|
792
|
+
children: /* @__PURE__ */ f("path", {
|
|
793
793
|
d: "M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4",
|
|
794
794
|
stroke: "currentColor",
|
|
795
795
|
strokeWidth: "2",
|
|
@@ -807,27 +807,27 @@ var Z = {
|
|
|
807
807
|
};
|
|
808
808
|
//#endregion
|
|
809
809
|
//#region src/flows/flow-minimap/flow-minimap.tsx
|
|
810
|
-
function
|
|
811
|
-
|
|
812
|
-
let x =
|
|
810
|
+
function pe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, width: o = 200, height: l = 150, position: d = "bottom-right", nodeColor: g, onViewportChange: _, label: v, className: y }) {
|
|
811
|
+
c();
|
|
812
|
+
let x = T(t) ?? {
|
|
813
813
|
x: 0,
|
|
814
814
|
y: 0,
|
|
815
815
|
width: 1,
|
|
816
816
|
height: 1
|
|
817
|
-
},
|
|
817
|
+
}, S = x.width || 1, w = x.height || 1, E = S * .1, D = w * .1, O = {
|
|
818
818
|
x: x.x - E,
|
|
819
819
|
y: x.y - D,
|
|
820
|
-
width:
|
|
821
|
-
height:
|
|
822
|
-
}, k = Math.min(
|
|
820
|
+
width: S + E * 2,
|
|
821
|
+
height: w + D * 2
|
|
822
|
+
}, k = Math.min(o / O.width, l / O.height), A = -O.x * k + (o - O.width * k) / 2, j = -O.y * k + (l - O.height * k) / 2, M = (e) => ({
|
|
823
823
|
x: e.x * k + A,
|
|
824
824
|
y: e.y * k + j
|
|
825
825
|
}), N = null;
|
|
826
826
|
if (i && a) {
|
|
827
|
-
let e =
|
|
827
|
+
let e = b({
|
|
828
828
|
x: 0,
|
|
829
829
|
y: 0
|
|
830
|
-
}, n), t =
|
|
830
|
+
}, n), t = b({
|
|
831
831
|
x: i,
|
|
832
832
|
y: a
|
|
833
833
|
}, n), r = M(e);
|
|
@@ -838,12 +838,12 @@ function fe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
838
838
|
h: (t.y - e.y) * k
|
|
839
839
|
};
|
|
840
840
|
}
|
|
841
|
-
let { handleRef: P, offset: F, isDragging: I } = r({ isDisabled: !_ }), L =
|
|
841
|
+
let { handleRef: P, offset: F, isDragging: I } = r({ isDisabled: !_ }), L = u(null), R = (e) => {
|
|
842
842
|
L.current = e, P.current = e;
|
|
843
|
-
}, z =
|
|
843
|
+
}, z = u(_);
|
|
844
844
|
z.current = _;
|
|
845
|
-
let B =
|
|
846
|
-
return
|
|
845
|
+
let B = u(null);
|
|
846
|
+
return s(() => {
|
|
847
847
|
let e = I.value, t = F.value;
|
|
848
848
|
if (!z.current) return;
|
|
849
849
|
if (!e) {
|
|
@@ -860,19 +860,19 @@ function fe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
860
860
|
y: r.vp.y - (t.y - r.off.y) / k * i,
|
|
861
861
|
zoom: i
|
|
862
862
|
});
|
|
863
|
-
}), /* @__PURE__ */
|
|
864
|
-
"data-position":
|
|
865
|
-
className: e(Z.minimap,
|
|
866
|
-
width:
|
|
867
|
-
height:
|
|
863
|
+
}), /* @__PURE__ */ p("svg", {
|
|
864
|
+
"data-position": d,
|
|
865
|
+
className: e(Z.minimap, y),
|
|
866
|
+
width: o,
|
|
867
|
+
height: l,
|
|
868
868
|
role: "img",
|
|
869
|
-
"aria-label": v ?? m
|
|
869
|
+
"aria-label": v ?? h(m.flow.minimap),
|
|
870
870
|
children: [t.map((e) => {
|
|
871
|
-
let t =
|
|
871
|
+
let t = C(e), n = M({
|
|
872
872
|
x: t.x,
|
|
873
873
|
y: t.y
|
|
874
874
|
});
|
|
875
|
-
return /* @__PURE__ */
|
|
875
|
+
return /* @__PURE__ */ f("rect", {
|
|
876
876
|
"data-node-id": e.id,
|
|
877
877
|
className: Z.node,
|
|
878
878
|
x: n.x,
|
|
@@ -881,7 +881,7 @@ function fe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
881
881
|
height: t.height * k,
|
|
882
882
|
fill: g
|
|
883
883
|
}, e.id);
|
|
884
|
-
}), N && /* @__PURE__ */
|
|
884
|
+
}), N && /* @__PURE__ */ f("rect", {
|
|
885
885
|
ref: R,
|
|
886
886
|
"data-viewport": "",
|
|
887
887
|
className: Z.viewport,
|
|
@@ -892,34 +892,34 @@ function fe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
892
892
|
})]
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
|
-
var
|
|
895
|
+
var me = { panel: "_panel_l0cix_2" };
|
|
896
896
|
//#endregion
|
|
897
897
|
//#region src/flows/flow-panel/flow-panel.tsx
|
|
898
|
-
function
|
|
899
|
-
return /* @__PURE__ */
|
|
898
|
+
function he({ position: t = "top-right", children: n, className: r, ...i }) {
|
|
899
|
+
return /* @__PURE__ */ f("div", {
|
|
900
900
|
"data-position": t,
|
|
901
|
-
className: e(
|
|
901
|
+
className: e(me.panel, r),
|
|
902
902
|
...i,
|
|
903
903
|
children: n
|
|
904
904
|
});
|
|
905
905
|
}
|
|
906
|
-
var
|
|
907
|
-
function
|
|
908
|
-
|
|
909
|
-
let D =
|
|
910
|
-
defaultNodes: g ?
|
|
906
|
+
var ge = { flow: "_flow_vejge_2" }, _e = 0;
|
|
907
|
+
function ve({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect: a, nodeTypes: s, fitView: l = !0, background: u = !1, controls: m = !1, minimap: h = !1, layout: g, minZoom: _, maxZoom: y, interactive: x = !0, activeEdgeId: S, activeDirection: C, className: T, style: E }) {
|
|
908
|
+
c();
|
|
909
|
+
let D = v({
|
|
910
|
+
defaultNodes: g ? z(t, n, g) : t,
|
|
911
911
|
defaultEdges: n,
|
|
912
912
|
onNodesChange: r,
|
|
913
913
|
onEdgesChange: i
|
|
914
914
|
}), O = U(D, {
|
|
915
|
-
minZoom:
|
|
916
|
-
maxZoom:
|
|
915
|
+
minZoom: _,
|
|
916
|
+
maxZoom: y,
|
|
917
917
|
fitOnInit: l
|
|
918
918
|
}), { connection: k } = W({
|
|
919
919
|
containerRef: O.containerRef,
|
|
920
920
|
clientToFlow: (e, t) => {
|
|
921
921
|
let n = O.containerRef.current?.getBoundingClientRect();
|
|
922
|
-
return
|
|
922
|
+
return b({
|
|
923
923
|
x: e - (n?.left ?? 0),
|
|
924
924
|
y: t - (n?.top ?? 0)
|
|
925
925
|
}, D.viewport.peek());
|
|
@@ -927,17 +927,17 @@ function _e({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
927
927
|
enabled: x,
|
|
928
928
|
onConnect: (e) => {
|
|
929
929
|
D.addEdge({
|
|
930
|
-
id: `e-${++
|
|
930
|
+
id: `e-${++_e}`,
|
|
931
931
|
source: e.source,
|
|
932
932
|
target: e.target
|
|
933
|
-
}),
|
|
933
|
+
}), a?.(e);
|
|
934
934
|
}
|
|
935
935
|
}), A = (e) => {
|
|
936
936
|
D.setNodes(D.nodes.value.map((t) => ({
|
|
937
937
|
...t,
|
|
938
938
|
selected: t.id === e
|
|
939
939
|
})));
|
|
940
|
-
}, j =
|
|
940
|
+
}, j = o({}), M = (e, t) => {
|
|
941
941
|
let n = j.peek()[e];
|
|
942
942
|
n && n.width === t.width && n.height === t.height || (j.value = {
|
|
943
943
|
...j.peek(),
|
|
@@ -950,32 +950,32 @@ function _e({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
950
950
|
width: t.width,
|
|
951
951
|
height: t.height
|
|
952
952
|
} : e];
|
|
953
|
-
})),
|
|
954
|
-
return /* @__PURE__ */
|
|
953
|
+
})), R = k.value;
|
|
954
|
+
return /* @__PURE__ */ p(ae, {
|
|
955
955
|
flow: D,
|
|
956
956
|
controller: O,
|
|
957
|
-
minZoom:
|
|
958
|
-
maxZoom:
|
|
959
|
-
chrome: /* @__PURE__ */
|
|
957
|
+
minZoom: _,
|
|
958
|
+
maxZoom: y,
|
|
959
|
+
chrome: /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(fe, {
|
|
960
960
|
onZoomIn: O.zoomIn,
|
|
961
961
|
onZoomOut: O.zoomOut,
|
|
962
962
|
onFitView: () => O.fitView()
|
|
963
|
-
}), h && /* @__PURE__ */
|
|
963
|
+
}), h && /* @__PURE__ */ f(pe, {
|
|
964
964
|
nodes: N,
|
|
965
965
|
viewport: D.viewport.value,
|
|
966
966
|
containerWidth: O.containerRef.current?.clientWidth,
|
|
967
967
|
containerHeight: O.containerRef.current?.clientHeight,
|
|
968
968
|
onViewportChange: D.setViewport
|
|
969
969
|
})] }),
|
|
970
|
-
className: e(
|
|
970
|
+
className: e(ge.flow, T),
|
|
971
971
|
style: E,
|
|
972
972
|
children: [
|
|
973
|
-
|
|
973
|
+
u && /* @__PURE__ */ f(se, { ...typeof u == "object" ? u : {} }),
|
|
974
974
|
P.map((e) => {
|
|
975
975
|
let t = L.get(e.source), n = L.get(e.target);
|
|
976
976
|
if (!t || !n) return null;
|
|
977
|
-
let r =
|
|
978
|
-
return /* @__PURE__ */
|
|
977
|
+
let r = w(t, "right"), i = w(n, "left"), a = S === e.id, o = a ? C : void 0, s = o === "reverse" ? !0 : o === "forward" ? !1 : e.markerStart ?? !1, c = o === "reverse" ? !1 : o === "forward" ? !0 : e.markerEnd ?? !0;
|
|
978
|
+
return /* @__PURE__ */ f(J, {
|
|
979
979
|
id: e.id,
|
|
980
980
|
sourceX: r.x,
|
|
981
981
|
sourceY: r.y,
|
|
@@ -991,14 +991,14 @@ function _e({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
991
991
|
selected: e.selected
|
|
992
992
|
}, e.id);
|
|
993
993
|
}),
|
|
994
|
-
|
|
995
|
-
sourceX:
|
|
996
|
-
sourceY:
|
|
997
|
-
targetX:
|
|
998
|
-
targetY:
|
|
994
|
+
R && /* @__PURE__ */ f(J, {
|
|
995
|
+
sourceX: R.from.x,
|
|
996
|
+
sourceY: R.from.y,
|
|
997
|
+
targetX: R.to.x,
|
|
998
|
+
targetY: R.to.y,
|
|
999
999
|
markerEnd: !1
|
|
1000
1000
|
}),
|
|
1001
|
-
N.map((e) => /* @__PURE__ */
|
|
1001
|
+
N.map((e) => /* @__PURE__ */ f(le, {
|
|
1002
1002
|
id: e.id,
|
|
1003
1003
|
position: e.position,
|
|
1004
1004
|
zoom: F,
|
|
@@ -1007,13 +1007,13 @@ function _e({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
1007
1007
|
onSelect: x ? A : void 0,
|
|
1008
1008
|
onMeasure: (t) => M(e.id, t),
|
|
1009
1009
|
onPositionChange: (t) => D.updateNode(e.id, { position: t }),
|
|
1010
|
-
children:
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
x && /* @__PURE__ */
|
|
1010
|
+
children: s && e.type && s[e.type] ? s[e.type]({ node: e }) : /* @__PURE__ */ p(d, { children: [
|
|
1011
|
+
/* @__PURE__ */ f("span", { children: String(e.data?.label ?? e.id) }),
|
|
1012
|
+
x && /* @__PURE__ */ f(K, {
|
|
1013
1013
|
type: "target",
|
|
1014
1014
|
position: "left"
|
|
1015
1015
|
}),
|
|
1016
|
-
x && /* @__PURE__ */
|
|
1016
|
+
x && /* @__PURE__ */ f(K, {
|
|
1017
1017
|
type: "source",
|
|
1018
1018
|
position: "right"
|
|
1019
1019
|
})
|
|
@@ -1038,53 +1038,53 @@ var Q = {
|
|
|
1038
1038
|
fill: "currentColor",
|
|
1039
1039
|
"aria-hidden": !0
|
|
1040
1040
|
};
|
|
1041
|
-
function
|
|
1042
|
-
|
|
1043
|
-
let C = V(r, n), w =
|
|
1041
|
+
function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 1500, stepGap: o = 0, playing: s, currentStep: l, onStepChange: u, controls: d = !0, autoPlay: g = !0, background: _ = !0, interactive: v = !1, labels: y, clock: b, className: x, style: S }) {
|
|
1042
|
+
c();
|
|
1043
|
+
let C = V(r, n), w = ie({
|
|
1044
1044
|
steps: C,
|
|
1045
1045
|
loop: i,
|
|
1046
1046
|
stepDuration: a,
|
|
1047
1047
|
stepGap: o,
|
|
1048
|
-
playing:
|
|
1048
|
+
playing: s,
|
|
1049
1049
|
defaultPlaying: g,
|
|
1050
1050
|
currentStep: l,
|
|
1051
1051
|
defaultCurrentStep: 0,
|
|
1052
1052
|
onStepChange: u,
|
|
1053
1053
|
clock: b
|
|
1054
1054
|
}), T = w.activeStep.value, E = w.currentStep.value, D = w.playing.value;
|
|
1055
|
-
return /* @__PURE__ */
|
|
1055
|
+
return /* @__PURE__ */ p("div", {
|
|
1056
1056
|
className: e(Q.story, x),
|
|
1057
1057
|
style: S,
|
|
1058
|
-
children: [/* @__PURE__ */
|
|
1058
|
+
children: [/* @__PURE__ */ f(ve, {
|
|
1059
1059
|
nodes: t,
|
|
1060
1060
|
edges: n,
|
|
1061
1061
|
background: _,
|
|
1062
1062
|
interactive: v,
|
|
1063
1063
|
activeEdgeId: T?.edgeId,
|
|
1064
1064
|
activeDirection: T?.direction
|
|
1065
|
-
}), /* @__PURE__ */
|
|
1065
|
+
}), /* @__PURE__ */ p("div", {
|
|
1066
1066
|
className: Q.overlay,
|
|
1067
|
-
children: [/* @__PURE__ */
|
|
1067
|
+
children: [/* @__PURE__ */ f("div", {
|
|
1068
1068
|
className: Q.caption,
|
|
1069
1069
|
"aria-live": "polite",
|
|
1070
|
-
children: T?.label && /* @__PURE__ */
|
|
1070
|
+
children: T?.label && /* @__PURE__ */ p("span", {
|
|
1071
1071
|
className: Q.captionText,
|
|
1072
|
-
children: [/* @__PURE__ */
|
|
1072
|
+
children: [/* @__PURE__ */ f("strong", { children: T.label }), T.description && /* @__PURE__ */ p("span", {
|
|
1073
1073
|
className: Q.captionDesc,
|
|
1074
1074
|
children: [" — ", T.description]
|
|
1075
1075
|
})]
|
|
1076
1076
|
}, E)
|
|
1077
|
-
}),
|
|
1077
|
+
}), d && /* @__PURE__ */ p("div", {
|
|
1078
1078
|
className: Q.controls,
|
|
1079
1079
|
children: [
|
|
1080
|
-
/* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ f("button", {
|
|
1081
1081
|
type: "button",
|
|
1082
1082
|
className: Q.button,
|
|
1083
|
-
"aria-label": y?.previous ?? m
|
|
1083
|
+
"aria-label": y?.previous ?? h(m.flow.previous),
|
|
1084
1084
|
onClick: w.prev,
|
|
1085
|
-
children: /* @__PURE__ */
|
|
1085
|
+
children: /* @__PURE__ */ f("svg", {
|
|
1086
1086
|
...$,
|
|
1087
|
-
children: /* @__PURE__ */
|
|
1087
|
+
children: /* @__PURE__ */ f("path", {
|
|
1088
1088
|
d: "M15 6 9 12l6 6",
|
|
1089
1089
|
stroke: "currentColor",
|
|
1090
1090
|
strokeWidth: "2",
|
|
@@ -1092,28 +1092,28 @@ function ve({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1092
1092
|
})
|
|
1093
1093
|
})
|
|
1094
1094
|
}),
|
|
1095
|
-
/* @__PURE__ */
|
|
1095
|
+
/* @__PURE__ */ f("button", {
|
|
1096
1096
|
type: "button",
|
|
1097
1097
|
className: Q.button,
|
|
1098
|
-
"aria-label": D ? y?.pause ?? m
|
|
1098
|
+
"aria-label": D ? y?.pause ?? h(m.flow.pause) : y?.play ?? h(m.flow.play),
|
|
1099
1099
|
"aria-pressed": D,
|
|
1100
1100
|
onClick: w.toggle,
|
|
1101
|
-
children: D ? /* @__PURE__ */
|
|
1101
|
+
children: D ? /* @__PURE__ */ f("svg", {
|
|
1102
1102
|
...$,
|
|
1103
|
-
children: /* @__PURE__ */
|
|
1104
|
-
}) : /* @__PURE__ */
|
|
1103
|
+
children: /* @__PURE__ */ f("path", { d: "M7 5h3v14H7zM14 5h3v14h-3z" })
|
|
1104
|
+
}) : /* @__PURE__ */ f("svg", {
|
|
1105
1105
|
...$,
|
|
1106
|
-
children: /* @__PURE__ */
|
|
1106
|
+
children: /* @__PURE__ */ f("path", { d: "M7 5l11 7-11 7z" })
|
|
1107
1107
|
})
|
|
1108
1108
|
}),
|
|
1109
|
-
/* @__PURE__ */
|
|
1109
|
+
/* @__PURE__ */ f("button", {
|
|
1110
1110
|
type: "button",
|
|
1111
1111
|
className: Q.button,
|
|
1112
|
-
"aria-label": y?.next ?? m
|
|
1112
|
+
"aria-label": y?.next ?? h(m.flow.next),
|
|
1113
1113
|
onClick: w.next,
|
|
1114
|
-
children: /* @__PURE__ */
|
|
1114
|
+
children: /* @__PURE__ */ f("svg", {
|
|
1115
1115
|
...$,
|
|
1116
|
-
children: /* @__PURE__ */
|
|
1116
|
+
children: /* @__PURE__ */ f("path", {
|
|
1117
1117
|
d: "M9 6l6 6-6 6",
|
|
1118
1118
|
stroke: "currentColor",
|
|
1119
1119
|
strokeWidth: "2",
|
|
@@ -1121,9 +1121,9 @@ function ve({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1121
1121
|
})
|
|
1122
1122
|
})
|
|
1123
1123
|
}),
|
|
1124
|
-
/* @__PURE__ */
|
|
1124
|
+
/* @__PURE__ */ f("span", {
|
|
1125
1125
|
className: Q.indicator,
|
|
1126
|
-
children: m
|
|
1126
|
+
children: h(m.flow.step, {
|
|
1127
1127
|
current: E + 1,
|
|
1128
1128
|
total: C.length
|
|
1129
1129
|
})
|
|
@@ -1134,4 +1134,4 @@ function ve({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1134
1134
|
});
|
|
1135
1135
|
}
|
|
1136
1136
|
//#endregion
|
|
1137
|
-
export {
|
|
1137
|
+
export { g as DEFAULT_NODE_SIZE, ve as Flow, se as FlowBackground, ae as FlowCanvas, fe as FlowControls, J as FlowEdge, K as FlowHandle, pe as FlowMiniMap, le as FlowNode, he as FlowPanel, ye as FlowStory, z as applyLayout, j as bezierPath, y as clampZoom, I as edgePath, E as fitViewport, x as flowToScreen, T as graphBounds, L as gridLayout, w as handleAnchor, R as layeredLayout, C as nodeBounds, S as nodeSize, V as resolveScript, ee as resolveStep, b as screenToFlow, F as smoothStepPath, A as straightPath, W as useConnection, v as useFlow, ie as useStory, U as useViewport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cascivo/flow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Flow & diagram components — CSS-native, signal-driven node/edge graphs with pan/zoom, draggable nodes, animated edges, and scripted storylines, zero dependencies",
|
|
6
6
|
"keywords": [
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"provenance": true
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@cascivo/core": "^0.
|
|
50
|
-
"@cascivo/i18n": "^0.2.
|
|
49
|
+
"@cascivo/core": "^0.6.0",
|
|
50
|
+
"@cascivo/i18n": "^0.2.12"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/jest-dom": "^6.9.1",
|