@aleph-alpha/ui-library 6.3.3 → 6.4.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/config.js +2 -1
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
- package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
- package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
- package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
- package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
- package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
- package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
- package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
- package/dist/system/components/UiStepper/context.d.ts +8 -0
- package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
- package/dist/system/components/UiToggle/types.d.ts +10 -2
- package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
- package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
- package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
- package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
- package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
- package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
- package/dist/system/components/core/toggle/index.d.ts +47 -2
- package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
- package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
- package/dist/system/components/core/toggle-group/context.d.ts +1 -0
- package/dist/system/components/core/toggle-group/index.d.ts +10 -2
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +14114 -13755
- package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +379 -8
- package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
- package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +232 -0
- package/dist/system/story-sidebar-icons.json +7 -0
- package/package.json +2 -2
- package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
- package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
- package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
- package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
- package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
- package/src/components/UiDropdownMenu/types.ts +3 -0
- package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
- package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
- package/src/components/UiFileUploadBox/types.ts +8 -5
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
- package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +1089 -4
- package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
- package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
- package/src/components/UiStepper/UiStepper.stories.ts +566 -2
- package/src/components/UiStepper/UiStepper.vue +14 -1
- package/src/components/UiStepper/UiStepperItem.vue +22 -4
- package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
- package/src/components/UiStepper/context.ts +10 -0
- package/src/components/UiToggle/UiToggle.stories.ts +386 -261
- package/src/components/UiToggle/UiToggle.vue +2 -0
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
- package/src/components/UiToggle/types.ts +10 -2
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
- package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
- package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
- package/src/components/UiToggleGroup/types.ts +12 -2
- package/src/components/core/calendar/Calendar.vue +234 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
- package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/src/components/core/toggle/Toggle.vue +12 -5
- package/src/components/core/toggle/index.ts +47 -19
- package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
- package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
- package/src/components/core/toggle-group/context.ts +1 -0
- package/src/components/core/toggle-group/index.ts +10 -24
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
- package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
- package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
- package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
- package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
- package/src/patterns/UiLayout/layout-shell.ts +159 -13
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
- package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
- package/src/patterns/UiTopBar/accessory-dropdown.ts +99 -0
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { CalendarDate, getLocalTimeZone, today } from '@internationalized/date';
|
|
3
3
|
import type { DateRange, DateValue } from 'reka-ui';
|
|
4
|
+
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
4
5
|
import { ref, watch } from 'vue';
|
|
5
6
|
import UiDatePicker from './UiDatePicker.vue';
|
|
6
7
|
|
|
8
|
+
// Module-level spy shared by every story with a play function; each play
|
|
9
|
+
// clears it first so runs stay independent.
|
|
10
|
+
const onUpdate = fn();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the day cell trigger for the given ISO date from the popover
|
|
14
|
+
* calendar (portaled to `document.body`), throwing when absent. Day triggers
|
|
15
|
+
* are divs with `role="button"`, queried by slot; the single and range
|
|
16
|
+
* calendars use different slots.
|
|
17
|
+
* @param value ISO date string, e.g. `2026-06-15`.
|
|
18
|
+
*/
|
|
19
|
+
function getDayCell(value: string): HTMLElement {
|
|
20
|
+
const cell = document.body.querySelector<HTMLElement>(
|
|
21
|
+
`[data-slot="calendar-cell-trigger"][data-value='${value}']:not([data-outside-view]),` +
|
|
22
|
+
`[data-slot="range-calendar-trigger"][data-value='${value}']:not([data-outside-view])`,
|
|
23
|
+
);
|
|
24
|
+
if (!cell) throw new Error(`Expected a day cell for ${value}`);
|
|
25
|
+
return cell;
|
|
26
|
+
}
|
|
27
|
+
|
|
7
28
|
const meta: Meta<typeof UiDatePicker> = {
|
|
8
29
|
title: 'Patterns/UiDatePicker',
|
|
9
30
|
component: UiDatePicker,
|
|
10
31
|
tags: ['autodocs'],
|
|
11
32
|
decorators: [
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
// The Accessibility story renders Default/Accessible panels side by side
|
|
34
|
+
// with explanatory text, so it needs the full canvas width; every other
|
|
35
|
+
// story shrinks to the picker's intrinsic size.
|
|
36
|
+
(story, context) => ({
|
|
37
|
+
template: `<div class="${
|
|
38
|
+
context.name === 'Accessibility' ? 'w-full p-4' : 'inline-block'
|
|
39
|
+
}"><story /></div>`,
|
|
14
40
|
}),
|
|
15
41
|
],
|
|
16
42
|
argTypes: {
|
|
@@ -120,7 +146,9 @@ export const Default: Story = {
|
|
|
120
146
|
watch(
|
|
121
147
|
() => args.modelValue,
|
|
122
148
|
(val) => {
|
|
123
|
-
|
|
149
|
+
// Range values belong to range mode; this single-mode binding
|
|
150
|
+
// ignores them.
|
|
151
|
+
date.value = val && 'start' in val ? undefined : val;
|
|
124
152
|
},
|
|
125
153
|
);
|
|
126
154
|
return { date, args };
|
|
@@ -152,10 +180,10 @@ export const Default: Story = {
|
|
|
152
180
|
const withPreselectedDateTemplateSource = `<script setup lang="ts">
|
|
153
181
|
import { ref } from 'vue'
|
|
154
182
|
import type { DateValue } from '@internationalized/date'
|
|
155
|
-
import {
|
|
183
|
+
import { CalendarDate } from '@internationalized/date'
|
|
156
184
|
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
157
185
|
|
|
158
|
-
const date = ref<DateValue>(
|
|
186
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15))
|
|
159
187
|
</script>
|
|
160
188
|
|
|
161
189
|
<template>
|
|
@@ -163,28 +191,69 @@ const date = ref<DateValue>(today(getLocalTimeZone()))
|
|
|
163
191
|
</template>`;
|
|
164
192
|
|
|
165
193
|
/**
|
|
166
|
-
* Date picker with a pre-selected date (
|
|
194
|
+
* Date picker with a pre-selected date (a fixed date, June 15 2026, so the
|
|
195
|
+
* story and its automated checks never depend on the real date).
|
|
167
196
|
*/
|
|
168
197
|
export const WithPreselectedDate: Story = {
|
|
169
198
|
render: (args) => ({
|
|
170
199
|
components: { UiDatePicker },
|
|
171
200
|
setup() {
|
|
172
|
-
const date = ref<DateValue>(
|
|
173
|
-
return { date, args };
|
|
201
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15));
|
|
202
|
+
return { date, args, onUpdate };
|
|
174
203
|
},
|
|
175
204
|
template: `<UiDatePicker
|
|
176
205
|
v-model="date"
|
|
177
206
|
:locale="args.locale"
|
|
178
207
|
:disabled="args.disabled"
|
|
208
|
+
@update:model-value="onUpdate"
|
|
179
209
|
/>`,
|
|
180
210
|
}),
|
|
181
211
|
parameters: {
|
|
212
|
+
// The play opens the popover, moves focus, and replaces the preselected
|
|
213
|
+
// date, so the end state no longer matches the showcased selection.
|
|
214
|
+
chromatic: { disableSnapshot: true },
|
|
182
215
|
docs: {
|
|
183
216
|
source: {
|
|
184
217
|
code: withPreselectedDateTemplateSource,
|
|
185
218
|
},
|
|
186
219
|
},
|
|
187
220
|
},
|
|
221
|
+
play: async ({ canvasElement, step }) => {
|
|
222
|
+
// Scenario (UiDatePicker): a pointer user opens the input's calendar on
|
|
223
|
+
// the preselected month, sees the selection marked, and picks a new day.
|
|
224
|
+
onUpdate.mockClear();
|
|
225
|
+
const canvas = within(canvasElement);
|
|
226
|
+
const body = within(document.body);
|
|
227
|
+
const trigger = canvas.getByRole('button');
|
|
228
|
+
|
|
229
|
+
await step(
|
|
230
|
+
'interaction: the trigger shows the selected date and opens the calendar on its month',
|
|
231
|
+
async () => {
|
|
232
|
+
await expect(trigger).toHaveTextContent('June 15, 2026');
|
|
233
|
+
await userEvent.click(trigger);
|
|
234
|
+
await body.findByRole('dialog');
|
|
235
|
+
// The calendar is lazy-loaded inside the popover.
|
|
236
|
+
await waitFor(async () => {
|
|
237
|
+
await expect(getDayCell('2026-06-15').closest('td')).toHaveAttribute(
|
|
238
|
+
'aria-selected',
|
|
239
|
+
'true',
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
await step(
|
|
246
|
+
'interaction: picking a day updates the input and closes the popover',
|
|
247
|
+
async () => {
|
|
248
|
+
await userEvent.click(getDayCell('2026-06-20'));
|
|
249
|
+
await expect(String(onUpdate.mock.lastCall?.[0])).toBe('2026-06-20');
|
|
250
|
+
await waitFor(async () => {
|
|
251
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
252
|
+
});
|
|
253
|
+
await expect(trigger).toHaveTextContent('June 20, 2026');
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
},
|
|
188
257
|
};
|
|
189
258
|
|
|
190
259
|
const withMonthYearDropdownsTemplateSource = `<script setup lang="ts">
|
|
@@ -244,6 +313,96 @@ export const WithMonthYearDropdowns: Story = {
|
|
|
244
313
|
},
|
|
245
314
|
};
|
|
246
315
|
|
|
316
|
+
const monthOnlyTemplateSource = `<script setup lang="ts">
|
|
317
|
+
import { ref } from 'vue'
|
|
318
|
+
import type { DateValue } from '@internationalized/date'
|
|
319
|
+
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
320
|
+
|
|
321
|
+
const date = ref<DateValue>()
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
<template>
|
|
325
|
+
<UiDatePicker v-model="date" layout="month-only" placeholder="Select date" />
|
|
326
|
+
</template>`;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Date picker with a month dropdown in the calendar header.
|
|
330
|
+
* Use `layout="month-only"` when users mostly stay within a year but jump
|
|
331
|
+
* between months.
|
|
332
|
+
*/
|
|
333
|
+
export const MonthOnly: Story = {
|
|
334
|
+
args: {
|
|
335
|
+
layout: 'month-only',
|
|
336
|
+
placeholder: 'Select date',
|
|
337
|
+
},
|
|
338
|
+
render: (args) => ({
|
|
339
|
+
components: { UiDatePicker },
|
|
340
|
+
setup() {
|
|
341
|
+
const date = ref<DateValue>();
|
|
342
|
+
return { date, args };
|
|
343
|
+
},
|
|
344
|
+
template: `<UiDatePicker
|
|
345
|
+
v-model="date"
|
|
346
|
+
:layout="args.layout"
|
|
347
|
+
:placeholder="args.placeholder"
|
|
348
|
+
:disabled="args.disabled"
|
|
349
|
+
:locale="args.locale"
|
|
350
|
+
/>`,
|
|
351
|
+
}),
|
|
352
|
+
parameters: {
|
|
353
|
+
docs: {
|
|
354
|
+
source: {
|
|
355
|
+
code: monthOnlyTemplateSource,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const yearOnlyTemplateSource = `<script setup lang="ts">
|
|
362
|
+
import { ref } from 'vue'
|
|
363
|
+
import type { DateValue } from '@internationalized/date'
|
|
364
|
+
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
365
|
+
|
|
366
|
+
const date = ref<DateValue>()
|
|
367
|
+
</script>
|
|
368
|
+
|
|
369
|
+
<template>
|
|
370
|
+
<UiDatePicker v-model="date" layout="year-only" placeholder="Select date" />
|
|
371
|
+
</template>`;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Date picker with a year dropdown in the calendar header.
|
|
375
|
+
* Use `layout="year-only"` when users navigate across years, e.g. for
|
|
376
|
+
* anniversaries or document dates.
|
|
377
|
+
*/
|
|
378
|
+
export const YearOnly: Story = {
|
|
379
|
+
args: {
|
|
380
|
+
layout: 'year-only',
|
|
381
|
+
placeholder: 'Select date',
|
|
382
|
+
},
|
|
383
|
+
render: (args) => ({
|
|
384
|
+
components: { UiDatePicker },
|
|
385
|
+
setup() {
|
|
386
|
+
const date = ref<DateValue>();
|
|
387
|
+
return { date, args };
|
|
388
|
+
},
|
|
389
|
+
template: `<UiDatePicker
|
|
390
|
+
v-model="date"
|
|
391
|
+
:layout="args.layout"
|
|
392
|
+
:placeholder="args.placeholder"
|
|
393
|
+
:disabled="args.disabled"
|
|
394
|
+
:locale="args.locale"
|
|
395
|
+
/>`,
|
|
396
|
+
}),
|
|
397
|
+
parameters: {
|
|
398
|
+
docs: {
|
|
399
|
+
source: {
|
|
400
|
+
code: yearOnlyTemplateSource,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
|
|
247
406
|
const withDateRangeTemplateSource = `<script setup lang="ts">
|
|
248
407
|
import { ref } from 'vue'
|
|
249
408
|
import type { DateValue } from '@internationalized/date'
|
|
@@ -360,6 +519,105 @@ export const DisabledWeekends: Story = {
|
|
|
360
519
|
},
|
|
361
520
|
};
|
|
362
521
|
|
|
522
|
+
const unavailableDatesTemplateSource = `<script setup lang="ts">
|
|
523
|
+
import { ref } from 'vue'
|
|
524
|
+
import type { DateValue } from '@internationalized/date'
|
|
525
|
+
import { CalendarDate } from '@internationalized/date'
|
|
526
|
+
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
527
|
+
|
|
528
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15))
|
|
529
|
+
|
|
530
|
+
// Mark already-booked days as unavailable
|
|
531
|
+
const isDateUnavailable = (date: DateValue) => {
|
|
532
|
+
return date.day === 13 || date.day === 14
|
|
533
|
+
}
|
|
534
|
+
</script>
|
|
535
|
+
|
|
536
|
+
<template>
|
|
537
|
+
<UiDatePicker
|
|
538
|
+
v-model="date"
|
|
539
|
+
:is-date-unavailable="isDateUnavailable"
|
|
540
|
+
placeholder="Select delivery date"
|
|
541
|
+
/>
|
|
542
|
+
</template>`;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Date picker with unavailable dates (e.g. already booked). Unlike disabled
|
|
546
|
+
* dates, unavailable days stay focusable and are announced as unavailable,
|
|
547
|
+
* but cannot be selected.
|
|
548
|
+
*/
|
|
549
|
+
export const UnavailableDates: Story = {
|
|
550
|
+
args: {
|
|
551
|
+
placeholder: 'Select delivery date',
|
|
552
|
+
},
|
|
553
|
+
render: (args) => ({
|
|
554
|
+
components: { UiDatePicker },
|
|
555
|
+
setup() {
|
|
556
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15));
|
|
557
|
+
const isDateUnavailable = (d: DateValue) => d.day === 13 || d.day === 14;
|
|
558
|
+
return { date, isDateUnavailable, args, onUpdate };
|
|
559
|
+
},
|
|
560
|
+
template: `<UiDatePicker
|
|
561
|
+
v-model="date"
|
|
562
|
+
:is-date-unavailable="isDateUnavailable"
|
|
563
|
+
:placeholder="args.placeholder"
|
|
564
|
+
:disabled="args.disabled"
|
|
565
|
+
:locale="args.locale"
|
|
566
|
+
@update:model-value="onUpdate"
|
|
567
|
+
/>`,
|
|
568
|
+
}),
|
|
569
|
+
parameters: {
|
|
570
|
+
// The play opens the popover and moves focus into it.
|
|
571
|
+
chromatic: { disableSnapshot: true },
|
|
572
|
+
docs: {
|
|
573
|
+
source: {
|
|
574
|
+
code: unavailableDatesTemplateSource,
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
play: async ({ canvasElement, step }) => {
|
|
579
|
+
// Scenario (UiDatePicker): an unavailable (booked) day is announced as
|
|
580
|
+
// disabled and refuses selection, while the value stays untouched.
|
|
581
|
+
onUpdate.mockClear();
|
|
582
|
+
const canvas = within(canvasElement);
|
|
583
|
+
const body = within(document.body);
|
|
584
|
+
const trigger = canvas.getByRole('button');
|
|
585
|
+
|
|
586
|
+
await step(
|
|
587
|
+
'interaction: an unavailable day announces aria-disabled and cannot be selected (WCAG 4.1.2)',
|
|
588
|
+
async () => {
|
|
589
|
+
await userEvent.click(trigger);
|
|
590
|
+
await body.findByRole('dialog');
|
|
591
|
+
// The calendar is lazy-loaded inside the popover.
|
|
592
|
+
await waitFor(async () => {
|
|
593
|
+
await expect(getDayCell('2026-06-13')).toHaveAttribute(
|
|
594
|
+
'data-unavailable',
|
|
595
|
+
);
|
|
596
|
+
});
|
|
597
|
+
const unavailableDay = getDayCell('2026-06-13');
|
|
598
|
+
await expect(unavailableDay).toHaveAttribute('aria-disabled', 'true');
|
|
599
|
+
await userEvent.click(unavailableDay);
|
|
600
|
+
await expect(onUpdate).not.toHaveBeenCalled();
|
|
601
|
+
// The popper wrapper stays visibility:hidden until positioned.
|
|
602
|
+
await waitFor(async () => {
|
|
603
|
+
await expect(body.getByRole('dialog')).toBeVisible();
|
|
604
|
+
});
|
|
605
|
+
await expect(trigger).toHaveTextContent('June 15, 2026');
|
|
606
|
+
},
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
await step(
|
|
610
|
+
'interaction: Escape closes the calendar without selecting',
|
|
611
|
+
async () => {
|
|
612
|
+
await userEvent.keyboard('{Escape}');
|
|
613
|
+
await waitFor(async () => {
|
|
614
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
615
|
+
});
|
|
616
|
+
},
|
|
617
|
+
);
|
|
618
|
+
},
|
|
619
|
+
};
|
|
620
|
+
|
|
363
621
|
const germanLocaleTemplateSource = `<script setup lang="ts">
|
|
364
622
|
import { ref } from 'vue'
|
|
365
623
|
import type { DateValue } from '@internationalized/date'
|
|
@@ -444,6 +702,108 @@ export const Disabled: Story = {
|
|
|
444
702
|
},
|
|
445
703
|
},
|
|
446
704
|
},
|
|
705
|
+
play: async ({ canvasElement, step }) => {
|
|
706
|
+
// Scenario (UiDatePicker): the disabled picker is announced as disabled
|
|
707
|
+
// and must not open its calendar. Nothing changes state, so the Chromatic
|
|
708
|
+
// snapshot of the disabled styling stays valid.
|
|
709
|
+
const canvas = within(canvasElement);
|
|
710
|
+
const body = within(document.body);
|
|
711
|
+
const trigger = canvas.getByRole('button');
|
|
712
|
+
|
|
713
|
+
await step(
|
|
714
|
+
'interaction: a disabled picker does not open (WCAG 4.1.2)',
|
|
715
|
+
async () => {
|
|
716
|
+
await expect(trigger).toBeDisabled();
|
|
717
|
+
// The disabled trigger renders with pointer-events: none; bypass the
|
|
718
|
+
// check to prove the guard itself blocks activation.
|
|
719
|
+
await userEvent.click(trigger, { pointerEventsCheck: 0 });
|
|
720
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
721
|
+
},
|
|
722
|
+
);
|
|
723
|
+
},
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const readonlyTemplateSource = `<script setup lang="ts">
|
|
727
|
+
import { ref } from 'vue'
|
|
728
|
+
import type { DateValue } from '@internationalized/date'
|
|
729
|
+
import { CalendarDate } from '@internationalized/date'
|
|
730
|
+
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
731
|
+
|
|
732
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15))
|
|
733
|
+
</script>
|
|
734
|
+
|
|
735
|
+
<template>
|
|
736
|
+
<UiDatePicker v-model="date" readonly />
|
|
737
|
+
</template>`;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Read-only date picker state.
|
|
741
|
+
* The calendar still opens for browsing, but the selection cannot change.
|
|
742
|
+
*/
|
|
743
|
+
export const Readonly: Story = {
|
|
744
|
+
args: {
|
|
745
|
+
readonly: true,
|
|
746
|
+
},
|
|
747
|
+
render: (args) => ({
|
|
748
|
+
components: { UiDatePicker },
|
|
749
|
+
setup() {
|
|
750
|
+
const date = ref<DateValue>(new CalendarDate(2026, 6, 15));
|
|
751
|
+
return { date, args, onUpdate };
|
|
752
|
+
},
|
|
753
|
+
template: `<UiDatePicker
|
|
754
|
+
v-model="date"
|
|
755
|
+
:readonly="args.readonly"
|
|
756
|
+
:locale="args.locale"
|
|
757
|
+
@update:model-value="onUpdate"
|
|
758
|
+
/>`,
|
|
759
|
+
}),
|
|
760
|
+
parameters: {
|
|
761
|
+
// The play opens the popover and moves focus into it.
|
|
762
|
+
chromatic: { disableSnapshot: true },
|
|
763
|
+
docs: {
|
|
764
|
+
source: {
|
|
765
|
+
code: readonlyTemplateSource,
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
play: async ({ canvasElement, step }) => {
|
|
770
|
+
// Scenario (UiDatePicker): read-only — the calendar can be browsed, but
|
|
771
|
+
// clicking a day must never change the value.
|
|
772
|
+
onUpdate.mockClear();
|
|
773
|
+
const canvas = within(canvasElement);
|
|
774
|
+
const body = within(document.body);
|
|
775
|
+
const trigger = canvas.getByRole('button');
|
|
776
|
+
|
|
777
|
+
await step(
|
|
778
|
+
'interaction: read-only selection cannot change the value',
|
|
779
|
+
async () => {
|
|
780
|
+
await expect(trigger).toHaveTextContent('June 15, 2026');
|
|
781
|
+
await userEvent.click(trigger);
|
|
782
|
+
await body.findByRole('dialog');
|
|
783
|
+
// The calendar is lazy-loaded inside the popover.
|
|
784
|
+
await waitFor(async () => {
|
|
785
|
+
await expect(getDayCell('2026-06-20')).toBeVisible();
|
|
786
|
+
});
|
|
787
|
+
await userEvent.click(getDayCell('2026-06-20'));
|
|
788
|
+
await expect(onUpdate).not.toHaveBeenCalled();
|
|
789
|
+
await expect(getDayCell('2026-06-15').closest('td')).toHaveAttribute(
|
|
790
|
+
'aria-selected',
|
|
791
|
+
'true',
|
|
792
|
+
);
|
|
793
|
+
await expect(trigger).toHaveTextContent('June 15, 2026');
|
|
794
|
+
},
|
|
795
|
+
);
|
|
796
|
+
|
|
797
|
+
await step(
|
|
798
|
+
'interaction: Escape closes the browse-only calendar',
|
|
799
|
+
async () => {
|
|
800
|
+
await userEvent.keyboard('{Escape}');
|
|
801
|
+
await waitFor(async () => {
|
|
802
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
803
|
+
});
|
|
804
|
+
},
|
|
805
|
+
);
|
|
806
|
+
},
|
|
447
807
|
};
|
|
448
808
|
|
|
449
809
|
const customWidthTemplateSource = `<script setup lang="ts">
|
|
@@ -803,13 +1163,12 @@ export const RangeWithConstraints: Story = {
|
|
|
803
1163
|
const rangePreselectedTemplateSource = `<script setup lang="ts">
|
|
804
1164
|
import { ref } from 'vue'
|
|
805
1165
|
import type { DateRange } from '@aleph-alpha/ui-library'
|
|
806
|
-
import {
|
|
1166
|
+
import { CalendarDate } from '@internationalized/date'
|
|
807
1167
|
import { UiDatePicker } from '@aleph-alpha/ui-library'
|
|
808
1168
|
|
|
809
|
-
const todayDate = today(getLocalTimeZone())
|
|
810
1169
|
const dateRange = ref<DateRange>({
|
|
811
|
-
start:
|
|
812
|
-
end:
|
|
1170
|
+
start: new CalendarDate(2026, 6, 10),
|
|
1171
|
+
end: new CalendarDate(2026, 6, 17),
|
|
813
1172
|
})
|
|
814
1173
|
</script>
|
|
815
1174
|
|
|
@@ -818,7 +1177,8 @@ const dateRange = ref<DateRange>({
|
|
|
818
1177
|
</template>`;
|
|
819
1178
|
|
|
820
1179
|
/**
|
|
821
|
-
* Range date picker with a pre-selected 7-day range
|
|
1180
|
+
* Range date picker with a pre-selected 7-day range (fixed June 10–17 2026,
|
|
1181
|
+
* so the story and its automated checks never depend on the real date).
|
|
822
1182
|
* Shows both months for better visualization of the selected range.
|
|
823
1183
|
*/
|
|
824
1184
|
export const RangePreselected: Story = {
|
|
@@ -829,12 +1189,11 @@ export const RangePreselected: Story = {
|
|
|
829
1189
|
render: (args) => ({
|
|
830
1190
|
components: { UiDatePicker },
|
|
831
1191
|
setup() {
|
|
832
|
-
const todayDate = today(getLocalTimeZone());
|
|
833
1192
|
const dateRange = ref<DateRange>({
|
|
834
|
-
start:
|
|
835
|
-
end:
|
|
1193
|
+
start: new CalendarDate(2026, 6, 10),
|
|
1194
|
+
end: new CalendarDate(2026, 6, 17),
|
|
836
1195
|
});
|
|
837
|
-
return { dateRange, args };
|
|
1196
|
+
return { dateRange, args, onUpdate };
|
|
838
1197
|
},
|
|
839
1198
|
template: `<UiDatePicker
|
|
840
1199
|
v-model="dateRange"
|
|
@@ -842,15 +1201,66 @@ export const RangePreselected: Story = {
|
|
|
842
1201
|
:number-of-months="2"
|
|
843
1202
|
:disabled="args.disabled"
|
|
844
1203
|
:locale="args.locale"
|
|
1204
|
+
@update:model-value="onUpdate"
|
|
845
1205
|
/>`,
|
|
846
1206
|
}),
|
|
847
1207
|
parameters: {
|
|
1208
|
+
// The play opens the popover, moves focus, and replaces the preselected
|
|
1209
|
+
// range, so the end state no longer matches the showcased selection.
|
|
1210
|
+
chromatic: { disableSnapshot: true },
|
|
848
1211
|
docs: {
|
|
849
1212
|
source: {
|
|
850
1213
|
code: rangePreselectedTemplateSource,
|
|
851
1214
|
},
|
|
852
1215
|
},
|
|
853
1216
|
},
|
|
1217
|
+
play: async ({ canvasElement, step }) => {
|
|
1218
|
+
// Scenario (UiDatePicker, range mode): a pointer user opens the input's
|
|
1219
|
+
// calendar, replaces the preselected range with a new start and end, and
|
|
1220
|
+
// the input reflects the completed range.
|
|
1221
|
+
onUpdate.mockClear();
|
|
1222
|
+
const canvas = within(canvasElement);
|
|
1223
|
+
const body = within(document.body);
|
|
1224
|
+
const trigger = canvas.getByRole('button');
|
|
1225
|
+
|
|
1226
|
+
await step(
|
|
1227
|
+
'interaction: the trigger shows the selected range and opens the calendar',
|
|
1228
|
+
async () => {
|
|
1229
|
+
await expect(trigger).toHaveTextContent(
|
|
1230
|
+
'June 10, 2026 - June 17, 2026',
|
|
1231
|
+
);
|
|
1232
|
+
await userEvent.click(trigger);
|
|
1233
|
+
await body.findByRole('dialog');
|
|
1234
|
+
// The calendar is lazy-loaded inside the popover.
|
|
1235
|
+
await waitFor(async () => {
|
|
1236
|
+
await expect(getDayCell('2026-06-10')).toHaveAttribute(
|
|
1237
|
+
'data-selection-start',
|
|
1238
|
+
);
|
|
1239
|
+
});
|
|
1240
|
+
},
|
|
1241
|
+
);
|
|
1242
|
+
|
|
1243
|
+
await step(
|
|
1244
|
+
'interaction: picking a new start keeps the popover open, the end completes and closes',
|
|
1245
|
+
async () => {
|
|
1246
|
+
await userEvent.click(getDayCell('2026-06-20'));
|
|
1247
|
+
await expect(getDayCell('2026-06-20')).toHaveAttribute(
|
|
1248
|
+
'data-selection-start',
|
|
1249
|
+
);
|
|
1250
|
+
await expect(body.getByRole('dialog')).toBeInTheDocument();
|
|
1251
|
+
await userEvent.click(getDayCell('2026-06-24'));
|
|
1252
|
+
const range = onUpdate.mock.lastCall?.[0] as DateRange;
|
|
1253
|
+
await expect(String(range.start)).toBe('2026-06-20');
|
|
1254
|
+
await expect(String(range.end)).toBe('2026-06-24');
|
|
1255
|
+
await waitFor(async () => {
|
|
1256
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1257
|
+
});
|
|
1258
|
+
await expect(trigger).toHaveTextContent(
|
|
1259
|
+
'June 20, 2026 - June 24, 2026',
|
|
1260
|
+
);
|
|
1261
|
+
},
|
|
1262
|
+
);
|
|
1263
|
+
},
|
|
854
1264
|
};
|
|
855
1265
|
|
|
856
1266
|
const rangeFormExampleTemplateSource = `<script setup lang="ts">
|
|
@@ -974,3 +1384,422 @@ export const RangeKeepOpen: Story = {
|
|
|
974
1384
|
},
|
|
975
1385
|
},
|
|
976
1386
|
};
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Shared single-mode fixture for the hidden test stories: June 15 2026
|
|
1390
|
+
* preselected (so the popover always opens on a fixed month), an
|
|
1391
|
+
* aria-labelled trigger, plus a disabled picker for the inert guard.
|
|
1392
|
+
*/
|
|
1393
|
+
function renderTestPicker() {
|
|
1394
|
+
return {
|
|
1395
|
+
components: { UiDatePicker },
|
|
1396
|
+
setup() {
|
|
1397
|
+
const date = ref<DateValue | undefined>(new CalendarDate(2026, 6, 15));
|
|
1398
|
+
return { date, onUpdate };
|
|
1399
|
+
},
|
|
1400
|
+
template: `
|
|
1401
|
+
<div class="flex flex-col items-start gap-4">
|
|
1402
|
+
<UiDatePicker
|
|
1403
|
+
v-model="date"
|
|
1404
|
+
aria-label="Choose date"
|
|
1405
|
+
@update:model-value="onUpdate"
|
|
1406
|
+
/>
|
|
1407
|
+
<UiDatePicker disabled aria-label="Disabled picker" />
|
|
1408
|
+
</div>
|
|
1409
|
+
`,
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* `UiDatePicker` is fully keyboard operable: `Tab` reaches the trigger,
|
|
1415
|
+
* `Enter` opens the popover with focus moving into the calendar grid, the
|
|
1416
|
+
* calendar keys navigate, `Enter` selects and closes, and `Escape` dismisses
|
|
1417
|
+
* without selecting.
|
|
1418
|
+
*/
|
|
1419
|
+
export const KeyboardNavigation: Story = {
|
|
1420
|
+
name: 'test - Keyboard Navigation',
|
|
1421
|
+
tags: ['!dev', '!autodocs'],
|
|
1422
|
+
parameters: {
|
|
1423
|
+
chromatic: { disableSnapshot: true },
|
|
1424
|
+
docs: {
|
|
1425
|
+
description: {
|
|
1426
|
+
story:
|
|
1427
|
+
'Press `Tab` to reach the trigger, Enter to open, calendar keys to move, Enter to select, Escape to dismiss.',
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1430
|
+
},
|
|
1431
|
+
render: renderTestPicker,
|
|
1432
|
+
play: async ({ canvasElement, step }) => {
|
|
1433
|
+
// Scenario (UiDatePicker): a keyboard user tabs to the input, opens the
|
|
1434
|
+
// calendar, walks the grid, selects a day, then reopens and escapes back
|
|
1435
|
+
// out — all without a pointer.
|
|
1436
|
+
onUpdate.mockClear();
|
|
1437
|
+
const canvas = within(canvasElement);
|
|
1438
|
+
const body = within(document.body);
|
|
1439
|
+
const trigger = canvas.getByRole('button', { name: 'Choose date' });
|
|
1440
|
+
const activeDataValue = () =>
|
|
1441
|
+
document.activeElement?.getAttribute('data-value');
|
|
1442
|
+
|
|
1443
|
+
await step(
|
|
1444
|
+
'keyboard: Tab reaches the trigger and Enter opens the calendar with focus on the selected day (WCAG 2.1.1)',
|
|
1445
|
+
async () => {
|
|
1446
|
+
await userEvent.tab();
|
|
1447
|
+
await expect(trigger).toHaveFocus();
|
|
1448
|
+
await userEvent.keyboard('{Enter}');
|
|
1449
|
+
await body.findByRole('dialog');
|
|
1450
|
+
await waitFor(async () => {
|
|
1451
|
+
await expect(activeDataValue()).toBe('2026-06-15');
|
|
1452
|
+
});
|
|
1453
|
+
},
|
|
1454
|
+
);
|
|
1455
|
+
|
|
1456
|
+
await step(
|
|
1457
|
+
'keyboard: arrow keys move through the grid and Enter selects, closing the popover',
|
|
1458
|
+
async () => {
|
|
1459
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
1460
|
+
await expect(activeDataValue()).toBe('2026-06-16');
|
|
1461
|
+
await userEvent.keyboard('{Enter}');
|
|
1462
|
+
await expect(String(onUpdate.mock.lastCall?.[0])).toBe('2026-06-16');
|
|
1463
|
+
await waitFor(async () => {
|
|
1464
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1465
|
+
});
|
|
1466
|
+
await expect(trigger).toHaveTextContent('June 16, 2026');
|
|
1467
|
+
},
|
|
1468
|
+
);
|
|
1469
|
+
|
|
1470
|
+
await step(
|
|
1471
|
+
'keyboard: Escape dismisses the popover without selecting and returns focus to the trigger (WCAG 2.1.2)',
|
|
1472
|
+
async () => {
|
|
1473
|
+
trigger.focus();
|
|
1474
|
+
await userEvent.keyboard(' ');
|
|
1475
|
+
await body.findByRole('dialog');
|
|
1476
|
+
await userEvent.keyboard('{Escape}');
|
|
1477
|
+
await waitFor(async () => {
|
|
1478
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1479
|
+
});
|
|
1480
|
+
await expect(trigger).toHaveFocus();
|
|
1481
|
+
await expect(trigger).toHaveTextContent('June 16, 2026');
|
|
1482
|
+
},
|
|
1483
|
+
);
|
|
1484
|
+
},
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Screen-reader semantics: the trigger announces its name, popup type, and
|
|
1489
|
+
* expanded state; the popover is a dialog; and the selected day announces
|
|
1490
|
+
* `aria-selected` with every day named by its full date.
|
|
1491
|
+
*/
|
|
1492
|
+
export const ScreenReader: Story = {
|
|
1493
|
+
name: 'test - Screen Reader',
|
|
1494
|
+
tags: ['!dev', '!autodocs'],
|
|
1495
|
+
parameters: {
|
|
1496
|
+
chromatic: { disableSnapshot: true },
|
|
1497
|
+
docs: {
|
|
1498
|
+
description: {
|
|
1499
|
+
story:
|
|
1500
|
+
'Verifies the roles, names, and states that assistive technology announces.',
|
|
1501
|
+
},
|
|
1502
|
+
},
|
|
1503
|
+
},
|
|
1504
|
+
render: renderTestPicker,
|
|
1505
|
+
play: async ({ canvasElement, step }) => {
|
|
1506
|
+
// Scenario (UiDatePicker): assistive tech hears a named button that opens
|
|
1507
|
+
// a dialog, and inside it a date grid announcing full dates and the
|
|
1508
|
+
// selected state.
|
|
1509
|
+
const canvas = within(canvasElement);
|
|
1510
|
+
const body = within(document.body);
|
|
1511
|
+
const trigger = canvas.getByRole('button', { name: 'Choose date' });
|
|
1512
|
+
|
|
1513
|
+
await step(
|
|
1514
|
+
'screen-reader: the trigger announces its name, popup type, and collapsed state (WCAG 4.1.2)',
|
|
1515
|
+
async () => {
|
|
1516
|
+
await expect(trigger).toHaveAccessibleName('Choose date');
|
|
1517
|
+
await expect(trigger).toHaveAttribute('aria-haspopup', 'dialog');
|
|
1518
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1519
|
+
},
|
|
1520
|
+
);
|
|
1521
|
+
|
|
1522
|
+
await step(
|
|
1523
|
+
'screen-reader: opening announces expanded and exposes a dialog (WCAG 4.1.2)',
|
|
1524
|
+
async () => {
|
|
1525
|
+
await userEvent.click(trigger);
|
|
1526
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
1527
|
+
const dialog = await body.findByRole('dialog');
|
|
1528
|
+
// The popper wrapper stays visibility:hidden until positioned.
|
|
1529
|
+
await waitFor(async () => {
|
|
1530
|
+
await expect(dialog).toBeVisible();
|
|
1531
|
+
});
|
|
1532
|
+
},
|
|
1533
|
+
);
|
|
1534
|
+
|
|
1535
|
+
await step(
|
|
1536
|
+
'screen-reader: the selected day announces aria-selected and days carry full-date names (WCAG 4.1.2)',
|
|
1537
|
+
async () => {
|
|
1538
|
+
await waitFor(async () => {
|
|
1539
|
+
await expect(getDayCell('2026-06-15').closest('td')).toHaveAttribute(
|
|
1540
|
+
'aria-selected',
|
|
1541
|
+
'true',
|
|
1542
|
+
);
|
|
1543
|
+
});
|
|
1544
|
+
const day = getDayCell('2026-06-15');
|
|
1545
|
+
await expect(day).toHaveAttribute('role', 'button');
|
|
1546
|
+
await expect(day.getAttribute('aria-label')).toContain('2026');
|
|
1547
|
+
},
|
|
1548
|
+
);
|
|
1549
|
+
|
|
1550
|
+
await step(
|
|
1551
|
+
'screen-reader: the disabled picker announces its disabled state (WCAG 4.1.2)',
|
|
1552
|
+
async () => {
|
|
1553
|
+
await userEvent.keyboard('{Escape}');
|
|
1554
|
+
await waitFor(async () => {
|
|
1555
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1556
|
+
});
|
|
1557
|
+
await expect(
|
|
1558
|
+
canvas.getByRole('button', { name: 'Disabled picker' }),
|
|
1559
|
+
).toBeDisabled();
|
|
1560
|
+
},
|
|
1561
|
+
);
|
|
1562
|
+
},
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
|
|
1567
|
+
* try 400% reflow (WCAG 1.4.10); the input and its calendar must stay visible,
|
|
1568
|
+
* readable, and operable.
|
|
1569
|
+
*/
|
|
1570
|
+
export const ZoomMagnification: Story = {
|
|
1571
|
+
name: 'test - Zoom Magnification',
|
|
1572
|
+
tags: ['!dev', '!autodocs'],
|
|
1573
|
+
globals: { zoom: '200' },
|
|
1574
|
+
parameters: {
|
|
1575
|
+
chromatic: { disableSnapshot: true },
|
|
1576
|
+
docs: {
|
|
1577
|
+
description: {
|
|
1578
|
+
story:
|
|
1579
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
1580
|
+
},
|
|
1581
|
+
},
|
|
1582
|
+
},
|
|
1583
|
+
render: renderTestPicker,
|
|
1584
|
+
play: async ({ canvasElement, step }) => {
|
|
1585
|
+
// Scenario (UiDatePicker): at 200% page zoom the input stays readable and
|
|
1586
|
+
// its popover calendar still opens and accepts a selection.
|
|
1587
|
+
onUpdate.mockClear();
|
|
1588
|
+
const canvas = within(canvasElement);
|
|
1589
|
+
const body = within(document.body);
|
|
1590
|
+
const trigger = canvas.getByRole('button', { name: 'Choose date' });
|
|
1591
|
+
|
|
1592
|
+
await step(
|
|
1593
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
1594
|
+
async () => {
|
|
1595
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
1596
|
+
},
|
|
1597
|
+
);
|
|
1598
|
+
|
|
1599
|
+
await step(
|
|
1600
|
+
'zoom: the input stays visible with a readable value when magnified',
|
|
1601
|
+
async () => {
|
|
1602
|
+
await expect(trigger).toBeVisible();
|
|
1603
|
+
await expect(trigger).toHaveTextContent('June 15, 2026');
|
|
1604
|
+
},
|
|
1605
|
+
);
|
|
1606
|
+
|
|
1607
|
+
await step('zoom: the picker remains operable when magnified', async () => {
|
|
1608
|
+
await userEvent.click(trigger);
|
|
1609
|
+
await body.findByRole('dialog');
|
|
1610
|
+
await waitFor(async () => {
|
|
1611
|
+
await expect(getDayCell('2026-06-20')).toBeVisible();
|
|
1612
|
+
});
|
|
1613
|
+
await userEvent.click(getDayCell('2026-06-20'));
|
|
1614
|
+
await waitFor(async () => {
|
|
1615
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1616
|
+
});
|
|
1617
|
+
await expect(trigger).toHaveTextContent('June 20, 2026');
|
|
1618
|
+
});
|
|
1619
|
+
},
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
1624
|
+
* toolbar. The input and its calendar stay usable and meet the minimum
|
|
1625
|
+
* touch-target size (WCAG 2.5.8).
|
|
1626
|
+
*/
|
|
1627
|
+
export const MobileBreakpoint: Story = {
|
|
1628
|
+
name: 'test - Mobile Breakpoint',
|
|
1629
|
+
tags: ['!dev', '!autodocs'],
|
|
1630
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
1631
|
+
parameters: {
|
|
1632
|
+
chromatic: { disableSnapshot: true },
|
|
1633
|
+
docs: {
|
|
1634
|
+
description: {
|
|
1635
|
+
story:
|
|
1636
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
1637
|
+
},
|
|
1638
|
+
},
|
|
1639
|
+
},
|
|
1640
|
+
render: renderTestPicker,
|
|
1641
|
+
play: async ({ canvasElement, step }) => {
|
|
1642
|
+
// Scenario (UiDatePicker): at the 320px mobile breakpoint the input and
|
|
1643
|
+
// its popover calendar stay on screen, days are big enough to tap, and a
|
|
1644
|
+
// tap still selects.
|
|
1645
|
+
onUpdate.mockClear();
|
|
1646
|
+
const canvas = within(canvasElement);
|
|
1647
|
+
const body = within(document.body);
|
|
1648
|
+
const trigger = canvas.getByRole('button', { name: 'Choose date' });
|
|
1649
|
+
|
|
1650
|
+
await step(
|
|
1651
|
+
'mobile: the input meets the minimum touch-target size (WCAG 2.5.8)',
|
|
1652
|
+
async () => {
|
|
1653
|
+
const { width, height } = trigger.getBoundingClientRect();
|
|
1654
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
1655
|
+
await expect(height).toBeGreaterThanOrEqual(24);
|
|
1656
|
+
},
|
|
1657
|
+
);
|
|
1658
|
+
|
|
1659
|
+
await step(
|
|
1660
|
+
'mobile: the calendar opens within the 320px viewport (WCAG 1.4.10 Reflow)',
|
|
1661
|
+
async () => {
|
|
1662
|
+
await userEvent.click(trigger);
|
|
1663
|
+
await body.findByRole('dialog');
|
|
1664
|
+
await waitFor(async () => {
|
|
1665
|
+
await expect(getDayCell('2026-06-15')).toBeVisible();
|
|
1666
|
+
});
|
|
1667
|
+
},
|
|
1668
|
+
);
|
|
1669
|
+
|
|
1670
|
+
await step(
|
|
1671
|
+
'mobile: day cells meet the minimum touch-target size (WCAG 2.5.8)',
|
|
1672
|
+
async () => {
|
|
1673
|
+
for (const value of ['2026-06-01', '2026-06-15', '2026-06-30']) {
|
|
1674
|
+
const { width, height } = getDayCell(value).getBoundingClientRect();
|
|
1675
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
1676
|
+
await expect(height).toBeGreaterThanOrEqual(24);
|
|
1677
|
+
}
|
|
1678
|
+
},
|
|
1679
|
+
);
|
|
1680
|
+
|
|
1681
|
+
await step(
|
|
1682
|
+
'mobile: tapping a day selects it at the 320px breakpoint',
|
|
1683
|
+
async () => {
|
|
1684
|
+
await userEvent.click(getDayCell('2026-06-20'));
|
|
1685
|
+
await expect(String(onUpdate.mock.lastCall?.[0])).toBe('2026-06-20');
|
|
1686
|
+
await waitFor(async () => {
|
|
1687
|
+
await expect(body.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1688
|
+
});
|
|
1689
|
+
await expect(trigger).toHaveTextContent('June 20, 2026');
|
|
1690
|
+
},
|
|
1691
|
+
);
|
|
1692
|
+
},
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Accessibility guidance for the date-picker input and its popover calendar:
|
|
1697
|
+
* day treatments that survive without colour, comfortable targets, and a
|
|
1698
|
+
* stable grid — shown side by side in the default and accessible themes.
|
|
1699
|
+
*/
|
|
1700
|
+
export const Accessibility: Story = {
|
|
1701
|
+
tags: ['!autodocs'],
|
|
1702
|
+
parameters: {
|
|
1703
|
+
a11y: { test: 'off' },
|
|
1704
|
+
chromatic: { disableSnapshot: true },
|
|
1705
|
+
docs: {
|
|
1706
|
+
canvas: {
|
|
1707
|
+
sourceState: 'none',
|
|
1708
|
+
},
|
|
1709
|
+
},
|
|
1710
|
+
},
|
|
1711
|
+
render: () => ({
|
|
1712
|
+
components: { UiDatePicker },
|
|
1713
|
+
setup() {
|
|
1714
|
+
const date = new CalendarDate(2025, 1, 10);
|
|
1715
|
+
return { date };
|
|
1716
|
+
},
|
|
1717
|
+
template: `
|
|
1718
|
+
<section class="flex w-full flex-col gap-6 p-4">
|
|
1719
|
+
<div>
|
|
1720
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
1721
|
+
Accessibility
|
|
1722
|
+
</h2>
|
|
1723
|
+
</div>
|
|
1724
|
+
|
|
1725
|
+
<div class="flex flex-col gap-6">
|
|
1726
|
+
<div class="flex flex-col gap-2">
|
|
1727
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1728
|
+
Requirements
|
|
1729
|
+
</h3>
|
|
1730
|
+
<ul class="body-16-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
|
|
1731
|
+
<li>
|
|
1732
|
+
Today and the selected day differ in shape as well as fill, so
|
|
1733
|
+
both survive without colour
|
|
1734
|
+
</li>
|
|
1735
|
+
<li>
|
|
1736
|
+
Selected, hover and focus are three distinguishable treatments,
|
|
1737
|
+
not variations of one
|
|
1738
|
+
</li>
|
|
1739
|
+
<li>
|
|
1740
|
+
Focus stays visible on a day even when that day is selected or
|
|
1741
|
+
inside a range
|
|
1742
|
+
</li>
|
|
1743
|
+
<li>
|
|
1744
|
+
Day buttons are a comfortable target at the size chosen,
|
|
1745
|
+
including the smallest one used
|
|
1746
|
+
</li>
|
|
1747
|
+
<li>
|
|
1748
|
+
Unavailable days carry a visible treatment beyond low contrast
|
|
1749
|
+
</li>
|
|
1750
|
+
<li>
|
|
1751
|
+
The grid keeps a stable size between months, so the page does
|
|
1752
|
+
not shift under the reader
|
|
1753
|
+
</li>
|
|
1754
|
+
<li>
|
|
1755
|
+
Give the trigger a meaningful name with aria-label (for example,
|
|
1756
|
+
"Choose departure date") and name its calendar with calendar-label.
|
|
1757
|
+
</li>
|
|
1758
|
+
<li>
|
|
1759
|
+
Tab to the trigger and press Enter or Space to open the calendar.
|
|
1760
|
+
Use arrow keys to navigate dates and Enter or Space to select.
|
|
1761
|
+
In range mode, select the start and then the end date.
|
|
1762
|
+
</li>
|
|
1763
|
+
<li>
|
|
1764
|
+
Escape dismisses the calendar and returns focus to the trigger.
|
|
1765
|
+
By default, selecting a date or completing a range also closes
|
|
1766
|
+
the popover; setting close-on-select to false keeps it open.
|
|
1767
|
+
</li>
|
|
1768
|
+
</ul>
|
|
1769
|
+
</div>
|
|
1770
|
+
|
|
1771
|
+
<div class="flex flex-col gap-2">
|
|
1772
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1773
|
+
Enable accessibility theme
|
|
1774
|
+
</h3>
|
|
1775
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
1776
|
+
When accessibility is required, enable our accessibility theme.
|
|
1777
|
+
This increases contrast and ensures there are no color contrast
|
|
1778
|
+
issues.
|
|
1779
|
+
</p>
|
|
1780
|
+
</div>
|
|
1781
|
+
</div>
|
|
1782
|
+
|
|
1783
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
1784
|
+
<div class="flex flex-col gap-3">
|
|
1785
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1786
|
+
Default
|
|
1787
|
+
</h3>
|
|
1788
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1789
|
+
<UiDatePicker :default-value="date" aria-label="Choose date" />
|
|
1790
|
+
</div>
|
|
1791
|
+
</div>
|
|
1792
|
+
|
|
1793
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
1794
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1795
|
+
Accessible
|
|
1796
|
+
</h3>
|
|
1797
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1798
|
+
<UiDatePicker :default-value="date" aria-label="Choose date" />
|
|
1799
|
+
</div>
|
|
1800
|
+
</div>
|
|
1801
|
+
</div>
|
|
1802
|
+
</section>
|
|
1803
|
+
`,
|
|
1804
|
+
}),
|
|
1805
|
+
};
|