@humanonlyweb/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/dist/components/accordion/Accordion.js +60 -0
  4. package/dist/components/accordion/Accordion.vue.d.ts +28 -0
  5. package/dist/components/accordion/AccordionItem.js +102 -0
  6. package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
  7. package/dist/components/avatar/Avatar.js +52 -0
  8. package/dist/components/avatar/Avatar.vue.d.ts +26 -0
  9. package/dist/components/avatar/AvatarGroup.js +48 -0
  10. package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
  11. package/dist/components/button/Button.js +95 -0
  12. package/dist/components/button/Button.vue.d.ts +74 -0
  13. package/dist/components/button/IconButton.js +47 -0
  14. package/dist/components/button/IconButton.vue.d.ts +115 -0
  15. package/dist/components/checkbox/Checkbox.js +93 -0
  16. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  17. package/dist/components/combobox/Combobox.js +294 -0
  18. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  19. package/dist/components/context-menu/ContextMenu.js +170 -0
  20. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  21. package/dist/components/dialog/ConfirmDialog.js +103 -0
  22. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  23. package/dist/components/dialog/Dialog.js +160 -0
  24. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  25. package/dist/components/field/FieldMessage.js +31 -0
  26. package/dist/components/input/Input.js +111 -0
  27. package/dist/components/input/Input.vue.d.ts +50 -0
  28. package/dist/components/kbd/Kbd.js +48 -0
  29. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  30. package/dist/components/menu/Menu.js +124 -0
  31. package/dist/components/menu/Menu.vue.d.ts +41 -0
  32. package/dist/components/otp-input/OtpInput.js +179 -0
  33. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  34. package/dist/components/popover/Popover.js +83 -0
  35. package/dist/components/popover/Popover.vue.d.ts +37 -0
  36. package/dist/components/radio-group/RadioGroup.js +125 -0
  37. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  38. package/dist/components/segmented/Segmented.js +110 -0
  39. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  40. package/dist/components/select/Select.js +231 -0
  41. package/dist/components/select/Select.vue.d.ts +59 -0
  42. package/dist/components/slider/Slider.js +196 -0
  43. package/dist/components/slider/Slider.vue.d.ts +49 -0
  44. package/dist/components/spin-button/SpinButton.js +231 -0
  45. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  46. package/dist/components/split-button/SplitButton.js +69 -0
  47. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  48. package/dist/components/switch/Switch.js +95 -0
  49. package/dist/components/switch/Switch.vue.d.ts +42 -0
  50. package/dist/components/table/Table.js +173 -0
  51. package/dist/components/table/Table.vue.d.ts +45 -0
  52. package/dist/components/tabs/Tabs.js +99 -0
  53. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  54. package/dist/components/textarea/Textarea.js +118 -0
  55. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  56. package/dist/components/toast/ToastItem.js +91 -0
  57. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  58. package/dist/components/toast/ToastViewport.js +56 -0
  59. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  60. package/dist/components/toolbar/Toolbar.js +91 -0
  61. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  62. package/dist/components/tooltip/Tooltip.js +85 -0
  63. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  64. package/dist/composables/internal/env.js +5 -0
  65. package/dist/composables/internal/is-equal.js +14 -0
  66. package/dist/composables/internal/on-click-outside.js +18 -0
  67. package/dist/composables/internal/standard-schema.d.ts +38 -0
  68. package/dist/composables/internal/use-document-visibility.js +16 -0
  69. package/dist/composables/internal/use-event-listener.js +24 -0
  70. package/dist/composables/internal/use-interval-fn.js +21 -0
  71. package/dist/composables/internal/use-resize-observer.js +21 -0
  72. package/dist/composables/internal/use-timeout-fn.js +25 -0
  73. package/dist/composables/use-accordion.d.ts +9 -0
  74. package/dist/composables/use-accordion.js +10 -0
  75. package/dist/composables/use-combobox.d.ts +44 -0
  76. package/dist/composables/use-combobox.js +185 -0
  77. package/dist/composables/use-field.d.ts +17 -0
  78. package/dist/composables/use-field.js +27 -0
  79. package/dist/composables/use-form.d.ts +44 -0
  80. package/dist/composables/use-form.js +146 -0
  81. package/dist/composables/use-menu.d.ts +26 -0
  82. package/dist/composables/use-menu.js +117 -0
  83. package/dist/composables/use-platform.d.ts +17 -0
  84. package/dist/composables/use-platform.js +126 -0
  85. package/dist/composables/use-popover.d.ts +35 -0
  86. package/dist/composables/use-popover.js +49 -0
  87. package/dist/composables/use-roving-selection.d.ts +22 -0
  88. package/dist/composables/use-roving-selection.js +65 -0
  89. package/dist/composables/use-select.d.ts +31 -0
  90. package/dist/composables/use-select.js +169 -0
  91. package/dist/composables/use-slide-indicator.d.ts +24 -0
  92. package/dist/composables/use-slide-indicator.js +52 -0
  93. package/dist/composables/use-toast.d.ts +23 -0
  94. package/dist/composables/use-toast.js +51 -0
  95. package/dist/config.d.ts +40 -0
  96. package/dist/config.js +35 -0
  97. package/dist/docs/README.md +44 -0
  98. package/dist/docs/changelog.md +14 -0
  99. package/dist/docs/components/accordion.md +100 -0
  100. package/dist/docs/components/avatar-group.md +58 -0
  101. package/dist/docs/components/avatar.md +40 -0
  102. package/dist/docs/components/button.md +109 -0
  103. package/dist/docs/components/checkbox.md +123 -0
  104. package/dist/docs/components/combobox.md +207 -0
  105. package/dist/docs/components/confirm-dialog.md +107 -0
  106. package/dist/docs/components/context-menu.md +98 -0
  107. package/dist/docs/components/dialog.md +127 -0
  108. package/dist/docs/components/icon-button.md +47 -0
  109. package/dist/docs/components/input.md +89 -0
  110. package/dist/docs/components/kbd.md +41 -0
  111. package/dist/docs/components/menu.md +112 -0
  112. package/dist/docs/components/otp-input.md +92 -0
  113. package/dist/docs/components/popover.md +72 -0
  114. package/dist/docs/components/radio-group.md +114 -0
  115. package/dist/docs/components/segmented.md +96 -0
  116. package/dist/docs/components/select.md +129 -0
  117. package/dist/docs/components/slider.md +105 -0
  118. package/dist/docs/components/spin-button.md +73 -0
  119. package/dist/docs/components/split-button.md +64 -0
  120. package/dist/docs/components/switch.md +71 -0
  121. package/dist/docs/components/table.md +241 -0
  122. package/dist/docs/components/tabs.md +106 -0
  123. package/dist/docs/components/textarea.md +46 -0
  124. package/dist/docs/components/toast.md +135 -0
  125. package/dist/docs/components/toolbar.md +71 -0
  126. package/dist/docs/components/tooltip.md +57 -0
  127. package/dist/docs/forms.md +182 -0
  128. package/dist/docs/index.md +11 -0
  129. package/dist/docs/installation.md +73 -0
  130. package/dist/docs/localisation.md +40 -0
  131. package/dist/docs/ssr.md +24 -0
  132. package/dist/docs/styling.md +66 -0
  133. package/dist/index.d.ts +46 -0
  134. package/dist/index.js +44 -0
  135. package/dist/nuxt/module.d.ts +15 -0
  136. package/dist/nuxt/module.js +72 -0
  137. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  138. package/dist/nuxt/runtime/plugin.js +24 -0
  139. package/dist/package.js +4 -0
  140. package/dist/styles/core.css +284 -0
  141. package/dist/translations.d.ts +71 -0
  142. package/dist/translations.js +55 -0
  143. package/dist/types.d.ts +61 -0
  144. package/package.json +93 -4
