@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,135 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
> Temporary notifications.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### useToast()
|
|
8
|
+
|
|
9
|
+
Place `<UiToastViewport />` once near the app root.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div class="demo-row">
|
|
18
|
+
<UiButton variant="secondary" @click="toast.success('Changes saved')">Success</UiButton>
|
|
19
|
+
<UiButton variant="secondary" @click="toast.error('Couldn’t reach the server')">Error</UiButton>
|
|
20
|
+
<UiButton variant="secondary" @click="toast.info('3 new comments')">Info</UiButton>
|
|
21
|
+
<UiButton variant="ghost" @click="toast.info('Stays until dismissed', { duration: 0 })">
|
|
22
|
+
Persistent
|
|
23
|
+
</UiButton>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Action
|
|
29
|
+
|
|
30
|
+
`action` adds a button, e.g. Undo. Pressing it runs `onClick` and dismisses the toast.
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
const toast = useToast();
|
|
35
|
+
const archived = ref(false);
|
|
36
|
+
|
|
37
|
+
function archive() {
|
|
38
|
+
archived.value = true;
|
|
39
|
+
toast.info("Conversation archived", {
|
|
40
|
+
action: { label: "Undo", onClick: () => (archived.value = false) },
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div class="demo-stack">
|
|
47
|
+
<UiButton variant="secondary" :disabled="archived" @click="archive">Archive</UiButton>
|
|
48
|
+
<p class="demo-note">{{ archived ? "Archived" : "In your inbox" }}</p>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
### ToastViewport
|
|
56
|
+
|
|
57
|
+
| Prop | Type | Default | Description |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
| `label` | `string` | — | Accessible name of the live region. Defaults to the `notifications` translation. |
|
|
60
|
+
|
|
61
|
+
| Slot | Props | Description |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `default` | `{ toast: Toast; dismiss: () => void; }` | Renders each toast, replacing the message and close button. |
|
|
64
|
+
| `close-icon` | — | Replaces each close button's icon. |
|
|
65
|
+
|
|
66
|
+
Types:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
export interface Toast {
|
|
70
|
+
id: number;
|
|
71
|
+
message: string;
|
|
72
|
+
tone: ToastTone;
|
|
73
|
+
/** Milliseconds before auto-dismiss; `0` keeps it until dismissed. */
|
|
74
|
+
duration: number;
|
|
75
|
+
/** A button in the toast, e.g. "Undo". Pressing it also dismisses the toast. */
|
|
76
|
+
action?: ToastAction;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ToastTone = "success" | "danger" | "info";
|
|
80
|
+
|
|
81
|
+
export interface ToastAction {
|
|
82
|
+
label: string;
|
|
83
|
+
onClick: () => void;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### ToastItem
|
|
88
|
+
|
|
89
|
+
| Prop | Type | Default | Description |
|
|
90
|
+
| --- | --- | --- | --- |
|
|
91
|
+
| `toast` (required) | `Toast` | — | The toast to render, from `useToast().items`. |
|
|
92
|
+
|
|
93
|
+
| Event | Payload | Description |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| `dismiss` | `[id: number]` | Timed out or closed. |
|
|
96
|
+
|
|
97
|
+
| Slot | Props | Description |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| `default` | `{ toast: Toast; dismiss: () => void; }` | Replaces the message and close button. |
|
|
100
|
+
| `close-icon` | — | Replaces the close button's icon. |
|
|
101
|
+
|
|
102
|
+
Types:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
export interface Toast {
|
|
106
|
+
id: number;
|
|
107
|
+
message: string;
|
|
108
|
+
tone: ToastTone;
|
|
109
|
+
/** Milliseconds before auto-dismiss; `0` keeps it until dismissed. */
|
|
110
|
+
duration: number;
|
|
111
|
+
/** A button in the toast, e.g. "Undo". Pressing it also dismisses the toast. */
|
|
112
|
+
action?: ToastAction;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ToastTone = "success" | "danger" | "info";
|
|
116
|
+
|
|
117
|
+
export interface ToastAction {
|
|
118
|
+
label: string;
|
|
119
|
+
onClick: () => void;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Styling
|
|
124
|
+
|
|
125
|
+
- Parts (`[data-part="…"]`): `toast-viewport`, `toast`, `toast-message`, `toast-action`, `toast-close`
|
|
126
|
+
- State attributes: `data-toast-tone`
|
|
127
|
+
|
|
128
|
+
- Parts (`[data-part="…"]`): `toast`, `toast-message`, `toast-action`, `toast-close`
|
|
129
|
+
- State attributes: `data-toast-tone`
|
|
130
|
+
|
|
131
|
+
## Accessibility
|
|
132
|
+
|
|
133
|
+
- Toasts are announced politely; errors are announced right away.
|
|
134
|
+
- Timers pause on hover, focus and hidden tabs, then resume with the time left. `duration: 0` keeps a toast until dismissed.
|
|
135
|
+
- Shown above an open modal dialog, but the browser makes it inert there: it can't be clicked or announced until the dialog closes.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Toolbar
|
|
2
|
+
|
|
3
|
+
> A row of controls with a single tab stop.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Formatting
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
const toast = useToast();
|
|
12
|
+
const align = ref("left");
|
|
13
|
+
const alignments = [
|
|
14
|
+
{ label: "Left", value: "left" },
|
|
15
|
+
{ label: "Center", value: "center" },
|
|
16
|
+
{ label: "Right", value: "right" },
|
|
17
|
+
];
|
|
18
|
+
const more = [
|
|
19
|
+
{ label: "Insert table", value: "table" },
|
|
20
|
+
{ label: "Insert image", value: "image" },
|
|
21
|
+
];
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<UiToolbar label="Formatting">
|
|
26
|
+
<UiTooltip text="Bold" v-slot="{ attrs }">
|
|
27
|
+
<UiIconButton label="Bold" v-bind="attrs"><Icon name="bold" /></UiIconButton>
|
|
28
|
+
</UiTooltip>
|
|
29
|
+
<UiTooltip text="Italic" v-slot="{ attrs }">
|
|
30
|
+
<UiIconButton label="Italic" v-bind="attrs"><Icon name="italic" /></UiIconButton>
|
|
31
|
+
</UiTooltip>
|
|
32
|
+
<UiTooltip text="Underline" v-slot="{ attrs }">
|
|
33
|
+
<UiIconButton label="Underline" v-bind="attrs"><Icon name="underline" /></UiIconButton>
|
|
34
|
+
</UiTooltip>
|
|
35
|
+
<span class="demo-divider" aria-hidden="true" />
|
|
36
|
+
<UiSegmented v-model="align" :options="alignments" label="Alignment" size="small" />
|
|
37
|
+
<span class="demo-divider" aria-hidden="true" />
|
|
38
|
+
<UiMenu :items="more" label="Insert" @select="(v) => toast.info(v)" />
|
|
39
|
+
</UiToolbar>
|
|
40
|
+
</template>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
| Prop | Type | Default | Description |
|
|
46
|
+
| --- | --- | --- | --- |
|
|
47
|
+
| `label` | `string` | — | Accessible name for the toolbar. |
|
|
48
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Which arrow keys move between controls; also `aria-orientation`. |
|
|
49
|
+
|
|
50
|
+
| Slot | Props | Description |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `default` | — | Buttons, toggles, menus and other controls. |
|
|
53
|
+
|
|
54
|
+
## Styling
|
|
55
|
+
|
|
56
|
+
- Parts (`[data-part="…"]`): `toolbar`
|
|
57
|
+
- State attributes: `data-orientation`
|
|
58
|
+
|
|
59
|
+
## Keyboard
|
|
60
|
+
|
|
61
|
+
| Keys | Action |
|
|
62
|
+
| -------------- | ------------------------------------------------- |
|
|
63
|
+
| `Tab` | Enter or leave the toolbar |
|
|
64
|
+
| `←` / `→` | Previous / next control (`↑` / `↓` when vertical) |
|
|
65
|
+
| `Home` / `End` | First / last control |
|
|
66
|
+
|
|
67
|
+
## Accessibility
|
|
68
|
+
|
|
69
|
+
- Returning to the toolbar focuses the last focused control.
|
|
70
|
+
- Text fields keep their arrow keys for the caret.
|
|
71
|
+
- Nested widgets (radio groups, tabs, menus) keep their own arrow keys and count as one stop.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
> A short label shown on hover and focus.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<template>
|
|
11
|
+
<div class="demo-row">
|
|
12
|
+
<UiTooltip text="Bold" v-slot="{ attrs }">
|
|
13
|
+
<UiIconButton label="Bold" variant="secondary" v-bind="attrs"
|
|
14
|
+
><Icon name="bold"
|
|
15
|
+
/></UiIconButton>
|
|
16
|
+
</UiTooltip>
|
|
17
|
+
<UiTooltip text="Italic" v-slot="{ attrs }">
|
|
18
|
+
<UiIconButton label="Italic" variant="secondary" v-bind="attrs">
|
|
19
|
+
<Icon name="italic" />
|
|
20
|
+
</UiIconButton>
|
|
21
|
+
</UiTooltip>
|
|
22
|
+
<UiTooltip text="Underline" v-slot="{ attrs }">
|
|
23
|
+
<UiIconButton label="Underline" variant="secondary" v-bind="attrs">
|
|
24
|
+
<Icon name="underline" />
|
|
25
|
+
</UiIconButton>
|
|
26
|
+
</UiTooltip>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| `text` | `string` | — | Tooltip text. Without it, only the trigger renders. |
|
|
36
|
+
| `delay` | `number` | `250` | Milliseconds of hover or focus before it shows. |
|
|
37
|
+
|
|
38
|
+
| Slot | Props | Description |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `default` | `{ attrs: { "aria-describedby"?: string \| undefined; }; }` | The trigger. Bind `attrs` to it so the tooltip describes it. |
|
|
41
|
+
|
|
42
|
+
## Styling
|
|
43
|
+
|
|
44
|
+
For an arrow: `data-tooltip-side` is `top` or `bottom` after flipping, and `--ui-tooltip-arrow-x` is the trigger's centre from the tooltip's left edge.
|
|
45
|
+
|
|
46
|
+
- Parts (`[data-part="…"]`): `tooltip-root`, `tooltip`
|
|
47
|
+
- State attributes: `data-tooltip-side`
|
|
48
|
+
|
|
49
|
+
## Keyboard
|
|
50
|
+
|
|
51
|
+
| Keys | Action |
|
|
52
|
+
| -------- | ------------------------------------------------------------ |
|
|
53
|
+
| `Escape` | Hide without moving focus, leaving a surrounding dialog open |
|
|
54
|
+
|
|
55
|
+
## Accessibility
|
|
56
|
+
|
|
57
|
+
- Bind the slot's `attrs` to the trigger, which it then describes.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Visually Hidden
|
|
2
|
+
|
|
3
|
+
> Text for assistive technology only.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Basic
|
|
8
|
+
|
|
9
|
+
Screen readers announce the hidden text, so a list of "Read more" links stays distinct.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<template>
|
|
13
|
+
<div class="demo-stack">
|
|
14
|
+
<ul class="demo-list">
|
|
15
|
+
<li>
|
|
16
|
+
<span>Spring budget</span>
|
|
17
|
+
<a href="#">Read more<UiVisuallyHidden> about the spring budget</UiVisuallyHidden></a>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<span>Autumn forecast</span>
|
|
21
|
+
<a href="#">Read more<UiVisuallyHidden> about the autumn forecast</UiVisuallyHidden></a>
|
|
22
|
+
</li>
|
|
23
|
+
<li>
|
|
24
|
+
<span>Winter plan</span>
|
|
25
|
+
<a href="#">Read more<UiVisuallyHidden> about the winter plan</UiVisuallyHidden></a>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
<p class="demo-note">
|
|
29
|
+
The "about the …" text is read by screen readers, but isn't drawn on screen.
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
| --- | --- | --- | --- |
|
|
39
|
+
| `as` | `string` | `"span"` | Element to render, e.g. "div". |
|
|
40
|
+
|
|
41
|
+
| Slot | Props | Description |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| `default` | — | The text to keep for assistive technology. |
|
|
44
|
+
|
|
45
|
+
## Styling
|
|
46
|
+
|
|
47
|
+
- Parts (`[data-part="…"]`): `visually-hidden`
|
|
48
|
+
|
|
49
|
+
## Accessibility
|
|
50
|
+
|
|
51
|
+
- The content stays in the accessibility tree, out of the layout.
|
|
52
|
+
- It isn't `display: none`, so screen readers still announce it.
|
|
53
|
+
- Focusable content inside stays in the keyboard tab order.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Forms
|
|
2
|
+
|
|
3
|
+
> Form state and validation with zod, valibot or any Standard Schema library.
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
const toast = useToast();
|
|
10
|
+
// Not `ref="form"`: that name is taken by the `form` values below.
|
|
11
|
+
const formRef = useTemplateRef("signup-form");
|
|
12
|
+
|
|
13
|
+
const { form, errors, submit, processing } = useForm({
|
|
14
|
+
schema: z.object({
|
|
15
|
+
name: z.string().min(1, "Tell us your name."),
|
|
16
|
+
email: z.email("Enter a valid email address."),
|
|
17
|
+
password: z.string().min(8, "Use at least 8 characters."),
|
|
18
|
+
}),
|
|
19
|
+
initialValues: { name: "", email: "", password: "" },
|
|
20
|
+
formRef,
|
|
21
|
+
onSubmit: async (values) => {
|
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
23
|
+
toast.success(`Welcome, ${values.name}!`);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<form ref="signup-form" class="demo-form" novalidate @submit="submit">
|
|
30
|
+
<UiInput v-model="form.name" name="name" label="Name" :error="errors.name" />
|
|
31
|
+
<UiInput v-model="form.email" name="email" type="email" label="Email" :error="errors.email" />
|
|
32
|
+
<UiInput
|
|
33
|
+
v-model="form.password"
|
|
34
|
+
name="password"
|
|
35
|
+
type="password"
|
|
36
|
+
label="Password"
|
|
37
|
+
hint="At least 8 characters."
|
|
38
|
+
:error="errors.password"
|
|
39
|
+
/>
|
|
40
|
+
<UiButton type="submit" :loading="processing" full-width>
|
|
41
|
+
<template #spinner><span class="spinner" /></template>
|
|
42
|
+
Create account
|
|
43
|
+
</UiButton>
|
|
44
|
+
</form>
|
|
45
|
+
</template>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { z } from "zod";
|
|
52
|
+
|
|
53
|
+
const formRef = useTemplateRef("signup-form");
|
|
54
|
+
|
|
55
|
+
const { form, errors, submit, processing, isDirty, reset } = useForm({
|
|
56
|
+
schema: z.object({
|
|
57
|
+
email: z.email(),
|
|
58
|
+
password: z.string().min(8),
|
|
59
|
+
}),
|
|
60
|
+
initialValues: { email: "", password: "" },
|
|
61
|
+
formRef,
|
|
62
|
+
onSubmit: (values) => api.signUp(values),
|
|
63
|
+
mapError: (error) => (error instanceof ApiError ? error.fields : undefined),
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Give each field a `name` and its error:
|
|
68
|
+
|
|
69
|
+
```vue-html
|
|
70
|
+
<form ref="signup-form" @submit="submit">
|
|
71
|
+
<UiInput v-model="form.email" name="email" label="Email" :error="errors.email" />
|
|
72
|
+
<UiButton type="submit" :loading="processing">Sign up</UiButton>
|
|
73
|
+
</form>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Nested fields
|
|
77
|
+
|
|
78
|
+
Bind nested values as usual, and name each input by its path. Errors use the same path; array items use their index, like `items.0.name`.
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import { z } from "zod";
|
|
83
|
+
|
|
84
|
+
const toast = useToast();
|
|
85
|
+
const formRef = useTemplateRef("shipping-form");
|
|
86
|
+
|
|
87
|
+
const { form, errors, submit, processing } = useForm({
|
|
88
|
+
schema: z.object({
|
|
89
|
+
name: z.string().min(1, "Who's it for?"),
|
|
90
|
+
address: z.object({
|
|
91
|
+
street: z.string().min(1, "Enter a street address."),
|
|
92
|
+
city: z.string().min(1, "Enter a city."),
|
|
93
|
+
postcode: z.string().regex(/^\d{5}$/, "Use 5 digits."),
|
|
94
|
+
}),
|
|
95
|
+
}),
|
|
96
|
+
initialValues: { name: "", address: { street: "", city: "", postcode: "" } },
|
|
97
|
+
formRef,
|
|
98
|
+
onSubmit: async (values) => {
|
|
99
|
+
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
100
|
+
toast.success(`Shipping to ${values.address.city}.`);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<template>
|
|
106
|
+
<form ref="shipping-form" class="demo-form" novalidate @submit="submit">
|
|
107
|
+
<UiInput v-model="form.name" name="name" label="Full name" :error="errors.name" />
|
|
108
|
+
<UiInput
|
|
109
|
+
v-model="form.address.street"
|
|
110
|
+
name="address.street"
|
|
111
|
+
label="Street"
|
|
112
|
+
:error="errors['address.street']"
|
|
113
|
+
/>
|
|
114
|
+
<div class="demo-form-row">
|
|
115
|
+
<UiInput
|
|
116
|
+
v-model="form.address.city"
|
|
117
|
+
name="address.city"
|
|
118
|
+
label="City"
|
|
119
|
+
:error="errors['address.city']"
|
|
120
|
+
/>
|
|
121
|
+
<UiInput
|
|
122
|
+
v-model="form.address.postcode"
|
|
123
|
+
name="address.postcode"
|
|
124
|
+
label="Postcode"
|
|
125
|
+
inputmode="numeric"
|
|
126
|
+
:error="errors['address.postcode']"
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
<UiButton type="submit" :loading="processing" full-width>
|
|
130
|
+
<template #spinner><span class="spinner" /></template>
|
|
131
|
+
Ship it
|
|
132
|
+
</UiButton>
|
|
133
|
+
</form>
|
|
134
|
+
</template>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```vue-html
|
|
138
|
+
<UiInput
|
|
139
|
+
v-model="form.address.city"
|
|
140
|
+
name="address.city"
|
|
141
|
+
label="City"
|
|
142
|
+
:error="errors['address.city']"
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Options
|
|
147
|
+
|
|
148
|
+
| Option | Description |
|
|
149
|
+
| --------------- | ------------------------------------------------------------------------------- |
|
|
150
|
+
| `schema` | Any Standard Schema. Its output type is what `onSubmit` receives. |
|
|
151
|
+
| `initialValues` | Starting values; also the baseline for `isDirty` and `reset()`. |
|
|
152
|
+
| `onSubmit` | Called with validated values. Errors it throws go through `mapError`. |
|
|
153
|
+
| `mapError` | Turns a thrown error into field errors, e.g. a 422 from your API. |
|
|
154
|
+
| `onError` | Called with any thrown error. Without it, non-field errors rethrow. |
|
|
155
|
+
| `formRef` | The `<form>`; enables blur/input tracking and focusing the first invalid field. |
|
|
156
|
+
| `validateOn` | When a field's error appears: `"blur"` (default), `"input"` or `"submit"`. |
|
|
157
|
+
|
|
158
|
+
## Returns
|
|
159
|
+
|
|
160
|
+
| Key | Description |
|
|
161
|
+
| --------------------------- | ------------------------------------------------------------------------- |
|
|
162
|
+
| `form` | Reactive values to bind with `v-model`. |
|
|
163
|
+
| `errors` | Visible errors, keyed by field path (`"address.city"` for nested fields). |
|
|
164
|
+
| `submit` | Validates, then calls `onSubmit`. Use as the form's `@submit`. |
|
|
165
|
+
| `processing` / `validating` | Submit and validation in flight. |
|
|
166
|
+
| `isValid` / `isDirty` | Schema validity, and whether values differ from the baseline. |
|
|
167
|
+
| `reset()` / `setValues()` | Restore the baseline, or set new values as the baseline. |
|
|
168
|
+
| `setErrors()` / `touch()` | Show server errors, or mark a field touched. |
|
|
169
|
+
|
|
170
|
+
## Plain HTML forms
|
|
171
|
+
|
|
172
|
+
A field with a `name` is sent when a regular `<form>` submits, just like a native input. A multiple Select, Combobox, TagInput or CheckboxGroup sends one value per pick; a Switch that's off sends nothing.
|
|
173
|
+
|
|
174
|
+
```vue-html
|
|
175
|
+
<form method="post" action="/settings">
|
|
176
|
+
<UiSelect name="plan" v-model="plan" :options="plans" label="Plan" />
|
|
177
|
+
<UiSwitch name="newsletter" v-model="newsletter" label="Newsletter" />
|
|
178
|
+
<UiButton type="submit">Save</UiButton>
|
|
179
|
+
</form>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`useForm` uses the same `name` to show a field's error once you leave it.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
> Headless, accessible Vue 3 components.
|
|
4
|
+
|
|
5
|
+
The components handle keyboard, focus and ARIA, following the WAI-ARIA Authoring Practices. How they look is up to you: every element has a `data-part` attribute, and states are attributes too.
|
|
6
|
+
|
|
7
|
+
- `core.css` is required, but it only positions and hides things. No visual styles.
|
|
8
|
+
- Works with server rendering in Vue and Nuxt.
|
|
9
|
+
- No dependencies besides `vue`, and you only ship what you import.
|
|
10
|
+
|
|
11
|
+
Needs a browser with the Popover API, CSS anchor positioning and `@starting-style`.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
> Nuxt module or Vue plugin.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @humanonlyweb/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Nuxt
|
|
12
|
+
|
|
13
|
+
Components and composables are auto-imported, and `core.css` is added for you.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// nuxt.config.ts
|
|
17
|
+
export default defineNuxtConfig({
|
|
18
|
+
modules: ["@humanonlyweb/ui/nuxt"],
|
|
19
|
+
ui: {
|
|
20
|
+
prefix: "Ui", // <UiButton>, <UiSelect>, …
|
|
21
|
+
css: true, // inject core.css
|
|
22
|
+
composables: true, // auto-import useForm, useField, useToast
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Vue
|
|
28
|
+
|
|
29
|
+
Install the plugin and import `core.css`. `link` is your router's link component, used by `<Button to>`; without it, a string `to` becomes a plain `<a>`.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createUi } from "@humanonlyweb/ui";
|
|
33
|
+
import { createApp } from "vue";
|
|
34
|
+
import { RouterLink } from "vue-router";
|
|
35
|
+
import "@humanonlyweb/ui/core.css";
|
|
36
|
+
|
|
37
|
+
createApp(App)
|
|
38
|
+
.use(createUi({ link: RouterLink }))
|
|
39
|
+
.mount("#app");
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then import what you use:
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<script setup lang="ts">
|
|
46
|
+
import { Button, Select } from "@humanonlyweb/ui";
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The examples use the Nuxt names, like `<UiButton>`. In Vue, drop the `Ui`.
|
|
51
|
+
|
|
52
|
+
## AI agents
|
|
53
|
+
|
|
54
|
+
The package ships these docs as Markdown, matching the installed version. Point your agent at them in `AGENTS.md` or `CLAUDE.md`:
|
|
55
|
+
|
|
56
|
+
```md
|
|
57
|
+
For @humanonlyweb/ui, read node_modules/@humanonlyweb/ui/dist/docs/README.md
|
|
58
|
+
before using a component. It indexes a page per component: props, events, slots
|
|
59
|
+
and styling hooks.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Toasts
|
|
63
|
+
|
|
64
|
+
Add the viewport once, near your app root:
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<NuxtPage />
|
|
69
|
+
<UiToastViewport />
|
|
70
|
+
</template>
|
|
71
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Localisation
|
|
2
|
+
|
|
3
|
+
> The components' built-in text, in your language.
|
|
4
|
+
|
|
5
|
+
A few strings come from the components themselves: button names like “Close”, counts like “3 of 80 characters”, empty states. They're English by default, and you can override any of them. Strings with a value in them are functions, so each language can put the words in its own order.
|
|
6
|
+
|
|
7
|
+
## Vue
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createUi } from "@humanonlyweb/ui";
|
|
11
|
+
|
|
12
|
+
app.use(
|
|
13
|
+
createUi({
|
|
14
|
+
translations: {
|
|
15
|
+
close: "Fermer",
|
|
16
|
+
characterCount: (count, max) => `${count} sur ${max} caractères`,
|
|
17
|
+
showPassword: "Afficher le mot de passe",
|
|
18
|
+
page: (page) => `Page ${page}`,
|
|
19
|
+
keys: { command: "Commande" },
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To switch languages without a reload, pass a ref instead, e.g. a `computed` from your i18n locale.
|
|
26
|
+
|
|
27
|
+
## Nuxt
|
|
28
|
+
|
|
29
|
+
Set them in a plugin:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// app/plugins/ui-translations.ts
|
|
33
|
+
import { useUiConfig } from "@humanonlyweb/ui";
|
|
34
|
+
|
|
35
|
+
export default defineNuxtPlugin(() => {
|
|
36
|
+
useUiConfig().translations.value = { close: "Fermer" };
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Keys
|
|
41
|
+
|
|
42
|
+
`defaultTranslations` lists every key with its English text; the type is `UiTranslations`. When a prop sets the same text, like ConfirmDialog's `confirm-text`, the prop wins.
|
package/dist/docs/ssr.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# SSR
|
|
2
|
+
|
|
3
|
+
> Setup needed for server rendering.
|
|
4
|
+
|
|
5
|
+
## Kbd
|
|
6
|
+
|
|
7
|
+
`<Kbd>` shows ⌘ on Apple devices and Ctrl elsewhere. Nuxt works out which from the request. In Vue, pass it per request:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createUi, platformFrom } from "@humanonlyweb/ui";
|
|
11
|
+
import { createSSRApp } from "vue";
|
|
12
|
+
|
|
13
|
+
const app = createSSRApp(App).use(
|
|
14
|
+
createUi({ platform: platformFrom(request.headers.get("user-agent")) }),
|
|
15
|
+
);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Without it, `<Kbd>` shows Ctrl until the page has loaded.
|
|
19
|
+
|
|
20
|
+
If you cache rendered pages, the cached copy keeps the first visitor's platform. Vary the cache on `Sec-CH-UA-Platform` (or `User-Agent`), or leave `platform` out on cached routes so the browser works it out.
|
|
21
|
+
|
|
22
|
+
## Multiple apps
|
|
23
|
+
|
|
24
|
+
Two Vue apps on one page need different `app.config.idPrefix` values, so their generated ids don't clash.
|