@ghchinoy/litflow 0.2.1 → 0.2.2
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/litflow.js +238 -209
- package/dist/litflow.js.map +1 -1
- package/package.json +1 -1
- package/src/lit-flow.ts +47 -13
package/dist/litflow.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { unsafeStatic as J, html as
|
|
3
|
-
import { property as a, customElement as
|
|
4
|
-
import { signal as
|
|
5
|
-
import { infiniteExtent as Q, Position as
|
|
6
|
-
import { m3Tokens as
|
|
7
|
-
function
|
|
1
|
+
import { LitElement as D, html as O, svg as S, css as B } from "lit";
|
|
2
|
+
import { unsafeStatic as J, html as j } from "lit/static-html.js";
|
|
3
|
+
import { property as a, customElement as C, query as q, state as N } from "lit/decorators.js";
|
|
4
|
+
import { signal as M, SignalWatcher as E } from "@lit-labs/signals";
|
|
5
|
+
import { infiniteExtent as Q, Position as L, getBezierPath as Y, adoptUserNodes as tt, updateAbsolutePositions as X, XYPanZoom as et, PanOnScrollMode as T, XYDrag as ot, getHandlePosition as V, getSmoothStepPath as W, getStraightPath as st, XYHandle as rt, ConnectionMode as nt, XYMinimap as it, getBoundsOfRects as at, getInternalNodesBounds as lt } from "@xyflow/system";
|
|
6
|
+
import { m3Tokens as F } from "./theme.js";
|
|
7
|
+
function dt() {
|
|
8
8
|
return {
|
|
9
|
-
nodes:
|
|
10
|
-
edges:
|
|
9
|
+
nodes: M([]),
|
|
10
|
+
edges: M([]),
|
|
11
11
|
nodeLookup: /* @__PURE__ */ new Map(),
|
|
12
12
|
parentLookup: /* @__PURE__ */ new Map(),
|
|
13
13
|
nodeExtent: Q,
|
|
@@ -15,22 +15,22 @@ function lt() {
|
|
|
15
15
|
snapToGrid: !1,
|
|
16
16
|
nodeOrigin: [0, 0],
|
|
17
17
|
multiSelectionActive: !1,
|
|
18
|
-
transform:
|
|
18
|
+
transform: M([0, 0, 1]),
|
|
19
19
|
autoPanOnNodeDrag: !0,
|
|
20
20
|
nodesDraggable: !0,
|
|
21
21
|
selectNodesOnDrag: !0,
|
|
22
22
|
nodeDragThreshold: 0,
|
|
23
23
|
panZoom: null,
|
|
24
24
|
domNode: null,
|
|
25
|
-
connectionInProgress:
|
|
25
|
+
connectionInProgress: M(null)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
var pt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor,
|
|
28
|
+
var pt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, k = (t, o, e, r) => {
|
|
29
29
|
for (var s = r > 1 ? void 0 : r ? ht(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
30
30
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
31
31
|
return r && s && pt(o, e, s), s;
|
|
32
32
|
};
|
|
33
|
-
let _ = class extends
|
|
33
|
+
let _ = class extends E(D) {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments), this.label = "", this.type = "default", this.data = {}, this.selected = !1, this.nodeId = "", this.positionX = 0, this.positionY = 0;
|
|
36
36
|
}
|
|
@@ -38,49 +38,49 @@ let _ = class extends B(z) {
|
|
|
38
38
|
return this;
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return
|
|
41
|
+
return O`
|
|
42
42
|
<div class="label" style="font-size: var(--md-sys-typescale-body-medium-size); color: var(--md-sys-color-on-surface); pointer-events: none; font-family: var(--md-sys-typescale-body-medium-font);">${this.label}</div>
|
|
43
43
|
<slot></slot>
|
|
44
|
-
${this.type === "input" || this.type === "default" ?
|
|
45
|
-
${this.type === "output" || this.type === "default" ?
|
|
44
|
+
${this.type === "input" || this.type === "default" ? O`<lit-handle type="source" data-handlepos="bottom" data-nodeid="${this.nodeId}"></lit-handle>` : ""}
|
|
45
|
+
${this.type === "output" || this.type === "default" ? O`<lit-handle type="target" data-handlepos="top" data-nodeid="${this.nodeId}"></lit-handle>` : ""}
|
|
46
46
|
`;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
k([
|
|
50
50
|
a({ type: String })
|
|
51
51
|
], _.prototype, "label", 2);
|
|
52
|
-
|
|
52
|
+
k([
|
|
53
53
|
a({ type: String, reflect: !0 })
|
|
54
54
|
], _.prototype, "type", 2);
|
|
55
|
-
|
|
55
|
+
k([
|
|
56
56
|
a({ type: Object })
|
|
57
57
|
], _.prototype, "data", 2);
|
|
58
|
-
|
|
58
|
+
k([
|
|
59
59
|
a({ type: Boolean, reflect: !0 })
|
|
60
60
|
], _.prototype, "selected", 2);
|
|
61
|
-
|
|
61
|
+
k([
|
|
62
62
|
a({ type: String, attribute: "data-id", reflect: !0 })
|
|
63
63
|
], _.prototype, "nodeId", 2);
|
|
64
|
-
|
|
64
|
+
k([
|
|
65
65
|
a({ type: Number, attribute: "position-x" })
|
|
66
66
|
], _.prototype, "positionX", 2);
|
|
67
|
-
|
|
67
|
+
k([
|
|
68
68
|
a({ type: Number, attribute: "position-y" })
|
|
69
69
|
], _.prototype, "positionY", 2);
|
|
70
|
-
_ =
|
|
71
|
-
|
|
70
|
+
_ = k([
|
|
71
|
+
C("lit-node")
|
|
72
72
|
], _);
|
|
73
|
-
var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor,
|
|
73
|
+
var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, P = (t, o, e, r) => {
|
|
74
74
|
for (var s = r > 1 ? void 0 : r ? ut(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
75
75
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
76
76
|
return r && s && ct(o, e, s), s;
|
|
77
77
|
};
|
|
78
|
-
let b = class extends
|
|
78
|
+
let b = class extends E(D) {
|
|
79
79
|
constructor() {
|
|
80
|
-
super(...arguments), this.sourceX = 0, this.sourceY = 0, this.targetX = 0, this.targetY = 0, this.sourcePosition =
|
|
80
|
+
super(...arguments), this.sourceX = 0, this.sourceY = 0, this.targetX = 0, this.targetY = 0, this.sourcePosition = L.Right, this.targetPosition = L.Left, this.selected = !1;
|
|
81
81
|
}
|
|
82
82
|
render() {
|
|
83
|
-
const [t] =
|
|
83
|
+
const [t] = Y({
|
|
84
84
|
sourceX: this.sourceX,
|
|
85
85
|
sourceY: this.sourceY,
|
|
86
86
|
sourcePosition: this.sourcePosition,
|
|
@@ -88,12 +88,12 @@ let b = class extends B(z) {
|
|
|
88
88
|
targetY: this.targetY,
|
|
89
89
|
targetPosition: this.targetPosition
|
|
90
90
|
});
|
|
91
|
-
return
|
|
91
|
+
return S`
|
|
92
92
|
<path d="${t}" />
|
|
93
93
|
`;
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
b.styles =
|
|
96
|
+
b.styles = B`
|
|
97
97
|
:host {
|
|
98
98
|
display: contents;
|
|
99
99
|
}
|
|
@@ -108,29 +108,29 @@ b.styles = S`
|
|
|
108
108
|
stroke: #555;
|
|
109
109
|
}
|
|
110
110
|
`;
|
|
111
|
-
|
|
111
|
+
P([
|
|
112
112
|
a({ type: Number })
|
|
113
113
|
], b.prototype, "sourceX", 2);
|
|
114
|
-
|
|
114
|
+
P([
|
|
115
115
|
a({ type: Number })
|
|
116
116
|
], b.prototype, "sourceY", 2);
|
|
117
|
-
|
|
117
|
+
P([
|
|
118
118
|
a({ type: Number })
|
|
119
119
|
], b.prototype, "targetX", 2);
|
|
120
|
-
|
|
120
|
+
P([
|
|
121
121
|
a({ type: Number })
|
|
122
122
|
], b.prototype, "targetY", 2);
|
|
123
|
-
|
|
123
|
+
P([
|
|
124
124
|
a({ type: String })
|
|
125
125
|
], b.prototype, "sourcePosition", 2);
|
|
126
|
-
|
|
126
|
+
P([
|
|
127
127
|
a({ type: String })
|
|
128
128
|
], b.prototype, "targetPosition", 2);
|
|
129
|
-
|
|
129
|
+
P([
|
|
130
130
|
a({ type: Boolean, reflect: !0 })
|
|
131
131
|
], b.prototype, "selected", 2);
|
|
132
|
-
b =
|
|
133
|
-
|
|
132
|
+
b = P([
|
|
133
|
+
C("lit-edge")
|
|
134
134
|
], b);
|
|
135
135
|
var mt = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, m = (t, o, e, r) => {
|
|
136
136
|
for (var s = r > 1 ? void 0 : r ? ft(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
@@ -141,9 +141,9 @@ const w = {
|
|
|
141
141
|
fromAttribute: (t) => t !== "false" && t !== null,
|
|
142
142
|
toAttribute: (t) => t ? "" : null
|
|
143
143
|
};
|
|
144
|
-
let
|
|
144
|
+
let u = class extends E(D) {
|
|
145
145
|
constructor() {
|
|
146
|
-
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state =
|
|
146
|
+
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state = dt(), this.nodeTypes = {
|
|
147
147
|
default: "lit-node",
|
|
148
148
|
input: "lit-node",
|
|
149
149
|
output: "lit-node"
|
|
@@ -153,7 +153,7 @@ let c = class extends B(z) {
|
|
|
153
153
|
this._state.nodes.set(t), tt(t, this._state.nodeLookup, this._state.parentLookup, {
|
|
154
154
|
nodeOrigin: this._state.nodeOrigin,
|
|
155
155
|
nodeExtent: this._state.nodeExtent
|
|
156
|
-
}),
|
|
156
|
+
}), X(this._state.nodeLookup, this._state.parentLookup, {
|
|
157
157
|
nodeOrigin: this._state.nodeOrigin,
|
|
158
158
|
nodeExtent: this._state.nodeExtent
|
|
159
159
|
});
|
|
@@ -215,24 +215,24 @@ let c = class extends B(z) {
|
|
|
215
215
|
i && (i.measured = e.measured);
|
|
216
216
|
const p = o.querySelectorAll("lit-handle");
|
|
217
217
|
if (p && p.length > 0) {
|
|
218
|
-
const h = [],
|
|
219
|
-
p.forEach((
|
|
220
|
-
const
|
|
221
|
-
id:
|
|
222
|
-
type:
|
|
223
|
-
position:
|
|
224
|
-
x: (
|
|
225
|
-
y: (
|
|
226
|
-
width:
|
|
227
|
-
height:
|
|
218
|
+
const h = [], l = [];
|
|
219
|
+
p.forEach((c) => {
|
|
220
|
+
const d = c.getBoundingClientRect(), f = o.getBoundingClientRect(), g = {
|
|
221
|
+
id: c.handleId || null,
|
|
222
|
+
type: c.type,
|
|
223
|
+
position: c.position,
|
|
224
|
+
x: (d.left - f.left) / n,
|
|
225
|
+
y: (d.top - f.top) / n,
|
|
226
|
+
width: d.width / n,
|
|
227
|
+
height: d.height / n
|
|
228
228
|
};
|
|
229
|
-
|
|
229
|
+
c.type === "source" ? h.push(g) : l.push(g);
|
|
230
230
|
}), e.internals.handleBounds = {
|
|
231
231
|
source: h,
|
|
232
|
-
target:
|
|
232
|
+
target: l
|
|
233
233
|
}, console.log(`Node ${t} handleBounds:`, e.internals.handleBounds);
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
X(this._state.nodeLookup, this._state.parentLookup, {
|
|
236
236
|
nodeOrigin: this._state.nodeOrigin,
|
|
237
237
|
nodeExtent: this._state.nodeExtent
|
|
238
238
|
}), this._state.nodes.set([...this.nodes]);
|
|
@@ -343,10 +343,10 @@ let c = class extends B(z) {
|
|
|
343
343
|
const h = this._state.nodeLookup.get(p);
|
|
344
344
|
if (h) {
|
|
345
345
|
h.position = i.position, h.internals.positionAbsolute = i.internals.positionAbsolute;
|
|
346
|
-
const
|
|
347
|
-
|
|
346
|
+
const l = this.nodes.find((c) => c.id === p);
|
|
347
|
+
l && (l.position = i.position);
|
|
348
348
|
}
|
|
349
|
-
}),
|
|
349
|
+
}), X(this._state.nodeLookup, this._state.parentLookup, {
|
|
350
350
|
nodeOrigin: this._state.nodeOrigin,
|
|
351
351
|
nodeExtent: this._state.nodeExtent
|
|
352
352
|
}), this._state.nodes.set([...this.nodes]);
|
|
@@ -366,33 +366,33 @@ let c = class extends B(z) {
|
|
|
366
366
|
_renderEdge(t) {
|
|
367
367
|
const o = this._state.nodeLookup.get(t.source), e = this._state.nodeLookup.get(t.target);
|
|
368
368
|
if (!o || !e) return null;
|
|
369
|
-
const r = this.nodes.find((
|
|
369
|
+
const r = this.nodes.find((y) => y.id === t.source), s = this.nodes.find((y) => y.id === t.target);
|
|
370
370
|
if (r?.hidden || s?.hidden) return null;
|
|
371
371
|
const n = (o.internals.handleBounds?.source || []).find(
|
|
372
|
-
(
|
|
372
|
+
(y) => y.id === (t.sourceHandle || null)
|
|
373
373
|
) || o.internals.handleBounds?.source?.[0] || {
|
|
374
374
|
id: null,
|
|
375
375
|
type: "source",
|
|
376
376
|
nodeId: t.source,
|
|
377
|
-
position:
|
|
377
|
+
position: L.Bottom,
|
|
378
378
|
x: (o.measured.width || 0) / 2,
|
|
379
379
|
y: o.measured.height || 0,
|
|
380
380
|
width: 1,
|
|
381
381
|
height: 1
|
|
382
382
|
}, i = (e.internals.handleBounds?.target || []).find(
|
|
383
|
-
(
|
|
383
|
+
(y) => y.id === (t.targetHandle || null)
|
|
384
384
|
) || e.internals.handleBounds?.target?.[0] || {
|
|
385
385
|
id: null,
|
|
386
386
|
type: "target",
|
|
387
387
|
nodeId: t.target,
|
|
388
|
-
position:
|
|
388
|
+
position: L.Top,
|
|
389
389
|
x: (e.measured.width || 0) / 2,
|
|
390
390
|
y: 0,
|
|
391
391
|
width: 1,
|
|
392
392
|
height: 1
|
|
393
|
-
}, p =
|
|
394
|
-
let
|
|
395
|
-
const
|
|
393
|
+
}, p = V(o, n, n.position, !0), h = V(e, i, i.position, !0);
|
|
394
|
+
let l = "", c = 0, d = 0;
|
|
395
|
+
const f = {
|
|
396
396
|
sourceX: p.x,
|
|
397
397
|
sourceY: p.y,
|
|
398
398
|
sourcePosition: n.position,
|
|
@@ -402,48 +402,63 @@ let c = class extends B(z) {
|
|
|
402
402
|
};
|
|
403
403
|
switch (t.type) {
|
|
404
404
|
case "straight":
|
|
405
|
-
[d] = st(
|
|
405
|
+
[l, c, d] = st(f);
|
|
406
406
|
break;
|
|
407
407
|
case "smoothstep":
|
|
408
|
-
[d] =
|
|
408
|
+
[l, c, d] = W(f);
|
|
409
409
|
break;
|
|
410
410
|
case "step":
|
|
411
|
-
[d] =
|
|
411
|
+
[l, c, d] = W({ ...f, borderRadius: 0 });
|
|
412
412
|
break;
|
|
413
413
|
default:
|
|
414
|
-
[d] =
|
|
414
|
+
[l, c, d] = Y(f);
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
|
-
const
|
|
418
|
-
if (!
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
},
|
|
422
|
-
return
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
417
|
+
const g = (y) => {
|
|
418
|
+
if (!y) return null;
|
|
419
|
+
const Z = typeof y == "string" ? y : y.type;
|
|
420
|
+
return Z ? `lit-flow__${Z}${t.selected ? "-selected" : ""}` : null;
|
|
421
|
+
}, x = g(t.markerEnd), $ = g(t.markerStart);
|
|
422
|
+
return S`
|
|
423
|
+
<g class="xyflow__edge">
|
|
424
|
+
<path
|
|
425
|
+
d="${l}"
|
|
426
|
+
fill="none"
|
|
427
|
+
stroke="${t.selected ? "var(--md-sys-color-primary)" : "var(--md-sys-color-outline-variant)"}"
|
|
428
|
+
stroke-width="2"
|
|
429
|
+
marker-end="${x ? `url(#${x})` : ""}"
|
|
430
|
+
marker-start="${$ ? `url(#${$})` : ""}"
|
|
431
|
+
style="pointer-events: none;"
|
|
432
|
+
/>
|
|
433
|
+
${t.label ? S`
|
|
434
|
+
<foreignObject
|
|
435
|
+
width="100"
|
|
436
|
+
height="30"
|
|
437
|
+
x="${c - 50}"
|
|
438
|
+
y="${d - 15}"
|
|
439
|
+
requiredExtensions="http://www.w3.org/1999/xhtml"
|
|
440
|
+
>
|
|
441
|
+
<div style="display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;">
|
|
442
|
+
<div class="xyflow__edge-label">${t.label}</div>
|
|
443
|
+
</div>
|
|
444
|
+
</foreignObject>
|
|
445
|
+
` : ""}
|
|
446
|
+
</g>
|
|
432
447
|
`;
|
|
433
448
|
}
|
|
434
449
|
_onHandlePointerDown(t) {
|
|
435
450
|
const { event: o, handleId: e, nodeId: r, type: s, handleDomNode: n } = t.detail, i = s === "target";
|
|
436
451
|
if (this._state.connectionInProgress.get() || !this.nodesConnectable)
|
|
437
452
|
return;
|
|
438
|
-
const p = n.getBoundingClientRect(), h = n.parentElement?.getBoundingClientRect(),
|
|
453
|
+
const p = n.getBoundingClientRect(), h = n.parentElement?.getBoundingClientRect(), l = this._state.transform.get()[2], c = {
|
|
439
454
|
id: e,
|
|
440
455
|
nodeId: r,
|
|
441
456
|
type: s,
|
|
442
457
|
position: n.position,
|
|
443
|
-
x: (p.left - (h?.left ?? 0)) /
|
|
444
|
-
y: (p.top - (h?.top ?? 0)) /
|
|
445
|
-
width: p.width /
|
|
446
|
-
height: p.height /
|
|
458
|
+
x: (p.left - (h?.left ?? 0)) / l,
|
|
459
|
+
y: (p.top - (h?.top ?? 0)) / l,
|
|
460
|
+
width: p.width / l,
|
|
461
|
+
height: p.height / l
|
|
447
462
|
};
|
|
448
463
|
rt.onPointerDown(o, {
|
|
449
464
|
handleId: e,
|
|
@@ -457,28 +472,28 @@ let c = class extends B(z) {
|
|
|
457
472
|
autoPanOnConnect: !0,
|
|
458
473
|
flowId: "lit-flow",
|
|
459
474
|
dragThreshold: 0,
|
|
460
|
-
panBy: async (
|
|
475
|
+
panBy: async (d) => {
|
|
461
476
|
const f = this._panZoom?.getViewport();
|
|
462
477
|
return f ? (await this._panZoom?.setViewport({
|
|
463
|
-
x: f.x +
|
|
464
|
-
y: f.y +
|
|
478
|
+
x: f.x + d.x,
|
|
479
|
+
y: f.y + d.y,
|
|
465
480
|
zoom: f.zoom
|
|
466
481
|
}), !0) : !1;
|
|
467
482
|
},
|
|
468
483
|
getTransform: () => this._state.transform.get(),
|
|
469
|
-
getFromHandle: () =>
|
|
470
|
-
updateConnection: (
|
|
471
|
-
|
|
484
|
+
getFromHandle: () => c,
|
|
485
|
+
updateConnection: (d) => {
|
|
486
|
+
d.inProgress ? this._state.connectionInProgress.set(d) : this._state.connectionInProgress.set(null);
|
|
472
487
|
},
|
|
473
488
|
cancelConnection: () => {
|
|
474
489
|
this._state.connectionInProgress.set(null);
|
|
475
490
|
},
|
|
476
|
-
onConnect: (
|
|
491
|
+
onConnect: (d) => {
|
|
477
492
|
this.dispatchEvent(new CustomEvent("connect", {
|
|
478
|
-
detail:
|
|
493
|
+
detail: d
|
|
479
494
|
}));
|
|
480
|
-
const f = `e-${
|
|
481
|
-
this.edges = [...this.edges, { ...
|
|
495
|
+
const f = `e-${d.source}${d.sourceHandle || ""}-${d.target}${d.targetHandle || ""}`;
|
|
496
|
+
this.edges = [...this.edges, { ...d, id: f }];
|
|
482
497
|
},
|
|
483
498
|
connectionRadius: 20
|
|
484
499
|
});
|
|
@@ -513,7 +528,7 @@ let c = class extends B(z) {
|
|
|
513
528
|
}
|
|
514
529
|
_renderConnectionLine(t) {
|
|
515
530
|
if (!t) return null;
|
|
516
|
-
const [o] =
|
|
531
|
+
const [o] = Y({
|
|
517
532
|
sourceX: t.from.x,
|
|
518
533
|
sourceY: t.from.y,
|
|
519
534
|
sourcePosition: t.fromPosition,
|
|
@@ -521,7 +536,7 @@ let c = class extends B(z) {
|
|
|
521
536
|
targetY: t.to.y,
|
|
522
537
|
targetPosition: t.toPosition
|
|
523
538
|
});
|
|
524
|
-
return
|
|
539
|
+
return S`
|
|
525
540
|
<path
|
|
526
541
|
class="xyflow__connection-path"
|
|
527
542
|
d="${o}"
|
|
@@ -534,7 +549,7 @@ let c = class extends B(z) {
|
|
|
534
549
|
}
|
|
535
550
|
render() {
|
|
536
551
|
const t = this._state.transform.get(), o = this._state.connectionInProgress.get();
|
|
537
|
-
return
|
|
552
|
+
return j`
|
|
538
553
|
<div
|
|
539
554
|
class="xyflow__renderer ${this.showGrid ? "has-grid" : ""}"
|
|
540
555
|
@dragover="${this._onDragOver}"
|
|
@@ -547,14 +562,14 @@ let c = class extends B(z) {
|
|
|
547
562
|
<div class="xyflow__nodes" @handle-pointer-down="${this._onHandlePointerDown}">
|
|
548
563
|
${this.nodes.map((e) => {
|
|
549
564
|
if (e.hidden) return null;
|
|
550
|
-
const s = this._state.nodeLookup.get(e.id)?.internals.positionAbsolute || e.position, n = this.nodeTypes[e.type || "default"] || this.nodeTypes.default, i = J(n), p = e.style || {}, h = Object.entries(p).map(([
|
|
551
|
-
return
|
|
565
|
+
const s = this._state.nodeLookup.get(e.id)?.internals.positionAbsolute || e.position, n = this.nodeTypes[e.type || "default"] || this.nodeTypes.default, i = J(n), p = e.style || {}, h = Object.entries(p).map(([x, $]) => `${x.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${typeof $ == "number" ? `${$}px` : $}`).join("; "), l = e.width || p.width, c = e.height || p.height, d = l ? `width: ${typeof l == "number" ? `${l}px` : l};` : "", f = c ? `height: ${typeof c == "number" ? `${c}px` : c};` : "", g = e.zIndex ? `z-index: ${e.zIndex};` : "";
|
|
566
|
+
return j`
|
|
552
567
|
<${i}
|
|
553
568
|
class="xyflow__node"
|
|
554
569
|
data-id="${e.id}"
|
|
555
570
|
type="${e.type || "default"}"
|
|
556
571
|
.nodeId="${e.id}"
|
|
557
|
-
style="transform: translate(${s.x}px, ${s.y}px); ${h} ${
|
|
572
|
+
style="transform: translate(${s.x}px, ${s.y}px); ${h} ${d} ${f} ${g}"
|
|
558
573
|
.data="${e.data}"
|
|
559
574
|
.label="${e.data.label}"
|
|
560
575
|
.type="${e.type || "default"}"
|
|
@@ -616,8 +631,8 @@ let c = class extends B(z) {
|
|
|
616
631
|
</svg>
|
|
617
632
|
</div>
|
|
618
633
|
</div>
|
|
619
|
-
${this.showControls ?
|
|
620
|
-
${this.showMinimap ?
|
|
634
|
+
${this.showControls ? j`<lit-controls .panZoom="${this._panZoom}"></lit-controls>` : ""}
|
|
635
|
+
${this.showMinimap ? j`
|
|
621
636
|
<lit-minimap
|
|
622
637
|
.panZoom="${this._panZoom}"
|
|
623
638
|
.nodeLookup="${this._state.nodeLookup}"
|
|
@@ -631,9 +646,9 @@ let c = class extends B(z) {
|
|
|
631
646
|
`;
|
|
632
647
|
}
|
|
633
648
|
};
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
649
|
+
u.styles = [
|
|
650
|
+
F,
|
|
651
|
+
B`
|
|
637
652
|
:host {
|
|
638
653
|
display: block;
|
|
639
654
|
width: 100%;
|
|
@@ -786,79 +801,93 @@ c.styles = [
|
|
|
786
801
|
stroke-dasharray: 5,5;
|
|
787
802
|
pointer-events: none;
|
|
788
803
|
}
|
|
804
|
+
|
|
805
|
+
.xyflow__edge-label {
|
|
806
|
+
background: var(--md-sys-color-surface);
|
|
807
|
+
color: var(--md-sys-color-on-surface);
|
|
808
|
+
padding: 2px 6px;
|
|
809
|
+
border-radius: var(--md-sys-shape-corner-extra-small);
|
|
810
|
+
font-size: var(--md-sys-typescale-label-small-size);
|
|
811
|
+
font-family: var(--md-sys-typescale-body-medium-font);
|
|
812
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
813
|
+
white-space: nowrap;
|
|
814
|
+
pointer-events: all;
|
|
815
|
+
user-select: none;
|
|
816
|
+
box-shadow: var(--md-sys-elevation-1);
|
|
817
|
+
}
|
|
789
818
|
`
|
|
790
819
|
];
|
|
791
820
|
m([
|
|
792
|
-
|
|
793
|
-
],
|
|
821
|
+
q(".xyflow__renderer")
|
|
822
|
+
], u.prototype, "_renderer", 2);
|
|
794
823
|
m([
|
|
795
|
-
|
|
796
|
-
],
|
|
824
|
+
q(".xyflow__viewport")
|
|
825
|
+
], u.prototype, "_viewport", 2);
|
|
797
826
|
m([
|
|
798
|
-
|
|
799
|
-
],
|
|
827
|
+
N()
|
|
828
|
+
], u.prototype, "_panZoom", 2);
|
|
800
829
|
m([
|
|
801
|
-
|
|
802
|
-
],
|
|
830
|
+
N()
|
|
831
|
+
], u.prototype, "_state", 2);
|
|
803
832
|
m([
|
|
804
833
|
a({ type: Object })
|
|
805
|
-
],
|
|
834
|
+
], u.prototype, "nodeTypes", 2);
|
|
806
835
|
m([
|
|
807
836
|
a({ type: Boolean, attribute: "show-controls", reflect: !0 })
|
|
808
|
-
],
|
|
837
|
+
], u.prototype, "showControls", 2);
|
|
809
838
|
m([
|
|
810
839
|
a({ type: Boolean, attribute: "show-minimap", reflect: !0, converter: w })
|
|
811
|
-
],
|
|
840
|
+
], u.prototype, "showMinimap", 2);
|
|
812
841
|
m([
|
|
813
842
|
a({ type: Boolean, attribute: "show-grid", reflect: !0, converter: w })
|
|
814
|
-
],
|
|
843
|
+
], u.prototype, "showGrid", 2);
|
|
815
844
|
m([
|
|
816
845
|
a({ type: Boolean, attribute: "nodes-draggable", reflect: !0, converter: w })
|
|
817
|
-
],
|
|
846
|
+
], u.prototype, "nodesDraggable", 2);
|
|
818
847
|
m([
|
|
819
848
|
a({ type: Boolean, attribute: "nodes-connectable", reflect: !0, converter: w })
|
|
820
|
-
],
|
|
849
|
+
], u.prototype, "nodesConnectable", 2);
|
|
821
850
|
m([
|
|
822
851
|
a({ type: Boolean, attribute: "pan-on-drag", reflect: !0, converter: w })
|
|
823
|
-
],
|
|
852
|
+
], u.prototype, "panOnDrag", 2);
|
|
824
853
|
m([
|
|
825
854
|
a({ type: Boolean, attribute: "zoom-on-scroll", reflect: !0, converter: w })
|
|
826
|
-
],
|
|
855
|
+
], u.prototype, "zoomOnScroll", 2);
|
|
827
856
|
m([
|
|
828
857
|
a({ type: Boolean, attribute: "zoom-on-pinch", reflect: !0, converter: w })
|
|
829
|
-
],
|
|
858
|
+
], u.prototype, "zoomOnPinch", 2);
|
|
830
859
|
m([
|
|
831
860
|
a({ type: Boolean, attribute: "zoom-on-double-click", reflect: !0, converter: w })
|
|
832
|
-
],
|
|
861
|
+
], u.prototype, "zoomOnDoubleClick", 2);
|
|
833
862
|
m([
|
|
834
863
|
a({ type: Boolean, attribute: "prompt-on-drop", reflect: !0, converter: w })
|
|
835
|
-
],
|
|
864
|
+
], u.prototype, "promptOnDrop", 2);
|
|
836
865
|
m([
|
|
837
|
-
|
|
838
|
-
],
|
|
866
|
+
N()
|
|
867
|
+
], u.prototype, "_width", 2);
|
|
839
868
|
m([
|
|
840
|
-
|
|
841
|
-
],
|
|
869
|
+
N()
|
|
870
|
+
], u.prototype, "_height", 2);
|
|
842
871
|
m([
|
|
843
872
|
a({ type: Array })
|
|
844
|
-
],
|
|
873
|
+
], u.prototype, "nodes", 1);
|
|
845
874
|
m([
|
|
846
875
|
a({ type: Array })
|
|
847
|
-
],
|
|
876
|
+
], u.prototype, "edges", 1);
|
|
848
877
|
m([
|
|
849
878
|
a({ type: Object })
|
|
850
|
-
],
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
],
|
|
854
|
-
var
|
|
855
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
879
|
+
], u.prototype, "viewport", 2);
|
|
880
|
+
u = m([
|
|
881
|
+
C("lit-flow")
|
|
882
|
+
], u);
|
|
883
|
+
var yt = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, A = (t, o, e, r) => {
|
|
884
|
+
for (var s = r > 1 ? void 0 : r ? gt(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
856
885
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
857
|
-
return r && s &&
|
|
886
|
+
return r && s && yt(o, e, s), s;
|
|
858
887
|
};
|
|
859
|
-
let
|
|
888
|
+
let I = class extends D {
|
|
860
889
|
constructor() {
|
|
861
|
-
super(), this.type = "source", this.position =
|
|
890
|
+
super(), this.type = "source", this.position = L.Top, this.addEventListener("mousedown", (t) => this._onPointerDown(t)), this.addEventListener("touchstart", (t) => this._onPointerDown(t));
|
|
862
891
|
}
|
|
863
892
|
createRenderRoot() {
|
|
864
893
|
return this;
|
|
@@ -885,7 +914,7 @@ let C = class extends z {
|
|
|
885
914
|
(t.has("nodeId") || t.has("handleId") || t.has("type")) && this.setAttribute("data-id", `lit-flow-${this.nodeId || ""}-${this.handleId || ""}-${this.type}`);
|
|
886
915
|
}
|
|
887
916
|
render() {
|
|
888
|
-
return
|
|
917
|
+
return O`
|
|
889
918
|
<div style="
|
|
890
919
|
width: 100%;
|
|
891
920
|
height: 100%;
|
|
@@ -896,27 +925,27 @@ let C = class extends z {
|
|
|
896
925
|
`;
|
|
897
926
|
}
|
|
898
927
|
};
|
|
899
|
-
|
|
928
|
+
A([
|
|
900
929
|
a({ type: String, reflect: !0 })
|
|
901
|
-
],
|
|
902
|
-
|
|
930
|
+
], I.prototype, "type", 2);
|
|
931
|
+
A([
|
|
903
932
|
a({ type: String, reflect: !0, attribute: "data-handlepos" })
|
|
904
|
-
],
|
|
905
|
-
|
|
933
|
+
], I.prototype, "position", 2);
|
|
934
|
+
A([
|
|
906
935
|
a({ type: String, reflect: !0, attribute: "data-handleid" })
|
|
907
|
-
],
|
|
908
|
-
|
|
936
|
+
], I.prototype, "handleId", 2);
|
|
937
|
+
A([
|
|
909
938
|
a({ type: String, reflect: !0, attribute: "data-nodeid" })
|
|
910
|
-
],
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
],
|
|
914
|
-
var bt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor,
|
|
939
|
+
], I.prototype, "nodeId", 2);
|
|
940
|
+
I = A([
|
|
941
|
+
C("lit-handle")
|
|
942
|
+
], I);
|
|
943
|
+
var bt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, G = (t, o, e, r) => {
|
|
915
944
|
for (var s = r > 1 ? void 0 : r ? vt(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
916
945
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
917
946
|
return r && s && bt(o, e, s), s;
|
|
918
947
|
};
|
|
919
|
-
let
|
|
948
|
+
let R = class extends E(D) {
|
|
920
949
|
_zoomIn() {
|
|
921
950
|
this.panZoom?.scaleBy(1.2);
|
|
922
951
|
}
|
|
@@ -927,7 +956,7 @@ let M = class extends B(z) {
|
|
|
927
956
|
this.panZoom?.setViewport({ x: 0, y: 0, zoom: 1 });
|
|
928
957
|
}
|
|
929
958
|
render() {
|
|
930
|
-
return
|
|
959
|
+
return O`
|
|
931
960
|
<button @click="${this._zoomIn}" title="Zoom In">
|
|
932
961
|
<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
|
933
962
|
</button>
|
|
@@ -940,7 +969,7 @@ let M = class extends B(z) {
|
|
|
940
969
|
`;
|
|
941
970
|
}
|
|
942
971
|
};
|
|
943
|
-
|
|
972
|
+
R.styles = B`
|
|
944
973
|
:host {
|
|
945
974
|
display: block;
|
|
946
975
|
position: absolute;
|
|
@@ -983,18 +1012,18 @@ M.styles = S`
|
|
|
983
1012
|
fill: currentColor;
|
|
984
1013
|
}
|
|
985
1014
|
`;
|
|
986
|
-
|
|
1015
|
+
G([
|
|
987
1016
|
a({ type: Object })
|
|
988
|
-
],
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
],
|
|
992
|
-
var _t = Object.defineProperty, wt = Object.getOwnPropertyDescriptor,
|
|
1017
|
+
], R.prototype, "panZoom", 2);
|
|
1018
|
+
R = G([
|
|
1019
|
+
C("lit-controls")
|
|
1020
|
+
], R);
|
|
1021
|
+
var _t = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, z = (t, o, e, r) => {
|
|
993
1022
|
for (var s = r > 1 ? void 0 : r ? wt(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
994
1023
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
995
1024
|
return r && s && _t(o, e, s), s;
|
|
996
1025
|
};
|
|
997
|
-
let v = class extends
|
|
1026
|
+
let v = class extends E(D) {
|
|
998
1027
|
constructor() {
|
|
999
1028
|
super(...arguments), this.nodeLookup = /* @__PURE__ */ new Map(), this.transform = [0, 0, 1], this.translateExtent = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], this.width = 0, this.height = 0;
|
|
1000
1029
|
}
|
|
@@ -1024,7 +1053,7 @@ let v = class extends B(z) {
|
|
|
1024
1053
|
width: this.width / this.transform[2],
|
|
1025
1054
|
height: this.height / this.transform[2]
|
|
1026
1055
|
};
|
|
1027
|
-
return this.nodeLookup.size > 0 ? at(
|
|
1056
|
+
return this.nodeLookup.size > 0 ? at(lt(this.nodeLookup), t) : t;
|
|
1028
1057
|
}
|
|
1029
1058
|
render() {
|
|
1030
1059
|
const t = this._getBoundingRect(), o = {
|
|
@@ -1032,21 +1061,21 @@ let v = class extends B(z) {
|
|
|
1032
1061
|
y: -this.transform[1] / this.transform[2],
|
|
1033
1062
|
width: this.width / this.transform[2],
|
|
1034
1063
|
height: this.height / this.transform[2]
|
|
1035
|
-
}, e = 200, r = 150, s = t.width / e, n = t.height / r, i = Math.max(s, n), p = i * e, h = i * r,
|
|
1036
|
-
return
|
|
1064
|
+
}, e = 200, r = 150, s = t.width / e, n = t.height / r, i = Math.max(s, n), p = i * e, h = i * r, l = 5 * i, c = t.x - (p - t.width) / 2 - l, d = t.y - (h - t.height) / 2 - l, f = p + l * 2, g = h + l * 2;
|
|
1065
|
+
return O`
|
|
1037
1066
|
<svg
|
|
1038
1067
|
width="${e}"
|
|
1039
1068
|
height="${r}"
|
|
1040
|
-
viewBox="${
|
|
1069
|
+
viewBox="${c} ${d} ${f} ${g}"
|
|
1041
1070
|
>
|
|
1042
|
-
${Array.from(this.nodeLookup.values()).map((
|
|
1043
|
-
const { x
|
|
1044
|
-
return
|
|
1071
|
+
${Array.from(this.nodeLookup.values()).map((x) => {
|
|
1072
|
+
const { x: $, y } = x.internals.positionAbsolute, Z = x.measured.width || 0, U = x.measured.height || 0;
|
|
1073
|
+
return S`
|
|
1045
1074
|
<rect
|
|
1046
1075
|
class="minimap-node"
|
|
1047
|
-
x="${
|
|
1048
|
-
y="${
|
|
1049
|
-
width="${
|
|
1076
|
+
x="${$}"
|
|
1077
|
+
y="${y}"
|
|
1078
|
+
width="${Z}"
|
|
1050
1079
|
height="${U}"
|
|
1051
1080
|
rx="2"
|
|
1052
1081
|
ry="2"
|
|
@@ -1055,14 +1084,14 @@ let v = class extends B(z) {
|
|
|
1055
1084
|
})}
|
|
1056
1085
|
<path
|
|
1057
1086
|
class="minimap-mask"
|
|
1058
|
-
d="M${
|
|
1087
|
+
d="M${c - l},${d - l}h${f + l * 2}v${g + l * 2}h${-f - l * 2}z
|
|
1059
1088
|
M${o.x},${o.y}h${o.width}v${o.height}h${-o.width}z"
|
|
1060
1089
|
/>
|
|
1061
1090
|
</svg>
|
|
1062
1091
|
`;
|
|
1063
1092
|
}
|
|
1064
1093
|
};
|
|
1065
|
-
v.styles =
|
|
1094
|
+
v.styles = B`
|
|
1066
1095
|
:host {
|
|
1067
1096
|
display: block;
|
|
1068
1097
|
position: absolute;
|
|
@@ -1091,36 +1120,36 @@ v.styles = S`
|
|
|
1091
1120
|
fill-rule: evenodd;
|
|
1092
1121
|
}
|
|
1093
1122
|
`;
|
|
1094
|
-
|
|
1123
|
+
z([
|
|
1095
1124
|
a({ type: Object })
|
|
1096
1125
|
], v.prototype, "panZoom", 2);
|
|
1097
|
-
|
|
1126
|
+
z([
|
|
1098
1127
|
a({ type: Object })
|
|
1099
1128
|
], v.prototype, "nodeLookup", 2);
|
|
1100
|
-
|
|
1129
|
+
z([
|
|
1101
1130
|
a({ type: Array })
|
|
1102
1131
|
], v.prototype, "transform", 2);
|
|
1103
|
-
|
|
1132
|
+
z([
|
|
1104
1133
|
a({ type: Array })
|
|
1105
1134
|
], v.prototype, "translateExtent", 2);
|
|
1106
|
-
|
|
1135
|
+
z([
|
|
1107
1136
|
a({ type: Number })
|
|
1108
1137
|
], v.prototype, "width", 2);
|
|
1109
|
-
|
|
1138
|
+
z([
|
|
1110
1139
|
a({ type: Number })
|
|
1111
1140
|
], v.prototype, "height", 2);
|
|
1112
|
-
|
|
1113
|
-
|
|
1141
|
+
z([
|
|
1142
|
+
N()
|
|
1114
1143
|
], v.prototype, "_minimapInstance", 2);
|
|
1115
|
-
v =
|
|
1116
|
-
|
|
1144
|
+
v = z([
|
|
1145
|
+
C("lit-minimap")
|
|
1117
1146
|
], v);
|
|
1118
|
-
var xt = Object.defineProperty, $t = Object.getOwnPropertyDescriptor,
|
|
1147
|
+
var xt = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, K = (t, o, e, r) => {
|
|
1119
1148
|
for (var s = r > 1 ? void 0 : r ? $t(o, e) : o, n = t.length - 1, i; n >= 0; n--)
|
|
1120
1149
|
(i = t[n]) && (s = (r ? i(o, e, s) : i(s)) || s);
|
|
1121
1150
|
return r && s && xt(o, e, s), s;
|
|
1122
1151
|
};
|
|
1123
|
-
let
|
|
1152
|
+
let H = class extends D {
|
|
1124
1153
|
constructor() {
|
|
1125
1154
|
super(...arguments), this.nodeTypes = [
|
|
1126
1155
|
{ type: "default", label: "Default Node" },
|
|
@@ -1132,11 +1161,11 @@ let R = class extends z {
|
|
|
1132
1161
|
t.dataTransfer && (t.dataTransfer.setData("application/litflow", o), t.dataTransfer.effectAllowed = "move");
|
|
1133
1162
|
}
|
|
1134
1163
|
render() {
|
|
1135
|
-
return
|
|
1164
|
+
return O`
|
|
1136
1165
|
<div class="sidebar-title">Node Palette</div>
|
|
1137
1166
|
<div class="node-palette">
|
|
1138
1167
|
${this.nodeTypes.map(
|
|
1139
|
-
(t) =>
|
|
1168
|
+
(t) => O`
|
|
1140
1169
|
<div
|
|
1141
1170
|
class="palette-item"
|
|
1142
1171
|
draggable="true"
|
|
@@ -1150,9 +1179,9 @@ let R = class extends z {
|
|
|
1150
1179
|
`;
|
|
1151
1180
|
}
|
|
1152
1181
|
};
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1182
|
+
H.styles = [
|
|
1183
|
+
F,
|
|
1184
|
+
B`
|
|
1156
1185
|
:host {
|
|
1157
1186
|
display: block;
|
|
1158
1187
|
width: 200px;
|
|
@@ -1200,21 +1229,21 @@ R.styles = [
|
|
|
1200
1229
|
}
|
|
1201
1230
|
`
|
|
1202
1231
|
];
|
|
1203
|
-
|
|
1232
|
+
K([
|
|
1204
1233
|
a({ type: Array })
|
|
1205
|
-
],
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
],
|
|
1234
|
+
], H.prototype, "nodeTypes", 2);
|
|
1235
|
+
H = K([
|
|
1236
|
+
C("lit-sidebar")
|
|
1237
|
+
], H);
|
|
1209
1238
|
export {
|
|
1210
|
-
|
|
1239
|
+
R as LitControls,
|
|
1211
1240
|
b as LitEdge,
|
|
1212
|
-
|
|
1213
|
-
|
|
1241
|
+
u as LitFlow,
|
|
1242
|
+
I as LitHandle,
|
|
1214
1243
|
v as LitMinimap,
|
|
1215
1244
|
_ as LitNode,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1245
|
+
H as LitSidebar,
|
|
1246
|
+
dt as createInitialState,
|
|
1247
|
+
F as m3Tokens
|
|
1219
1248
|
};
|
|
1220
1249
|
//# sourceMappingURL=litflow.js.map
|