@humanonlyweb/ui 0.0.0-stage → 0.1.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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/dist/components/accordion/Accordion.js +60 -0
  4. package/dist/components/accordion/Accordion.vue.d.ts +28 -0
  5. package/dist/components/accordion/AccordionItem.js +102 -0
  6. package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
  7. package/dist/components/avatar/Avatar.js +52 -0
  8. package/dist/components/avatar/Avatar.vue.d.ts +26 -0
  9. package/dist/components/avatar/AvatarGroup.js +48 -0
  10. package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
  11. package/dist/components/button/Button.js +95 -0
  12. package/dist/components/button/Button.vue.d.ts +74 -0
  13. package/dist/components/button/IconButton.js +47 -0
  14. package/dist/components/button/IconButton.vue.d.ts +115 -0
  15. package/dist/components/checkbox/Checkbox.js +93 -0
  16. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  17. package/dist/components/combobox/Combobox.js +294 -0
  18. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  19. package/dist/components/context-menu/ContextMenu.js +170 -0
  20. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  21. package/dist/components/dialog/ConfirmDialog.js +103 -0
  22. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  23. package/dist/components/dialog/Dialog.js +160 -0
  24. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  25. package/dist/components/field/FieldMessage.js +31 -0
  26. package/dist/components/input/Input.js +111 -0
  27. package/dist/components/input/Input.vue.d.ts +50 -0
  28. package/dist/components/kbd/Kbd.js +48 -0
  29. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  30. package/dist/components/menu/Menu.js +124 -0
  31. package/dist/components/menu/Menu.vue.d.ts +41 -0
  32. package/dist/components/otp-input/OtpInput.js +179 -0
  33. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  34. package/dist/components/popover/Popover.js +83 -0
  35. package/dist/components/popover/Popover.vue.d.ts +37 -0
  36. package/dist/components/radio-group/RadioGroup.js +125 -0
  37. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  38. package/dist/components/segmented/Segmented.js +110 -0
  39. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  40. package/dist/components/select/Select.js +231 -0
  41. package/dist/components/select/Select.vue.d.ts +59 -0
  42. package/dist/components/slider/Slider.js +196 -0
  43. package/dist/components/slider/Slider.vue.d.ts +49 -0
  44. package/dist/components/spin-button/SpinButton.js +231 -0
  45. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  46. package/dist/components/split-button/SplitButton.js +69 -0
  47. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  48. package/dist/components/switch/Switch.js +95 -0
  49. package/dist/components/switch/Switch.vue.d.ts +42 -0
  50. package/dist/components/table/Table.js +173 -0
  51. package/dist/components/table/Table.vue.d.ts +45 -0
  52. package/dist/components/tabs/Tabs.js +99 -0
  53. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  54. package/dist/components/textarea/Textarea.js +118 -0
  55. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  56. package/dist/components/toast/ToastItem.js +91 -0
  57. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  58. package/dist/components/toast/ToastViewport.js +56 -0
  59. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  60. package/dist/components/toolbar/Toolbar.js +91 -0
  61. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  62. package/dist/components/tooltip/Tooltip.js +85 -0
  63. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  64. package/dist/composables/internal/env.js +5 -0
  65. package/dist/composables/internal/is-equal.js +14 -0
  66. package/dist/composables/internal/on-click-outside.js +18 -0
  67. package/dist/composables/internal/standard-schema.d.ts +38 -0
  68. package/dist/composables/internal/use-document-visibility.js +16 -0
  69. package/dist/composables/internal/use-event-listener.js +24 -0
  70. package/dist/composables/internal/use-interval-fn.js +21 -0
  71. package/dist/composables/internal/use-resize-observer.js +21 -0
  72. package/dist/composables/internal/use-timeout-fn.js +25 -0
  73. package/dist/composables/use-accordion.d.ts +9 -0
  74. package/dist/composables/use-accordion.js +10 -0
  75. package/dist/composables/use-combobox.d.ts +44 -0
  76. package/dist/composables/use-combobox.js +185 -0
  77. package/dist/composables/use-field.d.ts +17 -0
  78. package/dist/composables/use-field.js +27 -0
  79. package/dist/composables/use-form.d.ts +44 -0
  80. package/dist/composables/use-form.js +146 -0
  81. package/dist/composables/use-menu.d.ts +26 -0
  82. package/dist/composables/use-menu.js +117 -0
  83. package/dist/composables/use-platform.d.ts +17 -0
  84. package/dist/composables/use-platform.js +126 -0
  85. package/dist/composables/use-popover.d.ts +35 -0
  86. package/dist/composables/use-popover.js +49 -0
  87. package/dist/composables/use-roving-selection.d.ts +22 -0
  88. package/dist/composables/use-roving-selection.js +65 -0
  89. package/dist/composables/use-select.d.ts +31 -0
  90. package/dist/composables/use-select.js +169 -0
  91. package/dist/composables/use-slide-indicator.d.ts +24 -0
  92. package/dist/composables/use-slide-indicator.js +52 -0
  93. package/dist/composables/use-toast.d.ts +23 -0
  94. package/dist/composables/use-toast.js +51 -0
  95. package/dist/config.d.ts +40 -0
  96. package/dist/config.js +35 -0
  97. package/dist/docs/README.md +44 -0
  98. package/dist/docs/changelog.md +14 -0
  99. package/dist/docs/components/accordion.md +100 -0
  100. package/dist/docs/components/avatar-group.md +58 -0
  101. package/dist/docs/components/avatar.md +40 -0
  102. package/dist/docs/components/button.md +109 -0
  103. package/dist/docs/components/checkbox.md +123 -0
  104. package/dist/docs/components/combobox.md +207 -0
  105. package/dist/docs/components/confirm-dialog.md +107 -0
  106. package/dist/docs/components/context-menu.md +98 -0
  107. package/dist/docs/components/dialog.md +127 -0
  108. package/dist/docs/components/icon-button.md +47 -0
  109. package/dist/docs/components/input.md +89 -0
  110. package/dist/docs/components/kbd.md +41 -0
  111. package/dist/docs/components/menu.md +112 -0
  112. package/dist/docs/components/otp-input.md +92 -0
  113. package/dist/docs/components/popover.md +72 -0
  114. package/dist/docs/components/radio-group.md +114 -0
  115. package/dist/docs/components/segmented.md +96 -0
  116. package/dist/docs/components/select.md +129 -0
  117. package/dist/docs/components/slider.md +105 -0
  118. package/dist/docs/components/spin-button.md +73 -0
  119. package/dist/docs/components/split-button.md +64 -0
  120. package/dist/docs/components/switch.md +71 -0
  121. package/dist/docs/components/table.md +241 -0
  122. package/dist/docs/components/tabs.md +106 -0
  123. package/dist/docs/components/textarea.md +46 -0
  124. package/dist/docs/components/toast.md +135 -0
  125. package/dist/docs/components/toolbar.md +71 -0
  126. package/dist/docs/components/tooltip.md +57 -0
  127. package/dist/docs/forms.md +182 -0
  128. package/dist/docs/index.md +11 -0
  129. package/dist/docs/installation.md +73 -0
  130. package/dist/docs/localisation.md +40 -0
  131. package/dist/docs/ssr.md +24 -0
  132. package/dist/docs/styling.md +66 -0
  133. package/dist/index.d.ts +46 -0
  134. package/dist/index.js +44 -0
  135. package/dist/nuxt/module.d.ts +15 -0
  136. package/dist/nuxt/module.js +72 -0
  137. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  138. package/dist/nuxt/runtime/plugin.js +24 -0
  139. package/dist/package.js +4 -0
  140. package/dist/styles/core.css +284 -0
  141. package/dist/translations.d.ts +71 -0
  142. package/dist/translations.js +55 -0
  143. package/dist/types.d.ts +61 -0
  144. package/package.json +93 -4
