vue-composable-ui 0.0.1 → 1.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.
Files changed (81) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/dist/composable-ui.js +1114 -0
  4. package/dist/composable-ui.umd.cjs +1 -0
  5. package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +8 -0
  6. package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
  7. package/dist/types/components/combobox/comboboxOption.vue.d.ts +22 -0
  8. package/dist/types/components/combobox/comboboxOptions.vue.d.ts +11 -0
  9. package/dist/types/components/injectionKeys.d.ts +43 -0
  10. package/dist/types/components/listbox/listbox.vue.d.ts +26 -0
  11. package/dist/types/components/listbox/listboxOption.vue.d.ts +22 -0
  12. package/dist/types/components/menu/menuItem.vue.d.ts +26 -0
  13. package/dist/types/components/menu/menuItems.vue.d.ts +11 -0
  14. package/dist/types/components/popover/popoverDialog.vue.d.ts +11 -0
  15. package/dist/types/components/tabs/tab.vue.d.ts +19 -0
  16. package/dist/types/components/tabs/tabContainer.vue.d.ts +18 -0
  17. package/dist/types/components/tabs/tabList.vue.d.ts +17 -0
  18. package/dist/types/components/tabs/tabPanel.vue.d.ts +15 -0
  19. package/dist/types/components/tooltip.vue.d.ts +36 -0
  20. package/dist/types/composables/formControl.d.ts +48 -0
  21. package/dist/types/composables/list.d.ts +103 -0
  22. package/dist/types/composables/listOption.d.ts +30 -0
  23. package/dist/types/composables/popover.d.ts +68 -0
  24. package/{src/main.ts → dist/types/main.d.ts} +3 -44
  25. package/dist/types/utils/element.d.ts +3 -0
  26. package/dist/types/utils/id.d.ts +1 -0
  27. package/package.json +19 -6
  28. package/.github/workflows/deploy.yml +0 -21
  29. package/.github/workflows/docs.yml +0 -62
  30. package/.vscode/extensions.json +0 -7
  31. package/docs/.vitepress/config.mts +0 -40
  32. package/docs/.vitepress/theme/index.js +0 -4
  33. package/docs/.vitepress/theme/style.scss +0 -155
  34. package/docs/components/combobox.md +0 -174
  35. package/docs/components/demos/combobox.vue +0 -142
  36. package/docs/components/demos/combobox_autocomplete.vue +0 -75
  37. package/docs/components/demos/combobox_tags.vue +0 -127
  38. package/docs/components/demos/input.vue +0 -35
  39. package/docs/components/demos/listbox.vue +0 -64
  40. package/docs/components/demos/menu.vue +0 -93
  41. package/docs/components/demos/popover.vue +0 -16
  42. package/docs/components/demos/tabs.vue +0 -59
  43. package/docs/components/demos/tooltip.vue +0 -27
  44. package/docs/components/listbox.md +0 -9
  45. package/docs/components/menu.md +0 -121
  46. package/docs/components/popover.md +0 -82
  47. package/docs/components/tabs.md +0 -9
  48. package/docs/components/tooltip.md +0 -78
  49. package/docs/composables/form-control.md +0 -130
  50. package/docs/composables/list-option.md +0 -47
  51. package/docs/composables/list.md +0 -192
  52. package/docs/composables/popover.md +0 -90
  53. package/docs/index.md +0 -24
  54. package/docs/intro.md +0 -0
  55. package/src/components/combobox/combobox.vue +0 -229
  56. package/src/components/combobox/comboboxFormInput.vue +0 -33
  57. package/src/components/combobox/comboboxOption.vue +0 -52
  58. package/src/components/combobox/comboboxOptions.vue +0 -17
  59. package/src/components/injectionKeys.ts +0 -50
  60. package/src/components/listbox/listbox.vue +0 -91
  61. package/src/components/listbox/listboxOption.vue +0 -37
  62. package/src/components/menu/menu.vue +0 -100
  63. package/src/components/menu/menuItem.vue +0 -86
  64. package/src/components/menu/menuItems.vue +0 -51
  65. package/src/components/popover/popover.vue +0 -68
  66. package/src/components/popover/popoverDialog.vue +0 -35
  67. package/src/components/tabs/tab.vue +0 -35
  68. package/src/components/tabs/tabContainer.vue +0 -50
  69. package/src/components/tabs/tabList.vue +0 -52
  70. package/src/components/tabs/tabPanel.vue +0 -36
  71. package/src/components/tooltip.vue +0 -115
  72. package/src/composables/formControl.ts +0 -144
  73. package/src/composables/list.ts +0 -326
  74. package/src/composables/listOption.ts +0 -80
  75. package/src/composables/popover.ts +0 -306
  76. package/src/utils/element.ts +0 -19
  77. package/src/utils/id.ts +0 -5
  78. package/src/vite-env.d.ts +0 -1
  79. package/tsconfig.json +0 -27
  80. package/tsconfig.node.json +0 -10
  81. package/vite.config.ts +0 -28
