@humanonlyweb/ui 0.0.0-stage → 0.2.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 (168) 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/breadcrumbs/Breadcrumbs.js +59 -0
  12. package/dist/components/breadcrumbs/Breadcrumbs.vue.d.ts +14 -0
  13. package/dist/components/button/Button.js +95 -0
  14. package/dist/components/button/Button.vue.d.ts +74 -0
  15. package/dist/components/button/IconButton.js +47 -0
  16. package/dist/components/button/IconButton.vue.d.ts +115 -0
  17. package/dist/components/checkbox/Checkbox.js +93 -0
  18. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  19. package/dist/components/checkbox-group/CheckboxGroup.js +89 -0
  20. package/dist/components/checkbox-group/CheckboxGroup.vue.d.ts +43 -0
  21. package/dist/components/combobox/Combobox.js +294 -0
  22. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  23. package/dist/components/context-menu/ContextMenu.js +170 -0
  24. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  25. package/dist/components/dialog/ConfirmDialog.js +103 -0
  26. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  27. package/dist/components/dialog/Dialog.js +160 -0
  28. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  29. package/dist/components/field/FieldMessage.js +31 -0
  30. package/dist/components/fieldset/Fieldset.js +59 -0
  31. package/dist/components/fieldset/Fieldset.vue.d.ts +29 -0
  32. package/dist/components/input/Input.js +111 -0
  33. package/dist/components/input/Input.vue.d.ts +50 -0
  34. package/dist/components/kbd/Kbd.js +48 -0
  35. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  36. package/dist/components/menu/Menu.js +124 -0
  37. package/dist/components/menu/Menu.vue.d.ts +41 -0
  38. package/dist/components/otp-input/OtpInput.js +179 -0
  39. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  40. package/dist/components/pagination/Pagination.js +128 -0
  41. package/dist/components/pagination/Pagination.vue.d.ts +24 -0
  42. package/dist/components/password-input/PasswordInput.js +151 -0
  43. package/dist/components/password-input/PasswordInput.vue.d.ts +32 -0
  44. package/dist/components/popover/Popover.js +83 -0
  45. package/dist/components/popover/Popover.vue.d.ts +37 -0
  46. package/dist/components/progress/Progress.js +52 -0
  47. package/dist/components/progress/Progress.vue.d.ts +17 -0
  48. package/dist/components/radio-group/RadioGroup.js +125 -0
  49. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  50. package/dist/components/segmented/Segmented.js +110 -0
  51. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  52. package/dist/components/select/Select.js +231 -0
  53. package/dist/components/select/Select.vue.d.ts +59 -0
  54. package/dist/components/slider/Slider.js +196 -0
  55. package/dist/components/slider/Slider.vue.d.ts +49 -0
  56. package/dist/components/spin-button/SpinButton.js +231 -0
  57. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  58. package/dist/components/split-button/SplitButton.js +69 -0
  59. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  60. package/dist/components/switch/Switch.js +95 -0
  61. package/dist/components/switch/Switch.vue.d.ts +42 -0
  62. package/dist/components/table/Table.js +173 -0
  63. package/dist/components/table/Table.vue.d.ts +45 -0
  64. package/dist/components/tabs/Tabs.js +103 -0
  65. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  66. package/dist/components/tag-input/TagInput.js +186 -0
  67. package/dist/components/tag-input/TagInput.vue.d.ts +36 -0
  68. package/dist/components/textarea/Textarea.js +118 -0
  69. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  70. package/dist/components/toast/ToastItem.js +91 -0
  71. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  72. package/dist/components/toast/ToastViewport.js +56 -0
  73. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  74. package/dist/components/toolbar/Toolbar.js +91 -0
  75. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  76. package/dist/components/tooltip/Tooltip.js +85 -0
  77. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  78. package/dist/components/visually-hidden/VisuallyHidden.js +16 -0
  79. package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +19 -0
  80. package/dist/composables/internal/env.js +5 -0
  81. package/dist/composables/internal/is-equal.js +14 -0
  82. package/dist/composables/internal/on-click-outside.js +18 -0
  83. package/dist/composables/internal/standard-schema.d.ts +38 -0
  84. package/dist/composables/internal/use-document-visibility.js +16 -0
  85. package/dist/composables/internal/use-event-listener.js +24 -0
  86. package/dist/composables/internal/use-interval-fn.js +21 -0
  87. package/dist/composables/internal/use-resize-observer.js +21 -0
  88. package/dist/composables/internal/use-timeout-fn.js +25 -0
  89. package/dist/composables/use-accordion.d.ts +9 -0
  90. package/dist/composables/use-accordion.js +10 -0
  91. package/dist/composables/use-combobox.d.ts +44 -0
  92. package/dist/composables/use-combobox.js +185 -0
  93. package/dist/composables/use-field.d.ts +17 -0
  94. package/dist/composables/use-field.js +27 -0
  95. package/dist/composables/use-form.d.ts +44 -0
  96. package/dist/composables/use-form.js +146 -0
  97. package/dist/composables/use-menu.d.ts +26 -0
  98. package/dist/composables/use-menu.js +117 -0
  99. package/dist/composables/use-platform.d.ts +17 -0
  100. package/dist/composables/use-platform.js +126 -0
  101. package/dist/composables/use-popover.d.ts +35 -0
  102. package/dist/composables/use-popover.js +49 -0
  103. package/dist/composables/use-roving-selection.d.ts +22 -0
  104. package/dist/composables/use-roving-selection.js +65 -0
  105. package/dist/composables/use-select.d.ts +31 -0
  106. package/dist/composables/use-select.js +169 -0
  107. package/dist/composables/use-slide-indicator.d.ts +24 -0
  108. package/dist/composables/use-slide-indicator.js +52 -0
  109. package/dist/composables/use-toast.d.ts +23 -0
  110. package/dist/composables/use-toast.js +51 -0
  111. package/dist/config.d.ts +40 -0
  112. package/dist/config.js +35 -0
  113. package/dist/docs/README.md +52 -0
  114. package/dist/docs/changelog.md +21 -0
  115. package/dist/docs/components/accordion.md +100 -0
  116. package/dist/docs/components/avatar-group.md +58 -0
  117. package/dist/docs/components/avatar.md +40 -0
  118. package/dist/docs/components/breadcrumbs.md +81 -0
  119. package/dist/docs/components/button.md +109 -0
  120. package/dist/docs/components/checkbox-group.md +118 -0
  121. package/dist/docs/components/checkbox.md +123 -0
  122. package/dist/docs/components/combobox.md +207 -0
  123. package/dist/docs/components/confirm-dialog.md +107 -0
  124. package/dist/docs/components/context-menu.md +98 -0
  125. package/dist/docs/components/dialog.md +127 -0
  126. package/dist/docs/components/fieldset.md +65 -0
  127. package/dist/docs/components/icon-button.md +47 -0
  128. package/dist/docs/components/input.md +89 -0
  129. package/dist/docs/components/kbd.md +41 -0
  130. package/dist/docs/components/menu.md +112 -0
  131. package/dist/docs/components/otp-input.md +92 -0
  132. package/dist/docs/components/pagination.md +62 -0
  133. package/dist/docs/components/password-input.md +55 -0
  134. package/dist/docs/components/popover.md +72 -0
  135. package/dist/docs/components/progress.md +56 -0
  136. package/dist/docs/components/radio-group.md +114 -0
  137. package/dist/docs/components/segmented.md +96 -0
  138. package/dist/docs/components/select.md +129 -0
  139. package/dist/docs/components/slider.md +105 -0
  140. package/dist/docs/components/spin-button.md +73 -0
  141. package/dist/docs/components/split-button.md +64 -0
  142. package/dist/docs/components/switch.md +71 -0
  143. package/dist/docs/components/table.md +241 -0
  144. package/dist/docs/components/tabs.md +106 -0
  145. package/dist/docs/components/tag-input.md +88 -0
  146. package/dist/docs/components/textarea.md +46 -0
  147. package/dist/docs/components/toast.md +135 -0
  148. package/dist/docs/components/toolbar.md +71 -0
  149. package/dist/docs/components/tooltip.md +57 -0
  150. package/dist/docs/components/visually-hidden.md +53 -0
  151. package/dist/docs/forms.md +182 -0
  152. package/dist/docs/index.md +11 -0
  153. package/dist/docs/installation.md +71 -0
  154. package/dist/docs/localisation.md +42 -0
  155. package/dist/docs/ssr.md +24 -0
  156. package/dist/docs/styling.md +82 -0
  157. package/dist/index.d.ts +60 -0
  158. package/dist/index.js +56 -0
  159. package/dist/nuxt/module.d.ts +15 -0
  160. package/dist/nuxt/module.js +80 -0
  161. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  162. package/dist/nuxt/runtime/plugin.js +24 -0
  163. package/dist/package.js +4 -0
  164. package/dist/styles/core.css +310 -0
  165. package/dist/translations.d.ts +85 -0
  166. package/dist/translations.js +62 -0
  167. package/dist/types.d.ts +69 -0
  168. package/package.json +93 -4