@@ -0,0 +1,115 @@
1
+ import { ButtonSize, ButtonType, ButtonVariant, LinkTarget, LinkTo } from "../../types.js";
2
+ import "../../index.js";
3
+ //#region src/components/button/IconButton.vue.d.ts
4
+ type __VLS_Slots = {
5
+ /** The icon. */
6
+ default?(): unknown;
7
+ /** Shown while `loading`, in place of the icon. */
8
+ spinner?(): unknown;
9
+ };
10
+ declare const __VLS_base: import("vue").DefineComponent<({
11
+ variant?: ButtonVariant;
12
+ size?: ButtonSize;
13
+ fullWidth?: boolean;
14
+ loading?: boolean;
15
+ disabled?: boolean;
16
+ } & {
17
+ type?: ButtonType;
18
+ href?: never;
19
+ to?: never;
20
+ target?: never;
21
+ } & {
22
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
23
+ label: string;
24
+ /** Shape hook, exposed as `data-button-shape`. */
25
+ shape?: "square" | "round";
26
+ }) | ({
27
+ variant?: ButtonVariant;
28
+ size?: ButtonSize;
29
+ fullWidth?: boolean;
30
+ loading?: boolean;
31
+ disabled?: boolean;
32
+ } & {
33
+ to: LinkTo;
34
+ href?: never;
35
+ type?: never;
36
+ target?: LinkTarget;
37
+ } & {
38
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
39
+ label: string;
40
+ /** Shape hook, exposed as `data-button-shape`. */
41
+ shape?: "square" | "round";
42
+ }) | ({
43
+ variant?: ButtonVariant;
44
+ size?: ButtonSize;
45
+ fullWidth?: boolean;
46
+ loading?: boolean;
47
+ disabled?: boolean;
48
+ } & {
49
+ href: string;
50
+ target?: LinkTarget;
51
+ type?: never;
52
+ to?: never;
53
+ } & {
54
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
55
+ label: string;
56
+ /** Shape hook, exposed as `data-button-shape`. */
57
+ shape?: "square" | "round";
58
+ }), {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<({
59
+ variant?: ButtonVariant;
60
+ size?: ButtonSize;
61
+ fullWidth?: boolean;
62
+ loading?: boolean;
63
+ disabled?: boolean;
64
+ } & {
65
+ type?: ButtonType;
66
+ href?: never;
67
+ to?: never;
68
+ target?: never;
69
+ } & {
70
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
71
+ label: string;
72
+ /** Shape hook, exposed as `data-button-shape`. */
73
+ shape?: "square" | "round";
74
+ }) | ({
75
+ variant?: ButtonVariant;
76
+ size?: ButtonSize;
77
+ fullWidth?: boolean;
78
+ loading?: boolean;
79
+ disabled?: boolean;
80
+ } & {
81
+ to: LinkTo;
82
+ href?: never;
83
+ type?: never;
84
+ target?: LinkTarget;
85
+ } & {
86
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
87
+ label: string;
88
+ /** Shape hook, exposed as `data-button-shape`. */
89
+ shape?: "square" | "round";
90
+ }) | ({
91
+ variant?: ButtonVariant;
92
+ size?: ButtonSize;
93
+ fullWidth?: boolean;
94
+ loading?: boolean;
95
+ disabled?: boolean;
96
+ } & {
97
+ href: string;
98
+ target?: LinkTarget;
99
+ type?: never;
100
+ to?: never;
101
+ } & {
102
+ /** Accessible name; icon-only buttons have no visible text to supply one. */
103
+ label: string;
104
+ /** Shape hook, exposed as `data-button-shape`. */
105
+ shape?: "square" | "round";
106
+ })> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
107
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
108
+ declare const _default: typeof __VLS_export;
109
+ type __VLS_WithSlots<T, S> = T & {
110
+ new (): {
111
+ $slots: S;
112
+ };
113
+ };
114
+ //#endregion
115
+ export { _default as default };
@@ -0,0 +1,93 @@
1
+ import { useField } from "../../composables/use-field.js";
2
+ import _sfc_main$1 from "../field/FieldMessage.js";
3
+ import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, renderSlot, toDisplayString, unref, useModel, useTemplateRef, vModelCheckbox, watchEffect, withDirectives } from "vue";
4
+ //#region src/components/checkbox/Checkbox.vue
5
+ const _hoisted_1 = ["data-checkbox-disabled", "data-checkbox-error"];
6
+ const _hoisted_2 = [
7
+ "id",
8
+ "value",
9
+ "disabled",
10
+ "aria-invalid",
11
+ "aria-describedby"
12
+ ];
13
+ const _hoisted_3 = {
14
+ "data-part": "checkbox-control",
15
+ "aria-hidden": "true"
16
+ };
17
+ const _hoisted_4 = {
18
+ key: 0,
19
+ "data-part": "checkbox-label"
20
+ };
21
+ const _sfc_main = /*@__PURE__*/ defineComponent({
22
+ inheritAttrs: false,
23
+ __name: "Checkbox",
24
+ props: /*@__PURE__*/ mergeModels({
25
+ label: {},
26
+ disabled: {
27
+ type: Boolean,
28
+ default: false
29
+ },
30
+ indeterminate: {
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ value: {},
35
+ hint: {},
36
+ error: { type: [String, Boolean] },
37
+ id: {}
38
+ }, {
39
+ "modelValue": { type: [Boolean, Array] },
40
+ "modelModifiers": {}
41
+ }),
42
+ emits: ["update:modelValue"],
43
+ setup(__props) {
44
+ /** Checked state, or with an array, the checked `value`s. */
45
+ const model = useModel(__props, "modelValue");
46
+ const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
47
+ id: () => __props.id,
48
+ hint: () => __props.hint,
49
+ error: () => __props.error
50
+ });
51
+ const inputRef = useTemplateRef("input");
52
+ watchEffect(() => {
53
+ if (inputRef.value) inputRef.value.indeterminate = __props.indeterminate;
54
+ });
55
+ return (_ctx, _cache) => {
56
+ return openBlock(), createElementBlock(Fragment, null, [
57
+ createElementVNode("label", {
58
+ "data-part": "checkbox",
59
+ "data-checkbox-disabled": __props.disabled || void 0,
60
+ "data-checkbox-error": unref(isError) || void 0
61
+ }, [
62
+ withDirectives(createElementVNode("input", mergeProps({
63
+ id: unref(id),
64
+ ref: "input",
65
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
66
+ type: "checkbox",
67
+ "data-part": "checkbox-input",
68
+ value: __props.value,
69
+ disabled: __props.disabled,
70
+ "aria-invalid": unref(isError) || void 0,
71
+ "aria-describedby": unref(describedBy)
72
+ }, _ctx.$attrs), null, 16, _hoisted_2), [[vModelCheckbox, model.value]]),
73
+ createElementVNode("span", _hoisted_3, [renderSlot(_ctx.$slots, "indicator")]),
74
+ _ctx.$slots.default || __props.label ? (openBlock(), createElementBlock("span", _hoisted_4, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.label), 1)])])) : createCommentVNode("v-if", true)
75
+ ], 8, _hoisted_1),
76
+ createCommentVNode(" A sibling, not a wrapper: without a hint or error the markup is just the label. "),
77
+ createVNode(_sfc_main$1, {
78
+ "error-id": unref(errorId),
79
+ "hint-id": unref(hintId),
80
+ "error-message": unref(errorMessage),
81
+ hint: __props.hint
82
+ }, null, 8, [
83
+ "error-id",
84
+ "hint-id",
85
+ "error-message",
86
+ "hint"
87
+ ])
88
+ ], 64);
89
+ };
90
+ }
91
+ });
92
+ //#endregion
93
+ export { _sfc_main as default };
@@ -0,0 +1,43 @@
1
+ import { SelectValue } from "../../types.js";
2
+ //#region src/components/checkbox/Checkbox.vue.d.ts
3
+ type __VLS_Props = {
4
+ /** Text next to the box. The default slot overrides it. */
5
+ label?: string;
6
+ /** Disables the checkbox. */
7
+ disabled?: boolean;
8
+ /** Shows the mixed state, e.g. for a "select all" with some rows picked. */
9
+ indeterminate?: boolean;
10
+ /** With an array `v-model`, this value is added/removed when toggled. */
11
+ value?: SelectValue;
12
+ /** Help text under the checkbox, announced as its description. */
13
+ hint?: string;
14
+ /** `true` marks it invalid; a string also shows it as the message, replacing the hint. */
15
+ error?: string | boolean;
16
+ /** Id for the input; generated with `useId()` when omitted. */
17
+ id?: string;
18
+ };
19
+ type __VLS_Slots = {
20
+ /** Label content, replacing `label`. */
21
+ default?(): unknown;
22
+ /** Inside `checkbox-control`, e.g. a check icon. */
23
+ indicator?(): unknown;
24
+ };
25
+ type __VLS_ModelProps = {
26
+ /** Checked state, or with an array, the checked `value`s. */
27
+ modelValue?: boolean | SelectValue[];
28
+ };
29
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
30
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
31
+ "update:modelValue": (value: boolean | SelectValue[] | undefined) => any;
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
33
+ "onUpdate:modelValue"?: ((value: boolean | SelectValue[] | undefined) => any) | undefined;
34
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
+ declare const _default: typeof __VLS_export;
37
+ type __VLS_WithSlots<T, S> = T & {
38
+ new (): {
39
+ $slots: S;
40
+ };
41
+ };
42
+ //#endregion
43
+ export { _default as default };
@@ -0,0 +1,294 @@
1
+ import { useTranslations } from "../../config.js";
2
+ import { useField } from "../../composables/use-field.js";
3
+ import _sfc_main$1 from "../field/FieldMessage.js";
4
+ import { useCombobox } from "../../composables/use-combobox.js";
5
+ import { useAnchor } from "../../composables/use-popover.js";
6
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef, vModelText, withDirectives, withModifiers } from "vue";
7
+ //#region src/components/combobox/Combobox.vue
8
+ const _hoisted_1 = ["data-field-error", "data-field-name"];
9
+ const _hoisted_2 = ["for"];
10
+ const _hoisted_3 = {
11
+ key: 0,
12
+ "data-part": "field-optional"
13
+ };
14
+ const _hoisted_4 = ["data-combobox-open", "data-combobox-disabled"];
15
+ const _hoisted_5 = { "data-part": "combobox-chip-label" };
16
+ const _hoisted_6 = [
17
+ "aria-label",
18
+ "disabled",
19
+ "onClick"
20
+ ];
21
+ const _hoisted_7 = [
22
+ "id",
23
+ "aria-expanded",
24
+ "aria-controls",
25
+ "aria-activedescendant",
26
+ "aria-invalid",
27
+ "aria-describedby",
28
+ "placeholder",
29
+ "disabled"
30
+ ];
31
+ const _hoisted_8 = [
32
+ "id",
33
+ "aria-multiselectable",
34
+ "aria-busy",
35
+ "aria-label"
36
+ ];
37
+ const _hoisted_9 = [
38
+ "id",
39
+ "aria-selected",
40
+ "aria-disabled",
41
+ "data-combobox-active",
42
+ "onClick",
43
+ "onPointermove"
44
+ ];
45
+ const _hoisted_10 = { "data-part": "combobox-option-label" };
46
+ const _hoisted_11 = {
47
+ key: 0,
48
+ "data-part": "combobox-loading"
49
+ };
50
+ const _hoisted_12 = {
51
+ key: 1,
52
+ "data-part": "combobox-create"
53
+ };
54
+ const _hoisted_13 = {
55
+ key: 2,
56
+ "data-part": "combobox-empty"
57
+ };
58
+ const _hoisted_14 = ["id"];
59
+ const _hoisted_15 = ["name", "value"];
60
+ const _sfc_main = /*@__PURE__*/ defineComponent({
61
+ inheritAttrs: false,
62
+ __name: "Combobox",
63
+ props: /*@__PURE__*/ mergeModels({
64
+ options: { default: () => [] },
65
+ label: {},
66
+ hint: {},
67
+ error: { type: [String, Boolean] },
68
+ placeholder: {},
69
+ multiple: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ creatable: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ optional: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ disabled: {
82
+ type: Boolean,
83
+ default: false
84
+ },
85
+ filter: { type: Function },
86
+ ignoreFilter: {
87
+ type: Boolean,
88
+ default: false
89
+ },
90
+ loading: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ name: {},
95
+ id: {}
96
+ }, {
97
+ "modelValue": {},
98
+ "modelModifiers": {},
99
+ "query": { default: "" },
100
+ "queryModifiers": {}
101
+ }),
102
+ emits: /*@__PURE__*/ mergeModels(["create"], ["update:modelValue", "update:query"]),
103
+ setup(__props, { expose: __expose, emit: __emit }) {
104
+ const emit = __emit;
105
+ /** The selected value, or values with `multiple`. */
106
+ const model = useModel(__props, "modelValue");
107
+ const submittedValues = computed(() => {
108
+ const value = model.value;
109
+ if (value == null) return [];
110
+ return Array.isArray(value) ? value : [value];
111
+ });
112
+ /** The input's text. Bind it to fetch options as the user types. */
113
+ const query = useModel(__props, "query");
114
+ const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
115
+ error: () => __props.error,
116
+ id: () => __props.id,
117
+ hint: () => __props.hint
118
+ });
119
+ const listboxId = computed(() => `${id.value}-listbox`);
120
+ const { anchorStyle, panelStyle } = useAnchor();
121
+ const inputRef = useTemplateRef("input");
122
+ const controlRef = useTemplateRef("control");
123
+ const popupRef = useTemplateRef("popup");
124
+ const { isOpen, activeIndex, activeId, optionId, results, selectedOptions, isSelected, canCreate, open, setActive, selectOption, remove, onInput, onKeydown } = useCombobox({
125
+ options: () => __props.options,
126
+ model,
127
+ query,
128
+ multiple: () => __props.multiple,
129
+ disabled: () => __props.disabled,
130
+ filter: () => __props.filter,
131
+ ignoreFilter: () => __props.ignoreFilter,
132
+ creatable: () => __props.creatable,
133
+ onCreate: (text) => emit("create", text),
134
+ baseId: () => id.value,
135
+ input: inputRef,
136
+ control: controlRef,
137
+ listbox: popupRef
138
+ });
139
+ const translations = useTranslations();
140
+ const selectedId = computed(() => `${id.value}-selected`);
141
+ const selectedText = computed(() => __props.multiple && selectedOptions.value.length ? translations.value.selectedItems(selectedOptions.value.map((option) => option.label)) : "");
142
+ const describedByAll = computed(() => [describedBy.value, selectedText.value ? selectedId.value : void 0].filter(Boolean).join(" ") || void 0);
143
+ const status = computed(() => {
144
+ const text = query.value.trim();
145
+ if (!isOpen.value || !text) return "";
146
+ if (__props.loading) return translations.value.loading;
147
+ if (results.value.length) return translations.value.resultCount(results.value.length);
148
+ return canCreate.value ? translations.value.createOption(text) : translations.value.noResults;
149
+ });
150
+ const visuallyHidden = {
151
+ position: "absolute",
152
+ width: "1px",
153
+ height: "1px",
154
+ overflow: "hidden",
155
+ clipPath: "inset(50%)",
156
+ whiteSpace: "nowrap"
157
+ };
158
+ __expose({ focus: () => inputRef.value?.focus() });
159
+ return (_ctx, _cache) => {
160
+ return openBlock(), createElementBlock("div", {
161
+ "data-part": "field",
162
+ "data-field-error": unref(isError) || void 0,
163
+ "data-field-name": __props.name
164
+ }, [
165
+ __props.label ? (openBlock(), createElementBlock("label", {
166
+ key: 0,
167
+ for: unref(id),
168
+ "data-part": "field-label"
169
+ }, [createTextVNode(toDisplayString(__props.label), 1), __props.optional ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(` ${unref(translations).optional}`), 1)) : createCommentVNode("v-if", true)], 8, _hoisted_2)) : createCommentVNode("v-if", true),
170
+ createElementVNode("div", {
171
+ ref: "control",
172
+ "data-part": "combobox-control",
173
+ "data-combobox-open": unref(isOpen) || void 0,
174
+ "data-combobox-disabled": __props.disabled || void 0,
175
+ style: normalizeStyle(unref(anchorStyle)),
176
+ onClick: _cache[4] || (_cache[4] = ($event) => inputRef.value?.focus())
177
+ }, [__props.multiple ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(selectedOptions), (option) => {
178
+ return openBlock(), createElementBlock("span", {
179
+ key: option.value,
180
+ "data-part": "combobox-chip"
181
+ }, [renderSlot(_ctx.$slots, "chip", {
182
+ option,
183
+ remove: () => unref(remove)(option.value)
184
+ }, () => [
185
+ createElementVNode("span", _hoisted_5, toDisplayString(option.label), 1),
186
+ createCommentVNode(" Out of the tab order: Backspace in the input removes chips by keyboard. "),
187
+ createElementVNode("button", {
188
+ type: "button",
189
+ tabindex: "-1",
190
+ "data-part": "combobox-chip-remove",
191
+ "aria-label": unref(translations).removeItem(option.label),
192
+ disabled: __props.disabled,
193
+ onClick: withModifiers(($event) => unref(remove)(option.value), ["stop"])
194
+ }, [..._cache[6] || (_cache[6] = [createElementVNode("svg", {
195
+ viewBox: "0 0 16 16",
196
+ width: "12",
197
+ height: "12",
198
+ "aria-hidden": "true",
199
+ focusable: "false"
200
+ }, [createElementVNode("path", {
201
+ d: "M4 4l8 8M12 4l-8 8",
202
+ stroke: "currentColor",
203
+ "stroke-width": "1.5",
204
+ "stroke-linecap": "round"
205
+ })], -1)])], 8, _hoisted_6)
206
+ ])]);
207
+ }), 128)) : createCommentVNode("v-if", true), withDirectives(createElementVNode("input", mergeProps({
208
+ id: unref(id),
209
+ ref: "input",
210
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => query.value = $event),
211
+ type: "text",
212
+ role: "combobox",
213
+ autocomplete: "off",
214
+ spellcheck: "false",
215
+ "aria-autocomplete": "list",
216
+ "aria-expanded": unref(isOpen),
217
+ "aria-controls": listboxId.value,
218
+ "aria-activedescendant": unref(activeId),
219
+ "aria-invalid": unref(isError) || void 0,
220
+ "aria-describedby": describedByAll.value,
221
+ placeholder: __props.multiple && unref(selectedOptions).length ? void 0 : __props.placeholder,
222
+ disabled: __props.disabled,
223
+ "data-part": "combobox-input"
224
+ }, _ctx.$attrs, {
225
+ onInput: _cache[1] || (_cache[1] = (...args) => unref(onInput) && unref(onInput)(...args)),
226
+ onKeydown: _cache[2] || (_cache[2] = (...args) => unref(onKeydown) && unref(onKeydown)(...args)),
227
+ onClick: _cache[3] || (_cache[3] = (...args) => unref(open) && unref(open)(...args))
228
+ }), null, 16, _hoisted_7), [[vModelText, query.value]])], 12, _hoisted_4),
229
+ createElementVNode("div", {
230
+ ref: "popup",
231
+ popover: "manual",
232
+ "data-part": "combobox-popup",
233
+ style: normalizeStyle(unref(panelStyle)),
234
+ onPointerdown: _cache[5] || (_cache[5] = withModifiers(() => {}, ["prevent"]))
235
+ }, [createElementVNode("ul", {
236
+ id: listboxId.value,
237
+ role: "listbox",
238
+ "data-part": "combobox-listbox",
239
+ "aria-multiselectable": __props.multiple || void 0,
240
+ "aria-busy": __props.loading || void 0,
241
+ "aria-label": __props.label
242
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(results), (option, i) => {
243
+ return openBlock(), createElementBlock("li", {
244
+ id: unref(optionId)(i),
245
+ key: option.value,
246
+ role: "option",
247
+ "data-part": "combobox-option",
248
+ "aria-selected": unref(isSelected)(option.value),
249
+ "aria-disabled": option.disabled || void 0,
250
+ "data-combobox-active": i === unref(activeIndex) || void 0,
251
+ onClick: ($event) => unref(selectOption)(option),
252
+ onPointermove: ($event) => !option.disabled && unref(setActive)(i)
253
+ }, [renderSlot(_ctx.$slots, "option", {
254
+ option,
255
+ selected: unref(isSelected)(option.value),
256
+ active: i === unref(activeIndex)
257
+ }, () => [createElementVNode("span", _hoisted_10, toDisplayString(option.label), 1)])], 40, _hoisted_9);
258
+ }), 128))], 8, _hoisted_8), __props.loading ? (openBlock(), createElementBlock("p", _hoisted_11, [renderSlot(_ctx.$slots, "loading", {}, () => [createTextVNode(toDisplayString(unref(translations).loading), 1)])])) : unref(canCreate) && !unref(results).length ? (openBlock(), createElementBlock("p", _hoisted_12, [renderSlot(_ctx.$slots, "create", { query: query.value.trim() }, () => [createTextVNode(toDisplayString(unref(translations).createOption(query.value.trim())), 1)])])) : !unref(results).length ? (openBlock(), createElementBlock("p", _hoisted_13, [renderSlot(_ctx.$slots, "empty", { query: query.value }, () => [createTextVNode(toDisplayString(unref(translations).noResults), 1)])])) : createCommentVNode("v-if", true)], 36),
259
+ createElementVNode("span", {
260
+ role: "status",
261
+ "data-part": "combobox-status",
262
+ style: visuallyHidden
263
+ }, toDisplayString(status.value), 1),
264
+ selectedText.value ? (openBlock(), createElementBlock("span", {
265
+ key: 1,
266
+ id: selectedId.value,
267
+ style: visuallyHidden
268
+ }, toDisplayString(selectedText.value), 9, _hoisted_14)) : createCommentVNode("v-if", true),
269
+ createCommentVNode(" Buttons don't submit values, so the form gets hidden inputs instead. "),
270
+ __props.name ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(submittedValues.value, (value) => {
271
+ return openBlock(), createElementBlock("input", {
272
+ key: value,
273
+ type: "hidden",
274
+ name: __props.name,
275
+ value
276
+ }, null, 8, _hoisted_15);
277
+ }), 128)) : createCommentVNode("v-if", true),
278
+ createVNode(_sfc_main$1, {
279
+ "error-id": unref(errorId),
280
+ "hint-id": unref(hintId),
281
+ "error-message": unref(errorMessage),
282
+ hint: __props.hint
283
+ }, null, 8, [
284
+ "error-id",
285
+ "hint-id",
286
+ "error-message",
287
+ "hint"
288
+ ])
289
+ ], 8, _hoisted_1);
290
+ };
291
+ }
292
+ });
293
+ //#endregion
294
+ export { _sfc_main as default };
@@ -0,0 +1,80 @@
1
+ import { SelectOption } from "../../types.js";
2
+ import { ComboboxFilter } from "../../composables/use-combobox.js";
3
+ //#region src/components/combobox/Combobox.vue.d.ts
4
+ declare const __VLS_export: <T extends string | number>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<({
6
+ /** Options to choose from. */
7
+ options?: SelectOption<T>[];
8
+ /** Visible label, linked to the input. */
9
+ label?: string;
10
+ /** Help text under the control, announced as its description. */
11
+ hint?: string;
12
+ /** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
13
+ error?: string | boolean;
14
+ /** Input placeholder. */
15
+ placeholder?: string;
16
+ /** Pick several; `v-model` becomes an array, shown as chips. Backspace removes the last one. */
17
+ multiple?: boolean;
18
+ /** Enter on text matching no option emits `create` with it. */
19
+ creatable?: boolean;
20
+ /** Appends the `optional` translation to the label. */
21
+ optional?: boolean;
22
+ /** Disables the control. */
23
+ disabled?: boolean;
24
+ /** Custom match for each option against the lower-cased query. By default, labels are ranked exact, then prefix, then substring. */
25
+ filter?: ComboboxFilter<T>;
26
+ /** Show `options` as given, without filtering, e.g. results from a search request. */
27
+ ignoreFilter?: boolean;
28
+ /** Options are being fetched: shows the `loading` translation and marks the list busy. */
29
+ loading?: boolean;
30
+ /** Form field name: submits the value with a native form, via hidden inputs. */
31
+ name?: string;
32
+ /** Id for the input; generated with `useId()` when omitted. */
33
+ id?: string;
34
+ } & {
35
+ /** The selected value, or values with `multiple`. */
36
+ modelValue?: T | T[];
37
+ /** The input's text. Bind it to fetch options as the user types. */
38
+ query?: string;
39
+ }) & {
40
+ "onUpdate:modelValue"?: ((value: T | T[] | undefined) => any) | undefined;
41
+ onCreate?: ((query: string) => any) | undefined;
42
+ "onUpdate:query"?: ((value: string) => any) | undefined;
43
+ }> & (typeof globalThis extends {
44
+ __VLS_PROPS_FALLBACK: infer P;
45
+ } ? P : {});
46
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
47
+ focus: () => void | undefined;
48
+ }>) => void;
49
+ attrs: any;
50
+ slots: {
51
+ /** Option content. */
52
+ option?(props: {
53
+ option: SelectOption<T>;
54
+ selected: boolean;
55
+ active: boolean;
56
+ }): unknown;
57
+ /** Each selected value in `multiple` mode. Call `remove` to deselect it. */
58
+ chip?(props: {
59
+ option: SelectOption<T>;
60
+ remove: () => void;
61
+ }): unknown;
62
+ /** Shown when nothing matches. */
63
+ empty?(props: {
64
+ query: string;
65
+ }): unknown;
66
+ /** Shown with `creatable` when Enter would create the typed value. */
67
+ create?(props: {
68
+ query: string;
69
+ }): unknown;
70
+ /** Shown while `loading`. */
71
+ loading?(): unknown;
72
+ };
73
+ emit: ((evt: "create", query: string) => void) & (((event: "update:modelValue", value: T | T[] | undefined) => void) & ((event: "update:query", value: string) => void));
74
+ }>) => import("vue").VNode & {
75
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
76
+ };
77
+ declare const _default: typeof __VLS_export;
78
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
79
+ //#endregion
80
+ export { _default as default };