@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.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/components/accordion/Accordion.js +60 -0
- package/dist/components/accordion/Accordion.vue.d.ts +28 -0
- package/dist/components/accordion/AccordionItem.js +102 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
- package/dist/components/avatar/Avatar.js +52 -0
- package/dist/components/avatar/Avatar.vue.d.ts +26 -0
- package/dist/components/avatar/AvatarGroup.js +48 -0
- package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +59 -0
- package/dist/components/breadcrumbs/Breadcrumbs.vue.d.ts +14 -0
- package/dist/components/button/Button.js +95 -0
- package/dist/components/button/Button.vue.d.ts +74 -0
- package/dist/components/button/IconButton.js +47 -0
- package/dist/components/button/IconButton.vue.d.ts +115 -0
- package/dist/components/checkbox/Checkbox.js +93 -0
- package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
- package/dist/components/checkbox-group/CheckboxGroup.js +89 -0
- package/dist/components/checkbox-group/CheckboxGroup.vue.d.ts +43 -0
- package/dist/components/combobox/Combobox.js +294 -0
- package/dist/components/combobox/Combobox.vue.d.ts +80 -0
- package/dist/components/context-menu/ContextMenu.js +170 -0
- package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
- package/dist/components/dialog/ConfirmDialog.js +103 -0
- package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
- package/dist/components/dialog/Dialog.js +160 -0
- package/dist/components/dialog/Dialog.vue.d.ts +54 -0
- package/dist/components/field/FieldMessage.js +31 -0
- package/dist/components/fieldset/Fieldset.js +59 -0
- package/dist/components/fieldset/Fieldset.vue.d.ts +29 -0
- package/dist/components/input/Input.js +111 -0
- package/dist/components/input/Input.vue.d.ts +50 -0
- package/dist/components/kbd/Kbd.js +48 -0
- package/dist/components/kbd/Kbd.vue.d.ts +24 -0
- package/dist/components/menu/Menu.js +124 -0
- package/dist/components/menu/Menu.vue.d.ts +41 -0
- package/dist/components/otp-input/OtpInput.js +179 -0
- package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
- package/dist/components/pagination/Pagination.js +128 -0
- package/dist/components/pagination/Pagination.vue.d.ts +24 -0
- package/dist/components/password-input/PasswordInput.js +151 -0
- package/dist/components/password-input/PasswordInput.vue.d.ts +32 -0
- package/dist/components/popover/Popover.js +83 -0
- package/dist/components/popover/Popover.vue.d.ts +37 -0
- package/dist/components/progress/Progress.js +52 -0
- package/dist/components/progress/Progress.vue.d.ts +17 -0
- package/dist/components/radio-group/RadioGroup.js +125 -0
- package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
- package/dist/components/segmented/Segmented.js +110 -0
- package/dist/components/segmented/Segmented.vue.d.ts +41 -0
- package/dist/components/select/Select.js +231 -0
- package/dist/components/select/Select.vue.d.ts +59 -0
- package/dist/components/slider/Slider.js +196 -0
- package/dist/components/slider/Slider.vue.d.ts +49 -0
- package/dist/components/spin-button/SpinButton.js +231 -0
- package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
- package/dist/components/split-button/SplitButton.js +69 -0
- package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
- package/dist/components/switch/Switch.js +95 -0
- package/dist/components/switch/Switch.vue.d.ts +42 -0
- package/dist/components/table/Table.js +173 -0
- package/dist/components/table/Table.vue.d.ts +45 -0
- package/dist/components/tabs/Tabs.js +103 -0
- package/dist/components/tabs/Tabs.vue.d.ts +39 -0
- package/dist/components/tag-input/TagInput.js +186 -0
- package/dist/components/tag-input/TagInput.vue.d.ts +36 -0
- package/dist/components/textarea/Textarea.js +118 -0
- package/dist/components/textarea/Textarea.vue.d.ts +34 -0
- package/dist/components/toast/ToastItem.js +91 -0
- package/dist/components/toast/ToastItem.vue.d.ts +29 -0
- package/dist/components/toast/ToastViewport.js +56 -0
- package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
- package/dist/components/toolbar/Toolbar.js +91 -0
- package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
- package/dist/components/tooltip/Tooltip.js +85 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
- package/dist/components/visually-hidden/VisuallyHidden.js +16 -0
- package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +19 -0
- package/dist/composables/internal/env.js +5 -0
- package/dist/composables/internal/is-equal.js +14 -0
- package/dist/composables/internal/on-click-outside.js +18 -0
- package/dist/composables/internal/standard-schema.d.ts +38 -0
- package/dist/composables/internal/use-document-visibility.js +16 -0
- package/dist/composables/internal/use-event-listener.js +24 -0
- package/dist/composables/internal/use-interval-fn.js +21 -0
- package/dist/composables/internal/use-resize-observer.js +21 -0
- package/dist/composables/internal/use-timeout-fn.js +25 -0
- package/dist/composables/use-accordion.d.ts +9 -0
- package/dist/composables/use-accordion.js +10 -0
- package/dist/composables/use-combobox.d.ts +44 -0
- package/dist/composables/use-combobox.js +185 -0
- package/dist/composables/use-field.d.ts +17 -0
- package/dist/composables/use-field.js +27 -0
- package/dist/composables/use-form.d.ts +44 -0
- package/dist/composables/use-form.js +146 -0
- package/dist/composables/use-menu.d.ts +26 -0
- package/dist/composables/use-menu.js +117 -0
- package/dist/composables/use-platform.d.ts +17 -0
- package/dist/composables/use-platform.js +126 -0
- package/dist/composables/use-popover.d.ts +35 -0
- package/dist/composables/use-popover.js +49 -0
- package/dist/composables/use-roving-selection.d.ts +22 -0
- package/dist/composables/use-roving-selection.js +65 -0
- package/dist/composables/use-select.d.ts +31 -0
- package/dist/composables/use-select.js +169 -0
- package/dist/composables/use-slide-indicator.d.ts +24 -0
- package/dist/composables/use-slide-indicator.js +52 -0
- package/dist/composables/use-toast.d.ts +23 -0
- package/dist/composables/use-toast.js +51 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.js +35 -0
- package/dist/docs/README.md +52 -0
- package/dist/docs/changelog.md +21 -0
- package/dist/docs/components/accordion.md +100 -0
- package/dist/docs/components/avatar-group.md +58 -0
- package/dist/docs/components/avatar.md +40 -0
- package/dist/docs/components/breadcrumbs.md +81 -0
- package/dist/docs/components/button.md +109 -0
- package/dist/docs/components/checkbox-group.md +118 -0
- package/dist/docs/components/checkbox.md +123 -0
- package/dist/docs/components/combobox.md +207 -0
- package/dist/docs/components/confirm-dialog.md +107 -0
- package/dist/docs/components/context-menu.md +98 -0
- package/dist/docs/components/dialog.md +127 -0
- package/dist/docs/components/fieldset.md +65 -0
- package/dist/docs/components/icon-button.md +47 -0
- package/dist/docs/components/input.md +89 -0
- package/dist/docs/components/kbd.md +41 -0
- package/dist/docs/components/menu.md +112 -0
- package/dist/docs/components/otp-input.md +92 -0
- package/dist/docs/components/pagination.md +62 -0
- package/dist/docs/components/password-input.md +55 -0
- package/dist/docs/components/popover.md +72 -0
- package/dist/docs/components/progress.md +56 -0
- package/dist/docs/components/radio-group.md +114 -0
- package/dist/docs/components/segmented.md +96 -0
- package/dist/docs/components/select.md +129 -0
- package/dist/docs/components/slider.md +105 -0
- package/dist/docs/components/spin-button.md +73 -0
- package/dist/docs/components/split-button.md +64 -0
- package/dist/docs/components/switch.md +71 -0
- package/dist/docs/components/table.md +241 -0
- package/dist/docs/components/tabs.md +106 -0
- package/dist/docs/components/tag-input.md +88 -0
- package/dist/docs/components/textarea.md +46 -0
- package/dist/docs/components/toast.md +135 -0
- package/dist/docs/components/toolbar.md +71 -0
- package/dist/docs/components/tooltip.md +57 -0
- package/dist/docs/components/visually-hidden.md +53 -0
- package/dist/docs/forms.md +182 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/installation.md +71 -0
- package/dist/docs/localisation.md +42 -0
- package/dist/docs/ssr.md +24 -0
- package/dist/docs/styling.md +82 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +56 -0
- package/dist/nuxt/module.d.ts +15 -0
- package/dist/nuxt/module.js +80 -0
- package/dist/nuxt/runtime/plugin.d.ts +4 -0
- package/dist/nuxt/runtime/plugin.js +24 -0
- package/dist/package.js +4 -0
- package/dist/styles/core.css +310 -0
- package/dist/translations.d.ts +85 -0
- package/dist/translations.js +62 -0
- package/dist/types.d.ts +69 -0
- package/package.json +93 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Checkbox Group
|
|
2
|
+
|
|
3
|
+
> Several checkboxes bound to one array.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
The array-model convenience over the group pattern documented on [Checkbox](/components/checkbox#group): one `v-model` for every checkbox.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
const toppings = ref<string[]>(["cheese"]);
|
|
14
|
+
const options = [
|
|
15
|
+
{ label: "Cheese", value: "cheese" },
|
|
16
|
+
{ label: "Olives", value: "olives" },
|
|
17
|
+
{ label: "Basil", value: "basil" },
|
|
18
|
+
];
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div class="demo-stack">
|
|
23
|
+
<UiCheckboxGroup
|
|
24
|
+
v-model="toppings"
|
|
25
|
+
:options="options"
|
|
26
|
+
label="Toppings"
|
|
27
|
+
hint="Pick any that apply."
|
|
28
|
+
/>
|
|
29
|
+
<p class="demo-note">Selected: {{ toppings.join(", ") || "none" }}</p>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Horizontal
|
|
35
|
+
|
|
36
|
+
`orientation` is a layout hook, exposed as `data-orientation`.
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
const extras = ref<string[]>([]);
|
|
41
|
+
const options = [
|
|
42
|
+
{ label: "Insurance", value: "insurance" },
|
|
43
|
+
{ label: "Gift wrap", value: "gift-wrap" },
|
|
44
|
+
{ label: "Priority", value: "priority" },
|
|
45
|
+
];
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<UiCheckboxGroup v-model="extras" :options="options" orientation="horizontal" label="Extras" />
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Error
|
|
54
|
+
|
|
55
|
+
A string `error` replaces the hint, and is announced as an alert when it appears.
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<script setup lang="ts">
|
|
59
|
+
const addons = ref<string[]>([]);
|
|
60
|
+
const options = [
|
|
61
|
+
{ label: "Insurance", value: "insurance" },
|
|
62
|
+
{ label: "Gift wrap", value: "gift-wrap" },
|
|
63
|
+
];
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<UiCheckboxGroup
|
|
68
|
+
v-model="addons"
|
|
69
|
+
:options="options"
|
|
70
|
+
label="Add-ons"
|
|
71
|
+
error="Pick at least one add-on."
|
|
72
|
+
/>
|
|
73
|
+
</template>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Default | Description |
|
|
79
|
+
| --- | --- | --- | --- |
|
|
80
|
+
| `options` | `SelectOption<T>[]` | `[]` | Checkboxes to render, in order. |
|
|
81
|
+
| `label` | `string` | — | Visible group label, which names the fieldset. |
|
|
82
|
+
| `hint` | `string` | — | Help text under the legend, announced as the group's description. |
|
|
83
|
+
| `error` | `string \| boolean` | — | `true` marks the group invalid; a string also shows it as the message, replacing the hint. |
|
|
84
|
+
| `disabled` | `boolean` | `false` | Disables every checkbox. |
|
|
85
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | Layout hook, exposed as `data-orientation`. |
|
|
86
|
+
| `name` | `string` | — | Form field name: submits the checked values with a native form, via hidden inputs. |
|
|
87
|
+
| `modelValue` | `T[]` | — | The checked values. |
|
|
88
|
+
|
|
89
|
+
| Event | Payload | Description |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| `update:modelValue` | `[value: T[] \| undefined]` | `v-model:modelValue` update. |
|
|
92
|
+
|
|
93
|
+
| Slot | Props | Description |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| `option` | `{ option: SelectOption<T>; checked: boolean; }` | Checkbox content, replacing the box and label. |
|
|
96
|
+
|
|
97
|
+
Types:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
export interface SelectOption<T extends SelectValue = SelectValue> {
|
|
101
|
+
label: string;
|
|
102
|
+
value: T;
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type SelectValue = string | number;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Styling
|
|
110
|
+
|
|
111
|
+
- Parts (`[data-part="…"]`): `checkbox-group`, `checkbox`, `checkbox-input`, `checkbox-control`, `checkbox-label`, `field-message`, `fieldset`, `fieldset-legend`
|
|
112
|
+
- State attributes: `data-orientation`, `data-field-name`, `data-checkbox-disabled`, `data-checkbox-error`, `data-field-tone`, `data-field-error`
|
|
113
|
+
|
|
114
|
+
## Accessibility
|
|
115
|
+
|
|
116
|
+
- The options sit in a `<fieldset>` with a `<legend>`, so the group's name is announced with each checkbox.
|
|
117
|
+
- Each option is a native `<input type="checkbox">`.
|
|
118
|
+
- `disabled` disables every checkbox; `option.disabled` disables just that one.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
> A checkbox, alone or in a group.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const accepted = ref(false);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="demo-stack">
|
|
16
|
+
<UiCheckbox v-model="accepted" label="Accept the terms" />
|
|
17
|
+
<UiCheckbox :model-value="true" label="Disabled" disabled />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Group
|
|
23
|
+
|
|
24
|
+
Bind several checkboxes to one array: each adds its `value` when checked.
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
const toppings = ref(["cheese"]);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<div class="demo-stack demo-field">
|
|
33
|
+
<UiCheckbox v-model="toppings" value="cheese" label="Cheese" />
|
|
34
|
+
<UiCheckbox v-model="toppings" value="olives" label="Olives" />
|
|
35
|
+
<UiCheckbox v-model="toppings" value="basil" label="Basil" />
|
|
36
|
+
<p class="demo-note">Selected: {{ toppings.join(", ") || "none" }}</p>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Indeterminate
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<script setup lang="ts">
|
|
45
|
+
const files = ref(["a.txt"]);
|
|
46
|
+
const all = ["a.txt", "b.txt", "c.txt"];
|
|
47
|
+
|
|
48
|
+
const allSelected = computed({
|
|
49
|
+
get: () => files.value.length === all.length,
|
|
50
|
+
set: (checked) => (files.value = checked ? [...all] : []),
|
|
51
|
+
});
|
|
52
|
+
const someSelected = computed(() => files.value.length > 0 && !allSelected.value);
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<div class="demo-stack">
|
|
57
|
+
<UiCheckbox v-model="allSelected" :indeterminate="someSelected" label="Select all" />
|
|
58
|
+
<div class="demo-stack demo-indent">
|
|
59
|
+
<UiCheckbox v-for="file in all" :key="file" v-model="files" :value="file" :label="file" />
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Hint and error
|
|
66
|
+
|
|
67
|
+
Shown under the label and read as its description.
|
|
68
|
+
|
|
69
|
+
```vue
|
|
70
|
+
<script setup lang="ts">
|
|
71
|
+
const accepted = ref(false);
|
|
72
|
+
const tried = ref(false);
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div class="demo-stack">
|
|
77
|
+
<UiCheckbox
|
|
78
|
+
v-model="accepted"
|
|
79
|
+
label="Accept the terms"
|
|
80
|
+
hint="Required to create an account."
|
|
81
|
+
:error="tried && !accepted ? 'Accept the terms to continue' : undefined"
|
|
82
|
+
/>
|
|
83
|
+
<UiButton size="small" @click="tried = true">Create account</UiButton>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## API
|
|
89
|
+
|
|
90
|
+
| Prop | Type | Default | Description |
|
|
91
|
+
| --- | --- | --- | --- |
|
|
92
|
+
| `label` | `string` | — | Text next to the box. The default slot overrides it. |
|
|
93
|
+
| `disabled` | `boolean` | `false` | Disables the checkbox. |
|
|
94
|
+
| `indeterminate` | `boolean` | `false` | Shows the mixed state, e.g. for a "select all" with some rows picked. |
|
|
95
|
+
| `value` | `string \| number` | — | With an array `v-model`, this value is added/removed when toggled. |
|
|
96
|
+
| `hint` | `string` | — | Help text under the checkbox, announced as its description. |
|
|
97
|
+
| `error` | `string \| boolean` | — | `true` marks it invalid; a string also shows it as the message, replacing the hint. |
|
|
98
|
+
| `id` | `string` | — | Id for the input; generated with `useId()` when omitted. |
|
|
99
|
+
| `modelValue` | `boolean \| (string \| number)[]` | — | Checked state, or with an array, the checked `value`s. |
|
|
100
|
+
|
|
101
|
+
| Event | Payload | Description |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| `update:modelValue` | `[value: boolean \| (string \| number)[] \| undefined]` | `v-model:modelValue` update. |
|
|
104
|
+
|
|
105
|
+
| Slot | Props | Description |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
| `default` | — | Label content, replacing `label`. |
|
|
108
|
+
| `indicator` | — | Inside `checkbox-control`, e.g. a check icon. |
|
|
109
|
+
|
|
110
|
+
## Styling
|
|
111
|
+
|
|
112
|
+
- Parts (`[data-part="…"]`): `checkbox`, `checkbox-input`, `checkbox-control`, `checkbox-label`, `field-message`
|
|
113
|
+
- State attributes: `data-checkbox-disabled`, `data-checkbox-error`, `data-field-tone`
|
|
114
|
+
|
|
115
|
+
## Keyboard
|
|
116
|
+
|
|
117
|
+
| Keys | Action |
|
|
118
|
+
| ------- | ------ |
|
|
119
|
+
| `Space` | Toggle |
|
|
120
|
+
|
|
121
|
+
## Accessibility
|
|
122
|
+
|
|
123
|
+
- It's a native `<input type="checkbox">`, so it submits with forms and works with any label.
|
|
@@ -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.
|