@@ -0,0 +1,231 @@
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 { useEventListener } from "../../composables/internal/use-event-listener.js";
5
+ import { useTimeoutFn } from "../../composables/internal/use-timeout-fn.js";
6
+ import { useIntervalFn } from "../../composables/internal/use-interval-fn.js";
7
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, ref, renderSlot, toDisplayString, unref, useModel, useTemplateRef } from "vue";
8
+ //#region src/components/spin-button/SpinButton.vue
9
+ const _hoisted_1 = ["data-field-error"];
10
+ const _hoisted_2 = ["for"];
11
+ const _hoisted_3 = {
12
+ key: 0,
13
+ "data-part": "field-optional"
14
+ };
15
+ const _hoisted_4 = ["data-spinbutton-error", "data-spinbutton-disabled"];
16
+ const _hoisted_5 = ["aria-label", "disabled"];
17
+ const _hoisted_6 = [
18
+ "id",
19
+ "value",
20
+ "disabled",
21
+ "aria-valuenow",
22
+ "aria-valuemin",
23
+ "aria-valuemax",
24
+ "aria-invalid",
25
+ "aria-describedby"
26
+ ];
27
+ const _hoisted_7 = ["aria-label", "disabled"];
28
+ const REPEAT_DELAY = 400;
29
+ const REPEAT_INTERVAL = 60;
30
+ const _sfc_main = /*@__PURE__*/ defineComponent({
31
+ inheritAttrs: false,
32
+ __name: "SpinButton",
33
+ props: /*@__PURE__*/ mergeModels({
34
+ id: {},
35
+ min: { default: () => Number.NEGATIVE_INFINITY },
36
+ max: { default: () => Number.POSITIVE_INFINITY },
37
+ step: { default: 1 },
38
+ hint: {},
39
+ label: {},
40
+ optional: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ disabled: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ error: { type: [String, Boolean] }
49
+ }, {
50
+ "modelValue": {},
51
+ "modelModifiers": {}
52
+ }),
53
+ emits: ["update:modelValue"],
54
+ setup(__props, { expose: __expose }) {
55
+ /** The value. `undefined` while the input is empty. */
56
+ const model = useModel(__props, "modelValue");
57
+ const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
58
+ id: () => __props.id,
59
+ hint: () => __props.hint,
60
+ error: () => __props.error
61
+ });
62
+ const translations = useTranslations();
63
+ const pageStep = computed(() => __props.step * 10);
64
+ const decimals = computed(() => String(__props.step).split(".")[1]?.length ?? 0);
65
+ function clamp(value) {
66
+ const bounded = Math.min(__props.max, Math.max(__props.min, value));
67
+ return decimals.value ? Number(bounded.toFixed(decimals.value)) : bounded;
68
+ }
69
+ const draft = ref(null);
70
+ const inputValue = computed(() => {
71
+ if (draft.value !== null) return draft.value;
72
+ return model.value == null ? "" : String(model.value);
73
+ });
74
+ function onInput(event) {
75
+ if (!(event.target instanceof HTMLInputElement)) return;
76
+ const raw = event.target.value;
77
+ draft.value = raw;
78
+ const parsed = Number.parseFloat(raw);
79
+ model.value = Number.isNaN(parsed) ? void 0 : parsed;
80
+ }
81
+ function onBlur() {
82
+ draft.value = null;
83
+ if (model.value != null) model.value = clamp(model.value);
84
+ }
85
+ function commit(value) {
86
+ if (__props.disabled) return;
87
+ model.value = clamp(value);
88
+ draft.value = null;
89
+ }
90
+ function nudge(direction, amount = __props.step) {
91
+ const base = model.value ?? (Number.isFinite(__props.min) ? __props.min : 0);
92
+ commit(model.value == null ? base : base + direction * amount);
93
+ }
94
+ const atMin = computed(() => model.value != null && model.value <= __props.min);
95
+ const atMax = computed(() => model.value != null && model.value >= __props.max);
96
+ function onKeydown(event) {
97
+ const action = {
98
+ ArrowUp: () => nudge(1),
99
+ ArrowDown: () => nudge(-1),
100
+ PageUp: () => nudge(1, pageStep.value),
101
+ PageDown: () => nudge(-1, pageStep.value),
102
+ Home: () => {
103
+ if (Number.isFinite(__props.min)) commit(__props.min);
104
+ },
105
+ End: () => {
106
+ if (Number.isFinite(__props.max)) commit(__props.max);
107
+ }
108
+ }[event.key];
109
+ if (!action) return;
110
+ event.preventDefault();
111
+ action();
112
+ }
113
+ let heldDirection = 1;
114
+ const repeat = useIntervalFn(() => nudge(heldDirection), REPEAT_INTERVAL);
115
+ const repeatDelay = useTimeoutFn(repeat.resume, REPEAT_DELAY);
116
+ function stopRepeat() {
117
+ repeatDelay.stop();
118
+ repeat.pause();
119
+ }
120
+ for (const type of [
121
+ "pointerup",
122
+ "pointercancel",
123
+ "blur"
124
+ ]) useEventListener(() => window, type, stopRepeat);
125
+ function onPointerdown(event, direction) {
126
+ if (event.button !== 0) return;
127
+ if (event.currentTarget instanceof HTMLElement) event.currentTarget.setPointerCapture(event.pointerId);
128
+ heldDirection = direction;
129
+ nudge(direction);
130
+ repeatDelay.start();
131
+ }
132
+ function onClick(event, direction) {
133
+ if (event.detail === 0) nudge(direction);
134
+ }
135
+ const inputRef = useTemplateRef("input");
136
+ __expose({ focus: () => inputRef.value?.focus() });
137
+ return (_ctx, _cache) => {
138
+ return openBlock(), createElementBlock("div", {
139
+ "data-part": "field",
140
+ "data-field-error": unref(isError) || void 0
141
+ }, [
142
+ __props.label ? (openBlock(), createElementBlock("label", {
143
+ key: 0,
144
+ for: unref(id),
145
+ "data-part": "field-label"
146
+ }, [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),
147
+ createElementVNode("div", {
148
+ "data-part": "spinbutton",
149
+ "data-spinbutton-error": unref(isError) || void 0,
150
+ "data-spinbutton-disabled": __props.disabled || void 0
151
+ }, [
152
+ createCommentVNode(" Out of the tab order: the arrow keys on the input do the same, and the\n buttons are a pointer convenience. "),
153
+ createElementVNode("button", {
154
+ type: "button",
155
+ tabindex: "-1",
156
+ "aria-label": unref(translations).decrease,
157
+ "data-part": "spinbutton-decrement",
158
+ disabled: __props.disabled || atMin.value,
159
+ onPointerdown: _cache[0] || (_cache[0] = ($event) => onPointerdown($event, -1)),
160
+ onClick: _cache[1] || (_cache[1] = ($event) => onClick($event, -1))
161
+ }, [renderSlot(_ctx.$slots, "decrement", {}, () => [_cache[4] || (_cache[4] = createElementVNode("svg", {
162
+ viewBox: "0 0 16 16",
163
+ width: "14",
164
+ height: "14",
165
+ "aria-hidden": "true",
166
+ focusable: "false"
167
+ }, [createElementVNode("path", {
168
+ d: "M4 8h8",
169
+ stroke: "currentColor",
170
+ "stroke-width": "1.5",
171
+ "stroke-linecap": "round"
172
+ })], -1))])], 40, _hoisted_5),
173
+ createElementVNode("input", mergeProps({
174
+ id: unref(id),
175
+ ref: "input",
176
+ type: "text",
177
+ role: "spinbutton",
178
+ inputmode: "decimal",
179
+ autocomplete: "off",
180
+ spellcheck: "false"
181
+ }, _ctx.$attrs, {
182
+ value: inputValue.value,
183
+ disabled: __props.disabled,
184
+ "aria-valuenow": model.value,
185
+ "aria-valuemin": Number.isFinite(__props.min) ? __props.min : void 0,
186
+ "aria-valuemax": Number.isFinite(__props.max) ? __props.max : void 0,
187
+ "aria-invalid": unref(isError) || void 0,
188
+ "aria-describedby": unref(describedBy),
189
+ "data-part": "spinbutton-input",
190
+ onInput,
191
+ onBlur,
192
+ onKeydown
193
+ }), null, 16, _hoisted_6),
194
+ createElementVNode("button", {
195
+ type: "button",
196
+ tabindex: "-1",
197
+ "aria-label": unref(translations).increase,
198
+ "data-part": "spinbutton-increment",
199
+ disabled: __props.disabled || atMax.value,
200
+ onPointerdown: _cache[2] || (_cache[2] = ($event) => onPointerdown($event, 1)),
201
+ onClick: _cache[3] || (_cache[3] = ($event) => onClick($event, 1))
202
+ }, [renderSlot(_ctx.$slots, "increment", {}, () => [_cache[5] || (_cache[5] = createElementVNode("svg", {
203
+ viewBox: "0 0 16 16",
204
+ width: "14",
205
+ height: "14",
206
+ "aria-hidden": "true",
207
+ focusable: "false"
208
+ }, [createElementVNode("path", {
209
+ d: "M4 8h8M8 4v8",
210
+ stroke: "currentColor",
211
+ "stroke-width": "1.5",
212
+ "stroke-linecap": "round"
213
+ })], -1))])], 40, _hoisted_7)
214
+ ], 8, _hoisted_4),
215
+ createVNode(_sfc_main$1, {
216
+ "error-id": unref(errorId),
217
+ "hint-id": unref(hintId),
218
+ "error-message": unref(errorMessage),
219
+ hint: __props.hint
220
+ }, null, 8, [
221
+ "error-id",
222
+ "hint-id",
223
+ "error-message",
224
+ "hint"
225
+ ])
226
+ ], 8, _hoisted_1);
227
+ };
228
+ }
229
+ });
230
+ //#endregion
231
+ export { _sfc_main as default };
@@ -0,0 +1,48 @@
1
+ //#region src/components/spin-button/SpinButton.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Id for the control; generated with `useId()` when omitted. */
4
+ id?: string;
5
+ /** Lowest value. Home jumps here. */
6
+ min?: number;
7
+ /** Highest value. End jumps here. */
8
+ max?: number;
9
+ /** Arrow-key and button increment; PageUp/PageDown move ten steps. Its decimals set the rounding. */
10
+ step?: number;
11
+ /** Help text under the control, announced as its description. */
12
+ hint?: string;
13
+ /** Visible label, linked to the control. */
14
+ label?: string;
15
+ /** Appends the `optional` translation to the label. */
16
+ optional?: boolean;
17
+ /** Disables the control. */
18
+ disabled?: boolean;
19
+ /** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
20
+ error?: string | boolean;
21
+ };
22
+ type __VLS_Slots = {
23
+ /** Decrease button icon. */
24
+ decrement?(): unknown;
25
+ /** Increase button icon. */
26
+ increment?(): unknown;
27
+ };
28
+ type __VLS_ModelProps = {
29
+ /** The value. `undefined` while the input is empty. */
30
+ modelValue?: number;
31
+ };
32
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
33
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
34
+ focus: () => void | undefined;
35
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
36
+ "update:modelValue": (value: number | undefined) => any;
37
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
38
+ "onUpdate:modelValue"?: ((value: number | undefined) => any) | undefined;
39
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
41
+ declare const _default: typeof __VLS_export;
42
+ type __VLS_WithSlots<T, S> = T & {
43
+ new (): {
44
+ $slots: S;
45
+ };
46
+ };
47
+ //#endregion
48
+ export { _default as default };
@@ -0,0 +1,69 @@
1
+ import { computed, createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, renderSlot } from "vue";
2
+ //#region src/components/split-button/SplitButton.vue
3
+ const _hoisted_1 = ["data-split-variant"];
4
+ const _hoisted_2 = ["disabled"];
5
+ const _hoisted_3 = { "data-part": "button-label" };
6
+ const _hoisted_4 = ["disabled", "aria-label"];
7
+ const _hoisted_5 = ["data-split-open"];
8
+ const _sfc_main = /*@__PURE__*/ defineComponent({
9
+ __name: "SplitButton",
10
+ props: {
11
+ menuLabel: {},
12
+ triggerAttrs: {},
13
+ variant: { default: "secondary" },
14
+ size: { default: "medium" },
15
+ disabled: {
16
+ type: Boolean,
17
+ default: false
18
+ }
19
+ },
20
+ emits: ["action", "toggle"],
21
+ setup(__props, { emit: __emit }) {
22
+ const emit = __emit;
23
+ const isOpen = computed(() => __props.triggerAttrs?.["aria-expanded"] === true);
24
+ const sharedAttrs = computed(() => ({
25
+ "data-part": "button",
26
+ "data-button-variant": __props.variant,
27
+ "data-button-size": __props.size,
28
+ "data-button-disabled": __props.disabled || void 0
29
+ }));
30
+ return (_ctx, _cache) => {
31
+ return openBlock(), createElementBlock("div", {
32
+ "data-part": "split-button",
33
+ "data-split-variant": __props.variant
34
+ }, [createElementVNode("button", mergeProps(sharedAttrs.value, {
35
+ type: "button",
36
+ "data-split-part": "action",
37
+ disabled: __props.disabled,
38
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("action"))
39
+ }), [createElementVNode("span", _hoisted_3, [renderSlot(_ctx.$slots, "default")])], 16, _hoisted_2), createElementVNode("button", mergeProps({
40
+ ...sharedAttrs.value,
41
+ ...__props.triggerAttrs
42
+ }, {
43
+ type: "button",
44
+ "data-split-part": "toggle",
45
+ disabled: __props.disabled,
46
+ "aria-label": __props.menuLabel,
47
+ onClick: _cache[1] || (_cache[1] = ($event) => emit("toggle"))
48
+ }), [createElementVNode("span", {
49
+ "data-split-part": "caret",
50
+ "data-split-open": isOpen.value || void 0,
51
+ "aria-hidden": "true"
52
+ }, [renderSlot(_ctx.$slots, "caret", { open: isOpen.value }, () => [_cache[2] || (_cache[2] = createElementVNode("svg", {
53
+ viewBox: "0 0 16 16",
54
+ width: "14",
55
+ height: "14",
56
+ focusable: "false"
57
+ }, [createElementVNode("path", {
58
+ d: "M4 6l4 4 4-4",
59
+ fill: "none",
60
+ stroke: "currentColor",
61
+ "stroke-width": "1.5",
62
+ "stroke-linecap": "round",
63
+ "stroke-linejoin": "round"
64
+ })], -1))])], 8, _hoisted_5)], 16, _hoisted_4)], 8, _hoisted_1);
65
+ };
66
+ }
67
+ });
68
+ //#endregion
69
+ export { _sfc_main as default };
@@ -0,0 +1,38 @@
1
+ import { ButtonSize, ButtonVariant } from "../../types.js";
2
+ //#region src/components/split-button/SplitButton.vue.d.ts
3
+ type __VLS_Props = {
4
+ /** Accessible name for the toggle half, e.g. "More save options". */
5
+ menuLabel: string;
6
+ /** The `attrs` from a `<Menu>` or `<Popover>` trigger slot, bound to the toggle half. */
7
+ triggerAttrs?: Record<string, unknown>;
8
+ /** Style hook, exposed as `data-button-variant` on both halves. */
9
+ variant?: Exclude<ButtonVariant, "link">;
10
+ /** Size hook, exposed as `data-button-size` on both halves. */
11
+ size?: Exclude<ButtonSize, "large">;
12
+ /** Disables both halves. */
13
+ disabled?: boolean;
14
+ };
15
+ type __VLS_Slots = {
16
+ /** Main action label. */
17
+ default?(): unknown;
18
+ /** Replaces the toggle's chevron. */
19
+ caret?(props: {
20
+ open: boolean;
21
+ }): unknown;
22
+ };
23
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
+ action: () => any;
25
+ toggle: () => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
+ onAction?: (() => any) | undefined;
28
+ onToggle?: (() => any) | undefined;
29
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
31
+ declare const _default: typeof __VLS_export;
32
+ type __VLS_WithSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
37
+ //#endregion
38
+ export { _default as default };
@@ -0,0 +1,95 @@
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 } from "vue";
4
+ //#region src/components/switch/Switch.vue
5
+ const _hoisted_1 = [
6
+ "id",
7
+ "aria-checked",
8
+ "aria-invalid",
9
+ "aria-describedby",
10
+ "disabled",
11
+ "data-switch-size",
12
+ "data-switch-checked",
13
+ "data-switch-error",
14
+ "data-field-name"
15
+ ];
16
+ const _hoisted_2 = {
17
+ key: 0,
18
+ "data-part": "switch-label"
19
+ };
20
+ const _hoisted_3 = ["name", "value"];
21
+ const _sfc_main = /*@__PURE__*/ defineComponent({
22
+ inheritAttrs: false,
23
+ __name: "Switch",
24
+ props: /*@__PURE__*/ mergeModels({
25
+ disabled: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ label: {},
30
+ size: { default: "medium" },
31
+ hint: {},
32
+ error: { type: [String, Boolean] },
33
+ name: {},
34
+ value: { default: "on" },
35
+ id: {}
36
+ }, {
37
+ "modelValue": {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ "modelModifiers": {}
42
+ }),
43
+ emits: ["update:modelValue"],
44
+ setup(__props) {
45
+ /** On or off. */
46
+ const model = useModel(__props, "modelValue");
47
+ const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
48
+ id: () => __props.id,
49
+ hint: () => __props.hint,
50
+ error: () => __props.error
51
+ });
52
+ return (_ctx, _cache) => {
53
+ return openBlock(), createElementBlock(Fragment, null, [
54
+ createElementVNode("button", mergeProps({
55
+ id: unref(id),
56
+ type: "button",
57
+ role: "switch",
58
+ "data-part": "switch",
59
+ "aria-checked": model.value,
60
+ "aria-invalid": unref(isError) || void 0,
61
+ "aria-describedby": unref(describedBy),
62
+ disabled: __props.disabled,
63
+ "data-switch-size": __props.size,
64
+ "data-switch-checked": model.value || void 0,
65
+ "data-switch-error": unref(isError) || void 0,
66
+ "data-field-name": __props.name
67
+ }, _ctx.$attrs, { onClick: _cache[0] || (_cache[0] = ($event) => model.value = !model.value) }), [_cache[1] || (_cache[1] = createElementVNode("span", {
68
+ "data-part": "switch-track",
69
+ "aria-hidden": "true"
70
+ }, [createElementVNode("span", { "data-part": "switch-thumb" })], -1)), _ctx.$slots.default || __props.label ? (openBlock(), createElementBlock("span", _hoisted_2, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.label), 1)])])) : createCommentVNode("v-if", true)], 16, _hoisted_1),
71
+ createCommentVNode(" A sibling, not a wrapper: without a hint or error the markup is just the button. "),
72
+ createVNode(_sfc_main$1, {
73
+ "error-id": unref(errorId),
74
+ "hint-id": unref(hintId),
75
+ "error-message": unref(errorMessage),
76
+ hint: __props.hint
77
+ }, null, 8, [
78
+ "error-id",
79
+ "hint-id",
80
+ "error-message",
81
+ "hint"
82
+ ]),
83
+ createCommentVNode(" The switch is a button, which doesn't submit a value; a hidden input does. "),
84
+ __props.name && model.value ? (openBlock(), createElementBlock("input", {
85
+ key: 0,
86
+ type: "hidden",
87
+ name: __props.name,
88
+ value: __props.value
89
+ }, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
90
+ ], 64);
91
+ };
92
+ }
93
+ });
94
+ //#endregion
95
+ export { _sfc_main as default };
@@ -0,0 +1,42 @@
1
+ //#region src/components/switch/Switch.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Disables the switch. */
4
+ disabled?: boolean;
5
+ /** Text next to the switch. The default slot overrides it. */
6
+ label?: string;
7
+ /** Size hook, exposed as `data-switch-size`. */
8
+ size?: "small" | "medium";
9
+ /** Help text under the switch, announced as its description. */
10
+ hint?: string;
11
+ /** `true` marks it invalid; a string also shows it as the message, replacing the hint. */
12
+ error?: string | boolean;
13
+ /** Form field name: while on, a native form submits `value` under it. */
14
+ name?: string;
15
+ /** What a native form submits while on, as a checkbox would. */
16
+ value?: string;
17
+ /** Id for the switch; generated with `useId()` when omitted. */
18
+ id?: string;
19
+ };
20
+ type __VLS_Slots = {
21
+ /** Label content, replacing `label`. */
22
+ default?(): unknown;
23
+ };
24
+ type __VLS_ModelProps = {
25
+ /** On or off. */
26
+ modelValue?: boolean;
27
+ };
28
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
29
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ "update:modelValue": (value: boolean) => any;
31
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
32
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
33
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
35
+ declare const _default: typeof __VLS_export;
36
+ type __VLS_WithSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
41
+ //#endregion
42
+ export { _default as default };