@cascivo/flow 0.1.19 → 0.16.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/dist/flow.css +1 -1
- package/dist/index.js +156 -155
- package/dist/node/index.js +156 -155
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,17 +3,18 @@ import './flow.css';
|
|
|
3
3
|
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";
|
|
4
4
|
import { useId as l, useRef as u } from "react";
|
|
5
5
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
6
|
+
import { cn as m } from "@cascivo/core/pure";
|
|
7
|
+
import { builtin as h, t as g } from "@cascivo/i18n";
|
|
7
8
|
//#region src/engine/types.ts
|
|
8
|
-
var
|
|
9
|
+
var _ = {
|
|
9
10
|
width: 150,
|
|
10
11
|
height: 40
|
|
11
|
-
},
|
|
12
|
+
}, v = {
|
|
12
13
|
x: 0,
|
|
13
14
|
y: 0,
|
|
14
15
|
zoom: 1
|
|
15
16
|
};
|
|
16
|
-
function
|
|
17
|
+
function y(e = {}) {
|
|
17
18
|
let [t, r] = n({
|
|
18
19
|
value: e.nodes,
|
|
19
20
|
defaultValue: e.defaultNodes ?? [],
|
|
@@ -24,7 +25,7 @@ function v(e = {}) {
|
|
|
24
25
|
onChange: e.onEdgesChange
|
|
25
26
|
}), [o, s] = n({
|
|
26
27
|
value: e.viewport,
|
|
27
|
-
defaultValue: e.defaultViewport ??
|
|
28
|
+
defaultValue: e.defaultViewport ?? v,
|
|
28
29
|
onChange: e.onViewportChange
|
|
29
30
|
});
|
|
30
31
|
return {
|
|
@@ -47,16 +48,16 @@ function v(e = {}) {
|
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/engine/transform.ts
|
|
50
|
-
function
|
|
51
|
+
function b(e, t = .2, n = 2) {
|
|
51
52
|
return Math.min(n, Math.max(t, e));
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function x(e, t) {
|
|
54
55
|
return {
|
|
55
56
|
x: (e.x - t.x) / t.zoom,
|
|
56
57
|
y: (e.y - t.y) / t.zoom
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function S(e, t) {
|
|
60
61
|
return {
|
|
61
62
|
x: e.x * t.zoom + t.x,
|
|
62
63
|
y: e.y * t.zoom + t.y
|
|
@@ -64,14 +65,14 @@ function x(e, t) {
|
|
|
64
65
|
}
|
|
65
66
|
//#endregion
|
|
66
67
|
//#region src/engine/geometry.ts
|
|
67
|
-
function
|
|
68
|
+
function C(e) {
|
|
68
69
|
return {
|
|
69
|
-
width: e.width ??
|
|
70
|
-
height: e.height ??
|
|
70
|
+
width: e.width ?? _.width,
|
|
71
|
+
height: e.height ?? _.height
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
let { width: t, height: n } =
|
|
74
|
+
function w(e) {
|
|
75
|
+
let { width: t, height: n } = C(e);
|
|
75
76
|
return {
|
|
76
77
|
x: e.position.x,
|
|
77
78
|
y: e.position.y,
|
|
@@ -79,8 +80,8 @@ function C(e) {
|
|
|
79
80
|
height: n
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
let { x: n, y: r, width: i, height: a } =
|
|
83
|
+
function T(e, t) {
|
|
84
|
+
let { x: n, y: r, width: i, height: a } = w(e);
|
|
84
85
|
switch (t) {
|
|
85
86
|
case "top": return {
|
|
86
87
|
x: n + i / 2,
|
|
@@ -100,11 +101,11 @@ function w(e, t) {
|
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
+
function E(e) {
|
|
104
105
|
if (e.length === 0) return null;
|
|
105
106
|
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
|
|
106
107
|
for (let a of e) {
|
|
107
|
-
let e =
|
|
108
|
+
let e = w(a);
|
|
108
109
|
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);
|
|
109
110
|
}
|
|
110
111
|
return {
|
|
@@ -114,14 +115,14 @@ function T(e) {
|
|
|
114
115
|
height: i - n
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
+
function D(e, t, n = {}) {
|
|
118
119
|
let { padding: r = .1, minZoom: i = .2, maxZoom: a = 2 } = n;
|
|
119
120
|
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0) return {
|
|
120
121
|
x: t.width / 2 - e.x,
|
|
121
122
|
y: t.height / 2 - e.y,
|
|
122
123
|
zoom: 1
|
|
123
124
|
};
|
|
124
|
-
let o = t.width / (e.width * (1 + r * 2)), s = t.height / (e.height * (1 + r * 2)), c =
|
|
125
|
+
let o = t.width / (e.width * (1 + r * 2)), s = t.height / (e.height * (1 + r * 2)), c = b(Math.min(o, s), i, a);
|
|
125
126
|
return {
|
|
126
127
|
x: t.width / 2 - (e.x + e.width / 2) * c,
|
|
127
128
|
y: t.height / 2 - (e.y + e.height / 2) * c,
|
|
@@ -130,11 +131,11 @@ function E(e, t, n = {}) {
|
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
132
133
|
//#region src/engine/path.ts
|
|
133
|
-
var
|
|
134
|
+
var O = (e) => Number.isInteger(e) ? String(e) : e.toFixed(2).replace(/\.?0+$/, ""), k = (e, t) => ({
|
|
134
135
|
x: (e.x + t.x) / 2,
|
|
135
136
|
y: (e.y + t.y) / 2
|
|
136
137
|
});
|
|
137
|
-
function
|
|
138
|
+
function A(e) {
|
|
138
139
|
switch (e) {
|
|
139
140
|
case "top": return {
|
|
140
141
|
x: 0,
|
|
@@ -154,14 +155,14 @@ function k(e) {
|
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function j({ source: e, target: t }) {
|
|
158
159
|
return {
|
|
159
|
-
d: `M${
|
|
160
|
-
mid:
|
|
160
|
+
d: `M${O(e.x)},${O(e.y)} L${O(t.x)},${O(t.y)}`,
|
|
161
|
+
mid: k(e, t)
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
-
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 =
|
|
164
|
+
function M(e) {
|
|
165
|
+
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 = A(i), l = A(a), u = {
|
|
165
166
|
x: t.x + c.x * s,
|
|
166
167
|
y: t.y + c.y * s
|
|
167
168
|
}, d = {
|
|
@@ -172,31 +173,31 @@ function j(e) {
|
|
|
172
173
|
y: (t.y + 3 * u.y + 3 * d.y + n.y) / 8
|
|
173
174
|
};
|
|
174
175
|
return {
|
|
175
|
-
d: `M${
|
|
176
|
+
d: `M${O(t.x)},${O(t.y)} C${O(u.x)},${O(u.y)} ${O(d.x)},${O(d.y)} ${O(n.x)},${O(n.y)}`,
|
|
176
177
|
mid: f
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function N(e, t) {
|
|
180
181
|
return Math.hypot(t.x - e.x, t.y - e.y);
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
let r =
|
|
183
|
+
function P(e, t, n) {
|
|
184
|
+
let r = N(e, t) || 1;
|
|
184
185
|
return {
|
|
185
186
|
x: e.x + (t.x - e.x) / r * n,
|
|
186
187
|
y: e.y + (t.y - e.y) / r * n
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
|
-
function
|
|
190
|
+
function F(e, t) {
|
|
190
191
|
if (e.length < 2) return "";
|
|
191
|
-
let n = e[0], r = `M${
|
|
192
|
+
let n = e[0], r = `M${O(n.x)},${O(n.y)}`;
|
|
192
193
|
for (let n = 1; n < e.length - 1; n++) {
|
|
193
|
-
let i = e[n - 1], a = e[n], o = e[n + 1], s = Math.min(t,
|
|
194
|
-
r += ` L${
|
|
194
|
+
let i = e[n - 1], a = e[n], o = e[n + 1], s = Math.min(t, N(i, a) / 2, N(a, o) / 2), c = P(a, i, s), l = P(a, o, s);
|
|
195
|
+
r += ` L${O(c.x)},${O(c.y)} Q${O(a.x)},${O(a.y)} ${O(l.x)},${O(l.y)}`;
|
|
195
196
|
}
|
|
196
197
|
let i = e[e.length - 1];
|
|
197
|
-
return r += ` L${
|
|
198
|
+
return r += ` L${O(i.x)},${O(i.y)}`, r;
|
|
198
199
|
}
|
|
199
|
-
function
|
|
200
|
+
function I(e) {
|
|
200
201
|
let { source: t, target: n, borderRadius: r = 8 } = e, i = e.sourcePosition ?? "right", a = i === "left" || i === "right", o = [t];
|
|
201
202
|
if (a) {
|
|
202
203
|
let e = (t.x + n.x) / 2;
|
|
@@ -218,21 +219,21 @@ function F(e) {
|
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
return o.push(n), {
|
|
221
|
-
d:
|
|
222
|
-
mid:
|
|
222
|
+
d: F(o, r),
|
|
223
|
+
mid: k(t, n)
|
|
223
224
|
};
|
|
224
225
|
}
|
|
225
|
-
function
|
|
226
|
+
function L(e, t) {
|
|
226
227
|
switch (e) {
|
|
227
|
-
case "straight": return
|
|
228
|
-
case "smoothstep": return
|
|
229
|
-
case "bezier": return
|
|
228
|
+
case "straight": return j(t);
|
|
229
|
+
case "smoothstep": return I(t);
|
|
230
|
+
case "bezier": return M(t);
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
//#endregion
|
|
233
234
|
//#region src/engine/layout.ts
|
|
234
|
-
function
|
|
235
|
-
let n = t.gap ?? 40, r = t.nodeWidth ??
|
|
235
|
+
function R(e, t = {}) {
|
|
236
|
+
let n = t.gap ?? 40, r = t.nodeWidth ?? _.width, i = t.nodeHeight ?? _.height, a = t.columns ?? Math.max(1, Math.ceil(Math.sqrt(e.length)));
|
|
236
237
|
return e.map((e, t) => {
|
|
237
238
|
let o = t % a, s = Math.floor(t / a);
|
|
238
239
|
return {
|
|
@@ -244,8 +245,8 @@ function L(e, t = {}) {
|
|
|
244
245
|
};
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
-
let r = n.direction ?? "LR", i = n.gap ?? 60, a = n.nodeWidth ??
|
|
248
|
+
function z(e, t, n = {}) {
|
|
249
|
+
let r = n.direction ?? "LR", i = n.gap ?? 60, a = n.nodeWidth ?? _.width, o = n.nodeHeight ?? _.height, s = new Set(e.map((e) => e.id)), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
249
250
|
for (let t of e) l.set(t.id, 0);
|
|
250
251
|
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));
|
|
251
252
|
let u = /* @__PURE__ */ new Map(), d = e.filter((e) => (l.get(e.id) ?? 0) === 0).map((e) => e.id);
|
|
@@ -279,21 +280,21 @@ function R(e, t, n = {}) {
|
|
|
279
280
|
};
|
|
280
281
|
});
|
|
281
282
|
}
|
|
282
|
-
function
|
|
283
|
-
return n === "grid" ?
|
|
283
|
+
function B(e, t, n) {
|
|
284
|
+
return n === "grid" ? R(e) : n === "layered" ? z(e, t) : n(e, t);
|
|
284
285
|
}
|
|
285
286
|
//#endregion
|
|
286
287
|
//#region src/engine/script.ts
|
|
287
|
-
function
|
|
288
|
+
function ee(e) {
|
|
288
289
|
return "edge" in e;
|
|
289
290
|
}
|
|
290
|
-
function
|
|
291
|
+
function te(e, t) {
|
|
291
292
|
let n = {
|
|
292
293
|
label: e.label,
|
|
293
294
|
description: e.description,
|
|
294
295
|
duration: e.duration
|
|
295
296
|
};
|
|
296
|
-
if (
|
|
297
|
+
if (ee(e)) {
|
|
297
298
|
let r = t.find((t) => t.id === e.edge);
|
|
298
299
|
if (!r) throw Error(`FlowStory: step references unknown edge "${e.edge}"`);
|
|
299
300
|
return {
|
|
@@ -317,13 +318,13 @@ function ee(e, t) {
|
|
|
317
318
|
throw Error(`FlowStory: no edge connects "${e.from}" and "${e.to}"`);
|
|
318
319
|
}
|
|
319
320
|
function V(e, t) {
|
|
320
|
-
return e.map((e) =>
|
|
321
|
+
return e.map((e) => te(e, t));
|
|
321
322
|
}
|
|
322
323
|
//#endregion
|
|
323
324
|
//#region src/core/use-viewport.ts
|
|
324
325
|
var H = 1.2;
|
|
325
326
|
function U(e, t = {}) {
|
|
326
|
-
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 }),
|
|
327
|
+
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 }), y = (e, t) => {
|
|
327
328
|
let n = f.peek();
|
|
328
329
|
p({
|
|
329
330
|
x: n.x + e,
|
|
@@ -331,7 +332,7 @@ function U(e, t = {}) {
|
|
|
331
332
|
zoom: n.zoom
|
|
332
333
|
});
|
|
333
334
|
}, S = (e, t) => {
|
|
334
|
-
let r = f.peek(), a =
|
|
335
|
+
let r = f.peek(), a = b(e, n, i);
|
|
335
336
|
if (!t) {
|
|
336
337
|
p({
|
|
337
338
|
x: r.x,
|
|
@@ -340,7 +341,7 @@ function U(e, t = {}) {
|
|
|
340
341
|
});
|
|
341
342
|
return;
|
|
342
343
|
}
|
|
343
|
-
let o =
|
|
344
|
+
let o = x(t, r);
|
|
344
345
|
p({
|
|
345
346
|
x: t.x - o.x * a,
|
|
346
347
|
y: t.y - o.y * a,
|
|
@@ -352,7 +353,7 @@ function U(e, t = {}) {
|
|
|
352
353
|
x: e.clientWidth / 2,
|
|
353
354
|
y: e.clientHeight / 2
|
|
354
355
|
};
|
|
355
|
-
}, w = () => S(f.peek().zoom * H, C()),
|
|
356
|
+
}, w = () => S(f.peek().zoom * H, C()), T = () => S(f.peek().zoom / H, C()), O = () => {
|
|
356
357
|
let e = h.peek();
|
|
357
358
|
if (e && e.width > 0 && e.height > 0) return e;
|
|
358
359
|
let t = m.current;
|
|
@@ -361,10 +362,10 @@ function U(e, t = {}) {
|
|
|
361
362
|
height: t.clientHeight
|
|
362
363
|
} : null;
|
|
363
364
|
}, k = (t) => {
|
|
364
|
-
let r =
|
|
365
|
+
let r = E(e.nodes.peek());
|
|
365
366
|
if (!r) return;
|
|
366
367
|
let a = t ?? O();
|
|
367
|
-
a && p(
|
|
368
|
+
a && p(D(r, a, {
|
|
368
369
|
padding: l,
|
|
369
370
|
minZoom: n,
|
|
370
371
|
maxZoom: i
|
|
@@ -410,16 +411,16 @@ function U(e, t = {}) {
|
|
|
410
411
|
containerRef: m,
|
|
411
412
|
panHandleRef: g,
|
|
412
413
|
viewport: f,
|
|
413
|
-
pan:
|
|
414
|
+
pan: y,
|
|
414
415
|
zoomTo: S,
|
|
415
416
|
zoomIn: w,
|
|
416
|
-
zoomOut:
|
|
417
|
+
zoomOut: T,
|
|
417
418
|
fitView: k
|
|
418
419
|
};
|
|
419
420
|
}
|
|
420
421
|
//#endregion
|
|
421
422
|
//#region src/core/use-connection.ts
|
|
422
|
-
var
|
|
423
|
+
var ne = "[data-flow-handle][data-handle-type=\"source\"]", re = "[data-flow-handle][data-handle-type=\"target\"]";
|
|
423
424
|
function W(e) {
|
|
424
425
|
let { containerRef: t } = e, n = o(null), r = u(e.onConnect);
|
|
425
426
|
r.current = e.onConnect;
|
|
@@ -441,7 +442,7 @@ function W(e) {
|
|
|
441
442
|
}, o = (e) => {
|
|
442
443
|
let t = n.peek();
|
|
443
444
|
if (window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), n.value = null, !t) return;
|
|
444
|
-
let s = e.target, c = s instanceof Element ? s.closest(
|
|
445
|
+
let s = e.target, c = s instanceof Element ? s.closest(re) : null, l = c?.closest("[data-node-id]");
|
|
445
446
|
if (!l) return;
|
|
446
447
|
let u = {
|
|
447
448
|
source: t.source,
|
|
@@ -453,7 +454,7 @@ function W(e) {
|
|
|
453
454
|
}, s = (e) => {
|
|
454
455
|
let t = e.target;
|
|
455
456
|
if (!(t instanceof Element)) return;
|
|
456
|
-
let r = t.closest(
|
|
457
|
+
let r = t.closest(ne);
|
|
457
458
|
if (!r) return;
|
|
458
459
|
let a = r.closest("[data-node-id]");
|
|
459
460
|
if (!a) return;
|
|
@@ -473,9 +474,9 @@ function W(e) {
|
|
|
473
474
|
}
|
|
474
475
|
//#endregion
|
|
475
476
|
//#region src/core/use-story.ts
|
|
476
|
-
var
|
|
477
|
-
function
|
|
478
|
-
let { steps: r, loop: i = !0, stepDuration: a =
|
|
477
|
+
var ie = 1500;
|
|
478
|
+
function ae(e) {
|
|
479
|
+
let { steps: r, loop: i = !0, stepDuration: a = ie, stepGap: o = 0 } = e, [c, l] = n({
|
|
479
480
|
value: e.currentStep,
|
|
480
481
|
defaultValue: e.defaultCurrentStep ?? 0,
|
|
481
482
|
onChange: e.onStepChange
|
|
@@ -526,9 +527,9 @@ var G = {
|
|
|
526
527
|
};
|
|
527
528
|
//#endregion
|
|
528
529
|
//#region src/core/flow-canvas/flow-canvas.tsx
|
|
529
|
-
function
|
|
530
|
+
function oe({ 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", ...v }) {
|
|
530
531
|
c();
|
|
531
|
-
let b =
|
|
532
|
+
let b = y({
|
|
532
533
|
viewport: r,
|
|
533
534
|
defaultViewport: i,
|
|
534
535
|
onViewportChange: a
|
|
@@ -543,7 +544,7 @@ function ae({ children: t, flow: n, viewport: r, defaultViewport: i, onViewportC
|
|
|
543
544
|
ref: C.containerRef,
|
|
544
545
|
className: e(G.canvas, g),
|
|
545
546
|
role: _,
|
|
546
|
-
...
|
|
547
|
+
...v,
|
|
547
548
|
children: [/* @__PURE__ */ p("div", {
|
|
548
549
|
className: G.pane,
|
|
549
550
|
style: {
|
|
@@ -559,28 +560,28 @@ function ae({ children: t, flow: n, viewport: r, defaultViewport: i, onViewportC
|
|
|
559
560
|
}), h]
|
|
560
561
|
});
|
|
561
562
|
}
|
|
562
|
-
var
|
|
563
|
+
var se = { background: "_background_1pu9x_2" };
|
|
563
564
|
//#endregion
|
|
564
565
|
//#region src/flows/flow-background/flow-background.tsx
|
|
565
|
-
function
|
|
566
|
+
function ce({ variant: e = "dots", gap: t = 20, size: n = 1, color: r, className: i, style: a, ...o }) {
|
|
566
567
|
return /* @__PURE__ */ f("div", {
|
|
567
|
-
"data-variant":
|
|
568
|
+
"data-variant": e,
|
|
568
569
|
"aria-hidden": "true",
|
|
569
|
-
className:
|
|
570
|
+
className: m(se.background, i),
|
|
570
571
|
style: {
|
|
571
|
-
"--flow-bg-gap": `${
|
|
572
|
-
"--flow-bg-size": `${
|
|
573
|
-
"--flow-bg-thick": `${Math.max(1,
|
|
574
|
-
...
|
|
575
|
-
...
|
|
572
|
+
"--flow-bg-gap": `${t}px`,
|
|
573
|
+
"--flow-bg-size": `${n}px`,
|
|
574
|
+
"--flow-bg-thick": `${Math.max(1, n)}px`,
|
|
575
|
+
...r ? { "--flow-bg-color": r } : {},
|
|
576
|
+
...a
|
|
576
577
|
},
|
|
577
|
-
...
|
|
578
|
+
...o
|
|
578
579
|
});
|
|
579
580
|
}
|
|
580
|
-
var
|
|
581
|
+
var le = { node: "_node_9zyg4_2" };
|
|
581
582
|
//#endregion
|
|
582
583
|
//#region src/flows/flow-node/flow-node.tsx
|
|
583
|
-
function
|
|
584
|
+
function ue({ 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 }) {
|
|
584
585
|
c();
|
|
585
586
|
let S = m && h, [C, w] = n({
|
|
586
587
|
value: i,
|
|
@@ -635,7 +636,7 @@ function le({ id: t, position: i, defaultPosition: a, onPositionChange: o, onMea
|
|
|
635
636
|
"data-static": !h || void 0,
|
|
636
637
|
role: "group",
|
|
637
638
|
tabIndex: h ? 0 : void 0,
|
|
638
|
-
className: e(
|
|
639
|
+
className: e(le.node, v),
|
|
639
640
|
style: {
|
|
640
641
|
"--flow-x": `${P.x}px`,
|
|
641
642
|
"--flow-y": `${P.y}px`
|
|
@@ -650,27 +651,27 @@ function le({ id: t, position: i, defaultPosition: a, onPositionChange: o, onMea
|
|
|
650
651
|
children: _
|
|
651
652
|
});
|
|
652
653
|
}
|
|
653
|
-
var
|
|
654
|
+
var de = {
|
|
654
655
|
handle: "_handle_8a1xa_2",
|
|
655
656
|
dot: "_dot_8a1xa_41"
|
|
656
657
|
};
|
|
657
658
|
//#endregion
|
|
658
659
|
//#region src/flows/flow-handle/flow-handle.tsx
|
|
659
|
-
function
|
|
660
|
+
function fe(e) {
|
|
660
661
|
return e === "source" ? "right" : "left";
|
|
661
662
|
}
|
|
662
|
-
function K({ type:
|
|
663
|
+
function K({ type: e, position: t, id: n, isConnectable: r = !0, className: i, ...a }) {
|
|
663
664
|
return /* @__PURE__ */ f("div", {
|
|
664
|
-
"data-handle-type":
|
|
665
|
-
"data-handle-pos":
|
|
666
|
-
"data-handle-id":
|
|
667
|
-
"data-connectable":
|
|
665
|
+
"data-handle-type": e,
|
|
666
|
+
"data-handle-pos": t ?? fe(e),
|
|
667
|
+
"data-handle-id": n,
|
|
668
|
+
"data-connectable": r || void 0,
|
|
668
669
|
"data-flow-handle": "",
|
|
669
|
-
tabIndex:
|
|
670
|
-
className:
|
|
671
|
-
...
|
|
670
|
+
tabIndex: r ? 0 : -1,
|
|
671
|
+
className: m(de.handle, i),
|
|
672
|
+
...a,
|
|
672
673
|
children: /* @__PURE__ */ f("span", {
|
|
673
|
-
className:
|
|
674
|
+
className: de.dot,
|
|
674
675
|
"aria-hidden": "true"
|
|
675
676
|
})
|
|
676
677
|
});
|
|
@@ -686,7 +687,7 @@ var q = {
|
|
|
686
687
|
//#endregion
|
|
687
688
|
//#region src/flows/flow-edge/flow-edge.tsx
|
|
688
689
|
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 }) {
|
|
689
|
-
let x = l(), S = `flow-arrow-${t ?? x}`, C = g || _, { d: w, mid: T } =
|
|
690
|
+
let x = l(), S = `flow-arrow-${t ?? x}`, C = g || _, { d: w, mid: T } = L(c, {
|
|
690
691
|
source: {
|
|
691
692
|
x: n,
|
|
692
693
|
y: r
|
|
@@ -741,8 +742,8 @@ function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePositi
|
|
|
741
742
|
})] });
|
|
742
743
|
}
|
|
743
744
|
var Y = {
|
|
744
|
-
controls: "
|
|
745
|
-
button: "
|
|
745
|
+
controls: "_controls_s32im_2",
|
|
746
|
+
button: "_button_s32im_32"
|
|
746
747
|
}, X = {
|
|
747
748
|
width: 18,
|
|
748
749
|
height: 18,
|
|
@@ -750,7 +751,7 @@ var Y = {
|
|
|
750
751
|
fill: "none",
|
|
751
752
|
"aria-hidden": !0
|
|
752
753
|
};
|
|
753
|
-
function
|
|
754
|
+
function pe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0, onZoomIn: i, onZoomOut: a, onFitView: o, labels: s, className: l, ...u }) {
|
|
754
755
|
return c(), /* @__PURE__ */ p("div", {
|
|
755
756
|
"data-position": t,
|
|
756
757
|
className: e(Y.controls, l),
|
|
@@ -758,7 +759,7 @@ function fe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0
|
|
|
758
759
|
children: [n && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
|
|
759
760
|
type: "button",
|
|
760
761
|
className: Y.button,
|
|
761
|
-
"aria-label": s?.zoomIn ?? h
|
|
762
|
+
"aria-label": s?.zoomIn ?? g(h.flow.zoomIn),
|
|
762
763
|
onClick: i,
|
|
763
764
|
children: /* @__PURE__ */ f("svg", {
|
|
764
765
|
...X,
|
|
@@ -772,7 +773,7 @@ function fe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0
|
|
|
772
773
|
}), /* @__PURE__ */ f("button", {
|
|
773
774
|
type: "button",
|
|
774
775
|
className: Y.button,
|
|
775
|
-
"aria-label": s?.zoomOut ?? h
|
|
776
|
+
"aria-label": s?.zoomOut ?? g(h.flow.zoomOut),
|
|
776
777
|
onClick: a,
|
|
777
778
|
children: /* @__PURE__ */ f("svg", {
|
|
778
779
|
...X,
|
|
@@ -786,7 +787,7 @@ function fe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0
|
|
|
786
787
|
})] }), r && /* @__PURE__ */ f("button", {
|
|
787
788
|
type: "button",
|
|
788
789
|
className: Y.button,
|
|
789
|
-
"aria-label": s?.fitView ?? h
|
|
790
|
+
"aria-label": s?.fitView ?? g(h.flow.fitView),
|
|
790
791
|
onClick: o,
|
|
791
792
|
children: /* @__PURE__ */ f("svg", {
|
|
792
793
|
...X,
|
|
@@ -808,27 +809,27 @@ var Z = {
|
|
|
808
809
|
};
|
|
809
810
|
//#endregion
|
|
810
811
|
//#region src/flows/flow-minimap/flow-minimap.tsx
|
|
811
|
-
function
|
|
812
|
+
function me({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, width: o = 200, height: l = 150, position: d = "bottom-right", nodeColor: m, onViewportChange: _, label: v, className: y }) {
|
|
812
813
|
c();
|
|
813
|
-
let
|
|
814
|
+
let b = E(t) ?? {
|
|
814
815
|
x: 0,
|
|
815
816
|
y: 0,
|
|
816
817
|
width: 1,
|
|
817
818
|
height: 1
|
|
818
|
-
}, S =
|
|
819
|
-
x:
|
|
820
|
-
y:
|
|
821
|
-
width: S +
|
|
822
|
-
height:
|
|
819
|
+
}, S = b.width || 1, C = b.height || 1, T = S * .1, D = C * .1, O = {
|
|
820
|
+
x: b.x - T,
|
|
821
|
+
y: b.y - D,
|
|
822
|
+
width: S + T * 2,
|
|
823
|
+
height: C + D * 2
|
|
823
824
|
}, 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) => ({
|
|
824
825
|
x: e.x * k + A,
|
|
825
826
|
y: e.y * k + j
|
|
826
827
|
}), N = null;
|
|
827
828
|
if (i && a) {
|
|
828
|
-
let e =
|
|
829
|
+
let e = x({
|
|
829
830
|
x: 0,
|
|
830
831
|
y: 0
|
|
831
|
-
}, n), t =
|
|
832
|
+
}, n), t = x({
|
|
832
833
|
x: i,
|
|
833
834
|
y: a
|
|
834
835
|
}, n), r = M(e);
|
|
@@ -867,9 +868,9 @@ function pe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
867
868
|
width: o,
|
|
868
869
|
height: l,
|
|
869
870
|
role: "img",
|
|
870
|
-
"aria-label": v ?? h
|
|
871
|
+
"aria-label": v ?? g(h.flow.minimap),
|
|
871
872
|
children: [t.map((e) => {
|
|
872
|
-
let t =
|
|
873
|
+
let t = w(e), n = M({
|
|
873
874
|
x: t.x,
|
|
874
875
|
y: t.y
|
|
875
876
|
});
|
|
@@ -880,7 +881,7 @@ function pe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
880
881
|
y: n.y,
|
|
881
882
|
width: t.width * k,
|
|
882
883
|
height: t.height * k,
|
|
883
|
-
fill:
|
|
884
|
+
fill: m
|
|
884
885
|
}, e.id);
|
|
885
886
|
}), N && /* @__PURE__ */ f("rect", {
|
|
886
887
|
ref: R,
|
|
@@ -893,42 +894,42 @@ function pe({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, widt
|
|
|
893
894
|
})]
|
|
894
895
|
});
|
|
895
896
|
}
|
|
896
|
-
var
|
|
897
|
+
var he = { panel: "_panel_l0cix_2" };
|
|
897
898
|
//#endregion
|
|
898
899
|
//#region src/flows/flow-panel/flow-panel.tsx
|
|
899
|
-
function
|
|
900
|
+
function ge({ position: e = "top-right", children: t, className: n, ...r }) {
|
|
900
901
|
return /* @__PURE__ */ f("div", {
|
|
901
|
-
"data-position":
|
|
902
|
-
className:
|
|
903
|
-
...
|
|
904
|
-
children:
|
|
902
|
+
"data-position": e,
|
|
903
|
+
className: m(he.panel, n),
|
|
904
|
+
...r,
|
|
905
|
+
children: t
|
|
905
906
|
});
|
|
906
907
|
}
|
|
907
|
-
var
|
|
908
|
-
function
|
|
908
|
+
var _e = { flow: "_flow_vejge_2" }, ve = 0;
|
|
909
|
+
function ye({ 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: v, interactive: b = !0, activeEdgeId: S, activeDirection: C, className: w, style: E }) {
|
|
909
910
|
c();
|
|
910
|
-
let D =
|
|
911
|
-
defaultNodes: g ?
|
|
911
|
+
let D = y({
|
|
912
|
+
defaultNodes: g ? B(t, n, g) : t,
|
|
912
913
|
defaultEdges: n,
|
|
913
914
|
onNodesChange: r,
|
|
914
915
|
onEdgesChange: i
|
|
915
916
|
}), O = U(D, {
|
|
916
917
|
minZoom: _,
|
|
917
|
-
maxZoom:
|
|
918
|
+
maxZoom: v,
|
|
918
919
|
fitOnInit: l
|
|
919
920
|
}), { connection: k } = W({
|
|
920
921
|
containerRef: O.containerRef,
|
|
921
922
|
clientToFlow: (e, t) => {
|
|
922
923
|
let n = O.containerRef.current?.getBoundingClientRect();
|
|
923
|
-
return
|
|
924
|
+
return x({
|
|
924
925
|
x: e - (n?.left ?? 0),
|
|
925
926
|
y: t - (n?.top ?? 0)
|
|
926
927
|
}, D.viewport.peek());
|
|
927
928
|
},
|
|
928
|
-
enabled:
|
|
929
|
+
enabled: b,
|
|
929
930
|
onConnect: (e) => {
|
|
930
931
|
D.addEdge({
|
|
931
|
-
id: `e-${++
|
|
932
|
+
id: `e-${++ve}`,
|
|
932
933
|
source: e.source,
|
|
933
934
|
target: e.target
|
|
934
935
|
}), a?.(e);
|
|
@@ -952,30 +953,30 @@ function ve({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
952
953
|
height: t.height
|
|
953
954
|
} : e];
|
|
954
955
|
})), R = k.value;
|
|
955
|
-
return /* @__PURE__ */ p(
|
|
956
|
+
return /* @__PURE__ */ p(oe, {
|
|
956
957
|
flow: D,
|
|
957
958
|
controller: O,
|
|
958
959
|
minZoom: _,
|
|
959
|
-
maxZoom:
|
|
960
|
-
chrome: /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(
|
|
960
|
+
maxZoom: v,
|
|
961
|
+
chrome: /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(pe, {
|
|
961
962
|
onZoomIn: O.zoomIn,
|
|
962
963
|
onZoomOut: O.zoomOut,
|
|
963
964
|
onFitView: () => O.fitView()
|
|
964
|
-
}), h && /* @__PURE__ */ f(
|
|
965
|
+
}), h && /* @__PURE__ */ f(me, {
|
|
965
966
|
nodes: N,
|
|
966
967
|
viewport: D.viewport.value,
|
|
967
968
|
containerWidth: O.containerRef.current?.clientWidth,
|
|
968
969
|
containerHeight: O.containerRef.current?.clientHeight,
|
|
969
970
|
onViewportChange: D.setViewport
|
|
970
971
|
})] }),
|
|
971
|
-
className: e(
|
|
972
|
+
className: e(_e.flow, w),
|
|
972
973
|
style: E,
|
|
973
974
|
children: [
|
|
974
|
-
u && /* @__PURE__ */ f(
|
|
975
|
+
u && /* @__PURE__ */ f(ce, { ...typeof u == "object" ? u : {} }),
|
|
975
976
|
P.map((e) => {
|
|
976
977
|
let t = L.get(e.source), n = L.get(e.target);
|
|
977
978
|
if (!t || !n) return null;
|
|
978
|
-
let r =
|
|
979
|
+
let r = T(t, "right"), i = T(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;
|
|
979
980
|
return /* @__PURE__ */ f(J, {
|
|
980
981
|
id: e.id,
|
|
981
982
|
sourceX: r.x,
|
|
@@ -999,22 +1000,22 @@ function ve({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
999
1000
|
targetY: R.to.y,
|
|
1000
1001
|
markerEnd: !1
|
|
1001
1002
|
}),
|
|
1002
|
-
N.map((e) => /* @__PURE__ */ f(
|
|
1003
|
+
N.map((e) => /* @__PURE__ */ f(ue, {
|
|
1003
1004
|
id: e.id,
|
|
1004
1005
|
position: e.position,
|
|
1005
1006
|
zoom: F,
|
|
1006
|
-
interactive:
|
|
1007
|
+
interactive: b,
|
|
1007
1008
|
selected: e.selected ?? !1,
|
|
1008
|
-
onSelect:
|
|
1009
|
+
onSelect: b ? A : void 0,
|
|
1009
1010
|
onMeasure: (t) => M(e.id, t),
|
|
1010
1011
|
onPositionChange: (t) => D.updateNode(e.id, { position: t }),
|
|
1011
1012
|
children: s && e.type && s[e.type] ? s[e.type]({ node: e }) : /* @__PURE__ */ p(d, { children: [
|
|
1012
1013
|
/* @__PURE__ */ f("span", { children: String(e.data?.label ?? e.id) }),
|
|
1013
|
-
|
|
1014
|
+
b && /* @__PURE__ */ f(K, {
|
|
1014
1015
|
type: "target",
|
|
1015
1016
|
position: "left"
|
|
1016
1017
|
}),
|
|
1017
|
-
|
|
1018
|
+
b && /* @__PURE__ */ f(K, {
|
|
1018
1019
|
type: "source",
|
|
1019
1020
|
position: "right"
|
|
1020
1021
|
})
|
|
@@ -1024,14 +1025,14 @@ function ve({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect:
|
|
|
1024
1025
|
});
|
|
1025
1026
|
}
|
|
1026
1027
|
var Q = {
|
|
1027
|
-
story: "
|
|
1028
|
-
overlay: "
|
|
1029
|
-
caption: "
|
|
1030
|
-
captionText: "
|
|
1031
|
-
captionDesc: "
|
|
1032
|
-
controls: "
|
|
1033
|
-
button: "
|
|
1034
|
-
indicator: "
|
|
1028
|
+
story: "_story_btt88_2",
|
|
1029
|
+
overlay: "_overlay_btt88_7",
|
|
1030
|
+
caption: "_caption_btt88_20",
|
|
1031
|
+
captionText: "_captionText_btt88_36",
|
|
1032
|
+
captionDesc: "_captionDesc_btt88_48",
|
|
1033
|
+
controls: "_controls_btt88_52",
|
|
1034
|
+
button: "_button_btt88_64",
|
|
1035
|
+
indicator: "_indicator_btt88_93"
|
|
1035
1036
|
}, $ = {
|
|
1036
1037
|
width: 18,
|
|
1037
1038
|
height: 18,
|
|
@@ -1039,15 +1040,15 @@ var Q = {
|
|
|
1039
1040
|
fill: "currentColor",
|
|
1040
1041
|
"aria-hidden": !0
|
|
1041
1042
|
};
|
|
1042
|
-
function
|
|
1043
|
+
function be({ 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: m = !0, background: _ = !0, interactive: v = !1, labels: y, clock: b, className: x, style: S }) {
|
|
1043
1044
|
c();
|
|
1044
|
-
let C = V(r, n), w =
|
|
1045
|
+
let C = V(r, n), w = ae({
|
|
1045
1046
|
steps: C,
|
|
1046
1047
|
loop: i,
|
|
1047
1048
|
stepDuration: a,
|
|
1048
1049
|
stepGap: o,
|
|
1049
1050
|
playing: s,
|
|
1050
|
-
defaultPlaying:
|
|
1051
|
+
defaultPlaying: m,
|
|
1051
1052
|
currentStep: l,
|
|
1052
1053
|
defaultCurrentStep: 0,
|
|
1053
1054
|
onStepChange: u,
|
|
@@ -1056,7 +1057,7 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1056
1057
|
return /* @__PURE__ */ p("div", {
|
|
1057
1058
|
className: e(Q.story, x),
|
|
1058
1059
|
style: S,
|
|
1059
|
-
children: [/* @__PURE__ */ f(
|
|
1060
|
+
children: [/* @__PURE__ */ f(ye, {
|
|
1060
1061
|
nodes: t,
|
|
1061
1062
|
edges: n,
|
|
1062
1063
|
background: _,
|
|
@@ -1081,7 +1082,7 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1081
1082
|
/* @__PURE__ */ f("button", {
|
|
1082
1083
|
type: "button",
|
|
1083
1084
|
className: Q.button,
|
|
1084
|
-
"aria-label": y?.previous ?? h
|
|
1085
|
+
"aria-label": y?.previous ?? g(h.flow.previous),
|
|
1085
1086
|
onClick: w.prev,
|
|
1086
1087
|
children: /* @__PURE__ */ f("svg", {
|
|
1087
1088
|
...$,
|
|
@@ -1096,7 +1097,7 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1096
1097
|
/* @__PURE__ */ f("button", {
|
|
1097
1098
|
type: "button",
|
|
1098
1099
|
className: Q.button,
|
|
1099
|
-
"aria-label": D ? y?.pause ?? h
|
|
1100
|
+
"aria-label": D ? y?.pause ?? g(h.flow.pause) : y?.play ?? g(h.flow.play),
|
|
1100
1101
|
"aria-pressed": D,
|
|
1101
1102
|
onClick: w.toggle,
|
|
1102
1103
|
children: D ? /* @__PURE__ */ f("svg", {
|
|
@@ -1110,7 +1111,7 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1110
1111
|
/* @__PURE__ */ f("button", {
|
|
1111
1112
|
type: "button",
|
|
1112
1113
|
className: Q.button,
|
|
1113
|
-
"aria-label": y?.next ?? h
|
|
1114
|
+
"aria-label": y?.next ?? g(h.flow.next),
|
|
1114
1115
|
onClick: w.next,
|
|
1115
1116
|
children: /* @__PURE__ */ f("svg", {
|
|
1116
1117
|
...$,
|
|
@@ -1124,7 +1125,7 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1124
1125
|
}),
|
|
1125
1126
|
/* @__PURE__ */ f("span", {
|
|
1126
1127
|
className: Q.indicator,
|
|
1127
|
-
children: h
|
|
1128
|
+
children: g(h.flow.step, {
|
|
1128
1129
|
current: E + 1,
|
|
1129
1130
|
total: C.length
|
|
1130
1131
|
})
|
|
@@ -1135,4 +1136,4 @@ function ye({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 150
|
|
|
1135
1136
|
});
|
|
1136
1137
|
}
|
|
1137
1138
|
//#endregion
|
|
1138
|
-
export {
|
|
1139
|
+
export { _ as DEFAULT_NODE_SIZE, ye as Flow, ce as FlowBackground, oe as FlowCanvas, pe as FlowControls, J as FlowEdge, K as FlowHandle, me as FlowMiniMap, ue as FlowNode, ge as FlowPanel, be as FlowStory, B as applyLayout, M as bezierPath, b as clampZoom, L as edgePath, D as fitViewport, S as flowToScreen, E as graphBounds, R as gridLayout, T as handleAnchor, z as layeredLayout, w as nodeBounds, C as nodeSize, V as resolveScript, te as resolveStep, x as screenToFlow, I as smoothStepPath, j as straightPath, W as useConnection, y as useFlow, ae as useStory, U as useViewport };
|