@@ -0,0 +1,1114 @@
1
+ import { ref as S, watch as oe, nextTick as H, onMounted as ae, onBeforeUnmount as G, shallowRef as pe, computed as E, provide as U, readonly as J, shallowReadonly as me, triggerRef as ce, unref as s, inject as B, onBeforeMount as be, defineComponent as A, mergeModels as ie, useModel as W, openBlock as _, createElementBlock as y, renderSlot as O, createCommentVNode as N, useSlots as Ie, Fragment as z, createBlock as te, Teleport as we, mergeProps as de, createTextVNode as he, toDisplayString as _e, renderList as fe, withDirectives as ge, vModelDynamic as ye } from "vue";
2
+ function R(i) {
3
+ return typeof i == "string" ? S(document.querySelector(i) || void 0) : i instanceof HTMLElement ? S(i) : i;
4
+ }
5
+ function Q(i, e, {
6
+ direction: t = "down",
7
+ align: o = "left",
8
+ position: n = "fixed",
9
+ closeOnOutsideClick: r = !0,
10
+ closeOnInsideClick: f = !1
11
+ } = {}) {
12
+ const a = S(!1);
13
+ function c() {
14
+ const v = R(i);
15
+ if (!v.value) throw new Error("Activator element is undefined");
16
+ return v.value;
17
+ }
18
+ function u() {
19
+ const v = R(e);
20
+ if (!v.value) throw new Error("Popover element is undefined");
21
+ return v.value;
22
+ }
23
+ function m({ focus: v = !0 } = {}) {
24
+ a.value = !0, v && H(() => {
25
+ u().focus();
26
+ });
27
+ }
28
+ function b({ focus: v = !0 } = {}) {
29
+ a.value = !1, v && c().focus();
30
+ }
31
+ function d(v) {
32
+ a.value ? b(v) : m(v);
33
+ }
34
+ function w() {
35
+ if (!a.value) return;
36
+ const v = c(), $ = u();
37
+ $.style.position = n;
38
+ const {
39
+ top: j,
40
+ right: l,
41
+ bottom: p,
42
+ left: h,
43
+ width: x,
44
+ height: I
45
+ } = v.getBoundingClientRect(), L = $.offsetHeight, F = $.offsetWidth, K = document.documentElement.clientHeight, q = document.documentElement.clientWidth;
46
+ let P = t;
47
+ t == "up" ? j - L < 0 && (P = "down") : t == "down" ? p + L > K && (P = "up") : t == "right" ? l + F > q && (P = "left") : t == "left" && h - F < 0 && (P = "right");
48
+ let M = o;
49
+ o == "left" ? h + F > q && (M = "right") : o == "right" ? l - F < 0 && (M = "left") : o == "top" ? j + L > K && (M = "bottom") : o == "bottom" && p - L < 0 && (M = "top");
50
+ const V = {
51
+ top: "auto",
52
+ bottom: "auto",
53
+ left: "auto",
54
+ right: "auto",
55
+ width: "auto"
56
+ }, T = n === "fixed";
57
+ P == "up" ? V.bottom = `${I + (T ? K - p : 0)}px` : P == "down" ? V.top = `${I + (T ? j : 0)}px` : P == "right" ? V.left = `${x + (T ? h : 0)}px` : P == "left" && (V.right = `${x + (T ? q - l : 0)}px`), ["up", "down"].includes(P) ? M == "right" ? V.right = `${T ? q - l : 0}px` : M == "left" || M == "stretch" ? V.left = `${T ? h : 0}px` : M == "center" && (V.left = `${(T ? h : 0) - (F - x) / 2}px`) : M == "bottom" ? V.bottom = `${T ? K - p : 0}px` : M == "top" ? V.top = `${T ? j : 0}px` : M == "center" && (V.top = `${(T ? j : 0) - (L - I) / 2}px`), ["up", "down"].includes(P) && M === "stretch" && (V.width = x + "px");
58
+ for (const le in V)
59
+ $.style[le] = V[le];
60
+ }
61
+ oe(
62
+ a,
63
+ (v) => {
64
+ v && H(() => {
65
+ w();
66
+ });
67
+ },
68
+ { flush: "pre" }
69
+ );
70
+ function C(v) {
71
+ const $ = v.target;
72
+ if (!c().contains($))
73
+ try {
74
+ u().contains($) ? f && b() : r && (a.value = !1);
75
+ } catch {
76
+ }
77
+ }
78
+ const g = new ResizeObserver(w), k = new AbortController();
79
+ return ae(() => {
80
+ window.addEventListener("resize", w, {
81
+ passive: !0,
82
+ signal: k.signal
83
+ }), window.addEventListener("scroll", w, {
84
+ passive: !0,
85
+ //capture: true,
86
+ signal: k.signal
87
+ }), window.addEventListener("click", C, {
88
+ passive: !0,
89
+ signal: k.signal
90
+ }), g.observe(c());
91
+ }), G(() => {
92
+ k.abort(), g.disconnect();
93
+ }), {
94
+ isOpen: a,
95
+ open: m,
96
+ close: b,
97
+ toggle: d
98
+ };
99
+ }
100
+ const ne = Symbol();
101
+ function ee(i, e) {
102
+ const [t, o] = [s(i), s(e)];
103
+ return typeof t == "object" ? typeof o == "object" ? JSON.stringify(t) === JSON.stringify(o) : !1 : t === o;
104
+ }
105
+ function X(i) {
106
+ let e = 0;
107
+ const t = pe([]), o = S(), n = E(() => Array.isArray(i.value));
108
+ function r(l) {
109
+ const p = t.value.find((h) => h.id === l);
110
+ if (!p) throw new Error(`Item not found: (${l})`);
111
+ return p;
112
+ }
113
+ function f(l) {
114
+ const p = s(l.element);
115
+ if (p)
116
+ return p.focus(), p;
117
+ }
118
+ function a(l, { focus: p = !1 } = {}) {
119
+ o.value = (l == null ? void 0 : l.id) ?? void 0, l !== void 0 && p && f(l);
120
+ }
121
+ function c(l, { focus: p = !1 } = {}) {
122
+ const h = r(l);
123
+ return a(h, { focus: p });
124
+ }
125
+ function u(l) {
126
+ return o.value === l;
127
+ }
128
+ function m(l, p, h = !1) {
129
+ const x = R(l), I = e++;
130
+ return t.value.push({
131
+ id: I,
132
+ value: p,
133
+ element: x,
134
+ disabled: h
135
+ }), ce(t), I;
136
+ }
137
+ function b(l) {
138
+ u(l) && a();
139
+ const p = r(l), h = t.value.indexOf(p);
140
+ t.value.splice(h, 1), ce(t);
141
+ }
142
+ function d(l) {
143
+ const p = r(l);
144
+ if (s(p.disabled)) return;
145
+ const h = s(p.value);
146
+ if (h !== void 0) {
147
+ if (s(n)) {
148
+ const x = i.value.findIndex(
149
+ (I) => ee(h, I)
150
+ );
151
+ x > -1 ? i.value.splice(x, 1) : i.value = [...i.value, h];
152
+ } else
153
+ i.value = h;
154
+ a(p);
155
+ }
156
+ }
157
+ function w(l) {
158
+ return s(n) ? !!i.value.find(
159
+ (p) => ee(l.value, p)
160
+ ) : ee(i, l.value);
161
+ }
162
+ function C(l) {
163
+ try {
164
+ const p = r(l);
165
+ return w(p);
166
+ } catch {
167
+ return !1;
168
+ }
169
+ }
170
+ function g({ focus: l = !1 } = {}) {
171
+ for (let p of t.value)
172
+ if (w(p))
173
+ return a(p, { focus: l });
174
+ }
175
+ function k({ focus: l = !1 } = {}) {
176
+ if (t.value.length)
177
+ return a(t.value[0], { focus: l });
178
+ }
179
+ function v({ focus: l = !1 } = {}) {
180
+ if (t.value.length)
181
+ return a(t.value[t.value.length - 1], { focus: l });
182
+ }
183
+ function $({
184
+ focus: l = !1,
185
+ loop: p = !1
186
+ } = {}) {
187
+ if (o.value === void 0) return k({ focus: l });
188
+ const h = r(o.value), x = t.value.indexOf(h);
189
+ let I;
190
+ if (x + 1 < t.value.length)
191
+ I = t.value[x + 1];
192
+ else if (p)
193
+ I = t.value[0];
194
+ else
195
+ return;
196
+ return a(I, { focus: l });
197
+ }
198
+ function j({
199
+ focus: l = !1,
200
+ loop: p = !1
201
+ } = {}) {
202
+ if (o.value === void 0) return v({ focus: l });
203
+ const h = r(o.value), x = t.value.indexOf(h);
204
+ let I;
205
+ if (x - 1 > -1)
206
+ I = t.value[x - 1];
207
+ else if (p)
208
+ I = t.value[t.value.length - 1];
209
+ else
210
+ return;
211
+ return a(I, { focus: l });
212
+ }
213
+ return U(ne, {
214
+ value: J(i),
215
+ selectItem: d,
216
+ activateItem: c,
217
+ isSelected: C,
218
+ isActive: u,
219
+ addItem: m,
220
+ removeItem: b
221
+ }), {
222
+ items: me(t),
223
+ isMultiselectable: J(n),
224
+ activeItem: E(
225
+ () => o.value !== void 0 ? r(o.value) : void 0
226
+ ),
227
+ selectActiveItem: () => {
228
+ o.value !== void 0 && d(o.value);
229
+ },
230
+ activateSelectedItem: g,
231
+ activateFirstItem: k,
232
+ activateLastItem: v,
233
+ activateNextItem: $,
234
+ activatePrevItem: j
235
+ };
236
+ }
237
+ function Y(i, e, t) {
238
+ const o = B(ne);
239
+ if (!o)
240
+ throw new Error("List injectable context is not provided");
241
+ const n = S(-1), r = E(() => o.isSelected(n.value)), f = E(() => o.isActive(n.value));
242
+ function a() {
243
+ o.selectItem(n.value);
244
+ }
245
+ function c({ focus: u = !0 } = {}) {
246
+ s(t) || o.activateItem(n.value, { focus: u });
247
+ }
248
+ return be(() => {
249
+ n.value = o.addItem(i, e, t);
250
+ }), G(() => {
251
+ o.removeItem(n.value);
252
+ }), {
253
+ isSelected: r,
254
+ isActive: f,
255
+ select: a,
256
+ activate: c
257
+ };
258
+ }
259
+ function Te(i, e = [], t = !0) {
260
+ const o = S(!1), n = S(!0), r = S(), f = S("");
261
+ let a, c;
262
+ function u() {
263
+ a == null || a.focus();
264
+ }
265
+ function m() {
266
+ n.value = a.validity.valid, r.value = a.validity, f.value = a.validationMessage;
267
+ }
268
+ function b() {
269
+ if (!a) throw new Error("Form element is undefined");
270
+ if (a.setCustomValidity(""), a.validity.valid) {
271
+ const g = a.value;
272
+ for (const k of s(e)) {
273
+ const v = k(g);
274
+ if (v !== !0) {
275
+ a.setCustomValidity(v);
276
+ break;
277
+ }
278
+ }
279
+ }
280
+ return m(), n.value;
281
+ }
282
+ function d(g) {
283
+ m(), s(t) || g.preventDefault();
284
+ }
285
+ function w() {
286
+ b(), o.value = c !== a.value;
287
+ }
288
+ let C = new AbortController();
289
+ return ae(() => {
290
+ if (a = R(i).value, !a) throw new Error("Form element is undefined");
291
+ c = a.value, a.addEventListener("change", w, {
292
+ signal: C.signal,
293
+ passive: !0
294
+ }), a.addEventListener("invalid", d, {
295
+ signal: C.signal
296
+ }), a != null && a.autofocus && u();
297
+ }), G(() => {
298
+ C.abort();
299
+ }), {
300
+ focus: u,
301
+ validate: b,
302
+ isValid: n,
303
+ validity: J(r),
304
+ validationMessage: J(f),
305
+ isChanged: o
306
+ };
307
+ }
308
+ let ke = 0;
309
+ function D(i = "id") {
310
+ return `${i}-${++ke}`;
311
+ }
312
+ const se = Symbol(), ve = Symbol(), re = Symbol(), Z = Symbol(), xe = ["aria-activedescendant", "aria-orientation", "aria-multiselectable"], Be = /* @__PURE__ */ A({
313
+ __name: "listbox",
314
+ props: /* @__PURE__ */ ie({
315
+ orientation: { default: "vertical" },
316
+ loop: { type: Boolean, default: !1 }
317
+ }, {
318
+ modelValue: {},
319
+ modelModifiers: {}
320
+ }),
321
+ emits: ["update:modelValue"],
322
+ setup(i) {
323
+ const e = i, t = W(i, "modelValue"), {
324
+ isMultiselectable: o,
325
+ activeItem: n,
326
+ selectActiveItem: r,
327
+ activateFirstItem: f,
328
+ activateLastItem: a,
329
+ activateNextItem: c,
330
+ activatePrevItem: u
331
+ } = X(t), m = E(() => {
332
+ var d, w;
333
+ return (w = (d = n.value) == null ? void 0 : d.element.value) == null ? void 0 : w.id;
334
+ });
335
+ function b(d) {
336
+ switch (d.code) {
337
+ case "Space":
338
+ r();
339
+ break;
340
+ case "ArrowUp":
341
+ if (e.orientation === "horizontal") return;
342
+ u({ focus: !1, loop: e.loop }), o.value || r();
343
+ break;
344
+ case "ArrowDown":
345
+ if (e.orientation === "horizontal") return;
346
+ c({ focus: !1, loop: e.loop }), o.value || r();
347
+ break;
348
+ case "ArrowLeft":
349
+ if (e.orientation === "vertical") return;
350
+ u({ focus: !1, loop: e.loop }), o.value || r();
351
+ break;
352
+ case "ArrowRight":
353
+ if (e.orientation === "vertical") return;
354
+ c({ focus: !1, loop: e.loop }), o.value || r();
355
+ break;
356
+ case "Home":
357
+ f({ focus: !1 });
358
+ break;
359
+ case "End":
360
+ a({ focus: !1 });
361
+ break;
362
+ default:
363
+ return;
364
+ }
365
+ d.preventDefault();
366
+ }
367
+ return (d, w) => (_(), y("div", {
368
+ onKeydown: b,
369
+ "aria-activedescendant": m.value,
370
+ "aria-orientation": d.orientation,
371
+ "aria-multiselectable": s(o),
372
+ role: "listbox",
373
+ tabindex: "0"
374
+ }, [
375
+ O(d.$slots, "default")
376
+ ], 40, xe));
377
+ }
378
+ }), $e = ["id", "aria-disabled", "aria-selected", "data-active"], Fe = /* @__PURE__ */ A({
379
+ __name: "listboxOption",
380
+ props: {
381
+ id: {},
382
+ value: {},
383
+ disabled: { type: Boolean }
384
+ },
385
+ setup(i) {
386
+ const e = i, t = e.id ?? D("list-option"), o = S(), { isSelected: n, isActive: r, select: f } = Y(
387
+ o,
388
+ e.value,
389
+ e.disabled
390
+ );
391
+ return (a, c) => (_(), y("div", {
392
+ ref_key: "itemEl",
393
+ ref: o,
394
+ id: s(t),
395
+ onClick: c[0] || (c[0] = //@ts-ignore
396
+ (...u) => s(f) && s(f)(...u)),
397
+ "aria-disabled": a.disabled,
398
+ "aria-selected": s(n),
399
+ "data-active": s(r),
400
+ role: "option",
401
+ tabindex: "-1"
402
+ }, [
403
+ O(a.$slots, "default", {
404
+ isSelected: s(n),
405
+ isActive: s(r)
406
+ })
407
+ ], 8, $e));
408
+ }
409
+ }), He = /* @__PURE__ */ A({
410
+ __name: "tabContainer",
411
+ props: {
412
+ modelValue: {},
413
+ modelModifiers: {}
414
+ },
415
+ emits: ["update:modelValue"],
416
+ setup(i) {
417
+ const e = W(i, "modelValue"), {
418
+ items: t,
419
+ selectActiveItem: o,
420
+ activateFirstItem: n,
421
+ activateLastItem: r,
422
+ activateNextItem: f,
423
+ activatePrevItem: a
424
+ } = X(e);
425
+ return U(se, {
426
+ getIds: (c) => E(() => {
427
+ var m, b;
428
+ const u = t.value.find((d) => d.value === c);
429
+ return {
430
+ tabId: ((m = u == null ? void 0 : u.element.value) == null ? void 0 : m.getAttribute("id")) || void 0,
431
+ panelId: ((b = u == null ? void 0 : u.element.value) == null ? void 0 : b.getAttribute("aria-controls")) || void 0
432
+ };
433
+ }),
434
+ selectActiveItem: o,
435
+ activateFirstItem: n,
436
+ activateLastItem: r,
437
+ activateNextItem: f,
438
+ activatePrevItem: a
439
+ }), (c, u) => (_(), y("div", null, [
440
+ O(c.$slots, "default")
441
+ ]));
442
+ }
443
+ }), Ae = ["aria-orientation"], Ke = /* @__PURE__ */ A({
444
+ __name: "tabList",
445
+ props: {
446
+ orientation: { default: "horizontal" }
447
+ },
448
+ setup(i) {
449
+ const e = i, t = B(se);
450
+ if (!t)
451
+ throw new Error("Tabs injectable context is not provided");
452
+ function o(n) {
453
+ switch (n.code) {
454
+ case "ArrowUp":
455
+ e.orientation === "vertical" && t.activatePrevItem({ focus: !0, loop: !0 });
456
+ break;
457
+ case "ArrowDown":
458
+ e.orientation === "vertical" && t.activateNextItem({ focus: !0, loop: !0 });
459
+ break;
460
+ case "ArrowLeft":
461
+ e.orientation === "horizontal" && t.activatePrevItem({ focus: !0, loop: !0 });
462
+ break;
463
+ case "ArrowRight":
464
+ e.orientation === "horizontal" && t.activateNextItem({ focus: !0, loop: !0 });
465
+ break;
466
+ case "Home":
467
+ t.activateFirstItem({ focus: !0 });
468
+ break;
469
+ case "End":
470
+ t.activateLastItem({ focus: !0 });
471
+ break;
472
+ default:
473
+ return;
474
+ }
475
+ t.selectActiveItem(), n.preventDefault();
476
+ }
477
+ return (n, r) => (_(), y("div", {
478
+ onKeydown: o,
479
+ "aria-orientation": e.orientation,
480
+ role: "tablist"
481
+ }, [
482
+ O(n.$slots, "default")
483
+ ], 40, Ae));
484
+ }
485
+ }), Ee = ["id", "aria-selected", "aria-controls", "tabindex"], Ne = /* @__PURE__ */ A({
486
+ __name: "tab",
487
+ props: {
488
+ id: {},
489
+ ariaControls: {},
490
+ value: {}
491
+ },
492
+ setup(i) {
493
+ const e = i, t = S(), { isSelected: o, select: n } = Y(t, e.value), r = e.id ?? D("tab"), f = e.ariaControls ?? D("tab-panel");
494
+ return (a, c) => (_(), y("button", {
495
+ ref_key: "tab",
496
+ ref: t,
497
+ onClick: c[0] || (c[0] = //@ts-ignore
498
+ (...u) => s(n) && s(n)(...u)),
499
+ id: s(r),
500
+ "aria-selected": s(o),
501
+ "aria-controls": s(f),
502
+ tabindex: s(o) ? 0 : -1,
503
+ role: "tab"
504
+ }, [
505
+ O(a.$slots, "default")
506
+ ], 8, Ee));
507
+ }
508
+ }), Oe = ["id", "aria-labelledby"], ze = /* @__PURE__ */ A({
509
+ __name: "tabPanel",
510
+ props: {
511
+ value: {}
512
+ },
513
+ setup(i) {
514
+ const e = i, t = B(ne);
515
+ if (!t)
516
+ throw new Error("List injectable context is not provided");
517
+ const o = B(se);
518
+ if (!o)
519
+ throw new Error("Tabs injectable context is not provided");
520
+ const n = E(() => e.value === t.value.value), r = o.getIds(e.value);
521
+ return (f, a) => n.value ? (_(), y("div", {
522
+ key: 0,
523
+ id: s(r).panelId,
524
+ "aria-labelledby": s(r).tabId,
525
+ tabindex: "0",
526
+ role: "tabpanel"
527
+ }, [
528
+ O(f.$slots, "default")
529
+ ], 8, Oe)) : N("", !0);
530
+ }
531
+ }), Re = /* @__PURE__ */ A({
532
+ __name: "popover",
533
+ props: {
534
+ id: {},
535
+ activatorId: {},
536
+ direction: { default: "down" },
537
+ align: { default: "left" },
538
+ position: { default: "fixed" },
539
+ closeOnOutsideClick: { type: Boolean, default: !0 },
540
+ closeOnInsideClick: { type: Boolean, default: !1 },
541
+ role: { default: "dialog" }
542
+ },
543
+ setup(i) {
544
+ const e = i, t = e.id ?? D("popover"), o = e.activatorId ?? D("popover-activator"), { isOpen: n, toggle: r, open: f, close: a } = Q(
545
+ `#${o}`,
546
+ `#${t}`,
547
+ {
548
+ direction: e.direction,
549
+ align: e.align,
550
+ position: e.position,
551
+ closeOnOutsideClick: e.closeOnOutsideClick,
552
+ closeOnInsideClick: e.closeOnInsideClick
553
+ }
554
+ ), c = E(() => ({
555
+ id: o,
556
+ "aria-controls": n.value ? e.id : void 0,
557
+ "aria-haspopup": e.role,
558
+ "aria-expanded": n.value
559
+ }));
560
+ return U(ve, {
561
+ popoverId: t,
562
+ activatorId: o,
563
+ role: e.role,
564
+ isOpen: n,
565
+ close: a
566
+ }), (u, m) => O(u.$slots, "default", {
567
+ attrs: c.value,
568
+ isOpen: s(n),
569
+ toggle: s(r),
570
+ open: s(f),
571
+ close: s(a)
572
+ });
573
+ }
574
+ }), Ce = ["id", "role", "aria-labelledby"], Ue = /* @__PURE__ */ A({
575
+ __name: "popoverDialog",
576
+ setup(i) {
577
+ const e = B(ve);
578
+ if (!e)
579
+ throw new Error("Popover injectable context is not provided");
580
+ function t(o) {
581
+ switch (o.code) {
582
+ case "Escape":
583
+ e.close();
584
+ break;
585
+ default:
586
+ return;
587
+ }
588
+ o.preventDefault();
589
+ }
590
+ return (o, n) => s(e).isOpen.value ? (_(), y("div", {
591
+ key: 0,
592
+ onKeydown: t,
593
+ id: s(e).popoverId,
594
+ role: s(e).role,
595
+ "aria-labelledby": s(e).activatorId,
596
+ tabindex: "-1"
597
+ }, [
598
+ O(o.$slots, "default")
599
+ ], 40, Ce)) : N("", !0);
600
+ }
601
+ }), Se = ["id"], We = /* @__PURE__ */ A({
602
+ inheritAttrs: !1,
603
+ __name: "tooltip",
604
+ props: {
605
+ id: {},
606
+ text: {},
607
+ delay: {},
608
+ direction: { default: "up" }
609
+ },
610
+ setup(i) {
611
+ const e = i, t = Ie(), o = S();
612
+ let n;
613
+ const r = e.id ?? D("tooltip"), { isOpen: f } = Q(`[aria-describedby=${r}]`, o, {
614
+ direction: e.direction,
615
+ align: "center"
616
+ });
617
+ function a() {
618
+ n = setTimeout(
619
+ () => {
620
+ f.value = !0;
621
+ },
622
+ typeof e.delay == "string" ? parseInt(e.delay) : e.delay
623
+ );
624
+ }
625
+ function c() {
626
+ f.value = !1, clearTimeout(n);
627
+ }
628
+ function u(d) {
629
+ d.key === "Escape" && c();
630
+ }
631
+ const m = {
632
+ "aria-describedby": r,
633
+ onmouseenter: a,
634
+ onmouseleave: c,
635
+ onfocus: a,
636
+ onblur: c,
637
+ onkeydown: u
638
+ }, b = new AbortController();
639
+ return ae(() => {
640
+ if (t.default) return;
641
+ const d = document.querySelector(
642
+ `[aria-describedby=${r}]`
643
+ );
644
+ if (!d)
645
+ throw new Error(`Tooltip activator not found: ${r}`);
646
+ d.addEventListener("mouseenter", a, {
647
+ signal: b.signal,
648
+ passive: !0
649
+ }), d.addEventListener("mouseleave", c, {
650
+ signal: b.signal,
651
+ passive: !0
652
+ }), d.addEventListener("focus", a, {
653
+ signal: b.signal,
654
+ passive: !0
655
+ }), d.addEventListener("blur", c, {
656
+ signal: b.signal,
657
+ passive: !0
658
+ }), d.addEventListener("keydown", u, {
659
+ signal: b.signal,
660
+ passive: !0
661
+ });
662
+ }), G(() => {
663
+ b.abort();
664
+ }), (d, w) => (_(), y(z, null, [
665
+ O(d.$slots, "default", { attrs: m }),
666
+ (_(), te(we, { to: "body" }, [
667
+ s(f) ? (_(), y("div", de({
668
+ key: 0,
669
+ ref_key: "popupEl",
670
+ ref: o,
671
+ id: s(r)
672
+ }, d.$attrs, { role: "tooltip" }), [
673
+ O(d.$slots, "content", {}, () => [
674
+ he(_e(d.text), 1)
675
+ ])
676
+ ], 16, Se)) : N("", !0)
677
+ ]))
678
+ ], 64));
679
+ }
680
+ }), qe = /* @__PURE__ */ A({
681
+ __name: "menu",
682
+ props: /* @__PURE__ */ ie({
683
+ id: {},
684
+ activatorId: {},
685
+ direction: { default: "down" },
686
+ align: { default: "left" },
687
+ position: { default: "fixed" }
688
+ }, {
689
+ modelValue: {},
690
+ modelModifiers: {}
691
+ }),
692
+ emits: ["update:modelValue"],
693
+ setup(i) {
694
+ const e = i, t = e.id ?? D("menu"), o = e.activatorId ?? D("menu-activator"), n = W(i, "modelValue"), {
695
+ isMultiselectable: r,
696
+ activeItem: f,
697
+ activateFirstItem: a,
698
+ activateLastItem: c,
699
+ activateNextItem: u,
700
+ activatePrevItem: m
701
+ } = X(n), { isOpen: b, toggle: d, open: w, close: C } = Q(
702
+ `#${o}`,
703
+ `#${t}`,
704
+ {
705
+ direction: e.direction,
706
+ align: e.align,
707
+ position: e.position,
708
+ closeOnOutsideClick: !0,
709
+ closeOnInsideClick: !1
710
+ }
711
+ );
712
+ function g(v) {
713
+ switch (v.code) {
714
+ case "Space":
715
+ case "Enter":
716
+ d(), b.value && H(a);
717
+ break;
718
+ case "ArrowUp":
719
+ w(), H(c);
720
+ break;
721
+ case "ArrowDown":
722
+ w(), H(a);
723
+ break;
724
+ default:
725
+ return;
726
+ }
727
+ v.preventDefault();
728
+ }
729
+ const k = E(() => ({
730
+ id: o,
731
+ "aria-controls": b.value ? t : void 0,
732
+ "aria-haspopup": "menu",
733
+ "aria-expanded": b.value,
734
+ onclick: d,
735
+ onkeydown: g,
736
+ tabindex: 0
737
+ }));
738
+ return U(re, {
739
+ menuId: t,
740
+ activatorId: o,
741
+ isOpen: b,
742
+ close: C,
743
+ isMultiselectable: r,
744
+ activeItemId: E(() => {
745
+ var v, $;
746
+ return ($ = (v = f.value) == null ? void 0 : v.element.value) == null ? void 0 : $.id;
747
+ }),
748
+ activateFirstItem: a,
749
+ activateLastItem: c,
750
+ activateNextItem: u,
751
+ activatePrevItem: m
752
+ }), (v, $) => O(v.$slots, "default", { attrs: k.value });
753
+ }
754
+ }), Ve = ["id", "aria-activedescendant", "aria-labelledby"], Je = /* @__PURE__ */ A({
755
+ __name: "menuItems",
756
+ setup(i) {
757
+ const e = B(re);
758
+ if (!e)
759
+ throw new Error("Menu injectable context is not provided");
760
+ function t(o) {
761
+ switch (o.code) {
762
+ case "ArrowUp":
763
+ e.activatePrevItem({ focus: !0, loop: !1 });
764
+ break;
765
+ case "ArrowDown":
766
+ e.activateNextItem({ focus: !0, loop: !1 });
767
+ break;
768
+ case "Home":
769
+ e.activateFirstItem({ focus: !0 });
770
+ break;
771
+ case "End":
772
+ e.activateLastItem({ focus: !0 });
773
+ break;
774
+ case "Escape":
775
+ e.close();
776
+ break;
777
+ case "Tab":
778
+ e.isOpen.value = !1;
779
+ return;
780
+ default:
781
+ return;
782
+ }
783
+ o.preventDefault();
784
+ }
785
+ return (o, n) => s(e).isOpen.value ? (_(), y("div", {
786
+ key: 0,
787
+ onKeydown: t,
788
+ id: s(e).menuId,
789
+ "aria-activedescendant": s(e).activeItemId.value,
790
+ "aria-labelledby": s(e).activatorId,
791
+ role: "menu",
792
+ tabindex: "-1"
793
+ }, [
794
+ O(o.$slots, "default")
795
+ ], 40, Ve)) : N("", !0);
796
+ }
797
+ }), Le = ["id", "data-active", "role", "aria-checked", "aria-disabled"], Ge = /* @__PURE__ */ A({
798
+ __name: "menuItem",
799
+ props: {
800
+ id: {},
801
+ value: {},
802
+ disabled: { type: Boolean }
803
+ },
804
+ emits: ["select"],
805
+ setup(i, { emit: e }) {
806
+ const t = i, o = e, n = t.id ?? D("menu-item"), r = S(), { isSelected: f, isActive: a, select: c, activate: u } = Y(
807
+ r,
808
+ t.value,
809
+ t.disabled
810
+ ), m = B(re);
811
+ if (!m)
812
+ throw new Error("Menu injectable context is not provided");
813
+ const b = E(() => t.value !== void 0 ? m.isMultiselectable.value ? "menuitemcheckbox" : "menuitemradio" : "menuitem");
814
+ function d() {
815
+ c(), o("select", t.value);
816
+ }
817
+ function w() {
818
+ d(), (t.value === void 0 || !(m != null && m.isMultiselectable.value)) && m.close();
819
+ }
820
+ function C(g) {
821
+ switch (g.code) {
822
+ case "Space":
823
+ d(), t.value === void 0 && m.close();
824
+ break;
825
+ case "Enter":
826
+ d(), m.close();
827
+ break;
828
+ default:
829
+ return;
830
+ }
831
+ g.preventDefault();
832
+ }
833
+ return (g, k) => (_(), y("div", {
834
+ ref_key: "itemEl",
835
+ ref: r,
836
+ id: s(n),
837
+ onClick: w,
838
+ onKeydown: C,
839
+ onMouseenter: k[0] || (k[0] = (v) => s(u)({ focus: !1 })),
840
+ "data-active": s(a),
841
+ role: b.value,
842
+ "aria-checked": g.value !== void 0 ? s(f) : void 0,
843
+ "aria-disabled": g.disabled || void 0,
844
+ tabindex: "-1"
845
+ }, [
846
+ O(g.$slots, "default", {
847
+ isSelected: s(f),
848
+ isActive: s(a)
849
+ })
850
+ ], 40, Le));
851
+ }
852
+ }), Me = ["name", "value"], ue = /* @__PURE__ */ A({
853
+ __name: "comboboxHiddenInput",
854
+ props: {
855
+ name: {},
856
+ value: {}
857
+ },
858
+ setup(i) {
859
+ const e = i, t = E(() => {
860
+ if (typeof e.value == "object") {
861
+ const o = {};
862
+ for (const [n, r] of Object.entries(e.value))
863
+ o[`${e.name}[${n}]`] = r;
864
+ return o;
865
+ } else
866
+ return {
867
+ [e.name]: e.value
868
+ };
869
+ });
870
+ return (o, n) => (_(!0), y(z, null, fe(t.value, (r, f) => (_(), y("input", {
871
+ name: f,
872
+ value: r,
873
+ type: "hidden"
874
+ }, null, 8, Me))), 256));
875
+ }
876
+ }), Qe = /* @__PURE__ */ A({
877
+ inheritAttrs: !1,
878
+ __name: "combobox",
879
+ props: /* @__PURE__ */ ie({
880
+ displayValue: { type: Function, default: (i) => Array.isArray(i) ? i.map((e) => e.toString()).join(", ") : i.toString() },
881
+ id: {},
882
+ activatorId: {},
883
+ name: {},
884
+ formValue: { type: Function, default: (i) => i }
885
+ }, {
886
+ modelValue: {},
887
+ modelModifiers: {}
888
+ }),
889
+ emits: ["update:modelValue"],
890
+ setup(i) {
891
+ const e = i, t = E(() => w.value ? o.value.map((I) => e.formValue(I)) : e.formValue(o.value)), o = W(i, "modelValue"), n = e.id ?? D("combobox"), r = e.activatorId ?? n, f = `${n}-popover`, { isOpen: a, toggle: c, open: u, close: m } = Q(
892
+ `#${r}`,
893
+ `#${f}`,
894
+ {
895
+ direction: "down",
896
+ align: "stretch",
897
+ position: "fixed",
898
+ closeOnOutsideClick: !0,
899
+ closeOnInsideClick: !1
900
+ }
901
+ ), {
902
+ items: b,
903
+ activeItem: d,
904
+ isMultiselectable: w,
905
+ selectActiveItem: C,
906
+ activateSelectedItem: g,
907
+ activateFirstItem: k,
908
+ activateLastItem: v,
909
+ activateNextItem: $,
910
+ activatePrevItem: j
911
+ } = X(o), l = E(() => e.displayValue(o.value));
912
+ oe(b, () => {
913
+ !d.value && b.value.length && (g({ focus: !1 }), d.value || k({ focus: !1 }));
914
+ });
915
+ function p() {
916
+ var L;
917
+ (L = R(`#${r}`).value) == null || L.focus();
918
+ }
919
+ function h(I) {
920
+ if (a.value)
921
+ switch (I.code) {
922
+ case "Space":
923
+ C(), w.value || m({ focus: !0 });
924
+ break;
925
+ case "Enter":
926
+ C(), m({ focus: !0 });
927
+ break;
928
+ case "Tab":
929
+ C(), m({ focus: !0 });
930
+ return;
931
+ case "ArrowUp":
932
+ j({ focus: !1, loop: !1 });
933
+ break;
934
+ case "ArrowDown":
935
+ $({ focus: !1, loop: !1 });
936
+ break;
937
+ case "Home":
938
+ k({ focus: !1 });
939
+ break;
940
+ case "End":
941
+ v({ focus: !1 });
942
+ break;
943
+ case "Escape":
944
+ m({ focus: !0 });
945
+ break;
946
+ default:
947
+ return;
948
+ }
949
+ else
950
+ switch (I.code) {
951
+ case "Space":
952
+ case "Enter":
953
+ u({ focus: !1 });
954
+ break;
955
+ case "End":
956
+ case "ArrowUp":
957
+ u({ focus: !1 }), H(() => v({ focus: !1 }));
958
+ break;
959
+ case "Home":
960
+ case "ArrowDown":
961
+ u({ focus: !1 }), H(() => k({ focus: !1 }));
962
+ break;
963
+ default:
964
+ return;
965
+ }
966
+ I.preventDefault();
967
+ }
968
+ const x = E(() => {
969
+ var I, L;
970
+ return {
971
+ onkeydown: h,
972
+ onclick: () => u({ focus: !1 }),
973
+ id: n,
974
+ "aria-controls": a.value ? f : void 0,
975
+ "aria-expanded": a.value,
976
+ "aria-activedescendant": (L = (I = d.value) == null ? void 0 : I.element.value) == null ? void 0 : L.id,
977
+ "aria-haspopup": "listbox",
978
+ role: "combobox"
979
+ };
980
+ });
981
+ return U(Z, {
982
+ displayValue: l,
983
+ popoverId: f,
984
+ isOpen: a,
985
+ open: u,
986
+ close: m,
987
+ focus: p,
988
+ isMultiselectable: w,
989
+ activatorAttrs: x
990
+ }), (I, L) => (_(), y(z, null, [
991
+ I.name ? (_(), y(z, { key: 0 }, [
992
+ s(w) ? (_(!0), y(z, { key: 0 }, fe(t.value, (F, K) => (_(), te(ue, {
993
+ name: `${I.name}[${K}]`,
994
+ value: F
995
+ }, null, 8, ["name", "value"]))), 256)) : (_(), te(ue, {
996
+ key: 1,
997
+ name: I.name,
998
+ value: t.value
999
+ }, null, 8, ["name", "value"]))
1000
+ ], 64)) : N("", !0),
1001
+ O(I.$slots, "default", {
1002
+ popoverId: f,
1003
+ isOpen: s(a),
1004
+ toggle: s(c),
1005
+ displayValue: l.value,
1006
+ attrs: x.value
1007
+ })
1008
+ ], 64));
1009
+ }
1010
+ }), Xe = /* @__PURE__ */ A({
1011
+ __name: "comboboxInput",
1012
+ props: {
1013
+ modelValue: {},
1014
+ modelModifiers: {}
1015
+ },
1016
+ emits: ["update:modelValue"],
1017
+ setup(i) {
1018
+ const e = B(Z);
1019
+ if (!e)
1020
+ throw new Error("Combobox injectable context is not provided");
1021
+ const t = W(i, "modelValue");
1022
+ function o() {
1023
+ t.value = e.displayValue.value;
1024
+ }
1025
+ oe(e.displayValue, o, { immediate: !0 });
1026
+ const n = E(() => ({
1027
+ oninput: () => e.open({ focus: !0 }),
1028
+ onchange: o,
1029
+ ...e.activatorAttrs.value
1030
+ }));
1031
+ return (r, f) => ge((_(), y("input", de({
1032
+ "onUpdate:modelValue": f[0] || (f[0] = (a) => t.value = a)
1033
+ }, n.value, { autocomplete: "off" }), null, 16)), [
1034
+ [ye, t.value]
1035
+ ]);
1036
+ }
1037
+ }), De = ["id"], Ye = /* @__PURE__ */ A({
1038
+ __name: "comboboxOptions",
1039
+ setup(i) {
1040
+ const e = B(Z);
1041
+ if (!e)
1042
+ throw new Error("Combobox injectable context is not provided");
1043
+ return (t, o) => s(e).isOpen.value ? (_(), y("div", {
1044
+ key: 0,
1045
+ id: s(e).popoverId,
1046
+ role: "listbox"
1047
+ }, [
1048
+ O(t.$slots, "default")
1049
+ ], 8, De)) : N("", !0);
1050
+ }
1051
+ }), je = ["id", "data-active", "aria-selected", "aria-disabled"], Ze = /* @__PURE__ */ A({
1052
+ __name: "comboboxOption",
1053
+ props: {
1054
+ id: {},
1055
+ value: {},
1056
+ disabled: { type: Boolean }
1057
+ },
1058
+ setup(i) {
1059
+ const e = i, t = e.id ?? D("combobox-option"), o = S(), { isSelected: n, isActive: r, activate: f, select: a } = Y(
1060
+ o,
1061
+ e.value,
1062
+ e.disabled
1063
+ ), c = B(Z);
1064
+ if (!c)
1065
+ throw new Error("Combobox injectable context is not provided");
1066
+ function u() {
1067
+ a(), c.isMultiselectable.value ? c.focus() : c.close({ focus: !0 });
1068
+ }
1069
+ return (m, b) => (_(), y("div", {
1070
+ ref_key: "itemEl",
1071
+ ref: o,
1072
+ id: s(t),
1073
+ onClick: u,
1074
+ onMouseenter: b[0] || (b[0] = (d) => s(f)({ focus: !1 })),
1075
+ "data-active": s(r),
1076
+ "aria-selected": s(n),
1077
+ "aria-disabled": m.disabled || void 0,
1078
+ role: "option"
1079
+ }, [
1080
+ O(m.$slots, "default", {
1081
+ isSelected: s(n),
1082
+ isActive: s(r)
1083
+ })
1084
+ ], 40, je));
1085
+ }
1086
+ });
1087
+ export {
1088
+ Qe as Combobox,
1089
+ Xe as ComboboxInput,
1090
+ Ze as ComboboxOption,
1091
+ Ye as ComboboxOptions,
1092
+ Be as Listbox,
1093
+ Fe as ListboxOption,
1094
+ qe as Menu,
1095
+ Ge as MenuItem,
1096
+ Je as MenuItems,
1097
+ Re as Popover,
1098
+ Ue as PopoverDialog,
1099
+ Ne as Tab,
1100
+ He as TabContainer,
1101
+ Ke as TabList,
1102
+ ze as TabPanel,
1103
+ We as Tooltip,
1104
+ Z as injectCombobox,
1105
+ re as injectMenu,
1106
+ ve as injectPopover,
1107
+ se as injectTabs,
1108
+ Te as useFormControl,
1109
+ R as useHTMLElement,
1110
+ X as useList,
1111
+ Y as useListOption,
1112
+ Q as usePopover,
1113
+ D as useSequentialId
1114
+ };