@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,127 @@
1
+ # Dialog
2
+
3
+ > A modal dialog.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const open = ref(false);
12
+ </script>
13
+
14
+ <template>
15
+ <UiButton variant="secondary" @click="open = true">Open dialog</UiButton>
16
+
17
+ <UiDialog v-model:open="open" title="Keyboard shortcuts" description="Work faster with these.">
18
+ <ul class="demo-list">
19
+ <li>Search <UiKbd keys="mod+k" size="small" /></li>
20
+ <li>Save <UiKbd keys="mod+s" size="small" /></li>
21
+ <li>Close <UiKbd keys="esc" size="small" /></li>
22
+ </ul>
23
+ </UiDialog>
24
+ </template>
25
+ ```
26
+
27
+ ### Form
28
+
29
+ The footer slot gets a `close` function.
30
+
31
+ ```vue
32
+ <script setup lang="ts">
33
+ const open = ref(false);
34
+ const name = ref("Acme Inc.");
35
+ const toast = useToast();
36
+
37
+ function save(close: () => void) {
38
+ toast.success(`Renamed to ${name.value}`);
39
+ close();
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <UiButton @click="open = true">Rename workspace</UiButton>
45
+
46
+ <UiDialog v-model:open="open" title="Rename workspace" size="sm">
47
+ <UiInput v-model="name" label="Workspace name" autofocus />
48
+
49
+ <template #footer="{ close }">
50
+ <UiButton variant="ghost" @click="close">Cancel</UiButton>
51
+ <UiButton @click="save(close)">Save</UiButton>
52
+ </template>
53
+ </UiDialog>
54
+ </template>
55
+ ```
56
+
57
+ ### Required step
58
+
59
+ With `dismissible` off, Escape, the backdrop and the × button do nothing; only your own buttons close it.
60
+
61
+ ```vue
62
+ <script setup lang="ts">
63
+ const open = ref(false);
64
+ const accepted = ref(false);
65
+ </script>
66
+
67
+ <template>
68
+ <UiButton variant="secondary" @click="open = true">Review terms</UiButton>
69
+
70
+ <UiDialog
71
+ v-model:open="open"
72
+ title="We've updated our terms"
73
+ description="Accept them to keep using your account."
74
+ size="sm"
75
+ :dismissible="false"
76
+ >
77
+ <UiCheckbox v-model="accepted" label="I accept the new terms" />
78
+
79
+ <template #footer="{ close }">
80
+ <UiButton :disabled="!accepted" @click="close">Continue</UiButton>
81
+ </template>
82
+ </UiDialog>
83
+ </template>
84
+ ```
85
+
86
+ ## API
87
+
88
+ | Prop | Type | Default | Description |
89
+ | --- | --- | --- | --- |
90
+ | `title` | `string` | — | Heading, which names the dialog. |
91
+ | `label` | `string` | — | Accessible name when there's no visible `title`. |
92
+ | `description` | `string` | — | Supporting text, announced as the dialog's description. |
93
+ | `dismissible` | `boolean` | `true` | Whether Escape, the backdrop and the header's close button can close it. The slots' `close` always can. |
94
+ | `size` | `"lg" \| "md" \| "sm" \| "xl"` | `"md"` | Size hook, exposed as `data-dialog-size`. |
95
+ | `flush` | `boolean` | `false` | Layout hook for edge-to-edge content, exposed as `data-dialog-flush`. |
96
+ | `closeOnBackdrop` | `boolean` | `true` | Close when the backdrop is clicked. |
97
+ | `showCloseButton` | `boolean` | `true` | Render the header's close button. |
98
+ | `open` | `boolean` | `false` | Whether the dialog is open. |
99
+
100
+ | Event | Payload | Description |
101
+ | --- | --- | --- |
102
+ | `close` | `[]` | Closed by any means. |
103
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
104
+
105
+ | Slot | Props | Description |
106
+ | --- | --- | --- |
107
+ | `default` | `{ close: () => void; }` | Body content. Mounted on first open. |
108
+ | `header` | — | Replaces the title and description. |
109
+ | `footer` | `{ close: () => void; }` | Actions, e.g. buttons. |
110
+ | `close-icon` | — | Replaces the close button's icon. |
111
+
112
+ ## Styling
113
+
114
+ - Parts (`[data-part="…"]`): `dialog`, `dialog-panel`, `dialog-header`, `dialog-header-text`, `dialog-title`, `dialog-description`, `dialog-close`, `dialog-body`, `dialog-footer`
115
+ - State attributes: `data-dialog-size`, `data-dialog-flush`
116
+
117
+ ## Keyboard
118
+
119
+ | Keys | Action |
120
+ | -------- | -------------------------- |
121
+ | `Escape` | Close (when `dismissible`) |
122
+ | `Tab` | Cycle within the dialog |
123
+
124
+ ## Accessibility
125
+
126
+ - The page behind is inert and doesn't scroll; focus returns to the opener on close.
127
+ - Named by `title`, or `label` without one.
@@ -0,0 +1,65 @@
1
+ # Fieldset
2
+
3
+ > Groups related controls under one legend.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const street = ref("");
12
+ const city = ref("");
13
+ </script>
14
+
15
+ <template>
16
+ <UiFieldset class="demo-form" legend="Shipping address" hint="Where should we send it?">
17
+ <UiInput v-model="street" label="Street" />
18
+ <UiInput v-model="city" label="City" />
19
+ </UiFieldset>
20
+ </template>
21
+ ```
22
+
23
+ ### Disabled
24
+
25
+ A disabled `<fieldset>` disables the native controls inside it.
26
+
27
+ ```vue
28
+ <script setup lang="ts">
29
+ const street = ref("12 Baker Street");
30
+ const city = ref("London");
31
+ </script>
32
+
33
+ <template>
34
+ <UiFieldset class="demo-form" legend="Shipping address" disabled>
35
+ <UiInput v-model="street" label="Street" />
36
+ <UiInput v-model="city" label="City" />
37
+ </UiFieldset>
38
+ </template>
39
+ ```
40
+
41
+ ## API
42
+
43
+ | Prop | Type | Default | Description |
44
+ | --- | --- | --- | --- |
45
+ | `legend` | `string` | — | Text inside the `<legend>`, naming the group. |
46
+ | `hint` | `string` | — | Help text under the legend, announced as the group's description. |
47
+ | `error` | `string \| boolean` | — | `true` marks the group invalid; a string also shows it as the message, replacing the hint. |
48
+ | `disabled` | `boolean` | `false` | Disables the group: native controls inside it too. |
49
+ | `id` | `string` | — | Id for the `<fieldset>`; generated with `useId()` when omitted. |
50
+
51
+ | Slot | Props | Description |
52
+ | --- | --- | --- |
53
+ | `default` | — | The grouped controls. |
54
+ | `legend` | `{}` | Legend content, replacing `legend`. |
55
+
56
+ ## Styling
57
+
58
+ - Parts (`[data-part="…"]`): `fieldset`, `fieldset-legend`, `field-message`
59
+ - State attributes: `data-field-error`, `data-field-tone`
60
+
61
+ ## Accessibility
62
+
63
+ - It's a native `<fieldset>` with a `<legend>`, so assistive tech announces the group's name with every control inside it.
64
+ - `hint` and `error` are the fieldset's description: `aria-describedby` points at the message.
65
+ - Native `<fieldset disabled>` only disables native controls. Components built on buttons (e.g. a segmented control) need their own `disabled`.
@@ -0,0 +1,47 @@
1
+ # Icon Button
2
+
3
+ > A button with only an icon.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="demo-row">
12
+ <UiIconButton label="Settings"><Icon name="settings" /></UiIconButton>
13
+ <UiIconButton label="Add" variant="secondary"><Icon name="plus" /></UiIconButton>
14
+ <UiIconButton label="Delete" variant="danger" shape="round"><Icon name="trash" /></UiIconButton>
15
+ </div>
16
+ </template>
17
+ ```
18
+
19
+ ## API
20
+
21
+ | Prop | Type | Default | Description |
22
+ | --- | --- | --- | --- |
23
+ | `variant` | `"primary" \| "secondary" \| "solid" \| "ghost" \| "danger" \| "link"` | `"ghost"` | Style hook, exposed as `data-button-variant`. |
24
+ | `size` | `"small" \| "medium" \| "large"` | — | Size hook, exposed as `data-button-size`. |
25
+ | `fullWidth` | `boolean` | — | Layout hook, exposed as `data-button-full-width`. |
26
+ | `loading` | `boolean` | — | Busy state: blocks clicks and sets `aria-busy`, but stays focusable. |
27
+ | `disabled` | `boolean` | — | Disables the button. A disabled link loses its `href` and leaves the tab order. |
28
+ | `type` | `"button" \| "submit" \| "reset"` | — | Native button type. |
29
+ | `href` | `string` | — | Renders an `<a>` to this URL instead of a `<button>`. |
30
+ | `to` | `string \| Record<string, unknown>` | — | Route for the router link given to `createUi({ link })`, rendering it instead of a `<button>`. |
31
+ | `target` | `"_blank" \| "_self" \| "_parent" \| "_top"` | — | Link target. |
32
+ | `label` (required) | `string` | — | Accessible name; icon-only buttons have no visible text to supply one. |
33
+ | `shape` | `"round" \| "square"` | — | Shape hook, exposed as `data-button-shape`. |
34
+
35
+ | Slot | Props | Description |
36
+ | --- | --- | --- |
37
+ | `default` | — | The icon. |
38
+ | `spinner` | — | Shown while `loading`, in place of the icon. |
39
+
40
+ ## Styling
41
+
42
+ - Parts (`[data-part="…"]`):
43
+ - State attributes: `data-button-shape`, `data-button-icon-only`
44
+
45
+ ## Accessibility
46
+
47
+ - `label` is required: with no visible text, it's the button's only name.
@@ -0,0 +1,89 @@
1
+ # Input
2
+
3
+ > A text input with label, hint and error.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const name = ref("");
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-field">
16
+ <UiInput
17
+ v-model="name"
18
+ label="Workspace name"
19
+ hint="Shown to everyone you invite."
20
+ placeholder="Acme Inc."
21
+ />
22
+ </div>
23
+ </template>
24
+ ```
25
+
26
+ ### Prefix and suffix
27
+
28
+ ```vue
29
+ <template>
30
+ <div class="demo-stack demo-field">
31
+ <UiInput label="Price" prefix="$" suffix="USD" type="number" placeholder="0.00" />
32
+ <UiInput label="Search" type="search" placeholder="Find anything" optional>
33
+ <template #prefix><Icon name="search" :size="14" /></template>
34
+ </UiInput>
35
+ </div>
36
+ </template>
37
+ ```
38
+
39
+ ### Validation
40
+
41
+ ```vue
42
+ <script setup lang="ts">
43
+ const email = ref("ada@");
44
+ const error = computed(() =>
45
+ /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email.value) ? undefined : "Enter a valid email address.",
46
+ );
47
+ </script>
48
+
49
+ <template>
50
+ <div class="demo-field">
51
+ <UiInput v-model="email" type="email" label="Email" :error="error" />
52
+ </div>
53
+ </template>
54
+ ```
55
+
56
+ ## API
57
+
58
+ | Prop | Type | Default | Description |
59
+ | --- | --- | --- | --- |
60
+ | `label` | `string` | — | Visible label, linked to the control. |
61
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
62
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
63
+ | `prefix` | `string` | — | Text shown before the input, e.g. a currency sign. Hidden from assistive tech. |
64
+ | `suffix` | `string` | — | Text shown after the input, e.g. a unit. Hidden from assistive tech. |
65
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
66
+ | `disabled` | `boolean` | `false` | Disables the control. |
67
+ | `type` | `"date" \| "datetime-local" \| "email" \| "month" \| "number" \| "password" \| "search" \| "tel" \| "text" \| "time" \| "url" \| "week"` | `"text"` | Native input type. |
68
+ | `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-field-size`. |
69
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
70
+ | `modelValue` | `string \| number` | — | The value. |
71
+
72
+ | Event | Payload | Description |
73
+ | --- | --- | --- |
74
+ | `update:modelValue` | `[value: string \| number \| undefined]` | `v-model:modelValue` update. |
75
+
76
+ | Slot | Props | Description |
77
+ | --- | --- | --- |
78
+ | `prefix` | — | Replaces the `prefix` text, e.g. with an icon. |
79
+ | `suffix` | — | Replaces the `suffix` text. |
80
+
81
+ ## Styling
82
+
83
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `input-control`, `input-prefix`, `input`, `input-suffix`, `field-message`
84
+ - State attributes: `data-field-size`, `data-field-error`, `data-field-tone`
85
+
86
+ ## Accessibility
87
+
88
+ - Errors set `aria-invalid` and are announced.
89
+ - Prefix and suffix are hidden from screen readers, so the label has to make sense without them.
@@ -0,0 +1,41 @@
1
+ # Kbd
2
+
3
+ > A keyboard shortcut, shown with the user's platform keys.
4
+
5
+ ## Examples
6
+
7
+ ### Chords
8
+
9
+ `mod` is ⌘ on Apple, Ctrl elsewhere.
10
+
11
+ ```vue
12
+ <template>
13
+ <ul class="demo-list">
14
+ <li>Command palette <UiKbd keys="mod+k" /></li>
15
+ <li>Save as <UiKbd keys="mod+shift+s" /></li>
16
+ <li>New line <UiKbd keys="shift enter" /></li>
17
+ <li>Forced PC keys <UiKbd keys="mod+alt+p" platform="pc" /></li>
18
+ </ul>
19
+ </template>
20
+ ```
21
+
22
+ ## API
23
+
24
+ | Prop | Type | Default | Description |
25
+ | --- | --- | --- | --- |
26
+ | `keys` | `string` | — | Chord written as "mod+k" or "shift enter". `mod` is ⌘ on Apple, Ctrl elsewhere. |
27
+ | `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-kbd-size`. |
28
+ | `platform` | `"apple" \| "pc"` | — | Forces a platform's key caps instead of the detected one. |
29
+
30
+ | Slot | Props | Description |
31
+ | --- | --- | --- |
32
+ | `default` | — | A single literal key, when `keys` isn't set. |
33
+
34
+ ## Styling
35
+
36
+ - Parts (`[data-part="…"]`): `kbd`, `key`, `kbd-label`
37
+ - State attributes: `data-kbd-size`
38
+
39
+ ## Accessibility
40
+
41
+ - Screen readers hear key names, e.g. “Command K”.
@@ -0,0 +1,112 @@
1
+ # Menu
2
+
3
+ > A list of actions opened from a button.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ `{ separator: true }` in `items` draws a line between groups.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const toast = useToast();
14
+
15
+ const items = [
16
+ { label: "Edit", value: "edit", hint: "E" },
17
+ { label: "Duplicate", value: "duplicate", hint: "D" },
18
+ { label: "Archive", value: "archive", disabled: true },
19
+ { separator: true as const },
20
+ { label: "Delete", value: "delete", hint: "⌫" },
21
+ ];
22
+ </script>
23
+
24
+ <template>
25
+ <UiMenu :items="items" label="Actions" @select="(value) => toast.info(`Selected ${value}`)" />
26
+ </template>
27
+ ```
28
+
29
+ ### Custom trigger
30
+
31
+ Bind the slot's `attrs` to your own button.
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ const toast = useToast();
36
+ const items = [
37
+ { label: "Profile", value: "profile" },
38
+ { label: "Billing", value: "billing" },
39
+ { label: "Sign out", value: "sign-out" },
40
+ ];
41
+ </script>
42
+
43
+ <template>
44
+ <UiMenu :items="items" label="Account" align="end" @select="(value) => toast.info(value)">
45
+ <template #trigger="{ attrs }">
46
+ <UiIconButton label="Account menu" variant="secondary" v-bind="attrs">
47
+ <Icon name="more" />
48
+ </UiIconButton>
49
+ </template>
50
+ </UiMenu>
51
+ </template>
52
+ ```
53
+
54
+ ## API
55
+
56
+ | Prop | Type | Default | Description |
57
+ | --- | --- | --- | --- |
58
+ | `items` | `MenuEntry<T>[]` | `[]` | Menu items in order; `{ separator: true }` draws a line between groups. |
59
+ | `label` | `string` | — | Trigger text for the default trigger, and the menu's accessible name. Defaults to the `menu` translation. |
60
+ | `align` | `"end" \| "start"` | `"start"` | Which trigger edge the menu lines up with. Flips automatically near the viewport edge. |
61
+ | `open` | `boolean` | `false` | Whether the menu is open. |
62
+
63
+ | Event | Payload | Description |
64
+ | --- | --- | --- |
65
+ | `select` | `[value: T]` | An item was activated. |
66
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
67
+
68
+ | Slot | Props | Description |
69
+ | --- | --- | --- |
70
+ | `trigger` | `{ isOpen: boolean; attrs: Record<string, unknown>; }` | Custom trigger. Bind `attrs` to a `<button>`. |
71
+ | `item` | `{ item: MenuItem<T>; active: boolean; }` | Item content. |
72
+
73
+ Types:
74
+
75
+ ```ts
76
+ export type MenuEntry<T extends SelectValue = SelectValue> = MenuItem<T> | MenuSeparator;
77
+
78
+ export interface MenuItem<T extends SelectValue = SelectValue> extends SelectOption<T> {
79
+ /** Trailing text, e.g. a shortcut like "⌘S". Render richer content via the `item` slot. */
80
+ hint?: string;
81
+ }
82
+
83
+ export type SelectValue = string | number;
84
+
85
+ /** A line between groups of menu items. */
86
+ export interface MenuSeparator {
87
+ separator: true;
88
+ }
89
+
90
+ export interface SelectOption<T extends SelectValue = SelectValue> {
91
+ label: string;
92
+ value: T;
93
+ disabled?: boolean;
94
+ }
95
+ ```
96
+
97
+ ## Styling
98
+
99
+ - Parts (`[data-part="…"]`): `menu`, `menu-trigger`, `menu-list`, `menu-separator`, `menu-item`, `menu-item-label`, `menu-item-hint`
100
+ - State attributes: `data-menu-open`, `data-menu-align`, `data-menu-index`, `data-menu-active`
101
+
102
+ ## Keyboard
103
+
104
+ | Keys | Action |
105
+ | ----------------------- | -------------------------------------------------- |
106
+ | `Enter` / `Space` / `↓` | Open and focus the first item |
107
+ | `↑` | Open and focus the last item |
108
+ | `↓` / `↑` | Move between items, skipping disabled ones |
109
+ | `Home` / `End` | First / last item |
110
+ | Letters | Jump to an item by label; repeat a letter to cycle |
111
+ | `Escape` | Close and return focus to the trigger |
112
+ | `Tab` | Close and move on |
@@ -0,0 +1,92 @@
1
+ # OTP Input
2
+
3
+ > A one-time code input, with a slot per character.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ `complete` fires once every slot is filled, so the code can be checked without a submit button.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const toast = useToast();
14
+ const code = ref("");
15
+ const error = ref<string>();
16
+
17
+ watch(code, () => (error.value = undefined));
18
+
19
+ function verify(value: string) {
20
+ if (value === "123456") toast.success("Verified.");
21
+ else error.value = "That code didn't work.";
22
+ }
23
+ </script>
24
+
25
+ <template>
26
+ <div class="demo-field">
27
+ <UiOtpInput
28
+ v-model="code"
29
+ name="code"
30
+ label="Verification code"
31
+ hint="Try 123456."
32
+ :error="error"
33
+ @complete="verify"
34
+ />
35
+ </div>
36
+ </template>
37
+ ```
38
+
39
+ ### Groups
40
+
41
+ ```vue
42
+ <template>
43
+ <div class="demo-field">
44
+ <UiOtpInput label="Sign-in code" :group-size="3" />
45
+ </div>
46
+ </template>
47
+ ```
48
+
49
+ ### Letters and digits
50
+
51
+ ```vue
52
+ <template>
53
+ <div class="demo-field">
54
+ <UiOtpInput label="Recovery code" type="alphanumeric" :length="8" :group-size="4" />
55
+ </div>
56
+ </template>
57
+ ```
58
+
59
+ ## API
60
+
61
+ | Prop | Type | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `label` | `string` | — | Visible label, linked to the control. |
64
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
65
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
66
+ | `length` | `number` | `6` | Number of characters in the code. |
67
+ | `type` | `"alphanumeric" \| "numeric"` | `"numeric"` | `"numeric"` takes digits and shows the number pad; `"alphanumeric"` takes letters too. |
68
+ | `groupSize` | `number` | — | Puts a separator after every this many slots, e.g. `3` for `123–456`. |
69
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
70
+ | `disabled` | `boolean` | `false` | Disables the control. |
71
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
72
+ | `modelValue` | `string` | `""` | The code typed so far. |
73
+
74
+ | Event | Payload | Description |
75
+ | --- | --- | --- |
76
+ | `complete` | `[code: string]` | Every slot is filled, by typing, pasting or autofill. |
77
+ | `update:modelValue` | `[value: string]` | `v-model:modelValue` update. |
78
+
79
+ | Slot | Props | Description |
80
+ | --- | --- | --- |
81
+ | `separator` | — | Content between groups. Defaults to a dash. |
82
+
83
+ ## Styling
84
+
85
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `otp`, `otp-input`, `otp-slot`, `otp-caret`, `otp-separator`, `field-message`
86
+ - State attributes: `data-field-error`, `data-otp-focused`, `data-otp-disabled`, `data-otp-active`, `data-otp-filled`, `data-field-tone`
87
+
88
+ ## Accessibility
89
+
90
+ - It's one native input with `autocomplete="one-time-code"`, so codes from SMS and password managers fill in, and screen readers announce a single field.
91
+ - Pasting a whole code fills every slot; spaces and dashes in it are dropped.
92
+ - The slots are hidden from screen readers, which read the input's value instead.
@@ -0,0 +1,62 @@
1
+ # Pagination
2
+
3
+ > Move between pages of results.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const page = ref(1);
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-stack">
16
+ <UiPagination v-model="page" :page-count="12" />
17
+ <p class="demo-note">Page {{ page }} of 12</p>
18
+ </div>
19
+ </template>
20
+ ```
21
+
22
+ ### Compact
23
+
24
+ `sibling-count` is how many pages show either side of the current one. With `0`, only the first and last pages and the current one are listed.
25
+
26
+ ```vue
27
+ <script setup lang="ts">
28
+ const page = ref(9);
29
+ </script>
30
+
31
+ <template>
32
+ <div class="demo-stack">
33
+ <UiPagination v-model="page" :page-count="20" :sibling-count="0" />
34
+ <p class="demo-note">Page {{ page }} of 20</p>
35
+ </div>
36
+ </template>
37
+ ```
38
+
39
+ ## API
40
+
41
+ | Prop | Type | Default | Description |
42
+ | --- | --- | --- | --- |
43
+ | `pageCount` (required) | `number` | — | Number of pages, at least 1. |
44
+ | `siblingCount` | `number` | `1` | Pages shown either side of the current one. |
45
+ | `label` | `string` | — | Accessible name for the navigation landmark, when the `pagination` translation isn't wanted. |
46
+ | `disabled` | `boolean` | `false` | Disables every button. |
47
+ | `modelValue` | `number` | — | The current page, 1-based. |
48
+
49
+ | Event | Payload | Description |
50
+ | --- | --- | --- |
51
+ | `update:modelValue` | `[value: number \| undefined]` | `v-model:modelValue` update. |
52
+
53
+ ## Styling
54
+
55
+ - Parts (`[data-part="…"]`): `pagination`, `pagination-list`, `pagination-item`, `pagination-previous`, `pagination-page`, `pagination-ellipsis`, `pagination-next`
56
+ - State attributes: `data-pagination-disabled`, `data-pagination-current`
57
+
58
+ ## Accessibility
59
+
60
+ - The whole control is a `<nav>` landmark, named by `label` or the `pagination` translation.
61
+ - The current page's button has `aria-current="page"`, and every page button is named “Page N”.
62
+ - Previous and next are real buttons, disabled at the first and last page.