@aleph-alpha/ui-library 6.2.0 → 6.3.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/dist/system/components/UiButtonGroup/index.d.ts +1 -0
- package/dist/system/components/UiCodeBlock/types.d.ts +11 -0
- package/dist/system/components/UiInputGroup/UiInputGroup.vue.d.ts +20 -0
- package/dist/system/components/UiInputGroup/UiInputGroupAddon.vue.d.ts +20 -0
- package/dist/system/components/UiInputGroup/UiInputGroupButton.vue.d.ts +17 -0
- package/dist/system/components/UiInputGroup/UiInputGroupInput.vue.d.ts +11 -0
- package/dist/system/components/UiInputGroup/UiInputGroupTextarea.vue.d.ts +11 -0
- package/dist/system/components/UiInputGroup/index.d.ts +7 -0
- package/dist/system/components/UiInputGroup/types.d.ts +151 -0
- package/dist/system/components/UiLabel/UiLabel.vue.d.ts +3 -1
- package/dist/system/components/UiLabel/types.d.ts +7 -0
- package/dist/system/components/core/input-group/InputGroup.vue.d.ts +25 -0
- package/dist/system/components/core/input-group/InputGroupAddon.vue.d.ts +25 -0
- package/dist/system/components/core/input-group/InputGroupButton.vue.d.ts +28 -0
- package/dist/system/components/core/input-group/InputGroupInput.vue.d.ts +12 -0
- package/dist/system/components/core/input-group/InputGroupText.vue.d.ts +21 -0
- package/dist/system/components/core/input-group/InputGroupTextarea.vue.d.ts +12 -0
- package/dist/system/components/core/input-group/index.d.ts +18 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/lib.js +14300 -13931
- package/package.json +1 -1
- package/src/components/UiButtonGroup/index.ts +4 -0
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +83 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +30 -2
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +21 -0
- package/src/components/UiCodeBlock/types.ts +11 -0
- package/src/components/UiField/UiField.stories.ts +329 -52
- package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
- package/src/components/UiInput/UiInput.stories.ts +3 -1
- package/src/components/UiInput/UiInput.vue +26 -5
- package/src/components/UiInputGroup/UiInputGroup.stories.ts +2083 -0
- package/src/components/UiInputGroup/UiInputGroup.vue +18 -0
- package/src/components/UiInputGroup/UiInputGroupAddon.vue +18 -0
- package/src/components/UiInputGroup/UiInputGroupButton.vue +30 -0
- package/src/components/UiInputGroup/UiInputGroupInput.vue +16 -0
- package/src/components/UiInputGroup/UiInputGroupTextarea.vue +16 -0
- package/src/components/UiInputGroup/__tests__/UiInputGroup.test.ts +195 -0
- package/src/components/UiInputGroup/index.ts +10 -0
- package/src/components/UiInputGroup/types.ts +171 -0
- package/src/components/UiLabel/UiLabel.vue +7 -2
- package/src/components/UiLabel/types.ts +8 -0
- package/src/components/core/button/index.ts +23 -13
- package/src/components/core/button-group/ButtonGroupText.vue +4 -0
- package/src/components/core/button-group/index.ts +6 -2
- package/src/components/core/field/FieldError.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/index.ts +7 -1
- package/src/components/core/input/Input.vue +4 -1
- package/src/components/core/input-group/InputGroup.vue +27 -0
- package/src/components/core/input-group/InputGroupAddon.vue +53 -0
- package/src/components/core/input-group/InputGroupButton.vue +35 -0
- package/src/components/core/input-group/InputGroupInput.vue +65 -0
- package/src/components/core/input-group/InputGroupText.vue +26 -0
- package/src/components/core/input-group/InputGroupTextarea.vue +62 -0
- package/src/components/core/input-group/index.ts +103 -0
- package/src/components/core/label/Label.vue +1 -1
- package/src/components/index.ts +1 -0
- package/src/theme/Typography.stories.ts +144 -6
- package/src/theme/__tests__/typography.test.ts +136 -0
|
@@ -0,0 +1,2083 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import UiInputGroup from './UiInputGroup.vue';
|
|
5
|
+
import UiInputGroupAddon from './UiInputGroupAddon.vue';
|
|
6
|
+
import UiInputGroupButton from './UiInputGroupButton.vue';
|
|
7
|
+
import UiInputGroupInput from './UiInputGroupInput.vue';
|
|
8
|
+
import UiInputGroupTextarea from './UiInputGroupTextarea.vue';
|
|
9
|
+
import { UiInputGroupText } from './index';
|
|
10
|
+
import { UiButtonGroup, UiButtonGroupText } from '../UiButtonGroup';
|
|
11
|
+
import {
|
|
12
|
+
UiDropdownMenu,
|
|
13
|
+
UiDropdownMenuContent,
|
|
14
|
+
UiDropdownMenuItem,
|
|
15
|
+
UiDropdownMenuTrigger,
|
|
16
|
+
} from '../UiDropdownMenu';
|
|
17
|
+
import { UiIcon } from '../UiIcon';
|
|
18
|
+
import { UiLabel } from '../UiLabel';
|
|
19
|
+
import { UiSeparator } from '../UiSeparator';
|
|
20
|
+
import { UiSpinner } from '../UiSpinner';
|
|
21
|
+
import { UiTooltip } from '../UiTooltip';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `UiInputGroup` attaches addons — icons, text affixes, keyboard shortcuts,
|
|
25
|
+
* buttons, or status — to an input or textarea inside one shared field
|
|
26
|
+
* boundary. The group carries the border, focus ring, and error ring for the
|
|
27
|
+
* control inside it, so the field and its addons read as a single control.
|
|
28
|
+
*/
|
|
29
|
+
const meta: Meta<typeof UiInputGroup> = {
|
|
30
|
+
title: 'Components/UiInputGroup',
|
|
31
|
+
component: UiInputGroup,
|
|
32
|
+
tags: ['autodocs'],
|
|
33
|
+
argTypes: {
|
|
34
|
+
type: {
|
|
35
|
+
control: 'select',
|
|
36
|
+
options: ['input', 'textarea'],
|
|
37
|
+
description:
|
|
38
|
+
"The kind of control the group hosts. `'textarea'` lets the group grow with its content instead of staying a fixed-height row.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default meta;
|
|
44
|
+
|
|
45
|
+
type Story = StoryObj<typeof UiInputGroup>;
|
|
46
|
+
|
|
47
|
+
// `UiInputGroupInput` / `UiInputGroupTextarea` wire `defineModel`
|
|
48
|
+
// (`update:modelValue`). Play functions bind these module-level spies via
|
|
49
|
+
// `@update:model-value` and `mockClear()` them first.
|
|
50
|
+
const onUpdate = fn();
|
|
51
|
+
const onClick = fn();
|
|
52
|
+
|
|
53
|
+
const defaultTemplateSource = `<script setup lang="ts">
|
|
54
|
+
import {
|
|
55
|
+
UiInputGroup,
|
|
56
|
+
UiInputGroupAddon,
|
|
57
|
+
UiInputGroupButton,
|
|
58
|
+
UiInputGroupInput,
|
|
59
|
+
UiInputGroupText,
|
|
60
|
+
UiInputGroupTextarea,
|
|
61
|
+
UiDropdownMenu,
|
|
62
|
+
UiDropdownMenuContent,
|
|
63
|
+
UiDropdownMenuItem,
|
|
64
|
+
UiDropdownMenuTrigger,
|
|
65
|
+
UiIcon,
|
|
66
|
+
UiSeparator,
|
|
67
|
+
UiTooltip,
|
|
68
|
+
} from '@aleph-alpha/ui-library'
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<template>
|
|
72
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
73
|
+
<UiInputGroup>
|
|
74
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
75
|
+
<UiInputGroupAddon>
|
|
76
|
+
<UiIcon name="search" :size="16" />
|
|
77
|
+
</UiInputGroupAddon>
|
|
78
|
+
<UiInputGroupAddon align="inline-end">
|
|
79
|
+
<UiInputGroupText>12 results</UiInputGroupText>
|
|
80
|
+
</UiInputGroupAddon>
|
|
81
|
+
</UiInputGroup>
|
|
82
|
+
|
|
83
|
+
<UiInputGroup>
|
|
84
|
+
<UiInputGroupInput placeholder="example.com" aria-label="Website address" class="!pl-1" />
|
|
85
|
+
<UiInputGroupAddon>
|
|
86
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
87
|
+
</UiInputGroupAddon>
|
|
88
|
+
<UiInputGroupAddon align="inline-end">
|
|
89
|
+
<UiTooltip content="We verify the address before saving.">
|
|
90
|
+
<UiInputGroupButton size="icon-xs" aria-label="More information" class="rounded-full">
|
|
91
|
+
<UiIcon name="info" :size="14" />
|
|
92
|
+
</UiInputGroupButton>
|
|
93
|
+
</UiTooltip>
|
|
94
|
+
</UiInputGroupAddon>
|
|
95
|
+
</UiInputGroup>
|
|
96
|
+
|
|
97
|
+
<UiInputGroup type="textarea">
|
|
98
|
+
<UiInputGroupTextarea placeholder="Ask, Search or Chat..." aria-label="Message" />
|
|
99
|
+
<UiInputGroupAddon align="block-end">
|
|
100
|
+
<UiInputGroupButton variant="outline" size="icon-xs" aria-label="Attach" class="rounded-full">
|
|
101
|
+
<UiIcon name="plus" :size="14" />
|
|
102
|
+
</UiInputGroupButton>
|
|
103
|
+
<UiDropdownMenu>
|
|
104
|
+
<UiDropdownMenuTrigger as-child>
|
|
105
|
+
<UiInputGroupButton>Auto</UiInputGroupButton>
|
|
106
|
+
</UiDropdownMenuTrigger>
|
|
107
|
+
<UiDropdownMenuContent side="top" align="start">
|
|
108
|
+
<UiDropdownMenuItem>Auto</UiDropdownMenuItem>
|
|
109
|
+
<UiDropdownMenuItem>Agent</UiDropdownMenuItem>
|
|
110
|
+
<UiDropdownMenuItem>Manual</UiDropdownMenuItem>
|
|
111
|
+
</UiDropdownMenuContent>
|
|
112
|
+
</UiDropdownMenu>
|
|
113
|
+
<UiInputGroupText class="ml-auto">52% used</UiInputGroupText>
|
|
114
|
+
<UiSeparator orientation="vertical" class="!h-4" />
|
|
115
|
+
<UiInputGroupButton variant="default" size="icon-xs" aria-label="Send" class="rounded-full" disabled>
|
|
116
|
+
<UiIcon name="arrow-up" :size="14" />
|
|
117
|
+
</UiInputGroupButton>
|
|
118
|
+
</UiInputGroupAddon>
|
|
119
|
+
</UiInputGroup>
|
|
120
|
+
|
|
121
|
+
<UiInputGroup>
|
|
122
|
+
<UiInputGroupInput placeholder="@username" aria-label="Username" />
|
|
123
|
+
<UiInputGroupAddon align="inline-end">
|
|
124
|
+
<UiIcon name="circle-check" :size="16" aria-label="Username verified" />
|
|
125
|
+
</UiInputGroupAddon>
|
|
126
|
+
</UiInputGroup>
|
|
127
|
+
</div>
|
|
128
|
+
</template>`;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The four building blocks in one view: an icon prefix with a status suffix,
|
|
132
|
+
* a text prefix with an inline action, a textarea with a block toolbar, and
|
|
133
|
+
* a verified-state suffix. Everything sits inside one field boundary.
|
|
134
|
+
*/
|
|
135
|
+
export const Default: Story = {
|
|
136
|
+
render: () => ({
|
|
137
|
+
components: {
|
|
138
|
+
UiInputGroup,
|
|
139
|
+
UiInputGroupAddon,
|
|
140
|
+
UiInputGroupButton,
|
|
141
|
+
UiInputGroupInput,
|
|
142
|
+
UiInputGroupText,
|
|
143
|
+
UiInputGroupTextarea,
|
|
144
|
+
UiDropdownMenu,
|
|
145
|
+
UiDropdownMenuContent,
|
|
146
|
+
UiDropdownMenuItem,
|
|
147
|
+
UiDropdownMenuTrigger,
|
|
148
|
+
UiIcon,
|
|
149
|
+
UiSeparator,
|
|
150
|
+
UiTooltip,
|
|
151
|
+
},
|
|
152
|
+
template: `
|
|
153
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
154
|
+
<UiInputGroup>
|
|
155
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
156
|
+
<UiInputGroupAddon>
|
|
157
|
+
<UiIcon name="search" :size="16" />
|
|
158
|
+
</UiInputGroupAddon>
|
|
159
|
+
<UiInputGroupAddon align="inline-end">
|
|
160
|
+
<UiInputGroupText>12 results</UiInputGroupText>
|
|
161
|
+
</UiInputGroupAddon>
|
|
162
|
+
</UiInputGroup>
|
|
163
|
+
|
|
164
|
+
<UiInputGroup>
|
|
165
|
+
<UiInputGroupInput placeholder="example.com" aria-label="Website address" class="!pl-1" />
|
|
166
|
+
<UiInputGroupAddon>
|
|
167
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
168
|
+
</UiInputGroupAddon>
|
|
169
|
+
<UiInputGroupAddon align="inline-end">
|
|
170
|
+
<UiTooltip content="We verify the address before saving.">
|
|
171
|
+
<UiInputGroupButton size="icon-xs" aria-label="More information" class="rounded-full">
|
|
172
|
+
<UiIcon name="info" :size="14" />
|
|
173
|
+
</UiInputGroupButton>
|
|
174
|
+
</UiTooltip>
|
|
175
|
+
</UiInputGroupAddon>
|
|
176
|
+
</UiInputGroup>
|
|
177
|
+
|
|
178
|
+
<UiInputGroup type="textarea">
|
|
179
|
+
<UiInputGroupTextarea placeholder="Ask, Search or Chat..." aria-label="Message" />
|
|
180
|
+
<UiInputGroupAddon align="block-end">
|
|
181
|
+
<UiInputGroupButton variant="outline" size="icon-xs" aria-label="Attach" class="rounded-full">
|
|
182
|
+
<UiIcon name="plus" :size="14" />
|
|
183
|
+
</UiInputGroupButton>
|
|
184
|
+
<UiDropdownMenu>
|
|
185
|
+
<UiDropdownMenuTrigger as-child>
|
|
186
|
+
<UiInputGroupButton>Auto</UiInputGroupButton>
|
|
187
|
+
</UiDropdownMenuTrigger>
|
|
188
|
+
<UiDropdownMenuContent side="top" align="start">
|
|
189
|
+
<UiDropdownMenuItem>Auto</UiDropdownMenuItem>
|
|
190
|
+
<UiDropdownMenuItem>Agent</UiDropdownMenuItem>
|
|
191
|
+
<UiDropdownMenuItem>Manual</UiDropdownMenuItem>
|
|
192
|
+
</UiDropdownMenuContent>
|
|
193
|
+
</UiDropdownMenu>
|
|
194
|
+
<UiInputGroupText class="ml-auto">52% used</UiInputGroupText>
|
|
195
|
+
<UiSeparator orientation="vertical" class="!h-4" />
|
|
196
|
+
<UiInputGroupButton variant="default" size="icon-xs" aria-label="Send" class="rounded-full" disabled>
|
|
197
|
+
<UiIcon name="arrow-up" :size="14" />
|
|
198
|
+
</UiInputGroupButton>
|
|
199
|
+
</UiInputGroupAddon>
|
|
200
|
+
</UiInputGroup>
|
|
201
|
+
|
|
202
|
+
<UiInputGroup>
|
|
203
|
+
<UiInputGroupInput placeholder="@username" aria-label="Username" />
|
|
204
|
+
<UiInputGroupAddon align="inline-end">
|
|
205
|
+
<UiIcon name="circle-check" :size="16" aria-label="Username verified" />
|
|
206
|
+
</UiInputGroupAddon>
|
|
207
|
+
</UiInputGroup>
|
|
208
|
+
</div>
|
|
209
|
+
`,
|
|
210
|
+
}),
|
|
211
|
+
parameters: {
|
|
212
|
+
docs: {
|
|
213
|
+
source: {
|
|
214
|
+
code: defaultTemplateSource,
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
play: async ({ canvasElement, step }) => {
|
|
219
|
+
// Scenario (UiInputGroup): assistive tech sees a grouped field whose control is an
|
|
220
|
+
// enabled textbox. These checks don't mutate state, so the snapshot stays stable.
|
|
221
|
+
const canvas = within(canvasElement);
|
|
222
|
+
|
|
223
|
+
await step(
|
|
224
|
+
'screen-reader: the group exposes a group role and its control an accessible name (WCAG 4.1.2)',
|
|
225
|
+
async () => {
|
|
226
|
+
const search = canvas.getByRole('textbox', { name: 'Search' });
|
|
227
|
+
await expect(search).toBeEnabled();
|
|
228
|
+
await expect(search.closest('[data-slot=input-group]')).not.toBeNull();
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
await step(
|
|
233
|
+
'screen-reader: icon-only addon buttons carry accessible names',
|
|
234
|
+
async () => {
|
|
235
|
+
await expect(
|
|
236
|
+
canvas.getByRole('button', { name: 'More information' }),
|
|
237
|
+
).toBeInTheDocument();
|
|
238
|
+
await expect(
|
|
239
|
+
canvas.getByRole('button', { name: 'Send' }),
|
|
240
|
+
).toBeInTheDocument();
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const iconTemplateSource = `<script setup lang="ts">
|
|
247
|
+
import { UiInputGroup, UiInputGroupAddon, UiInputGroupInput, UiIcon } from '@aleph-alpha/ui-library'
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<template>
|
|
251
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
252
|
+
<UiInputGroup>
|
|
253
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
254
|
+
<UiInputGroupAddon>
|
|
255
|
+
<UiIcon name="search" :size="16" />
|
|
256
|
+
</UiInputGroupAddon>
|
|
257
|
+
</UiInputGroup>
|
|
258
|
+
|
|
259
|
+
<UiInputGroup>
|
|
260
|
+
<UiInputGroupInput type="email" placeholder="Enter your email" aria-label="Email" />
|
|
261
|
+
<UiInputGroupAddon>
|
|
262
|
+
<UiIcon name="mail" :size="16" />
|
|
263
|
+
</UiInputGroupAddon>
|
|
264
|
+
</UiInputGroup>
|
|
265
|
+
|
|
266
|
+
<UiInputGroup>
|
|
267
|
+
<UiInputGroupInput placeholder="Card number" aria-label="Card number" />
|
|
268
|
+
<UiInputGroupAddon>
|
|
269
|
+
<UiIcon name="credit-card" :size="16" />
|
|
270
|
+
</UiInputGroupAddon>
|
|
271
|
+
<UiInputGroupAddon align="inline-end">
|
|
272
|
+
<UiIcon name="check" :size="16" aria-label="Card number valid" />
|
|
273
|
+
</UiInputGroupAddon>
|
|
274
|
+
</UiInputGroup>
|
|
275
|
+
|
|
276
|
+
<UiInputGroup>
|
|
277
|
+
<UiInputGroupInput placeholder="Card number" aria-label="Card number" />
|
|
278
|
+
<UiInputGroupAddon align="inline-end">
|
|
279
|
+
<UiIcon name="star" :size="16" />
|
|
280
|
+
<UiIcon name="info" :size="16" />
|
|
281
|
+
</UiInputGroupAddon>
|
|
282
|
+
</UiInputGroup>
|
|
283
|
+
</div>
|
|
284
|
+
</template>`;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Icon addons mark what the value means — a search scope, an email field, a
|
|
288
|
+
* validated card number. Decorative icons stay hidden from assistive tech;
|
|
289
|
+
* status icons carry an `aria-label`.
|
|
290
|
+
*/
|
|
291
|
+
export const Icon: Story = {
|
|
292
|
+
render: () => ({
|
|
293
|
+
components: { UiInputGroup, UiInputGroupAddon, UiInputGroupInput, UiIcon },
|
|
294
|
+
template: `
|
|
295
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
296
|
+
<UiInputGroup>
|
|
297
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
298
|
+
<UiInputGroupAddon>
|
|
299
|
+
<UiIcon name="search" :size="16" />
|
|
300
|
+
</UiInputGroupAddon>
|
|
301
|
+
</UiInputGroup>
|
|
302
|
+
|
|
303
|
+
<UiInputGroup>
|
|
304
|
+
<UiInputGroupInput type="email" placeholder="Enter your email" aria-label="Email" />
|
|
305
|
+
<UiInputGroupAddon>
|
|
306
|
+
<UiIcon name="mail" :size="16" />
|
|
307
|
+
</UiInputGroupAddon>
|
|
308
|
+
</UiInputGroup>
|
|
309
|
+
|
|
310
|
+
<UiInputGroup>
|
|
311
|
+
<UiInputGroupInput placeholder="Card number" aria-label="Card number" />
|
|
312
|
+
<UiInputGroupAddon>
|
|
313
|
+
<UiIcon name="credit-card" :size="16" />
|
|
314
|
+
</UiInputGroupAddon>
|
|
315
|
+
<UiInputGroupAddon align="inline-end">
|
|
316
|
+
<UiIcon name="check" :size="16" aria-label="Card number valid" />
|
|
317
|
+
</UiInputGroupAddon>
|
|
318
|
+
</UiInputGroup>
|
|
319
|
+
|
|
320
|
+
<UiInputGroup>
|
|
321
|
+
<UiInputGroupInput placeholder="Card number" aria-label="Card number" />
|
|
322
|
+
<UiInputGroupAddon align="inline-end">
|
|
323
|
+
<UiIcon name="star" :size="16" />
|
|
324
|
+
<UiIcon name="info" :size="16" />
|
|
325
|
+
</UiInputGroupAddon>
|
|
326
|
+
</UiInputGroup>
|
|
327
|
+
</div>
|
|
328
|
+
`,
|
|
329
|
+
}),
|
|
330
|
+
parameters: {
|
|
331
|
+
docs: {
|
|
332
|
+
source: {
|
|
333
|
+
code: iconTemplateSource,
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const textTemplateSource = `<script setup lang="ts">
|
|
340
|
+
import {
|
|
341
|
+
UiInputGroup,
|
|
342
|
+
UiInputGroupAddon,
|
|
343
|
+
UiInputGroupInput,
|
|
344
|
+
UiInputGroupText,
|
|
345
|
+
UiInputGroupTextarea,
|
|
346
|
+
} from '@aleph-alpha/ui-library'
|
|
347
|
+
</script>
|
|
348
|
+
|
|
349
|
+
<template>
|
|
350
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
351
|
+
<UiInputGroup>
|
|
352
|
+
<UiInputGroupAddon>
|
|
353
|
+
<UiInputGroupText>$</UiInputGroupText>
|
|
354
|
+
</UiInputGroupAddon>
|
|
355
|
+
<UiInputGroupInput placeholder="0.00" aria-label="Amount" />
|
|
356
|
+
<UiInputGroupAddon align="inline-end">
|
|
357
|
+
<UiInputGroupText>USD</UiInputGroupText>
|
|
358
|
+
</UiInputGroupAddon>
|
|
359
|
+
</UiInputGroup>
|
|
360
|
+
|
|
361
|
+
<UiInputGroup>
|
|
362
|
+
<UiInputGroupAddon>
|
|
363
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
364
|
+
</UiInputGroupAddon>
|
|
365
|
+
<UiInputGroupInput placeholder="example" aria-label="Website name" class="!pl-0.5" />
|
|
366
|
+
<UiInputGroupAddon align="inline-end">
|
|
367
|
+
<UiInputGroupText>.com</UiInputGroupText>
|
|
368
|
+
</UiInputGroupAddon>
|
|
369
|
+
</UiInputGroup>
|
|
370
|
+
|
|
371
|
+
<UiInputGroup>
|
|
372
|
+
<UiInputGroupInput placeholder="Enter your username" aria-label="Username" />
|
|
373
|
+
<UiInputGroupAddon align="inline-end">
|
|
374
|
+
<UiInputGroupText>@company.com</UiInputGroupText>
|
|
375
|
+
</UiInputGroupAddon>
|
|
376
|
+
</UiInputGroup>
|
|
377
|
+
|
|
378
|
+
<UiInputGroup type="textarea">
|
|
379
|
+
<UiInputGroupTextarea placeholder="Enter your message" aria-label="Message" />
|
|
380
|
+
<UiInputGroupAddon align="block-end">
|
|
381
|
+
<UiInputGroupText>120 characters left</UiInputGroupText>
|
|
382
|
+
</UiInputGroupAddon>
|
|
383
|
+
</UiInputGroup>
|
|
384
|
+
</div>
|
|
385
|
+
</template>`;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Text addons carry prefixes and suffixes that are part of the value —
|
|
389
|
+
* currency symbols, protocol and domain affixes, or a remaining-characters
|
|
390
|
+
* counter under a textarea.
|
|
391
|
+
*/
|
|
392
|
+
export const Text: Story = {
|
|
393
|
+
render: () => ({
|
|
394
|
+
components: {
|
|
395
|
+
UiInputGroup,
|
|
396
|
+
UiInputGroupAddon,
|
|
397
|
+
UiInputGroupInput,
|
|
398
|
+
UiInputGroupText,
|
|
399
|
+
UiInputGroupTextarea,
|
|
400
|
+
},
|
|
401
|
+
template: `
|
|
402
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
403
|
+
<UiInputGroup>
|
|
404
|
+
<UiInputGroupAddon>
|
|
405
|
+
<UiInputGroupText>$</UiInputGroupText>
|
|
406
|
+
</UiInputGroupAddon>
|
|
407
|
+
<UiInputGroupInput placeholder="0.00" aria-label="Amount" />
|
|
408
|
+
<UiInputGroupAddon align="inline-end">
|
|
409
|
+
<UiInputGroupText>USD</UiInputGroupText>
|
|
410
|
+
</UiInputGroupAddon>
|
|
411
|
+
</UiInputGroup>
|
|
412
|
+
|
|
413
|
+
<UiInputGroup>
|
|
414
|
+
<UiInputGroupAddon>
|
|
415
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
416
|
+
</UiInputGroupAddon>
|
|
417
|
+
<UiInputGroupInput placeholder="example" aria-label="Website name" class="!pl-0.5" />
|
|
418
|
+
<UiInputGroupAddon align="inline-end">
|
|
419
|
+
<UiInputGroupText>.com</UiInputGroupText>
|
|
420
|
+
</UiInputGroupAddon>
|
|
421
|
+
</UiInputGroup>
|
|
422
|
+
|
|
423
|
+
<UiInputGroup>
|
|
424
|
+
<UiInputGroupInput placeholder="Enter your username" aria-label="Username" />
|
|
425
|
+
<UiInputGroupAddon align="inline-end">
|
|
426
|
+
<UiInputGroupText>@company.com</UiInputGroupText>
|
|
427
|
+
</UiInputGroupAddon>
|
|
428
|
+
</UiInputGroup>
|
|
429
|
+
|
|
430
|
+
<UiInputGroup type="textarea">
|
|
431
|
+
<UiInputGroupTextarea placeholder="Enter your message" aria-label="Message" />
|
|
432
|
+
<UiInputGroupAddon align="block-end">
|
|
433
|
+
<UiInputGroupText>120 characters left</UiInputGroupText>
|
|
434
|
+
</UiInputGroupAddon>
|
|
435
|
+
</UiInputGroup>
|
|
436
|
+
</div>
|
|
437
|
+
`,
|
|
438
|
+
}),
|
|
439
|
+
parameters: {
|
|
440
|
+
docs: {
|
|
441
|
+
source: {
|
|
442
|
+
code: textTemplateSource,
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
const buttonTemplateSource = `<script setup lang="ts">
|
|
449
|
+
import { ref } from 'vue'
|
|
450
|
+
import {
|
|
451
|
+
UiInputGroup,
|
|
452
|
+
UiInputGroupAddon,
|
|
453
|
+
UiInputGroupButton,
|
|
454
|
+
UiInputGroupInput,
|
|
455
|
+
UiInputGroupText,
|
|
456
|
+
UiIcon,
|
|
457
|
+
} from '@aleph-alpha/ui-library'
|
|
458
|
+
|
|
459
|
+
const copied = ref(false)
|
|
460
|
+
const favorite = ref(false)
|
|
461
|
+
|
|
462
|
+
function copyLink() {
|
|
463
|
+
navigator.clipboard.writeText('https://x.com/aleph-alpha')
|
|
464
|
+
copied.value = true
|
|
465
|
+
}
|
|
466
|
+
</script>
|
|
467
|
+
|
|
468
|
+
<template>
|
|
469
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
470
|
+
<UiInputGroup>
|
|
471
|
+
<UiInputGroupInput model-value="https://x.com/aleph-alpha" readonly aria-label="Profile link" />
|
|
472
|
+
<UiInputGroupAddon align="inline-end">
|
|
473
|
+
<UiInputGroupButton size="icon-xs" aria-label="Copy link" @click="copyLink">
|
|
474
|
+
<UiIcon :name="copied ? 'check' : 'copy'" :size="14" />
|
|
475
|
+
</UiInputGroupButton>
|
|
476
|
+
</UiInputGroupAddon>
|
|
477
|
+
</UiInputGroup>
|
|
478
|
+
|
|
479
|
+
<UiInputGroup>
|
|
480
|
+
<UiInputGroupAddon>
|
|
481
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
482
|
+
</UiInputGroupAddon>
|
|
483
|
+
<UiInputGroupInput aria-label="Website address" />
|
|
484
|
+
<UiInputGroupAddon align="inline-end">
|
|
485
|
+
<UiInputGroupButton size="icon-xs" :aria-label="favorite ? 'Remove from favorites' : 'Add to favorites'" :aria-pressed="favorite" @click="favorite = !favorite">
|
|
486
|
+
<UiIcon name="star" :size="14" :class="favorite ? 'fill-current' : ''" />
|
|
487
|
+
</UiInputGroupButton>
|
|
488
|
+
</UiInputGroupAddon>
|
|
489
|
+
</UiInputGroup>
|
|
490
|
+
|
|
491
|
+
<UiInputGroup>
|
|
492
|
+
<UiInputGroupInput placeholder="Type to search..." aria-label="Search" />
|
|
493
|
+
<UiInputGroupAddon align="inline-end">
|
|
494
|
+
<UiInputGroupButton variant="secondary">Search</UiInputGroupButton>
|
|
495
|
+
</UiInputGroupAddon>
|
|
496
|
+
</UiInputGroup>
|
|
497
|
+
</div>
|
|
498
|
+
</template>`;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Buttons inside the boundary act on the value: copy it, favorite it, or
|
|
502
|
+
* submit it. Icon-only buttons must carry an `ariaLabel`/`aria-label`.
|
|
503
|
+
*/
|
|
504
|
+
export const Button: Story = {
|
|
505
|
+
render: () => ({
|
|
506
|
+
components: {
|
|
507
|
+
UiInputGroup,
|
|
508
|
+
UiInputGroupAddon,
|
|
509
|
+
UiInputGroupButton,
|
|
510
|
+
UiInputGroupInput,
|
|
511
|
+
UiInputGroupText,
|
|
512
|
+
UiIcon,
|
|
513
|
+
},
|
|
514
|
+
setup() {
|
|
515
|
+
const copied = ref(false);
|
|
516
|
+
const favorite = ref(false);
|
|
517
|
+
|
|
518
|
+
function copyLink() {
|
|
519
|
+
navigator.clipboard.writeText('https://x.com/aleph-alpha');
|
|
520
|
+
copied.value = true;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return { copied, favorite, copyLink };
|
|
524
|
+
},
|
|
525
|
+
template: `
|
|
526
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
527
|
+
<UiInputGroup>
|
|
528
|
+
<UiInputGroupInput model-value="https://x.com/aleph-alpha" readonly aria-label="Profile link" />
|
|
529
|
+
<UiInputGroupAddon align="inline-end">
|
|
530
|
+
<UiInputGroupButton size="icon-xs" aria-label="Copy link" @click="copyLink">
|
|
531
|
+
<UiIcon :name="copied ? 'check' : 'copy'" :size="14" />
|
|
532
|
+
</UiInputGroupButton>
|
|
533
|
+
</UiInputGroupAddon>
|
|
534
|
+
</UiInputGroup>
|
|
535
|
+
|
|
536
|
+
<UiInputGroup>
|
|
537
|
+
<UiInputGroupAddon>
|
|
538
|
+
<UiInputGroupText>https://</UiInputGroupText>
|
|
539
|
+
</UiInputGroupAddon>
|
|
540
|
+
<UiInputGroupInput aria-label="Website address" />
|
|
541
|
+
<UiInputGroupAddon align="inline-end">
|
|
542
|
+
<UiInputGroupButton size="icon-xs" :aria-label="favorite ? 'Remove from favorites' : 'Add to favorites'" :aria-pressed="favorite" @click="favorite = !favorite">
|
|
543
|
+
<UiIcon name="star" :size="14" :class="favorite ? 'fill-current' : ''" />
|
|
544
|
+
</UiInputGroupButton>
|
|
545
|
+
</UiInputGroupAddon>
|
|
546
|
+
</UiInputGroup>
|
|
547
|
+
|
|
548
|
+
<UiInputGroup>
|
|
549
|
+
<UiInputGroupInput placeholder="Type to search..." aria-label="Search" />
|
|
550
|
+
<UiInputGroupAddon align="inline-end">
|
|
551
|
+
<UiInputGroupButton variant="secondary">Search</UiInputGroupButton>
|
|
552
|
+
</UiInputGroupAddon>
|
|
553
|
+
</UiInputGroup>
|
|
554
|
+
</div>
|
|
555
|
+
`,
|
|
556
|
+
}),
|
|
557
|
+
parameters: {
|
|
558
|
+
docs: {
|
|
559
|
+
source: {
|
|
560
|
+
code: buttonTemplateSource,
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
const buttonSizesTemplateSource = `<script setup lang="ts">
|
|
567
|
+
import {
|
|
568
|
+
UiIcon,
|
|
569
|
+
UiInputGroup,
|
|
570
|
+
UiInputGroupAddon,
|
|
571
|
+
UiInputGroupButton,
|
|
572
|
+
UiInputGroupInput,
|
|
573
|
+
} from '@aleph-alpha/ui-library'
|
|
574
|
+
</script>
|
|
575
|
+
|
|
576
|
+
<template>
|
|
577
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
578
|
+
<UiInputGroup>
|
|
579
|
+
<UiInputGroupInput placeholder="xs — text button" aria-label="xs example" />
|
|
580
|
+
<UiInputGroupAddon align="inline-end">
|
|
581
|
+
<UiInputGroupButton size="xs">Copy</UiInputGroupButton>
|
|
582
|
+
</UiInputGroupAddon>
|
|
583
|
+
</UiInputGroup>
|
|
584
|
+
|
|
585
|
+
<UiInputGroup>
|
|
586
|
+
<UiInputGroupInput placeholder="sm — text button" aria-label="sm example" />
|
|
587
|
+
<UiInputGroupAddon align="inline-end">
|
|
588
|
+
<UiInputGroupButton size="sm">Search</UiInputGroupButton>
|
|
589
|
+
</UiInputGroupAddon>
|
|
590
|
+
</UiInputGroup>
|
|
591
|
+
|
|
592
|
+
<UiInputGroup>
|
|
593
|
+
<UiInputGroupInput placeholder="icon-xs — icon-only button" aria-label="icon-xs example" />
|
|
594
|
+
<UiInputGroupAddon align="inline-end">
|
|
595
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear value">
|
|
596
|
+
<UiIcon name="circle-x" :size="16" />
|
|
597
|
+
</UiInputGroupButton>
|
|
598
|
+
</UiInputGroupAddon>
|
|
599
|
+
</UiInputGroup>
|
|
600
|
+
|
|
601
|
+
<UiInputGroup>
|
|
602
|
+
<UiInputGroupInput placeholder="icon-sm — icon-only button" aria-label="icon-sm example" />
|
|
603
|
+
<UiInputGroupAddon align="inline-end">
|
|
604
|
+
<UiInputGroupButton size="icon-sm" aria-label="Copy value">
|
|
605
|
+
<UiIcon name="copy" :size="16" />
|
|
606
|
+
</UiInputGroupButton>
|
|
607
|
+
</UiInputGroupAddon>
|
|
608
|
+
</UiInputGroup>
|
|
609
|
+
</div>
|
|
610
|
+
</template>`;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Every supported button size: `xs` and `sm` render text buttons named by
|
|
614
|
+
* their visible label; `icon-xs` and `icon-sm` render icon-only buttons and
|
|
615
|
+
* require `ariaLabel` (enforced by the props type).
|
|
616
|
+
*/
|
|
617
|
+
export const ButtonSizes: Story = {
|
|
618
|
+
render: () => ({
|
|
619
|
+
components: {
|
|
620
|
+
UiIcon,
|
|
621
|
+
UiInputGroup,
|
|
622
|
+
UiInputGroupAddon,
|
|
623
|
+
UiInputGroupButton,
|
|
624
|
+
UiInputGroupInput,
|
|
625
|
+
},
|
|
626
|
+
template: `
|
|
627
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
628
|
+
<UiInputGroup>
|
|
629
|
+
<UiInputGroupInput placeholder="xs — text button" aria-label="xs example" />
|
|
630
|
+
<UiInputGroupAddon align="inline-end">
|
|
631
|
+
<UiInputGroupButton size="xs">Copy</UiInputGroupButton>
|
|
632
|
+
</UiInputGroupAddon>
|
|
633
|
+
</UiInputGroup>
|
|
634
|
+
|
|
635
|
+
<UiInputGroup>
|
|
636
|
+
<UiInputGroupInput placeholder="sm — text button" aria-label="sm example" />
|
|
637
|
+
<UiInputGroupAddon align="inline-end">
|
|
638
|
+
<UiInputGroupButton size="sm">Search</UiInputGroupButton>
|
|
639
|
+
</UiInputGroupAddon>
|
|
640
|
+
</UiInputGroup>
|
|
641
|
+
|
|
642
|
+
<UiInputGroup>
|
|
643
|
+
<UiInputGroupInput placeholder="icon-xs — icon-only button" aria-label="icon-xs example" />
|
|
644
|
+
<UiInputGroupAddon align="inline-end">
|
|
645
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear value">
|
|
646
|
+
<UiIcon name="circle-x" :size="16" />
|
|
647
|
+
</UiInputGroupButton>
|
|
648
|
+
</UiInputGroupAddon>
|
|
649
|
+
</UiInputGroup>
|
|
650
|
+
|
|
651
|
+
<UiInputGroup>
|
|
652
|
+
<UiInputGroupInput placeholder="icon-sm — icon-only button" aria-label="icon-sm example" />
|
|
653
|
+
<UiInputGroupAddon align="inline-end">
|
|
654
|
+
<UiInputGroupButton size="icon-sm" aria-label="Copy value">
|
|
655
|
+
<UiIcon name="copy" :size="16" />
|
|
656
|
+
</UiInputGroupButton>
|
|
657
|
+
</UiInputGroupAddon>
|
|
658
|
+
</UiInputGroup>
|
|
659
|
+
</div>
|
|
660
|
+
`,
|
|
661
|
+
}),
|
|
662
|
+
parameters: {
|
|
663
|
+
docs: {
|
|
664
|
+
source: {
|
|
665
|
+
code: buttonSizesTemplateSource,
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
play: async ({ canvasElement, step }) => {
|
|
670
|
+
// Scenario (UiInputGroupButton): every size renders an operable button
|
|
671
|
+
// with an accessible name — text sizes from their visible label,
|
|
672
|
+
// icon-only sizes from the required ariaLabel.
|
|
673
|
+
const canvas = within(canvasElement);
|
|
674
|
+
|
|
675
|
+
await step(
|
|
676
|
+
'screen-reader: all sizes expose an accessible name (WCAG 4.1.2)',
|
|
677
|
+
async () => {
|
|
678
|
+
for (const name of ['Copy', 'Search', 'Clear value', 'Copy value']) {
|
|
679
|
+
await expect(canvas.getByRole('button', { name })).toBeVisible();
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
);
|
|
683
|
+
},
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const buttonVariantsTemplateSource = `<script setup lang="ts">
|
|
687
|
+
import {
|
|
688
|
+
UiInputGroup,
|
|
689
|
+
UiInputGroupAddon,
|
|
690
|
+
UiInputGroupButton,
|
|
691
|
+
UiInputGroupInput,
|
|
692
|
+
} from '@aleph-alpha/ui-library'
|
|
693
|
+
</script>
|
|
694
|
+
|
|
695
|
+
<template>
|
|
696
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
697
|
+
<UiInputGroup v-for="variant in ['default', 'secondary', 'outline', 'ghost', 'destructive', 'link']" :key="variant">
|
|
698
|
+
<UiInputGroupInput :placeholder="variant" :aria-label="variant + ' example'" />
|
|
699
|
+
<UiInputGroupAddon align="inline-end">
|
|
700
|
+
<UiInputGroupButton :variant="variant" size="sm">Action</UiInputGroupButton>
|
|
701
|
+
</UiInputGroupAddon>
|
|
702
|
+
</UiInputGroup>
|
|
703
|
+
</div>
|
|
704
|
+
</template>`;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Every supported visual variant (`default`, `secondary`, `outline`,
|
|
708
|
+
* `ghost`, `destructive`, `link`) rendered inside a group addon.
|
|
709
|
+
*/
|
|
710
|
+
export const ButtonVariants: Story = {
|
|
711
|
+
render: () => ({
|
|
712
|
+
components: {
|
|
713
|
+
UiInputGroup,
|
|
714
|
+
UiInputGroupAddon,
|
|
715
|
+
UiInputGroupButton,
|
|
716
|
+
UiInputGroupInput,
|
|
717
|
+
},
|
|
718
|
+
setup() {
|
|
719
|
+
const variants = [
|
|
720
|
+
'default',
|
|
721
|
+
'secondary',
|
|
722
|
+
'outline',
|
|
723
|
+
'ghost',
|
|
724
|
+
'destructive',
|
|
725
|
+
'link',
|
|
726
|
+
];
|
|
727
|
+
return { variants };
|
|
728
|
+
},
|
|
729
|
+
template: `
|
|
730
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
731
|
+
<UiInputGroup v-for="variant in variants" :key="variant">
|
|
732
|
+
<UiInputGroupInput :placeholder="variant" :aria-label="variant + ' example'" />
|
|
733
|
+
<UiInputGroupAddon align="inline-end">
|
|
734
|
+
<UiInputGroupButton :variant="variant" size="sm">Action</UiInputGroupButton>
|
|
735
|
+
</UiInputGroupAddon>
|
|
736
|
+
</UiInputGroup>
|
|
737
|
+
</div>
|
|
738
|
+
`,
|
|
739
|
+
}),
|
|
740
|
+
parameters: {
|
|
741
|
+
docs: {
|
|
742
|
+
source: {
|
|
743
|
+
code: buttonVariantsTemplateSource,
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
play: async ({ canvasElement, step }) => {
|
|
748
|
+
// Scenario (UiInputGroupButton): each variant stays an operable, named
|
|
749
|
+
// button inside the addon.
|
|
750
|
+
const canvas = within(canvasElement);
|
|
751
|
+
|
|
752
|
+
await step(
|
|
753
|
+
'screen-reader: every variant renders an operable named button (WCAG 4.1.2)',
|
|
754
|
+
async () => {
|
|
755
|
+
const buttons = canvas.getAllByRole('button', { name: 'Action' });
|
|
756
|
+
await expect(buttons).toHaveLength(6);
|
|
757
|
+
},
|
|
758
|
+
);
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
const tooltipTemplateSource = `<script setup lang="ts">
|
|
763
|
+
import {
|
|
764
|
+
UiInputGroup,
|
|
765
|
+
UiInputGroupAddon,
|
|
766
|
+
UiInputGroupButton,
|
|
767
|
+
UiInputGroupInput,
|
|
768
|
+
UiIcon,
|
|
769
|
+
UiTooltip,
|
|
770
|
+
} from '@aleph-alpha/ui-library'
|
|
771
|
+
</script>
|
|
772
|
+
|
|
773
|
+
<template>
|
|
774
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
775
|
+
<UiInputGroup>
|
|
776
|
+
<UiInputGroupInput type="password" placeholder="Enter password" aria-label="Password" />
|
|
777
|
+
<UiInputGroupAddon align="inline-end">
|
|
778
|
+
<UiTooltip content="Password must be at least 8 characters">
|
|
779
|
+
<UiInputGroupButton size="icon-xs" aria-label="Password requirements">
|
|
780
|
+
<UiIcon name="info" :size="14" />
|
|
781
|
+
</UiInputGroupButton>
|
|
782
|
+
</UiTooltip>
|
|
783
|
+
</UiInputGroupAddon>
|
|
784
|
+
</UiInputGroup>
|
|
785
|
+
|
|
786
|
+
<UiInputGroup>
|
|
787
|
+
<UiInputGroupInput placeholder="Your email address" aria-label="Email address" />
|
|
788
|
+
<UiInputGroupAddon align="inline-end">
|
|
789
|
+
<UiTooltip content="We'll use this to send you notifications">
|
|
790
|
+
<UiInputGroupButton size="icon-xs" aria-label="Why we need your email">
|
|
791
|
+
<UiIcon name="circle-help" :size="14" />
|
|
792
|
+
</UiInputGroupButton>
|
|
793
|
+
</UiTooltip>
|
|
794
|
+
</UiInputGroupAddon>
|
|
795
|
+
</UiInputGroup>
|
|
796
|
+
|
|
797
|
+
<UiInputGroup>
|
|
798
|
+
<UiInputGroupInput placeholder="Enter API key" aria-label="API key" />
|
|
799
|
+
<UiInputGroupAddon>
|
|
800
|
+
<UiTooltip content="Click for help with API keys" side="left">
|
|
801
|
+
<UiInputGroupButton size="icon-xs" aria-label="Help with API keys">
|
|
802
|
+
<UiIcon name="circle-help" :size="14" />
|
|
803
|
+
</UiInputGroupButton>
|
|
804
|
+
</UiTooltip>
|
|
805
|
+
</UiInputGroupAddon>
|
|
806
|
+
</UiInputGroup>
|
|
807
|
+
</div>
|
|
808
|
+
</template>`;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Tooltips on addon buttons explain the expected format or why a value is
|
|
812
|
+
* needed — as help, not as the only explanation of the field.
|
|
813
|
+
*/
|
|
814
|
+
export const Tooltip: Story = {
|
|
815
|
+
render: () => ({
|
|
816
|
+
components: {
|
|
817
|
+
UiInputGroup,
|
|
818
|
+
UiInputGroupAddon,
|
|
819
|
+
UiInputGroupButton,
|
|
820
|
+
UiInputGroupInput,
|
|
821
|
+
UiIcon,
|
|
822
|
+
UiTooltip,
|
|
823
|
+
},
|
|
824
|
+
template: `
|
|
825
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
826
|
+
<UiInputGroup>
|
|
827
|
+
<UiInputGroupInput type="password" placeholder="Enter password" aria-label="Password" />
|
|
828
|
+
<UiInputGroupAddon align="inline-end">
|
|
829
|
+
<UiTooltip content="Password must be at least 8 characters">
|
|
830
|
+
<UiInputGroupButton size="icon-xs" aria-label="Password requirements">
|
|
831
|
+
<UiIcon name="info" :size="14" />
|
|
832
|
+
</UiInputGroupButton>
|
|
833
|
+
</UiTooltip>
|
|
834
|
+
</UiInputGroupAddon>
|
|
835
|
+
</UiInputGroup>
|
|
836
|
+
|
|
837
|
+
<UiInputGroup>
|
|
838
|
+
<UiInputGroupInput placeholder="Your email address" aria-label="Email address" />
|
|
839
|
+
<UiInputGroupAddon align="inline-end">
|
|
840
|
+
<UiTooltip content="We'll use this to send you notifications">
|
|
841
|
+
<UiInputGroupButton size="icon-xs" aria-label="Why we need your email">
|
|
842
|
+
<UiIcon name="circle-help" :size="14" />
|
|
843
|
+
</UiInputGroupButton>
|
|
844
|
+
</UiTooltip>
|
|
845
|
+
</UiInputGroupAddon>
|
|
846
|
+
</UiInputGroup>
|
|
847
|
+
|
|
848
|
+
<UiInputGroup>
|
|
849
|
+
<UiInputGroupInput placeholder="Enter API key" aria-label="API key" />
|
|
850
|
+
<UiInputGroupAddon>
|
|
851
|
+
<UiTooltip content="Click for help with API keys" side="left">
|
|
852
|
+
<UiInputGroupButton size="icon-xs" aria-label="Help with API keys">
|
|
853
|
+
<UiIcon name="circle-help" :size="14" />
|
|
854
|
+
</UiInputGroupButton>
|
|
855
|
+
</UiTooltip>
|
|
856
|
+
</UiInputGroupAddon>
|
|
857
|
+
</UiInputGroup>
|
|
858
|
+
</div>
|
|
859
|
+
`,
|
|
860
|
+
}),
|
|
861
|
+
parameters: {
|
|
862
|
+
docs: {
|
|
863
|
+
source: {
|
|
864
|
+
code: tooltipTemplateSource,
|
|
865
|
+
},
|
|
866
|
+
},
|
|
867
|
+
},
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
const allTypesTemplateSource = `<script setup lang="ts">
|
|
871
|
+
import {
|
|
872
|
+
UiInputGroup,
|
|
873
|
+
UiInputGroupAddon,
|
|
874
|
+
UiInputGroupButton,
|
|
875
|
+
UiInputGroupInput,
|
|
876
|
+
UiInputGroupText,
|
|
877
|
+
UiInputGroupTextarea,
|
|
878
|
+
UiIcon,
|
|
879
|
+
} from '@aleph-alpha/ui-library'
|
|
880
|
+
</script>
|
|
881
|
+
|
|
882
|
+
<template>
|
|
883
|
+
<div class="grid w-full max-w-md gap-8">
|
|
884
|
+
<div class="flex flex-col gap-3">
|
|
885
|
+
<h3 class="body-14-medium">type="input"</h3>
|
|
886
|
+
<UiInputGroup>
|
|
887
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
888
|
+
<UiInputGroupAddon>
|
|
889
|
+
<UiIcon name="search" :size="16" />
|
|
890
|
+
</UiInputGroupAddon>
|
|
891
|
+
<UiInputGroupAddon align="inline-end">
|
|
892
|
+
<UiInputGroupButton variant="secondary">Search</UiInputGroupButton>
|
|
893
|
+
</UiInputGroupAddon>
|
|
894
|
+
</UiInputGroup>
|
|
895
|
+
</div>
|
|
896
|
+
|
|
897
|
+
<div class="flex flex-col gap-3">
|
|
898
|
+
<h3 class="body-14-medium">type="textarea"</h3>
|
|
899
|
+
<UiInputGroup type="textarea">
|
|
900
|
+
<UiInputGroupTextarea placeholder="console.log('Hello, world!');" aria-label="Code" class="min-h-[200px] font-mono" />
|
|
901
|
+
<UiInputGroupAddon align="block-start" class="border-b border-border-surface-default">
|
|
902
|
+
<UiInputGroupText class="font-mono">
|
|
903
|
+
<UiIcon name="file-code" :size="16" />
|
|
904
|
+
script.js
|
|
905
|
+
</UiInputGroupText>
|
|
906
|
+
<UiInputGroupButton size="icon-xs" aria-label="Rerun" class="ml-auto">
|
|
907
|
+
<UiIcon name="refresh-cw" :size="14" />
|
|
908
|
+
</UiInputGroupButton>
|
|
909
|
+
<UiInputGroupButton size="icon-xs" aria-label="Copy code">
|
|
910
|
+
<UiIcon name="copy" :size="14" />
|
|
911
|
+
</UiInputGroupButton>
|
|
912
|
+
</UiInputGroupAddon>
|
|
913
|
+
<UiInputGroupAddon align="block-end" class="border-t border-border-surface-default">
|
|
914
|
+
<UiInputGroupText>Line 1, Column 1</UiInputGroupText>
|
|
915
|
+
<UiInputGroupButton variant="default" size="sm" class="ml-auto">
|
|
916
|
+
Run
|
|
917
|
+
<UiIcon name="corner-down-left" :size="14" />
|
|
918
|
+
</UiInputGroupButton>
|
|
919
|
+
</UiInputGroupAddon>
|
|
920
|
+
</UiInputGroup>
|
|
921
|
+
</div>
|
|
922
|
+
</div>
|
|
923
|
+
</template>`;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Both group types side by side. `type="input"` (the default) renders a
|
|
927
|
+
* fixed-height row with inline addons; `type="textarea"` grows with its
|
|
928
|
+
* content and takes `block-start`/`block-end` addons — rows of their own for
|
|
929
|
+
* toolbars, status lines, and submit actions.
|
|
930
|
+
*/
|
|
931
|
+
export const AllTypes: Story = {
|
|
932
|
+
render: () => ({
|
|
933
|
+
components: {
|
|
934
|
+
UiInputGroup,
|
|
935
|
+
UiInputGroupAddon,
|
|
936
|
+
UiInputGroupButton,
|
|
937
|
+
UiInputGroupInput,
|
|
938
|
+
UiInputGroupText,
|
|
939
|
+
UiInputGroupTextarea,
|
|
940
|
+
UiIcon,
|
|
941
|
+
},
|
|
942
|
+
template: `
|
|
943
|
+
<div class="grid w-full max-w-md gap-8">
|
|
944
|
+
<div class="flex flex-col gap-3">
|
|
945
|
+
<h3 class="body-14-medium text-content-on-surface-primary">type="input"</h3>
|
|
946
|
+
<UiInputGroup>
|
|
947
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
948
|
+
<UiInputGroupAddon>
|
|
949
|
+
<UiIcon name="search" :size="16" />
|
|
950
|
+
</UiInputGroupAddon>
|
|
951
|
+
<UiInputGroupAddon align="inline-end">
|
|
952
|
+
<UiInputGroupButton variant="secondary">Search</UiInputGroupButton>
|
|
953
|
+
</UiInputGroupAddon>
|
|
954
|
+
</UiInputGroup>
|
|
955
|
+
</div>
|
|
956
|
+
|
|
957
|
+
<div class="flex flex-col gap-3">
|
|
958
|
+
<h3 class="body-14-medium text-content-on-surface-primary">type="textarea"</h3>
|
|
959
|
+
<UiInputGroup type="textarea">
|
|
960
|
+
<UiInputGroupTextarea placeholder="console.log('Hello, world!');" aria-label="Code" class="min-h-[200px] font-mono" />
|
|
961
|
+
<UiInputGroupAddon align="block-start" class="border-b border-border-surface-default">
|
|
962
|
+
<UiInputGroupText class="font-mono">
|
|
963
|
+
<UiIcon name="file-code" :size="16" />
|
|
964
|
+
script.js
|
|
965
|
+
</UiInputGroupText>
|
|
966
|
+
<UiInputGroupButton size="icon-xs" aria-label="Rerun" class="ml-auto">
|
|
967
|
+
<UiIcon name="refresh-cw" :size="14" />
|
|
968
|
+
</UiInputGroupButton>
|
|
969
|
+
<UiInputGroupButton size="icon-xs" aria-label="Copy code">
|
|
970
|
+
<UiIcon name="copy" :size="14" />
|
|
971
|
+
</UiInputGroupButton>
|
|
972
|
+
</UiInputGroupAddon>
|
|
973
|
+
<UiInputGroupAddon align="block-end" class="border-t border-border-surface-default">
|
|
974
|
+
<UiInputGroupText>Line 1, Column 1</UiInputGroupText>
|
|
975
|
+
<UiInputGroupButton variant="default" size="sm" class="ml-auto">
|
|
976
|
+
Run
|
|
977
|
+
<UiIcon name="corner-down-left" :size="14" />
|
|
978
|
+
</UiInputGroupButton>
|
|
979
|
+
</UiInputGroupAddon>
|
|
980
|
+
</UiInputGroup>
|
|
981
|
+
</div>
|
|
982
|
+
</div>
|
|
983
|
+
`,
|
|
984
|
+
}),
|
|
985
|
+
parameters: {
|
|
986
|
+
docs: {
|
|
987
|
+
source: {
|
|
988
|
+
code: allTypesTemplateSource,
|
|
989
|
+
},
|
|
990
|
+
},
|
|
991
|
+
},
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
const spinnerTemplateSource = `<script setup lang="ts">
|
|
995
|
+
import {
|
|
996
|
+
UiInputGroup,
|
|
997
|
+
UiInputGroupAddon,
|
|
998
|
+
UiInputGroupInput,
|
|
999
|
+
UiInputGroupText,
|
|
1000
|
+
UiSpinner,
|
|
1001
|
+
} from '@aleph-alpha/ui-library'
|
|
1002
|
+
</script>
|
|
1003
|
+
|
|
1004
|
+
<template>
|
|
1005
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1006
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1007
|
+
<UiInputGroupInput placeholder="Searching..." disabled aria-label="Search" />
|
|
1008
|
+
<UiInputGroupAddon align="inline-end">
|
|
1009
|
+
<UiSpinner />
|
|
1010
|
+
</UiInputGroupAddon>
|
|
1011
|
+
</UiInputGroup>
|
|
1012
|
+
|
|
1013
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1014
|
+
<UiInputGroupInput placeholder="Processing..." disabled aria-label="Query" />
|
|
1015
|
+
<UiInputGroupAddon>
|
|
1016
|
+
<UiSpinner />
|
|
1017
|
+
</UiInputGroupAddon>
|
|
1018
|
+
</UiInputGroup>
|
|
1019
|
+
|
|
1020
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1021
|
+
<UiInputGroupInput placeholder="Saving changes..." disabled aria-label="Document name" />
|
|
1022
|
+
<UiInputGroupAddon align="inline-end">
|
|
1023
|
+
<UiInputGroupText>Saving...</UiInputGroupText>
|
|
1024
|
+
<UiSpinner />
|
|
1025
|
+
</UiInputGroupAddon>
|
|
1026
|
+
</UiInputGroup>
|
|
1027
|
+
|
|
1028
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1029
|
+
<UiInputGroupInput placeholder="Refreshing data..." disabled aria-label="Data filter" />
|
|
1030
|
+
<UiInputGroupAddon>
|
|
1031
|
+
<UiSpinner />
|
|
1032
|
+
</UiInputGroupAddon>
|
|
1033
|
+
<UiInputGroupAddon align="inline-end">
|
|
1034
|
+
<UiInputGroupText>Please wait...</UiInputGroupText>
|
|
1035
|
+
</UiInputGroupAddon>
|
|
1036
|
+
</UiInputGroup>
|
|
1037
|
+
</div>
|
|
1038
|
+
</template>`;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Spinners report an in-flight operation on the value. Disable the control,
|
|
1042
|
+
* mark the group with `data-disabled="true"` so addons dim with the field,
|
|
1043
|
+
* and set `aria-busy="true"` so screen readers can tell an in-progress
|
|
1044
|
+
* operation apart from an ordinarily disabled field.
|
|
1045
|
+
*/
|
|
1046
|
+
export const Spinner: Story = {
|
|
1047
|
+
render: () => ({
|
|
1048
|
+
components: {
|
|
1049
|
+
UiInputGroup,
|
|
1050
|
+
UiInputGroupAddon,
|
|
1051
|
+
UiInputGroupInput,
|
|
1052
|
+
UiInputGroupText,
|
|
1053
|
+
UiSpinner,
|
|
1054
|
+
},
|
|
1055
|
+
template: `
|
|
1056
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1057
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1058
|
+
<UiInputGroupInput placeholder="Searching..." disabled aria-label="Search" />
|
|
1059
|
+
<UiInputGroupAddon align="inline-end">
|
|
1060
|
+
<UiSpinner />
|
|
1061
|
+
</UiInputGroupAddon>
|
|
1062
|
+
</UiInputGroup>
|
|
1063
|
+
|
|
1064
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1065
|
+
<UiInputGroupInput placeholder="Processing..." disabled aria-label="Query" />
|
|
1066
|
+
<UiInputGroupAddon>
|
|
1067
|
+
<UiSpinner />
|
|
1068
|
+
</UiInputGroupAddon>
|
|
1069
|
+
</UiInputGroup>
|
|
1070
|
+
|
|
1071
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1072
|
+
<UiInputGroupInput placeholder="Saving changes..." disabled aria-label="Document name" />
|
|
1073
|
+
<UiInputGroupAddon align="inline-end">
|
|
1074
|
+
<UiInputGroupText>Saving...</UiInputGroupText>
|
|
1075
|
+
<UiSpinner />
|
|
1076
|
+
</UiInputGroupAddon>
|
|
1077
|
+
</UiInputGroup>
|
|
1078
|
+
|
|
1079
|
+
<UiInputGroup data-disabled="true" aria-busy="true">
|
|
1080
|
+
<UiInputGroupInput placeholder="Refreshing data..." disabled aria-label="Data filter" />
|
|
1081
|
+
<UiInputGroupAddon>
|
|
1082
|
+
<UiSpinner />
|
|
1083
|
+
</UiInputGroupAddon>
|
|
1084
|
+
<UiInputGroupAddon align="inline-end">
|
|
1085
|
+
<UiInputGroupText>Please wait...</UiInputGroupText>
|
|
1086
|
+
</UiInputGroupAddon>
|
|
1087
|
+
</UiInputGroup>
|
|
1088
|
+
</div>
|
|
1089
|
+
`,
|
|
1090
|
+
}),
|
|
1091
|
+
parameters: {
|
|
1092
|
+
a11y: {
|
|
1093
|
+
// The "Saving..." / "Please wait..." addon text sits inside groups that
|
|
1094
|
+
// are `data-disabled` + `aria-busy`: text in inactive UI components is
|
|
1095
|
+
// exempt from contrast minimums (WCAG 1.4.3), but axe cannot recognize
|
|
1096
|
+
// non-native disabling, so its color-contrast rule is off for this story.
|
|
1097
|
+
config: { rules: [{ id: 'color-contrast', enabled: false }] },
|
|
1098
|
+
},
|
|
1099
|
+
docs: {
|
|
1100
|
+
source: {
|
|
1101
|
+
code: spinnerTemplateSource,
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
},
|
|
1105
|
+
play: async ({ canvasElement, step }) => {
|
|
1106
|
+
// Scenario (UiInputGroup): while loading, the control reports its disabled state and
|
|
1107
|
+
// the spinner is announced. These checks don't mutate state.
|
|
1108
|
+
const canvas = within(canvasElement);
|
|
1109
|
+
|
|
1110
|
+
await step(
|
|
1111
|
+
'screen-reader: loading state exposes a disabled control and a labelled spinner (WCAG 4.1.2)',
|
|
1112
|
+
async () => {
|
|
1113
|
+
const search = canvas.getByRole('textbox', { name: 'Search' });
|
|
1114
|
+
await expect(search).toBeDisabled();
|
|
1115
|
+
await expect(canvas.getAllByLabelText('Loading')).not.toHaveLength(0);
|
|
1116
|
+
},
|
|
1117
|
+
);
|
|
1118
|
+
|
|
1119
|
+
await step(
|
|
1120
|
+
'screen-reader: loading groups expose aria-busy so AT can distinguish in-progress from disabled (WCAG 4.1.2)',
|
|
1121
|
+
async () => {
|
|
1122
|
+
// Role queries exclude aria-busy elements unless asked for them —
|
|
1123
|
+
// finding all four groups only via `busy: true` proves the state.
|
|
1124
|
+
const busyGroups = canvas.getAllByRole('group', { busy: true });
|
|
1125
|
+
await expect(busyGroups).toHaveLength(4);
|
|
1126
|
+
for (const group of busyGroups) {
|
|
1127
|
+
await expect(group).toHaveAttribute('aria-busy', 'true');
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
);
|
|
1131
|
+
},
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
const errorTemplateSource = `<script setup lang="ts">
|
|
1135
|
+
import { ref } from 'vue'
|
|
1136
|
+
import {
|
|
1137
|
+
UiIcon,
|
|
1138
|
+
UiInputGroup,
|
|
1139
|
+
UiInputGroupAddon,
|
|
1140
|
+
UiInputGroupButton,
|
|
1141
|
+
UiInputGroupInput,
|
|
1142
|
+
UiInputGroupTextarea,
|
|
1143
|
+
} from '@aleph-alpha/ui-library'
|
|
1144
|
+
|
|
1145
|
+
const email = ref('not-an-email')
|
|
1146
|
+
const message = ref('')
|
|
1147
|
+
</script>
|
|
1148
|
+
|
|
1149
|
+
<template>
|
|
1150
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1151
|
+
<!-- aria-invalid marks the control invalid; the group draws the error
|
|
1152
|
+
ring. The explicit "true" value, a bare attribute, and a boolean
|
|
1153
|
+
binding are all accepted. -->
|
|
1154
|
+
<UiInputGroup>
|
|
1155
|
+
<UiInputGroupInput v-model="email" aria-label="Email" aria-invalid="true" />
|
|
1156
|
+
<UiInputGroupAddon align="inline-end">
|
|
1157
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear email" @click="email = ''">
|
|
1158
|
+
<UiIcon name="circle-x" :size="16" />
|
|
1159
|
+
</UiInputGroupButton>
|
|
1160
|
+
</UiInputGroupAddon>
|
|
1161
|
+
</UiInputGroup>
|
|
1162
|
+
|
|
1163
|
+
<UiInputGroup type="textarea">
|
|
1164
|
+
<UiInputGroupTextarea v-model="message" placeholder="Message" aria-label="Message" aria-invalid />
|
|
1165
|
+
<UiInputGroupAddon align="block-end">
|
|
1166
|
+
<UiInputGroupButton size="sm" variant="secondary">Send</UiInputGroupButton>
|
|
1167
|
+
</UiInputGroupAddon>
|
|
1168
|
+
</UiInputGroup>
|
|
1169
|
+
</div>
|
|
1170
|
+
</template>`;
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Error state: `aria-invalid` on the control switches the group boundary to
|
|
1174
|
+
* the `border/input/error` token. The built-in controls normalize the bare
|
|
1175
|
+
* attribute and boolean bindings to the canonical `"true"`, so all common
|
|
1176
|
+
* Vue spellings both style the group and announce correctly.
|
|
1177
|
+
*/
|
|
1178
|
+
export const ErrorState: Story = {
|
|
1179
|
+
name: 'Error',
|
|
1180
|
+
render: () => ({
|
|
1181
|
+
components: {
|
|
1182
|
+
UiIcon,
|
|
1183
|
+
UiInputGroup,
|
|
1184
|
+
UiInputGroupAddon,
|
|
1185
|
+
UiInputGroupButton,
|
|
1186
|
+
UiInputGroupInput,
|
|
1187
|
+
UiInputGroupTextarea,
|
|
1188
|
+
},
|
|
1189
|
+
setup() {
|
|
1190
|
+
const email = ref('not-an-email');
|
|
1191
|
+
const message = ref('');
|
|
1192
|
+
return { email, message };
|
|
1193
|
+
},
|
|
1194
|
+
template: `
|
|
1195
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1196
|
+
<UiInputGroup>
|
|
1197
|
+
<UiInputGroupInput v-model="email" aria-label="Email" aria-invalid="true" />
|
|
1198
|
+
<UiInputGroupAddon align="inline-end">
|
|
1199
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear email" @click="email = ''">
|
|
1200
|
+
<UiIcon name="circle-x" :size="16" />
|
|
1201
|
+
</UiInputGroupButton>
|
|
1202
|
+
</UiInputGroupAddon>
|
|
1203
|
+
</UiInputGroup>
|
|
1204
|
+
|
|
1205
|
+
<UiInputGroup type="textarea">
|
|
1206
|
+
<UiInputGroupTextarea v-model="message" placeholder="Message" aria-label="Message" aria-invalid />
|
|
1207
|
+
<UiInputGroupAddon align="block-end">
|
|
1208
|
+
<UiInputGroupButton size="sm" variant="secondary">Send</UiInputGroupButton>
|
|
1209
|
+
</UiInputGroupAddon>
|
|
1210
|
+
</UiInputGroup>
|
|
1211
|
+
</div>
|
|
1212
|
+
`,
|
|
1213
|
+
}),
|
|
1214
|
+
parameters: {
|
|
1215
|
+
docs: {
|
|
1216
|
+
source: {
|
|
1217
|
+
code: errorTemplateSource,
|
|
1218
|
+
},
|
|
1219
|
+
},
|
|
1220
|
+
},
|
|
1221
|
+
play: async ({ canvasElement, step }) => {
|
|
1222
|
+
// Scenario (UiInputGroup): the invalid state is announced (aria-invalid)
|
|
1223
|
+
// and drawn (error outline on the group), for both the canonical "true"
|
|
1224
|
+
// value and the bare-attribute spelling.
|
|
1225
|
+
const canvas = within(canvasElement);
|
|
1226
|
+
|
|
1227
|
+
await step(
|
|
1228
|
+
'screen-reader: both spellings of aria-invalid expose the canonical "true" (WCAG 4.1.2)',
|
|
1229
|
+
async () => {
|
|
1230
|
+
const email = canvas.getByRole('textbox', { name: 'Email' });
|
|
1231
|
+
await expect(email).toHaveAttribute('aria-invalid', 'true');
|
|
1232
|
+
// The bare attribute (renders "") is normalized by the control.
|
|
1233
|
+
const message = canvas.getByRole('textbox', { name: 'Message' });
|
|
1234
|
+
await expect(message).toHaveAttribute('aria-invalid', 'true');
|
|
1235
|
+
},
|
|
1236
|
+
);
|
|
1237
|
+
|
|
1238
|
+
await step(
|
|
1239
|
+
'interaction: invalid groups draw the border/input/error outline',
|
|
1240
|
+
async () => {
|
|
1241
|
+
// Probe resolves the same token the group outline should use. It is
|
|
1242
|
+
// authored in the `color-mix(...)` form the generated `outline-*`
|
|
1243
|
+
// utilities use (see uno's presetWind4 color output), so both computed
|
|
1244
|
+
// values serialize to the same `color(srgb ...)` string.
|
|
1245
|
+
const probe = document.createElement('div');
|
|
1246
|
+
probe.style.outlineColor =
|
|
1247
|
+
'color-mix(in srgb, oklch(var(--border-input-error)) 100%, transparent)';
|
|
1248
|
+
canvasElement.appendChild(probe);
|
|
1249
|
+
const errorColor = getComputedStyle(probe).outlineColor;
|
|
1250
|
+
probe.remove();
|
|
1251
|
+
|
|
1252
|
+
for (const name of ['Email', 'Message']) {
|
|
1253
|
+
const control = canvas.getByRole('textbox', { name });
|
|
1254
|
+
const group = control.closest<HTMLElement>('[data-slot=input-group]');
|
|
1255
|
+
await expect(group).not.toBeNull();
|
|
1256
|
+
if (!group) return; // unreachable — the assertion above already threw
|
|
1257
|
+
await expect(getComputedStyle(group).outlineColor).toBe(errorColor);
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
);
|
|
1261
|
+
},
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
const labelTemplateSource = `<script setup lang="ts">
|
|
1265
|
+
import {
|
|
1266
|
+
UiInputGroup,
|
|
1267
|
+
UiInputGroupAddon,
|
|
1268
|
+
UiInputGroupButton,
|
|
1269
|
+
UiInputGroupInput,
|
|
1270
|
+
UiIcon,
|
|
1271
|
+
UiLabel,
|
|
1272
|
+
UiTooltip,
|
|
1273
|
+
} from '@aleph-alpha/ui-library'
|
|
1274
|
+
</script>
|
|
1275
|
+
|
|
1276
|
+
<template>
|
|
1277
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1278
|
+
<UiInputGroup>
|
|
1279
|
+
<UiInputGroupInput id="handle" placeholder="username" />
|
|
1280
|
+
<UiInputGroupAddon>
|
|
1281
|
+
<UiLabel for="handle">@</UiLabel>
|
|
1282
|
+
</UiInputGroupAddon>
|
|
1283
|
+
</UiInputGroup>
|
|
1284
|
+
|
|
1285
|
+
<UiInputGroup>
|
|
1286
|
+
<UiInputGroupInput id="email" placeholder="name@company.com" />
|
|
1287
|
+
<UiInputGroupAddon align="block-start">
|
|
1288
|
+
<UiLabel for="email" class="text-content-on-surface-primary">Email</UiLabel>
|
|
1289
|
+
<UiTooltip content="We'll use this to send you notifications">
|
|
1290
|
+
<UiInputGroupButton size="icon-xs" aria-label="Why we need your email" class="ml-auto rounded-full">
|
|
1291
|
+
<UiIcon name="info" :size="14" />
|
|
1292
|
+
</UiInputGroupButton>
|
|
1293
|
+
</UiTooltip>
|
|
1294
|
+
</UiInputGroupAddon>
|
|
1295
|
+
</UiInputGroup>
|
|
1296
|
+
</div>
|
|
1297
|
+
</template>`;
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* Labels rendered inside an addon stay programmatically associated with the
|
|
1301
|
+
* control via `for`/`id`, so the group needs no external label element.
|
|
1302
|
+
*/
|
|
1303
|
+
export const Label: Story = {
|
|
1304
|
+
render: () => ({
|
|
1305
|
+
components: {
|
|
1306
|
+
UiInputGroup,
|
|
1307
|
+
UiInputGroupAddon,
|
|
1308
|
+
UiInputGroupButton,
|
|
1309
|
+
UiInputGroupInput,
|
|
1310
|
+
UiIcon,
|
|
1311
|
+
UiLabel,
|
|
1312
|
+
UiTooltip,
|
|
1313
|
+
},
|
|
1314
|
+
template: `
|
|
1315
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1316
|
+
<UiInputGroup>
|
|
1317
|
+
<UiInputGroupInput id="handle" placeholder="username" />
|
|
1318
|
+
<UiInputGroupAddon>
|
|
1319
|
+
<UiLabel for="handle">@</UiLabel>
|
|
1320
|
+
</UiInputGroupAddon>
|
|
1321
|
+
</UiInputGroup>
|
|
1322
|
+
|
|
1323
|
+
<UiInputGroup>
|
|
1324
|
+
<UiInputGroupInput id="email" placeholder="name@company.com" />
|
|
1325
|
+
<UiInputGroupAddon align="block-start">
|
|
1326
|
+
<UiLabel for="email" class="text-content-on-surface-primary">Email</UiLabel>
|
|
1327
|
+
<UiTooltip content="We'll use this to send you notifications">
|
|
1328
|
+
<UiInputGroupButton size="icon-xs" aria-label="Why we need your email" class="ml-auto rounded-full">
|
|
1329
|
+
<UiIcon name="info" :size="14" />
|
|
1330
|
+
</UiInputGroupButton>
|
|
1331
|
+
</UiTooltip>
|
|
1332
|
+
</UiInputGroupAddon>
|
|
1333
|
+
</UiInputGroup>
|
|
1334
|
+
</div>
|
|
1335
|
+
`,
|
|
1336
|
+
}),
|
|
1337
|
+
parameters: {
|
|
1338
|
+
docs: {
|
|
1339
|
+
source: {
|
|
1340
|
+
code: labelTemplateSource,
|
|
1341
|
+
},
|
|
1342
|
+
},
|
|
1343
|
+
},
|
|
1344
|
+
play: async ({ canvasElement, step }) => {
|
|
1345
|
+
// Scenario (UiInputGroup): the label inside the addon names the control for
|
|
1346
|
+
// assistive tech through the for/id association.
|
|
1347
|
+
const canvas = within(canvasElement);
|
|
1348
|
+
|
|
1349
|
+
await step(
|
|
1350
|
+
'screen-reader: the addon label names its control (WCAG 1.3.1 / 4.1.2)',
|
|
1351
|
+
async () => {
|
|
1352
|
+
const email = canvas.getByRole('textbox', { name: 'Email' });
|
|
1353
|
+
await expect(email).toHaveAccessibleName('Email');
|
|
1354
|
+
},
|
|
1355
|
+
);
|
|
1356
|
+
},
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
const dropdownTemplateSource = `<script setup lang="ts">
|
|
1360
|
+
import {
|
|
1361
|
+
UiInputGroup,
|
|
1362
|
+
UiInputGroupAddon,
|
|
1363
|
+
UiInputGroupButton,
|
|
1364
|
+
UiInputGroupInput,
|
|
1365
|
+
UiDropdownMenu,
|
|
1366
|
+
UiDropdownMenuContent,
|
|
1367
|
+
UiDropdownMenuItem,
|
|
1368
|
+
UiDropdownMenuTrigger,
|
|
1369
|
+
UiIcon,
|
|
1370
|
+
} from '@aleph-alpha/ui-library'
|
|
1371
|
+
</script>
|
|
1372
|
+
|
|
1373
|
+
<template>
|
|
1374
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1375
|
+
<UiInputGroup>
|
|
1376
|
+
<UiInputGroupInput placeholder="Enter file name" aria-label="File name" />
|
|
1377
|
+
<UiInputGroupAddon align="inline-end">
|
|
1378
|
+
<UiDropdownMenu>
|
|
1379
|
+
<UiDropdownMenuTrigger as-child>
|
|
1380
|
+
<UiInputGroupButton size="icon-xs" aria-label="More options">
|
|
1381
|
+
<UiIcon name="ellipsis" :size="14" />
|
|
1382
|
+
</UiInputGroupButton>
|
|
1383
|
+
</UiDropdownMenuTrigger>
|
|
1384
|
+
<UiDropdownMenuContent align="end">
|
|
1385
|
+
<UiDropdownMenuItem>Settings</UiDropdownMenuItem>
|
|
1386
|
+
<UiDropdownMenuItem>Copy path</UiDropdownMenuItem>
|
|
1387
|
+
<UiDropdownMenuItem>Open location</UiDropdownMenuItem>
|
|
1388
|
+
</UiDropdownMenuContent>
|
|
1389
|
+
</UiDropdownMenu>
|
|
1390
|
+
</UiInputGroupAddon>
|
|
1391
|
+
</UiInputGroup>
|
|
1392
|
+
|
|
1393
|
+
<UiInputGroup>
|
|
1394
|
+
<UiInputGroupInput placeholder="Enter search query" aria-label="Search query" />
|
|
1395
|
+
<UiInputGroupAddon align="inline-end">
|
|
1396
|
+
<UiDropdownMenu>
|
|
1397
|
+
<UiDropdownMenuTrigger as-child>
|
|
1398
|
+
<UiInputGroupButton>
|
|
1399
|
+
Search In...
|
|
1400
|
+
<UiIcon name="chevron-down" :size="12" />
|
|
1401
|
+
</UiInputGroupButton>
|
|
1402
|
+
</UiDropdownMenuTrigger>
|
|
1403
|
+
<UiDropdownMenuContent align="end">
|
|
1404
|
+
<UiDropdownMenuItem>Documentation</UiDropdownMenuItem>
|
|
1405
|
+
<UiDropdownMenuItem>Blog Posts</UiDropdownMenuItem>
|
|
1406
|
+
<UiDropdownMenuItem>Changelog</UiDropdownMenuItem>
|
|
1407
|
+
</UiDropdownMenuContent>
|
|
1408
|
+
</UiDropdownMenu>
|
|
1409
|
+
</UiInputGroupAddon>
|
|
1410
|
+
</UiInputGroup>
|
|
1411
|
+
</div>
|
|
1412
|
+
</template>`;
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* Dropdown menus in the inline-end addon scope or act on the value — file
|
|
1416
|
+
* actions, or choosing where a search runs.
|
|
1417
|
+
*/
|
|
1418
|
+
export const Dropdown: Story = {
|
|
1419
|
+
render: () => ({
|
|
1420
|
+
components: {
|
|
1421
|
+
UiInputGroup,
|
|
1422
|
+
UiInputGroupAddon,
|
|
1423
|
+
UiInputGroupButton,
|
|
1424
|
+
UiInputGroupInput,
|
|
1425
|
+
UiDropdownMenu,
|
|
1426
|
+
UiDropdownMenuContent,
|
|
1427
|
+
UiDropdownMenuItem,
|
|
1428
|
+
UiDropdownMenuTrigger,
|
|
1429
|
+
UiIcon,
|
|
1430
|
+
},
|
|
1431
|
+
template: `
|
|
1432
|
+
<div class="grid w-full max-w-sm gap-4">
|
|
1433
|
+
<UiInputGroup>
|
|
1434
|
+
<UiInputGroupInput placeholder="Enter file name" aria-label="File name" />
|
|
1435
|
+
<UiInputGroupAddon align="inline-end">
|
|
1436
|
+
<UiDropdownMenu>
|
|
1437
|
+
<UiDropdownMenuTrigger as-child>
|
|
1438
|
+
<UiInputGroupButton size="icon-xs" aria-label="More options">
|
|
1439
|
+
<UiIcon name="ellipsis" :size="14" />
|
|
1440
|
+
</UiInputGroupButton>
|
|
1441
|
+
</UiDropdownMenuTrigger>
|
|
1442
|
+
<UiDropdownMenuContent align="end">
|
|
1443
|
+
<UiDropdownMenuItem>Settings</UiDropdownMenuItem>
|
|
1444
|
+
<UiDropdownMenuItem>Copy path</UiDropdownMenuItem>
|
|
1445
|
+
<UiDropdownMenuItem>Open location</UiDropdownMenuItem>
|
|
1446
|
+
</UiDropdownMenuContent>
|
|
1447
|
+
</UiDropdownMenu>
|
|
1448
|
+
</UiInputGroupAddon>
|
|
1449
|
+
</UiInputGroup>
|
|
1450
|
+
|
|
1451
|
+
<UiInputGroup>
|
|
1452
|
+
<UiInputGroupInput placeholder="Enter search query" aria-label="Search query" />
|
|
1453
|
+
<UiInputGroupAddon align="inline-end">
|
|
1454
|
+
<UiDropdownMenu>
|
|
1455
|
+
<UiDropdownMenuTrigger as-child>
|
|
1456
|
+
<UiInputGroupButton>
|
|
1457
|
+
Search In...
|
|
1458
|
+
<UiIcon name="chevron-down" :size="12" />
|
|
1459
|
+
</UiInputGroupButton>
|
|
1460
|
+
</UiDropdownMenuTrigger>
|
|
1461
|
+
<UiDropdownMenuContent align="end">
|
|
1462
|
+
<UiDropdownMenuItem>Documentation</UiDropdownMenuItem>
|
|
1463
|
+
<UiDropdownMenuItem>Blog Posts</UiDropdownMenuItem>
|
|
1464
|
+
<UiDropdownMenuItem>Changelog</UiDropdownMenuItem>
|
|
1465
|
+
</UiDropdownMenuContent>
|
|
1466
|
+
</UiDropdownMenu>
|
|
1467
|
+
</UiInputGroupAddon>
|
|
1468
|
+
</UiInputGroup>
|
|
1469
|
+
</div>
|
|
1470
|
+
`,
|
|
1471
|
+
}),
|
|
1472
|
+
parameters: {
|
|
1473
|
+
docs: {
|
|
1474
|
+
source: {
|
|
1475
|
+
code: dropdownTemplateSource,
|
|
1476
|
+
},
|
|
1477
|
+
},
|
|
1478
|
+
},
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
const buttonGroupTemplateSource = `<script setup lang="ts">
|
|
1482
|
+
import {
|
|
1483
|
+
UiButtonGroup,
|
|
1484
|
+
UiButtonGroupText,
|
|
1485
|
+
UiInputGroup,
|
|
1486
|
+
UiInputGroupAddon,
|
|
1487
|
+
UiInputGroupInput,
|
|
1488
|
+
UiIcon,
|
|
1489
|
+
} from '@aleph-alpha/ui-library'
|
|
1490
|
+
</script>
|
|
1491
|
+
|
|
1492
|
+
<template>
|
|
1493
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
1494
|
+
<UiButtonGroup>
|
|
1495
|
+
<UiButtonGroupText>https://</UiButtonGroupText>
|
|
1496
|
+
<UiInputGroup>
|
|
1497
|
+
<UiInputGroupInput id="company-url" placeholder="example" aria-label="Website name" />
|
|
1498
|
+
<UiInputGroupAddon align="inline-end">
|
|
1499
|
+
<UiIcon name="link-2" :size="16" />
|
|
1500
|
+
</UiInputGroupAddon>
|
|
1501
|
+
</UiInputGroup>
|
|
1502
|
+
<UiButtonGroupText>.com</UiButtonGroupText>
|
|
1503
|
+
</UiButtonGroup>
|
|
1504
|
+
</div>
|
|
1505
|
+
</template>`;
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* Wrap an input group with `UiButtonGroup` to attach flat prefixes and
|
|
1509
|
+
* suffixes outside the field boundary — here a labelled protocol prefix and
|
|
1510
|
+
* a domain suffix.
|
|
1511
|
+
*/
|
|
1512
|
+
export const ButtonGroup: Story = {
|
|
1513
|
+
render: () => ({
|
|
1514
|
+
components: {
|
|
1515
|
+
UiButtonGroup,
|
|
1516
|
+
UiButtonGroupText,
|
|
1517
|
+
UiInputGroup,
|
|
1518
|
+
UiInputGroupAddon,
|
|
1519
|
+
UiInputGroupInput,
|
|
1520
|
+
UiIcon,
|
|
1521
|
+
},
|
|
1522
|
+
template: `
|
|
1523
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
1524
|
+
<UiButtonGroup>
|
|
1525
|
+
<UiButtonGroupText>https://</UiButtonGroupText>
|
|
1526
|
+
<UiInputGroup>
|
|
1527
|
+
<UiInputGroupInput id="company-url" placeholder="example" aria-label="Website name" />
|
|
1528
|
+
<UiInputGroupAddon align="inline-end">
|
|
1529
|
+
<UiIcon name="link-2" :size="16" />
|
|
1530
|
+
</UiInputGroupAddon>
|
|
1531
|
+
</UiInputGroup>
|
|
1532
|
+
<UiButtonGroupText>.com</UiButtonGroupText>
|
|
1533
|
+
</UiButtonGroup>
|
|
1534
|
+
</div>
|
|
1535
|
+
`,
|
|
1536
|
+
}),
|
|
1537
|
+
parameters: {
|
|
1538
|
+
docs: {
|
|
1539
|
+
source: {
|
|
1540
|
+
code: buttonGroupTemplateSource,
|
|
1541
|
+
},
|
|
1542
|
+
},
|
|
1543
|
+
},
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
const customInputTemplateSource = `<script setup lang="ts">
|
|
1547
|
+
import {
|
|
1548
|
+
UiInputGroup,
|
|
1549
|
+
UiInputGroupAddon,
|
|
1550
|
+
UiInputGroupButton,
|
|
1551
|
+
UiIcon,
|
|
1552
|
+
} from '@aleph-alpha/ui-library'
|
|
1553
|
+
</script>
|
|
1554
|
+
|
|
1555
|
+
<template>
|
|
1556
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
1557
|
+
<UiInputGroup type="textarea">
|
|
1558
|
+
<!--
|
|
1559
|
+
Custom controls opt into the group's focus and error handling by
|
|
1560
|
+
setting data-slot="input-group-control". No style is applied to the
|
|
1561
|
+
control itself — bring your own classes.
|
|
1562
|
+
-->
|
|
1563
|
+
<textarea
|
|
1564
|
+
data-slot="input-group-control"
|
|
1565
|
+
class="flex field-sizing-content min-h-16 w-full resize-none rounded-md bg-transparent px-3 py-2.5 body-s-regular outline-none"
|
|
1566
|
+
placeholder="Autoresize textarea..."
|
|
1567
|
+
aria-label="Message"
|
|
1568
|
+
></textarea>
|
|
1569
|
+
<UiInputGroupAddon align="block-end">
|
|
1570
|
+
<UiInputGroupButton variant="default" size="icon-xs" aria-label="Send" class="ml-auto rounded-full">
|
|
1571
|
+
<UiIcon name="arrow-up" :size="14" />
|
|
1572
|
+
</UiInputGroupButton>
|
|
1573
|
+
</UiInputGroupAddon>
|
|
1574
|
+
</UiInputGroup>
|
|
1575
|
+
</div>
|
|
1576
|
+
</template>`;
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Any custom control can join the group: add
|
|
1580
|
+
* `data-slot="input-group-control"` and the container handles the focus ring
|
|
1581
|
+
* and error ring. The control itself stays unstyled — bring your own classes.
|
|
1582
|
+
*/
|
|
1583
|
+
export const CustomInput: Story = {
|
|
1584
|
+
render: () => ({
|
|
1585
|
+
components: { UiInputGroup, UiInputGroupAddon, UiInputGroupButton, UiIcon },
|
|
1586
|
+
template: `
|
|
1587
|
+
<div class="grid w-full max-w-sm gap-6">
|
|
1588
|
+
<UiInputGroup type="textarea">
|
|
1589
|
+
<textarea
|
|
1590
|
+
data-slot="input-group-control"
|
|
1591
|
+
class="flex field-sizing-content min-h-16 w-full resize-none rounded-md bg-transparent px-3 py-2.5 body-s-regular outline-none"
|
|
1592
|
+
placeholder="Autoresize textarea..."
|
|
1593
|
+
aria-label="Message"
|
|
1594
|
+
></textarea>
|
|
1595
|
+
<UiInputGroupAddon align="block-end">
|
|
1596
|
+
<UiInputGroupButton variant="default" size="icon-xs" aria-label="Send" class="ml-auto rounded-full">
|
|
1597
|
+
<UiIcon name="arrow-up" :size="14" />
|
|
1598
|
+
</UiInputGroupButton>
|
|
1599
|
+
</UiInputGroupAddon>
|
|
1600
|
+
</UiInputGroup>
|
|
1601
|
+
</div>
|
|
1602
|
+
`,
|
|
1603
|
+
}),
|
|
1604
|
+
parameters: {
|
|
1605
|
+
docs: {
|
|
1606
|
+
source: {
|
|
1607
|
+
code: customInputTemplateSource,
|
|
1608
|
+
},
|
|
1609
|
+
},
|
|
1610
|
+
},
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Accessibility guidance for labelling, focus, error states, and contrast.
|
|
1615
|
+
*/
|
|
1616
|
+
export const Accessibility: Story = {
|
|
1617
|
+
render: () => ({
|
|
1618
|
+
components: {
|
|
1619
|
+
UiInputGroup,
|
|
1620
|
+
UiInputGroupAddon,
|
|
1621
|
+
UiInputGroupButton,
|
|
1622
|
+
UiInputGroupInput,
|
|
1623
|
+
UiIcon,
|
|
1624
|
+
},
|
|
1625
|
+
template: `
|
|
1626
|
+
<section class="flex flex-col gap-6 p-4">
|
|
1627
|
+
<div>
|
|
1628
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
1629
|
+
Accessibility
|
|
1630
|
+
</h2>
|
|
1631
|
+
</div>
|
|
1632
|
+
|
|
1633
|
+
<div class="flex flex-col gap-6">
|
|
1634
|
+
<div class="flex flex-col gap-2">
|
|
1635
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1636
|
+
Requirements
|
|
1637
|
+
</h3>
|
|
1638
|
+
<ul class="body-16-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
|
|
1639
|
+
<li>The whole group shows focus as one boundary, so it is clear the field is active.</li>
|
|
1640
|
+
<li>Every control needs an accessible name — an associated <code>UiLabel</code> or an <code>aria-label</code>.</li>
|
|
1641
|
+
<li>Icon-only addon buttons must set <code>ariaLabel</code>; a tooltip alone is not an accessible name.</li>
|
|
1642
|
+
<li>Error states belong on the control (<code>aria-invalid</code>) with text beneath the field, not only on the addon.</li>
|
|
1643
|
+
<li>Text addons keep enough contrast against the field background and are not the only explanation of the expected format.</li>
|
|
1644
|
+
<li>Place addons after the control in the markup so the control keeps the first tab stop.</li>
|
|
1645
|
+
</ul>
|
|
1646
|
+
</div>
|
|
1647
|
+
|
|
1648
|
+
<div class="flex flex-col gap-2">
|
|
1649
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1650
|
+
Enable accessibility theme
|
|
1651
|
+
</h3>
|
|
1652
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
1653
|
+
When accessibility is required, enable our accessibility theme.
|
|
1654
|
+
This increases contrast and ensures there are no color contrast
|
|
1655
|
+
issues.
|
|
1656
|
+
</p>
|
|
1657
|
+
</div>
|
|
1658
|
+
</div>
|
|
1659
|
+
|
|
1660
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
1661
|
+
<div class="flex flex-col gap-3">
|
|
1662
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1663
|
+
Default
|
|
1664
|
+
</h3>
|
|
1665
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1666
|
+
<UiInputGroup class="max-w-xs">
|
|
1667
|
+
<UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
|
|
1668
|
+
<UiInputGroupAddon>
|
|
1669
|
+
<UiIcon name="search" :size="16" />
|
|
1670
|
+
</UiInputGroupAddon>
|
|
1671
|
+
<UiInputGroupAddon align="inline-end">
|
|
1672
|
+
<UiInputGroupButton size="icon-xs" aria-label="Search by voice">
|
|
1673
|
+
<UiIcon name="mic" :size="14" />
|
|
1674
|
+
</UiInputGroupButton>
|
|
1675
|
+
</UiInputGroupAddon>
|
|
1676
|
+
</UiInputGroup>
|
|
1677
|
+
</div>
|
|
1678
|
+
</div>
|
|
1679
|
+
|
|
1680
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
1681
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1682
|
+
Accessible
|
|
1683
|
+
</h3>
|
|
1684
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1685
|
+
<UiInputGroup class="max-w-xs">
|
|
1686
|
+
<UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
|
|
1687
|
+
<UiInputGroupAddon>
|
|
1688
|
+
<UiIcon name="search" :size="16" />
|
|
1689
|
+
</UiInputGroupAddon>
|
|
1690
|
+
<UiInputGroupAddon align="inline-end">
|
|
1691
|
+
<UiInputGroupButton size="icon-xs" aria-label="Search by voice">
|
|
1692
|
+
<UiIcon name="mic" :size="14" />
|
|
1693
|
+
</UiInputGroupButton>
|
|
1694
|
+
</UiInputGroupAddon>
|
|
1695
|
+
</UiInputGroup>
|
|
1696
|
+
</div>
|
|
1697
|
+
</div>
|
|
1698
|
+
</div>
|
|
1699
|
+
</section>
|
|
1700
|
+
`,
|
|
1701
|
+
}),
|
|
1702
|
+
tags: ['!autodocs'],
|
|
1703
|
+
parameters: {
|
|
1704
|
+
a11y: { test: 'off' },
|
|
1705
|
+
chromatic: {
|
|
1706
|
+
disableSnapshot: true,
|
|
1707
|
+
},
|
|
1708
|
+
docs: {
|
|
1709
|
+
canvas: {
|
|
1710
|
+
sourceState: 'none',
|
|
1711
|
+
},
|
|
1712
|
+
},
|
|
1713
|
+
},
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Clicking a non-interactive addon focuses the control, and typing updates
|
|
1718
|
+
* the value via `update:modelValue`. Hidden test-only story.
|
|
1719
|
+
*/
|
|
1720
|
+
export const AddonInteraction: Story = {
|
|
1721
|
+
name: 'test - Addon Interaction',
|
|
1722
|
+
tags: ['!dev', '!autodocs'],
|
|
1723
|
+
parameters: {
|
|
1724
|
+
chromatic: { disableSnapshot: true },
|
|
1725
|
+
docs: {
|
|
1726
|
+
description: {
|
|
1727
|
+
story:
|
|
1728
|
+
'Click the icon addon to focus the input, then type — each keystroke emits `update:modelValue`.',
|
|
1729
|
+
},
|
|
1730
|
+
},
|
|
1731
|
+
},
|
|
1732
|
+
render: () => ({
|
|
1733
|
+
components: {
|
|
1734
|
+
UiInputGroup,
|
|
1735
|
+
UiInputGroupAddon,
|
|
1736
|
+
UiInputGroupButton,
|
|
1737
|
+
UiInputGroupInput,
|
|
1738
|
+
UiIcon,
|
|
1739
|
+
},
|
|
1740
|
+
setup() {
|
|
1741
|
+
return { onUpdate, onClick };
|
|
1742
|
+
},
|
|
1743
|
+
template: `
|
|
1744
|
+
<UiInputGroup class="max-w-sm">
|
|
1745
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" @update:model-value="onUpdate" />
|
|
1746
|
+
<UiInputGroupAddon>
|
|
1747
|
+
<UiIcon name="search" :size="16" />
|
|
1748
|
+
</UiInputGroupAddon>
|
|
1749
|
+
<UiInputGroupAddon align="inline-end">
|
|
1750
|
+
<UiInputGroupButton variant="secondary" @click="onClick">Search</UiInputGroupButton>
|
|
1751
|
+
</UiInputGroupAddon>
|
|
1752
|
+
</UiInputGroup>
|
|
1753
|
+
`,
|
|
1754
|
+
}),
|
|
1755
|
+
play: async ({ canvasElement, step }) => {
|
|
1756
|
+
// Scenario (UiInputGroup): the addon behaves as part of the field — clicking it
|
|
1757
|
+
// focuses the control — while buttons inside addons keep their own behavior.
|
|
1758
|
+
onUpdate.mockClear();
|
|
1759
|
+
onClick.mockClear();
|
|
1760
|
+
const canvas = within(canvasElement);
|
|
1761
|
+
const input = canvas.getByRole('textbox', { name: 'Search' });
|
|
1762
|
+
const button = canvas.getByRole('button', { name: 'Search' });
|
|
1763
|
+
|
|
1764
|
+
await step(
|
|
1765
|
+
'interaction: clicking a non-interactive addon focuses the control',
|
|
1766
|
+
async () => {
|
|
1767
|
+
const addon = canvasElement.querySelector<HTMLElement>(
|
|
1768
|
+
'[data-slot=input-group-addon]',
|
|
1769
|
+
);
|
|
1770
|
+
await expect(addon).not.toBeNull();
|
|
1771
|
+
if (!addon) return; // unreachable — the assertion above already threw
|
|
1772
|
+
await userEvent.click(addon);
|
|
1773
|
+
await expect(input).toHaveFocus();
|
|
1774
|
+
},
|
|
1775
|
+
);
|
|
1776
|
+
|
|
1777
|
+
await step(
|
|
1778
|
+
'interaction: typing updates the value and emits update:modelValue',
|
|
1779
|
+
async () => {
|
|
1780
|
+
await userEvent.keyboard('release notes');
|
|
1781
|
+
await expect(input).toHaveValue('release notes');
|
|
1782
|
+
await expect(onUpdate).toHaveBeenLastCalledWith('release notes');
|
|
1783
|
+
},
|
|
1784
|
+
);
|
|
1785
|
+
|
|
1786
|
+
await step(
|
|
1787
|
+
'interaction: clicking a button inside an addon fires the button, not the focus helper',
|
|
1788
|
+
async () => {
|
|
1789
|
+
await userEvent.click(button);
|
|
1790
|
+
await expect(onClick).toHaveBeenCalledTimes(1);
|
|
1791
|
+
await expect(button).toHaveFocus();
|
|
1792
|
+
},
|
|
1793
|
+
);
|
|
1794
|
+
},
|
|
1795
|
+
};
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* The control keeps the first tab stop, addon buttons follow in DOM order,
|
|
1799
|
+
* and `Enter`/`Space` activates the focused button (WCAG 2.1.1, 2.4.3).
|
|
1800
|
+
* Hidden test-only story.
|
|
1801
|
+
*/
|
|
1802
|
+
export const KeyboardNavigation: Story = {
|
|
1803
|
+
name: 'test - Keyboard Navigation',
|
|
1804
|
+
tags: ['!dev', '!autodocs'],
|
|
1805
|
+
parameters: {
|
|
1806
|
+
chromatic: { disableSnapshot: true },
|
|
1807
|
+
docs: {
|
|
1808
|
+
description: {
|
|
1809
|
+
story:
|
|
1810
|
+
'Tab moves from the control to the addon buttons in DOM order; Space activates the focused button.',
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1813
|
+
},
|
|
1814
|
+
render: () => ({
|
|
1815
|
+
components: {
|
|
1816
|
+
UiInputGroup,
|
|
1817
|
+
UiInputGroupAddon,
|
|
1818
|
+
UiInputGroupButton,
|
|
1819
|
+
UiInputGroupInput,
|
|
1820
|
+
UiIcon,
|
|
1821
|
+
},
|
|
1822
|
+
setup() {
|
|
1823
|
+
return { onClick };
|
|
1824
|
+
},
|
|
1825
|
+
template: `
|
|
1826
|
+
<UiInputGroup class="max-w-sm">
|
|
1827
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" />
|
|
1828
|
+
<UiInputGroupAddon align="inline-end">
|
|
1829
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear" @click="onClick">
|
|
1830
|
+
<UiIcon name="x" :size="14" />
|
|
1831
|
+
</UiInputGroupButton>
|
|
1832
|
+
<UiInputGroupButton variant="secondary" @click="onClick">Search</UiInputGroupButton>
|
|
1833
|
+
</UiInputGroupAddon>
|
|
1834
|
+
</UiInputGroup>
|
|
1835
|
+
`,
|
|
1836
|
+
}),
|
|
1837
|
+
play: async ({ canvasElement, step }) => {
|
|
1838
|
+
// Scenario (UiInputGroup): a keyboard user tabs into the field first, then through
|
|
1839
|
+
// the addon actions, and activates the focused action with Space.
|
|
1840
|
+
onClick.mockClear();
|
|
1841
|
+
const canvas = within(canvasElement);
|
|
1842
|
+
const input = canvas.getByRole('textbox', { name: 'Search' });
|
|
1843
|
+
const clear = canvas.getByRole('button', { name: 'Clear' });
|
|
1844
|
+
const search = canvas.getByRole('button', { name: 'Search' });
|
|
1845
|
+
|
|
1846
|
+
await step(
|
|
1847
|
+
'keyboard: Tab reaches the control before the addon actions (WCAG 2.4.3)',
|
|
1848
|
+
async () => {
|
|
1849
|
+
await userEvent.tab();
|
|
1850
|
+
await expect(input).toHaveFocus();
|
|
1851
|
+
},
|
|
1852
|
+
);
|
|
1853
|
+
|
|
1854
|
+
await step(
|
|
1855
|
+
'keyboard: Tab moves through the addon buttons in DOM order',
|
|
1856
|
+
async () => {
|
|
1857
|
+
await userEvent.tab();
|
|
1858
|
+
await expect(clear).toHaveFocus();
|
|
1859
|
+
await userEvent.tab();
|
|
1860
|
+
await expect(search).toHaveFocus();
|
|
1861
|
+
},
|
|
1862
|
+
);
|
|
1863
|
+
|
|
1864
|
+
await step(
|
|
1865
|
+
'keyboard: Space activates the focused addon button (WCAG 2.1.1)',
|
|
1866
|
+
async () => {
|
|
1867
|
+
await userEvent.keyboard(' ');
|
|
1868
|
+
await expect(onClick).toHaveBeenCalledTimes(1);
|
|
1869
|
+
},
|
|
1870
|
+
);
|
|
1871
|
+
},
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* Screen-reader semantics: the container exposes a `group` role, the control
|
|
1876
|
+
* an accessible name, and every icon-only addon button its own label
|
|
1877
|
+
* (WCAG 4.1.2 Name, Role, Value). Hidden test-only story.
|
|
1878
|
+
*/
|
|
1879
|
+
export const ScreenReader: Story = {
|
|
1880
|
+
name: 'test - Screen Reader',
|
|
1881
|
+
tags: ['!dev', '!autodocs'],
|
|
1882
|
+
parameters: {
|
|
1883
|
+
chromatic: { disableSnapshot: true },
|
|
1884
|
+
docs: {
|
|
1885
|
+
description: {
|
|
1886
|
+
story:
|
|
1887
|
+
'Verifies the group role, the label association on the control, and the accessible names of icon-only addon buttons.',
|
|
1888
|
+
},
|
|
1889
|
+
},
|
|
1890
|
+
},
|
|
1891
|
+
render: () => ({
|
|
1892
|
+
components: {
|
|
1893
|
+
UiInputGroup,
|
|
1894
|
+
UiInputGroupAddon,
|
|
1895
|
+
UiInputGroupButton,
|
|
1896
|
+
UiInputGroupInput,
|
|
1897
|
+
UiIcon,
|
|
1898
|
+
UiLabel,
|
|
1899
|
+
},
|
|
1900
|
+
template: `
|
|
1901
|
+
<UiInputGroup class="max-w-sm" aria-label="Email field">
|
|
1902
|
+
<UiInputGroupInput id="sr-email" placeholder="name@company.com" />
|
|
1903
|
+
<UiInputGroupAddon align="block-start">
|
|
1904
|
+
<UiLabel for="sr-email">Email</UiLabel>
|
|
1905
|
+
</UiInputGroupAddon>
|
|
1906
|
+
<UiInputGroupAddon align="inline-end">
|
|
1907
|
+
<UiInputGroupButton size="icon-xs" aria-label="Clear email">
|
|
1908
|
+
<UiIcon name="x" :size="14" />
|
|
1909
|
+
</UiInputGroupButton>
|
|
1910
|
+
</UiInputGroupAddon>
|
|
1911
|
+
</UiInputGroup>
|
|
1912
|
+
`,
|
|
1913
|
+
}),
|
|
1914
|
+
play: async ({ canvasElement, step }) => {
|
|
1915
|
+
// Scenario (UiInputGroup): assistive tech reads the group, the labelled control,
|
|
1916
|
+
// and the named icon-only action.
|
|
1917
|
+
const canvas = within(canvasElement);
|
|
1918
|
+
|
|
1919
|
+
await step(
|
|
1920
|
+
'screen-reader: exposes a group role with an accessible name (WCAG 4.1.2)',
|
|
1921
|
+
async () => {
|
|
1922
|
+
const group = canvas.getByRole('group', { name: 'Email field' });
|
|
1923
|
+
await expect(group).toHaveAccessibleName('Email field');
|
|
1924
|
+
},
|
|
1925
|
+
);
|
|
1926
|
+
|
|
1927
|
+
await step(
|
|
1928
|
+
'screen-reader: the addon label names the control (WCAG 1.3.1)',
|
|
1929
|
+
async () => {
|
|
1930
|
+
const input = canvas.getByRole('textbox', { name: 'Email' });
|
|
1931
|
+
await expect(input).toHaveAccessibleName('Email');
|
|
1932
|
+
},
|
|
1933
|
+
);
|
|
1934
|
+
|
|
1935
|
+
await step(
|
|
1936
|
+
'screen-reader: icon-only addon buttons expose their own names',
|
|
1937
|
+
async () => {
|
|
1938
|
+
await expect(
|
|
1939
|
+
canvas.getByRole('button', { name: 'Clear email' }),
|
|
1940
|
+
).toBeInTheDocument();
|
|
1941
|
+
},
|
|
1942
|
+
);
|
|
1943
|
+
},
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar
|
|
1948
|
+
* to try 400% reflow (WCAG 1.4.10); the group must stay visible and operable.
|
|
1949
|
+
* Hidden test-only story.
|
|
1950
|
+
*/
|
|
1951
|
+
export const ZoomMagnification: Story = {
|
|
1952
|
+
name: 'test - Zoom Magnification',
|
|
1953
|
+
tags: ['!dev', '!autodocs'],
|
|
1954
|
+
globals: { zoom: '200' },
|
|
1955
|
+
parameters: {
|
|
1956
|
+
chromatic: { disableSnapshot: true },
|
|
1957
|
+
docs: {
|
|
1958
|
+
description: {
|
|
1959
|
+
story:
|
|
1960
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
1961
|
+
},
|
|
1962
|
+
},
|
|
1963
|
+
},
|
|
1964
|
+
render: () => ({
|
|
1965
|
+
components: {
|
|
1966
|
+
UiInputGroup,
|
|
1967
|
+
UiInputGroupAddon,
|
|
1968
|
+
UiInputGroupInput,
|
|
1969
|
+
UiIcon,
|
|
1970
|
+
},
|
|
1971
|
+
setup() {
|
|
1972
|
+
return { onUpdate };
|
|
1973
|
+
},
|
|
1974
|
+
template: `
|
|
1975
|
+
<UiInputGroup class="max-w-sm">
|
|
1976
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" @update:model-value="onUpdate" />
|
|
1977
|
+
<UiInputGroupAddon>
|
|
1978
|
+
<UiIcon name="search" :size="16" />
|
|
1979
|
+
</UiInputGroupAddon>
|
|
1980
|
+
</UiInputGroup>
|
|
1981
|
+
`,
|
|
1982
|
+
}),
|
|
1983
|
+
play: async ({ canvasElement, step }) => {
|
|
1984
|
+
// Scenario (UiInputGroup): at 200% page zoom the group stays visible and the control
|
|
1985
|
+
// remains operable.
|
|
1986
|
+
onUpdate.mockClear();
|
|
1987
|
+
const canvas = within(canvasElement);
|
|
1988
|
+
const input = canvas.getByRole('textbox', { name: 'Search' });
|
|
1989
|
+
|
|
1990
|
+
await step(
|
|
1991
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
1992
|
+
async () => {
|
|
1993
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
1994
|
+
},
|
|
1995
|
+
);
|
|
1996
|
+
|
|
1997
|
+
await step('zoom: group stays visible when magnified', async () => {
|
|
1998
|
+
await expect(input).toBeVisible();
|
|
1999
|
+
});
|
|
2000
|
+
|
|
2001
|
+
await step('zoom: remains operable when magnified', async () => {
|
|
2002
|
+
await userEvent.click(input);
|
|
2003
|
+
await userEvent.keyboard('a');
|
|
2004
|
+
await expect(onUpdate).toHaveBeenLastCalledWith('a');
|
|
2005
|
+
});
|
|
2006
|
+
},
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
2011
|
+
* toolbar. Stays operable and each addon action meets the minimum
|
|
2012
|
+
* touch-target size (WCAG 1.4.10 Reflow, 2.5.8 Target Size (Minimum)).
|
|
2013
|
+
* Hidden test-only story.
|
|
2014
|
+
*/
|
|
2015
|
+
export const MobileBreakpoint: Story = {
|
|
2016
|
+
name: 'test - Mobile Breakpoint',
|
|
2017
|
+
tags: ['!dev', '!autodocs'],
|
|
2018
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
2019
|
+
parameters: {
|
|
2020
|
+
chromatic: { disableSnapshot: true },
|
|
2021
|
+
docs: {
|
|
2022
|
+
description: {
|
|
2023
|
+
story:
|
|
2024
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
2025
|
+
},
|
|
2026
|
+
},
|
|
2027
|
+
},
|
|
2028
|
+
render: () => ({
|
|
2029
|
+
components: {
|
|
2030
|
+
UiInputGroup,
|
|
2031
|
+
UiInputGroupAddon,
|
|
2032
|
+
UiInputGroupButton,
|
|
2033
|
+
UiInputGroupInput,
|
|
2034
|
+
UiIcon,
|
|
2035
|
+
},
|
|
2036
|
+
setup() {
|
|
2037
|
+
return { onUpdate, onClick };
|
|
2038
|
+
},
|
|
2039
|
+
template: `
|
|
2040
|
+
<UiInputGroup>
|
|
2041
|
+
<UiInputGroupInput placeholder="Search..." aria-label="Search" @update:model-value="onUpdate" />
|
|
2042
|
+
<UiInputGroupAddon>
|
|
2043
|
+
<UiIcon name="search" :size="16" />
|
|
2044
|
+
</UiInputGroupAddon>
|
|
2045
|
+
<UiInputGroupAddon align="inline-end">
|
|
2046
|
+
<UiInputGroupButton size="icon-xs" aria-label="Search by voice" @click="onClick">
|
|
2047
|
+
<UiIcon name="mic" :size="14" />
|
|
2048
|
+
</UiInputGroupButton>
|
|
2049
|
+
</UiInputGroupAddon>
|
|
2050
|
+
</UiInputGroup>
|
|
2051
|
+
`,
|
|
2052
|
+
}),
|
|
2053
|
+
play: async ({ canvasElement, step }) => {
|
|
2054
|
+
// Scenario (UiInputGroup): at the 320px mobile breakpoint the group fits the
|
|
2055
|
+
// viewport, stays operable, and its action meets the touch-target minimum.
|
|
2056
|
+
onUpdate.mockClear();
|
|
2057
|
+
onClick.mockClear();
|
|
2058
|
+
const canvas = within(canvasElement);
|
|
2059
|
+
const input = canvas.getByRole('textbox', { name: 'Search' });
|
|
2060
|
+
const voice = canvas.getByRole('button', { name: 'Search by voice' });
|
|
2061
|
+
|
|
2062
|
+
await step(
|
|
2063
|
+
'mobile: renders and stays operable at the 320px breakpoint (WCAG 1.4.10)',
|
|
2064
|
+
async () => {
|
|
2065
|
+
await expect(input).toBeVisible();
|
|
2066
|
+
await userEvent.click(input);
|
|
2067
|
+
await userEvent.keyboard('hi');
|
|
2068
|
+
await expect(onUpdate).toHaveBeenLastCalledWith('hi');
|
|
2069
|
+
},
|
|
2070
|
+
);
|
|
2071
|
+
|
|
2072
|
+
await step(
|
|
2073
|
+
'mobile: addon action meets the minimum touch-target size (WCAG 2.5.8)',
|
|
2074
|
+
async () => {
|
|
2075
|
+
const { width, height } = voice.getBoundingClientRect();
|
|
2076
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
2077
|
+
await expect(height).toBeGreaterThanOrEqual(24);
|
|
2078
|
+
await userEvent.click(voice);
|
|
2079
|
+
await expect(onClick).toHaveBeenCalledTimes(1);
|
|
2080
|
+
},
|
|
2081
|
+
);
|
|
2082
|
+
},
|
|
2083
|
+
};
|