@opentiny/tiny-robot 0.5.2-alpha.8 → 0.5.2-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,1006 @@
1
+ import * as ce 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 ve, defineComponent as N, onMounted as pe, toRef as Ve, useSlots as G, openBlock as c, createElementBlock as p, createBlock as A, resolveDynamicComponent as H, renderSlot as M, withDirectives as ae, createElementVNode as C, 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 fe, guardReactiveProps as Le, createTextVNode as re, mergeProps as ge, onBeforeUnmount as Be, useModel as de, vModelSelect as Re, vModelText as Fe, mergeModels as De } from "vue";
3
+ import { IconMore as Oe, IconArrowDown as be, 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 ue = /* @__PURE__ */ new WeakMap();
7
+ function he() {
8
+ const e = ce.useId;
9
+ if (e)
10
+ return e();
11
+ const a = ce.getCurrentInstance();
12
+ if (!a)
13
+ return "";
14
+ const t = a.appContext, s = ue.get(t) ?? 0;
15
+ return ue.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 [d, l] of Object.entries(s ?? {}))
29
+ (d === "installed" || d === "available") && z(r, d, 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)), d = 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) ?? d.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), me = () => se({ selectedTag: "", searchValue: "" }), qe = (e) => {
100
+ const a = se(We()), t = me();
101
+ return D(
102
+ () => X(e).map((r) => r.id),
103
+ (r) => {
104
+ const d = new Set(r);
105
+ for (const l of Object.keys(a))
106
+ d.has(l) || delete a[l];
107
+ },
108
+ { immediate: !0 }
109
+ ), { getFilterState: (r) => r === void 0 ? t : a[r] ?? (a[r] = me()) };
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
+ }), d = x(() => Je(X(e.tags)));
133
+ D(
134
+ d,
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((k) => {
144
+ const m = !s.value || n(k).includes(s.value), f = !o || u(k, o);
145
+ return m && f;
146
+ });
147
+ }), v = x(() => ({
148
+ tags: d.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
+ }, _e = (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] : _e(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 d = _e(((l = e()) == null ? void 0 : l(s)) ?? []);
165
+ return d.length !== 1 || !et(d[0]) ? null : Se(d[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(), d = () => {
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)), k = l.bottom + n, m = l.top - v.height - n, f = k + 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" ? k : 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 ve(), d());
197
+ },
198
+ { flush: "post" }
199
+ ), Q("resize", d, { passive: !0 }), Q("scroll", d, {
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-${he()}`, s = B(null), r = B(null), d = B(!1), l = B(!1);
214
+ pe(() => {
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: d,
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
+ d.value = !1;
235
+ return;
236
+ }
237
+ (i = r.value) != null && i.matches(":popover-open") && r.value.hidePopover();
238
+ }, w = () => {
239
+ if (!l.value) {
240
+ d.value = !d.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 || !d.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 || !d.value || i.key !== "Escape" || (y(), (g = s.value) == null || g.focus());
251
+ });
252
+ const { renderAsChild: k } = tt({
253
+ getSlot: () => n.trigger,
254
+ componentName: "ExtensionCardPopover"
255
+ }), m = () => k(
256
+ {
257
+ popoverId: t,
258
+ open: d.value
259
+ },
260
+ {
261
+ ref: u,
262
+ ...l.value ? {
263
+ popovertarget: t,
264
+ popovertargetaction: "toggle"
265
+ } : { onClick: w }
266
+ }
267
+ ), f = (i) => {
268
+ d.value = i.newState === "open";
269
+ };
270
+ return (i, g) => (c(), p(P, null, [
271
+ e.asChild ? (c(), A(H(m()), { key: 0 })) : (c(), 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": d.value,
279
+ onClick: w
280
+ }, [
281
+ M(i.$slots, "trigger", {
282
+ popoverId: t,
283
+ open: d.value
284
+ }, void 0, !0)
285
+ ], 8, at)),
286
+ ae(C("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 || d.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)), d = (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 ? (c(), p("div", rt, [
329
+ j(it, {
330
+ "as-child": "",
331
+ placement: t.placement
332
+ }, {
333
+ trigger: O(({ open: o }) => [
334
+ C("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
+ C("ul", ct, [
346
+ (c(!0), p(P, null, U(t.actions, (n) => (c(), p("li", {
347
+ key: n.id
348
+ }, [
349
+ C("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) => d(n, o)
355
+ }, [
356
+ r.value ? (c(), p("span", ut, [
357
+ n.icon ? (c(), A(H(n.icon), {
358
+ key: 0,
359
+ class: "tr-extension-card__more-menu-item-icon"
360
+ })) : (c(), p("span", mt))
361
+ ])) : S("", !0),
362
+ C("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-657a919a"]]), 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
+ }, d = (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) => (c(), p("div", ft, [
394
+ (c(!0), p(P, null, U(t.actions, (n) => (c(), p(P, {
395
+ key: n.id
396
+ }, [
397
+ n.type === "switch" ? (c(), p("label", {
398
+ key: 0,
399
+ class: R(["tr-extension-card-primary-actions__switch", { "is-disabled": n.disabled, "is-danger": n.danger }])
400
+ }, [
401
+ C("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] = C("span", { class: "tr-extension-card-primary-actions__switch-track" }, null, -1))
410
+ ], 2)) : n.type === "button" ? (c(), 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) => d(n)
417
+ }, [
418
+ n.icon ? (c(), A(H(n.icon), {
419
+ key: 0,
420
+ class: "tr-extension-card-primary-actions__button-icon"
421
+ })) : S("", !0),
422
+ C("span", null, I(n.label), 1)
423
+ ], 10, bt)) : v.$slots["primary-action"] ? (c(), 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)) : (c(), 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 ? (c(), A(H(n.icon), {
440
+ key: 0,
441
+ class: "tr-extension-card-primary-actions__button-icon"
442
+ })) : S("", !0),
443
+ C("span", null, I(n.label), 1)
444
+ ], 10, ht))
445
+ ], 64))), 128))
446
+ ]));
447
+ }
448
+ }), yt = /* @__PURE__ */ L(_t, [["__scopeId", "data-v-d5244352"]]), 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, d = x(() => t.actions.filter((f) => !f.hidden)), l = x(() => Math.max(0, Math.floor(t.primaryActionsLimit))), v = x(() => d.value.slice(0, l.value)), o = x(() => d.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
+ }, k = (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) => (c(), p("div", xt, [
475
+ C("div", kt, [
476
+ typeof e.icon == "string" && e.icon ? (c(), 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 ? (c(), A(H(e.icon), {
482
+ key: 1,
483
+ class: "tr-extension-card__icon"
484
+ })) : (c(), p("div", Tt, I(e.name.slice(0, 1)), 1))
485
+ ]),
486
+ C("div", wt, [
487
+ C("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: k,
493
+ onKeydown: m
494
+ }, I(e.name), 43, $t),
495
+ e.description ? (c(), 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 ? (c(), 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 ? (c(), 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", fe(Le(g)), void 0, !0)
518
+ ]),
519
+ key: "0"
520
+ } : void 0
521
+ ]), 1032, ["actions"])) : S("", !0),
522
+ o.value.length ? (c(), 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 ? (c(), 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
+ C("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-c38268e3"]]), 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, d = (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) => (c(), p("ul", It, [
579
+ e.items.length === 0 ? (c(), p("li", At, [
580
+ M(o.$slots, "empty", {}, () => [
581
+ re(I(e.emptyText), 1)
582
+ ], !0)
583
+ ])) : (c(!0), p(P, { key: 1 }, U(e.items, (u, y) => (c(), 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) : (c(), A(W, ge({
592
+ key: 1,
593
+ ref_for: !0
594
+ }, d(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, d = () => r("section-toggle", !t.expanded), l = (o) => r("action", o), v = (o) => r("name-click", o);
618
+ return (o, n) => (c(), p("section", {
619
+ class: "extension-manager-section",
620
+ "data-tab-id": t.tabId,
621
+ "data-section-key": t.section.key
622
+ }, [
623
+ C("div", Lt, [
624
+ C("button", {
625
+ class: "extension-manager-section__title",
626
+ type: "button",
627
+ "aria-expanded": t.expanded,
628
+ onClick: d
629
+ }, [
630
+ j($(be), {
631
+ class: R(["extension-manager-section__arrow", { "is-expanded": t.expanded }])
632
+ }, null, 8, ["class"]),
633
+ C("span", null, I(t.section.title), 1)
634
+ ], 8, Bt)
635
+ ]),
636
+ t.expanded ? (c(), p("div", Rt, [
637
+ t.section.items.length > 0 ? (c(), 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"])) : (c(), 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(), d = (i) => `${i.length}:${i}`, l = (i) => `${t.idPrefix}-tab-${d(i)}`, v = (i) => `${t.idPrefix}-tabpanel-${d(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" }), pe(() => {
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 k = (i) => s("select", i), m = (i) => {
697
+ ve(() => {
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(), k(V.id), m(V.id));
721
+ };
722
+ return (i, g) => (c(), p("div", jt, [
723
+ (c(!0), p(P, null, U(t.tabs, (h, V) => (c(), 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) => k(h.id),
735
+ onKeydown: (F) => f(V, F)
736
+ }, [
737
+ r.tab ? (c(), 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: () => k(h.id)
747
+ }, void 0, !0)
748
+ ])) : (c(), p(P, { key: 1 }, [
749
+ re(I(h.label), 1)
750
+ ], 64))
751
+ ], 40, Gt))), 128)),
752
+ n.value ? (c(), 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-ce43701e"]]), 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 = {
767
+ key: 0,
768
+ class: "extension-filter-controls__select-wrapper"
769
+ }, qt = ["value"], Xt = { class: "extension-filter-controls__input-wrapper" }, Jt = /* @__PURE__ */ N({
770
+ name: "ExtensionFilterControls",
771
+ __name: "ExtensionFilterControls",
772
+ props: /* @__PURE__ */ De({
773
+ tags: {}
774
+ }, {
775
+ selectedTag: { default: "" },
776
+ selectedTagModifiers: {},
777
+ searchValue: { default: "" },
778
+ searchValueModifiers: {}
779
+ }),
780
+ emits: ["update:selectedTag", "update:searchValue"],
781
+ setup(e) {
782
+ const a = e, t = de(e, "selectedTag"), s = de(e, "searchValue");
783
+ return (r, d) => (c(), p("div", Kt, [
784
+ C("div", zt, [
785
+ a.tags.length > 0 ? (c(), p("div", Wt, [
786
+ ae(C("select", {
787
+ "data-testid": "filter-tag",
788
+ class: "extension-filter-controls__select",
789
+ "aria-label": "标签",
790
+ "onUpdate:modelValue": d[0] || (d[0] = (l) => t.value = l)
791
+ }, [
792
+ d[3] || (d[3] = C("option", { value: "" }, "全部标签", -1)),
793
+ (c(!0), p(P, null, U(a.tags, (l) => (c(), p("option", {
794
+ key: l.value,
795
+ value: l.value
796
+ }, I(l.label), 9, qt))), 128))
797
+ ], 512), [
798
+ [Re, t.value]
799
+ ]),
800
+ j($(be), {
801
+ class: "extension-filter-controls__select-arrow",
802
+ "aria-hidden": "true"
803
+ })
804
+ ])) : S("", !0),
805
+ C("div", Xt, [
806
+ ae(C("input", {
807
+ "data-testid": "filter-search",
808
+ class: "extension-filter-controls__input",
809
+ type: "search",
810
+ "aria-label": "搜索扩展",
811
+ placeholder: "请输入关键字搜索",
812
+ "onUpdate:modelValue": d[1] || (d[1] = (l) => s.value = l)
813
+ }, null, 512), [
814
+ [Fe, s.value]
815
+ ]),
816
+ s.value ? (c(), p("button", {
817
+ key: 0,
818
+ "data-testid": "filter-search-clear",
819
+ class: "extension-filter-controls__clear",
820
+ type: "button",
821
+ "aria-label": "清空搜索",
822
+ onClick: d[2] || (d[2] = (l) => s.value = "")
823
+ }, [
824
+ j($(je), {
825
+ class: "extension-filter-controls__clear-icon",
826
+ "aria-hidden": "true"
827
+ })
828
+ ])) : S("", !0)
829
+ ])
830
+ ])
831
+ ]));
832
+ }
833
+ }), Qt = /* @__PURE__ */ L(Jt, [["__scopeId", "data-v-470772ce"]]), Yt = { class: "extension-manager" }, Zt = {
834
+ key: 0,
835
+ class: "extension-manager__header"
836
+ }, en = {
837
+ key: 0,
838
+ class: "extension-manager__title"
839
+ }, tn = {
840
+ key: 1,
841
+ class: "extension-manager__header-actions"
842
+ }, nn = ["id", "aria-labelledby"], an = {
843
+ key: 3,
844
+ class: "extension-manager__empty"
845
+ }, on = /* @__PURE__ */ N({
846
+ name: "ExtensionManager",
847
+ __name: "index",
848
+ props: {
849
+ tabs: {},
850
+ activeTab: {},
851
+ defaultActiveTab: {},
852
+ title: {},
853
+ emptyText: { default: "暂无内容" }
854
+ },
855
+ emits: ["update:active-tab", "tab-change", "section-toggle", "action", "name-click"],
856
+ setup(e, { emit: a }) {
857
+ const t = e, s = a, r = G(), d = [
858
+ { key: "installed", title: "已安装" },
859
+ { key: "available", title: "可安装" }
860
+ ], l = (b) => b.length + ":" + b, v = (b, T) => "extension-manager/section/" + l(b) + "/" + l(T), n = "extension-manager-" + he(), u = (b) => n + "-tab-" + l(b), y = (b) => n + "-tabpanel-" + l(b), w = (b, T) => {
861
+ switch (b) {
862
+ case "update:active-tab":
863
+ s("update:active-tab", T);
864
+ break;
865
+ case "tab-change":
866
+ s("tab-change", T);
867
+ break;
868
+ case "section-toggle":
869
+ s("section-toggle", T);
870
+ break;
871
+ }
872
+ }, { activeTab: k, activeTabId: m, selectTab: f, isSectionExpanded: i, toggleSection: g } = ze(
873
+ t,
874
+ w
875
+ ), { getFilterState: h } = qe(() => t.tabs), V = (b) => [...new Set(b.flatMap((_) => _.tags ?? []))].map((_) => ({ value: _, label: _ })), F = Ze({
876
+ items: () => {
877
+ var b;
878
+ return ((b = k.value) == null ? void 0 : b.items) ?? [];
879
+ },
880
+ tags: () => {
881
+ var b;
882
+ return V(((b = k.value) == null ? void 0 : b.items) ?? []);
883
+ },
884
+ state: () => h(m.value)
885
+ }), le = x(() => k.value !== void 0), ye = x(() => !!(t.title || r["header-actions"])), xe = (b) => {
886
+ const { installed: T, tags: _, ...E } = b;
887
+ return E;
888
+ }, ke = x(() => {
889
+ const b = F.filteredItems.value;
890
+ return d.map(({ key: T, title: _ }) => ({
891
+ key: T,
892
+ title: _,
893
+ items: b.filter((E) => (E.installed === !0 ? "installed" : "available") === T).map(xe)
894
+ }));
895
+ }), Ce = (b, T) => i(b, T), Te = (b, T) => {
896
+ var _;
897
+ ((_ = k.value) == null ? void 0 : _.id) === b && g(b, T);
898
+ }, we = (b, T, _) => {
899
+ s("action", {
900
+ tabId: b,
901
+ sectionKey: T,
902
+ itemId: _.itemId,
903
+ action: _.action
904
+ });
905
+ }, $e = (b, T, _) => {
906
+ s("name-click", {
907
+ tabId: b,
908
+ sectionKey: T,
909
+ itemId: _.itemId,
910
+ event: _.event
911
+ });
912
+ };
913
+ return (b, T) => (c(), p("div", Yt, [
914
+ ye.value ? (c(), p("div", Zt, [
915
+ t.title ? (c(), p("div", en, I(t.title), 1)) : S("", !0),
916
+ r["header-actions"] ? (c(), p("div", tn, [
917
+ M(b.$slots, "header-actions", {}, void 0, !0)
918
+ ])) : S("", !0)
919
+ ])) : S("", !0),
920
+ j(Ht, {
921
+ tabs: t.tabs,
922
+ "active-tab-id": $(m),
923
+ "id-prefix": n,
924
+ onSelect: $(f)
925
+ }, J({ _: 2 }, [
926
+ r.tab ? {
927
+ name: "tab",
928
+ fn: O(({ tab: _, active: E, select: ne }) => [
929
+ M(b.$slots, "tab", {
930
+ tab: _,
931
+ active: E,
932
+ select: ne
933
+ }, void 0, !0)
934
+ ]),
935
+ key: "0"
936
+ } : void 0
937
+ ]), 1032, ["tabs", "active-tab-id", "onSelect"]),
938
+ le.value ? (c(), A(Qt, fe(ge({ key: 1 }, $(F).controls.value)), null, 16)) : S("", !0),
939
+ le.value ? (c(), p("div", {
940
+ key: 2,
941
+ class: "extension-manager__sections",
942
+ role: "tabpanel",
943
+ id: y($(m)),
944
+ "aria-labelledby": u($(m))
945
+ }, [
946
+ (c(!0), p(P, null, U(ke.value, (_) => (c(), A(Ot, {
947
+ key: v($(m), _.key),
948
+ "tab-id": $(m),
949
+ section: _,
950
+ expanded: Ce($(m), _.key),
951
+ onSectionToggle: (E) => Te($(m), _.key),
952
+ onAction: (E) => we($(m), _.key, E),
953
+ onNameClick: (E) => $e($(m), _.key, E)
954
+ }, J({ _: 2 }, [
955
+ r.item ? {
956
+ name: "item",
957
+ fn: O(({ item: E, index: ne }) => [
958
+ M(b.$slots, "item", {
959
+ tab: $(k),
960
+ sectionKey: _.key,
961
+ item: E,
962
+ index: ne
963
+ }, void 0, !0)
964
+ ]),
965
+ key: "0"
966
+ } : void 0,
967
+ r.empty ? {
968
+ name: "empty",
969
+ fn: O(() => [
970
+ M(b.$slots, "empty", {
971
+ tab: $(k),
972
+ sectionKey: _.key,
973
+ title: _.title
974
+ }, void 0, !0)
975
+ ]),
976
+ key: "1"
977
+ } : void 0
978
+ ]), 1032, ["tab-id", "section", "expanded", "onSectionToggle", "onAction", "onNameClick"]))), 128))
979
+ ], 8, nn)) : (c(), p("div", an, I(t.emptyText), 1))
980
+ ]));
981
+ }
982
+ }), Z = /* @__PURE__ */ L(on, [["__scopeId", "data-v-de388c90"]]);
983
+ W.name = "TrExtensionCard";
984
+ const sn = function(e) {
985
+ e.component(W.name, W);
986
+ }, ee = W;
987
+ ee.install = sn;
988
+ q.name = "TrExtensionCardGrid";
989
+ const rn = function(e) {
990
+ e.component(q.name, q);
991
+ }, te = q;
992
+ te.install = rn;
993
+ Z.name = "TrExtensionManager";
994
+ const ln = function(e) {
995
+ e.component(Z.name, Z), e.component(ee.name, ee), e.component(te.name, te);
996
+ }, vn = Object.assign(Z, {
997
+ install: ln,
998
+ Card: ee,
999
+ CardGrid: te
1000
+ });
1001
+ export {
1002
+ ee as ExtensionCard,
1003
+ te as ExtensionCardGrid,
1004
+ vn as ExtensionManager,
1005
+ vn as default
1006
+ };