@@ -0,0 +1,46 @@
1
+ # Textarea
2
+
3
+ > A multi-line input with an optional character limit.
4
+
5
+ ## Examples
6
+
7
+ ### With a limit
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const bio = ref("Building the web for humans.");
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-field">
16
+ <UiTextarea v-model="bio" label="Bio" :max-length="80" :rows="3" />
17
+ </div>
18
+ </template>
19
+ ```
20
+
21
+ ## API
22
+
23
+ | Prop | Type | Default | Description |
24
+ | --- | --- | --- | --- |
25
+ | `label` | `string` | — | Visible label, linked to the control. |
26
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
27
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
28
+ | `maxLength` | `number` | — | Character limit. Shows a live counter and flags values already over it. |
29
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
30
+ | `disabled` | `boolean` | `false` | Disables the control. |
31
+ | `rows` | `number` | `4` | Visible text lines. |
32
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
33
+ | `modelValue` | `string` | — | The value. |
34
+
35
+ | Event | Payload | Description |
36
+ | --- | --- | --- |
37
+ | `update:modelValue` | `[value: string \| undefined]` | `v-model:modelValue` update. |
38
+
39
+ ## Styling
40
+
41
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `textarea`, `field-footer`, `field-count`, `field-message`
42
+ - State attributes: `data-field-error`, `data-field-count-exceeded`, `data-field-tone`
43
+
44
+ ## Accessibility
45
+
46
+ - Values over the limit are flagged, not truncated.
@@ -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,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 or Combobox 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,73 @@
1
+ # Installation
2
+
3
+ > Nuxt module or Vue plugin.
4
+
5
+ ## Install
6
+
7
+ Not on npm yet, so this command won't work. It will once the package is published.
8
+
9
+ ```bash
10
+ bun add @humanonlyweb/ui
11
+ ```
12
+
13
+ ## Nuxt
14
+
15
+ Components and composables are auto-imported, and `core.css` is added for you.
16
+
17
+ ```ts
18
+ // nuxt.config.ts
19
+ export default defineNuxtConfig({
20
+ modules: ["@humanonlyweb/ui/nuxt"],
21
+ ui: {
22
+ prefix: "Ui", // <UiButton>, <UiSelect>, …
23
+ css: true, // inject core.css
24
+ composables: true, // auto-import useForm, useField, useToast
25
+ },
26
+ });
27
+ ```
28
+
29
+ ## Vue
30
+
31
+ 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>`.
32
+
33
+ ```ts
34
+ import { createUi } from "@humanonlyweb/ui";
35
+ import { createApp } from "vue";
36
+ import { RouterLink } from "vue-router";
37
+ import "@humanonlyweb/ui/core.css";
38
+
39
+ createApp(App)
40
+ .use(createUi({ link: RouterLink }))
41
+ .mount("#app");
42
+ ```
43
+
44
+ Then import what you use:
45
+
46
+ ```vue
47
+ <script setup lang="ts">
48
+ import { Button, Select } from "@humanonlyweb/ui";
49
+ </script>
50
+ ```
51
+
52
+ The examples use the Nuxt names, like `<UiButton>`. In Vue, drop the `Ui`.
53
+
54
+ ## AI agents
55
+
56
+ The package ships these docs as Markdown, matching the installed version. Point your agent at them in `AGENTS.md` or `CLAUDE.md`:
57
+
58
+ ```md
59
+ For @humanonlyweb/ui, read node_modules/@humanonlyweb/ui/dist/docs/README.md
60
+ before using a component. It indexes a page per component: props, events, slots
61
+ and styling hooks.
62
+ ```
63
+
64
+ ## Toasts
65
+
66
+ Add the viewport once, near your app root:
67
+
68
+ ```vue
69
+ <template>
70
+ <NuxtPage />
71
+ <UiToastViewport />
72
+ </template>
73
+ ```
@@ -0,0 +1,40 @@
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
+ keys: { command: "Commande" },
18
+ },
19
+ }),
20
+ );
21
+ ```
22
+
23
+ To switch languages without a reload, pass a ref instead, e.g. a `computed` from your i18n locale.
24
+
25
+ ## Nuxt
26
+
27
+ Set them in a plugin:
28
+
29
+ ```ts
30
+ // app/plugins/ui-translations.ts
31
+ import { useUiConfig } from "@humanonlyweb/ui";
32
+
33
+ export default defineNuxtPlugin(() => {
34
+ useUiConfig().translations.value = { close: "Fermer" };
35
+ });
36
+ ```
37
+
38
+ ## Keys
39
+
40
+ `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.
@@ -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.