@ghchinoy/litflow 0.2.2 → 0.2.6
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 +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/lit-flow.d.ts +16 -0
- package/dist/lit-gemini-image-node.d.ts +12 -0
- package/dist/lit-gemini-prompt-node.d.ts +12 -0
- package/dist/litflow.js +709 -406
- package/dist/litflow.js.map +1 -1
- package/dist/theme.js +1 -0
- package/dist/theme.js.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +2 -0
- package/src/lit-controls.ts +6 -5
- package/src/lit-flow.ts +342 -47
- package/src/lit-gemini-image-node.ts +72 -0
- package/src/lit-gemini-prompt-node.ts +92 -0
- package/src/theme.ts +1 -0
package/dist/litflow.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { unsafeStatic as
|
|
3
|
-
import { property 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 R, css as A } from "lit";
|
|
2
|
+
import { unsafeStatic as ot, html as B } from "lit/static-html.js";
|
|
3
|
+
import { property as d, customElement as O, query as q, state as N } from "lit/decorators.js";
|
|
4
|
+
import { signal as X, SignalWatcher as j } from "@lit-labs/signals";
|
|
5
|
+
import { infiniteExtent as st, Position as D, getBezierPath as W, adoptUserNodes as rt, updateAbsolutePositions as U, PanOnScrollMode as it, XYPanZoom as nt, XYDrag as at, getHandlePosition as K, getSmoothStepPath as F, getStraightPath as dt, XYHandle as lt, ConnectionMode as ht, XYMinimap as pt, getBoundsOfRects as ct, getInternalNodesBounds as ut } from "@xyflow/system";
|
|
6
|
+
import { m3Tokens as J } from "./theme.js";
|
|
7
|
+
function ft() {
|
|
8
8
|
return {
|
|
9
|
-
nodes:
|
|
10
|
-
edges:
|
|
9
|
+
nodes: X([]),
|
|
10
|
+
edges: X([]),
|
|
11
11
|
nodeLookup: /* @__PURE__ */ new Map(),
|
|
12
12
|
parentLookup: /* @__PURE__ */ new Map(),
|
|
13
|
-
nodeExtent:
|
|
13
|
+
nodeExtent: st,
|
|
14
14
|
snapGrid: [15, 15],
|
|
15
15
|
snapToGrid: !1,
|
|
16
16
|
nodeOrigin: [0, 0],
|
|
17
17
|
multiSelectionActive: !1,
|
|
18
|
-
transform:
|
|
18
|
+
transform: X([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: X(null)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
var
|
|
29
|
-
for (var
|
|
30
|
-
(
|
|
31
|
-
return
|
|
28
|
+
var mt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, z = (t, o, e, s) => {
|
|
29
|
+
for (var r = s > 1 ? void 0 : s ? yt(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
30
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
31
|
+
return s && r && mt(o, e, r), r;
|
|
32
32
|
};
|
|
33
|
-
let
|
|
33
|
+
let $ = class extends j(P) {
|
|
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 E(D) {
|
|
|
38
38
|
return this;
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return
|
|
41
|
+
return v`
|
|
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" ? 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
|
-
|
|
50
|
-
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
],
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
],
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
],
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
],
|
|
73
|
-
var
|
|
74
|
-
for (var
|
|
75
|
-
(
|
|
76
|
-
return
|
|
49
|
+
z([
|
|
50
|
+
d({ type: String })
|
|
51
|
+
], $.prototype, "label", 2);
|
|
52
|
+
z([
|
|
53
|
+
d({ type: String, reflect: !0 })
|
|
54
|
+
], $.prototype, "type", 2);
|
|
55
|
+
z([
|
|
56
|
+
d({ type: Object })
|
|
57
|
+
], $.prototype, "data", 2);
|
|
58
|
+
z([
|
|
59
|
+
d({ type: Boolean, reflect: !0 })
|
|
60
|
+
], $.prototype, "selected", 2);
|
|
61
|
+
z([
|
|
62
|
+
d({ type: String, attribute: "data-id", reflect: !0 })
|
|
63
|
+
], $.prototype, "nodeId", 2);
|
|
64
|
+
z([
|
|
65
|
+
d({ type: Number, attribute: "position-x" })
|
|
66
|
+
], $.prototype, "positionX", 2);
|
|
67
|
+
z([
|
|
68
|
+
d({ type: Number, attribute: "position-y" })
|
|
69
|
+
], $.prototype, "positionY", 2);
|
|
70
|
+
$ = z([
|
|
71
|
+
O("lit-node")
|
|
72
|
+
], $);
|
|
73
|
+
var gt = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, I = (t, o, e, s) => {
|
|
74
|
+
for (var r = s > 1 ? void 0 : s ? _t(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
75
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
76
|
+
return s && r && gt(o, e, r), r;
|
|
77
77
|
};
|
|
78
|
-
let
|
|
78
|
+
let w = class extends j(P) {
|
|
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 = D.Right, this.targetPosition = D.Left, this.selected = !1;
|
|
81
81
|
}
|
|
82
82
|
render() {
|
|
83
|
-
const [t] =
|
|
83
|
+
const [t] = W({
|
|
84
84
|
sourceX: this.sourceX,
|
|
85
85
|
sourceY: this.sourceY,
|
|
86
86
|
sourcePosition: this.sourcePosition,
|
|
@@ -88,12 +88,12 @@ let b = class extends E(D) {
|
|
|
88
88
|
targetY: this.targetY,
|
|
89
89
|
targetPosition: this.targetPosition
|
|
90
90
|
});
|
|
91
|
-
return
|
|
91
|
+
return R`
|
|
92
92
|
<path d="${t}" />
|
|
93
93
|
`;
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
|
|
96
|
+
w.styles = A`
|
|
97
97
|
:host {
|
|
98
98
|
display: contents;
|
|
99
99
|
}
|
|
@@ -108,59 +108,69 @@ b.styles = B`
|
|
|
108
108
|
stroke: #555;
|
|
109
109
|
}
|
|
110
110
|
`;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
],
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
],
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
],
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
],
|
|
135
|
-
var
|
|
136
|
-
for (var
|
|
137
|
-
(
|
|
138
|
-
return
|
|
111
|
+
I([
|
|
112
|
+
d({ type: Number })
|
|
113
|
+
], w.prototype, "sourceX", 2);
|
|
114
|
+
I([
|
|
115
|
+
d({ type: Number })
|
|
116
|
+
], w.prototype, "sourceY", 2);
|
|
117
|
+
I([
|
|
118
|
+
d({ type: Number })
|
|
119
|
+
], w.prototype, "targetX", 2);
|
|
120
|
+
I([
|
|
121
|
+
d({ type: Number })
|
|
122
|
+
], w.prototype, "targetY", 2);
|
|
123
|
+
I([
|
|
124
|
+
d({ type: String })
|
|
125
|
+
], w.prototype, "sourcePosition", 2);
|
|
126
|
+
I([
|
|
127
|
+
d({ type: String })
|
|
128
|
+
], w.prototype, "targetPosition", 2);
|
|
129
|
+
I([
|
|
130
|
+
d({ type: Boolean, reflect: !0 })
|
|
131
|
+
], w.prototype, "selected", 2);
|
|
132
|
+
w = I([
|
|
133
|
+
O("lit-edge")
|
|
134
|
+
], w);
|
|
135
|
+
var vt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, m = (t, o, e, s) => {
|
|
136
|
+
for (var r = s > 1 ? void 0 : s ? bt(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
137
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
138
|
+
return s && r && vt(o, e, r), r;
|
|
139
139
|
};
|
|
140
|
-
const
|
|
140
|
+
const k = {
|
|
141
141
|
fromAttribute: (t) => t !== "false" && t !== null,
|
|
142
142
|
toAttribute: (t) => t ? "" : null
|
|
143
143
|
};
|
|
144
|
-
let
|
|
144
|
+
let f = class extends j(P) {
|
|
145
145
|
constructor() {
|
|
146
|
-
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state =
|
|
146
|
+
super(...arguments), this._drags = /* @__PURE__ */ new Map(), this._state = ft(), this.nodeTypes = {
|
|
147
147
|
default: "lit-node",
|
|
148
148
|
input: "lit-node",
|
|
149
149
|
output: "lit-node"
|
|
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 };
|
|
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.selectionMode = "pan", this._selectionRect = null, this._selectionStart = null, this._width = 0, this._height = 0, this.viewport = { x: 0, y: 0, zoom: 1 };
|
|
151
151
|
}
|
|
152
152
|
set nodes(t) {
|
|
153
|
-
this._state.nodes.set(t),
|
|
153
|
+
this._state.nodes.set(t), rt(t, this._state.nodeLookup, this._state.parentLookup, {
|
|
154
154
|
nodeOrigin: this._state.nodeOrigin,
|
|
155
155
|
nodeExtent: this._state.nodeExtent
|
|
156
|
-
}),
|
|
156
|
+
}), U(this._state.nodeLookup, this._state.parentLookup, {
|
|
157
157
|
nodeOrigin: this._state.nodeOrigin,
|
|
158
158
|
nodeExtent: this._state.nodeExtent
|
|
159
|
-
});
|
|
159
|
+
}), this._notifyChange();
|
|
160
160
|
}
|
|
161
161
|
get nodes() {
|
|
162
162
|
return this._state.nodes.get();
|
|
163
163
|
}
|
|
164
|
+
_notifyChange() {
|
|
165
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
166
|
+
detail: {
|
|
167
|
+
nodes: this.nodes,
|
|
168
|
+
edges: this.edges
|
|
169
|
+
},
|
|
170
|
+
bubbles: !0,
|
|
171
|
+
composed: !0
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
164
174
|
_discoverNodes() {
|
|
165
175
|
if (this.nodes.length > 0) return;
|
|
166
176
|
const t = Array.from(this.querySelectorAll("lit-node"));
|
|
@@ -177,13 +187,13 @@ let u = class extends E(D) {
|
|
|
177
187
|
...e.data
|
|
178
188
|
}
|
|
179
189
|
}));
|
|
180
|
-
this.nodes = o, t.forEach((e,
|
|
181
|
-
e.nodeId = o[
|
|
190
|
+
this.nodes = o, t.forEach((e, s) => {
|
|
191
|
+
e.nodeId = o[s].id;
|
|
182
192
|
});
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
195
|
set edges(t) {
|
|
186
|
-
this._state.edges.set(t);
|
|
196
|
+
this._state.edges.set(t), this._notifyChange();
|
|
187
197
|
}
|
|
188
198
|
get edges() {
|
|
189
199
|
return this._state.edges.get();
|
|
@@ -206,40 +216,40 @@ let u = class extends E(D) {
|
|
|
206
216
|
const e = this._state.nodeLookup.get(t);
|
|
207
217
|
if (e) {
|
|
208
218
|
"updateComplete" in o && await o.updateComplete;
|
|
209
|
-
const { width:
|
|
219
|
+
const { width: s, height: r } = o.getBoundingClientRect(), i = this._state.transform.get()[2];
|
|
210
220
|
e.measured = {
|
|
211
|
-
width:
|
|
212
|
-
height:
|
|
221
|
+
width: s / i,
|
|
222
|
+
height: r / i
|
|
213
223
|
};
|
|
214
|
-
const
|
|
215
|
-
|
|
224
|
+
const n = this.nodes.find((c) => c.id === t);
|
|
225
|
+
n && (n.measured = e.measured);
|
|
216
226
|
const p = o.querySelectorAll("lit-handle");
|
|
217
227
|
if (p && p.length > 0) {
|
|
218
|
-
const
|
|
219
|
-
p.forEach((
|
|
220
|
-
const
|
|
221
|
-
id:
|
|
222
|
-
type:
|
|
223
|
-
position:
|
|
224
|
-
x: (
|
|
225
|
-
y: (
|
|
226
|
-
width:
|
|
227
|
-
height:
|
|
228
|
+
const c = [], a = [];
|
|
229
|
+
p.forEach((h) => {
|
|
230
|
+
const l = h.getBoundingClientRect(), u = o.getBoundingClientRect(), y = {
|
|
231
|
+
id: h.handleId || null,
|
|
232
|
+
type: h.type,
|
|
233
|
+
position: h.position,
|
|
234
|
+
x: (l.left - u.left) / i,
|
|
235
|
+
y: (l.top - u.top) / i,
|
|
236
|
+
width: l.width / i,
|
|
237
|
+
height: l.height / i
|
|
228
238
|
};
|
|
229
|
-
|
|
239
|
+
h.type === "source" ? c.push(y) : a.push(y);
|
|
230
240
|
}), e.internals.handleBounds = {
|
|
231
|
-
source:
|
|
232
|
-
target:
|
|
241
|
+
source: c,
|
|
242
|
+
target: a
|
|
233
243
|
}, console.log(`Node ${t} handleBounds:`, e.internals.handleBounds);
|
|
234
244
|
}
|
|
235
|
-
|
|
245
|
+
U(this._state.nodeLookup, this._state.parentLookup, {
|
|
236
246
|
nodeOrigin: this._state.nodeOrigin,
|
|
237
247
|
nodeExtent: this._state.nodeExtent
|
|
238
|
-
}), this._state.nodes.set([...this.nodes]);
|
|
248
|
+
}), this._state.nodes.set([...this.nodes]), this._notifyChange();
|
|
239
249
|
}
|
|
240
250
|
}
|
|
241
251
|
_selectNode(t, o) {
|
|
242
|
-
const e = this.nodes.map((
|
|
252
|
+
const e = this.nodes.map((s) => s.id === t ? { ...s, selected: !s.selected } : o ? s : { ...s, selected: !1 });
|
|
243
253
|
this.nodes = e;
|
|
244
254
|
}
|
|
245
255
|
/**
|
|
@@ -247,56 +257,40 @@ let u = class extends E(D) {
|
|
|
247
257
|
* Useful for Drag & Drop and context menus.
|
|
248
258
|
*/
|
|
249
259
|
project(t) {
|
|
250
|
-
const [o, e,
|
|
260
|
+
const [o, e, s] = this._state.transform.get();
|
|
251
261
|
return {
|
|
252
|
-
x: (t.x - o) /
|
|
253
|
-
y: (t.y - e) /
|
|
262
|
+
x: (t.x - o) / s,
|
|
263
|
+
y: (t.y - e) / s
|
|
254
264
|
};
|
|
255
265
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
preventScrolling: !0,
|
|
274
|
-
panOnScroll: !1,
|
|
275
|
-
panOnDrag: this.panOnDrag,
|
|
276
|
-
panOnScrollMode: T.Free,
|
|
277
|
-
panOnScrollSpeed: 0.5,
|
|
278
|
-
userSelectionActive: !1,
|
|
279
|
-
zoomOnPinch: this.zoomOnPinch,
|
|
280
|
-
zoomOnScroll: this.zoomOnScroll,
|
|
281
|
-
zoomOnDoubleClick: this.zoomOnDoubleClick,
|
|
282
|
-
zoomActivationKeyPressed: !1,
|
|
283
|
-
lib: "lit",
|
|
284
|
-
onTransformChange: () => {
|
|
285
|
-
},
|
|
286
|
-
connectionInProgress: !1,
|
|
287
|
-
paneClickDistance: 0
|
|
288
|
-
}), this._state.panZoom = this._panZoom);
|
|
266
|
+
/**
|
|
267
|
+
* Fits the view to the current nodes.
|
|
268
|
+
* @param padding Optional padding in pixels (default: 50)
|
|
269
|
+
*/
|
|
270
|
+
async fitView(t = 50) {
|
|
271
|
+
if (!this._panZoom || this.nodes.length === 0) return;
|
|
272
|
+
const o = Array.from(this._state.nodeLookup.values());
|
|
273
|
+
if (o.length === 0) return;
|
|
274
|
+
let e = 1 / 0, s = 1 / 0, r = -1 / 0, i = -1 / 0;
|
|
275
|
+
o.forEach((_) => {
|
|
276
|
+
const { x: g, y: S } = _.internals.positionAbsolute, G = _.measured.width || 0, et = _.measured.height || 0;
|
|
277
|
+
e = Math.min(e, g), s = Math.min(s, S), r = Math.max(r, g + G), i = Math.max(i, S + et);
|
|
278
|
+
});
|
|
279
|
+
const n = r - e, p = i - s, c = this.offsetWidth, a = this.offsetHeight;
|
|
280
|
+
if (c === 0 || a === 0) return;
|
|
281
|
+
const h = (c - t * 2) / n, l = (a - t * 2) / p, u = Math.min(h, l, 1), y = (c - n * u) / 2 - e * u, b = (a - p * u) / 2 - s * u;
|
|
282
|
+
await this._panZoom.setViewport({ x: y, y: b, zoom: u }, { duration: 400 });
|
|
289
283
|
}
|
|
290
|
-
|
|
291
|
-
|
|
284
|
+
_updatePanZoom(t = !1) {
|
|
285
|
+
this._panZoom && this._panZoom.update({
|
|
292
286
|
noWheelClassName: "nowheel",
|
|
293
287
|
noPanClassName: "nopan",
|
|
294
288
|
preventScrolling: !0,
|
|
295
289
|
panOnScroll: !1,
|
|
296
290
|
panOnDrag: this.panOnDrag,
|
|
297
|
-
panOnScrollMode:
|
|
291
|
+
panOnScrollMode: it.Free,
|
|
298
292
|
panOnScrollSpeed: 0.5,
|
|
299
|
-
userSelectionActive:
|
|
293
|
+
userSelectionActive: t,
|
|
300
294
|
zoomOnPinch: this.zoomOnPinch,
|
|
301
295
|
zoomOnScroll: this.zoomOnScroll,
|
|
302
296
|
zoomOnDoubleClick: this.zoomOnDoubleClick,
|
|
@@ -304,59 +298,76 @@ let u = class extends E(D) {
|
|
|
304
298
|
lib: "lit",
|
|
305
299
|
onTransformChange: () => {
|
|
306
300
|
},
|
|
307
|
-
connectionInProgress:
|
|
301
|
+
connectionInProgress: !!this._state.connectionInProgress.get(),
|
|
308
302
|
paneClickDistance: 0
|
|
309
303
|
});
|
|
310
304
|
}
|
|
305
|
+
firstUpdated() {
|
|
306
|
+
this._renderer && (this._state.domNode = this._renderer, this._resizeObserver?.observe(this._renderer), this._renderer.addEventListener("pointerdown", (t) => this._onPointerDown(t), { capture: !0 }), this._panZoom = nt({
|
|
307
|
+
domNode: this._renderer,
|
|
308
|
+
minZoom: 0.5,
|
|
309
|
+
maxZoom: 2,
|
|
310
|
+
translateExtent: this._state.nodeExtent,
|
|
311
|
+
viewport: this.viewport,
|
|
312
|
+
onDraggingChange: () => {
|
|
313
|
+
},
|
|
314
|
+
onPanZoom: (t, { x: o, y: e, zoom: s }) => {
|
|
315
|
+
this.viewport = { x: o, y: e, zoom: s }, this._state.transform.set([o, e, s]), this._viewport && (this._viewport.style.transform = `translate(${o}px,${e}px) scale(${s})`);
|
|
316
|
+
}
|
|
317
|
+
}), this._updatePanZoom(), this._state.panZoom = this._panZoom);
|
|
318
|
+
}
|
|
319
|
+
updated(t) {
|
|
320
|
+
(t.has("nodes") || t.has("nodesDraggable")) && this._setupDrags(), this._panZoom && (t.has("panOnDrag") || t.has("zoomOnScroll") || t.has("zoomOnPinch") || t.has("zoomOnDoubleClick")) && this._updatePanZoom();
|
|
321
|
+
}
|
|
311
322
|
_setupDrags() {
|
|
312
323
|
const t = this.shadowRoot?.querySelectorAll(".xyflow__node"), o = /* @__PURE__ */ new Set();
|
|
313
324
|
t?.forEach((e) => {
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
if (o.add(
|
|
317
|
-
|
|
325
|
+
const s = e.dataset.id;
|
|
326
|
+
if (s) {
|
|
327
|
+
if (o.add(s), this._resizeObserver?.observe(e), e.onclick = (i) => {
|
|
328
|
+
i.stopPropagation(), this._selectNode(s, i.shiftKey || i.metaKey);
|
|
318
329
|
}, e.style.cursor = this.nodesDraggable ? "grab" : "default", !this.nodesDraggable) {
|
|
319
|
-
this._drags.delete(
|
|
330
|
+
this._drags.delete(s);
|
|
320
331
|
return;
|
|
321
332
|
}
|
|
322
|
-
let
|
|
323
|
-
|
|
333
|
+
let r = this._drags.get(s);
|
|
334
|
+
r || (r = at({
|
|
324
335
|
getStoreItems: () => ({
|
|
325
336
|
...this._state,
|
|
326
337
|
nodes: this._state.nodes.get(),
|
|
327
338
|
edges: this._state.edges.get(),
|
|
328
339
|
transform: this._state.transform.get(),
|
|
329
|
-
panBy: async (
|
|
330
|
-
const { panZoom:
|
|
331
|
-
return
|
|
340
|
+
panBy: async (i) => {
|
|
341
|
+
const { panZoom: n, nodeExtent: p } = this._state, c = this._state.transform.get();
|
|
342
|
+
return n ? !!await n.setViewportConstrained(
|
|
332
343
|
{
|
|
333
|
-
x:
|
|
334
|
-
y:
|
|
335
|
-
zoom:
|
|
344
|
+
x: c[0] + i.x,
|
|
345
|
+
y: c[1] + i.y,
|
|
346
|
+
zoom: c[2]
|
|
336
347
|
},
|
|
337
348
|
[[0, 0], [this.offsetWidth, this.offsetHeight]],
|
|
338
349
|
p
|
|
339
350
|
) : !1;
|
|
340
351
|
},
|
|
341
|
-
updateNodePositions: (
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
352
|
+
updateNodePositions: (i) => {
|
|
353
|
+
i.forEach((n, p) => {
|
|
354
|
+
const c = this._state.nodeLookup.get(p);
|
|
355
|
+
if (c) {
|
|
356
|
+
c.position = n.position, c.internals.positionAbsolute = n.internals.positionAbsolute;
|
|
357
|
+
const a = this.nodes.find((h) => h.id === p);
|
|
358
|
+
a && (a.position = n.position);
|
|
348
359
|
}
|
|
349
|
-
}),
|
|
360
|
+
}), U(this._state.nodeLookup, this._state.parentLookup, {
|
|
350
361
|
nodeOrigin: this._state.nodeOrigin,
|
|
351
362
|
nodeExtent: this._state.nodeExtent
|
|
352
|
-
}), this._state.nodes.set([...this.nodes]);
|
|
363
|
+
}), this._state.nodes.set([...this.nodes]), this._notifyChange();
|
|
353
364
|
},
|
|
354
365
|
unselectNodesAndEdges: () => {
|
|
355
366
|
}
|
|
356
367
|
})
|
|
357
|
-
}), this._drags.set(
|
|
368
|
+
}), this._drags.set(s, r)), r.update({
|
|
358
369
|
domNode: e,
|
|
359
|
-
nodeId:
|
|
370
|
+
nodeId: s
|
|
360
371
|
});
|
|
361
372
|
}
|
|
362
373
|
});
|
|
@@ -366,76 +377,76 @@ let u = class extends E(D) {
|
|
|
366
377
|
_renderEdge(t) {
|
|
367
378
|
const o = this._state.nodeLookup.get(t.source), e = this._state.nodeLookup.get(t.target);
|
|
368
379
|
if (!o || !e) return null;
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
(
|
|
380
|
+
const s = this.nodes.find((g) => g.id === t.source), r = this.nodes.find((g) => g.id === t.target);
|
|
381
|
+
if (s?.hidden || r?.hidden) return null;
|
|
382
|
+
const i = (o.internals.handleBounds?.source || []).find(
|
|
383
|
+
(g) => g.id === (t.sourceHandle || null)
|
|
373
384
|
) || o.internals.handleBounds?.source?.[0] || {
|
|
374
385
|
id: null,
|
|
375
386
|
type: "source",
|
|
376
387
|
nodeId: t.source,
|
|
377
|
-
position:
|
|
388
|
+
position: D.Bottom,
|
|
378
389
|
x: (o.measured.width || 0) / 2,
|
|
379
390
|
y: o.measured.height || 0,
|
|
380
391
|
width: 1,
|
|
381
392
|
height: 1
|
|
382
|
-
},
|
|
383
|
-
(
|
|
393
|
+
}, n = (e.internals.handleBounds?.target || []).find(
|
|
394
|
+
(g) => g.id === (t.targetHandle || null)
|
|
384
395
|
) || e.internals.handleBounds?.target?.[0] || {
|
|
385
396
|
id: null,
|
|
386
397
|
type: "target",
|
|
387
398
|
nodeId: t.target,
|
|
388
|
-
position:
|
|
399
|
+
position: D.Top,
|
|
389
400
|
x: (e.measured.width || 0) / 2,
|
|
390
401
|
y: 0,
|
|
391
402
|
width: 1,
|
|
392
403
|
height: 1
|
|
393
|
-
}, p =
|
|
394
|
-
let
|
|
395
|
-
const
|
|
404
|
+
}, p = K(o, i, i.position, !0), c = K(e, n, n.position, !0);
|
|
405
|
+
let a = "", h = 0, l = 0;
|
|
406
|
+
const u = {
|
|
396
407
|
sourceX: p.x,
|
|
397
408
|
sourceY: p.y,
|
|
398
|
-
sourcePosition:
|
|
399
|
-
targetX:
|
|
400
|
-
targetY:
|
|
401
|
-
targetPosition:
|
|
409
|
+
sourcePosition: i.position,
|
|
410
|
+
targetX: c.x,
|
|
411
|
+
targetY: c.y,
|
|
412
|
+
targetPosition: n.position
|
|
402
413
|
};
|
|
403
414
|
switch (t.type) {
|
|
404
415
|
case "straight":
|
|
405
|
-
[
|
|
416
|
+
[a, h, l] = dt(u);
|
|
406
417
|
break;
|
|
407
418
|
case "smoothstep":
|
|
408
|
-
[
|
|
419
|
+
[a, h, l] = F(u);
|
|
409
420
|
break;
|
|
410
421
|
case "step":
|
|
411
|
-
[
|
|
422
|
+
[a, h, l] = F({ ...u, borderRadius: 0 });
|
|
412
423
|
break;
|
|
413
424
|
default:
|
|
414
|
-
[
|
|
425
|
+
[a, h, l] = W(u);
|
|
415
426
|
break;
|
|
416
427
|
}
|
|
417
|
-
const
|
|
418
|
-
if (!
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
},
|
|
422
|
-
return
|
|
428
|
+
const y = (g) => {
|
|
429
|
+
if (!g) return null;
|
|
430
|
+
const S = typeof g == "string" ? g : g.type;
|
|
431
|
+
return S ? `lit-flow__${S}${t.selected ? "-selected" : ""}` : null;
|
|
432
|
+
}, b = y(t.markerEnd), _ = y(t.markerStart);
|
|
433
|
+
return R`
|
|
423
434
|
<g class="xyflow__edge">
|
|
424
435
|
<path
|
|
425
|
-
d="${
|
|
436
|
+
d="${a}"
|
|
426
437
|
fill="none"
|
|
427
438
|
stroke="${t.selected ? "var(--md-sys-color-primary)" : "var(--md-sys-color-outline-variant)"}"
|
|
428
|
-
stroke-width="2"
|
|
429
|
-
marker-end="${
|
|
430
|
-
marker-start="${
|
|
431
|
-
style="pointer-events: none;"
|
|
439
|
+
stroke-width="${t.selected ? "3" : "2"}"
|
|
440
|
+
marker-end="${b ? `url(#${b})` : ""}"
|
|
441
|
+
marker-start="${_ ? `url(#${_})` : ""}"
|
|
442
|
+
style="pointer-events: none; transition: stroke 0.2s ease-in-out, stroke-width 0.2s ease-in-out;"
|
|
432
443
|
/>
|
|
433
|
-
${t.label ?
|
|
444
|
+
${t.label ? R`
|
|
434
445
|
<foreignObject
|
|
435
446
|
width="100"
|
|
436
447
|
height="30"
|
|
437
|
-
x="${
|
|
438
|
-
y="${
|
|
448
|
+
x="${h - 50}"
|
|
449
|
+
y="${l - 15}"
|
|
439
450
|
requiredExtensions="http://www.w3.org/1999/xhtml"
|
|
440
451
|
>
|
|
441
452
|
<div style="display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;">
|
|
@@ -446,54 +457,108 @@ let u = class extends E(D) {
|
|
|
446
457
|
</g>
|
|
447
458
|
`;
|
|
448
459
|
}
|
|
460
|
+
_isPaneClick(t) {
|
|
461
|
+
return t instanceof HTMLElement || t instanceof SVGElement ? !!(t === this._renderer || t.classList.contains("xyflow__viewport") || t.classList.contains("xyflow__edges") || t.classList.contains("xyflow__nodes")) : !1;
|
|
462
|
+
}
|
|
463
|
+
_onPointerDown(t) {
|
|
464
|
+
const o = this._isPaneClick(t.target), e = t.shiftKey || this.selectionMode === "select";
|
|
465
|
+
if (o && e) {
|
|
466
|
+
console.log("LitFlow: Selection started", { x: t.clientX, y: t.clientY, shift: t.shiftKey });
|
|
467
|
+
const s = this._renderer.getBoundingClientRect();
|
|
468
|
+
this._selectionStart = {
|
|
469
|
+
x: t.clientX - s.left,
|
|
470
|
+
y: t.clientY - s.top
|
|
471
|
+
}, this._selectionRect = { x: this._selectionStart.x, y: this._selectionStart.y, width: 0, height: 0 }, this._updatePanZoom(!0), this._renderer.setPointerCapture(t.pointerId), t.stopImmediatePropagation();
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
_onPointerMove(t) {
|
|
475
|
+
if (this._selectionStart && this._renderer) {
|
|
476
|
+
const o = this._renderer.getBoundingClientRect(), e = t.clientX - o.left, s = t.clientY - o.top, r = Math.min(this._selectionStart.x, e), i = Math.min(this._selectionStart.y, s), n = Math.abs(this._selectionStart.x - e), p = Math.abs(this._selectionStart.y - s);
|
|
477
|
+
this._selectionRect = { x: r, y: i, width: n, height: p }, this._performSelection(t.shiftKey);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
_onPointerUp(t) {
|
|
481
|
+
this._selectionStart && (console.log("LitFlow: Selection ended", this._selectionRect), this._performSelection(t.shiftKey), this._selectionStart = null, this._selectionRect = null, this._updatePanZoom(!1), this._renderer && this._renderer.releasePointerCapture(t.pointerId));
|
|
482
|
+
}
|
|
483
|
+
_performSelection(t) {
|
|
484
|
+
if (!this._selectionRect) return;
|
|
485
|
+
const o = this.project({ x: this._selectionRect.x, y: this._selectionRect.y }), e = this.project({
|
|
486
|
+
x: this._selectionRect.x + this._selectionRect.width,
|
|
487
|
+
y: this._selectionRect.y + this._selectionRect.height
|
|
488
|
+
}), s = {
|
|
489
|
+
x: Math.min(o.x, e.x),
|
|
490
|
+
y: Math.min(o.y, e.y),
|
|
491
|
+
width: Math.abs(o.x - e.x),
|
|
492
|
+
height: Math.abs(o.y - e.y)
|
|
493
|
+
};
|
|
494
|
+
let r = !1;
|
|
495
|
+
const i = this.nodes.map((a) => {
|
|
496
|
+
const h = this._state.nodeLookup.get(a.id);
|
|
497
|
+
if (!h) return a;
|
|
498
|
+
const l = h.internals.positionAbsolute, u = h.measured.width || 0, y = h.measured.height || 0, _ = l.x >= s.x && l.y >= s.y && l.x + u <= s.x + s.width && l.y + y <= s.y + s.height || t && a.selected;
|
|
499
|
+
return _ !== !!a.selected ? (r = !0, { ...a, selected: _ }) : a;
|
|
500
|
+
});
|
|
501
|
+
r && (this.nodes = i);
|
|
502
|
+
let n = !1;
|
|
503
|
+
const p = new Map(i.map((a) => [a.id, !!a.selected])), c = this.edges.map((a) => {
|
|
504
|
+
const h = p.get(a.source), l = p.get(a.target), y = h && l || t && a.selected;
|
|
505
|
+
return y !== !!a.selected ? (n = !0, { ...a, selected: y }) : a;
|
|
506
|
+
});
|
|
507
|
+
n && (this.edges = c), (r || n) && this.dispatchEvent(new CustomEvent("selection-change", {
|
|
508
|
+
detail: {
|
|
509
|
+
nodes: this.nodes.filter((a) => a.selected),
|
|
510
|
+
edges: this.edges.filter((a) => a.selected)
|
|
511
|
+
}
|
|
512
|
+
}));
|
|
513
|
+
}
|
|
449
514
|
_onHandlePointerDown(t) {
|
|
450
|
-
const { event: o, handleId: e, nodeId:
|
|
515
|
+
const { event: o, handleId: e, nodeId: s, type: r, handleDomNode: i } = t.detail, n = r === "target";
|
|
451
516
|
if (this._state.connectionInProgress.get() || !this.nodesConnectable)
|
|
452
517
|
return;
|
|
453
|
-
const p =
|
|
518
|
+
const p = i.getBoundingClientRect(), c = i.parentElement?.getBoundingClientRect(), a = this._state.transform.get()[2], h = {
|
|
454
519
|
id: e,
|
|
455
|
-
nodeId:
|
|
456
|
-
type:
|
|
457
|
-
position:
|
|
458
|
-
x: (p.left - (
|
|
459
|
-
y: (p.top - (
|
|
460
|
-
width: p.width /
|
|
461
|
-
height: p.height /
|
|
520
|
+
nodeId: s,
|
|
521
|
+
type: r,
|
|
522
|
+
position: i.position,
|
|
523
|
+
x: (p.left - (c?.left ?? 0)) / a,
|
|
524
|
+
y: (p.top - (c?.top ?? 0)) / a,
|
|
525
|
+
width: p.width / a,
|
|
526
|
+
height: p.height / a
|
|
462
527
|
};
|
|
463
|
-
|
|
528
|
+
lt.onPointerDown(o, {
|
|
464
529
|
handleId: e,
|
|
465
|
-
nodeId:
|
|
466
|
-
isTarget:
|
|
530
|
+
nodeId: s,
|
|
531
|
+
isTarget: n,
|
|
467
532
|
domNode: this._renderer,
|
|
468
|
-
handleDomNode:
|
|
533
|
+
handleDomNode: i,
|
|
469
534
|
nodeLookup: this._state.nodeLookup,
|
|
470
|
-
connectionMode:
|
|
535
|
+
connectionMode: ht.Strict,
|
|
471
536
|
lib: "lit",
|
|
472
537
|
autoPanOnConnect: !0,
|
|
473
538
|
flowId: "lit-flow",
|
|
474
539
|
dragThreshold: 0,
|
|
475
|
-
panBy: async (
|
|
476
|
-
const
|
|
477
|
-
return
|
|
478
|
-
x:
|
|
479
|
-
y:
|
|
480
|
-
zoom:
|
|
540
|
+
panBy: async (l) => {
|
|
541
|
+
const u = this._panZoom?.getViewport();
|
|
542
|
+
return u ? (await this._panZoom?.setViewport({
|
|
543
|
+
x: u.x + l.x,
|
|
544
|
+
y: u.y + l.y,
|
|
545
|
+
zoom: u.zoom
|
|
481
546
|
}), !0) : !1;
|
|
482
547
|
},
|
|
483
548
|
getTransform: () => this._state.transform.get(),
|
|
484
|
-
getFromHandle: () =>
|
|
485
|
-
updateConnection: (
|
|
486
|
-
|
|
549
|
+
getFromHandle: () => h,
|
|
550
|
+
updateConnection: (l) => {
|
|
551
|
+
l.inProgress ? this._state.connectionInProgress.set(l) : this._state.connectionInProgress.set(null);
|
|
487
552
|
},
|
|
488
553
|
cancelConnection: () => {
|
|
489
554
|
this._state.connectionInProgress.set(null);
|
|
490
555
|
},
|
|
491
|
-
onConnect: (
|
|
556
|
+
onConnect: (l) => {
|
|
492
557
|
this.dispatchEvent(new CustomEvent("connect", {
|
|
493
|
-
detail:
|
|
558
|
+
detail: l
|
|
494
559
|
}));
|
|
495
|
-
const
|
|
496
|
-
this.edges = [...this.edges, { ...
|
|
560
|
+
const u = `e-${l.source}${l.sourceHandle || ""}-${l.target}${l.targetHandle || ""}`;
|
|
561
|
+
this.edges = [...this.edges, { ...l, id: u }];
|
|
497
562
|
},
|
|
498
563
|
connectionRadius: 20
|
|
499
564
|
});
|
|
@@ -506,29 +571,29 @@ let u = class extends E(D) {
|
|
|
506
571
|
const o = t.dataTransfer?.getData("application/litflow");
|
|
507
572
|
if (typeof o > "u" || !o)
|
|
508
573
|
return;
|
|
509
|
-
const e = this.getBoundingClientRect(),
|
|
574
|
+
const e = this.getBoundingClientRect(), s = this.project({
|
|
510
575
|
x: t.clientX - e.left,
|
|
511
576
|
y: t.clientY - e.top
|
|
512
577
|
});
|
|
513
|
-
let
|
|
578
|
+
let r = `${o} node`;
|
|
514
579
|
if (this.promptOnDrop) {
|
|
515
|
-
const
|
|
516
|
-
if (
|
|
517
|
-
|
|
580
|
+
const n = window.prompt("Enter node label:", r);
|
|
581
|
+
if (n === null) return;
|
|
582
|
+
r = n || r;
|
|
518
583
|
}
|
|
519
|
-
const
|
|
584
|
+
const i = {
|
|
520
585
|
id: `node_${Date.now()}`,
|
|
521
586
|
type: o,
|
|
522
|
-
position:
|
|
523
|
-
data: { label:
|
|
587
|
+
position: s,
|
|
588
|
+
data: { label: r }
|
|
524
589
|
};
|
|
525
|
-
this.nodes = [...this.nodes,
|
|
526
|
-
detail: { node:
|
|
590
|
+
this.nodes = [...this.nodes, i], this.dispatchEvent(new CustomEvent("node-drop", {
|
|
591
|
+
detail: { node: i, event: t }
|
|
527
592
|
}));
|
|
528
593
|
}
|
|
529
594
|
_renderConnectionLine(t) {
|
|
530
595
|
if (!t) return null;
|
|
531
|
-
const [o] =
|
|
596
|
+
const [o] = W({
|
|
532
597
|
sourceX: t.from.x,
|
|
533
598
|
sourceY: t.from.y,
|
|
534
599
|
sourcePosition: t.fromPosition,
|
|
@@ -536,7 +601,7 @@ let u = class extends E(D) {
|
|
|
536
601
|
targetY: t.to.y,
|
|
537
602
|
targetPosition: t.toPosition
|
|
538
603
|
});
|
|
539
|
-
return
|
|
604
|
+
return R`
|
|
540
605
|
<path
|
|
541
606
|
class="xyflow__connection-path"
|
|
542
607
|
d="${o}"
|
|
@@ -547,13 +612,51 @@ let u = class extends E(D) {
|
|
|
547
612
|
/>
|
|
548
613
|
`;
|
|
549
614
|
}
|
|
615
|
+
_onKeyDown(t) {
|
|
616
|
+
if (!(t.target instanceof HTMLInputElement || t.target instanceof HTMLTextAreaElement || t.target.isContentEditable)) {
|
|
617
|
+
if (t.key === "Delete" || t.key === "Backspace") {
|
|
618
|
+
const o = this.nodes.filter((s) => s.selected), e = this.edges.filter((s) => s.selected);
|
|
619
|
+
if (o.length > 0 || e.length > 0) {
|
|
620
|
+
const s = new Set(o.map((i) => i.id)), r = new Set(e.map((i) => i.id));
|
|
621
|
+
this.edges.forEach((i) => {
|
|
622
|
+
(s.has(i.source) || s.has(i.target)) && r.add(i.id);
|
|
623
|
+
}), this.nodes = this.nodes.filter((i) => !s.has(i.id)), this.edges = this.edges.filter((i) => !r.has(i.id)), this.dispatchEvent(new CustomEvent("nodes-delete", {
|
|
624
|
+
detail: { nodes: o }
|
|
625
|
+
})), this.dispatchEvent(new CustomEvent("edges-delete", {
|
|
626
|
+
detail: { edges: e }
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && this.nodes.filter((e) => e.selected).length > 0) {
|
|
631
|
+
t.preventDefault();
|
|
632
|
+
const e = t.shiftKey ? 10 : 1, s = {
|
|
633
|
+
x: t.key === "ArrowLeft" ? -e : t.key === "ArrowRight" ? e : 0,
|
|
634
|
+
y: t.key === "ArrowUp" ? -e : t.key === "ArrowDown" ? e : 0
|
|
635
|
+
};
|
|
636
|
+
this.nodes = this.nodes.map((r) => r.selected ? {
|
|
637
|
+
...r,
|
|
638
|
+
position: {
|
|
639
|
+
x: r.position.x + s.x,
|
|
640
|
+
y: r.position.y + s.y
|
|
641
|
+
}
|
|
642
|
+
} : r);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
550
646
|
render() {
|
|
551
647
|
const t = this._state.transform.get(), o = this._state.connectionInProgress.get();
|
|
552
|
-
return
|
|
648
|
+
return B`
|
|
553
649
|
<div
|
|
554
650
|
class="xyflow__renderer ${this.showGrid ? "has-grid" : ""}"
|
|
651
|
+
tabindex="0"
|
|
652
|
+
@keydown="${this._onKeyDown}"
|
|
555
653
|
@dragover="${this._onDragOver}"
|
|
556
654
|
@drop="${this._onDrop}"
|
|
655
|
+
@pointermove="${this._onPointerMove}"
|
|
656
|
+
@pointerup="${this._onPointerUp}"
|
|
657
|
+
@click="${(e) => {
|
|
658
|
+
this._isPaneClick(e.target) && (this.nodes = this.nodes.map((s) => ({ ...s, selected: !1 })), this.edges = this.edges.map((s) => ({ ...s, selected: !1 })));
|
|
659
|
+
}}"
|
|
557
660
|
>
|
|
558
661
|
<div
|
|
559
662
|
class="xyflow__viewport"
|
|
@@ -562,20 +665,20 @@ let u = class extends E(D) {
|
|
|
562
665
|
<div class="xyflow__nodes" @handle-pointer-down="${this._onHandlePointerDown}">
|
|
563
666
|
${this.nodes.map((e) => {
|
|
564
667
|
if (e.hidden) return null;
|
|
565
|
-
const
|
|
566
|
-
return
|
|
567
|
-
<${
|
|
668
|
+
const r = this._state.nodeLookup.get(e.id)?.internals.positionAbsolute || e.position, i = this.nodeTypes[e.type || "default"] || this.nodeTypes.default, n = ot(i), p = e.style || {}, c = Object.entries(p).map(([b, _]) => `${b.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${typeof _ == "number" ? `${_}px` : _}`).join("; "), a = e.width || p.width, h = e.height || p.height, l = a ? `width: ${typeof a == "number" ? `${a}px` : a};` : "", u = h ? `height: ${typeof h == "number" ? `${h}px` : h};` : "", y = e.zIndex ? `z-index: ${e.zIndex};` : "";
|
|
669
|
+
return B`
|
|
670
|
+
<${n}
|
|
568
671
|
class="xyflow__node"
|
|
569
672
|
data-id="${e.id}"
|
|
570
673
|
type="${e.type || "default"}"
|
|
571
674
|
.nodeId="${e.id}"
|
|
572
|
-
style="transform: translate(${
|
|
675
|
+
style="transform: translate(${r.x}px, ${r.y}px); ${c} ${l} ${u} ${y}"
|
|
573
676
|
.data="${e.data}"
|
|
574
677
|
.label="${e.data.label}"
|
|
575
678
|
.type="${e.type || "default"}"
|
|
576
679
|
?selected="${e.selected}"
|
|
577
680
|
>
|
|
578
|
-
</${
|
|
681
|
+
</${n}>
|
|
579
682
|
`;
|
|
580
683
|
})}
|
|
581
684
|
</div>
|
|
@@ -630,9 +733,15 @@ let u = class extends E(D) {
|
|
|
630
733
|
${this._renderConnectionLine(o)}
|
|
631
734
|
</svg>
|
|
632
735
|
</div>
|
|
736
|
+
${this._selectionRect ? B`
|
|
737
|
+
<div
|
|
738
|
+
class="xyflow__selection"
|
|
739
|
+
style="transform: translate(${this._selectionRect.x}px, ${this._selectionRect.y}px); width: ${this._selectionRect.width}px; height: ${this._selectionRect.height}px;"
|
|
740
|
+
></div>
|
|
741
|
+
` : ""}
|
|
633
742
|
</div>
|
|
634
|
-
${this.showControls ?
|
|
635
|
-
${this.showMinimap ?
|
|
743
|
+
${this.showControls ? B`<lit-controls .panZoom="${this._panZoom}" @fit-view="${() => this.fitView()}"></lit-controls>` : ""}
|
|
744
|
+
${this.showMinimap ? B`
|
|
636
745
|
<lit-minimap
|
|
637
746
|
.panZoom="${this._panZoom}"
|
|
638
747
|
.nodeLookup="${this._state.nodeLookup}"
|
|
@@ -646,9 +755,9 @@ let u = class extends E(D) {
|
|
|
646
755
|
`;
|
|
647
756
|
}
|
|
648
757
|
};
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
758
|
+
f.styles = [
|
|
759
|
+
J,
|
|
760
|
+
A`
|
|
652
761
|
:host {
|
|
653
762
|
display: block;
|
|
654
763
|
width: 100%;
|
|
@@ -666,6 +775,11 @@ u.styles = [
|
|
|
666
775
|
position: absolute;
|
|
667
776
|
top: 0;
|
|
668
777
|
left: 0;
|
|
778
|
+
outline: none;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.xyflow__renderer:focus-visible {
|
|
782
|
+
box-shadow: inset 0 0 0 2px var(--md-sys-color-primary);
|
|
669
783
|
}
|
|
670
784
|
|
|
671
785
|
.xyflow__renderer.has-grid {
|
|
@@ -710,7 +824,7 @@ u.styles = [
|
|
|
710
824
|
box-sizing: border-box;
|
|
711
825
|
color: var(--lit-flow-node-text);
|
|
712
826
|
font-size: var(--md-sys-typescale-body-medium-size);
|
|
713
|
-
transition: box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
|
|
827
|
+
transition: box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out, border-width 0.1s ease-in-out;
|
|
714
828
|
}
|
|
715
829
|
|
|
716
830
|
.xyflow__node[type="group"] {
|
|
@@ -727,8 +841,9 @@ u.styles = [
|
|
|
727
841
|
|
|
728
842
|
.xyflow__node[selected] {
|
|
729
843
|
border-color: var(--lit-flow-node-selected-border);
|
|
730
|
-
border-width:
|
|
731
|
-
box-shadow: var(--md-sys-elevation-
|
|
844
|
+
border-width: 3px;
|
|
845
|
+
box-shadow: var(--md-sys-elevation-3);
|
|
846
|
+
margin: -2px; /* Offset the border width increase to prevent layout shift */
|
|
732
847
|
}
|
|
733
848
|
|
|
734
849
|
.xyflow__node[type="input"] {
|
|
@@ -815,79 +930,96 @@ u.styles = [
|
|
|
815
930
|
user-select: none;
|
|
816
931
|
box-shadow: var(--md-sys-elevation-1);
|
|
817
932
|
}
|
|
933
|
+
|
|
934
|
+
.xyflow__selection {
|
|
935
|
+
position: absolute;
|
|
936
|
+
top: 0;
|
|
937
|
+
left: 0;
|
|
938
|
+
background: var(--md-sys-color-primary-container);
|
|
939
|
+
border: 1px solid var(--md-sys-color-primary);
|
|
940
|
+
opacity: 0.4;
|
|
941
|
+
pointer-events: none;
|
|
942
|
+
z-index: 1000;
|
|
943
|
+
}
|
|
818
944
|
`
|
|
819
945
|
];
|
|
820
946
|
m([
|
|
821
947
|
q(".xyflow__renderer")
|
|
822
|
-
],
|
|
948
|
+
], f.prototype, "_renderer", 2);
|
|
823
949
|
m([
|
|
824
950
|
q(".xyflow__viewport")
|
|
825
|
-
],
|
|
951
|
+
], f.prototype, "_viewport", 2);
|
|
826
952
|
m([
|
|
827
953
|
N()
|
|
828
|
-
],
|
|
954
|
+
], f.prototype, "_panZoom", 2);
|
|
829
955
|
m([
|
|
830
956
|
N()
|
|
831
|
-
],
|
|
957
|
+
], f.prototype, "_state", 2);
|
|
832
958
|
m([
|
|
833
|
-
|
|
834
|
-
],
|
|
959
|
+
d({ type: Object })
|
|
960
|
+
], f.prototype, "nodeTypes", 2);
|
|
835
961
|
m([
|
|
836
|
-
|
|
837
|
-
],
|
|
962
|
+
d({ type: Boolean, attribute: "show-controls", reflect: !0 })
|
|
963
|
+
], f.prototype, "showControls", 2);
|
|
838
964
|
m([
|
|
839
|
-
|
|
840
|
-
],
|
|
965
|
+
d({ type: Boolean, attribute: "show-minimap", reflect: !0, converter: k })
|
|
966
|
+
], f.prototype, "showMinimap", 2);
|
|
841
967
|
m([
|
|
842
|
-
|
|
843
|
-
],
|
|
968
|
+
d({ type: Boolean, attribute: "show-grid", reflect: !0, converter: k })
|
|
969
|
+
], f.prototype, "showGrid", 2);
|
|
844
970
|
m([
|
|
845
|
-
|
|
846
|
-
],
|
|
971
|
+
d({ type: Boolean, attribute: "nodes-draggable", reflect: !0, converter: k })
|
|
972
|
+
], f.prototype, "nodesDraggable", 2);
|
|
847
973
|
m([
|
|
848
|
-
|
|
849
|
-
],
|
|
974
|
+
d({ type: Boolean, attribute: "nodes-connectable", reflect: !0, converter: k })
|
|
975
|
+
], f.prototype, "nodesConnectable", 2);
|
|
850
976
|
m([
|
|
851
|
-
|
|
852
|
-
],
|
|
977
|
+
d({ type: Boolean, attribute: "pan-on-drag", reflect: !0, converter: k })
|
|
978
|
+
], f.prototype, "panOnDrag", 2);
|
|
853
979
|
m([
|
|
854
|
-
|
|
855
|
-
],
|
|
980
|
+
d({ type: Boolean, attribute: "zoom-on-scroll", reflect: !0, converter: k })
|
|
981
|
+
], f.prototype, "zoomOnScroll", 2);
|
|
856
982
|
m([
|
|
857
|
-
|
|
858
|
-
],
|
|
983
|
+
d({ type: Boolean, attribute: "zoom-on-pinch", reflect: !0, converter: k })
|
|
984
|
+
], f.prototype, "zoomOnPinch", 2);
|
|
859
985
|
m([
|
|
860
|
-
|
|
861
|
-
],
|
|
986
|
+
d({ type: Boolean, attribute: "zoom-on-double-click", reflect: !0, converter: k })
|
|
987
|
+
], f.prototype, "zoomOnDoubleClick", 2);
|
|
862
988
|
m([
|
|
863
|
-
|
|
864
|
-
],
|
|
989
|
+
d({ type: Boolean, attribute: "prompt-on-drop", reflect: !0, converter: k })
|
|
990
|
+
], f.prototype, "promptOnDrop", 2);
|
|
991
|
+
m([
|
|
992
|
+
d({ type: String, attribute: "selection-mode" })
|
|
993
|
+
], f.prototype, "selectionMode", 2);
|
|
994
|
+
m([
|
|
995
|
+
N()
|
|
996
|
+
], f.prototype, "_selectionRect", 2);
|
|
865
997
|
m([
|
|
866
998
|
N()
|
|
867
|
-
],
|
|
999
|
+
], f.prototype, "_width", 2);
|
|
868
1000
|
m([
|
|
869
1001
|
N()
|
|
870
|
-
],
|
|
1002
|
+
], f.prototype, "_height", 2);
|
|
871
1003
|
m([
|
|
872
|
-
|
|
873
|
-
],
|
|
1004
|
+
d({ type: Array })
|
|
1005
|
+
], f.prototype, "nodes", 1);
|
|
874
1006
|
m([
|
|
875
|
-
|
|
876
|
-
],
|
|
1007
|
+
d({ type: Array })
|
|
1008
|
+
], f.prototype, "edges", 1);
|
|
877
1009
|
m([
|
|
878
|
-
|
|
879
|
-
],
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
],
|
|
883
|
-
var
|
|
884
|
-
for (var
|
|
885
|
-
(
|
|
886
|
-
return
|
|
1010
|
+
d({ type: Object })
|
|
1011
|
+
], f.prototype, "viewport", 2);
|
|
1012
|
+
f = m([
|
|
1013
|
+
O("lit-flow")
|
|
1014
|
+
], f);
|
|
1015
|
+
var wt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Z = (t, o, e, s) => {
|
|
1016
|
+
for (var r = s > 1 ? void 0 : s ? xt(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1017
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1018
|
+
return s && r && wt(o, e, r), r;
|
|
887
1019
|
};
|
|
888
|
-
let
|
|
1020
|
+
let E = class extends P {
|
|
889
1021
|
constructor() {
|
|
890
|
-
super(), this.type = "source", this.position =
|
|
1022
|
+
super(), this.type = "source", this.position = D.Top, this.addEventListener("mousedown", (t) => this._onPointerDown(t)), this.addEventListener("touchstart", (t) => this._onPointerDown(t));
|
|
891
1023
|
}
|
|
892
1024
|
createRenderRoot() {
|
|
893
1025
|
return this;
|
|
@@ -914,7 +1046,7 @@ let I = class extends D {
|
|
|
914
1046
|
(t.has("nodeId") || t.has("handleId") || t.has("type")) && this.setAttribute("data-id", `lit-flow-${this.nodeId || ""}-${this.handleId || ""}-${this.type}`);
|
|
915
1047
|
}
|
|
916
1048
|
render() {
|
|
917
|
-
return
|
|
1049
|
+
return v`
|
|
918
1050
|
<div style="
|
|
919
1051
|
width: 100%;
|
|
920
1052
|
height: 100%;
|
|
@@ -925,27 +1057,27 @@ let I = class extends D {
|
|
|
925
1057
|
`;
|
|
926
1058
|
}
|
|
927
1059
|
};
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
],
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
],
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
],
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
],
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
],
|
|
943
|
-
var
|
|
944
|
-
for (var
|
|
945
|
-
(
|
|
946
|
-
return
|
|
1060
|
+
Z([
|
|
1061
|
+
d({ type: String, reflect: !0 })
|
|
1062
|
+
], E.prototype, "type", 2);
|
|
1063
|
+
Z([
|
|
1064
|
+
d({ type: String, reflect: !0, attribute: "data-handlepos" })
|
|
1065
|
+
], E.prototype, "position", 2);
|
|
1066
|
+
Z([
|
|
1067
|
+
d({ type: String, reflect: !0, attribute: "data-handleid" })
|
|
1068
|
+
], E.prototype, "handleId", 2);
|
|
1069
|
+
Z([
|
|
1070
|
+
d({ type: String, reflect: !0, attribute: "data-nodeid" })
|
|
1071
|
+
], E.prototype, "nodeId", 2);
|
|
1072
|
+
E = Z([
|
|
1073
|
+
O("lit-handle")
|
|
1074
|
+
], E);
|
|
1075
|
+
var $t = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, Q = (t, o, e, s) => {
|
|
1076
|
+
for (var r = s > 1 ? void 0 : s ? Pt(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1077
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1078
|
+
return s && r && $t(o, e, r), r;
|
|
947
1079
|
};
|
|
948
|
-
let
|
|
1080
|
+
let Y = class extends j(P) {
|
|
949
1081
|
_zoomIn() {
|
|
950
1082
|
this.panZoom?.scaleBy(1.2);
|
|
951
1083
|
}
|
|
@@ -953,23 +1085,26 @@ let R = class extends E(D) {
|
|
|
953
1085
|
this.panZoom?.scaleBy(1 / 1.2);
|
|
954
1086
|
}
|
|
955
1087
|
_fitView() {
|
|
956
|
-
this.
|
|
1088
|
+
this.dispatchEvent(new CustomEvent("fit-view", {
|
|
1089
|
+
bubbles: !0,
|
|
1090
|
+
composed: !0
|
|
1091
|
+
}));
|
|
957
1092
|
}
|
|
958
1093
|
render() {
|
|
959
|
-
return
|
|
1094
|
+
return v`
|
|
960
1095
|
<button @click="${this._zoomIn}" title="Zoom In">
|
|
961
1096
|
<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
|
962
1097
|
</button>
|
|
963
1098
|
<button @click="${this._zoomOut}" title="Zoom Out">
|
|
964
1099
|
<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>
|
|
965
1100
|
</button>
|
|
966
|
-
<button @click="${this._fitView}" title="
|
|
967
|
-
<svg viewBox="0 0 24 24"><path d="
|
|
1101
|
+
<button @click="${this._fitView}" title="Fit View">
|
|
1102
|
+
<svg viewBox="0 0 24 24"><path d="M6 16h12V8H6v8zm2-6h8v4H8v-4zM4 4h16v16H4V4zm2 2v12h12V6H6z"/></svg>
|
|
968
1103
|
</button>
|
|
969
1104
|
`;
|
|
970
1105
|
}
|
|
971
1106
|
};
|
|
972
|
-
|
|
1107
|
+
Y.styles = A`
|
|
973
1108
|
:host {
|
|
974
1109
|
display: block;
|
|
975
1110
|
position: absolute;
|
|
@@ -1012,25 +1147,25 @@ R.styles = B`
|
|
|
1012
1147
|
fill: currentColor;
|
|
1013
1148
|
}
|
|
1014
1149
|
`;
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
],
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
],
|
|
1021
|
-
var
|
|
1022
|
-
for (var
|
|
1023
|
-
(
|
|
1024
|
-
return
|
|
1150
|
+
Q([
|
|
1151
|
+
d({ type: Object })
|
|
1152
|
+
], Y.prototype, "panZoom", 2);
|
|
1153
|
+
Y = Q([
|
|
1154
|
+
O("lit-controls")
|
|
1155
|
+
], Y);
|
|
1156
|
+
var Ot = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, C = (t, o, e, s) => {
|
|
1157
|
+
for (var r = s > 1 ? void 0 : s ? kt(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1158
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1159
|
+
return s && r && Ot(o, e, r), r;
|
|
1025
1160
|
};
|
|
1026
|
-
let
|
|
1161
|
+
let x = class extends j(P) {
|
|
1027
1162
|
constructor() {
|
|
1028
1163
|
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;
|
|
1029
1164
|
}
|
|
1030
1165
|
updated(t) {
|
|
1031
1166
|
if (!this._minimapInstance && this.panZoom) {
|
|
1032
1167
|
const o = this.shadowRoot?.querySelector("svg");
|
|
1033
|
-
o && (this._minimapInstance =
|
|
1168
|
+
o && (this._minimapInstance = pt({
|
|
1034
1169
|
domNode: o,
|
|
1035
1170
|
panZoom: this.panZoom,
|
|
1036
1171
|
getTransform: () => this.transform,
|
|
@@ -1053,7 +1188,7 @@ let v = class extends E(D) {
|
|
|
1053
1188
|
width: this.width / this.transform[2],
|
|
1054
1189
|
height: this.height / this.transform[2]
|
|
1055
1190
|
};
|
|
1056
|
-
return this.nodeLookup.size > 0 ?
|
|
1191
|
+
return this.nodeLookup.size > 0 ? ct(ut(this.nodeLookup), t) : t;
|
|
1057
1192
|
}
|
|
1058
1193
|
render() {
|
|
1059
1194
|
const t = this._getBoundingRect(), o = {
|
|
@@ -1061,22 +1196,22 @@ let v = class extends E(D) {
|
|
|
1061
1196
|
y: -this.transform[1] / this.transform[2],
|
|
1062
1197
|
width: this.width / this.transform[2],
|
|
1063
1198
|
height: this.height / this.transform[2]
|
|
1064
|
-
}, e = 200,
|
|
1065
|
-
return
|
|
1199
|
+
}, e = 200, s = 150, r = t.width / e, i = t.height / s, n = Math.max(r, i), p = n * e, c = n * s, a = 5 * n, h = t.x - (p - t.width) / 2 - a, l = t.y - (c - t.height) / 2 - a, u = p + a * 2, y = c + a * 2;
|
|
1200
|
+
return v`
|
|
1066
1201
|
<svg
|
|
1067
1202
|
width="${e}"
|
|
1068
|
-
height="${
|
|
1069
|
-
viewBox="${
|
|
1203
|
+
height="${s}"
|
|
1204
|
+
viewBox="${h} ${l} ${u} ${y}"
|
|
1070
1205
|
>
|
|
1071
|
-
${Array.from(this.nodeLookup.values()).map((
|
|
1072
|
-
const { x:
|
|
1073
|
-
return
|
|
1206
|
+
${Array.from(this.nodeLookup.values()).map((b) => {
|
|
1207
|
+
const { x: _, y: g } = b.internals.positionAbsolute, S = b.measured.width || 0, G = b.measured.height || 0;
|
|
1208
|
+
return R`
|
|
1074
1209
|
<rect
|
|
1075
1210
|
class="minimap-node"
|
|
1076
|
-
x="${
|
|
1077
|
-
y="${
|
|
1078
|
-
width="${
|
|
1079
|
-
height="${
|
|
1211
|
+
x="${_}"
|
|
1212
|
+
y="${g}"
|
|
1213
|
+
width="${S}"
|
|
1214
|
+
height="${G}"
|
|
1080
1215
|
rx="2"
|
|
1081
1216
|
ry="2"
|
|
1082
1217
|
/>
|
|
@@ -1084,14 +1219,14 @@ let v = class extends E(D) {
|
|
|
1084
1219
|
})}
|
|
1085
1220
|
<path
|
|
1086
1221
|
class="minimap-mask"
|
|
1087
|
-
d="M${
|
|
1222
|
+
d="M${h - a},${l - a}h${u + a * 2}v${y + a * 2}h${-u - a * 2}z
|
|
1088
1223
|
M${o.x},${o.y}h${o.width}v${o.height}h${-o.width}z"
|
|
1089
1224
|
/>
|
|
1090
1225
|
</svg>
|
|
1091
1226
|
`;
|
|
1092
1227
|
}
|
|
1093
1228
|
};
|
|
1094
|
-
|
|
1229
|
+
x.styles = A`
|
|
1095
1230
|
:host {
|
|
1096
1231
|
display: block;
|
|
1097
1232
|
position: absolute;
|
|
@@ -1120,36 +1255,36 @@ v.styles = B`
|
|
|
1120
1255
|
fill-rule: evenodd;
|
|
1121
1256
|
}
|
|
1122
1257
|
`;
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
],
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
],
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
],
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
],
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
],
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
],
|
|
1141
|
-
|
|
1258
|
+
C([
|
|
1259
|
+
d({ type: Object })
|
|
1260
|
+
], x.prototype, "panZoom", 2);
|
|
1261
|
+
C([
|
|
1262
|
+
d({ type: Object })
|
|
1263
|
+
], x.prototype, "nodeLookup", 2);
|
|
1264
|
+
C([
|
|
1265
|
+
d({ type: Array })
|
|
1266
|
+
], x.prototype, "transform", 2);
|
|
1267
|
+
C([
|
|
1268
|
+
d({ type: Array })
|
|
1269
|
+
], x.prototype, "translateExtent", 2);
|
|
1270
|
+
C([
|
|
1271
|
+
d({ type: Number })
|
|
1272
|
+
], x.prototype, "width", 2);
|
|
1273
|
+
C([
|
|
1274
|
+
d({ type: Number })
|
|
1275
|
+
], x.prototype, "height", 2);
|
|
1276
|
+
C([
|
|
1142
1277
|
N()
|
|
1143
|
-
],
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
],
|
|
1147
|
-
var
|
|
1148
|
-
for (var
|
|
1149
|
-
(
|
|
1150
|
-
return
|
|
1278
|
+
], x.prototype, "_minimapInstance", 2);
|
|
1279
|
+
x = C([
|
|
1280
|
+
O("lit-minimap")
|
|
1281
|
+
], x);
|
|
1282
|
+
var zt = Object.defineProperty, It = Object.getOwnPropertyDescriptor, tt = (t, o, e, s) => {
|
|
1283
|
+
for (var r = s > 1 ? void 0 : s ? It(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1284
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1285
|
+
return s && r && zt(o, e, r), r;
|
|
1151
1286
|
};
|
|
1152
|
-
let
|
|
1287
|
+
let T = class extends P {
|
|
1153
1288
|
constructor() {
|
|
1154
1289
|
super(...arguments), this.nodeTypes = [
|
|
1155
1290
|
{ type: "default", label: "Default Node" },
|
|
@@ -1161,11 +1296,11 @@ let H = class extends D {
|
|
|
1161
1296
|
t.dataTransfer && (t.dataTransfer.setData("application/litflow", o), t.dataTransfer.effectAllowed = "move");
|
|
1162
1297
|
}
|
|
1163
1298
|
render() {
|
|
1164
|
-
return
|
|
1299
|
+
return v`
|
|
1165
1300
|
<div class="sidebar-title">Node Palette</div>
|
|
1166
1301
|
<div class="node-palette">
|
|
1167
1302
|
${this.nodeTypes.map(
|
|
1168
|
-
(t) =>
|
|
1303
|
+
(t) => v`
|
|
1169
1304
|
<div
|
|
1170
1305
|
class="palette-item"
|
|
1171
1306
|
draggable="true"
|
|
@@ -1179,9 +1314,9 @@ let H = class extends D {
|
|
|
1179
1314
|
`;
|
|
1180
1315
|
}
|
|
1181
1316
|
};
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1317
|
+
T.styles = [
|
|
1318
|
+
J,
|
|
1319
|
+
A`
|
|
1185
1320
|
:host {
|
|
1186
1321
|
display: block;
|
|
1187
1322
|
width: 200px;
|
|
@@ -1229,21 +1364,189 @@ H.styles = [
|
|
|
1229
1364
|
}
|
|
1230
1365
|
`
|
|
1231
1366
|
];
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
],
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
],
|
|
1367
|
+
tt([
|
|
1368
|
+
d({ type: Array })
|
|
1369
|
+
], T.prototype, "nodeTypes", 2);
|
|
1370
|
+
T = tt([
|
|
1371
|
+
O("lit-sidebar")
|
|
1372
|
+
], T);
|
|
1373
|
+
var Ct = Object.defineProperty, St = Object.getOwnPropertyDescriptor, V = (t, o, e, s) => {
|
|
1374
|
+
for (var r = s > 1 ? void 0 : s ? St(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1375
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1376
|
+
return s && r && Ct(o, e, r), r;
|
|
1377
|
+
};
|
|
1378
|
+
let M = class extends P {
|
|
1379
|
+
constructor() {
|
|
1380
|
+
super(...arguments), this.nodeId = "", this._data = {}, this.prompt = "";
|
|
1381
|
+
}
|
|
1382
|
+
createRenderRoot() {
|
|
1383
|
+
return this;
|
|
1384
|
+
}
|
|
1385
|
+
set data(t) {
|
|
1386
|
+
this._data = t, t.prompt && (this.prompt = t.prompt);
|
|
1387
|
+
}
|
|
1388
|
+
get data() {
|
|
1389
|
+
return this._data;
|
|
1390
|
+
}
|
|
1391
|
+
_onInput(t) {
|
|
1392
|
+
const o = t.target;
|
|
1393
|
+
this.prompt = o.value, this.dispatchEvent(new CustomEvent("node-data-change", {
|
|
1394
|
+
bubbles: !0,
|
|
1395
|
+
composed: !0,
|
|
1396
|
+
detail: { id: this.nodeId, data: { prompt: this.prompt } }
|
|
1397
|
+
}));
|
|
1398
|
+
}
|
|
1399
|
+
render() {
|
|
1400
|
+
return v`
|
|
1401
|
+
<div class="gemini-node prompt-node" style="
|
|
1402
|
+
padding: 12px;
|
|
1403
|
+
background: var(--md-sys-color-surface-container-high);
|
|
1404
|
+
border-radius: 12px;
|
|
1405
|
+
width: 200px;
|
|
1406
|
+
box-sizing: border-box;
|
|
1407
|
+
display: flex;
|
|
1408
|
+
flex-direction: column;
|
|
1409
|
+
gap: 8px;
|
|
1410
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
1411
|
+
text-align: left;
|
|
1412
|
+
">
|
|
1413
|
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 4px;">
|
|
1414
|
+
<span style="font-size: 18px;">✨</span>
|
|
1415
|
+
<span style="font-size: 12px; font-weight: bold; color: var(--md-sys-color-primary);">GEMINI PROMPT</span>
|
|
1416
|
+
</div>
|
|
1417
|
+
<textarea
|
|
1418
|
+
style="
|
|
1419
|
+
width: 100%;
|
|
1420
|
+
height: 80px;
|
|
1421
|
+
border-radius: 8px;
|
|
1422
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
1423
|
+
padding: 8px;
|
|
1424
|
+
font-family: inherit;
|
|
1425
|
+
font-size: 12px;
|
|
1426
|
+
resize: none;
|
|
1427
|
+
box-sizing: border-box;
|
|
1428
|
+
background: var(--md-sys-color-surface);
|
|
1429
|
+
color: var(--md-sys-color-on-surface);
|
|
1430
|
+
"
|
|
1431
|
+
placeholder="Enter prompt..."
|
|
1432
|
+
.value="${this.prompt}"
|
|
1433
|
+
@input="${this._onInput}"
|
|
1434
|
+
></textarea>
|
|
1435
|
+
<button
|
|
1436
|
+
style="
|
|
1437
|
+
width: 100%;
|
|
1438
|
+
padding: 8px;
|
|
1439
|
+
border-radius: 8px;
|
|
1440
|
+
border: none;
|
|
1441
|
+
background: var(--md-sys-color-primary);
|
|
1442
|
+
color: var(--md-sys-color-on-primary);
|
|
1443
|
+
font-size: 12px;
|
|
1444
|
+
font-weight: bold;
|
|
1445
|
+
cursor: pointer;
|
|
1446
|
+
"
|
|
1447
|
+
@click="${() => this.dispatchEvent(new CustomEvent("gemini-generate", { bubbles: !0, composed: !0, detail: { id: this.nodeId, prompt: this.prompt } }))}"
|
|
1448
|
+
>
|
|
1449
|
+
Generate
|
|
1450
|
+
</button>
|
|
1451
|
+
<lit-handle type="source" data-handlepos="${D.Bottom}" data-nodeid="${this.nodeId}"></lit-handle>
|
|
1452
|
+
</div>
|
|
1453
|
+
`;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
V([
|
|
1457
|
+
d({ type: String, attribute: "data-id", reflect: !0 })
|
|
1458
|
+
], M.prototype, "nodeId", 2);
|
|
1459
|
+
V([
|
|
1460
|
+
d({ type: Object })
|
|
1461
|
+
], M.prototype, "data", 1);
|
|
1462
|
+
V([
|
|
1463
|
+
d({ type: String })
|
|
1464
|
+
], M.prototype, "prompt", 2);
|
|
1465
|
+
M = V([
|
|
1466
|
+
O("lit-gemini-prompt-node")
|
|
1467
|
+
], M);
|
|
1468
|
+
var Dt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, H = (t, o, e, s) => {
|
|
1469
|
+
for (var r = s > 1 ? void 0 : s ? Et(o, e) : o, i = t.length - 1, n; i >= 0; i--)
|
|
1470
|
+
(n = t[i]) && (r = (s ? n(o, e, r) : n(r)) || r);
|
|
1471
|
+
return s && r && Dt(o, e, r), r;
|
|
1472
|
+
};
|
|
1473
|
+
let L = class extends P {
|
|
1474
|
+
constructor() {
|
|
1475
|
+
super(...arguments), this.nodeId = "", this._data = {}, this.imageUrl = "", this.status = "idle";
|
|
1476
|
+
}
|
|
1477
|
+
createRenderRoot() {
|
|
1478
|
+
return this;
|
|
1479
|
+
}
|
|
1480
|
+
set data(t) {
|
|
1481
|
+
this._data = t, t.imageUrl && (this.imageUrl = t.imageUrl), t.status && (this.status = t.status);
|
|
1482
|
+
}
|
|
1483
|
+
get data() {
|
|
1484
|
+
return this._data;
|
|
1485
|
+
}
|
|
1486
|
+
render() {
|
|
1487
|
+
return v`
|
|
1488
|
+
<div class="gemini-node image-node" style="
|
|
1489
|
+
padding: 12px;
|
|
1490
|
+
background: var(--md-sys-color-surface-container-high);
|
|
1491
|
+
border-radius: 12px;
|
|
1492
|
+
width: 220px;
|
|
1493
|
+
box-sizing: border-box;
|
|
1494
|
+
display: flex;
|
|
1495
|
+
flex-direction: column;
|
|
1496
|
+
gap: 8px;
|
|
1497
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
1498
|
+
text-align: left;
|
|
1499
|
+
">
|
|
1500
|
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 4px;">
|
|
1501
|
+
<span style="font-size: 18px;">🖼️</span>
|
|
1502
|
+
<span style="font-size: 12px; font-weight: bold; color: var(--md-sys-color-secondary);">GEMINI IMAGE</span>
|
|
1503
|
+
</div>
|
|
1504
|
+
|
|
1505
|
+
<div style="
|
|
1506
|
+
width: 100%;
|
|
1507
|
+
height: 150px;
|
|
1508
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
1509
|
+
border-radius: 8px;
|
|
1510
|
+
display: flex;
|
|
1511
|
+
align-items: center;
|
|
1512
|
+
justify-content: center;
|
|
1513
|
+
overflow: hidden;
|
|
1514
|
+
border: 1px dashed var(--md-sys-color-outline);
|
|
1515
|
+
">
|
|
1516
|
+
${this.status === "loading" ? v`<div style="font-size: 12px; color: var(--md-sys-color-outline);">Generating...</div>` : this.imageUrl ? v`<img src="${this.imageUrl}" style="width: 100%; height: 100%; object-fit: cover;" />` : v`<div style="font-size: 12px; color: var(--md-sys-color-outline);">No image generated</div>`}
|
|
1517
|
+
</div>
|
|
1518
|
+
|
|
1519
|
+
<lit-handle type="target" data-handlepos="${D.Top}" data-nodeid="${this.nodeId}"></lit-handle>
|
|
1520
|
+
</div>
|
|
1521
|
+
`;
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
H([
|
|
1525
|
+
d({ type: String, attribute: "data-id", reflect: !0 })
|
|
1526
|
+
], L.prototype, "nodeId", 2);
|
|
1527
|
+
H([
|
|
1528
|
+
d({ type: Object })
|
|
1529
|
+
], L.prototype, "data", 1);
|
|
1530
|
+
H([
|
|
1531
|
+
d({ type: String })
|
|
1532
|
+
], L.prototype, "imageUrl", 2);
|
|
1533
|
+
H([
|
|
1534
|
+
d({ type: String })
|
|
1535
|
+
], L.prototype, "status", 2);
|
|
1536
|
+
L = H([
|
|
1537
|
+
O("lit-gemini-image-node")
|
|
1538
|
+
], L);
|
|
1238
1539
|
export {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1540
|
+
Y as LitControls,
|
|
1541
|
+
w as LitEdge,
|
|
1542
|
+
f as LitFlow,
|
|
1543
|
+
L as LitGeminiImageNode,
|
|
1544
|
+
M as LitGeminiPromptNode,
|
|
1545
|
+
E as LitHandle,
|
|
1546
|
+
x as LitMinimap,
|
|
1547
|
+
$ as LitNode,
|
|
1548
|
+
T as LitSidebar,
|
|
1549
|
+
ft as createInitialState,
|
|
1550
|
+
J as m3Tokens
|
|
1248
1551
|
};
|
|
1249
1552
|
//# sourceMappingURL=litflow.js.map
|