@agent-ui-kit/web-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-ui.css +1 -0
- package/dist/chunks/agent-ciCayeod.js +1241 -0
- package/dist/chunks/agent-ciCayeod.js.map +1 -0
- package/dist/chunks/registry-BNb5ABBs.js +25 -0
- package/dist/chunks/registry-BNb5ABBs.js.map +1 -0
- package/dist/components/agent.js +13 -0
- package/dist/components/agent.js.map +1 -0
- package/dist/components/editor.js +200 -0
- package/dist/components/editor.js.map +1 -0
- package/dist/components/graph.js +352 -0
- package/dist/components/graph.js.map +1 -0
- package/dist/components.js +3137 -0
- package/dist/components.js.map +1 -0
- package/dist/element.js +10 -0
- package/dist/element.js.map +1 -0
- package/dist/icons.js +104 -0
- package/dist/icons.js.map +1 -0
- package/dist/reactivity.js +9 -0
- package/dist/reactivity.js.map +1 -0
- package/dist/register.js +1441 -0
- package/dist/register.js.map +1 -0
- package/dist/store.js +34 -0
- package/dist/store.js.map +1 -0
- package/dist/styles.js +2 -0
- package/dist/styles.js.map +1 -0
- package/dist/traits.js +2453 -0
- package/dist/traits.js.map +1 -0
- package/package.json +56 -0
package/dist/register.js
ADDED
|
@@ -0,0 +1,1441 @@
|
|
|
1
|
+
import { A as T, s as S, a as I, b as $, d as F, e as o, p as W, v as X, f as K, g as B, h as _, i as j, j as J, k as V, l as Z, m as Q, n as tt } from "./chunks/agent-ciCayeod.js";
|
|
2
|
+
import { registerBuiltinTraits as et } from "./traits.js";
|
|
3
|
+
import { AuiEditor as it, AuiEditorLayer as st } from "./components/editor.js";
|
|
4
|
+
import { AuiGraphUi as at, AuiGraphLayer as nt, AuiGraphNode as ot, AuiGraphNoodle as rt, AuiGraphPort as lt } from "./components/graph.js";
|
|
5
|
+
import { AuiButton as ut, AuiInput as dt, AuiCheckbox as ht, AuiSwitch as ct, AuiRadio as mt, AuiRadioGroup as ft, AuiTextarea as pt, AuiContainer as bt, AuiDialog as gt, AuiDrawer as vt, AuiIcon as yt, AuiTooltip as At, AuiRange as wt, AuiInputOtp as xt, AuiGripper as Et, AuiOption as Ct, AuiOptgroup as kt, AuiSelect as St, AuiToast as Pt, AuiTabs as $t, AuiTab as Lt, AuiTabPanel as Mt, AuiAccordion as Dt, AuiAccordionItem as Tt, AuiBreadcrumb as It, AuiBreadcrumbItem as Nt, AuiSegmentedControl as Yt, AuiSegment as qt, AuiPagination as Rt, AuiCommand as zt, AuiCommandInput as Ft, AuiCommandList as Gt, AuiCommandItem as Ut, AuiCommandGroup as Ht, AuiCommandEmpty as Ot, AuiPanes as Wt, AuiPane as Xt, AuiTable as Kt, AuiTableHead as Bt, AuiTableBody as _t, AuiTableRow as jt, AuiTableHeader as Jt, AuiTableCell as Vt, AuiTree as Zt, AuiTreeItem as Qt, AuiFeed as te, AuiRoot as ee, AuiAppShell as ie, AuiPage as se, AuiPageMain as ae, AuiPageContext as ne, AuiSidebar as oe, AuiSidebarHeader as re, AuiSidebarContent as le, AuiSidebarFooter as ue } from "./components.js";
|
|
6
|
+
class de extends T {
|
|
7
|
+
static attributes = {
|
|
8
|
+
key: { type: "string", default: "" },
|
|
9
|
+
label: { type: "string", default: "" },
|
|
10
|
+
sortable: { type: "boolean", default: !1 },
|
|
11
|
+
filterable: { type: "boolean", default: !1 },
|
|
12
|
+
width: { type: "string", default: "1fr" },
|
|
13
|
+
type: { type: "enum", values: ["string", "number", "date"], default: "string" },
|
|
14
|
+
align: { type: "enum", values: ["start", "center", "end"], default: "start" }
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
class he extends T {
|
|
18
|
+
static attributes = {
|
|
19
|
+
background: { type: "string", default: "none" },
|
|
20
|
+
orientation: { type: "string", default: "horizontal" },
|
|
21
|
+
"pan-enabled": { type: "boolean", default: !1 },
|
|
22
|
+
"zoom-enabled": { type: "boolean", default: !1 },
|
|
23
|
+
infinite: { type: "boolean", default: !1 },
|
|
24
|
+
bordered: { type: "boolean", default: !1 }
|
|
25
|
+
};
|
|
26
|
+
#n = null;
|
|
27
|
+
#t = null;
|
|
28
|
+
#e = null;
|
|
29
|
+
// Pan state
|
|
30
|
+
#a = 0;
|
|
31
|
+
#s = 0;
|
|
32
|
+
#l = !1;
|
|
33
|
+
#u = 0;
|
|
34
|
+
#i = 0;
|
|
35
|
+
#m = 0;
|
|
36
|
+
#f = 0;
|
|
37
|
+
// Zoom state
|
|
38
|
+
#r = 1;
|
|
39
|
+
// ── Public API ──
|
|
40
|
+
get panX() {
|
|
41
|
+
return this.#a;
|
|
42
|
+
}
|
|
43
|
+
get panY() {
|
|
44
|
+
return this.#s;
|
|
45
|
+
}
|
|
46
|
+
get zoom() {
|
|
47
|
+
return this.#r;
|
|
48
|
+
}
|
|
49
|
+
/** Reset pan and zoom to defaults */
|
|
50
|
+
reset() {
|
|
51
|
+
this.#a = 0, this.#s = 0, this.#r = 1, this.#o(), this.#d(), this.#b();
|
|
52
|
+
}
|
|
53
|
+
/** Set pan position programmatically */
|
|
54
|
+
panTo(t, e) {
|
|
55
|
+
this.#a = t, this.#s = e, this.#o(), this.#d();
|
|
56
|
+
}
|
|
57
|
+
/** Set zoom level programmatically */
|
|
58
|
+
zoomTo(t) {
|
|
59
|
+
this.#r = Math.max(0.1, Math.min(10, t)), this.#o(), this.#b();
|
|
60
|
+
}
|
|
61
|
+
// ── Lifecycle ──
|
|
62
|
+
activate() {
|
|
63
|
+
if (this.#e = this.querySelector(':scope > [slot="content"]'), !this.#e) {
|
|
64
|
+
this.#e = document.createElement("div"), this.#e.setAttribute("slot", "content");
|
|
65
|
+
const e = Array.from(this.childNodes);
|
|
66
|
+
for (const i of e) {
|
|
67
|
+
if (i instanceof HTMLElement) {
|
|
68
|
+
const s = i.getAttribute("slot");
|
|
69
|
+
if (s === "leading" || s === "trailing") continue;
|
|
70
|
+
}
|
|
71
|
+
this.#e.appendChild(i);
|
|
72
|
+
}
|
|
73
|
+
this.appendChild(this.#e);
|
|
74
|
+
}
|
|
75
|
+
const t = this.hasAttribute("pan-enabled") || this.hasAttribute("zoom-enabled") || this.hasAttribute("infinite") || this.#e.querySelector(':scope > [slot^="float-"]');
|
|
76
|
+
t && this.#c(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "region"), t && this.addEventListener("keydown", this.#h);
|
|
77
|
+
}
|
|
78
|
+
dispose() {
|
|
79
|
+
const t = this.#n;
|
|
80
|
+
t && (t.removeEventListener("pointerdown", this.#A), t.removeEventListener("pointermove", this.#w), t.removeEventListener("pointerup", this.#v), t.removeEventListener("pointercancel", this.#v), t.removeEventListener("wheel", this.#y)), this.removeEventListener("keydown", this.#h);
|
|
81
|
+
}
|
|
82
|
+
// ── DOM stamping ──
|
|
83
|
+
#c() {
|
|
84
|
+
const t = this.#e, e = document.createElement("div");
|
|
85
|
+
e.setAttribute("data-viewport", "");
|
|
86
|
+
const i = document.createElement("div");
|
|
87
|
+
i.setAttribute("data-transform", "");
|
|
88
|
+
const s = Array.from(t.childNodes);
|
|
89
|
+
for (const r of s) {
|
|
90
|
+
if (r instanceof HTMLElement && r.getAttribute("slot")?.startsWith("float-")) {
|
|
91
|
+
e.appendChild(r);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
i.appendChild(r);
|
|
95
|
+
}
|
|
96
|
+
e.appendChild(i), t.appendChild(e), this.#n = e, this.#t = i;
|
|
97
|
+
const a = this.hasAttribute("pan-enabled") || this.hasAttribute("infinite"), n = this.hasAttribute("zoom-enabled") || this.hasAttribute("infinite");
|
|
98
|
+
a && (t.addEventListener("pointerdown", this.#A), t.addEventListener("pointermove", this.#w), t.addEventListener("pointerup", this.#v), t.addEventListener("pointercancel", this.#v)), n && t.addEventListener("wheel", this.#y, { passive: !1 }), this.#o();
|
|
99
|
+
}
|
|
100
|
+
// ── Transform ──
|
|
101
|
+
#o() {
|
|
102
|
+
this.style.setProperty("--_canvas-x", `${this.#a}px`), this.style.setProperty("--_canvas-y", `${this.#s}px`), this.style.setProperty("--_canvas-zoom", String(this.#r));
|
|
103
|
+
}
|
|
104
|
+
#d() {
|
|
105
|
+
this.dispatchEvent(new CustomEvent("aui:canvas-pan", {
|
|
106
|
+
bubbles: !0,
|
|
107
|
+
composed: !0,
|
|
108
|
+
detail: { x: this.#a, y: this.#s }
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
#b() {
|
|
112
|
+
this.dispatchEvent(new CustomEvent("aui:canvas-zoom", {
|
|
113
|
+
bubbles: !0,
|
|
114
|
+
composed: !0,
|
|
115
|
+
detail: { zoom: this.#r }
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
// ── Pan handlers ──
|
|
119
|
+
#A = (t) => {
|
|
120
|
+
if (t.button !== 0) return;
|
|
121
|
+
const e = t.target, i = this.#t;
|
|
122
|
+
i && i.contains(e) || (this.#l = !0, this.#u = t.clientX, this.#i = t.clientY, this.#m = this.#a, this.#f = this.#s, this.#e.setPointerCapture(t.pointerId), this.setAttribute("data-canvas-panning", ""));
|
|
123
|
+
};
|
|
124
|
+
#w = (t) => {
|
|
125
|
+
this.#l && (this.#a = this.#m + (t.clientX - this.#u), this.#s = this.#f + (t.clientY - this.#i), this.#o());
|
|
126
|
+
};
|
|
127
|
+
#v = (t) => {
|
|
128
|
+
this.#l && (this.#l = !1, this.removeAttribute("data-canvas-panning"), this.#d());
|
|
129
|
+
};
|
|
130
|
+
// ── Zoom handler ──
|
|
131
|
+
#y = (t) => {
|
|
132
|
+
t.preventDefault();
|
|
133
|
+
const e = t.deltaY > 0 ? -0.05 : 0.05, i = Math.max(0.1, Math.min(10, this.#r + e * this.#r));
|
|
134
|
+
if (this.#e) {
|
|
135
|
+
const s = this.#e.getBoundingClientRect(), a = (t.clientX - s.left) / s.width, n = (t.clientY - s.top) / s.height, r = i / this.#r;
|
|
136
|
+
this.#a = a * s.width * (1 - r) + this.#a * r, this.#s = n * s.height * (1 - r) + this.#s * r;
|
|
137
|
+
}
|
|
138
|
+
this.#r = i, this.#o(), this.#b();
|
|
139
|
+
};
|
|
140
|
+
// ── Keyboard ──
|
|
141
|
+
#h = (t) => {
|
|
142
|
+
switch (t.key) {
|
|
143
|
+
case "0":
|
|
144
|
+
t.preventDefault(), this.#r = 1, this.#o(), this.#b();
|
|
145
|
+
break;
|
|
146
|
+
case "+":
|
|
147
|
+
case "=":
|
|
148
|
+
t.preventDefault(), this.zoomTo(this.#r * 1.15);
|
|
149
|
+
break;
|
|
150
|
+
case "-":
|
|
151
|
+
t.preventDefault(), this.zoomTo(this.#r / 1.15);
|
|
152
|
+
break;
|
|
153
|
+
case "Escape":
|
|
154
|
+
t.preventDefault(), this.reset();
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function L(m) {
|
|
160
|
+
if (!m) return null;
|
|
161
|
+
const t = /* @__PURE__ */ new Date(m + "T00:00:00");
|
|
162
|
+
return isNaN(t.getTime()) ? null : t;
|
|
163
|
+
}
|
|
164
|
+
function ce(m) {
|
|
165
|
+
const t = m.getFullYear(), e = String(m.getMonth() + 1).padStart(2, "0"), i = String(m.getDate()).padStart(2, "0");
|
|
166
|
+
return `${t}-${e}-${i}`;
|
|
167
|
+
}
|
|
168
|
+
function N(m, t) {
|
|
169
|
+
return m.getFullYear() === t.getFullYear() && m.getMonth() === t.getMonth() && m.getDate() === t.getDate();
|
|
170
|
+
}
|
|
171
|
+
class me {
|
|
172
|
+
view;
|
|
173
|
+
focusedYear;
|
|
174
|
+
focusedMonth;
|
|
175
|
+
value;
|
|
176
|
+
rangeStart;
|
|
177
|
+
rangeEnd;
|
|
178
|
+
min;
|
|
179
|
+
max;
|
|
180
|
+
// WHY: Computed grid of day cells for the focused month view
|
|
181
|
+
days;
|
|
182
|
+
months;
|
|
183
|
+
years;
|
|
184
|
+
title;
|
|
185
|
+
constructor(t = {}) {
|
|
186
|
+
const e = /* @__PURE__ */ new Date(), i = L(t.value ?? null) ?? e;
|
|
187
|
+
this.view = S("day"), this.focusedYear = S(i.getFullYear()), this.focusedMonth = S(i.getMonth()), this.value = S(t.value ?? null), this.rangeStart = S(t.rangeStart ?? null), this.rangeEnd = S(t.rangeEnd ?? null), this.min = S(t.min ?? null), this.max = S(t.max ?? null), this.days = I(() => this.#n()), this.months = I(() => this.#t()), this.years = I(() => this.#e()), this.title = I(() => this.#a());
|
|
188
|
+
}
|
|
189
|
+
// ── Navigation ──
|
|
190
|
+
prevMonth() {
|
|
191
|
+
$(() => {
|
|
192
|
+
this.focusedMonth.value === 0 ? (this.focusedMonth.value = 11, this.focusedYear.value--) : this.focusedMonth.value--;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
nextMonth() {
|
|
196
|
+
$(() => {
|
|
197
|
+
this.focusedMonth.value === 11 ? (this.focusedMonth.value = 0, this.focusedYear.value++) : this.focusedMonth.value++;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
prevYear() {
|
|
201
|
+
this.focusedYear.value--;
|
|
202
|
+
}
|
|
203
|
+
nextYear() {
|
|
204
|
+
this.focusedYear.value++;
|
|
205
|
+
}
|
|
206
|
+
prevDecade() {
|
|
207
|
+
this.focusedYear.value -= 10;
|
|
208
|
+
}
|
|
209
|
+
nextDecade() {
|
|
210
|
+
this.focusedYear.value += 10;
|
|
211
|
+
}
|
|
212
|
+
// ── Selection ──
|
|
213
|
+
selectDate(t) {
|
|
214
|
+
this.value.value = t;
|
|
215
|
+
}
|
|
216
|
+
selectMonth(t) {
|
|
217
|
+
$(() => {
|
|
218
|
+
this.focusedMonth.value = t, this.view.value = "day";
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
selectYear(t) {
|
|
222
|
+
$(() => {
|
|
223
|
+
this.focusedYear.value = t, this.view.value = "month";
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
// ── Range ──
|
|
227
|
+
setRange(t, e) {
|
|
228
|
+
$(() => {
|
|
229
|
+
this.rangeStart.value = t, this.rangeEnd.value = e;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// ── Validation ──
|
|
233
|
+
isDateDisabled(t) {
|
|
234
|
+
const e = L(this.min.value), i = L(this.max.value), s = L(t);
|
|
235
|
+
return !!(!s || e && s < e || i && s > i);
|
|
236
|
+
}
|
|
237
|
+
// ── Private Computations ──
|
|
238
|
+
#n() {
|
|
239
|
+
const t = this.focusedYear.value, e = this.focusedMonth.value, i = L(this.value.value), s = /* @__PURE__ */ new Date(), a = L(this.rangeStart.value), n = L(this.rangeEnd.value), c = new Date(t, e, 1).getDay(), h = new Date(t, e, 1 - c), f = [];
|
|
240
|
+
for (let u = 0; u < 42; u++) {
|
|
241
|
+
const l = new Date(h.getFullYear(), h.getMonth(), h.getDate() + u), v = ce(l), d = l.getMonth() === e, p = N(l, s), g = i ? N(l, i) : !1, E = this.isDateDisabled(v);
|
|
242
|
+
let b = !1, A = !1, P = !1;
|
|
243
|
+
if (a && n) {
|
|
244
|
+
const C = a <= n ? a : n, D = a <= n ? n : a;
|
|
245
|
+
b = l >= C && l <= D, A = N(l, C), P = N(l, D);
|
|
246
|
+
}
|
|
247
|
+
f.push({
|
|
248
|
+
date: v,
|
|
249
|
+
day: l.getDate(),
|
|
250
|
+
inMonth: d,
|
|
251
|
+
isToday: p,
|
|
252
|
+
isSelected: g,
|
|
253
|
+
isDisabled: E,
|
|
254
|
+
inRange: b,
|
|
255
|
+
isRangeStart: A,
|
|
256
|
+
isRangeEnd: P
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return f;
|
|
260
|
+
}
|
|
261
|
+
#t() {
|
|
262
|
+
const t = this.focusedYear.value, e = this.focusedMonth.value;
|
|
263
|
+
return ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((s, a) => ({
|
|
264
|
+
month: a,
|
|
265
|
+
name: s,
|
|
266
|
+
isCurrent: a === e && t === (/* @__PURE__ */ new Date()).getFullYear(),
|
|
267
|
+
isSelected: a === e
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
#e() {
|
|
271
|
+
const t = this.focusedYear.value, e = Math.floor(t / 10) * 10, i = (/* @__PURE__ */ new Date()).getFullYear(), s = [];
|
|
272
|
+
for (let a = e - 1; a <= e + 10; a++)
|
|
273
|
+
s.push({
|
|
274
|
+
year: a,
|
|
275
|
+
inDecade: a >= e && a < e + 10,
|
|
276
|
+
isCurrent: a === i,
|
|
277
|
+
isSelected: a === t
|
|
278
|
+
});
|
|
279
|
+
return s;
|
|
280
|
+
}
|
|
281
|
+
#a() {
|
|
282
|
+
const t = [
|
|
283
|
+
"January",
|
|
284
|
+
"February",
|
|
285
|
+
"March",
|
|
286
|
+
"April",
|
|
287
|
+
"May",
|
|
288
|
+
"June",
|
|
289
|
+
"July",
|
|
290
|
+
"August",
|
|
291
|
+
"September",
|
|
292
|
+
"October",
|
|
293
|
+
"November",
|
|
294
|
+
"December"
|
|
295
|
+
];
|
|
296
|
+
switch (this.view.value) {
|
|
297
|
+
case "day":
|
|
298
|
+
return `${t[this.focusedMonth.value]} ${this.focusedYear.value}`;
|
|
299
|
+
case "month":
|
|
300
|
+
return `${this.focusedYear.value}`;
|
|
301
|
+
case "year": {
|
|
302
|
+
const e = Math.floor(this.focusedYear.value / 10) * 10;
|
|
303
|
+
return `${e}–${e + 9}`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
class fe extends T {
|
|
309
|
+
static attributes = {
|
|
310
|
+
value: { type: "string", default: "" },
|
|
311
|
+
min: { type: "string", default: "" },
|
|
312
|
+
max: { type: "string", default: "" },
|
|
313
|
+
disabled: { type: "boolean", default: !1 },
|
|
314
|
+
range: { type: "boolean", default: !1 }
|
|
315
|
+
};
|
|
316
|
+
#n;
|
|
317
|
+
#t = new me();
|
|
318
|
+
#e = S(!1);
|
|
319
|
+
// WHY: Track focused cell index for keyboard navigation within the grid
|
|
320
|
+
#a = S(0);
|
|
321
|
+
// WHY: 3-phase range cycle: idle → selecting (hover previews) → committed → idle
|
|
322
|
+
#s = "idle";
|
|
323
|
+
// WHY: Drag-based range selection — pointerdown starts, pointermove previews, pointerup commits
|
|
324
|
+
#l = !1;
|
|
325
|
+
constructor() {
|
|
326
|
+
super(), this.#n = this.attachInternals(), this.#n.role = "group";
|
|
327
|
+
}
|
|
328
|
+
get store() {
|
|
329
|
+
return this.#t;
|
|
330
|
+
}
|
|
331
|
+
get value() {
|
|
332
|
+
return this.#t.value.value;
|
|
333
|
+
}
|
|
334
|
+
set value(t) {
|
|
335
|
+
this.#t.value.value = t, t ? this.setAttribute("value", t) : this.removeAttribute("value");
|
|
336
|
+
}
|
|
337
|
+
get disabled() {
|
|
338
|
+
return this.#e.value;
|
|
339
|
+
}
|
|
340
|
+
set disabled(t) {
|
|
341
|
+
this.#e.value = t, this.toggleAttribute("disabled", t);
|
|
342
|
+
}
|
|
343
|
+
get range() {
|
|
344
|
+
return this.hasAttribute("range");
|
|
345
|
+
}
|
|
346
|
+
attributeChangedCallback(t, e, i) {
|
|
347
|
+
if (e !== i) {
|
|
348
|
+
switch (t) {
|
|
349
|
+
case "value":
|
|
350
|
+
this.#t.value.value = i;
|
|
351
|
+
break;
|
|
352
|
+
case "min":
|
|
353
|
+
this.#t.min.value = i;
|
|
354
|
+
break;
|
|
355
|
+
case "max":
|
|
356
|
+
this.#t.max.value = i;
|
|
357
|
+
break;
|
|
358
|
+
case "disabled":
|
|
359
|
+
this.#e.value = i !== null;
|
|
360
|
+
break;
|
|
361
|
+
case "range":
|
|
362
|
+
this.#s = "idle", this.#t.setRange(null, null);
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
super.attributeChangedCallback?.(t, e, i);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
activate() {
|
|
369
|
+
super.activate(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0");
|
|
370
|
+
const t = this.getAttribute("value"), e = this.getAttribute("min"), i = this.getAttribute("max");
|
|
371
|
+
$(() => {
|
|
372
|
+
t && (this.#t.value.value = t), e && (this.#t.min.value = e), i && (this.#t.max.value = i);
|
|
373
|
+
}), this.#u(), this.addEventListener("keydown", this.#C), this.addEffect(() => this.#i()), this.addEffect(() => {
|
|
374
|
+
this.setAttribute("aria-label", this.#t.title.value);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
dispose() {
|
|
378
|
+
this.querySelector('aui-button[data-role="prev"]')?.removeEventListener("click", this.#m), this.querySelector('aui-button[data-role="next"]')?.removeEventListener("click", this.#f), this.querySelector('aui-button[data-role="title"]')?.removeEventListener("click", this.#r);
|
|
379
|
+
const t = this.querySelector("[data-cal-grid]");
|
|
380
|
+
t?.removeEventListener("click", this.#c), t?.removeEventListener("pointermove", this.#o), t?.removeEventListener("pointerdown", this.#d), t?.removeEventListener("pointerup", this.#b), this.removeEventListener("keydown", this.#C), super.dispose();
|
|
381
|
+
}
|
|
382
|
+
#u() {
|
|
383
|
+
this.innerHTML = `
|
|
384
|
+
<div data-cal-header>
|
|
385
|
+
<aui-button data-role="prev" aria-label="Previous" tabindex="-1"><aui-icon name="caret-left"></aui-icon></aui-button>
|
|
386
|
+
<aui-button data-role="title" tabindex="-1"></aui-button>
|
|
387
|
+
<aui-button data-role="next" aria-label="Next" tabindex="-1"><aui-icon name="caret-right"></aui-icon></aui-button>
|
|
388
|
+
</div>
|
|
389
|
+
<div data-cal-weekdays></div>
|
|
390
|
+
<div data-cal-grid role="grid"></div>
|
|
391
|
+
`;
|
|
392
|
+
for (const a of this.querySelectorAll("[data-cal-header] aui-button"))
|
|
393
|
+
a.setAttribute("tabindex", "-1");
|
|
394
|
+
const t = this.querySelector('aui-button[data-role="prev"]'), e = this.querySelector('aui-button[data-role="next"]'), i = this.querySelector('aui-button[data-role="title"]');
|
|
395
|
+
t?.addEventListener("click", this.#m), e?.addEventListener("click", this.#f), i?.addEventListener("click", this.#r);
|
|
396
|
+
const s = this.querySelector("[data-cal-grid]");
|
|
397
|
+
s?.addEventListener("click", this.#c), s?.addEventListener("pointermove", this.#o), s?.addEventListener("pointerdown", this.#d), s?.addEventListener("pointerup", this.#b);
|
|
398
|
+
}
|
|
399
|
+
#i() {
|
|
400
|
+
const t = this.#t.view.value, e = this.querySelector('aui-button[data-role="title"]'), i = this.querySelector("[data-cal-weekdays]"), s = this.querySelector("[data-cal-grid]");
|
|
401
|
+
if (!(!e || !i || !s)) {
|
|
402
|
+
if (e.textContent = this.#t.title.value, t === "day") {
|
|
403
|
+
this.setAttribute("view", "day"), i.innerHTML = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((n) => `<span data-cal-weekday>${n}</span>`).join("");
|
|
404
|
+
const a = this.#t.days.value;
|
|
405
|
+
s.innerHTML = a.map((n, r) => {
|
|
406
|
+
let c = `data-date="${n.date}" data-index="${r}" tabindex="-1"`;
|
|
407
|
+
return n.inMonth || (c += " data-outside"), n.isToday && (c += ' data-today aria-current="date"'), n.isSelected && (c += ' data-selected aria-selected="true"'), n.isDisabled && (c += " disabled"), n.inRange && (c += " data-in-range"), n.isRangeStart && (c += " data-range-start"), n.isRangeEnd && (c += " data-range-end"), `<div data-cal-day ${c}>${n.day}</div>`;
|
|
408
|
+
}).join("");
|
|
409
|
+
} else if (t === "month") {
|
|
410
|
+
this.setAttribute("view", "month"), i.innerHTML = "";
|
|
411
|
+
const a = this.#t.months.value;
|
|
412
|
+
s.innerHTML = a.map((n) => {
|
|
413
|
+
let r = `data-month="${n.month}" tabindex="-1"`;
|
|
414
|
+
return n.isCurrent && (r += ' data-today aria-current="date"'), n.isSelected && (r += ' data-selected aria-selected="true"'), `<div data-cal-cell ${r}>${n.name}</div>`;
|
|
415
|
+
}).join("");
|
|
416
|
+
} else {
|
|
417
|
+
this.setAttribute("view", "year"), i.innerHTML = "";
|
|
418
|
+
const a = this.#t.years.value;
|
|
419
|
+
s.innerHTML = a.map((n) => {
|
|
420
|
+
let r = `data-year="${n.year}" tabindex="-1"`;
|
|
421
|
+
return n.inDecade || (r += " data-outside"), n.isCurrent && (r += ' data-today aria-current="date"'), n.isSelected && (r += ' data-selected aria-selected="true"'), `<div data-cal-cell ${r}>${n.year}</div>`;
|
|
422
|
+
}).join("");
|
|
423
|
+
}
|
|
424
|
+
for (const a of s.querySelectorAll("[data-cal-day]:not([disabled]), [data-cal-cell]"))
|
|
425
|
+
a.setAttribute("tabindex", "-1");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
#m = () => {
|
|
429
|
+
this.#A();
|
|
430
|
+
};
|
|
431
|
+
#f = () => {
|
|
432
|
+
this.#w();
|
|
433
|
+
};
|
|
434
|
+
#r = () => {
|
|
435
|
+
this.#v();
|
|
436
|
+
};
|
|
437
|
+
#c = (t) => {
|
|
438
|
+
this.#y(t);
|
|
439
|
+
};
|
|
440
|
+
#o = (t) => {
|
|
441
|
+
this.#E(t);
|
|
442
|
+
};
|
|
443
|
+
#d = (t) => {
|
|
444
|
+
this.#k(t);
|
|
445
|
+
};
|
|
446
|
+
#b = (t) => {
|
|
447
|
+
this.#p(t);
|
|
448
|
+
};
|
|
449
|
+
#A() {
|
|
450
|
+
const t = this.#t.view.value;
|
|
451
|
+
t === "day" ? this.#t.prevMonth() : t === "month" ? this.#t.prevYear() : this.#t.prevDecade();
|
|
452
|
+
}
|
|
453
|
+
#w() {
|
|
454
|
+
const t = this.#t.view.value;
|
|
455
|
+
t === "day" ? this.#t.nextMonth() : t === "month" ? this.#t.nextYear() : this.#t.nextDecade();
|
|
456
|
+
}
|
|
457
|
+
#v() {
|
|
458
|
+
const t = this.#t.view.value;
|
|
459
|
+
t === "day" ? this.#t.view.value = "month" : t === "month" && (this.#t.view.value = "year");
|
|
460
|
+
}
|
|
461
|
+
#y(t) {
|
|
462
|
+
if (this.#e.value) return;
|
|
463
|
+
const e = t.target.closest("[data-cal-day], [data-cal-cell]");
|
|
464
|
+
if (!e || e.hasAttribute("disabled")) return;
|
|
465
|
+
const i = e.dataset.date, s = e.dataset.month, a = e.dataset.year;
|
|
466
|
+
i ? this.#h(i) : s !== void 0 ? this.#t.selectMonth(Number(s)) : a !== void 0 && this.#t.selectYear(Number(a));
|
|
467
|
+
}
|
|
468
|
+
#h(t) {
|
|
469
|
+
this.range ? this.#s === "idle" ? ($(() => {
|
|
470
|
+
this.#t.selectDate(t), this.#t.setRange(t, null);
|
|
471
|
+
}), this.setAttribute("value", t), this.#s = "selecting") : this.#s === "selecting" ? this.#g(t) : ($(() => {
|
|
472
|
+
this.#t.value.value = null, this.#t.setRange(null, null);
|
|
473
|
+
}), this.removeAttribute("value"), this.#s = "idle") : (this.#t.selectDate(t), this.setAttribute("value", t), this.dispatchEvent(new CustomEvent("change", {
|
|
474
|
+
bubbles: !0,
|
|
475
|
+
composed: !0,
|
|
476
|
+
detail: { value: t }
|
|
477
|
+
})));
|
|
478
|
+
}
|
|
479
|
+
#g(t) {
|
|
480
|
+
const e = this.#t.rangeStart.value;
|
|
481
|
+
e && (this.#t.setRange(e, t), this.#s = "committed", this.#l = !1, this.dispatchEvent(new CustomEvent("aui:range-select", {
|
|
482
|
+
bubbles: !0,
|
|
483
|
+
composed: !0,
|
|
484
|
+
detail: { start: this.#t.rangeStart.value, end: this.#t.rangeEnd.value }
|
|
485
|
+
})));
|
|
486
|
+
}
|
|
487
|
+
#k(t) {
|
|
488
|
+
if (this.#e.value || !this.range || t.button !== 0) return;
|
|
489
|
+
const e = t.target.closest("[data-cal-day]");
|
|
490
|
+
if (!e || e.hasAttribute("disabled")) return;
|
|
491
|
+
const i = e.dataset.date;
|
|
492
|
+
i && (this.#l = !0, (this.#s === "idle" || this.#s === "committed") && ($(() => {
|
|
493
|
+
this.#t.selectDate(i), this.#t.setRange(i, null);
|
|
494
|
+
}), this.setAttribute("value", i), this.#s = "selecting"));
|
|
495
|
+
}
|
|
496
|
+
#p(t) {
|
|
497
|
+
if (!this.#l || (this.#l = !1, this.#s !== "selecting")) return;
|
|
498
|
+
const e = t.target.closest("[data-cal-day]");
|
|
499
|
+
if (!e || e.hasAttribute("disabled")) return;
|
|
500
|
+
const i = e.dataset.date;
|
|
501
|
+
if (!i) return;
|
|
502
|
+
const s = this.#t.rangeStart.value;
|
|
503
|
+
s && s !== i && this.#g(i);
|
|
504
|
+
}
|
|
505
|
+
#E(t) {
|
|
506
|
+
if (this.#e.value || !this.range || this.#s !== "selecting") return;
|
|
507
|
+
const e = t.target.closest("[data-cal-day]");
|
|
508
|
+
if (!e || e.hasAttribute("disabled")) return;
|
|
509
|
+
const i = e.dataset.date;
|
|
510
|
+
if (!i) return;
|
|
511
|
+
const s = this.#t.rangeStart.value;
|
|
512
|
+
s && this.#t.setRange(s, i);
|
|
513
|
+
}
|
|
514
|
+
#C = (t) => {
|
|
515
|
+
if (this.#e.value || this.#t.view.value !== "day") return;
|
|
516
|
+
const i = this.#t.days.value;
|
|
517
|
+
let s = this.#a.value, a = !0;
|
|
518
|
+
switch (t.key) {
|
|
519
|
+
case "ArrowRight":
|
|
520
|
+
s += 1;
|
|
521
|
+
break;
|
|
522
|
+
case "ArrowLeft":
|
|
523
|
+
s -= 1;
|
|
524
|
+
break;
|
|
525
|
+
case "ArrowDown":
|
|
526
|
+
s += 7;
|
|
527
|
+
break;
|
|
528
|
+
case "ArrowUp":
|
|
529
|
+
s -= 7;
|
|
530
|
+
break;
|
|
531
|
+
case "Home":
|
|
532
|
+
s = s - s % 7;
|
|
533
|
+
break;
|
|
534
|
+
case "End":
|
|
535
|
+
s = s - s % 7 + 6;
|
|
536
|
+
break;
|
|
537
|
+
case "PageDown":
|
|
538
|
+
t.shiftKey ? this.#t.nextYear() : this.#t.nextMonth();
|
|
539
|
+
break;
|
|
540
|
+
case "PageUp":
|
|
541
|
+
t.shiftKey ? this.#t.prevYear() : this.#t.prevMonth();
|
|
542
|
+
break;
|
|
543
|
+
case "Enter":
|
|
544
|
+
case " ": {
|
|
545
|
+
const n = i[s];
|
|
546
|
+
n && !n.isDisabled && this.#h(n.date);
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
default:
|
|
550
|
+
a = !1;
|
|
551
|
+
}
|
|
552
|
+
a && (t.preventDefault(), s = Math.max(0, Math.min(41, s)), this.#a.value = s, s < 0 && this.#t.prevMonth(), s > 41 && this.#t.nextMonth());
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
let pe = 0;
|
|
556
|
+
function H(m) {
|
|
557
|
+
return `${m}-${Date.now().toString(36)}-${(++pe).toString(36)}`;
|
|
558
|
+
}
|
|
559
|
+
const be = 50, M = "http://www.w3.org/2000/svg";
|
|
560
|
+
class ge {
|
|
561
|
+
host;
|
|
562
|
+
// ── Public mutable options ──
|
|
563
|
+
selector;
|
|
564
|
+
editable;
|
|
565
|
+
color;
|
|
566
|
+
strokeWidth;
|
|
567
|
+
tension;
|
|
568
|
+
showPorts;
|
|
569
|
+
portSize;
|
|
570
|
+
style;
|
|
571
|
+
animated;
|
|
572
|
+
disabled;
|
|
573
|
+
// ── Private state ──
|
|
574
|
+
#n = !1;
|
|
575
|
+
#t = null;
|
|
576
|
+
#e = /* @__PURE__ */ new Map();
|
|
577
|
+
#a = null;
|
|
578
|
+
#s = null;
|
|
579
|
+
#l = [];
|
|
580
|
+
#u = null;
|
|
581
|
+
#i = null;
|
|
582
|
+
#m = null;
|
|
583
|
+
#f = null;
|
|
584
|
+
#r = 0;
|
|
585
|
+
#c = !1;
|
|
586
|
+
#o = !1;
|
|
587
|
+
#d = null;
|
|
588
|
+
constructor(t, e = {}) {
|
|
589
|
+
if (this.host = t, this.selector = e.selector ?? "[data-noodle-port]", this.editable = e.editable ?? !1, this.color = e.color ?? "var(--aui-accent-500)", this.strokeWidth = e.strokeWidth ?? 2, this.tension = e.tension ?? 0.5, this.showPorts = e.showPorts ?? this.editable, this.portSize = e.portSize ?? 10, this.style = e.style ?? "bezier", this.animated = e.animated ?? !1, this.disabled = e.disabled ?? !1, e.connections)
|
|
590
|
+
for (const i of e.connections)
|
|
591
|
+
this.#e.set(i.id, {
|
|
592
|
+
...i,
|
|
593
|
+
fromPort: i.fromPort ?? "right",
|
|
594
|
+
toPort: i.toPort ?? "left"
|
|
595
|
+
});
|
|
596
|
+
this.attach();
|
|
597
|
+
}
|
|
598
|
+
// ── Lifecycle ──
|
|
599
|
+
attach() {
|
|
600
|
+
if (this.#n) return;
|
|
601
|
+
this.#n = !0, getComputedStyle(this.host).position === "static" && (this.host.style.position = "relative"), this.host.style.isolation = "isolate", this.#b(), this.#w(), this.#R(), this.showPorts && this.#S(), this.host.addEventListener("aui:magnet-snap", this.#x), this.host.addEventListener("aui:magnet-drop", this.#x), this.host.addEventListener("aui:drag-move", this.#x), this.#p();
|
|
602
|
+
}
|
|
603
|
+
detach() {
|
|
604
|
+
this.#n && (this.#n = !1, this.#z(), this.#T(), this.#A(), this.#v(), this.host.style.isolation = "", this.host.removeEventListener("aui:magnet-snap", this.#x), this.host.removeEventListener("aui:magnet-drop", this.#x), this.host.removeEventListener("aui:drag-move", this.#x), this.#r && (cancelAnimationFrame(this.#r), this.#r = 0), this.#c = !1);
|
|
605
|
+
}
|
|
606
|
+
destroy() {
|
|
607
|
+
this.#M(), this.detach(), this.#e.clear();
|
|
608
|
+
}
|
|
609
|
+
// ── Public API ──
|
|
610
|
+
/** Add a connection. Returns the connection ID. */
|
|
611
|
+
connect(t, e, i = "right", s = "left") {
|
|
612
|
+
const a = H("noodle"), n = { id: a, from: t, to: e, fromPort: i, toPort: s };
|
|
613
|
+
return this.#e.set(a, n), this.#p(), this.host.dispatchEvent(new CustomEvent("aui:noodle-connect", {
|
|
614
|
+
bubbles: !0,
|
|
615
|
+
composed: !0,
|
|
616
|
+
detail: { id: a, from: t, to: e, fromPort: i, toPort: s }
|
|
617
|
+
})), a;
|
|
618
|
+
}
|
|
619
|
+
/** Remove a connection by ID. */
|
|
620
|
+
disconnect(t) {
|
|
621
|
+
const e = this.#e.get(t);
|
|
622
|
+
return e ? (this.#e.delete(t), this.#p(), this.host.dispatchEvent(new CustomEvent("aui:noodle-disconnect", {
|
|
623
|
+
bubbles: !0,
|
|
624
|
+
composed: !0,
|
|
625
|
+
detail: { id: t, from: e.from, to: e.to, fromPort: e.fromPort, toPort: e.toPort }
|
|
626
|
+
})), !0) : !1;
|
|
627
|
+
}
|
|
628
|
+
/** Remove all connections. */
|
|
629
|
+
clear() {
|
|
630
|
+
const t = [...this.#e.values()];
|
|
631
|
+
this.#e.clear(), this.#p();
|
|
632
|
+
for (const e of t)
|
|
633
|
+
this.host.dispatchEvent(new CustomEvent("aui:noodle-disconnect", {
|
|
634
|
+
bubbles: !0,
|
|
635
|
+
composed: !0,
|
|
636
|
+
detail: { id: e.id, from: e.from, to: e.to, fromPort: e.fromPort, toPort: e.toPort }
|
|
637
|
+
}));
|
|
638
|
+
}
|
|
639
|
+
/** Get all current connections. */
|
|
640
|
+
getConnections() {
|
|
641
|
+
return [...this.#e.values()];
|
|
642
|
+
}
|
|
643
|
+
/** Replace all connections. */
|
|
644
|
+
setConnections(t) {
|
|
645
|
+
this.#e.clear();
|
|
646
|
+
for (const e of t)
|
|
647
|
+
this.#e.set(e.id ?? H("noodle"), {
|
|
648
|
+
...e,
|
|
649
|
+
fromPort: e.fromPort ?? "right",
|
|
650
|
+
toPort: e.toPort ?? "left"
|
|
651
|
+
});
|
|
652
|
+
this.#p();
|
|
653
|
+
}
|
|
654
|
+
/** Force re-render all paths and rebuild port indicators.
|
|
655
|
+
* Call after programmatic element moves or when the set of port elements changes. */
|
|
656
|
+
update() {
|
|
657
|
+
this.#p(), this.showPorts && !this.#u && this.#S();
|
|
658
|
+
}
|
|
659
|
+
// ── SVG overlay ──
|
|
660
|
+
#b() {
|
|
661
|
+
const t = document.createElementNS(M, "svg");
|
|
662
|
+
t.setAttribute("data-noodle-svg", ""), t.style.cssText = "position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible;z-index:0;", this.#s = document.createElementNS(M, "g"), this.#s.setAttribute("data-noodle-hits", ""), t.appendChild(this.#s), this.#a = document.createElementNS(M, "g"), this.#a.setAttribute("data-noodle-paths", ""), t.appendChild(this.#a), this.host.appendChild(t), this.#t = t;
|
|
663
|
+
}
|
|
664
|
+
#A() {
|
|
665
|
+
this.#t?.remove(), this.#t = null, this.#a = null, this.#s = null;
|
|
666
|
+
}
|
|
667
|
+
#w() {
|
|
668
|
+
if (this.#d) return;
|
|
669
|
+
const t = document.createElement("style");
|
|
670
|
+
t.textContent = "@keyframes noodle-flow{to{stroke-dashoffset:-12}}", this.host.appendChild(t), this.#d = t;
|
|
671
|
+
}
|
|
672
|
+
#v() {
|
|
673
|
+
this.#d?.remove(), this.#d = null;
|
|
674
|
+
}
|
|
675
|
+
// ── Coordinate helpers ──
|
|
676
|
+
/** Convert client (screen) coordinates to the host's layout coordinate space,
|
|
677
|
+
* accounting for CSS transforms (zoom/pan) on the host or its ancestors. */
|
|
678
|
+
#y(t, e) {
|
|
679
|
+
const i = this.host.getBoundingClientRect(), s = i.width / (this.host.clientWidth || 1), a = i.height / (this.host.clientHeight || 1);
|
|
680
|
+
return {
|
|
681
|
+
x: (t - i.left) / s,
|
|
682
|
+
y: (e - i.top) / a
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
// ── Path computation ──
|
|
686
|
+
#h(t, e) {
|
|
687
|
+
const i = this.host.querySelector(`#${CSS.escape(t)}`);
|
|
688
|
+
if (!i) return null;
|
|
689
|
+
let s = 0, a = 0, n = i;
|
|
690
|
+
for (; n && n !== this.host; ) {
|
|
691
|
+
s += n.offsetLeft, a += n.offsetTop;
|
|
692
|
+
const h = n.style.translate;
|
|
693
|
+
if (h) {
|
|
694
|
+
const f = h.match(/-?[\d.]+/g);
|
|
695
|
+
f && (s += parseFloat(f[0]) || 0, a += parseFloat(f[1]) || 0);
|
|
696
|
+
}
|
|
697
|
+
n = n.offsetParent;
|
|
698
|
+
}
|
|
699
|
+
const r = i.offsetWidth, c = i.offsetHeight;
|
|
700
|
+
switch (e) {
|
|
701
|
+
case "top":
|
|
702
|
+
return { x: s + r / 2, y: a };
|
|
703
|
+
case "right":
|
|
704
|
+
return { x: s + r, y: a + c / 2 };
|
|
705
|
+
case "bottom":
|
|
706
|
+
return { x: s + r / 2, y: a + c };
|
|
707
|
+
case "left":
|
|
708
|
+
return { x: s, y: a + c / 2 };
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
#g(t, e, i, s) {
|
|
712
|
+
switch (i) {
|
|
713
|
+
case "right":
|
|
714
|
+
return [t + s, e];
|
|
715
|
+
case "left":
|
|
716
|
+
return [t - s, e];
|
|
717
|
+
case "bottom":
|
|
718
|
+
return [t, e + s];
|
|
719
|
+
case "top":
|
|
720
|
+
return [t, e - s];
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
#k(t) {
|
|
724
|
+
const e = this.#h(t.from, t.fromPort), i = this.#h(t.to, t.toPort);
|
|
725
|
+
if (!e || !i) return null;
|
|
726
|
+
switch (this.style) {
|
|
727
|
+
case "straight":
|
|
728
|
+
return `M ${e.x} ${e.y} L ${i.x} ${i.y}`;
|
|
729
|
+
case "step": {
|
|
730
|
+
const s = (e.x + i.x) / 2;
|
|
731
|
+
return `M ${e.x} ${e.y} L ${s} ${e.y} L ${s} ${i.y} L ${i.x} ${i.y}`;
|
|
732
|
+
}
|
|
733
|
+
case "bezier":
|
|
734
|
+
default: {
|
|
735
|
+
const s = Math.max(Math.abs(i.x - e.x), Math.abs(i.y - e.y)), a = Math.max(50, s * this.tension), [n, r] = this.#g(e.x, e.y, t.fromPort, a), [c, h] = this.#g(i.x, i.y, t.toPort, a);
|
|
736
|
+
return `M ${e.x} ${e.y} C ${n} ${r}, ${c} ${h}, ${i.x} ${i.y}`;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
// ── Rendering ──
|
|
741
|
+
#p() {
|
|
742
|
+
if (!(!this.#a || !this.#s)) {
|
|
743
|
+
this.#o = !0, this.#a.textContent = "", this.#s.textContent = "", this.#i && this.#a.appendChild(this.#i);
|
|
744
|
+
for (const t of this.#e.values()) {
|
|
745
|
+
const e = this.#k(t);
|
|
746
|
+
if (!e) continue;
|
|
747
|
+
if (this.editable) {
|
|
748
|
+
const s = document.createElementNS(M, "path");
|
|
749
|
+
s.setAttribute("d", e), s.setAttribute("stroke", "transparent"), s.setAttribute("stroke-width", "14"), s.setAttribute("fill", "none"), s.style.pointerEvents = "stroke", s.style.cursor = "pointer", s.dataset.noodleId = t.id, s.addEventListener("pointerdown", this.#q), this.#s.appendChild(s);
|
|
750
|
+
}
|
|
751
|
+
const i = document.createElementNS(M, "path");
|
|
752
|
+
i.setAttribute("d", e), i.setAttribute("fill", "none"), i.setAttribute("stroke-linecap", "round"), this.disabled ? (i.setAttribute("stroke", "var(--aui-ink-muted)"), i.setAttribute("stroke-width", String(this.strokeWidth)), i.setAttribute("stroke-dasharray", "6 4"), i.style.opacity = "0.6") : (i.setAttribute("stroke", t.color ?? this.color), i.setAttribute("stroke-width", String(this.strokeWidth)), this.animated && (i.setAttribute("stroke-dasharray", "8 4"), i.style.animation = "noodle-flow 0.6s linear infinite")), this.#a.appendChild(i);
|
|
753
|
+
}
|
|
754
|
+
this.#u || queueMicrotask(() => {
|
|
755
|
+
this.#o = !1;
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
#E() {
|
|
760
|
+
this.#c || (this.#c = !0, this.#r = requestAnimationFrame(() => {
|
|
761
|
+
this.#c = !1, this.#p(), this.showPorts && this.#D();
|
|
762
|
+
}));
|
|
763
|
+
}
|
|
764
|
+
/** Full update: recreate port indicators (for child list changes). */
|
|
765
|
+
#C() {
|
|
766
|
+
this.#c || (this.#c = !0, this.#r = requestAnimationFrame(() => {
|
|
767
|
+
this.#c = !1, this.#p(), this.showPorts && !this.#u && this.#S();
|
|
768
|
+
}));
|
|
769
|
+
}
|
|
770
|
+
// ── Port indicators (edit mode) ──
|
|
771
|
+
#S() {
|
|
772
|
+
this.#o = !0, this.#T();
|
|
773
|
+
const t = this.host.querySelectorAll(this.selector);
|
|
774
|
+
for (const e of t) {
|
|
775
|
+
const i = (e.getAttribute("data-noodle-port") ?? "").split(/\s+/).filter(Boolean), s = e.id;
|
|
776
|
+
if (s)
|
|
777
|
+
for (const a of i) {
|
|
778
|
+
const n = document.createElement("div");
|
|
779
|
+
n.setAttribute("data-noodle-port-indicator", ""), n.setAttribute("data-noodle-side", a), n.setAttribute("data-noodle-target", s), n.style.cssText = `position:absolute;width:${this.portSize}px;height:${this.portSize}px;border-radius:50%;background:${this.color};border:2px solid white;pointer-events:auto;cursor:crosshair;z-index:5;touch-action:none;transform:translate(-50%,-50%);transition:transform 150ms ease,box-shadow 150ms ease;box-shadow:0 1px 3px rgba(0,0,0,0.2);`, n.addEventListener("pointerdown", this.#I), this.host.appendChild(n), this.#l.push(n);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
this.#D(), this.#u || queueMicrotask(() => {
|
|
783
|
+
this.#o = !1;
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
#D() {
|
|
787
|
+
for (const t of this.#l) {
|
|
788
|
+
const e = t.getAttribute("data-noodle-target"), i = t.getAttribute("data-noodle-side"), s = this.#h(e, i);
|
|
789
|
+
s && (t.style.left = `${s.x}px`, t.style.top = `${s.y}px`);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
#T() {
|
|
793
|
+
for (const t of this.#l)
|
|
794
|
+
t.removeEventListener("pointerdown", this.#I), t.remove();
|
|
795
|
+
this.#l = [];
|
|
796
|
+
}
|
|
797
|
+
// ── Edit mode: drag-to-connect ──
|
|
798
|
+
#I = (t) => {
|
|
799
|
+
if (this.disabled || !this.editable || t.button !== 0) return;
|
|
800
|
+
const e = t.target.closest("[data-noodle-port-indicator]");
|
|
801
|
+
if (!e) return;
|
|
802
|
+
t.preventDefault(), t.stopPropagation();
|
|
803
|
+
const i = e.getAttribute("data-noodle-target"), s = e.getAttribute("data-noodle-side"), a = this.host.querySelector(`#${CSS.escape(i)}`);
|
|
804
|
+
if (a) {
|
|
805
|
+
this.#u = {
|
|
806
|
+
fromElement: a,
|
|
807
|
+
fromPort: s,
|
|
808
|
+
fromId: i,
|
|
809
|
+
pointerId: t.pointerId,
|
|
810
|
+
sourceDot: e
|
|
811
|
+
}, e.setAttribute("data-noodle-dragging", "");
|
|
812
|
+
for (const n of this.#l) {
|
|
813
|
+
if (n === e) continue;
|
|
814
|
+
const r = n.getAttribute("data-noodle-target"), c = n.getAttribute("data-noodle-side");
|
|
815
|
+
r === i && c === s || n.setAttribute("data-noodle-droppable", "");
|
|
816
|
+
}
|
|
817
|
+
this.#o = !0, this.#i = document.createElementNS(M, "path"), this.#i.setAttribute("stroke", "var(--aui-ink-muted)"), this.#i.setAttribute("stroke-width", String(this.strokeWidth)), this.#i.setAttribute("fill", "none"), this.#i.setAttribute("stroke-dasharray", "6 4"), this.#i.setAttribute("stroke-linecap", "round"), this.#i.style.opacity = "0.7", this.#a?.appendChild(this.#i), this.host.dispatchEvent(new CustomEvent("aui:noodle-drag", {
|
|
818
|
+
bubbles: !0,
|
|
819
|
+
composed: !0,
|
|
820
|
+
detail: { from: i, fromPort: s, x: t.clientX, y: t.clientY }
|
|
821
|
+
})), document.addEventListener("pointermove", this.#P), document.addEventListener("pointerup", this.#$), document.addEventListener("pointercancel", this.#L);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
#P = (t) => {
|
|
825
|
+
const e = this.#u;
|
|
826
|
+
if (!e || !this.#i) return;
|
|
827
|
+
const i = this.#h(e.fromId, e.fromPort);
|
|
828
|
+
if (!i) return;
|
|
829
|
+
const { x: s, y: a } = this.#y(t.clientX, t.clientY), n = Math.max(Math.abs(s - i.x), Math.abs(a - i.y)), r = Math.max(50, n * this.tension), [c, h] = this.#g(i.x, i.y, e.fromPort, r), f = `M ${i.x} ${i.y} C ${c} ${h}, ${s} ${a}, ${s} ${a}`;
|
|
830
|
+
this.#i.setAttribute("d", f), this.#Y(t.clientX, t.clientY);
|
|
831
|
+
};
|
|
832
|
+
#$ = (t) => {
|
|
833
|
+
const e = this.#u;
|
|
834
|
+
if (!e) return;
|
|
835
|
+
const i = this.#N(t.clientX, t.clientY);
|
|
836
|
+
if (i) {
|
|
837
|
+
const s = i.getAttribute("data-noodle-target"), a = i.getAttribute("data-noodle-side");
|
|
838
|
+
(s !== e.fromId || a !== e.fromPort) && this.connect(e.fromId, s, e.fromPort, a);
|
|
839
|
+
}
|
|
840
|
+
this.#M();
|
|
841
|
+
};
|
|
842
|
+
#L = () => {
|
|
843
|
+
this.#M();
|
|
844
|
+
};
|
|
845
|
+
#M() {
|
|
846
|
+
for (const t of this.#l)
|
|
847
|
+
t.removeAttribute("data-noodle-dragging"), t.removeAttribute("data-noodle-droppable"), t.removeAttribute("data-noodle-drop-ready");
|
|
848
|
+
this.#i?.remove(), this.#i = null, this.#u = null, document.removeEventListener("pointermove", this.#P), document.removeEventListener("pointerup", this.#$), document.removeEventListener("pointercancel", this.#L), this.#o = !1;
|
|
849
|
+
}
|
|
850
|
+
// ── Proximity helpers ──
|
|
851
|
+
/** Find the nearest droppable port within DROP_SNAP_RADIUS of a screen point. */
|
|
852
|
+
#N(t, e) {
|
|
853
|
+
let i = null, s = be;
|
|
854
|
+
for (const a of this.#l) {
|
|
855
|
+
if (!a.hasAttribute("data-noodle-droppable")) continue;
|
|
856
|
+
const n = a.getBoundingClientRect(), r = n.left + n.width / 2, c = n.top + n.height / 2, h = Math.hypot(t - r, e - c);
|
|
857
|
+
h < s && (s = h, i = a);
|
|
858
|
+
}
|
|
859
|
+
return i;
|
|
860
|
+
}
|
|
861
|
+
/** Toggle data-noodle-drop-ready on the nearest droppable port and update drag path color. */
|
|
862
|
+
#Y(t, e) {
|
|
863
|
+
const i = this.#N(t, e);
|
|
864
|
+
for (const s of this.#l)
|
|
865
|
+
s === i ? s.setAttribute("data-noodle-drop-ready", "") : s.removeAttribute("data-noodle-drop-ready");
|
|
866
|
+
if (i && this.#i && this.#u) {
|
|
867
|
+
this.#i.setAttribute("stroke", this.color), this.#i.style.opacity = "1", this.#i.removeAttribute("stroke-dasharray");
|
|
868
|
+
const s = i.getAttribute("data-noodle-target"), a = i.getAttribute("data-noodle-side"), n = this.#h(s, a), r = this.#h(this.#u.fromId, this.#u.fromPort);
|
|
869
|
+
if (r && n) {
|
|
870
|
+
const c = Math.max(Math.abs(n.x - r.x), Math.abs(n.y - r.y)), h = Math.max(50, c * this.tension), [f, u] = this.#g(r.x, r.y, this.#u.fromPort, h), [l, v] = this.#g(n.x, n.y, a, h);
|
|
871
|
+
this.#i.setAttribute("d", `M ${r.x} ${r.y} C ${f} ${u}, ${l} ${v}, ${n.x} ${n.y}`);
|
|
872
|
+
}
|
|
873
|
+
} else this.#i && (this.#i.setAttribute("stroke", "var(--aui-ink-muted)"), this.#i.style.opacity = "0.7", this.#i.setAttribute("stroke-dasharray", "6 4"));
|
|
874
|
+
}
|
|
875
|
+
// ── Reconnect drag (grab existing noodle near endpoint) ──
|
|
876
|
+
#q = (t) => {
|
|
877
|
+
if (this.disabled || !this.editable || t.button !== 0) return;
|
|
878
|
+
const i = t.target.dataset.noodleId;
|
|
879
|
+
if (!i) return;
|
|
880
|
+
const s = this.#e.get(i);
|
|
881
|
+
if (!s) return;
|
|
882
|
+
t.preventDefault(), t.stopPropagation(), this.#o = !0;
|
|
883
|
+
const a = this.#h(s.from, s.fromPort), n = this.#h(s.to, s.toPort);
|
|
884
|
+
if (!a || !n) {
|
|
885
|
+
this.#o = !1;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
const { x: r, y: c } = this.#y(t.clientX, t.clientY), h = Math.hypot(r - a.x, c - a.y), f = Math.hypot(r - n.x, c - n.y), u = h < f ? s.to : s.from, l = h < f ? s.toPort : s.fromPort;
|
|
889
|
+
this.disconnect(i);
|
|
890
|
+
const v = this.#l.find(
|
|
891
|
+
(b) => b.getAttribute("data-noodle-target") === u && b.getAttribute("data-noodle-side") === l
|
|
892
|
+
);
|
|
893
|
+
if (!v) {
|
|
894
|
+
this.#o = !1;
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const d = this.host.querySelector(`#${CSS.escape(u)}`);
|
|
898
|
+
if (!d) {
|
|
899
|
+
this.#o = !1;
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
this.#u = {
|
|
903
|
+
fromElement: d,
|
|
904
|
+
fromPort: l,
|
|
905
|
+
fromId: u,
|
|
906
|
+
pointerId: t.pointerId,
|
|
907
|
+
sourceDot: v,
|
|
908
|
+
reconnectId: i
|
|
909
|
+
}, v.setAttribute("data-noodle-dragging", "");
|
|
910
|
+
for (const b of this.#l) {
|
|
911
|
+
if (b === v) continue;
|
|
912
|
+
const A = b.getAttribute("data-noodle-target"), P = b.getAttribute("data-noodle-side");
|
|
913
|
+
A === u && P === l || b.setAttribute("data-noodle-droppable", "");
|
|
914
|
+
}
|
|
915
|
+
this.#i = document.createElementNS(M, "path"), this.#i.setAttribute("stroke", "var(--aui-ink-muted)"), this.#i.setAttribute("stroke-width", String(this.strokeWidth)), this.#i.setAttribute("fill", "none"), this.#i.setAttribute("stroke-dasharray", "6 4"), this.#i.setAttribute("stroke-linecap", "round"), this.#i.style.opacity = "0.7";
|
|
916
|
+
const p = this.#h(u, l), { x: g, y: E } = this.#y(t.clientX, t.clientY);
|
|
917
|
+
if (p) {
|
|
918
|
+
const b = Math.max(Math.abs(g - p.x), Math.abs(E - p.y)), A = Math.max(50, b * this.tension), [P, C] = this.#g(p.x, p.y, l, A);
|
|
919
|
+
this.#i.setAttribute("d", `M ${p.x} ${p.y} C ${P} ${C}, ${g} ${E}, ${g} ${E}`);
|
|
920
|
+
}
|
|
921
|
+
this.#a?.appendChild(this.#i), this.host.dispatchEvent(new CustomEvent("aui:noodle-drag", {
|
|
922
|
+
bubbles: !0,
|
|
923
|
+
composed: !0,
|
|
924
|
+
detail: { from: u, fromPort: l, x: t.clientX, y: t.clientY, reconnect: !0 }
|
|
925
|
+
})), document.addEventListener("pointermove", this.#P), document.addEventListener("pointerup", this.#$), document.addEventListener("pointercancel", this.#L);
|
|
926
|
+
};
|
|
927
|
+
// ── Movement tracking ──
|
|
928
|
+
#x = () => {
|
|
929
|
+
this.#E();
|
|
930
|
+
};
|
|
931
|
+
#R() {
|
|
932
|
+
this.#m = new ResizeObserver(() => this.#E()), this.#m.observe(this.host), this.#f = new MutationObserver((t) => {
|
|
933
|
+
if (this.#o) return;
|
|
934
|
+
t.some((i) => i.type === "childList") ? this.#C() : this.#E();
|
|
935
|
+
}), this.#f.observe(this.host, {
|
|
936
|
+
childList: !0,
|
|
937
|
+
subtree: !0,
|
|
938
|
+
attributes: !0,
|
|
939
|
+
attributeFilter: ["style", "class", "translate", "data-noodle-port"]
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
#z() {
|
|
943
|
+
this.#m?.disconnect(), this.#m = null, this.#f?.disconnect(), this.#f = null;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
class ve extends T {
|
|
947
|
+
static attributes = {
|
|
948
|
+
editable: { type: "boolean", default: !1 },
|
|
949
|
+
color: { type: "string", default: "" },
|
|
950
|
+
"stroke-width": { type: "string", default: "2" },
|
|
951
|
+
tension: { type: "string", default: "0.5" },
|
|
952
|
+
"show-ports": { type: "boolean", default: !1 },
|
|
953
|
+
"port-size": { type: "string", default: "10" },
|
|
954
|
+
curve: { type: "string", default: "bezier" },
|
|
955
|
+
animated: { type: "boolean", default: !1 },
|
|
956
|
+
disabled: { type: "boolean", default: !1 }
|
|
957
|
+
};
|
|
958
|
+
#n = null;
|
|
959
|
+
// ── Public API (pass-through) ──
|
|
960
|
+
/** Current connections. */
|
|
961
|
+
get connections() {
|
|
962
|
+
return this.#n?.getConnections() ?? [];
|
|
963
|
+
}
|
|
964
|
+
/** Create a connection between two elements. Returns the connection ID. */
|
|
965
|
+
connect(t, e, i, s) {
|
|
966
|
+
return this.#n.connect(t, e, i, s);
|
|
967
|
+
}
|
|
968
|
+
/** Remove a connection by ID. */
|
|
969
|
+
disconnect(t) {
|
|
970
|
+
return this.#n?.disconnect(t) ?? !1;
|
|
971
|
+
}
|
|
972
|
+
/** Replace all connections. */
|
|
973
|
+
setConnections(t) {
|
|
974
|
+
this.#n?.setConnections(t);
|
|
975
|
+
}
|
|
976
|
+
/** Remove all connections. */
|
|
977
|
+
clear() {
|
|
978
|
+
this.#n?.clear();
|
|
979
|
+
}
|
|
980
|
+
/** Force re-render paths and port indicators. */
|
|
981
|
+
update() {
|
|
982
|
+
this.#n?.update();
|
|
983
|
+
}
|
|
984
|
+
// ── Lifecycle ──
|
|
985
|
+
activate() {
|
|
986
|
+
this.#n = new ge(this, this.#t());
|
|
987
|
+
}
|
|
988
|
+
dispose() {
|
|
989
|
+
this.#n?.destroy(), this.#n = null;
|
|
990
|
+
}
|
|
991
|
+
attributeChangedCallback(t, e, i) {
|
|
992
|
+
e !== i && (super.attributeChangedCallback(t, e, i), this.#n && this.#e(t, i));
|
|
993
|
+
}
|
|
994
|
+
// ── Private ──
|
|
995
|
+
#t() {
|
|
996
|
+
const t = {};
|
|
997
|
+
this.hasAttribute("editable") && (t.editable = !0), this.hasAttribute("animated") && (t.animated = !0), this.hasAttribute("disabled") && (t.disabled = !0);
|
|
998
|
+
const e = this.getAttribute("color");
|
|
999
|
+
e && (t.color = e);
|
|
1000
|
+
const i = this.getAttribute("stroke-width");
|
|
1001
|
+
if (i) {
|
|
1002
|
+
const r = Number(i);
|
|
1003
|
+
isNaN(r) || (t.strokeWidth = r);
|
|
1004
|
+
}
|
|
1005
|
+
const s = this.getAttribute("tension");
|
|
1006
|
+
if (s) {
|
|
1007
|
+
const r = Number(s);
|
|
1008
|
+
isNaN(r) || (t.tension = r);
|
|
1009
|
+
}
|
|
1010
|
+
this.hasAttribute("show-ports") && (t.showPorts = this.getAttribute("show-ports") !== "false");
|
|
1011
|
+
const a = this.getAttribute("port-size");
|
|
1012
|
+
if (a) {
|
|
1013
|
+
const r = Number(a);
|
|
1014
|
+
isNaN(r) || (t.portSize = r);
|
|
1015
|
+
}
|
|
1016
|
+
const n = this.getAttribute("curve");
|
|
1017
|
+
return (n === "bezier" || n === "step" || n === "straight") && (t.style = n), t;
|
|
1018
|
+
}
|
|
1019
|
+
#e(t, e) {
|
|
1020
|
+
const i = this.#n;
|
|
1021
|
+
switch (t) {
|
|
1022
|
+
case "editable":
|
|
1023
|
+
i.editable = e !== null, i.update();
|
|
1024
|
+
break;
|
|
1025
|
+
case "color":
|
|
1026
|
+
i.color = e ?? "var(--aui-accent-500)", i.update();
|
|
1027
|
+
break;
|
|
1028
|
+
case "stroke-width": {
|
|
1029
|
+
const s = Number(e);
|
|
1030
|
+
isNaN(s) || (i.strokeWidth = s, i.update());
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
case "tension": {
|
|
1034
|
+
const s = Number(e);
|
|
1035
|
+
isNaN(s) || (i.tension = s, i.update());
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
case "show-ports":
|
|
1039
|
+
i.showPorts = e !== "false" && e !== null, i.update();
|
|
1040
|
+
break;
|
|
1041
|
+
case "port-size": {
|
|
1042
|
+
const s = Number(e);
|
|
1043
|
+
isNaN(s) || (i.portSize = s, i.update());
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
case "curve":
|
|
1047
|
+
(e === "bezier" || e === "step" || e === "straight") && (i.style = e, i.update());
|
|
1048
|
+
break;
|
|
1049
|
+
case "animated":
|
|
1050
|
+
i.animated = e !== null, i.update();
|
|
1051
|
+
break;
|
|
1052
|
+
case "disabled":
|
|
1053
|
+
i.disabled = e !== null, i.update();
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
const ye = '<svg width="20" height="20" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M92.2671 346.112C88.1711 262.144 202.347 250.88 288.875 237.568C288.363 202.752 290.923 133.12 221.291 133.12C206.955 133.12 197.227 134.144 186.987 137.216L189.547 147.968C228.459 148.992 238.187 173.056 237.163 193.024C235.115 229.888 196.715 242.688 169.579 242.688C141.419 242.688 104.555 227.328 106.091 186.88C107.627 143.872 163.435 112.64 250.987 112.64C348.779 112.64 403.563 139.776 403.563 244.736V351.744C403.563 369.152 407.659 375.296 417.387 375.296C422.507 375.296 427.627 369.664 431.723 361.984L444.523 369.152C423.019 401.408 391.275 415.744 362.603 415.744C302.699 415.744 279.147 377.856 308.331 313.856L296.043 309.76C277.611 386.048 232.555 415.744 180.331 415.744C135.787 415.744 94.3151 391.68 92.2671 346.112ZM202.859 327.168C208.491 348.672 227.435 357.888 245.355 351.232C267.883 343.04 285.291 311.808 288.363 265.216L288.875 257.536C232.555 267.776 191.083 283.136 202.859 327.168Z" fill="currentColor"/></svg>';
|
|
1059
|
+
function k(m) {
|
|
1060
|
+
return m.split("-").map((t) => t[0].toUpperCase() + t.slice(1)).join(" ");
|
|
1061
|
+
}
|
|
1062
|
+
class Ae extends T {
|
|
1063
|
+
static attributes = {
|
|
1064
|
+
src: { type: "string", default: "./preview.json" }
|
|
1065
|
+
};
|
|
1066
|
+
#n;
|
|
1067
|
+
#t;
|
|
1068
|
+
// Navigation state
|
|
1069
|
+
#e = null;
|
|
1070
|
+
#a = null;
|
|
1071
|
+
#s = null;
|
|
1072
|
+
activate() {
|
|
1073
|
+
this.#l();
|
|
1074
|
+
}
|
|
1075
|
+
dispose() {
|
|
1076
|
+
document.removeEventListener("keydown", this.#f);
|
|
1077
|
+
}
|
|
1078
|
+
async #l() {
|
|
1079
|
+
let t;
|
|
1080
|
+
try {
|
|
1081
|
+
t = await (await fetch(this.src)).json();
|
|
1082
|
+
} catch {
|
|
1083
|
+
this.textContent = "Failed to load preview.json";
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const { section: e, param: i, items: s, links: a } = t, r = new URL(this.src, window.location.href).href.replace(/preview\.json$/, ""), h = new URLSearchParams(location.search).get(i), f = document.createElement("div");
|
|
1087
|
+
f.setAttribute("data-role", "navbar");
|
|
1088
|
+
const u = document.createElement("aui-select");
|
|
1089
|
+
u.setAttribute("mode", "bar"), u.setAttribute("width", "full");
|
|
1090
|
+
const l = document.createElement("aui-option");
|
|
1091
|
+
l.setAttribute("value", ""), l.setAttribute("overflow-pin", ""), l.setAttribute("data-preview-logo", ""), l.dataset.href = window.location.pathname, l.innerHTML = `${ye} AgentUI`, u.appendChild(l);
|
|
1092
|
+
const v = "aui-preview-scheme", d = localStorage.getItem(v);
|
|
1093
|
+
d && (document.documentElement.dataset.theme = d, document.documentElement.style.colorScheme = d);
|
|
1094
|
+
const p = document.createElement("aui-button");
|
|
1095
|
+
p.setAttribute("ghost", ""), p.setAttribute("size", "sm"), p.setAttribute("hide-label", ""), p.setAttribute("label", "Toggle color scheme");
|
|
1096
|
+
const g = document.createElement("aui-icon"), E = document.documentElement.dataset.theme === "dark";
|
|
1097
|
+
g.setAttribute("name", E ? "sun" : "moon"), p.appendChild(g), u.appendChild(p), p.addEventListener("click", () => {
|
|
1098
|
+
const y = document.documentElement, x = y.dataset.theme === "dark", w = x ? "light" : "dark";
|
|
1099
|
+
y.dataset.theme = w, y.style.colorScheme = w, localStorage.setItem(v, w), g.setAttribute("name", x ? "moon" : "sun");
|
|
1100
|
+
});
|
|
1101
|
+
const b = document.createElement("aui-select");
|
|
1102
|
+
if (b.setAttribute("placeholder", k(e)), b.setAttribute("outline", ""), b.setAttribute("data-role", "page-select"), a.length) {
|
|
1103
|
+
const y = document.createElement("aui-optgroup");
|
|
1104
|
+
y.setAttribute("label", "Sections");
|
|
1105
|
+
for (const x of a) {
|
|
1106
|
+
const w = document.createElement("aui-option");
|
|
1107
|
+
w.setAttribute("value", `go-${x.label.toLowerCase()}`), w.dataset.href = x.href, w.textContent = x.label, y.appendChild(w);
|
|
1108
|
+
}
|
|
1109
|
+
b.appendChild(y);
|
|
1110
|
+
}
|
|
1111
|
+
let A = null, P = "";
|
|
1112
|
+
for (const y of s) {
|
|
1113
|
+
const x = y.group || k(e);
|
|
1114
|
+
x !== P && (A = document.createElement("aui-optgroup"), A.setAttribute("label", x), b.appendChild(A), P = x);
|
|
1115
|
+
const w = document.createElement("aui-option");
|
|
1116
|
+
w.setAttribute("value", y.slug), y.file && (w.dataset.file = y.file), y.slug === h && w.setAttribute("selected", ""), w.textContent = y.name || k(y.slug), A.appendChild(w);
|
|
1117
|
+
}
|
|
1118
|
+
h && b.setAttribute("value", h), u.appendChild(b), f.appendChild(u), this.appendChild(f);
|
|
1119
|
+
const C = document.createElement("aui-editor");
|
|
1120
|
+
C.setAttribute("data-role", "canvas"), C.setAttribute("background", "dots");
|
|
1121
|
+
const D = document.createElement("aui-editor-layer");
|
|
1122
|
+
D.setAttribute("name", "content");
|
|
1123
|
+
const R = document.createElement("div");
|
|
1124
|
+
if (R.setAttribute("data-role", "content"), D.appendChild(R), C.appendChild(D), this.appendChild(C), this.#n = C, this.#t = R, u.addEventListener("click", (y) => {
|
|
1125
|
+
const w = y.target.closest("aui-option")?.dataset?.href;
|
|
1126
|
+
w && (window.location.href = w);
|
|
1127
|
+
}), b.addEventListener("change", (y) => {
|
|
1128
|
+
const x = y.target.value, G = b.querySelector(`aui-option[value="${x}"]`)?.dataset?.href;
|
|
1129
|
+
if (G) {
|
|
1130
|
+
window.location.href = G;
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const U = new URL(window.location.href);
|
|
1134
|
+
U.searchParams.set(i, x), window.location.href = U.toString();
|
|
1135
|
+
}), h) {
|
|
1136
|
+
const x = s.find((w) => w.slug === h)?.file || `${h}/${h}.html`;
|
|
1137
|
+
document.title = `${k(h)} — AgentUI ${k(e)}`, await this.#c(x, r);
|
|
1138
|
+
} else
|
|
1139
|
+
document.title = `AgentUI — ${k(e)}`, await this.#o(s, r);
|
|
1140
|
+
this.#e = t, this.#a = h, this.#u(t, i), document.addEventListener("keydown", this.#f), requestAnimationFrame(() => this.#d());
|
|
1141
|
+
}
|
|
1142
|
+
// ── Command palette ──
|
|
1143
|
+
#u(t, e) {
|
|
1144
|
+
const i = document.createElement("aui-dialog");
|
|
1145
|
+
i.setAttribute("size", "sm");
|
|
1146
|
+
const s = document.createElement("aui-command");
|
|
1147
|
+
s.setAttribute("max-width", "full");
|
|
1148
|
+
const a = document.createElement("aui-command-input");
|
|
1149
|
+
a.setAttribute("placeholder", `Go to ${k(t.section)}…`), s.appendChild(a);
|
|
1150
|
+
const n = document.createElement("aui-command-list");
|
|
1151
|
+
if (t.links.length) {
|
|
1152
|
+
const f = document.createElement("aui-command-group");
|
|
1153
|
+
f.setAttribute("label", "Sections");
|
|
1154
|
+
for (const u of t.links) {
|
|
1155
|
+
const l = document.createElement("aui-command-item");
|
|
1156
|
+
l.setAttribute("value", `section:${u.label}`), l.dataset.href = u.href, l.textContent = u.label, f.appendChild(l);
|
|
1157
|
+
}
|
|
1158
|
+
n.appendChild(f);
|
|
1159
|
+
}
|
|
1160
|
+
let r = null, c = "";
|
|
1161
|
+
for (const f of t.items) {
|
|
1162
|
+
const u = f.group || k(t.section);
|
|
1163
|
+
u !== c && (r = document.createElement("aui-command-group"), r.setAttribute("label", u), n.appendChild(r), c = u);
|
|
1164
|
+
const l = document.createElement("aui-command-item");
|
|
1165
|
+
l.setAttribute("value", f.slug), f.summary && l.setAttribute("keywords", f.summary), l.textContent = f.name || k(f.slug), r.appendChild(l);
|
|
1166
|
+
}
|
|
1167
|
+
s.appendChild(n);
|
|
1168
|
+
const h = document.createElement("aui-command-empty");
|
|
1169
|
+
h.textContent = "No results.", s.appendChild(h), s.addEventListener("select", (f) => {
|
|
1170
|
+
const { value: u } = f.detail, v = s.querySelector(`aui-command-item[value="${CSS.escape(u)}"]`)?.dataset?.href;
|
|
1171
|
+
if (v) {
|
|
1172
|
+
window.location.href = v;
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
if (u.startsWith("section:")) return;
|
|
1176
|
+
const d = new URL(window.location.href);
|
|
1177
|
+
d.searchParams.set(e, u), window.location.href = d.toString();
|
|
1178
|
+
}), s.addEventListener("dismiss", () => this.#m()), i.addEventListener("close", () => {
|
|
1179
|
+
this.#s?.removeAttribute("open");
|
|
1180
|
+
}), i.appendChild(s), this.appendChild(i), this.#s = i;
|
|
1181
|
+
}
|
|
1182
|
+
#i() {
|
|
1183
|
+
if (!this.#s) return;
|
|
1184
|
+
const t = this.#s.querySelector("aui-command-input");
|
|
1185
|
+
t?.clear?.(), this.#s.setAttribute("open", ""), requestAnimationFrame(() => {
|
|
1186
|
+
t?.focus?.();
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
#m() {
|
|
1190
|
+
this.#s?.removeAttribute("open");
|
|
1191
|
+
}
|
|
1192
|
+
// ── Keyboard navigation ──
|
|
1193
|
+
#f = (t) => {
|
|
1194
|
+
if ((t.metaKey || t.ctrlKey) && t.key === "k") {
|
|
1195
|
+
t.preventDefault(), this.#s?.hasAttribute("open") ? this.#m() : this.#i();
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (!t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && (t.key === "[" || t.key === "]")) {
|
|
1199
|
+
const e = t.target?.tagName, i = t.target?.isContentEditable;
|
|
1200
|
+
if (e === "INPUT" || e === "TEXTAREA" || i) return;
|
|
1201
|
+
t.preventDefault(), this.#r(t.key === "]" ? 1 : -1);
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
#r(t) {
|
|
1206
|
+
if (!this.#e) return;
|
|
1207
|
+
const { items: e, param: i } = this.#e;
|
|
1208
|
+
if (!e.length) return;
|
|
1209
|
+
let a = (this.#a ? e.findIndex((c) => c.slug === this.#a) : -1) + t;
|
|
1210
|
+
a >= e.length && (a = 0), a < 0 && (a = e.length - 1);
|
|
1211
|
+
const n = e[a];
|
|
1212
|
+
if (!n) return;
|
|
1213
|
+
const r = new URL(window.location.href);
|
|
1214
|
+
r.searchParams.set(i, n.slug), window.location.href = r.toString();
|
|
1215
|
+
}
|
|
1216
|
+
async #c(t, e) {
|
|
1217
|
+
const i = t.split("/")[0], s = `${e}${t}`, a = `${e}${i}/${i}.css`, n = `${e}${i}/${i}.ts`;
|
|
1218
|
+
try {
|
|
1219
|
+
const d = await fetch(s);
|
|
1220
|
+
d.ok && (this.#t.innerHTML = await d.text());
|
|
1221
|
+
} catch {
|
|
1222
|
+
}
|
|
1223
|
+
await new Promise((d) => requestAnimationFrame(() => requestAnimationFrame(d))), await new Promise((d) => requestAnimationFrame(() => requestAnimationFrame(d)));
|
|
1224
|
+
const r = Array.from(this.#t.children).filter(
|
|
1225
|
+
(d) => d.nodeType === 1 && d.tagName !== "SCRIPT"
|
|
1226
|
+
), c = 96, h = 200, f = r.map((d) => ({
|
|
1227
|
+
el: d,
|
|
1228
|
+
height: d.offsetHeight,
|
|
1229
|
+
width: d.offsetWidth
|
|
1230
|
+
}));
|
|
1231
|
+
let u = h, l = 0;
|
|
1232
|
+
for (const { el: d, height: p, width: g } of f)
|
|
1233
|
+
d.style.position = "absolute", d.style.left = "0px", d.style.top = `${u}px`, d.tagName === "AUI-GRAPH-UI" || d.tagName === "AUI-EDITOR" || (F(d, "drag", { config: { mode: "free", modifier: "alt" } }), F(d, "resize", { config: { modifier: "alt" } })), g > l && (l = g), u += p + c;
|
|
1234
|
+
this.#t.style.width = `${l}px`, this.#t.style.height = `${u}px`;
|
|
1235
|
+
const v = document.createElement("link");
|
|
1236
|
+
v.rel = "stylesheet", v.href = a, document.head.appendChild(v);
|
|
1237
|
+
try {
|
|
1238
|
+
await import(
|
|
1239
|
+
/* @vite-ignore */
|
|
1240
|
+
n
|
|
1241
|
+
);
|
|
1242
|
+
} catch {
|
|
1243
|
+
}
|
|
1244
|
+
for (const d of Array.from(this.#t.querySelectorAll("script"))) {
|
|
1245
|
+
const p = document.createElement("script");
|
|
1246
|
+
for (const g of d.attributes) p.setAttribute(g.name, g.value);
|
|
1247
|
+
p.textContent = d.textContent, d.replaceWith(p);
|
|
1248
|
+
}
|
|
1249
|
+
requestAnimationFrame(() => this.#d());
|
|
1250
|
+
}
|
|
1251
|
+
async #o(t, e) {
|
|
1252
|
+
const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1253
|
+
let r = 200, c = 0;
|
|
1254
|
+
for (const h of t) {
|
|
1255
|
+
const f = h.file || `${h.slug}/${h.slug}.html`, u = f.split("/")[0], l = `${e}${f}`, v = `${e}${u}/${u}.css`, d = `${e}${u}/${u}.ts`;
|
|
1256
|
+
if (!a.has(v)) {
|
|
1257
|
+
a.add(v);
|
|
1258
|
+
const A = document.createElement("link");
|
|
1259
|
+
A.rel = "stylesheet", A.href = v, document.head.appendChild(A);
|
|
1260
|
+
}
|
|
1261
|
+
if (!n.has(d)) {
|
|
1262
|
+
n.add(d);
|
|
1263
|
+
try {
|
|
1264
|
+
await import(
|
|
1265
|
+
/* @vite-ignore */
|
|
1266
|
+
d
|
|
1267
|
+
);
|
|
1268
|
+
} catch {
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
let p = "";
|
|
1272
|
+
try {
|
|
1273
|
+
const A = await fetch(l);
|
|
1274
|
+
A.ok && (p = await A.text());
|
|
1275
|
+
} catch {
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1278
|
+
if (!p.trim()) continue;
|
|
1279
|
+
const g = document.createElement("div");
|
|
1280
|
+
g.setAttribute("data-role", "gallery-item"), g.innerHTML = `<h3 style="margin:0 0 1rem;font-family:var(--aui-font-family);font-size:var(--aui-font-lg);font-weight:var(--aui-font-weight-semibold);color:var(--aui-ink-muted);">${h.name || k(h.slug)}</h3>${p}`, this.#t.appendChild(g), await new Promise((A) => requestAnimationFrame(A));
|
|
1281
|
+
const E = g.offsetHeight, b = g.offsetWidth;
|
|
1282
|
+
g.style.position = "absolute", g.style.left = "0px", g.style.top = `${r}px`, b > c && (c = b), r += E + 96;
|
|
1283
|
+
}
|
|
1284
|
+
this.#t.style.width = `${c}px`, this.#t.style.height = `${r}px`, requestAnimationFrame(() => this.#d());
|
|
1285
|
+
}
|
|
1286
|
+
#d() {
|
|
1287
|
+
const t = this.#n, e = this.#n.clientWidth, i = this.#t.offsetWidth, s = (e - i) / 2;
|
|
1288
|
+
t.panTo?.(s, 0);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
et();
|
|
1292
|
+
o("aui-button", ut);
|
|
1293
|
+
o("aui-input", dt);
|
|
1294
|
+
o("aui-checkbox", ht);
|
|
1295
|
+
o("aui-switch", ct);
|
|
1296
|
+
o("aui-radio", mt);
|
|
1297
|
+
o("aui-radio-group", ft);
|
|
1298
|
+
o("aui-textarea", pt);
|
|
1299
|
+
o("aui-container", bt);
|
|
1300
|
+
o("aui-dialog", gt);
|
|
1301
|
+
o("aui-drawer", vt);
|
|
1302
|
+
o("aui-icon", yt);
|
|
1303
|
+
o("aui-tooltip", At);
|
|
1304
|
+
o("aui-range", wt);
|
|
1305
|
+
o("aui-input-otp", xt);
|
|
1306
|
+
o("aui-gripper", Et);
|
|
1307
|
+
o("aui-option", Ct);
|
|
1308
|
+
o("aui-optgroup", kt);
|
|
1309
|
+
o("aui-select", St);
|
|
1310
|
+
o("aui-toast", Pt);
|
|
1311
|
+
o("aui-tabs", $t);
|
|
1312
|
+
o("aui-tab", Lt);
|
|
1313
|
+
o("aui-tab-panel", Mt);
|
|
1314
|
+
o("aui-accordion", Dt);
|
|
1315
|
+
o("aui-accordion-item", Tt);
|
|
1316
|
+
o("aui-breadcrumb", It);
|
|
1317
|
+
o("aui-breadcrumb-item", Nt);
|
|
1318
|
+
o("aui-segmented-control", Yt);
|
|
1319
|
+
o("aui-segment", qt);
|
|
1320
|
+
o("aui-pagination", Rt);
|
|
1321
|
+
o("aui-command", zt);
|
|
1322
|
+
o("aui-command-input", Ft);
|
|
1323
|
+
o("aui-command-list", Gt);
|
|
1324
|
+
o("aui-command-item", Ut);
|
|
1325
|
+
o("aui-command-group", Ht);
|
|
1326
|
+
o("aui-command-empty", Ot);
|
|
1327
|
+
o("aui-panes", Wt);
|
|
1328
|
+
o("aui-pane", Xt);
|
|
1329
|
+
o("aui-table", Kt);
|
|
1330
|
+
o("aui-table-head", Bt);
|
|
1331
|
+
o("aui-table-body", _t);
|
|
1332
|
+
o("aui-table-row", jt);
|
|
1333
|
+
o("aui-table-header", Jt);
|
|
1334
|
+
o("aui-table-cell", Vt);
|
|
1335
|
+
o("aui-table-column", de);
|
|
1336
|
+
o("aui-tree", Zt);
|
|
1337
|
+
o("aui-tree-item", Qt);
|
|
1338
|
+
o("aui-feed", te);
|
|
1339
|
+
o("aui-root", ee);
|
|
1340
|
+
o("aui-canvas", he);
|
|
1341
|
+
o("aui-calendar", fe);
|
|
1342
|
+
o("aui-noodles", ve);
|
|
1343
|
+
o("aui-agent-feed", K);
|
|
1344
|
+
o("aui-agent-thread", B);
|
|
1345
|
+
o("aui-agent-message", _);
|
|
1346
|
+
o("aui-agent-text", j);
|
|
1347
|
+
o("aui-agent-activity", J);
|
|
1348
|
+
o("aui-agent-seeds", V);
|
|
1349
|
+
o("aui-agent-panel", Z);
|
|
1350
|
+
o("aui-agent-input", Q);
|
|
1351
|
+
o("aui-agent-prompt", tt);
|
|
1352
|
+
o("aui-app-shell", ie);
|
|
1353
|
+
o("aui-page", se);
|
|
1354
|
+
o("aui-page-main", ae);
|
|
1355
|
+
o("aui-page-context", ne);
|
|
1356
|
+
o("aui-sidebar", oe);
|
|
1357
|
+
o("aui-sidebar-header", re);
|
|
1358
|
+
o("aui-sidebar-content", le);
|
|
1359
|
+
o("aui-sidebar-footer", ue);
|
|
1360
|
+
o("aui-preview-app", Ae);
|
|
1361
|
+
o("aui-editor", it);
|
|
1362
|
+
o("aui-editor-layer", st);
|
|
1363
|
+
o("aui-graph-ui", at);
|
|
1364
|
+
o("aui-graph-layer", nt);
|
|
1365
|
+
o("aui-graph-node", ot);
|
|
1366
|
+
o("aui-graph-noodle", rt);
|
|
1367
|
+
o("aui-graph-port", lt);
|
|
1368
|
+
const q = /* @__PURE__ */ new WeakMap();
|
|
1369
|
+
function Y(m) {
|
|
1370
|
+
if (m instanceof T || q.has(m)) return;
|
|
1371
|
+
const t = m.getAttribute("traits");
|
|
1372
|
+
if (!t) return;
|
|
1373
|
+
const e = W(t), i = X(e, m.localName), s = [];
|
|
1374
|
+
for (const { entry: a } of i) {
|
|
1375
|
+
const n = F(m, a.name, {
|
|
1376
|
+
config: a.config
|
|
1377
|
+
});
|
|
1378
|
+
s.push(n);
|
|
1379
|
+
}
|
|
1380
|
+
q.set(m, s);
|
|
1381
|
+
}
|
|
1382
|
+
function z(m) {
|
|
1383
|
+
const t = q.get(m);
|
|
1384
|
+
if (t) {
|
|
1385
|
+
for (const e of t) e();
|
|
1386
|
+
q.delete(m);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function O() {
|
|
1390
|
+
for (const t of document.querySelectorAll("[traits]"))
|
|
1391
|
+
Y(t);
|
|
1392
|
+
new MutationObserver((t) => {
|
|
1393
|
+
for (const e of t) {
|
|
1394
|
+
if (e.type === "childList") {
|
|
1395
|
+
for (const i of e.addedNodes) {
|
|
1396
|
+
if (i.nodeType !== 1) continue;
|
|
1397
|
+
const s = i;
|
|
1398
|
+
s.hasAttribute("traits") && Y(s);
|
|
1399
|
+
for (const a of s.querySelectorAll("[traits]"))
|
|
1400
|
+
Y(a);
|
|
1401
|
+
}
|
|
1402
|
+
for (const i of e.removedNodes) {
|
|
1403
|
+
if (i.nodeType !== 1) continue;
|
|
1404
|
+
const s = i;
|
|
1405
|
+
z(s);
|
|
1406
|
+
for (const a of s.querySelectorAll("[traits]"))
|
|
1407
|
+
z(a);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
if (e.type === "attributes" && e.attributeName === "traits") {
|
|
1411
|
+
const i = e.target;
|
|
1412
|
+
z(i), i.hasAttribute("traits") && Y(i);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}).observe(document.body, {
|
|
1416
|
+
childList: !0,
|
|
1417
|
+
subtree: !0,
|
|
1418
|
+
attributes: !0,
|
|
1419
|
+
attributeFilter: ["traits"]
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
document.body ? O() : document.addEventListener("DOMContentLoaded", O, { once: !0 });
|
|
1423
|
+
document.addEventListener("click", (m) => {
|
|
1424
|
+
const t = m.target?.closest?.("[popover-trigger]");
|
|
1425
|
+
if (!t) return;
|
|
1426
|
+
const e = t.getAttribute("popover-trigger");
|
|
1427
|
+
if (!e) return;
|
|
1428
|
+
const i = document.getElementById(e);
|
|
1429
|
+
if (!i || !("togglePopover" in i)) return;
|
|
1430
|
+
const s = `--aui-popover-${e}`;
|
|
1431
|
+
t.style.anchorName = s, i.style.positionAnchor = s;
|
|
1432
|
+
try {
|
|
1433
|
+
i.togglePopover();
|
|
1434
|
+
} catch {
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
for (const m of ["pointermove", "pointerdown", "pointerup", "mouseover", "mouseenter", "mouseleave"])
|
|
1438
|
+
document.addEventListener(m, (t) => {
|
|
1439
|
+
t.target?.closest?.("[popover], dialog") && t.stopPropagation();
|
|
1440
|
+
}, !0);
|
|
1441
|
+
//# sourceMappingURL=register.js.map
|