@ghchinoy/litflow 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/index.d.ts +1 -0
- package/dist/lit-flow.d.ts +15 -0
- package/dist/lit-node.d.ts +2 -0
- package/dist/lit-sidebar.d.ts +10 -0
- package/dist/litflow.js +420 -253
- package/dist/litflow.js.map +1 -1
- package/dist/theme.js +4 -0
- package/dist/theme.js.map +1 -1
- package/package.json +3 -1
- package/src/index.ts +1 -0
- package/src/lit-controls.ts +12 -11
- package/src/lit-flow.ts +92 -1
- package/src/lit-minimap.ts +4 -4
- package/src/lit-node.ts +7 -1
- package/src/lit-sidebar.ts +90 -0
- package/src/theme.ts +4 -0
package/dist/litflow.js
CHANGED
|
@@ -1,80 +1,86 @@
|
|
|
1
|
-
import { LitElement as P, html as
|
|
2
|
-
import { unsafeStatic as
|
|
3
|
-
import { property as a, customElement as z, query as
|
|
4
|
-
import { signal as
|
|
5
|
-
import { infiniteExtent as
|
|
6
|
-
import { m3Tokens as
|
|
7
|
-
function
|
|
1
|
+
import { LitElement as P, html as v, svg as Z, css as I } from "lit";
|
|
2
|
+
import { unsafeStatic as J, html as L } from "lit/static-html.js";
|
|
3
|
+
import { property as a, customElement as z, query as V, state as N } from "lit/decorators.js";
|
|
4
|
+
import { signal as A, SignalWatcher as B } from "@lit-labs/signals";
|
|
5
|
+
import { infiniteExtent as Q, Position as S, getBezierPath as H, adoptUserNodes as tt, updateAbsolutePositions as T, XYPanZoom as et, PanOnScrollMode as M, XYDrag as ot, getHandlePosition as X, getSmoothStepPath as Y, getStraightPath as st, XYHandle as nt, ConnectionMode as rt, XYMinimap as it, getBoundsOfRects as at, getInternalNodesBounds as dt } from "@xyflow/system";
|
|
6
|
+
import { m3Tokens as W } from "./theme.js";
|
|
7
|
+
function lt() {
|
|
8
8
|
return {
|
|
9
|
-
nodes:
|
|
10
|
-
edges:
|
|
9
|
+
nodes: A([]),
|
|
10
|
+
edges: A([]),
|
|
11
11
|
nodeLookup: /* @__PURE__ */ new Map(),
|
|
12
12
|
parentLookup: /* @__PURE__ */ new Map(),
|
|
13
|
-
nodeExtent:
|
|
13
|
+
nodeExtent: Q,
|
|
14
14
|
snapGrid: [15, 15],
|
|
15
15
|
snapToGrid: !1,
|
|
16
16
|
nodeOrigin: [0, 0],
|
|
17
17
|
multiSelectionActive: !1,
|
|
18
|
-
transform:
|
|
18
|
+
transform: A([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: A(null)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
var
|
|
29
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
28
|
+
var pt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, w = (t, o, e, n) => {
|
|
29
|
+
for (var s = n > 1 ? void 0 : n ? ht(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
30
30
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
31
|
-
return n && s &&
|
|
31
|
+
return n && s && pt(o, e, s), s;
|
|
32
32
|
};
|
|
33
|
-
let
|
|
33
|
+
let b = class extends B(P) {
|
|
34
34
|
constructor() {
|
|
35
|
-
super(...arguments), this.label = "", this.type = "default", this.data = {}, this.selected = !1, this.nodeId = "";
|
|
35
|
+
super(...arguments), this.label = "", this.type = "default", this.data = {}, this.selected = !1, this.nodeId = "", this.positionX = 0, this.positionY = 0;
|
|
36
36
|
}
|
|
37
37
|
createRenderRoot() {
|
|
38
38
|
return this;
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return
|
|
42
|
-
<div class="label" style="font-size:
|
|
41
|
+
return v`
|
|
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" ? v`<lit-handle type="source" data-handlepos="bottom" data-nodeid="${this.nodeId}"></lit-handle>` : ""}
|
|
45
|
+
${this.type === "output" || this.type === "default" ? v`<lit-handle type="target" data-handlepos="top" data-nodeid="${this.nodeId}"></lit-handle>` : ""}
|
|
46
46
|
`;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
w([
|
|
50
50
|
a({ type: String })
|
|
51
|
-
],
|
|
52
|
-
|
|
51
|
+
], b.prototype, "label", 2);
|
|
52
|
+
w([
|
|
53
53
|
a({ type: String, reflect: !0 })
|
|
54
|
-
],
|
|
55
|
-
|
|
54
|
+
], b.prototype, "type", 2);
|
|
55
|
+
w([
|
|
56
56
|
a({ type: Object })
|
|
57
|
-
],
|
|
58
|
-
|
|
57
|
+
], b.prototype, "data", 2);
|
|
58
|
+
w([
|
|
59
59
|
a({ type: Boolean, reflect: !0 })
|
|
60
|
-
],
|
|
61
|
-
|
|
60
|
+
], b.prototype, "selected", 2);
|
|
61
|
+
w([
|
|
62
62
|
a({ type: String, attribute: "data-id", reflect: !0 })
|
|
63
|
-
],
|
|
64
|
-
|
|
63
|
+
], b.prototype, "nodeId", 2);
|
|
64
|
+
w([
|
|
65
|
+
a({ type: Number, attribute: "position-x" })
|
|
66
|
+
], b.prototype, "positionX", 2);
|
|
67
|
+
w([
|
|
68
|
+
a({ type: Number, attribute: "position-y" })
|
|
69
|
+
], b.prototype, "positionY", 2);
|
|
70
|
+
b = w([
|
|
65
71
|
z("lit-node")
|
|
66
|
-
],
|
|
67
|
-
var
|
|
68
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
72
|
+
], b);
|
|
73
|
+
var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, x = (t, o, e, n) => {
|
|
74
|
+
for (var s = n > 1 ? void 0 : n ? ut(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
69
75
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
70
|
-
return n && s &&
|
|
76
|
+
return n && s && ct(o, e, s), s;
|
|
71
77
|
};
|
|
72
|
-
let
|
|
78
|
+
let g = class extends B(P) {
|
|
73
79
|
constructor() {
|
|
74
|
-
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 = S.Right, this.targetPosition = S.Left, this.selected = !1;
|
|
75
81
|
}
|
|
76
82
|
render() {
|
|
77
|
-
const [t] =
|
|
83
|
+
const [t] = H({
|
|
78
84
|
sourceX: this.sourceX,
|
|
79
85
|
sourceY: this.sourceY,
|
|
80
86
|
sourcePosition: this.sourcePosition,
|
|
@@ -87,7 +93,7 @@ let m = class extends B(P) {
|
|
|
87
93
|
`;
|
|
88
94
|
}
|
|
89
95
|
};
|
|
90
|
-
|
|
96
|
+
g.styles = I`
|
|
91
97
|
:host {
|
|
92
98
|
display: contents;
|
|
93
99
|
}
|
|
@@ -102,52 +108,52 @@ m.styles = A`
|
|
|
102
108
|
stroke: #555;
|
|
103
109
|
}
|
|
104
110
|
`;
|
|
105
|
-
|
|
111
|
+
x([
|
|
106
112
|
a({ type: Number })
|
|
107
|
-
],
|
|
108
|
-
|
|
113
|
+
], g.prototype, "sourceX", 2);
|
|
114
|
+
x([
|
|
109
115
|
a({ type: Number })
|
|
110
|
-
],
|
|
111
|
-
|
|
116
|
+
], g.prototype, "sourceY", 2);
|
|
117
|
+
x([
|
|
112
118
|
a({ type: Number })
|
|
113
|
-
],
|
|
114
|
-
|
|
119
|
+
], g.prototype, "targetX", 2);
|
|
120
|
+
x([
|
|
115
121
|
a({ type: Number })
|
|
116
|
-
],
|
|
117
|
-
|
|
122
|
+
], g.prototype, "targetY", 2);
|
|
123
|
+
x([
|
|
118
124
|
a({ type: String })
|
|
119
|
-
],
|
|
120
|
-
|
|
125
|
+
], g.prototype, "sourcePosition", 2);
|
|
126
|
+
x([
|
|
121
127
|
a({ type: String })
|
|
122
|
-
],
|
|
123
|
-
|
|
128
|
+
], g.prototype, "targetPosition", 2);
|
|
129
|
+
x([
|
|
124
130
|
a({ type: Boolean, reflect: !0 })
|
|
125
|
-
],
|
|
126
|
-
|
|
131
|
+
], g.prototype, "selected", 2);
|
|
132
|
+
g = x([
|
|
127
133
|
z("lit-edge")
|
|
128
|
-
],
|
|
129
|
-
var
|
|
130
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
134
|
+
], g);
|
|
135
|
+
var ft = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, f = (t, o, e, n) => {
|
|
136
|
+
for (var s = n > 1 ? void 0 : n ? mt(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
131
137
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
132
|
-
return n && s &&
|
|
138
|
+
return n && s && ft(o, e, s), s;
|
|
133
139
|
};
|
|
134
|
-
const
|
|
140
|
+
const _ = {
|
|
135
141
|
fromAttribute: (t) => t !== "false" && t !== null,
|
|
136
142
|
toAttribute: (t) => t ? "" : null
|
|
137
143
|
};
|
|
138
|
-
let
|
|
144
|
+
let c = class extends B(P) {
|
|
139
145
|
constructor() {
|
|
140
|
-
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state =
|
|
146
|
+
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state = lt(), this.nodeTypes = {
|
|
141
147
|
default: "lit-node",
|
|
142
148
|
input: "lit-node",
|
|
143
149
|
output: "lit-node"
|
|
144
|
-
}, this.showControls = !1, this.showMinimap = !1, this.showGrid = !0, this.nodesDraggable = !0, this.nodesConnectable = !0, this.panOnDrag = !0, this.zoomOnScroll = !0, this.zoomOnPinch = !0, this.zoomOnDoubleClick = !0, this._width = 0, this._height = 0, this.viewport = { x: 0, y: 0, zoom: 1 };
|
|
150
|
+
}, this.showControls = !1, this.showMinimap = !1, this.showGrid = !0, this.nodesDraggable = !0, this.nodesConnectable = !0, this.panOnDrag = !0, this.zoomOnScroll = !0, this.zoomOnPinch = !0, this.zoomOnDoubleClick = !0, this.promptOnDrop = !1, this._width = 0, this._height = 0, this.viewport = { x: 0, y: 0, zoom: 1 };
|
|
145
151
|
}
|
|
146
152
|
set nodes(t) {
|
|
147
|
-
this._state.nodes.set(t),
|
|
153
|
+
this._state.nodes.set(t), tt(t, this._state.nodeLookup, this._state.parentLookup, {
|
|
148
154
|
nodeOrigin: this._state.nodeOrigin,
|
|
149
155
|
nodeExtent: this._state.nodeExtent
|
|
150
|
-
}),
|
|
156
|
+
}), T(this._state.nodeLookup, this._state.parentLookup, {
|
|
151
157
|
nodeOrigin: this._state.nodeOrigin,
|
|
152
158
|
nodeExtent: this._state.nodeExtent
|
|
153
159
|
});
|
|
@@ -155,6 +161,27 @@ let u = class extends B(P) {
|
|
|
155
161
|
get nodes() {
|
|
156
162
|
return this._state.nodes.get();
|
|
157
163
|
}
|
|
164
|
+
_discoverNodes() {
|
|
165
|
+
if (this.nodes.length > 0) return;
|
|
166
|
+
const t = Array.from(this.querySelectorAll("lit-node"));
|
|
167
|
+
if (t.length > 0) {
|
|
168
|
+
const o = t.map((e) => ({
|
|
169
|
+
id: e.id || e.getAttribute("id") || `node-${Math.random().toString(36).substr(2, 9)}`,
|
|
170
|
+
type: e.type || e.getAttribute("type") || "default",
|
|
171
|
+
position: {
|
|
172
|
+
x: parseFloat(e.getAttribute("position-x") || "0"),
|
|
173
|
+
y: parseFloat(e.getAttribute("position-y") || "0")
|
|
174
|
+
},
|
|
175
|
+
data: {
|
|
176
|
+
label: e.label || e.getAttribute("label") || "",
|
|
177
|
+
...e.data
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
this.nodes = o, t.forEach((e, n) => {
|
|
181
|
+
e.nodeId = o[n].id;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
158
185
|
set edges(t) {
|
|
159
186
|
this._state.edges.set(t);
|
|
160
187
|
}
|
|
@@ -162,7 +189,7 @@ let u = class extends B(P) {
|
|
|
162
189
|
return this._state.edges.get();
|
|
163
190
|
}
|
|
164
191
|
connectedCallback() {
|
|
165
|
-
super.connectedCallback(), this._resizeObserver = new ResizeObserver((t) => {
|
|
192
|
+
super.connectedCallback(), this._discoverNodes(), this._resizeObserver = new ResizeObserver((t) => {
|
|
166
193
|
for (const o of t)
|
|
167
194
|
if (o.target === this)
|
|
168
195
|
this._width = o.contentRect.width, this._height = o.contentRect.height;
|
|
@@ -184,28 +211,28 @@ let u = class extends B(P) {
|
|
|
184
211
|
width: n / r,
|
|
185
212
|
height: s / r
|
|
186
213
|
};
|
|
187
|
-
const i = this.nodes.find((
|
|
214
|
+
const i = this.nodes.find((h) => h.id === t);
|
|
188
215
|
i && (i.measured = e.measured);
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
const l =
|
|
194
|
-
id:
|
|
195
|
-
type:
|
|
196
|
-
position:
|
|
197
|
-
x: (l.left -
|
|
198
|
-
y: (l.top -
|
|
216
|
+
const p = o.querySelectorAll("lit-handle");
|
|
217
|
+
if (p && p.length > 0) {
|
|
218
|
+
const h = [], d = [];
|
|
219
|
+
p.forEach((u) => {
|
|
220
|
+
const l = u.getBoundingClientRect(), m = o.getBoundingClientRect(), O = {
|
|
221
|
+
id: u.handleId || null,
|
|
222
|
+
type: u.type,
|
|
223
|
+
position: u.position,
|
|
224
|
+
x: (l.left - m.left) / r,
|
|
225
|
+
y: (l.top - m.top) / r,
|
|
199
226
|
width: l.width / r,
|
|
200
227
|
height: l.height / r
|
|
201
228
|
};
|
|
202
|
-
|
|
229
|
+
u.type === "source" ? h.push(O) : d.push(O);
|
|
203
230
|
}), e.internals.handleBounds = {
|
|
204
|
-
source:
|
|
231
|
+
source: h,
|
|
205
232
|
target: d
|
|
206
233
|
}, console.log(`Node ${t} handleBounds:`, e.internals.handleBounds);
|
|
207
234
|
}
|
|
208
|
-
|
|
235
|
+
T(this._state.nodeLookup, this._state.parentLookup, {
|
|
209
236
|
nodeOrigin: this._state.nodeOrigin,
|
|
210
237
|
nodeExtent: this._state.nodeExtent
|
|
211
238
|
}), this._state.nodes.set([...this.nodes]);
|
|
@@ -215,10 +242,21 @@ let u = class extends B(P) {
|
|
|
215
242
|
const e = this.nodes.map((n) => n.id === t ? { ...n, selected: !n.selected } : o ? n : { ...n, selected: !1 });
|
|
216
243
|
this.nodes = e;
|
|
217
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Projects a screen position (relative to the flow container) to canvas coordinates.
|
|
247
|
+
* Useful for Drag & Drop and context menus.
|
|
248
|
+
*/
|
|
249
|
+
project(t) {
|
|
250
|
+
const [o, e, n] = this._state.transform.get();
|
|
251
|
+
return {
|
|
252
|
+
x: (t.x - o) / n,
|
|
253
|
+
y: (t.y - e) / n
|
|
254
|
+
};
|
|
255
|
+
}
|
|
218
256
|
firstUpdated() {
|
|
219
257
|
this._renderer && (this._state.domNode = this._renderer, this._resizeObserver?.observe(this._renderer), this._renderer.onclick = () => {
|
|
220
258
|
this.nodes = this.nodes.map((t) => ({ ...t, selected: !1 }));
|
|
221
|
-
}, this._panZoom =
|
|
259
|
+
}, this._panZoom = et({
|
|
222
260
|
domNode: this._renderer,
|
|
223
261
|
minZoom: 0.5,
|
|
224
262
|
maxZoom: 2,
|
|
@@ -282,33 +320,33 @@ let u = class extends B(P) {
|
|
|
282
320
|
return;
|
|
283
321
|
}
|
|
284
322
|
let s = this._drags.get(n);
|
|
285
|
-
s || (s =
|
|
323
|
+
s || (s = ot({
|
|
286
324
|
getStoreItems: () => ({
|
|
287
325
|
...this._state,
|
|
288
326
|
nodes: this._state.nodes.get(),
|
|
289
327
|
edges: this._state.edges.get(),
|
|
290
328
|
transform: this._state.transform.get(),
|
|
291
329
|
panBy: async (r) => {
|
|
292
|
-
const { panZoom: i, nodeExtent:
|
|
330
|
+
const { panZoom: i, nodeExtent: p } = this._state, h = this._state.transform.get();
|
|
293
331
|
return i ? !!await i.setViewportConstrained(
|
|
294
332
|
{
|
|
295
|
-
x:
|
|
296
|
-
y:
|
|
297
|
-
zoom:
|
|
333
|
+
x: h[0] + r.x,
|
|
334
|
+
y: h[1] + r.y,
|
|
335
|
+
zoom: h[2]
|
|
298
336
|
},
|
|
299
337
|
[[0, 0], [this.offsetWidth, this.offsetHeight]],
|
|
300
|
-
|
|
338
|
+
p
|
|
301
339
|
) : !1;
|
|
302
340
|
},
|
|
303
341
|
updateNodePositions: (r) => {
|
|
304
|
-
r.forEach((i,
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
const d = this.nodes.find((
|
|
342
|
+
r.forEach((i, p) => {
|
|
343
|
+
const h = this._state.nodeLookup.get(p);
|
|
344
|
+
if (h) {
|
|
345
|
+
h.position = i.position, h.internals.positionAbsolute = i.internals.positionAbsolute;
|
|
346
|
+
const d = this.nodes.find((u) => u.id === p);
|
|
309
347
|
d && (d.position = i.position);
|
|
310
348
|
}
|
|
311
|
-
}),
|
|
349
|
+
}), T(this._state.nodeLookup, this._state.parentLookup, {
|
|
312
350
|
nodeOrigin: this._state.nodeOrigin,
|
|
313
351
|
nodeExtent: this._state.nodeExtent
|
|
314
352
|
}), this._state.nodes.set([...this.nodes]);
|
|
@@ -336,7 +374,7 @@ let u = class extends B(P) {
|
|
|
336
374
|
id: null,
|
|
337
375
|
type: "source",
|
|
338
376
|
nodeId: t.source,
|
|
339
|
-
position:
|
|
377
|
+
position: S.Bottom,
|
|
340
378
|
x: (o.measured.width || 0) / 2,
|
|
341
379
|
y: o.measured.height || 0,
|
|
342
380
|
width: 1,
|
|
@@ -347,33 +385,33 @@ let u = class extends B(P) {
|
|
|
347
385
|
id: null,
|
|
348
386
|
type: "target",
|
|
349
387
|
nodeId: t.target,
|
|
350
|
-
position:
|
|
388
|
+
position: S.Top,
|
|
351
389
|
x: (e.measured.width || 0) / 2,
|
|
352
390
|
y: 0,
|
|
353
391
|
width: 1,
|
|
354
392
|
height: 1
|
|
355
|
-
},
|
|
393
|
+
}, p = X(o, r, r.position, !0), h = X(e, i, i.position, !0);
|
|
356
394
|
let d = "";
|
|
357
|
-
const
|
|
358
|
-
sourceX:
|
|
359
|
-
sourceY:
|
|
395
|
+
const u = {
|
|
396
|
+
sourceX: p.x,
|
|
397
|
+
sourceY: p.y,
|
|
360
398
|
sourcePosition: r.position,
|
|
361
|
-
targetX:
|
|
362
|
-
targetY:
|
|
399
|
+
targetX: h.x,
|
|
400
|
+
targetY: h.y,
|
|
363
401
|
targetPosition: i.position
|
|
364
402
|
};
|
|
365
403
|
switch (t.type) {
|
|
366
404
|
case "straight":
|
|
367
|
-
[d] =
|
|
405
|
+
[d] = st(u);
|
|
368
406
|
break;
|
|
369
407
|
case "smoothstep":
|
|
370
|
-
[d] = Y(
|
|
408
|
+
[d] = Y(u);
|
|
371
409
|
break;
|
|
372
410
|
case "step":
|
|
373
|
-
[d] = Y({ ...
|
|
411
|
+
[d] = Y({ ...u, borderRadius: 0 });
|
|
374
412
|
break;
|
|
375
413
|
default:
|
|
376
|
-
[d] =
|
|
414
|
+
[d] = H(u);
|
|
377
415
|
break;
|
|
378
416
|
}
|
|
379
417
|
return Z`
|
|
@@ -390,38 +428,38 @@ let u = class extends B(P) {
|
|
|
390
428
|
const { event: o, handleId: e, nodeId: n, type: s, handleDomNode: r } = t.detail, i = s === "target";
|
|
391
429
|
if (this._state.connectionInProgress.get() || !this.nodesConnectable)
|
|
392
430
|
return;
|
|
393
|
-
const
|
|
431
|
+
const p = r.getBoundingClientRect(), h = r.parentElement?.getBoundingClientRect(), d = this._state.transform.get()[2], u = {
|
|
394
432
|
id: e,
|
|
395
433
|
nodeId: n,
|
|
396
434
|
type: s,
|
|
397
435
|
position: r.position,
|
|
398
|
-
x: (
|
|
399
|
-
y: (
|
|
400
|
-
width:
|
|
401
|
-
height:
|
|
436
|
+
x: (p.left - (h?.left ?? 0)) / d,
|
|
437
|
+
y: (p.top - (h?.top ?? 0)) / d,
|
|
438
|
+
width: p.width / d,
|
|
439
|
+
height: p.height / d
|
|
402
440
|
};
|
|
403
|
-
|
|
441
|
+
nt.onPointerDown(o, {
|
|
404
442
|
handleId: e,
|
|
405
443
|
nodeId: n,
|
|
406
444
|
isTarget: i,
|
|
407
445
|
domNode: this._renderer,
|
|
408
446
|
handleDomNode: r,
|
|
409
447
|
nodeLookup: this._state.nodeLookup,
|
|
410
|
-
connectionMode:
|
|
448
|
+
connectionMode: rt.Strict,
|
|
411
449
|
lib: "lit",
|
|
412
450
|
autoPanOnConnect: !0,
|
|
413
451
|
flowId: "lit-flow",
|
|
414
452
|
dragThreshold: 0,
|
|
415
453
|
panBy: async (l) => {
|
|
416
|
-
const
|
|
417
|
-
return
|
|
418
|
-
x:
|
|
419
|
-
y:
|
|
420
|
-
zoom:
|
|
454
|
+
const m = this._panZoom?.getViewport();
|
|
455
|
+
return m ? (await this._panZoom?.setViewport({
|
|
456
|
+
x: m.x + l.x,
|
|
457
|
+
y: m.y + l.y,
|
|
458
|
+
zoom: m.zoom
|
|
421
459
|
}), !0) : !1;
|
|
422
460
|
},
|
|
423
461
|
getTransform: () => this._state.transform.get(),
|
|
424
|
-
getFromHandle: () =>
|
|
462
|
+
getFromHandle: () => u,
|
|
425
463
|
updateConnection: (l) => {
|
|
426
464
|
l.inProgress ? this._state.connectionInProgress.set(l) : this._state.connectionInProgress.set(null);
|
|
427
465
|
},
|
|
@@ -432,15 +470,43 @@ let u = class extends B(P) {
|
|
|
432
470
|
this.dispatchEvent(new CustomEvent("connect", {
|
|
433
471
|
detail: l
|
|
434
472
|
}));
|
|
435
|
-
const
|
|
436
|
-
this.edges = [...this.edges, { ...l, id:
|
|
473
|
+
const m = `e-${l.source}${l.sourceHandle || ""}-${l.target}${l.targetHandle || ""}`;
|
|
474
|
+
this.edges = [...this.edges, { ...l, id: m }];
|
|
437
475
|
},
|
|
438
476
|
connectionRadius: 20
|
|
439
477
|
});
|
|
440
478
|
}
|
|
479
|
+
_onDragOver(t) {
|
|
480
|
+
t.preventDefault(), t.dataTransfer && (t.dataTransfer.dropEffect = "move");
|
|
481
|
+
}
|
|
482
|
+
_onDrop(t) {
|
|
483
|
+
t.preventDefault();
|
|
484
|
+
const o = t.dataTransfer?.getData("application/litflow");
|
|
485
|
+
if (typeof o > "u" || !o)
|
|
486
|
+
return;
|
|
487
|
+
const e = this.getBoundingClientRect(), n = this.project({
|
|
488
|
+
x: t.clientX - e.left,
|
|
489
|
+
y: t.clientY - e.top
|
|
490
|
+
});
|
|
491
|
+
let s = `${o} node`;
|
|
492
|
+
if (this.promptOnDrop) {
|
|
493
|
+
const i = window.prompt("Enter node label:", s);
|
|
494
|
+
if (i === null) return;
|
|
495
|
+
s = i || s;
|
|
496
|
+
}
|
|
497
|
+
const r = {
|
|
498
|
+
id: `node_${Date.now()}`,
|
|
499
|
+
type: o,
|
|
500
|
+
position: n,
|
|
501
|
+
data: { label: s }
|
|
502
|
+
};
|
|
503
|
+
this.nodes = [...this.nodes, r], this.dispatchEvent(new CustomEvent("node-drop", {
|
|
504
|
+
detail: { node: r, event: t }
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
441
507
|
_renderConnectionLine(t) {
|
|
442
508
|
if (!t) return null;
|
|
443
|
-
const [o] =
|
|
509
|
+
const [o] = H({
|
|
444
510
|
sourceX: t.from.x,
|
|
445
511
|
sourceY: t.from.y,
|
|
446
512
|
sourcePosition: t.fromPosition,
|
|
@@ -461,8 +527,12 @@ let u = class extends B(P) {
|
|
|
461
527
|
}
|
|
462
528
|
render() {
|
|
463
529
|
const t = this._state.transform.get(), o = this._state.connectionInProgress.get();
|
|
464
|
-
return
|
|
465
|
-
<div
|
|
530
|
+
return L`
|
|
531
|
+
<div
|
|
532
|
+
class="xyflow__renderer ${this.showGrid ? "has-grid" : ""}"
|
|
533
|
+
@dragover="${this._onDragOver}"
|
|
534
|
+
@drop="${this._onDrop}"
|
|
535
|
+
>
|
|
466
536
|
<div
|
|
467
537
|
class="xyflow__viewport"
|
|
468
538
|
style="transform: translate(${t[0]}px, ${t[1]}px) scale(${t[2]})"
|
|
@@ -470,14 +540,14 @@ let u = class extends B(P) {
|
|
|
470
540
|
<div class="xyflow__nodes" @handle-pointer-down="${this._onHandlePointerDown}">
|
|
471
541
|
${this.nodes.map((e) => {
|
|
472
542
|
if (e.hidden) return null;
|
|
473
|
-
const s = this._state.nodeLookup.get(e.id)?.internals.positionAbsolute || e.position, r = this.nodeTypes[e.type || "default"] || this.nodeTypes.default, i =
|
|
474
|
-
return
|
|
543
|
+
const s = this._state.nodeLookup.get(e.id)?.internals.positionAbsolute || e.position, r = this.nodeTypes[e.type || "default"] || this.nodeTypes.default, i = J(r), p = e.style || {}, h = Object.entries(p).map(([k, C]) => `${k.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${typeof C == "number" ? `${C}px` : C}`).join("; "), d = e.width || p.width, u = e.height || p.height, l = d ? `width: ${typeof d == "number" ? `${d}px` : d};` : "", m = u ? `height: ${typeof u == "number" ? `${u}px` : u};` : "", O = e.zIndex ? `z-index: ${e.zIndex};` : "";
|
|
544
|
+
return L`
|
|
475
545
|
<${i}
|
|
476
546
|
class="xyflow__node"
|
|
477
547
|
data-id="${e.id}"
|
|
478
548
|
type="${e.type || "default"}"
|
|
479
549
|
.nodeId="${e.id}"
|
|
480
|
-
style="transform: translate(${s.x}px, ${s.y}px); ${
|
|
550
|
+
style="transform: translate(${s.x}px, ${s.y}px); ${h} ${l} ${m} ${O}"
|
|
481
551
|
.data="${e.data}"
|
|
482
552
|
.label="${e.data.label}"
|
|
483
553
|
.type="${e.type || "default"}"
|
|
@@ -493,8 +563,8 @@ let u = class extends B(P) {
|
|
|
493
563
|
</svg>
|
|
494
564
|
</div>
|
|
495
565
|
</div>
|
|
496
|
-
${this.showControls ?
|
|
497
|
-
${this.showMinimap ?
|
|
566
|
+
${this.showControls ? L`<lit-controls .panZoom="${this._panZoom}"></lit-controls>` : ""}
|
|
567
|
+
${this.showMinimap ? L`
|
|
498
568
|
<lit-minimap
|
|
499
569
|
.panZoom="${this._panZoom}"
|
|
500
570
|
.nodeLookup="${this._state.nodeLookup}"
|
|
@@ -504,12 +574,13 @@ let u = class extends B(P) {
|
|
|
504
574
|
.height="${this._height}"
|
|
505
575
|
></lit-minimap>
|
|
506
576
|
` : ""}
|
|
577
|
+
<slot style="display: none;"></slot>
|
|
507
578
|
`;
|
|
508
579
|
}
|
|
509
580
|
};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
581
|
+
c.styles = [
|
|
582
|
+
W,
|
|
583
|
+
I`
|
|
513
584
|
:host {
|
|
514
585
|
display: block;
|
|
515
586
|
width: 100%;
|
|
@@ -664,74 +735,77 @@ u.styles = [
|
|
|
664
735
|
}
|
|
665
736
|
`
|
|
666
737
|
];
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
],
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
],
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
],
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
],
|
|
679
|
-
|
|
738
|
+
f([
|
|
739
|
+
V(".xyflow__renderer")
|
|
740
|
+
], c.prototype, "_renderer", 2);
|
|
741
|
+
f([
|
|
742
|
+
V(".xyflow__viewport")
|
|
743
|
+
], c.prototype, "_viewport", 2);
|
|
744
|
+
f([
|
|
745
|
+
N()
|
|
746
|
+
], c.prototype, "_panZoom", 2);
|
|
747
|
+
f([
|
|
748
|
+
N()
|
|
749
|
+
], c.prototype, "_state", 2);
|
|
750
|
+
f([
|
|
680
751
|
a({ type: Object })
|
|
681
|
-
],
|
|
682
|
-
|
|
752
|
+
], c.prototype, "nodeTypes", 2);
|
|
753
|
+
f([
|
|
683
754
|
a({ type: Boolean, attribute: "show-controls", reflect: !0 })
|
|
684
|
-
],
|
|
685
|
-
|
|
686
|
-
a({ type: Boolean, attribute: "show-minimap", reflect: !0, converter:
|
|
687
|
-
],
|
|
688
|
-
|
|
689
|
-
a({ type: Boolean, attribute: "show-grid", reflect: !0, converter:
|
|
690
|
-
],
|
|
691
|
-
|
|
692
|
-
a({ type: Boolean, attribute: "nodes-draggable", reflect: !0, converter:
|
|
693
|
-
],
|
|
694
|
-
|
|
695
|
-
a({ type: Boolean, attribute: "nodes-connectable", reflect: !0, converter:
|
|
696
|
-
],
|
|
697
|
-
|
|
698
|
-
a({ type: Boolean, attribute: "pan-on-drag", reflect: !0, converter:
|
|
699
|
-
],
|
|
700
|
-
|
|
701
|
-
a({ type: Boolean, attribute: "zoom-on-scroll", reflect: !0, converter:
|
|
702
|
-
],
|
|
703
|
-
|
|
704
|
-
a({ type: Boolean, attribute: "zoom-on-pinch", reflect: !0, converter:
|
|
705
|
-
],
|
|
706
|
-
|
|
707
|
-
a({ type: Boolean, attribute: "zoom-on-double-click", reflect: !0, converter:
|
|
708
|
-
],
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
],
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
],
|
|
715
|
-
|
|
755
|
+
], c.prototype, "showControls", 2);
|
|
756
|
+
f([
|
|
757
|
+
a({ type: Boolean, attribute: "show-minimap", reflect: !0, converter: _ })
|
|
758
|
+
], c.prototype, "showMinimap", 2);
|
|
759
|
+
f([
|
|
760
|
+
a({ type: Boolean, attribute: "show-grid", reflect: !0, converter: _ })
|
|
761
|
+
], c.prototype, "showGrid", 2);
|
|
762
|
+
f([
|
|
763
|
+
a({ type: Boolean, attribute: "nodes-draggable", reflect: !0, converter: _ })
|
|
764
|
+
], c.prototype, "nodesDraggable", 2);
|
|
765
|
+
f([
|
|
766
|
+
a({ type: Boolean, attribute: "nodes-connectable", reflect: !0, converter: _ })
|
|
767
|
+
], c.prototype, "nodesConnectable", 2);
|
|
768
|
+
f([
|
|
769
|
+
a({ type: Boolean, attribute: "pan-on-drag", reflect: !0, converter: _ })
|
|
770
|
+
], c.prototype, "panOnDrag", 2);
|
|
771
|
+
f([
|
|
772
|
+
a({ type: Boolean, attribute: "zoom-on-scroll", reflect: !0, converter: _ })
|
|
773
|
+
], c.prototype, "zoomOnScroll", 2);
|
|
774
|
+
f([
|
|
775
|
+
a({ type: Boolean, attribute: "zoom-on-pinch", reflect: !0, converter: _ })
|
|
776
|
+
], c.prototype, "zoomOnPinch", 2);
|
|
777
|
+
f([
|
|
778
|
+
a({ type: Boolean, attribute: "zoom-on-double-click", reflect: !0, converter: _ })
|
|
779
|
+
], c.prototype, "zoomOnDoubleClick", 2);
|
|
780
|
+
f([
|
|
781
|
+
a({ type: Boolean, attribute: "prompt-on-drop", reflect: !0, converter: _ })
|
|
782
|
+
], c.prototype, "promptOnDrop", 2);
|
|
783
|
+
f([
|
|
784
|
+
N()
|
|
785
|
+
], c.prototype, "_width", 2);
|
|
786
|
+
f([
|
|
787
|
+
N()
|
|
788
|
+
], c.prototype, "_height", 2);
|
|
789
|
+
f([
|
|
716
790
|
a({ type: Array })
|
|
717
|
-
],
|
|
718
|
-
|
|
791
|
+
], c.prototype, "nodes", 1);
|
|
792
|
+
f([
|
|
719
793
|
a({ type: Array })
|
|
720
|
-
],
|
|
721
|
-
|
|
794
|
+
], c.prototype, "edges", 1);
|
|
795
|
+
f([
|
|
722
796
|
a({ type: Object })
|
|
723
|
-
],
|
|
724
|
-
|
|
797
|
+
], c.prototype, "viewport", 2);
|
|
798
|
+
c = f([
|
|
725
799
|
z("lit-flow")
|
|
726
|
-
],
|
|
727
|
-
var gt = Object.defineProperty,
|
|
728
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
800
|
+
], c);
|
|
801
|
+
var gt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, E = (t, o, e, n) => {
|
|
802
|
+
for (var s = n > 1 ? void 0 : n ? yt(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
729
803
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
730
804
|
return n && s && gt(o, e, s), s;
|
|
731
805
|
};
|
|
732
|
-
let
|
|
806
|
+
let D = class extends P {
|
|
733
807
|
constructor() {
|
|
734
|
-
super(), this.type = "source", this.position =
|
|
808
|
+
super(), this.type = "source", this.position = S.Top, this.addEventListener("mousedown", (t) => this._onPointerDown(t)), this.addEventListener("touchstart", (t) => this._onPointerDown(t));
|
|
735
809
|
}
|
|
736
810
|
createRenderRoot() {
|
|
737
811
|
return this;
|
|
@@ -758,7 +832,7 @@ let O = class extends P {
|
|
|
758
832
|
(t.has("nodeId") || t.has("handleId") || t.has("type")) && this.setAttribute("data-id", `lit-flow-${this.nodeId || ""}-${this.handleId || ""}-${this.type}`);
|
|
759
833
|
}
|
|
760
834
|
render() {
|
|
761
|
-
return
|
|
835
|
+
return v`
|
|
762
836
|
<div style="
|
|
763
837
|
width: 100%;
|
|
764
838
|
height: 100%;
|
|
@@ -769,25 +843,25 @@ let O = class extends P {
|
|
|
769
843
|
`;
|
|
770
844
|
}
|
|
771
845
|
};
|
|
772
|
-
|
|
846
|
+
E([
|
|
773
847
|
a({ type: String, reflect: !0 })
|
|
774
|
-
],
|
|
775
|
-
|
|
848
|
+
], D.prototype, "type", 2);
|
|
849
|
+
E([
|
|
776
850
|
a({ type: String, reflect: !0, attribute: "data-handlepos" })
|
|
777
|
-
],
|
|
778
|
-
|
|
851
|
+
], D.prototype, "position", 2);
|
|
852
|
+
E([
|
|
779
853
|
a({ type: String, reflect: !0, attribute: "data-handleid" })
|
|
780
|
-
],
|
|
781
|
-
|
|
854
|
+
], D.prototype, "handleId", 2);
|
|
855
|
+
E([
|
|
782
856
|
a({ type: String, reflect: !0, attribute: "data-nodeid" })
|
|
783
|
-
],
|
|
784
|
-
|
|
857
|
+
], D.prototype, "nodeId", 2);
|
|
858
|
+
D = E([
|
|
785
859
|
z("lit-handle")
|
|
786
|
-
],
|
|
787
|
-
var
|
|
788
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
860
|
+
], D);
|
|
861
|
+
var bt = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, F = (t, o, e, n) => {
|
|
862
|
+
for (var s = n > 1 ? void 0 : n ? _t(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
789
863
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
790
|
-
return n && s &&
|
|
864
|
+
return n && s && bt(o, e, s), s;
|
|
791
865
|
};
|
|
792
866
|
let R = class extends B(P) {
|
|
793
867
|
_zoomIn() {
|
|
@@ -800,7 +874,7 @@ let R = class extends B(P) {
|
|
|
800
874
|
this.panZoom?.setViewport({ x: 0, y: 0, zoom: 1 });
|
|
801
875
|
}
|
|
802
876
|
render() {
|
|
803
|
-
return
|
|
877
|
+
return v`
|
|
804
878
|
<button @click="${this._zoomIn}" title="Zoom In">
|
|
805
879
|
<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
|
806
880
|
</button>
|
|
@@ -813,26 +887,26 @@ let R = class extends B(P) {
|
|
|
813
887
|
`;
|
|
814
888
|
}
|
|
815
889
|
};
|
|
816
|
-
R.styles =
|
|
890
|
+
R.styles = I`
|
|
817
891
|
:host {
|
|
818
892
|
display: block;
|
|
819
893
|
position: absolute;
|
|
820
|
-
left:
|
|
821
|
-
bottom:
|
|
894
|
+
left: 16px;
|
|
895
|
+
bottom: 16px;
|
|
822
896
|
z-index: 5;
|
|
823
897
|
display: flex;
|
|
824
898
|
flex-direction: column;
|
|
825
|
-
gap:
|
|
899
|
+
gap: 2px;
|
|
826
900
|
background: var(--md-sys-color-surface);
|
|
827
901
|
padding: 4px;
|
|
828
|
-
border-radius: var(--md-sys-shape-corner-
|
|
902
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
829
903
|
box-shadow: var(--md-sys-elevation-1);
|
|
830
904
|
border: 1px solid var(--md-sys-color-outline-variant);
|
|
831
905
|
}
|
|
832
906
|
|
|
833
907
|
button {
|
|
834
|
-
width:
|
|
835
|
-
height:
|
|
908
|
+
width: 32px;
|
|
909
|
+
height: 32px;
|
|
836
910
|
display: flex;
|
|
837
911
|
align-items: center;
|
|
838
912
|
justify-content: center;
|
|
@@ -841,30 +915,31 @@ R.styles = A`
|
|
|
841
915
|
border-radius: var(--md-sys-shape-corner-extra-small);
|
|
842
916
|
cursor: pointer;
|
|
843
917
|
padding: 0;
|
|
844
|
-
color: var(--md-sys-color-on-surface);
|
|
845
|
-
transition: background-color 0.2s ease;
|
|
918
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
919
|
+
transition: background-color 0.2s ease, color 0.2s ease;
|
|
846
920
|
}
|
|
847
921
|
|
|
848
922
|
button:hover {
|
|
849
|
-
background: var(--md-sys-color-
|
|
923
|
+
background: var(--md-sys-color-secondary-container);
|
|
924
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
850
925
|
}
|
|
851
926
|
|
|
852
927
|
button svg {
|
|
853
|
-
width:
|
|
854
|
-
height:
|
|
928
|
+
width: 20px;
|
|
929
|
+
height: 20px;
|
|
855
930
|
fill: currentColor;
|
|
856
931
|
}
|
|
857
932
|
`;
|
|
858
|
-
|
|
933
|
+
F([
|
|
859
934
|
a({ type: Object })
|
|
860
935
|
], R.prototype, "panZoom", 2);
|
|
861
|
-
R =
|
|
936
|
+
R = F([
|
|
862
937
|
z("lit-controls")
|
|
863
938
|
], R);
|
|
864
|
-
var
|
|
865
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
939
|
+
var vt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, $ = (t, o, e, n) => {
|
|
940
|
+
for (var s = n > 1 ? void 0 : n ? wt(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
866
941
|
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
867
|
-
return n && s &&
|
|
942
|
+
return n && s && vt(o, e, s), s;
|
|
868
943
|
};
|
|
869
944
|
let y = class extends B(P) {
|
|
870
945
|
constructor() {
|
|
@@ -873,7 +948,7 @@ let y = class extends B(P) {
|
|
|
873
948
|
updated(t) {
|
|
874
949
|
if (!this._minimapInstance && this.panZoom) {
|
|
875
950
|
const o = this.shadowRoot?.querySelector("svg");
|
|
876
|
-
o && (this._minimapInstance =
|
|
951
|
+
o && (this._minimapInstance = it({
|
|
877
952
|
domNode: o,
|
|
878
953
|
panZoom: this.panZoom,
|
|
879
954
|
getTransform: () => this.transform,
|
|
@@ -896,7 +971,7 @@ let y = class extends B(P) {
|
|
|
896
971
|
width: this.width / this.transform[2],
|
|
897
972
|
height: this.height / this.transform[2]
|
|
898
973
|
};
|
|
899
|
-
return this.nodeLookup.size > 0 ?
|
|
974
|
+
return this.nodeLookup.size > 0 ? at(dt(this.nodeLookup), t) : t;
|
|
900
975
|
}
|
|
901
976
|
render() {
|
|
902
977
|
const t = this._getBoundingRect(), o = {
|
|
@@ -904,22 +979,22 @@ let y = class extends B(P) {
|
|
|
904
979
|
y: -this.transform[1] / this.transform[2],
|
|
905
980
|
width: this.width / this.transform[2],
|
|
906
981
|
height: this.height / this.transform[2]
|
|
907
|
-
}, e = 200, n = 150, s = t.width / e, r = t.height / n, i = Math.max(s, r),
|
|
908
|
-
return
|
|
982
|
+
}, e = 200, n = 150, s = t.width / e, r = t.height / n, i = Math.max(s, r), p = i * e, h = i * n, d = 5 * i, u = t.x - (p - t.width) / 2 - d, l = t.y - (h - t.height) / 2 - d, m = p + d * 2, O = h + d * 2;
|
|
983
|
+
return v`
|
|
909
984
|
<svg
|
|
910
985
|
width="${e}"
|
|
911
986
|
height="${n}"
|
|
912
|
-
viewBox="${
|
|
987
|
+
viewBox="${u} ${l} ${m} ${O}"
|
|
913
988
|
>
|
|
914
|
-
${Array.from(this.nodeLookup.values()).map((
|
|
915
|
-
const { x:
|
|
989
|
+
${Array.from(this.nodeLookup.values()).map((k) => {
|
|
990
|
+
const { x: C, y: G } = k.internals.positionAbsolute, K = k.measured.width || 0, U = k.measured.height || 0;
|
|
916
991
|
return Z`
|
|
917
992
|
<rect
|
|
918
993
|
class="minimap-node"
|
|
919
|
-
x="${
|
|
920
|
-
y="${
|
|
921
|
-
width="${
|
|
922
|
-
height="${
|
|
994
|
+
x="${C}"
|
|
995
|
+
y="${G}"
|
|
996
|
+
width="${K}"
|
|
997
|
+
height="${U}"
|
|
923
998
|
rx="2"
|
|
924
999
|
ry="2"
|
|
925
1000
|
/>
|
|
@@ -927,23 +1002,23 @@ let y = class extends B(P) {
|
|
|
927
1002
|
})}
|
|
928
1003
|
<path
|
|
929
1004
|
class="minimap-mask"
|
|
930
|
-
d="M${
|
|
1005
|
+
d="M${u - d},${l - d}h${m + d * 2}v${O + d * 2}h${-m - d * 2}z
|
|
931
1006
|
M${o.x},${o.y}h${o.width}v${o.height}h${-o.width}z"
|
|
932
1007
|
/>
|
|
933
1008
|
</svg>
|
|
934
1009
|
`;
|
|
935
1010
|
}
|
|
936
1011
|
};
|
|
937
|
-
y.styles =
|
|
1012
|
+
y.styles = I`
|
|
938
1013
|
:host {
|
|
939
1014
|
display: block;
|
|
940
1015
|
position: absolute;
|
|
941
|
-
right:
|
|
942
|
-
bottom:
|
|
1016
|
+
right: 16px;
|
|
1017
|
+
bottom: 16px;
|
|
943
1018
|
z-index: 5;
|
|
944
1019
|
background: var(--md-sys-color-surface);
|
|
945
1020
|
border: 1px solid var(--md-sys-color-outline-variant);
|
|
946
|
-
border-radius: var(--md-sys-shape-corner-
|
|
1021
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
947
1022
|
box-shadow: var(--md-sys-elevation-1);
|
|
948
1023
|
overflow: hidden;
|
|
949
1024
|
}
|
|
@@ -955,7 +1030,7 @@ y.styles = A`
|
|
|
955
1030
|
.minimap-node {
|
|
956
1031
|
fill: var(--md-sys-color-surface-variant);
|
|
957
1032
|
stroke: var(--md-sys-color-outline-variant);
|
|
958
|
-
stroke-width:
|
|
1033
|
+
stroke-width: 0.5;
|
|
959
1034
|
}
|
|
960
1035
|
|
|
961
1036
|
.minimap-mask {
|
|
@@ -963,38 +1038,130 @@ y.styles = A`
|
|
|
963
1038
|
fill-rule: evenodd;
|
|
964
1039
|
}
|
|
965
1040
|
`;
|
|
966
|
-
|
|
1041
|
+
$([
|
|
967
1042
|
a({ type: Object })
|
|
968
1043
|
], y.prototype, "panZoom", 2);
|
|
969
|
-
|
|
1044
|
+
$([
|
|
970
1045
|
a({ type: Object })
|
|
971
1046
|
], y.prototype, "nodeLookup", 2);
|
|
972
|
-
|
|
1047
|
+
$([
|
|
973
1048
|
a({ type: Array })
|
|
974
1049
|
], y.prototype, "transform", 2);
|
|
975
|
-
|
|
1050
|
+
$([
|
|
976
1051
|
a({ type: Array })
|
|
977
1052
|
], y.prototype, "translateExtent", 2);
|
|
978
|
-
|
|
1053
|
+
$([
|
|
979
1054
|
a({ type: Number })
|
|
980
1055
|
], y.prototype, "width", 2);
|
|
981
|
-
|
|
1056
|
+
$([
|
|
982
1057
|
a({ type: Number })
|
|
983
1058
|
], y.prototype, "height", 2);
|
|
984
|
-
|
|
985
|
-
|
|
1059
|
+
$([
|
|
1060
|
+
N()
|
|
986
1061
|
], y.prototype, "_minimapInstance", 2);
|
|
987
|
-
y =
|
|
1062
|
+
y = $([
|
|
988
1063
|
z("lit-minimap")
|
|
989
1064
|
], y);
|
|
1065
|
+
var xt = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, q = (t, o, e, n) => {
|
|
1066
|
+
for (var s = n > 1 ? void 0 : n ? $t(o, e) : o, r = t.length - 1, i; r >= 0; r--)
|
|
1067
|
+
(i = t[r]) && (s = (n ? i(o, e, s) : i(s)) || s);
|
|
1068
|
+
return n && s && xt(o, e, s), s;
|
|
1069
|
+
};
|
|
1070
|
+
let j = class extends P {
|
|
1071
|
+
constructor() {
|
|
1072
|
+
super(...arguments), this.nodeTypes = [
|
|
1073
|
+
{ type: "default", label: "Default Node" },
|
|
1074
|
+
{ type: "input", label: "Input Node" },
|
|
1075
|
+
{ type: "output", label: "Output Node" }
|
|
1076
|
+
];
|
|
1077
|
+
}
|
|
1078
|
+
_onDragStart(t, o) {
|
|
1079
|
+
t.dataTransfer && (t.dataTransfer.setData("application/litflow", o), t.dataTransfer.effectAllowed = "move");
|
|
1080
|
+
}
|
|
1081
|
+
render() {
|
|
1082
|
+
return v`
|
|
1083
|
+
<div class="sidebar-title">Node Palette</div>
|
|
1084
|
+
<div class="node-palette">
|
|
1085
|
+
${this.nodeTypes.map(
|
|
1086
|
+
(t) => v`
|
|
1087
|
+
<div
|
|
1088
|
+
class="palette-item"
|
|
1089
|
+
draggable="true"
|
|
1090
|
+
@dragstart="${(o) => this._onDragStart(o, t.type)}"
|
|
1091
|
+
>
|
|
1092
|
+
${t.label}
|
|
1093
|
+
</div>
|
|
1094
|
+
`
|
|
1095
|
+
)}
|
|
1096
|
+
</div>
|
|
1097
|
+
`;
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
j.styles = [
|
|
1101
|
+
W,
|
|
1102
|
+
I`
|
|
1103
|
+
:host {
|
|
1104
|
+
display: block;
|
|
1105
|
+
width: 200px;
|
|
1106
|
+
background: var(--md-sys-color-surface);
|
|
1107
|
+
border-right: 1px solid var(--md-sys-color-outline-variant);
|
|
1108
|
+
padding: 16px;
|
|
1109
|
+
box-sizing: border-box;
|
|
1110
|
+
height: 100%;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
.sidebar-title {
|
|
1114
|
+
font-family: var(--md-sys-typescale-body-medium-font);
|
|
1115
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
1116
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
1117
|
+
text-transform: uppercase;
|
|
1118
|
+
font-weight: bold;
|
|
1119
|
+
margin-bottom: 16px;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
.node-palette {
|
|
1123
|
+
display: flex;
|
|
1124
|
+
flex-direction: column;
|
|
1125
|
+
gap: 12px;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
.palette-item {
|
|
1129
|
+
padding: 12px;
|
|
1130
|
+
background: var(--md-sys-color-surface-container-low);
|
|
1131
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
1132
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
1133
|
+
cursor: grab;
|
|
1134
|
+
font-family: var(--md-sys-typescale-body-medium-font);
|
|
1135
|
+
font-size: var(--md-sys-typescale-body-medium-size);
|
|
1136
|
+
color: var(--md-sys-color-on-surface);
|
|
1137
|
+
user-select: none;
|
|
1138
|
+
transition: background-color 0.2s ease;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
.palette-item:hover {
|
|
1142
|
+
background: var(--md-sys-color-surface-container-high);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.palette-item:active {
|
|
1146
|
+
cursor: grabbing;
|
|
1147
|
+
}
|
|
1148
|
+
`
|
|
1149
|
+
];
|
|
1150
|
+
q([
|
|
1151
|
+
a({ type: Array })
|
|
1152
|
+
], j.prototype, "nodeTypes", 2);
|
|
1153
|
+
j = q([
|
|
1154
|
+
z("lit-sidebar")
|
|
1155
|
+
], j);
|
|
990
1156
|
export {
|
|
991
1157
|
R as LitControls,
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1158
|
+
g as LitEdge,
|
|
1159
|
+
c as LitFlow,
|
|
1160
|
+
D as LitHandle,
|
|
995
1161
|
y as LitMinimap,
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1162
|
+
b as LitNode,
|
|
1163
|
+
j as LitSidebar,
|
|
1164
|
+
lt as createInitialState,
|
|
1165
|
+
W as m3Tokens
|
|
999
1166
|
};
|
|
1000
1167
|
//# sourceMappingURL=litflow.js.map
|