vue-composable-ui 1.2.0 → 1.3.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.
Files changed (39) hide show
  1. package/dist/combobox.vue_vue_type_script_setup_true_lang-CFyb8irG.js +144 -0
  2. package/dist/comboboxOptions.vue_vue_type_script_setup_true_lang-DZuDsRZX.js +21 -0
  3. package/dist/composable-ui.js +27 -27
  4. package/dist/composable-ui11.js +1 -1
  5. package/dist/composable-ui12.js +1 -1
  6. package/dist/composable-ui13.js +1 -1
  7. package/dist/composable-ui15.js +1 -1
  8. package/dist/composable-ui18.js +1 -1
  9. package/dist/composable-ui2.js +1 -1
  10. package/dist/composable-ui20.js +17 -18
  11. package/dist/composable-ui22.js +117 -105
  12. package/dist/composable-ui23.js +65 -89
  13. package/dist/composable-ui24.js +7 -4
  14. package/dist/composable-ui6.js +1 -1
  15. package/dist/composable-ui9.js +1 -1
  16. package/dist/menu.vue_vue_type_script_setup_true_lang-CXMH_Siw.js +82 -0
  17. package/dist/{menuItems.vue_vue_type_script_setup_true_lang-DQV-lU_A.js → menuItems.vue_vue_type_script_setup_true_lang-C7feROa2.js} +10 -9
  18. package/dist/popover.vue_vue_type_script_setup_true_lang-2uGxM2x-.js +64 -0
  19. package/dist/{popoverDialog.vue_vue_type_script_setup_true_lang-BbR_2G3W.js → popoverDialog.vue_vue_type_script_setup_true_lang-C_cJy27S.js} +5 -4
  20. package/dist/tabContainer.vue_vue_type_script_setup_true_lang-B65gXNdp.js +42 -0
  21. package/dist/tooltip.vue_vue_type_script_setup_true_lang-DX78jdaW.js +81 -0
  22. package/dist/types/components/combobox/combobox.vue.d.ts +9 -1
  23. package/dist/types/components/injectionKeys.d.ts +19 -1
  24. package/dist/types/components/menu/menu.vue.d.ts +2 -0
  25. package/dist/types/components/popover/popover.vue.d.ts +4 -2
  26. package/dist/types/components/tooltip.vue.d.ts +2 -0
  27. package/dist/types/composables/formControl.d.ts +3 -4
  28. package/dist/types/composables/list.d.ts +8 -4
  29. package/dist/types/composables/listOption.d.ts +3 -4
  30. package/dist/types/composables/popover.d.ts +4 -5
  31. package/dist/types/main.d.ts +1 -1
  32. package/dist/types/utils/element.d.ts +10 -3
  33. package/package.json +1 -1
  34. package/dist/combobox.vue_vue_type_script_setup_true_lang-sMngTuXu.js +0 -139
  35. package/dist/comboboxOptions.vue_vue_type_script_setup_true_lang-DN0tz5dv.js +0 -20
  36. package/dist/menu.vue_vue_type_script_setup_true_lang-B0Jm9v_v.js +0 -82
  37. package/dist/popover.vue_vue_type_script_setup_true_lang-BEMQwnTq.js +0 -64
  38. package/dist/tabContainer.vue_vue_type_script_setup_true_lang-yqy32Zx5.js +0 -40
  39. package/dist/tooltip.vue_vue_type_script_setup_true_lang-BSjMpNzD.js +0 -78
