@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,207 @@
1
+ # Combobox
2
+
3
+ > A text input that filters a list of options as you type.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const country = ref<string>();
12
+ const countries = [
13
+ "Argentina",
14
+ "Australia",
15
+ "Brazil",
16
+ "Canada",
17
+ "Egypt",
18
+ "France",
19
+ "Germany",
20
+ "Ghana",
21
+ "India",
22
+ "Japan",
23
+ "Kenya",
24
+ "Mexico",
25
+ "Nigeria",
26
+ "Norway",
27
+ "Portugal",
28
+ "South Africa",
29
+ "Spain",
30
+ "Sweden",
31
+ "United Kingdom",
32
+ "United States",
33
+ ].map((label) => ({ label, value: label.toLowerCase().replaceAll(" ", "-") }));
34
+ </script>
35
+
36
+ <template>
37
+ <div class="demo-field">
38
+ <UiCombobox
39
+ v-model="country"
40
+ :options="countries"
41
+ label="Country"
42
+ placeholder="Search countries"
43
+ />
44
+ </div>
45
+ </template>
46
+ ```
47
+
48
+ ### Tags
49
+
50
+ With `multiple`, picks show as chips. With `creatable`, Enter on new text emits `create` so you can add it.
51
+
52
+ ```vue
53
+ <script setup lang="ts">
54
+ const tags = ref(["vue", "css"]);
55
+ const options = ref(
56
+ ["vue", "nuxt", "css", "typescript", "accessibility", "ssr"].map((value) => ({
57
+ label: value,
58
+ value,
59
+ })),
60
+ );
61
+
62
+ function create(tag: string) {
63
+ const value = tag.toLowerCase();
64
+ options.value.push({ label: value, value });
65
+ tags.value.push(value);
66
+ }
67
+ </script>
68
+
69
+ <template>
70
+ <div class="demo-field">
71
+ <UiCombobox
72
+ v-model="tags"
73
+ :options="options"
74
+ label="Tags"
75
+ placeholder="Add a tag"
76
+ hint="Enter adds a new tag. Backspace removes the last."
77
+ multiple
78
+ creatable
79
+ @create="create"
80
+ />
81
+ </div>
82
+ </template>
83
+ ```
84
+
85
+ ### Async options
86
+
87
+ Fetch matches as `v-model:query` changes, and set `ignore-filter` so your results show as they are. Set `loading` while a request runs.
88
+
89
+ ```vue
90
+ <script setup lang="ts">
91
+ const query = ref("");
92
+ const user = ref<number>();
93
+
94
+ const people = [
95
+ "Ada Lovelace",
96
+ "Alan Turing",
97
+ "Grace Hopper",
98
+ "Katherine Johnson",
99
+ "Linus Torvalds",
100
+ "Margaret Hamilton",
101
+ ];
102
+
103
+ // Stand-in for a search request: options arrive already filtered.
104
+ const { data: results, pending } = useAsyncData(
105
+ "people-search",
106
+ async () => {
107
+ await new Promise((resolve) => setTimeout(resolve, 400));
108
+ const q = query.value.toLowerCase();
109
+ return people
110
+ .map((label, value) => ({ label, value }))
111
+ .filter((person) => person.label.toLowerCase().includes(q));
112
+ },
113
+ { watch: [query], default: () => [] },
114
+ );
115
+ </script>
116
+
117
+ <template>
118
+ <div class="demo-field">
119
+ <UiCombobox
120
+ v-model="user"
121
+ v-model:query="query"
122
+ :options="results"
123
+ ignore-filter
124
+ :loading="pending"
125
+ label="Assignee"
126
+ placeholder="Search people"
127
+ >
128
+ <template #empty>No one matches “{{ query }}”.</template>
129
+ </UiCombobox>
130
+ </div>
131
+ </template>
132
+ ```
133
+
134
+ ## API
135
+
136
+ | Prop | Type | Default | Description |
137
+ | --- | --- | --- | --- |
138
+ | `options` | `SelectOption<T>[]` | `[]` | Options to choose from. |
139
+ | `label` | `string` | — | Visible label, linked to the input. |
140
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
141
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
142
+ | `placeholder` | `string` | — | Input placeholder. |
143
+ | `multiple` | `boolean` | `false` | Pick several; `v-model` becomes an array, shown as chips. Backspace removes the last one. |
144
+ | `creatable` | `boolean` | `false` | Enter on text matching no option emits `create` with it. |
145
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
146
+ | `disabled` | `boolean` | `false` | Disables the control. |
147
+ | `filter` | `ComboboxFilter<T>` | — | Custom match for each option against the lower-cased query. By default, labels are ranked exact, then prefix, then substring. |
148
+ | `ignoreFilter` | `boolean` | `false` | Show `options` as given, without filtering, e.g. results from a search request. |
149
+ | `loading` | `boolean` | `false` | Options are being fetched: shows the `loading` translation and marks the list busy. |
150
+ | `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
151
+ | `id` | `string` | — | Id for the input; generated with `useId()` when omitted. |
152
+ | `modelValue` | `T \| T[]` | — | The selected value, or values with `multiple`. |
153
+ | `query` | `string` | `""` | The input's text. Bind it to fetch options as the user types. |
154
+
155
+ | Event | Payload | Description |
156
+ | --- | --- | --- |
157
+ | `create` | `[query: string]` | Enter was pressed on text matching no option (with `creatable`). |
158
+ | `update:modelValue` | `[value: T \| T[] \| undefined]` | `v-model:modelValue` update. |
159
+ | `update:query` | `[value: string]` | `v-model:query` update. |
160
+
161
+ | Slot | Props | Description |
162
+ | --- | --- | --- |
163
+ | `option` | `{ option: SelectOption<T>; selected: boolean; active: boolean; }` | Option content. |
164
+ | `chip` | `{ option: SelectOption<T>; remove: () => void; }` | Each selected value in `multiple` mode. Call `remove` to deselect it. |
165
+ | `empty` | `{ query: string; }` | Shown when nothing matches. |
166
+ | `create` | `{ query: string; }` | Shown with `creatable` when Enter would create the typed value. |
167
+ | `loading` | — | Shown while `loading`. |
168
+
169
+ Types:
170
+
171
+ ```ts
172
+ export interface SelectOption<T extends SelectValue = SelectValue> {
173
+ label: string;
174
+ value: T;
175
+ disabled?: boolean;
176
+ }
177
+
178
+ export type ComboboxFilter<T extends SelectValue> = (
179
+ option: SelectOption<T>,
180
+ query: string,
181
+ ) => boolean;
182
+
183
+ export type SelectValue = string | number;
184
+ ```
185
+
186
+ ## Styling
187
+
188
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `combobox-control`, `combobox-chip`, `combobox-chip-label`, `combobox-chip-remove`, `combobox-input`, `combobox-popup`, `combobox-listbox`, `combobox-option`, `combobox-option-label`, `combobox-loading`, `combobox-create`, `combobox-empty`, `combobox-status`, `field-message`
189
+ - State attributes: `data-field-error`, `data-field-name`, `data-combobox-open`, `data-combobox-disabled`, `data-combobox-active`, `data-field-tone`
190
+
191
+ ## Keyboard
192
+
193
+ | Keys | Action |
194
+ | ----------- | -------------------------------------------------------- |
195
+ | Typing | Filter, and open the list |
196
+ | `↓` / `↑` | Move between options, wrapping |
197
+ | `Alt` + `↓` | Open without moving |
198
+ | `Enter` | Select the active option, or create (with `creatable`) |
199
+ | `Escape` | Close; press again to clear |
200
+ | `Backspace` | With `multiple` and an empty input, remove the last chip |
201
+
202
+ ## Accessibility
203
+
204
+ - Focus stays in the input; screen readers follow the highlighted option through `aria-activedescendant`.
205
+ - While typing, a hidden status announces the number of matches, “No results”, or “Loading…”.
206
+ - Chips aren't in the tab order, so with `multiple` the picks are read as part of the input's description.
207
+ - In single mode, leaving the input with unmatched text restores the selection.
@@ -0,0 +1,107 @@
1
+ # Confirm Dialog
2
+
3
+ > Asks to confirm or cancel an action.
4
+
5
+ ## Examples
6
+
7
+ ### Destructive
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const open = ref(false);
12
+ const toast = useToast();
13
+ </script>
14
+
15
+ <template>
16
+ <UiButton variant="danger" @click="open = true">Delete project</UiButton>
17
+
18
+ <UiConfirmDialog
19
+ v-model:open="open"
20
+ title="Delete this project?"
21
+ description="Its files and history are removed for everyone. This can't be undone."
22
+ confirm-text="Delete"
23
+ danger
24
+ @confirm="toast.error('Project deleted')"
25
+ @cancel="toast.info('Kept the project')"
26
+ />
27
+ </template>
28
+ ```
29
+
30
+ ### Async action
31
+
32
+ With `keep-open`, Confirm doesn't close the dialog. Set `loading` while your action runs, then close it yourself; it can't be cancelled while loading.
33
+
34
+ ```vue
35
+ <script setup lang="ts">
36
+ const open = ref(false);
37
+ const deleting = ref(false);
38
+ const toast = useToast();
39
+
40
+ // Stand-in for a delete request.
41
+ async function remove() {
42
+ deleting.value = true;
43
+ await new Promise((resolve) => setTimeout(resolve, 1200));
44
+ deleting.value = false;
45
+ open.value = false;
46
+ toast.success("Branch deleted");
47
+ }
48
+ </script>
49
+
50
+ <template>
51
+ <UiButton variant="danger" @click="open = true">Delete branch</UiButton>
52
+
53
+ <UiConfirmDialog
54
+ v-model:open="open"
55
+ title="Delete feature/login?"
56
+ description="Unmerged commits on it are lost."
57
+ confirm-text="Delete"
58
+ danger
59
+ keep-open
60
+ :loading="deleting"
61
+ @confirm="remove"
62
+ >
63
+ <template #spinner><span class="spinner" /></template>
64
+ </UiConfirmDialog>
65
+ </template>
66
+ ```
67
+
68
+ ## API
69
+
70
+ | Prop | Type | Default | Description |
71
+ | --- | --- | --- | --- |
72
+ | `title` | `string` | — | Heading, which names the dialog. |
73
+ | `description` | `string` | — | Supporting text, announced as the dialog's description. |
74
+ | `confirmText` | `string` | — | Confirm button text. Defaults to the `confirm` translation. |
75
+ | `cancelText` | `string` | — | Cancel button text. Defaults to the `cancel` translation. |
76
+ | `danger` | `boolean` | `false` | Destructive action: a danger-styled confirm, and Cancel takes initial focus. |
77
+ | `loading` | `boolean` | `false` | The confirmed action is running: Confirm shows it, and the dialog can't be cancelled. |
78
+ | `keepOpen` | `boolean` | `false` | Stay open after Confirm, e.g. while `loading`; close it by setting `open` to false. |
79
+ | `open` | `boolean` | `false` | Whether the dialog is open. |
80
+
81
+ | Event | Payload | Description |
82
+ | --- | --- | --- |
83
+ | `cancel` | `[]` | Cancelled by the button or Escape. |
84
+ | `confirm` | `[]` | The confirm button was pressed. |
85
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
86
+
87
+ | Slot | Props | Description |
88
+ | --- | --- | --- |
89
+ | `default` | — | Extra body content. |
90
+ | `spinner` | — | The Confirm button's spinner while `loading`. |
91
+
92
+ ## Styling
93
+
94
+ - Parts (`[data-part="…"]`): `button`, `button-spinner`, `button-label`, `dialog`, `dialog-panel`, `dialog-header`, `dialog-header-text`, `dialog-title`, `dialog-description`, `dialog-close`, `dialog-body`, `dialog-footer`
95
+ - State attributes: `data-button-variant`, `data-button-size`, `data-button-full-width`, `data-button-disabled`, `data-button-loading`, `data-dialog-size`, `data-dialog-flush`
96
+
97
+ ## Keyboard
98
+
99
+ | Keys | Action |
100
+ | -------- | ------------------------- |
101
+ | `Escape` | Cancel |
102
+ | `Tab` | Cycle between the buttons |
103
+
104
+ ## Accessibility
105
+
106
+ - The backdrop doesn't close it.
107
+ - With `danger`, Cancel gets initial focus.
@@ -0,0 +1,98 @@
1
+ # Context Menu
2
+
3
+ > A menu opened at the pointer by right-click or long-press.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ As in Menu, `{ separator: true }` draws a line between groups.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const toast = useToast();
14
+ const items = [
15
+ { label: "Open", value: "open" },
16
+ { label: "Rename", value: "rename", hint: "F2" },
17
+ { label: "Duplicate", value: "duplicate" },
18
+ { separator: true as const },
19
+ { label: "Move to trash", value: "trash", hint: "⌫" },
20
+ ];
21
+ </script>
22
+
23
+ <template>
24
+ <UiContextMenu :items="items" @select="(action) => toast.info(`${action}: report.pdf`)">
25
+ <div class="demo-dropzone" tabindex="0">
26
+ <Icon name="copy" />
27
+ <span>report.pdf</span>
28
+ <small>Right-click, long-press, or focus and press Shift+F10</small>
29
+ </div>
30
+ </UiContextMenu>
31
+ </template>
32
+ ```
33
+
34
+ ## API
35
+
36
+ | Prop | Type | Default | Description |
37
+ | --- | --- | --- | --- |
38
+ | `items` | `MenuEntry<T>[]` | `[]` | Menu items in order; `{ separator: true }` draws a line between groups. |
39
+ | `label` | `string` | — | Accessible name for the menu. Defaults to the `contextMenu` translation. |
40
+ | `disabled` | `boolean` | `false` | Leaves the browser's own context menu in place. |
41
+ | `open` | `boolean` | `false` | Whether the menu is open. |
42
+
43
+ | Event | Payload | Description |
44
+ | --- | --- | --- |
45
+ | `select` | `[value: T]` | An item was activated. |
46
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
47
+
48
+ | Slot | Props | Description |
49
+ | --- | --- | --- |
50
+ | `default` | — | The area that opens the menu on right-click, long-press, or Shift+F10. |
51
+ | `item` | `{ item: MenuItem<T>; active: boolean; }` | Item content. |
52
+
53
+ Types:
54
+
55
+ ```ts
56
+ export type MenuEntry<T extends SelectValue = SelectValue> = MenuItem<T> | MenuSeparator;
57
+
58
+ export interface MenuItem<T extends SelectValue = SelectValue> extends SelectOption<T> {
59
+ /** Trailing text, e.g. a shortcut like "⌘S". Render richer content via the `item` slot. */
60
+ hint?: string;
61
+ }
62
+
63
+ export type SelectValue = string | number;
64
+
65
+ /** A line between groups of menu items. */
66
+ export interface MenuSeparator {
67
+ separator: true;
68
+ }
69
+
70
+ export interface SelectOption<T extends SelectValue = SelectValue> {
71
+ label: string;
72
+ value: T;
73
+ disabled?: boolean;
74
+ }
75
+ ```
76
+
77
+ ## Styling
78
+
79
+ Its items use Menu's styling hooks.
80
+
81
+ - Parts (`[data-part="…"]`): `context-menu`, `context-menu-anchor`, `menu-list`, `menu-separator`, `menu-item`, `menu-item-label`, `menu-item-hint`
82
+ - State attributes: `data-context-menu-open`, `data-menu-index`, `data-menu-active`
83
+
84
+ ## Keyboard
85
+
86
+ | Keys | Action |
87
+ | -------------------------- | ----------------------------- |
88
+ | `Shift` + `F10` / Menu key | Open from the focused element |
89
+ | `↓` / `↑` | Move between items |
90
+ | `Home` / `End` | First / last item |
91
+ | Letters | Jump to an item by label |
92
+ | `Enter` / `Space` | Activate |
93
+ | `Escape` | Close and return focus |
94
+
95
+ ## Accessibility
96
+
97
+ - Make the area focusable (`tabindex="0"`) so keyboard users can open it.
98
+ - Long-press opens it on touch, including iOS Safari, which has no `contextmenu` event.
@@ -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,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.