@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.
- 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/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/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/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/popover/Popover.js +83 -0
- package/dist/components/popover/Popover.vue.d.ts +37 -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 +99 -0
- package/dist/components/tabs/Tabs.vue.d.ts +39 -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/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 +44 -0
- package/dist/docs/changelog.md +14 -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/button.md +109 -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/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/popover.md +72 -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/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/forms.md +182 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/installation.md +73 -0
- package/dist/docs/localisation.md +40 -0
- package/dist/docs/ssr.md +24 -0
- package/dist/docs/styling.md +66 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +44 -0
- package/dist/nuxt/module.d.ts +15 -0
- package/dist/nuxt/module.js +72 -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 +284 -0
- package/dist/translations.d.ts +71 -0
- package/dist/translations.js +55 -0
- package/dist/types.d.ts +61 -0
- package/package.json +93 -4
|
@@ -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,72 @@
|
|
|
1
|
+
# Popover
|
|
2
|
+
|
|
3
|
+
> A non-modal panel anchored to a trigger.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const toast = useToast();
|
|
12
|
+
const email = ref("");
|
|
13
|
+
|
|
14
|
+
function invite(close: () => void) {
|
|
15
|
+
toast.success(`Invited ${email.value || "a teammate"}`);
|
|
16
|
+
email.value = "";
|
|
17
|
+
close();
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<UiPopover label="Invite a teammate">
|
|
23
|
+
<template #trigger="{ attrs }">
|
|
24
|
+
<UiButton variant="secondary" v-bind="attrs">
|
|
25
|
+
<template #leading><Icon name="plus" :size="14" /></template>
|
|
26
|
+
Invite
|
|
27
|
+
</UiButton>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<template #default="{ close }">
|
|
31
|
+
<form class="demo-popover" @submit.prevent="invite(close)">
|
|
32
|
+
<UiInput v-model="email" type="email" label="Email" placeholder="ada@example.com" />
|
|
33
|
+
<UiButton type="submit" size="small" full-width>Send invite</UiButton>
|
|
34
|
+
</form>
|
|
35
|
+
</template>
|
|
36
|
+
</UiPopover>
|
|
37
|
+
</template>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Default | Description |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| `label` (required) | `string` | — | Accessible name for the panel (role="dialog"). |
|
|
45
|
+
| `align` | `"end" \| "start"` | `"start"` | Which trigger edge the panel lines up with. Flips automatically near the viewport edge. |
|
|
46
|
+
| `open` | `boolean` | `false` | Whether the panel is open. |
|
|
47
|
+
|
|
48
|
+
| Event | Payload | Description |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `update:open` | `[value: boolean]` | `v-model:open` update. |
|
|
51
|
+
|
|
52
|
+
| Slot | Props | Description |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `trigger` | `{ isOpen: boolean; attrs: Record<string, unknown>; }` | The trigger. Bind `attrs` to a `<button>`. |
|
|
55
|
+
| `default` | `{ close: () => void; }` | Panel content. Mounted on first open. |
|
|
56
|
+
|
|
57
|
+
## Styling
|
|
58
|
+
|
|
59
|
+
- Parts (`[data-part="…"]`): `popover-anchor`, `popover`
|
|
60
|
+
- State attributes: `data-popover-align`
|
|
61
|
+
|
|
62
|
+
## Keyboard
|
|
63
|
+
|
|
64
|
+
| Keys | Action |
|
|
65
|
+
| ----------------- | -------------------------------------------- |
|
|
66
|
+
| `Enter` / `Space` | Toggle |
|
|
67
|
+
| `Escape` | Close and return focus to the trigger |
|
|
68
|
+
| `Tab` | Move through the panel; leaving it closes it |
|
|
69
|
+
|
|
70
|
+
## Accessibility
|
|
71
|
+
|
|
72
|
+
- Focus moves into the panel on open.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Radio Group
|
|
2
|
+
|
|
3
|
+
> A single choice from a list.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const plan = ref("pro");
|
|
12
|
+
const plans = [
|
|
13
|
+
{ label: "Hobby — free", value: "hobby" },
|
|
14
|
+
{ label: "Pro — $20/month", value: "pro" },
|
|
15
|
+
{ label: "Enterprise — contact us", value: "enterprise", disabled: true },
|
|
16
|
+
];
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<UiRadioGroup v-model="plan" :options="plans" label="Plan" hint="You can change it any time." />
|
|
21
|
+
</template>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Horizontal
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
const size = ref("m");
|
|
29
|
+
const sizes = ["xs", "s", "m", "l", "xl"].map((value) => ({ label: value.toUpperCase(), value }));
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<UiRadioGroup v-model="size" :options="sizes" label="Size" orientation="horizontal" />
|
|
34
|
+
</template>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Custom options
|
|
38
|
+
|
|
39
|
+
The `option` slot replaces each radio's content. Include `radio-control` to keep the circle.
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
const plan = ref("pro");
|
|
44
|
+
const plans = [
|
|
45
|
+
{ label: "Hobby", value: "hobby", price: "Free", detail: "One project, community support" },
|
|
46
|
+
{ label: "Pro", value: "pro", price: "$20/mo", detail: "Unlimited projects, email support" },
|
|
47
|
+
{ label: "Team", value: "team", price: "$60/mo", detail: "Shared workspaces, SSO" },
|
|
48
|
+
];
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<UiRadioGroup v-model="plan" :options="plans" label="Plan" class="plan-cards">
|
|
53
|
+
<template #option="{ option }">
|
|
54
|
+
<span data-part="radio-control" aria-hidden="true" />
|
|
55
|
+
<span class="plan-text">
|
|
56
|
+
<strong>{{ option.label }}</strong>
|
|
57
|
+
<small>{{ plans.find((p) => p.value === option.value)?.detail }}</small>
|
|
58
|
+
</span>
|
|
59
|
+
<span class="plan-price">{{ plans.find((p) => p.value === option.value)?.price }}</span>
|
|
60
|
+
</template>
|
|
61
|
+
</UiRadioGroup>
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## API
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Description |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| `options` | `SelectOption<T>[]` | `[]` | Radios to render, in order. |
|
|
70
|
+
| `label` | `string` | — | Visible group label, which names the radiogroup. |
|
|
71
|
+
| `hint` | `string` | — | Help text under the control, announced as its description. |
|
|
72
|
+
| `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
|
|
73
|
+
| `disabled` | `boolean` | `false` | Disables the control. |
|
|
74
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | Layout hook, exposed as `data-orientation` and `aria-orientation`. |
|
|
75
|
+
| `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
|
|
76
|
+
| `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
|
|
77
|
+
| `modelValue` | `T` | — | The selected value. |
|
|
78
|
+
|
|
79
|
+
| Event | Payload | Description |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
|
|
82
|
+
|
|
83
|
+
| Slot | Props | Description |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `option` | `{ option: SelectOption<T>; checked: boolean; }` | Radio content, replacing the control and label. |
|
|
86
|
+
|
|
87
|
+
Types:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
export interface SelectOption<T extends SelectValue = SelectValue> {
|
|
91
|
+
label: string;
|
|
92
|
+
value: T;
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type SelectValue = string | number;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Styling
|
|
100
|
+
|
|
101
|
+
- Parts (`[data-part="…"]`): `field`, `field-label`, `radio-group`, `radio`, `radio-control`, `radio-label`, `field-message`
|
|
102
|
+
- State attributes: `data-field-error`, `data-field-name`, `data-orientation`, `data-radio-checked`, `data-field-tone`
|
|
103
|
+
|
|
104
|
+
## Keyboard
|
|
105
|
+
|
|
106
|
+
| Keys | Action |
|
|
107
|
+
| -------------- | ------------------------------------------ |
|
|
108
|
+
| `Tab` | Focus the selected radio |
|
|
109
|
+
| Arrow keys | Select the next / previous radio, wrapping |
|
|
110
|
+
| `Home` / `End` | Select the first / last radio |
|
|
111
|
+
|
|
112
|
+
## Accessibility
|
|
113
|
+
|
|
114
|
+
- In right-to-left layouts, `←` / `→` follow the visual direction.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Segmented
|
|
2
|
+
|
|
3
|
+
> A single choice shown as a row of buttons.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const view = ref("week");
|
|
12
|
+
const views = [
|
|
13
|
+
{ label: "Day", value: "day" },
|
|
14
|
+
{ label: "Week", value: "week" },
|
|
15
|
+
{ label: "Month", value: "month" },
|
|
16
|
+
{ label: "Year", value: "year" },
|
|
17
|
+
];
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<UiSegmented v-model="view" :options="views" label="Calendar view" />
|
|
22
|
+
</template>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Icon only
|
|
26
|
+
|
|
27
|
+
The option labels become the buttons' names.
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
const style = ref<"bold" | "italic" | "underline">("bold");
|
|
32
|
+
const styles = [
|
|
33
|
+
{ label: "Bold", value: "bold" },
|
|
34
|
+
{ label: "Italic", value: "italic" },
|
|
35
|
+
{ label: "Underline", value: "underline" },
|
|
36
|
+
] as const;
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<UiSegmented v-model="style" :options="[...styles]" label="Text style" size="small" icon-only>
|
|
41
|
+
<template #option="{ option }"><Icon :name="option.value" :size="14" /></template>
|
|
42
|
+
</UiSegmented>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| `options` | `SelectOption<T>[]` | `[]` | Segments to render, in order. |
|
|
51
|
+
| `label` | `string` | — | Accessible name for the group. |
|
|
52
|
+
| `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-segmented-size`. |
|
|
53
|
+
| `iconOnly` | `boolean` | `false` | Segments render only the `option` slot (e.g. an icon); labels become their accessible names. |
|
|
54
|
+
| `disabled` | `boolean` | `false` | Disables every segment. |
|
|
55
|
+
| `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
|
|
56
|
+
| `modelValue` | `T` | — | The selected value. |
|
|
57
|
+
|
|
58
|
+
| Event | Payload | Description |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
|
|
61
|
+
|
|
62
|
+
| Slot | Props | Description |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| `option` | `{ option: SelectOption<T>; checked: boolean; }` | Segment content, e.g. an icon. |
|
|
65
|
+
|
|
66
|
+
Types:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
export interface SelectOption<T extends SelectValue = SelectValue> {
|
|
70
|
+
label: string;
|
|
71
|
+
value: T;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type SelectValue = string | number;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Styling
|
|
79
|
+
|
|
80
|
+
`--ui-indicator-x`, `--ui-indicator-width`, `--ui-indicator-top` and `--ui-indicator-height` place the indicator on the selected item.
|
|
81
|
+
|
|
82
|
+
- Parts (`[data-part="…"]`): `segmented`, `segmented-indicator`, `segment`
|
|
83
|
+
- State attributes: `data-field-name`, `data-segmented-size`, `data-segmented-icon-only`, `data-segmented-sliding`, `data-segmented-animate`, `data-segment-checked`
|
|
84
|
+
|
|
85
|
+
## Keyboard
|
|
86
|
+
|
|
87
|
+
| Keys | Action |
|
|
88
|
+
| -------------- | ---------------------------------- |
|
|
89
|
+
| `Tab` | Focus the selected segment |
|
|
90
|
+
| Arrow keys | Select the next / previous segment |
|
|
91
|
+
| `Home` / `End` | Select the first / last segment |
|
|
92
|
+
|
|
93
|
+
## Accessibility
|
|
94
|
+
|
|
95
|
+
- The indicator is measured in the browser, so also style `[data-segment-checked]` for the first paint.
|
|
96
|
+
- In right-to-left layouts, `←` / `→` follow the visual direction.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
> A single or multiple choice from a dropdown.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const timezone = ref<string>("Europe/London");
|
|
12
|
+
const timezones = [
|
|
13
|
+
{ label: "Lagos", value: "Africa/Lagos", offset: "UTC+1" },
|
|
14
|
+
{ label: "London", value: "Europe/London", offset: "UTC+0" },
|
|
15
|
+
{ label: "New York", value: "America/New_York", offset: "UTC−5" },
|
|
16
|
+
{ label: "Tokyo", value: "Asia/Tokyo", offset: "UTC+9" },
|
|
17
|
+
{ label: "Sydney", value: "Australia/Sydney", offset: "UTC+10", disabled: true },
|
|
18
|
+
];
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div class="demo-field">
|
|
23
|
+
<UiSelect v-model="timezone" :options="timezones" label="Timezone">
|
|
24
|
+
<template #option="{ option, selected }">
|
|
25
|
+
<span class="option-label">{{ option.label }}</span>
|
|
26
|
+
<span class="option-detail">{{
|
|
27
|
+
timezones.find((t) => t.value === option.value)?.offset
|
|
28
|
+
}}</span>
|
|
29
|
+
<Icon v-if="selected" name="check" :size="14" class="option-check" />
|
|
30
|
+
</template>
|
|
31
|
+
</UiSelect>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Multiple
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
const labels = ref(["bug", "docs"]);
|
|
41
|
+
const options = [
|
|
42
|
+
{ label: "Bug", value: "bug", color: "oklch(0.68 0.19 25)" },
|
|
43
|
+
{ label: "Feature", value: "feature", color: "oklch(0.72 0.15 250)" },
|
|
44
|
+
{ label: "Docs", value: "docs", color: "oklch(0.75 0.14 150)" },
|
|
45
|
+
{ label: "Question", value: "question", color: "oklch(0.8 0.14 85)" },
|
|
46
|
+
];
|
|
47
|
+
const colorOf = (value: string | number) => options.find((o) => o.value === value)?.color;
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<div class="demo-field">
|
|
52
|
+
<UiSelect v-model="labels" :options="options" label="Labels" placeholder="Add labels" multiple>
|
|
53
|
+
<template #value="{ selected, placeholder }">
|
|
54
|
+
<span v-if="selected.length" class="chips">
|
|
55
|
+
<span v-for="option in selected" :key="option.value" class="chip">
|
|
56
|
+
<span class="dot" :style="{ background: colorOf(option.value) }" />
|
|
57
|
+
{{ option.label }}
|
|
58
|
+
</span>
|
|
59
|
+
</span>
|
|
60
|
+
<template v-else>{{ placeholder }}</template>
|
|
61
|
+
</template>
|
|
62
|
+
<template #option="{ option, selected }">
|
|
63
|
+
<span class="dot" :style="{ background: colorOf(option.value) }" />
|
|
64
|
+
<span class="option-label">{{ option.label }}</span>
|
|
65
|
+
<Icon v-if="selected" name="check" :size="14" class="option-check" />
|
|
66
|
+
</template>
|
|
67
|
+
</UiSelect>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API
|
|
73
|
+
|
|
74
|
+
| Prop | Type | Default | Description |
|
|
75
|
+
| --- | --- | --- | --- |
|
|
76
|
+
| `options` | `SelectOption<T>[]` | `[]` | Options to choose from. |
|
|
77
|
+
| `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
|
|
78
|
+
| `placeholder` | `string` | `"Select an option"` | Shown when nothing is selected. |
|
|
79
|
+
| `multiple` | `boolean` | `false` | Allow several selections; `v-model` becomes an array and the list stays open while picking. |
|
|
80
|
+
| `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
|
|
81
|
+
| `disabled` | `boolean` | `false` | Disables the control. |
|
|
82
|
+
| `label` | `string` | — | Visible label, linked to the control. |
|
|
83
|
+
| `hint` | `string` | — | Help text under the control, announced as its description. |
|
|
84
|
+
| `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
|
|
85
|
+
| `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
|
|
86
|
+
| `modelValue` | `T \| T[]` | — | The selected value, or values with `multiple`. |
|
|
87
|
+
|
|
88
|
+
| Event | Payload | Description |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| `update:modelValue` | `[value: T \| T[] \| undefined]` | `v-model:modelValue` update. |
|
|
91
|
+
|
|
92
|
+
| Slot | Props | Description |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| `value` | `{ selected: SelectOption<T>[]; placeholder: string; }` | Trigger content, replacing the selected label or placeholder. |
|
|
95
|
+
| `option` | `{ option: SelectOption<T>; selected: boolean; active: boolean; }` | Option content. |
|
|
96
|
+
| `chevron` | — | Replaces the trigger's chevron. |
|
|
97
|
+
| `check` | — | Replaces the selected option's check mark. |
|
|
98
|
+
|
|
99
|
+
Types:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
export interface SelectOption<T extends SelectValue = SelectValue> {
|
|
103
|
+
label: string;
|
|
104
|
+
value: T;
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type SelectValue = string | number;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Styling
|
|
112
|
+
|
|
113
|
+
- Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `select-control`, `select-trigger`, `select-value`, `select-chevron`, `select-listbox`, `select-option`, `select-option-check`, `select-option-label`, `field-message`
|
|
114
|
+
- State attributes: `data-field-error`, `data-field-name`, `data-select-open`, `data-select-error`, `data-select-placeholder`, `data-select-active`, `data-field-tone`
|
|
115
|
+
|
|
116
|
+
## Keyboard
|
|
117
|
+
|
|
118
|
+
| Keys | Action |
|
|
119
|
+
| ----------------- | ---------------------------------------------------- |
|
|
120
|
+
| `↓` / `↑` | Open, then move between options |
|
|
121
|
+
| `Enter` / `Space` | Open, or select the active option |
|
|
122
|
+
| `Home` / `End` | First / last option |
|
|
123
|
+
| Any letter | Jump to an option by label; repeat a letter to cycle |
|
|
124
|
+
| `Tab` | Keep the active option and close |
|
|
125
|
+
| `Escape` | Close |
|
|
126
|
+
|
|
127
|
+
## Accessibility
|
|
128
|
+
|
|
129
|
+
- Focus stays on the trigger; the active option is set with `aria-activedescendant`.
|