@@ -1,3 +1,4 @@
1
+ import { type ComponentPublicInstance } from "vue";
1
2
  type __VLS_Props = {
2
3
  id?: string;
3
4
  activatorId?: string;
@@ -18,9 +19,10 @@ type __VLS_ModelProps = {
18
19
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
19
20
  declare var __VLS_1: {
20
21
  attrs: {
22
+ ref: import("vue").ShallowRef<HTMLElement | ComponentPublicInstance | null, HTMLElement | ComponentPublicInstance | null>;
21
23
  id: string;
22
24
  "aria-controls": string | undefined;
23
- "aria-haspopup": "dialog" | "menu" | "listbox" | "tree" | "grid" | undefined;
25
+ "aria-haspopup": "dialog" | "listbox" | "menu" | "tree" | "grid" | undefined;
24
26
  "aria-expanded": boolean;
25
27
  };
26
28
  isOpen: boolean;
@@ -36,12 +38,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
36
38
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
37
39
  "onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
38
40
  }>, {
39
- role: "dialog" | "listbox" | "menu" | "tree" | "grid" | "none";
40
41
  direction: "up" | "down" | "left" | "right";
41
42
  align: "top" | "bottom" | "left" | "right" | "center" | "stretch";
42
43
  position: "fixed" | "absolute";
43
44
  closeOnOutsideClick: boolean;
44
45
  closeOnInsideClick: boolean;
46
+ role: "dialog" | "listbox" | "menu" | "tree" | "grid" | "none";
45
47
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
46
48
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
47
49
  declare const _default: typeof __VLS_export;
@@ -1,3 +1,4 @@
1
+ import { type ComponentPublicInstance } from "vue";
1
2
  type __VLS_Props = {
2
3
  id?: string;
3
4
  text?: string;
@@ -8,6 +9,7 @@ declare function open(): void;
8
9
  declare function close(): void;
9
10
  declare var __VLS_1: {
10
11
  attrs: {
12
+ ref: import("vue").ShallowRef<HTMLElement | ComponentPublicInstance | null, HTMLElement | ComponentPublicInstance | null>;
11
13
  "aria-describedby": string;
12
14
  onmouseenter: typeof open;
13
15
  onmouseleave: typeof close;
@@ -1,5 +1,4 @@
1
- import type { MaybeRef, Ref } from "vue";
2
- import type { TemplateRefOrSelector } from "../utils/element";
1
+ import type { MaybeRef, Ref, TemplateRef } from "vue";
3
2
  type FormElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
4
3
  /**
5
4
  * A validating function must return `true` or a string describing the error
@@ -38,11 +37,11 @@ export interface useFormControlReturn {
38
37
  /**
39
38
  * Utilizes Constraint Validation API to enable custom validation constrains for a form control
40
39
  *
41
- * @param el A template ref or a CSS selector
40
+ * @param el A template ref pointing at the form control
42
41
  * @param validators An array of validating functions
43
42
  * @param showValidationError Whether to show the default browser validation error (true by default)
44
43
  *
45
44
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation}
46
45
  */
47
- export declare function useFormControl(el: TemplateRefOrSelector<FormElement>, validators?: MaybeRef<FormValidator[]>, showValidationError?: MaybeRef<boolean>): useFormControlReturn;
46
+ export declare function useFormControl(el: TemplateRef<FormElement>, validators?: MaybeRef<FormValidator[]>, showValidationError?: MaybeRef<boolean>): useFormControlReturn;
48
47
  export {};
@@ -1,9 +1,9 @@
1
- import type { ComputedRef, MaybeRef, Ref, ShallowRef, InjectionKey } from "vue";
2
- import { TemplateRefOrSelector } from "../utils/element";
1
+ import type { ComponentPublicInstance, ComputedRef, MaybeRef, Ref, ShallowRef, InjectionKey, TemplateRef } from "vue";
3
2
  export type ItemValue = unknown;
4
3
  export interface Item {
5
4
  id: number;
6
- element: Ref<HTMLElement | null>;
5
+ /** The registered element, resolved from the template ref it was added with. */
6
+ element: ComputedRef<HTMLElement | null>;
7
7
  value: ItemValue;
8
8
  disabled: MaybeRef<boolean>;
9
9
  }
@@ -36,6 +36,10 @@ export interface UseListReturn {
36
36
  * Currently active item
37
37
  */
38
38
  activeItem: ComputedRef<Item | undefined>;
39
+ /**
40
+ * The first selected item, of which a multiselectable list may have several
41
+ */
42
+ selectedItem: ComputedRef<Item | undefined>;
39
43
  /**
40
44
  * Select the currently active item
41
45
  */
@@ -91,7 +95,7 @@ interface UseListInjectionKey {
91
95
  *
92
96
  * @returns New item ID
93
97
  */
94
- addItem: (itemEl: TemplateRefOrSelector, itemVal: ItemValue, disabled?: MaybeRef<boolean>) => number;
98
+ addItem: (itemEl: TemplateRef<HTMLElement | ComponentPublicInstance>, itemVal: ItemValue, disabled?: MaybeRef<boolean>) => number;
95
99
  /**
96
100
  * Remove an item from the list by ID
97
101
  */
@@ -1,5 +1,4 @@
1
- import type { ComputedRef, MaybeRef } from "vue";
2
- import type { TemplateRefOrSelector } from "../utils/element";
1
+ import type { ComponentPublicInstance, ComputedRef, MaybeRef, TemplateRef } from "vue";
3
2
  import type { ItemValue, ActivationOptions } from "./list";
4
3
  interface UseListOptionReturn {
5
4
  /**
@@ -26,9 +25,9 @@ interface UseListOptionReturn {
26
25
  /**
27
26
  * Registers an HTML element and an associated value in the list created in the parent component
28
27
  *
29
- * @param el A template ref or a CSS selector
28
+ * @param el A template ref pointing at the element to register
30
29
  * @param value A value of any type
31
30
  * @param disabled Whether the item is disabled (false by default)
32
31
  */
33
- export declare function useListOption(el: TemplateRefOrSelector, value: ItemValue, disabled?: MaybeRef<boolean>): UseListOptionReturn;
32
+ export declare function useListOption(el: TemplateRef<HTMLElement | ComponentPublicInstance>, value: ItemValue, disabled?: MaybeRef<boolean>): UseListOptionReturn;
34
33
  export {};
@@ -1,5 +1,4 @@
1
- import type { Ref } from "vue";
2
- import { TemplateRefOrSelector } from "../utils/element";
1
+ import type { ComponentPublicInstance, Ref, TemplateRef } from "vue";
3
2
  interface UsePopoverOptions {
4
3
  /**
5
4
  * The direction of the popover dialog
@@ -69,9 +68,9 @@ export interface UsePopoverReturn {
69
68
  }
70
69
  /**
71
70
  *
72
- * @param activatorEl A template ref or a CSS selector
73
- * @param popupEl A template ref or a CSS selector
71
+ * @param activatorEl A template ref pointing at the activator element
72
+ * @param popupEl A template ref pointing at the popover element
74
73
  * @param options Popover options
75
74
  */
76
- export declare function usePopover(activatorEl: TemplateRefOrSelector, popupEl: TemplateRefOrSelector, { direction, align, position, closeOnOutsideClick, closeOnInsideClick, }?: UsePopoverOptions): UsePopoverReturn;
75
+ export declare function usePopover(activatorEl: TemplateRef<HTMLElement | ComponentPublicInstance>, popupEl: TemplateRef<HTMLElement | ComponentPublicInstance>, { direction, align, position, closeOnOutsideClick, closeOnInsideClick, }?: UsePopoverOptions): UsePopoverReturn;
77
76
  export {};
@@ -2,7 +2,7 @@ export { usePopover, type PopoverFocusOptions } from "./composables/popover";
2
2
  export { useList } from "./composables/list";
3
3
  export { useListOption } from "./composables/listOption";
4
4
  export { useFormControl } from "./composables/formControl";
5
- export { useHTMLElement } from "./utils/element";
5
+ export { toElement } from "./utils/element";
6
6
  export { useValidation, type Validator } from "./utils/validation";
7
7
  export * from "./components/injectionKeys";
8
8
  export { default as Listbox } from "./components/listbox/listbox.vue";
@@ -1,3 +1,10 @@
1
- import type { Ref } from "vue";
2
- export type TemplateRefOrSelector<E extends HTMLElement = HTMLElement> = Ref<E | null> | E | string;
3
- export declare function useHTMLElement<E extends HTMLElement = HTMLElement>(el: TemplateRefOrSelector<E>): Ref<E | null, E | null> | ([E | null] extends [Ref<any, any>] ? import("@vue/shared").IfAny<Ref<any, any> & E, Ref<Ref<any, any> & E, Ref<any, any> & E>, Ref<any, any> & E> : Ref<import("vue").UnwrapRef<E> | null, E | import("vue").UnwrapRef<E> | null>);
1
+ import type { ComponentPublicInstance, TemplateRef } from "vue";
2
+ /**
3
+ * Resolve a template ref to its element, or `null` when there is none yet.
4
+ *
5
+ * `unref` stops one step short: a ref placed on a component holds the
6
+ * instance, not an element, so single-root components are unwrapped through
7
+ * `$el` — that is what lets an activator be a `<Btn v-bind="attrs">` as
8
+ * readily as a `<button>`.
9
+ */
10
+ export declare function toElement<E extends HTMLElement = HTMLElement>(el: TemplateRef<E | ComponentPublicInstance>): E | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-composable-ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,139 +0,0 @@
1
- import { defineComponent as B, computed as p, useModel as H, useId as T, watch as j, provide as K, openBlock as r, createElementBlock as v, Fragment as b, unref as k, renderList as N, createBlock as A, createCommentVNode as P, renderSlot as U, mergeModels as _, nextTick as h } from "vue";
2
- import { useHTMLElement as q } from "./composable-ui24.js";
3
- import { usePopover as z } from "./composable-ui23.js";
4
- import { useList as G } from "./composable-ui22.js";
5
- import { _ as $ } from "./comboboxHiddenInput.vue_vue_type_script_setup_true_lang-BtODyQnH.js";
6
- import { injectCombobox as J } from "./composable-ui19.js";
7
- const ae = /* @__PURE__ */ B({
8
- inheritAttrs: !1,
9
- __name: "combobox",
10
- props: /* @__PURE__ */ _({
11
- displayValue: { type: Function, default: (e) => Array.isArray(e) ? e.map((t) => t.toString()).join(", ") : e?.toString() },
12
- id: {},
13
- activatorId: {},
14
- name: {},
15
- formValue: { type: Function, default: (e) => e }
16
- }, {
17
- modelValue: {},
18
- modelModifiers: {}
19
- }),
20
- emits: ["update:modelValue"],
21
- setup(e) {
22
- const t = e, I = p(() => u.value ? c.value.map((a) => t.formValue(a)) : t.formValue(c.value)), c = H(e, "modelValue"), i = t.id ?? T(), y = t.activatorId ?? i, l = `${i}-popover`, { isOpen: o, toggle: E, open: n, close: s } = z(
23
- `#${y}`,
24
- `#${l}`,
25
- {
26
- direction: "down",
27
- align: "stretch",
28
- position: "fixed",
29
- closeOnOutsideClick: !0,
30
- closeOnInsideClick: !1
31
- }
32
- ), {
33
- items: w,
34
- activeItem: f,
35
- isMultiselectable: u,
36
- selectActiveItem: m,
37
- activateSelectedItem: O,
38
- activateFirstItem: d,
39
- activateLastItem: V,
40
- activateNextItem: S,
41
- activatePrevItem: C
42
- } = G(c), g = p(() => t.displayValue(c.value));
43
- j(w, () => {
44
- !f.value && w.value.length && (O({ focus: !1 }), f.value || d({ focus: !1 }));
45
- });
46
- function D() {
47
- q(`#${y}`).value?.focus();
48
- }
49
- function M(a) {
50
- if (o.value)
51
- switch (a.code) {
52
- case "Space":
53
- m(), u.value || s({ focus: !0 });
54
- break;
55
- case "Enter":
56
- m(), s({ focus: !0 });
57
- break;
58
- case "Tab":
59
- m(), s({ focus: !0 });
60
- return;
61
- case "ArrowUp":
62
- C({ focus: !1, loop: !1 });
63
- break;
64
- case "ArrowDown":
65
- S({ focus: !1, loop: !1 });
66
- break;
67
- case "Home":
68
- d({ focus: !1 });
69
- break;
70
- case "End":
71
- V({ focus: !1 });
72
- break;
73
- case "Escape":
74
- s({ focus: !0 });
75
- break;
76
- default:
77
- return;
78
- }
79
- else
80
- switch (a.code) {
81
- case "Space":
82
- case "Enter":
83
- n({ focus: !1 });
84
- break;
85
- case "End":
86
- case "ArrowUp":
87
- n({ focus: !1 }), h(() => V({ focus: !1 }));
88
- break;
89
- case "Home":
90
- case "ArrowDown":
91
- n({ focus: !1 }), h(() => d({ focus: !1 }));
92
- break;
93
- default:
94
- return;
95
- }
96
- a.preventDefault();
97
- }
98
- const x = p(() => ({
99
- id: i,
100
- "aria-controls": o.value ? l : void 0,
101
- "aria-expanded": o.value,
102
- "aria-activedescendant": f.value?.element.value?.id,
103
- "aria-haspopup": "listbox",
104
- role: "combobox"
105
- }));
106
- return K(J, {
107
- displayValue: g,
108
- popoverId: l,
109
- isOpen: o,
110
- open: n,
111
- close: s,
112
- focus: D,
113
- isMultiselectable: u,
114
- activatorAttrs: x,
115
- activatorOnKeyDown: M
116
- }), (a, Q) => (r(), v(b, null, [
117
- e.name ? (r(), v(b, { key: 0 }, [
118
- k(u) ? (r(!0), v(b, { key: 0 }, N(I.value, (F, L) => (r(), A($, {
119
- name: `${e.name}[${L}]`,
120
- value: F
121
- }, null, 8, ["name", "value"]))), 256)) : (r(), A($, {
122
- key: 1,
123
- name: e.name,
124
- value: I.value
125
- }, null, 8, ["name", "value"]))
126
- ], 64)) : P("", !0),
127
- U(a.$slots, "default", {
128
- popoverId: l,
129
- isOpen: k(o),
130
- toggle: () => k(E)(),
131
- displayValue: g.value,
132
- attrs: x.value
133
- })
134
- ], 64));
135
- }
136
- });
137
- export {
138
- ae as _
139
- };
@@ -1,20 +0,0 @@
1
- import { defineComponent as n, inject as r, unref as e, openBlock as i, createElementBlock as c, renderSlot as m, createCommentVNode as s } from "vue";
2
- import { injectCombobox as p } from "./composable-ui19.js";
3
- const d = ["id"], f = /* @__PURE__ */ n({
4
- __name: "comboboxOptions",
5
- setup(b) {
6
- const o = r(p);
7
- if (!o)
8
- throw new Error("Combobox injectable context is not provided");
9
- return (t, l) => e(o).isOpen.value ? (i(), c("div", {
10
- key: 0,
11
- id: e(o).popoverId,
12
- role: "listbox"
13
- }, [
14
- m(t.$slots, "default")
15
- ], 8, d)) : s("", !0);
16
- }
17
- });
18
- export {
19
- f as _
20
- };
@@ -1,82 +0,0 @@
1
- import { defineComponent as b, useId as u, useModel as M, computed as m, provide as O, renderSlot as A, unref as _, mergeModels as h, nextTick as r } from "vue";
2
- import { usePopover as C } from "./composable-ui23.js";
3
- import { useList as D } from "./composable-ui22.js";
4
- import { injectMenu as V } from "./composable-ui19.js";
5
- const j = /* @__PURE__ */ b({
6
- __name: "menu",
7
- props: /* @__PURE__ */ h({
8
- id: {},
9
- activatorId: {},
10
- direction: { default: "down" },
11
- align: { default: "left" },
12
- position: { default: "fixed" }
13
- }, {
14
- modelValue: {},
15
- modelModifiers: {}
16
- }),
17
- emits: ["update:modelValue"],
18
- setup(s) {
19
- const e = s, a = e.id ?? u(), i = e.activatorId ?? u(), p = M(s, "modelValue"), {
20
- isMultiselectable: v,
21
- activeItem: f,
22
- activateFirstItem: n,
23
- activateLastItem: c,
24
- activateNextItem: I,
25
- activatePrevItem: k
26
- } = D(p), { isOpen: t, toggle: d, open: l, close: w } = C(
27
- `#${i}`,
28
- `#${a}`,
29
- {
30
- direction: e.direction,
31
- align: e.align,
32
- position: e.position,
33
- closeOnOutsideClick: !0,
34
- closeOnInsideClick: !1
35
- }
36
- );
37
- function g(o) {
38
- switch (o.code) {
39
- case "Space":
40
- case "Enter":
41
- d(), t.value && r(n);
42
- break;
43
- case "ArrowUp":
44
- l(), r(c);
45
- break;
46
- case "ArrowDown":
47
- l(), r(n);
48
- break;
49
- default:
50
- return;
51
- }
52
- o.preventDefault();
53
- }
54
- const x = m(() => ({
55
- id: i,
56
- "aria-controls": t.value ? a : void 0,
57
- "aria-haspopup": "menu",
58
- "aria-expanded": t.value,
59
- onclick: () => d(),
60
- onkeydown: g,
61
- tabindex: 0
62
- }));
63
- return O(V, {
64
- menuId: a,
65
- activatorId: i,
66
- isOpen: t,
67
- close: w,
68
- isMultiselectable: v,
69
- activeItemId: m(() => f.value?.element.value?.id),
70
- activateFirstItem: n,
71
- activateLastItem: c,
72
- activateNextItem: I,
73
- activatePrevItem: k
74
- }), (o, $) => A(o.$slots, "default", {
75
- attrs: x.value,
76
- isOpen: _(t)
77
- });
78
- }
79
- });
80
- export {
81
- j as _
82
- };
@@ -1,64 +0,0 @@
1
- import { defineComponent as v, useModel as m, useId as c, watch as p, onMounted as O, computed as g, provide as I, renderSlot as C, unref as n, mergeModels as k } from "vue";
2
- import { usePopover as M } from "./composable-ui23.js";
3
- import { injectPopover as _ } from "./composable-ui19.js";
4
- const $ = /* @__PURE__ */ v({
5
- __name: "popover",
6
- props: /* @__PURE__ */ k({
7
- id: {},
8
- activatorId: {},
9
- direction: { default: "down" },
10
- align: { default: "left" },
11
- position: { default: "fixed" },
12
- closeOnOutsideClick: { type: Boolean, default: !0 },
13
- closeOnInsideClick: { type: Boolean, default: !1 },
14
- role: { default: "dialog" }
15
- }, {
16
- open: { type: Boolean },
17
- openModifiers: {}
18
- }),
19
- emits: ["update:open"],
20
- setup(d) {
21
- const e = d, i = m(d, "open"), l = e.id ?? c(), s = e.activatorId ?? c(), { isOpen: t, toggle: u, open: a, close: r } = M(
22
- `#${s}`,
23
- `#${l}`,
24
- {
25
- direction: e.direction,
26
- align: e.align,
27
- position: e.position,
28
- closeOnOutsideClick: e.closeOnOutsideClick,
29
- closeOnInsideClick: e.closeOnInsideClick
30
- }
31
- );
32
- p(t, (o) => {
33
- i.value !== o && (i.value = o);
34
- }), p(i, (o) => {
35
- o === void 0 || o === t.value || (o ? a({ focus: !1 }) : r());
36
- }), O(() => {
37
- i.value && !t.value && a({ focus: !1 });
38
- });
39
- const f = g(() => ({
40
- id: s,
41
- "aria-controls": t.value ? l : void 0,
42
- // A disclosure is a plain expandable region: aria-haspopup would promise
43
- // assistive technology a widget that is not there.
44
- "aria-haspopup": e.role === "none" ? void 0 : e.role,
45
- "aria-expanded": t.value
46
- }));
47
- return I(_, {
48
- popoverId: l,
49
- activatorId: s,
50
- role: e.role,
51
- isOpen: t,
52
- close: r
53
- }), (o, h) => C(o.$slots, "default", {
54
- attrs: f.value,
55
- isOpen: n(t),
56
- toggle: n(u),
57
- open: n(a),
58
- close: n(r)
59
- });
60
- }
61
- });
62
- export {
63
- $ as _
64
- };
@@ -1,40 +0,0 @@
1
- import { defineComponent as c, useModel as u, provide as v, computed as p, openBlock as f, createElementBlock as I, renderSlot as _ } from "vue";
2
- import { useList as b } from "./composable-ui22.js";
3
- import { injectTabs as g } from "./composable-ui19.js";
4
- const x = /* @__PURE__ */ c({
5
- __name: "tabContainer",
6
- props: {
7
- modelValue: {},
8
- modelModifiers: {}
9
- },
10
- emits: ["update:modelValue"],
11
- setup(o) {
12
- const a = u(o, "modelValue"), {
13
- items: i,
14
- selectActiveItem: l,
15
- activateFirstItem: m,
16
- activateLastItem: r,
17
- activateNextItem: n,
18
- activatePrevItem: s
19
- } = b(a);
20
- return v(g, {
21
- getIds: (e) => p(() => {
22
- const t = i.value.find((d) => d.value === e);
23
- return {
24
- tabId: t?.element.value?.getAttribute("id") || void 0,
25
- panelId: t?.element.value?.getAttribute("aria-controls") || void 0
26
- };
27
- }),
28
- selectActiveItem: l,
29
- activateFirstItem: m,
30
- activateLastItem: r,
31
- activateNextItem: n,
32
- activatePrevItem: s
33
- }), (e, t) => (f(), I("div", null, [
34
- _(e.$slots, "default")
35
- ]));
36
- }
37
- });
38
- export {
39
- x as _
40
- };
@@ -1,78 +0,0 @@
1
- import { defineComponent as g, useSlots as y, ref as b, useId as E, onMounted as $, onBeforeUnmount as k, openBlock as a, createElementBlock as c, Fragment as T, renderSlot as p, createBlock as _, Teleport as h, unref as f, mergeProps as B, createTextVNode as L, toDisplayString as S, createCommentVNode as w } from "vue";
2
- import { usePopover as A } from "./composable-ui23.js";
3
- const C = ["id"], P = /* @__PURE__ */ g({
4
- inheritAttrs: !1,
5
- __name: "tooltip",
6
- props: {
7
- id: {},
8
- text: {},
9
- delay: {},
10
- direction: { default: "up" }
11
- },
12
- setup(l) {
13
- const t = l, m = y(), d = b();
14
- let u;
15
- const o = t.id ?? E(), { isOpen: i } = A(`[aria-describedby=${o}]`, d, {
16
- direction: t.direction,
17
- align: "center"
18
- });
19
- function n() {
20
- u = setTimeout(
21
- () => {
22
- i.value = !0;
23
- },
24
- typeof t.delay == "string" ? parseInt(t.delay) : t.delay
25
- );
26
- }
27
- function s() {
28
- i.value = !1, clearTimeout(u);
29
- }
30
- const v = {
31
- "aria-describedby": o,
32
- onmouseenter: n,
33
- onmouseleave: s,
34
- onfocus: n,
35
- onblur: s
36
- }, r = new AbortController();
37
- return $(() => {
38
- if (m.default) return;
39
- const e = document.querySelector(
40
- `[aria-describedby=${o}]`
41
- );
42
- if (!e)
43
- throw new Error(`Tooltip activator not found: ${o}`);
44
- e.addEventListener("mouseenter", n, {
45
- signal: r.signal,
46
- passive: !0
47
- }), e.addEventListener("mouseleave", s, {
48
- signal: r.signal,
49
- passive: !0
50
- }), e.addEventListener("focus", n, {
51
- signal: r.signal,
52
- passive: !0
53
- }), e.addEventListener("blur", s, {
54
- signal: r.signal,
55
- passive: !0
56
- });
57
- }), k(() => {
58
- r.abort();
59
- }), (e, I) => (a(), c(T, null, [
60
- p(e.$slots, "default", { attrs: v }),
61
- (a(), _(h, { to: "body" }, [
62
- f(i) ? (a(), c("div", B({
63
- key: 0,
64
- ref_key: "popupEl",
65
- ref: d,
66
- id: f(o)
67
- }, e.$attrs, { role: "tooltip" }), [
68
- p(e.$slots, "content", {}, () => [
69
- L(S(l.text), 1)
70
- ])
71
- ], 16, C)) : w("", !0)
72
- ]))
73
- ], 64));
74
- }
75
- });
76
- export {
77
- P as _
78
- };