@opentiny/tiny-robot 0.5.2-alpha.8 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1004 @@
1
+ import * as le from "vue";
2
+ import { ref as B, computed as x, watch as D, reactive as se, toValue as X, cloneVNode as Se, Comment as Me, Text as Ee, Fragment as P, isVNode as Ie, Teleport as Ae, Suspense as Pe, nextTick as me, defineComponent as N, onMounted as ve, toRef as Ve, useSlots as G, openBlock as d, createElementBlock as p, createBlock as A, resolveDynamicComponent as H, renderSlot as M, withDirectives as ae, createElementVNode as k, normalizeStyle as ie, vShow as Ne, createVNode as j, withCtx as O, renderList as U, normalizeClass as R, createCommentVNode as S, toDisplayString as I, unref as $, withModifiers as oe, createSlots as J, normalizeProps as pe, guardReactiveProps as fe, createTextVNode as re, mergeProps as Le, onBeforeUnmount as Be, useModel as ce, vModelSelect as Re, vModelText as Fe, mergeModels as De } from "vue";
3
+ import { IconMore as Oe, IconArrowDown as ge, IconClose as je } from "@opentiny/tiny-robot-svgs";
4
+ import { g as Q } from "../index4.js";
5
+ import { _ as L } from "../_plugin-vue_export-helper.js";
6
+ const de = /* @__PURE__ */ new WeakMap();
7
+ function be() {
8
+ const e = le.useId;
9
+ if (e)
10
+ return e();
11
+ const a = le.getCurrentInstance();
12
+ if (!a)
13
+ return "";
14
+ const t = a.appContext, s = de.get(t) ?? 0;
15
+ return de.set(t, s + 1), `tr-${s}`;
16
+ }
17
+ const Y = (e, a) => Object.prototype.hasOwnProperty.call(e, a), K = () => /* @__PURE__ */ Object.create(null), z = (e, a, t) => {
18
+ Object.defineProperty(e, a, {
19
+ configurable: !0,
20
+ enumerable: !0,
21
+ value: t,
22
+ writable: !0
23
+ });
24
+ }, Ge = (e) => {
25
+ const a = K();
26
+ for (const [t, s] of Object.entries(e)) {
27
+ const r = K();
28
+ for (const [c, l] of Object.entries(s ?? {}))
29
+ (c === "installed" || c === "available") && z(r, c, l);
30
+ z(a, t, r);
31
+ }
32
+ return a;
33
+ }, Ue = (e, a, t) => {
34
+ if (!Y(e, a)) return;
35
+ const s = e[a];
36
+ if (!(s === void 0 || !Y(s, t)))
37
+ return s[t];
38
+ }, He = (e, a, t, s) => {
39
+ const r = Y(e, a) && e[a] !== void 0 ? e[a] : K();
40
+ Y(e, a) || z(e, a, r), z(r, t, s);
41
+ }, Ke = (e, a, t) => Ue(e, a, t) ?? !0, ze = (e, a) => {
42
+ const t = B(e.defaultActiveTab), s = B(K()), r = x(() => e.tabs.map((m) => m.id)), c = x(() => r.value[0]);
43
+ D(
44
+ r,
45
+ (m) => {
46
+ const f = new Set(m), i = K();
47
+ for (const [g, h] of Object.entries(s.value))
48
+ f.has(g) && z(i, g, h);
49
+ s.value = i;
50
+ },
51
+ { immediate: !0 }
52
+ );
53
+ const l = (m) => {
54
+ m.includes(t.value ?? "") || (t.value = m[0]);
55
+ };
56
+ D(
57
+ [r, () => e.activeTab],
58
+ ([m, f]) => {
59
+ f === void 0 && l(m);
60
+ },
61
+ { immediate: !0 }
62
+ );
63
+ const v = x(() => {
64
+ const m = e.activeTab ?? t.value, f = e.tabs.find((i) => i.id === m);
65
+ return (f == null ? void 0 : f.id) ?? c.value;
66
+ }), o = x(
67
+ () => v.value === void 0 ? void 0 : e.tabs.find((m) => m.id === v.value)
68
+ );
69
+ let n = e.activeTab;
70
+ const u = (m) => {
71
+ n = m, a("update:active-tab", m);
72
+ };
73
+ D(
74
+ v,
75
+ (m) => {
76
+ if (e.activeTab !== void 0 && m === e.activeTab) {
77
+ n = m;
78
+ return;
79
+ }
80
+ m !== n && u(m);
81
+ },
82
+ { immediate: e.activeTab !== void 0 }
83
+ );
84
+ const y = (m, f) => Ke(s.value, m, f);
85
+ return {
86
+ activeTabId: v,
87
+ activeTab: o,
88
+ selectTab: (m) => {
89
+ const f = e.tabs.find((i) => i.id === m);
90
+ !f || v.value === f.id || (e.activeTab === void 0 && (t.value = f.id), u(f.id), a("tab-change", { tabId: f.id }));
91
+ },
92
+ isSectionExpanded: y,
93
+ toggleSection: (m, f) => {
94
+ if (!e.tabs.some((h) => h.id === m)) return;
95
+ const i = !y(m, f), g = Ge(s.value);
96
+ He(g, m, f, i), s.value = g, a("section-toggle", { tabId: m, sectionKey: f, expanded: i });
97
+ }
98
+ };
99
+ }, We = () => /* @__PURE__ */ Object.create(null), ue = () => se({ selectedTag: "", searchValue: "" }), qe = (e) => {
100
+ const a = se(We()), t = ue();
101
+ return D(
102
+ () => X(e).map((r) => r.id),
103
+ (r) => {
104
+ const c = new Set(r);
105
+ for (const l of Object.keys(a))
106
+ c.has(l) || delete a[l];
107
+ },
108
+ { immediate: !0 }
109
+ ), { getFilterState: (r) => r === void 0 ? t : a[r] ?? (a[r] = ue()) };
110
+ }, Xe = () => se({ selectedTag: "", searchValue: "" }), Je = (e) => {
111
+ const a = /* @__PURE__ */ new Set(), t = [];
112
+ for (const s of e)
113
+ !s.value || a.has(s.value) || (a.add(s.value), t.push(s));
114
+ return t;
115
+ }, Qe = (e) => {
116
+ const a = e.tags;
117
+ return Array.isArray(a) && a.every((t) => typeof t == "string") ? a : [];
118
+ }, Ye = (e, a) => {
119
+ const t = e, s = typeof t.name == "string" ? t.name : "", r = typeof t.description == "string" ? t.description : "";
120
+ return `${s} ${r}`.toLowerCase().includes(a);
121
+ }, Ze = (e) => {
122
+ const a = Xe(), t = x(() => X(e.state) ?? a), s = x({
123
+ get: () => t.value.selectedTag,
124
+ set: (o) => {
125
+ t.value.selectedTag = o;
126
+ }
127
+ }), r = x({
128
+ get: () => t.value.searchValue,
129
+ set: (o) => {
130
+ t.value.searchValue = o;
131
+ }
132
+ }), c = x(() => Je(X(e.tags)));
133
+ D(
134
+ c,
135
+ (o) => {
136
+ s.value && !o.some((n) => n.value === s.value) && (s.value = "");
137
+ },
138
+ { immediate: !0 }
139
+ );
140
+ const l = x(() => {
141
+ var y, w;
142
+ const o = r.value.trim().toLowerCase(), n = ((y = e.rules) == null ? void 0 : y.getItemTags) ?? Qe, u = ((w = e.rules) == null ? void 0 : w.search) ?? Ye;
143
+ return X(e.items).filter((C) => {
144
+ const m = !s.value || n(C).includes(s.value), f = !o || u(C, o);
145
+ return m && f;
146
+ });
147
+ }), v = x(() => ({
148
+ tags: c.value,
149
+ selectedTag: s.value,
150
+ searchValue: r.value,
151
+ "onUpdate:selectedTag": (o) => {
152
+ s.value = o;
153
+ },
154
+ "onUpdate:searchValue": (o) => {
155
+ r.value = o;
156
+ }
157
+ }));
158
+ return { filteredItems: l, selectedTag: s, searchValue: r, controls: v };
159
+ }, he = (e) => e.flatMap((a) => a.type === Me ? [] : a.type === Ee && typeof a.children == "string" && a.children.trim() === "" ? [] : a.type !== P || !Array.isArray(a.children) ? [a] : he(a.children.filter(Ie))), et = (e) => e.type === Ae || e.type === Pe ? !1 : typeof e.type == "string" || typeof e.type == "object" || typeof e.type == "function";
160
+ function tt({ getSlot: e, componentName: a }) {
161
+ return {
162
+ renderAsChild: (s, r = {}) => {
163
+ var l;
164
+ const c = he(((l = e()) == null ? void 0 : l(s)) ?? []);
165
+ return c.length !== 1 || !et(c[0]) ? null : Se(c[0], r, !0);
166
+ }
167
+ };
168
+ }
169
+ const nt = ({
170
+ triggerRef: e,
171
+ popoverRef: a,
172
+ open: t,
173
+ placement: s
174
+ }) => {
175
+ const r = B(), c = () => {
176
+ if (!t.value || !e.value || !a.value) return;
177
+ const l = e.value.getBoundingClientRect(), v = a.value.getBoundingClientRect(), o = 8, n = 8, u = Math.max(
178
+ o,
179
+ document.documentElement.clientWidth - v.width - o
180
+ ), y = Math.max(
181
+ o,
182
+ document.documentElement.clientHeight - v.height - o
183
+ ), w = Math.min(u, Math.max(o, l.right - v.width)), C = l.bottom + n, m = l.top - v.height - n, f = C + v.height <= document.documentElement.clientHeight - o, i = m >= o;
184
+ let g = s.value;
185
+ g === "bottom-end" && !f && i ? g = "top-end" : g === "top-end" && !i && f && (g = "bottom-end");
186
+ const V = Math.min(y, Math.max(o, g === "bottom-end" ? C : m));
187
+ r.value = {
188
+ x: w,
189
+ y: V,
190
+ placement: g
191
+ };
192
+ };
193
+ return D(
194
+ [t, s],
195
+ async ([l]) => {
196
+ l && (await me(), c());
197
+ },
198
+ { flush: "post" }
199
+ ), Q("resize", c, { passive: !0 }), Q("scroll", c, {
200
+ capture: !0,
201
+ passive: !0
202
+ }), {
203
+ position: r
204
+ };
205
+ }, at = ["aria-expanded"], ot = ["popover"], st = /* @__PURE__ */ N({
206
+ inheritAttrs: !1,
207
+ __name: "ExtensionCardPopover",
208
+ props: {
209
+ asChild: { type: Boolean, default: !1 },
210
+ placement: { default: "bottom-end" }
211
+ },
212
+ setup(e) {
213
+ const a = e, t = `tr-extension-card-popover-${be()}`, s = B(null), r = B(null), c = B(!1), l = B(!1);
214
+ ve(() => {
215
+ l.value = typeof HTMLElement.prototype.showPopover == "function" && typeof HTMLElement.prototype.hidePopover == "function";
216
+ });
217
+ const { position: v } = nt({
218
+ triggerRef: s,
219
+ popoverRef: r,
220
+ open: c,
221
+ placement: Ve(a, "placement")
222
+ }), o = x(() => {
223
+ if (v.value)
224
+ return {
225
+ left: `${v.value.x}px`,
226
+ top: `${v.value.y}px`
227
+ };
228
+ }), n = G(), u = (i) => {
229
+ const g = i instanceof Element ? i : i == null ? void 0 : i.$el;
230
+ s.value = g instanceof HTMLElement ? g : null;
231
+ }, y = () => {
232
+ var i;
233
+ if (!l.value) {
234
+ c.value = !1;
235
+ return;
236
+ }
237
+ (i = r.value) != null && i.matches(":popover-open") && r.value.hidePopover();
238
+ }, w = () => {
239
+ if (!l.value) {
240
+ c.value = !c.value;
241
+ return;
242
+ }
243
+ r.value && (r.value.matches(":popover-open") ? r.value.hidePopover() : r.value.showPopover());
244
+ };
245
+ Q("click", (i) => {
246
+ var g, h;
247
+ l.value || !c.value || !(i.target instanceof Node) || (g = s.value) != null && g.contains(i.target) || (h = r.value) != null && h.contains(i.target) || y();
248
+ }), Q("keydown", (i) => {
249
+ var g;
250
+ l.value || !c.value || i.key !== "Escape" || (y(), (g = s.value) == null || g.focus());
251
+ });
252
+ const { renderAsChild: C } = tt({
253
+ getSlot: () => n.trigger,
254
+ componentName: "ExtensionCardPopover"
255
+ }), m = () => C(
256
+ {
257
+ popoverId: t,
258
+ open: c.value
259
+ },
260
+ {
261
+ ref: u,
262
+ ...l.value ? {
263
+ popovertarget: t,
264
+ popovertargetaction: "toggle"
265
+ } : { onClick: w }
266
+ }
267
+ ), f = (i) => {
268
+ c.value = i.newState === "open";
269
+ };
270
+ return (i, g) => (d(), p(P, null, [
271
+ e.asChild ? (d(), A(H(m()), { key: 0 })) : (d(), p("button", {
272
+ key: 1,
273
+ ref_key: "triggerRef",
274
+ ref: s,
275
+ type: "button",
276
+ class: "tr-extension-card-popover__trigger",
277
+ "aria-controls": t,
278
+ "aria-expanded": c.value,
279
+ onClick: w
280
+ }, [
281
+ M(i.$slots, "trigger", {
282
+ popoverId: t,
283
+ open: c.value
284
+ }, void 0, !0)
285
+ ], 8, at)),
286
+ ae(k("div", {
287
+ id: t,
288
+ ref_key: "popoverRef",
289
+ ref: r,
290
+ popover: l.value ? "auto" : void 0,
291
+ class: "tr-extension-card-popover__content",
292
+ style: ie(o.value),
293
+ onToggle: f
294
+ }, [
295
+ M(i.$slots, "content", { close: y }, void 0, !0)
296
+ ], 44, ot), [
297
+ [Ne, l.value || c.value]
298
+ ])
299
+ ], 64));
300
+ }
301
+ }), it = /* @__PURE__ */ L(st, [["__scopeId", "data-v-6dbac593"]]), rt = {
302
+ key: 0,
303
+ class: "tr-extension-card__more-action"
304
+ }, lt = ["title", "aria-label", "aria-expanded"], ct = { class: "tr-extension-card__more-menu" }, dt = ["disabled", "aria-pressed", "onClick"], ut = {
305
+ key: 0,
306
+ class: "tr-extension-card__more-menu-item-icon-slot"
307
+ }, mt = {
308
+ key: 1,
309
+ class: "tr-extension-card__more-menu-item-icon-placeholder",
310
+ "aria-hidden": "true"
311
+ }, vt = /* @__PURE__ */ N({
312
+ __name: "ExtensionCardMoreMenu",
313
+ props: {
314
+ actions: { default: () => [] },
315
+ label: { default: "更多操作" },
316
+ placement: { default: "bottom-end" },
317
+ showIcons: { type: Boolean, default: !0 }
318
+ },
319
+ emits: ["action"],
320
+ setup(e, { emit: a }) {
321
+ const t = e, s = a, r = x(() => t.showIcons && t.actions.some((l) => !!l.icon)), c = (l, v) => {
322
+ l.disabled || (v(), s("action", {
323
+ id: l.id,
324
+ type: l.type,
325
+ ...l.type === "switch" ? { checked: !l.checked } : {}
326
+ }));
327
+ };
328
+ return (l, v) => t.actions.length ? (d(), p("div", rt, [
329
+ j(it, {
330
+ "as-child": "",
331
+ placement: t.placement
332
+ }, {
333
+ trigger: O(({ open: o }) => [
334
+ k("button", {
335
+ class: "tr-extension-card__icon-button",
336
+ type: "button",
337
+ title: t.label,
338
+ "aria-label": t.label,
339
+ "aria-expanded": o
340
+ }, [
341
+ j($(Oe), { class: "tr-extension-card__action-icon" })
342
+ ], 8, lt)
343
+ ]),
344
+ content: O(({ close: o }) => [
345
+ k("ul", ct, [
346
+ (d(!0), p(P, null, U(t.actions, (n) => (d(), p("li", {
347
+ key: n.id
348
+ }, [
349
+ k("button", {
350
+ class: R(["tr-extension-card__more-menu-item", { "is-danger": n.danger }]),
351
+ type: "button",
352
+ disabled: n.disabled,
353
+ "aria-pressed": n.type === "switch" ? n.checked : void 0,
354
+ onClick: (u) => c(n, o)
355
+ }, [
356
+ r.value ? (d(), p("span", ut, [
357
+ n.icon ? (d(), A(H(n.icon), {
358
+ key: 0,
359
+ class: "tr-extension-card__more-menu-item-icon"
360
+ })) : (d(), p("span", mt))
361
+ ])) : S("", !0),
362
+ k("span", null, I(n.label), 1)
363
+ ], 10, dt)
364
+ ]))), 128))
365
+ ])
366
+ ]),
367
+ _: 1
368
+ }, 8, ["placement"])
369
+ ])) : S("", !0);
370
+ }
371
+ }), pt = /* @__PURE__ */ L(vt, [["__scopeId", "data-v-8d00263e"]]), ft = { class: "tr-extension-card-primary-actions" }, gt = ["checked", "disabled", "aria-label", "onChange"], bt = ["aria-label", "disabled", "onClick"], ht = ["aria-label", "disabled", "onClick"], _t = /* @__PURE__ */ N({
372
+ __name: "ExtensionCardActions",
373
+ props: {
374
+ actions: { default: () => [] }
375
+ },
376
+ emits: ["action"],
377
+ setup(e, { emit: a }) {
378
+ const t = e, s = a, r = (v, o) => {
379
+ if (v.disabled) return;
380
+ const n = o.currentTarget, u = n.checked;
381
+ n.checked = !!v.checked, s("action", {
382
+ id: v.id,
383
+ type: v.type,
384
+ checked: u
385
+ });
386
+ }, c = (v) => {
387
+ v.disabled || s("action", { id: v.id, type: v.type });
388
+ }, l = (v, o) => {
389
+ if (v.disabled) return;
390
+ const n = { id: v.id, type: v.type };
391
+ o !== void 0 && (n.payload = o), s("action", n);
392
+ };
393
+ return (v, o) => (d(), p("div", ft, [
394
+ (d(!0), p(P, null, U(t.actions, (n) => (d(), p(P, {
395
+ key: n.id
396
+ }, [
397
+ n.type === "switch" ? (d(), p("label", {
398
+ key: 0,
399
+ class: R(["tr-extension-card-primary-actions__switch", { "is-disabled": n.disabled, "is-danger": n.danger }])
400
+ }, [
401
+ k("input", {
402
+ type: "checkbox",
403
+ role: "switch",
404
+ checked: n.checked,
405
+ disabled: n.disabled,
406
+ "aria-label": n.label,
407
+ onChange: (u) => r(n, u)
408
+ }, null, 40, gt),
409
+ o[0] || (o[0] = k("span", { class: "tr-extension-card-primary-actions__switch-track" }, null, -1))
410
+ ], 2)) : n.type === "button" ? (d(), p("button", {
411
+ key: 1,
412
+ class: R(["tr-extension-card-primary-actions__button", { "is-danger": n.danger }]),
413
+ type: "button",
414
+ "aria-label": n.label,
415
+ disabled: n.disabled,
416
+ onClick: (u) => c(n)
417
+ }, [
418
+ n.icon ? (d(), A(H(n.icon), {
419
+ key: 0,
420
+ class: "tr-extension-card-primary-actions__button-icon"
421
+ })) : S("", !0),
422
+ k("span", null, I(n.label), 1)
423
+ ], 10, bt)) : v.$slots["primary-action"] ? (d(), p("span", {
424
+ key: 2,
425
+ class: R(["tr-extension-card-primary-actions__custom-action", { "is-disabled": n.disabled, "is-danger": n.danger }])
426
+ }, [
427
+ M(v.$slots, "primary-action", {
428
+ action: n,
429
+ trigger: (u) => l(n, u)
430
+ }, void 0, !0)
431
+ ], 2)) : (d(), p("button", {
432
+ key: 3,
433
+ class: R(["tr-extension-card-primary-actions__button", { "is-danger": n.danger }]),
434
+ type: "button",
435
+ "aria-label": n.label,
436
+ disabled: n.disabled,
437
+ onClick: (u) => l(n)
438
+ }, [
439
+ n.icon ? (d(), A(H(n.icon), {
440
+ key: 0,
441
+ class: "tr-extension-card-primary-actions__button-icon"
442
+ })) : S("", !0),
443
+ k("span", null, I(n.label), 1)
444
+ ], 10, ht))
445
+ ], 64))), 128))
446
+ ]));
447
+ }
448
+ }), yt = /* @__PURE__ */ L(_t, [["__scopeId", "data-v-7f997e75"]]), xt = { class: "tr-extension-card" }, kt = { class: "tr-extension-card__icon-region" }, Ct = ["src", "alt"], Tt = {
449
+ key: 2,
450
+ class: "tr-extension-card__icon tr-extension-card__icon--placeholder"
451
+ }, wt = { class: "tr-extension-card__content" }, $t = ["role", "tabindex", "title"], St = ["title"], Mt = ["aria-label", "aria-valuenow"], Et = /* @__PURE__ */ N({
452
+ __name: "ExtensionCard",
453
+ props: {
454
+ name: {},
455
+ description: {},
456
+ icon: {},
457
+ actions: { default: () => [] },
458
+ primaryActionsLimit: { default: 1 },
459
+ progress: {},
460
+ nameClickable: { type: Boolean, default: !0 },
461
+ overflowMenuLabel: { default: "更多操作" },
462
+ overflowMenuPlacement: { default: "bottom-end" },
463
+ overflowMenuShowIcons: { type: Boolean, default: !0 }
464
+ },
465
+ emits: ["name-click", "action"],
466
+ setup(e, { emit: a }) {
467
+ const t = e, s = G(), r = a, c = x(() => t.actions.filter((f) => !f.hidden)), l = x(() => Math.max(0, Math.floor(t.primaryActionsLimit))), v = x(() => c.value.slice(0, l.value)), o = x(() => c.value.slice(l.value)), n = x(() => v.value.length > 0 || o.value.length > 0), u = x(() => t.progress === "indeterminate" || t.progress === void 0 ? t.progress : Math.min(100, Math.max(0, t.progress))), y = x(() => !!s["primary-action"]), w = (f) => {
468
+ r("action", f);
469
+ }, C = (f) => {
470
+ t.nameClickable && r("name-click", f);
471
+ }, m = (f) => {
472
+ !t.nameClickable || f.key !== "Enter" && f.key !== " " || (f.preventDefault(), r("name-click", f));
473
+ };
474
+ return (f, i) => (d(), p("div", xt, [
475
+ k("div", kt, [
476
+ typeof e.icon == "string" && e.icon ? (d(), p("img", {
477
+ key: 0,
478
+ src: e.icon,
479
+ alt: e.name,
480
+ class: "tr-extension-card__icon"
481
+ }, null, 8, Ct)) : e.icon ? (d(), A(H(e.icon), {
482
+ key: 1,
483
+ class: "tr-extension-card__icon"
484
+ })) : (d(), p("div", Tt, I(e.name.slice(0, 1)), 1))
485
+ ]),
486
+ k("div", wt, [
487
+ k("div", {
488
+ class: R(["tr-extension-card__name", { "is-clickable": e.nameClickable }]),
489
+ role: e.nameClickable ? "button" : void 0,
490
+ tabindex: e.nameClickable ? 0 : void 0,
491
+ title: e.name,
492
+ onClick: C,
493
+ onKeydown: m
494
+ }, I(e.name), 43, $t),
495
+ e.description ? (d(), p("div", {
496
+ key: 0,
497
+ class: "tr-extension-card__description",
498
+ title: e.description
499
+ }, I(e.description), 9, St)) : S("", !0)
500
+ ]),
501
+ n.value ? (d(), p("div", {
502
+ key: 0,
503
+ class: "tr-extension-card__actions",
504
+ onClick: i[1] || (i[1] = oe(() => {
505
+ }, ["stop"])),
506
+ onKeydown: i[2] || (i[2] = oe(() => {
507
+ }, ["stop"]))
508
+ }, [
509
+ v.value.length ? (d(), A(yt, {
510
+ key: 0,
511
+ actions: v.value,
512
+ onAction: i[0] || (i[0] = (g) => r("action", g))
513
+ }, J({ _: 2 }, [
514
+ y.value ? {
515
+ name: "primary-action",
516
+ fn: O((g) => [
517
+ M(f.$slots, "primary-action", pe(fe(g)), void 0, !0)
518
+ ]),
519
+ key: "0"
520
+ } : void 0
521
+ ]), 1032, ["actions"])) : S("", !0),
522
+ o.value.length ? (d(), A(pt, {
523
+ key: 1,
524
+ actions: o.value,
525
+ label: e.overflowMenuLabel,
526
+ placement: e.overflowMenuPlacement,
527
+ "show-icons": e.overflowMenuShowIcons,
528
+ onAction: w
529
+ }, null, 8, ["actions", "label", "placement", "show-icons"])) : S("", !0)
530
+ ], 32)) : S("", !0),
531
+ u.value !== void 0 ? (d(), p("div", {
532
+ key: 1,
533
+ class: "tr-extension-card__progress",
534
+ role: "progressbar",
535
+ "aria-label": e.name,
536
+ "aria-valuemin": "0",
537
+ "aria-valuemax": "100",
538
+ "aria-valuenow": u.value === "indeterminate" ? void 0 : u.value
539
+ }, [
540
+ k("span", {
541
+ class: R(["tr-extension-card__progress-bar", { "is-indeterminate": u.value === "indeterminate" }]),
542
+ style: ie(u.value === "indeterminate" ? void 0 : { width: `${u.value}%` })
543
+ }, null, 6)
544
+ ], 8, Mt)) : S("", !0)
545
+ ]));
546
+ }
547
+ }), W = /* @__PURE__ */ L(Et, [["__scopeId", "data-v-adf5e9c0"]]), It = { class: "tr-extension-card-grid" }, At = {
548
+ key: 0,
549
+ class: "tr-extension-card-grid__empty"
550
+ }, Pt = ["data-card-id"], Vt = /* @__PURE__ */ N({
551
+ __name: "ExtensionCardGrid",
552
+ props: {
553
+ items: {},
554
+ emptyText: { default: "暂无内容" },
555
+ primaryActionsLimit: {},
556
+ nameClickable: { type: Boolean, default: void 0 },
557
+ overflowMenuLabel: {},
558
+ overflowMenuPlacement: {},
559
+ overflowMenuShowIcons: { type: Boolean, default: void 0 }
560
+ },
561
+ emits: ["action", "name-click"],
562
+ setup(e, { emit: a }) {
563
+ const t = e, s = G(), r = a, c = (o) => {
564
+ const { id: n, ...u } = o;
565
+ return {
566
+ ...u,
567
+ primaryActionsLimit: o.primaryActionsLimit ?? t.primaryActionsLimit,
568
+ nameClickable: o.nameClickable ?? t.nameClickable,
569
+ overflowMenuLabel: o.overflowMenuLabel ?? t.overflowMenuLabel,
570
+ overflowMenuPlacement: o.overflowMenuPlacement ?? t.overflowMenuPlacement,
571
+ overflowMenuShowIcons: o.overflowMenuShowIcons ?? t.overflowMenuShowIcons
572
+ };
573
+ }, l = (o, n) => {
574
+ r("action", { itemId: o, action: n });
575
+ }, v = (o, n) => {
576
+ r("name-click", { itemId: o, event: n });
577
+ };
578
+ return (o, n) => (d(), p("ul", It, [
579
+ e.items.length === 0 ? (d(), p("li", At, [
580
+ M(o.$slots, "empty", {}, () => [
581
+ re(I(e.emptyText), 1)
582
+ ], !0)
583
+ ])) : (d(!0), p(P, { key: 1 }, U(e.items, (u, y) => (d(), p("li", {
584
+ key: u.id,
585
+ class: "tr-extension-card-grid__item",
586
+ "data-card-id": u.id
587
+ }, [
588
+ $(s).item ? M(o.$slots, "item", {
589
+ item: u,
590
+ index: y
591
+ }, void 0, !0, 0) : (d(), A(W, Le({
592
+ key: 1,
593
+ ref_for: !0
594
+ }, c(u), {
595
+ onAction: (w) => l(u.id, w),
596
+ onNameClick: (w) => v(u.id, w)
597
+ }), null, 16, ["onAction", "onNameClick"]))
598
+ ], 8, Pt))), 128))
599
+ ]));
600
+ }
601
+ }), q = /* @__PURE__ */ L(Vt, [["__scopeId", "data-v-b736eba6"]]), Nt = ["data-tab-id", "data-section-key"], Lt = { class: "extension-manager-section__header" }, Bt = ["aria-expanded"], Rt = {
602
+ key: 0,
603
+ class: "extension-manager-section__body"
604
+ }, Ft = {
605
+ key: 1,
606
+ class: "extension-manager-section__state"
607
+ }, Dt = /* @__PURE__ */ N({
608
+ name: "ExtensionManagerSection",
609
+ __name: "ExtensionManagerSection",
610
+ props: {
611
+ tabId: {},
612
+ section: {},
613
+ expanded: { type: Boolean }
614
+ },
615
+ emits: ["section-toggle", "action", "name-click"],
616
+ setup(e, { emit: a }) {
617
+ const t = e, s = G(), r = a, c = () => r("section-toggle", !t.expanded), l = (o) => r("action", o), v = (o) => r("name-click", o);
618
+ return (o, n) => (d(), p("section", {
619
+ class: "extension-manager-section",
620
+ "data-tab-id": t.tabId,
621
+ "data-section-key": t.section.key
622
+ }, [
623
+ k("div", Lt, [
624
+ k("button", {
625
+ class: "extension-manager-section__title",
626
+ type: "button",
627
+ "aria-expanded": t.expanded,
628
+ onClick: c
629
+ }, [
630
+ j($(ge), {
631
+ class: R(["extension-manager-section__arrow", { "is-expanded": t.expanded }])
632
+ }, null, 8, ["class"]),
633
+ k("span", null, I(t.section.title), 1)
634
+ ], 8, Bt)
635
+ ]),
636
+ t.expanded ? (d(), p("div", Rt, [
637
+ t.section.items.length > 0 ? (d(), A(q, {
638
+ key: 0,
639
+ items: t.section.items,
640
+ "primary-actions-limit": 1,
641
+ "name-clickable": !0,
642
+ onAction: l,
643
+ onNameClick: v
644
+ }, J({ _: 2 }, [
645
+ s.item ? {
646
+ name: "item",
647
+ fn: O(({ item: u, index: y }) => [
648
+ M(o.$slots, "item", {
649
+ item: u,
650
+ index: y
651
+ }, void 0, !0)
652
+ ]),
653
+ key: "0"
654
+ } : void 0
655
+ ]), 1032, ["items"])) : (d(), p("div", Ft, [
656
+ M(o.$slots, "empty", {}, () => [
657
+ n[0] || (n[0] = re("暂无内容", -1))
658
+ ], !0)
659
+ ]))
660
+ ])) : S("", !0)
661
+ ], 8, Nt));
662
+ }
663
+ }), Ot = /* @__PURE__ */ L(Dt, [["__scopeId", "data-v-89f78201"]]), jt = {
664
+ class: "extension-manager-tabs",
665
+ role: "tablist",
666
+ "aria-orientation": "horizontal"
667
+ }, Gt = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], Ut = /* @__PURE__ */ N({
668
+ name: "ExtensionManagerTabs",
669
+ __name: "ExtensionManagerTabs",
670
+ props: {
671
+ tabs: {},
672
+ activeTabId: {},
673
+ idPrefix: {}
674
+ },
675
+ emits: ["select"],
676
+ setup(e, { emit: a }) {
677
+ const t = e, s = a, r = G(), c = (i) => `${i.length}:${i}`, l = (i) => `${t.idPrefix}-tab-${c(i)}`, v = (i) => `${t.idPrefix}-tabpanel-${c(i)}`, o = /* @__PURE__ */ new Map(), n = B();
678
+ let u;
679
+ const y = () => {
680
+ const i = t.activeTabId ? o.get(t.activeTabId) : void 0;
681
+ if (!i) {
682
+ n.value = void 0;
683
+ return;
684
+ }
685
+ n.value = {
686
+ transform: `translateX(${i.offsetLeft}px)`,
687
+ width: `${i.offsetWidth}px`
688
+ };
689
+ }, w = (i, g) => {
690
+ const h = o.get(i);
691
+ h && h !== g && (u == null || u.unobserve(h)), g ? (o.set(i, g), u == null || u.observe(g)) : o.delete(i);
692
+ };
693
+ D([() => t.activeTabId, () => t.tabs.map((i) => i.id)], y, { flush: "post" }), ve(() => {
694
+ typeof ResizeObserver < "u" && (u = new ResizeObserver(y), o.forEach((i) => u == null ? void 0 : u.observe(i))), y();
695
+ }), Be(() => u == null ? void 0 : u.disconnect());
696
+ const C = (i) => s("select", i), m = (i) => {
697
+ me(() => {
698
+ var g;
699
+ return (g = o.get(i)) == null ? void 0 : g.focus();
700
+ });
701
+ }, f = (i, g) => {
702
+ let h;
703
+ switch (g.key) {
704
+ case "ArrowLeft":
705
+ h = (i - 1 + t.tabs.length) % t.tabs.length;
706
+ break;
707
+ case "ArrowRight":
708
+ h = (i + 1) % t.tabs.length;
709
+ break;
710
+ case "Home":
711
+ h = 0;
712
+ break;
713
+ case "End":
714
+ h = t.tabs.length - 1;
715
+ break;
716
+ default:
717
+ return;
718
+ }
719
+ const V = t.tabs[h];
720
+ V && (g.preventDefault(), C(V.id), m(V.id));
721
+ };
722
+ return (i, g) => (d(), p("div", jt, [
723
+ (d(!0), p(P, null, U(t.tabs, (h, V) => (d(), p("button", {
724
+ key: h.id,
725
+ ref_for: !0,
726
+ ref: (F) => w(h.id, F),
727
+ class: "extension-manager-tabs__tab",
728
+ type: "button",
729
+ role: "tab",
730
+ id: l(h.id),
731
+ "aria-selected": h.id === t.activeTabId,
732
+ "aria-controls": h.id === t.activeTabId ? v(h.id) : void 0,
733
+ tabindex: h.id === t.activeTabId ? 0 : -1,
734
+ onClick: (F) => C(h.id),
735
+ onKeydown: (F) => f(V, F)
736
+ }, [
737
+ r.tab ? (d(), p("span", {
738
+ key: 0,
739
+ class: "extension-manager-tabs__slot",
740
+ onClick: g[0] || (g[0] = oe(() => {
741
+ }, ["stop"]))
742
+ }, [
743
+ M(i.$slots, "tab", {
744
+ tab: h,
745
+ active: h.id === t.activeTabId,
746
+ select: () => C(h.id)
747
+ }, void 0, !0)
748
+ ])) : (d(), p(P, { key: 1 }, [
749
+ re(I(h.label), 1)
750
+ ], 64))
751
+ ], 40, Gt))), 128)),
752
+ n.value ? (d(), p("span", {
753
+ key: 0,
754
+ class: "extension-manager-tabs__indicator",
755
+ style: ie(n.value),
756
+ "aria-hidden": "true"
757
+ }, null, 4)) : S("", !0)
758
+ ]));
759
+ }
760
+ }), Ht = /* @__PURE__ */ L(Ut, [["__scopeId", "data-v-6a23a300"]]), Kt = {
761
+ class: "extension-filter-controls",
762
+ "data-testid": "extension-filter-controls"
763
+ }, zt = {
764
+ "data-testid": "filter-root",
765
+ class: "extension-filter-controls__fields"
766
+ }, Wt = { class: "extension-filter-controls__select-wrapper" }, qt = ["disabled"], Xt = ["value"], Jt = { class: "extension-filter-controls__input-wrapper" }, Qt = /* @__PURE__ */ N({
767
+ name: "ExtensionFilterControls",
768
+ __name: "ExtensionFilterControls",
769
+ props: /* @__PURE__ */ De({
770
+ tags: {}
771
+ }, {
772
+ selectedTag: { default: "" },
773
+ selectedTagModifiers: {},
774
+ searchValue: { default: "" },
775
+ searchValueModifiers: {}
776
+ }),
777
+ emits: ["update:selectedTag", "update:searchValue"],
778
+ setup(e) {
779
+ const a = e, t = ce(e, "selectedTag"), s = ce(e, "searchValue");
780
+ return (r, c) => (d(), p("div", Kt, [
781
+ k("div", zt, [
782
+ k("div", Wt, [
783
+ ae(k("select", {
784
+ "data-testid": "filter-tag",
785
+ class: "extension-filter-controls__select",
786
+ "aria-label": "标签",
787
+ disabled: a.tags.length === 0,
788
+ "onUpdate:modelValue": c[0] || (c[0] = (l) => t.value = l)
789
+ }, [
790
+ c[3] || (c[3] = k("option", { value: "" }, "全部标签", -1)),
791
+ (d(!0), p(P, null, U(a.tags, (l) => (d(), p("option", {
792
+ key: l.value,
793
+ value: l.value
794
+ }, I(l.label), 9, Xt))), 128))
795
+ ], 8, qt), [
796
+ [Re, t.value]
797
+ ]),
798
+ j($(ge), {
799
+ class: "extension-filter-controls__select-arrow",
800
+ "aria-hidden": "true"
801
+ })
802
+ ]),
803
+ k("div", Jt, [
804
+ ae(k("input", {
805
+ "data-testid": "filter-search",
806
+ class: "extension-filter-controls__input",
807
+ type: "search",
808
+ "aria-label": "搜索扩展",
809
+ placeholder: "请输入关键字搜索",
810
+ "onUpdate:modelValue": c[1] || (c[1] = (l) => s.value = l)
811
+ }, null, 512), [
812
+ [Fe, s.value]
813
+ ]),
814
+ s.value ? (d(), p("button", {
815
+ key: 0,
816
+ "data-testid": "filter-search-clear",
817
+ class: "extension-filter-controls__clear",
818
+ type: "button",
819
+ "aria-label": "清空搜索",
820
+ onClick: c[2] || (c[2] = (l) => s.value = "")
821
+ }, [
822
+ j($(je), {
823
+ class: "extension-filter-controls__clear-icon",
824
+ "aria-hidden": "true"
825
+ })
826
+ ])) : S("", !0)
827
+ ])
828
+ ])
829
+ ]));
830
+ }
831
+ }), Yt = /* @__PURE__ */ L(Qt, [["__scopeId", "data-v-21ca2283"]]), Zt = { class: "extension-manager" }, en = {
832
+ key: 0,
833
+ class: "extension-manager__header"
834
+ }, tn = {
835
+ key: 0,
836
+ class: "extension-manager__title"
837
+ }, nn = {
838
+ key: 1,
839
+ class: "extension-manager__header-actions"
840
+ }, an = ["id", "aria-labelledby"], on = {
841
+ key: 2,
842
+ class: "extension-manager__empty"
843
+ }, sn = /* @__PURE__ */ N({
844
+ name: "ExtensionManager",
845
+ __name: "index",
846
+ props: {
847
+ tabs: {},
848
+ activeTab: {},
849
+ defaultActiveTab: {},
850
+ title: {},
851
+ emptyText: { default: "暂无内容" }
852
+ },
853
+ emits: ["update:active-tab", "tab-change", "section-toggle", "action", "name-click"],
854
+ setup(e, { emit: a }) {
855
+ const t = e, s = a, r = G(), c = [
856
+ { key: "installed", title: "已安装" },
857
+ { key: "available", title: "可安装" }
858
+ ], l = (b) => b.length + ":" + b, v = (b, T) => "extension-manager/section/" + l(b) + "/" + l(T), n = "extension-manager-" + be(), u = (b) => n + "-tab-" + l(b), y = (b) => n + "-tabpanel-" + l(b), w = (b, T) => {
859
+ switch (b) {
860
+ case "update:active-tab":
861
+ s("update:active-tab", T);
862
+ break;
863
+ case "tab-change":
864
+ s("tab-change", T);
865
+ break;
866
+ case "section-toggle":
867
+ s("section-toggle", T);
868
+ break;
869
+ }
870
+ }, { activeTab: C, activeTabId: m, selectTab: f, isSectionExpanded: i, toggleSection: g } = ze(
871
+ t,
872
+ w
873
+ ), { getFilterState: h } = qe(() => t.tabs), V = (b) => [...new Set(b.flatMap((_) => _.tags ?? []))].map((_) => ({ value: _, label: _ })), F = Ze({
874
+ items: () => {
875
+ var b;
876
+ return ((b = C.value) == null ? void 0 : b.items) ?? [];
877
+ },
878
+ tags: () => {
879
+ var b;
880
+ return V(((b = C.value) == null ? void 0 : b.items) ?? []);
881
+ },
882
+ state: () => h(m.value)
883
+ }), _e = x(() => C.value !== void 0), ye = x(() => !!(t.title || r["header-actions"])), xe = (b) => {
884
+ const { installed: T, tags: _, ...E } = b;
885
+ return E;
886
+ }, ke = x(() => {
887
+ const b = F.filteredItems.value;
888
+ return c.map(({ key: T, title: _ }) => ({
889
+ key: T,
890
+ title: _,
891
+ items: b.filter((E) => (E.installed === !0 ? "installed" : "available") === T).map(xe)
892
+ }));
893
+ }), Ce = (b, T) => i(b, T), Te = (b, T) => {
894
+ var _;
895
+ ((_ = C.value) == null ? void 0 : _.id) === b && g(b, T);
896
+ }, we = (b, T, _) => {
897
+ s("action", {
898
+ tabId: b,
899
+ sectionKey: T,
900
+ itemId: _.itemId,
901
+ action: _.action
902
+ });
903
+ }, $e = (b, T, _) => {
904
+ s("name-click", {
905
+ tabId: b,
906
+ sectionKey: T,
907
+ itemId: _.itemId,
908
+ event: _.event
909
+ });
910
+ };
911
+ return (b, T) => (d(), p("div", Zt, [
912
+ ye.value ? (d(), p("div", en, [
913
+ t.title ? (d(), p("div", tn, I(t.title), 1)) : S("", !0),
914
+ r["header-actions"] ? (d(), p("div", nn, [
915
+ M(b.$slots, "header-actions", {}, void 0, !0)
916
+ ])) : S("", !0)
917
+ ])) : S("", !0),
918
+ j(Ht, {
919
+ tabs: t.tabs,
920
+ "active-tab-id": $(m),
921
+ "id-prefix": n,
922
+ onSelect: $(f)
923
+ }, J({ _: 2 }, [
924
+ r.tab ? {
925
+ name: "tab",
926
+ fn: O(({ tab: _, active: E, select: ne }) => [
927
+ M(b.$slots, "tab", {
928
+ tab: _,
929
+ active: E,
930
+ select: ne
931
+ }, void 0, !0)
932
+ ]),
933
+ key: "0"
934
+ } : void 0
935
+ ]), 1032, ["tabs", "active-tab-id", "onSelect"]),
936
+ j(Yt, pe(fe($(F).controls.value)), null, 16),
937
+ _e.value ? (d(), p("div", {
938
+ key: 1,
939
+ class: "extension-manager__sections",
940
+ role: "tabpanel",
941
+ id: y($(m)),
942
+ "aria-labelledby": u($(m))
943
+ }, [
944
+ (d(!0), p(P, null, U(ke.value, (_) => (d(), A(Ot, {
945
+ key: v($(m), _.key),
946
+ "tab-id": $(m),
947
+ section: _,
948
+ expanded: Ce($(m), _.key),
949
+ onSectionToggle: (E) => Te($(m), _.key),
950
+ onAction: (E) => we($(m), _.key, E),
951
+ onNameClick: (E) => $e($(m), _.key, E)
952
+ }, J({ _: 2 }, [
953
+ r.item ? {
954
+ name: "item",
955
+ fn: O(({ item: E, index: ne }) => [
956
+ M(b.$slots, "item", {
957
+ tab: $(C),
958
+ sectionKey: _.key,
959
+ item: E,
960
+ index: ne
961
+ }, void 0, !0)
962
+ ]),
963
+ key: "0"
964
+ } : void 0,
965
+ r.empty ? {
966
+ name: "empty",
967
+ fn: O(() => [
968
+ M(b.$slots, "empty", {
969
+ tab: $(C),
970
+ sectionKey: _.key,
971
+ title: _.title
972
+ }, void 0, !0)
973
+ ]),
974
+ key: "1"
975
+ } : void 0
976
+ ]), 1032, ["tab-id", "section", "expanded", "onSectionToggle", "onAction", "onNameClick"]))), 128))
977
+ ], 8, an)) : (d(), p("div", on, I(t.emptyText), 1))
978
+ ]));
979
+ }
980
+ }), Z = /* @__PURE__ */ L(sn, [["__scopeId", "data-v-f410c157"]]);
981
+ W.name = "TrExtensionCard";
982
+ const rn = function(e) {
983
+ e.component(W.name, W);
984
+ }, ee = W;
985
+ ee.install = rn;
986
+ q.name = "TrExtensionCardGrid";
987
+ const ln = function(e) {
988
+ e.component(q.name, q);
989
+ }, te = q;
990
+ te.install = ln;
991
+ Z.name = "TrExtensionManager";
992
+ const cn = function(e) {
993
+ e.component(Z.name, Z), e.component(ee.name, ee), e.component(te.name, te);
994
+ }, pn = Object.assign(Z, {
995
+ install: cn,
996
+ Card: ee,
997
+ CardGrid: te
998
+ });
999
+ export {
1000
+ ee as ExtensionCard,
1001
+ te as ExtensionCardGrid,
1002
+ pn as ExtensionManager,
1003
+ pn as default
1004
+ };