@aleph-alpha/ui-library 5.3.1 → 5.5.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.d.ts +38 -3
- package/config.js +103 -6
- package/dist/system/lib.js +8926 -8768
- package/dist/system/patterns/UiDataTable/UiDataTableFilterMenu.vue.d.ts +24 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +1 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +23 -1
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +173 -2
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +15 -1
- package/dist/system/patterns/UiFloatActions/types.d.ts +25 -1
- package/dist/system/story-sidebar-icons.json +5 -1
- package/docs/public-docs/getting-started-designers.md +3 -1
- package/package.json +5 -3
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +2 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +5 -5
- package/src/components/UiButton/UiButton.stories.ts +14 -14
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +260 -9
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +2 -2
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiEmpty/UiEmpty.vue +2 -2
- package/src/components/UiField/UiField.stories.ts +610 -3
- package/src/components/UiField/UiFieldDescription.vue +7 -2
- package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +2 -2
- package/src/components/UiInput/UiInput.stories.ts +336 -2
- package/src/components/UiInput/UiInput.vue +3 -3
- package/src/components/UiInput/__tests__/UiInput.test.ts +20 -28
- package/src/components/UiItem/UiItem.stories.ts +236 -1
- package/src/components/UiItem/__tests__/UiItem.test.ts +11 -72
- package/src/components/UiKbd/UiKbd.stories.ts +14 -14
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +42 -42
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +2 -2
- package/src/components/UiResizable/UiResizable.stories.ts +6 -5
- package/src/components/UiSeparator/UiSeparator.stories.ts +6 -6
- package/src/components/UiSheet/UiSheet.stories.ts +2 -2
- package/src/components/UiSlider/UiSlider.stories.ts +8 -8
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.vue +4 -4
- package/src/components/UiSnackbar/UiSnackbarContent.vue +4 -4
- package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
- package/src/components/UiSwitch/UiSwitch.stories.ts +2 -2
- package/src/components/UiTabs/UiTabs.stories.ts +30 -30
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +5 -3
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +9 -9
- package/src/components/UiTooltip/UiTooltip.stories.ts +3 -3
- package/src/components/core/accordion/AccordionTrigger.vue +2 -2
- package/src/components/core/alert/AlertDescription.vue +1 -1
- package/src/components/core/badge/index.ts +1 -1
- package/src/components/core/button/index.ts +2 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +2 -2
- package/src/components/core/calendar/CalendarHeadCell.vue +1 -1
- package/src/components/core/card/CardDescription.vue +1 -1
- package/src/components/core/checkbox/Checkbox.vue +1 -2
- package/src/components/core/drawer/DrawerDescription.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/FieldSeparator.vue +1 -1
- package/src/components/core/input/Input.vue +2 -2
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/kbd/Kbd.vue +1 -1
- package/src/components/core/listbox/ListboxFilter.vue +1 -1
- package/src/components/core/listbox/ListboxGroupLabel.vue +4 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +3 -3
- package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
- package/src/components/core/navigation-menu/index.ts +1 -1
- package/src/components/core/radio-group/RadioGroupItem.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +2 -2
- package/src/components/core/range-calendar/RangeCalendarHeadCell.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/select/SelectLabel.vue +4 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/sheet/SheetDescription.vue +3 -1
- package/src/components/core/switch/Switch.vue +1 -1
- package/src/components/core/table/TableCaption.vue +3 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputItemDelete.vue +1 -1
- package/src/components/core/textarea/Textarea.vue +1 -1
- package/src/components/core/toggle/index.ts +3 -3
- package/src/components/core/toggle-group/index.ts +2 -2
- package/src/lib/useDrag.stories.ts +8 -8
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +913 -16
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +91 -0
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
- package/src/patterns/UiDataTable/constants.ts +12 -0
- package/src/patterns/UiDataTable/index.ts +1 -0
- package/src/patterns/UiDataTable/types.ts +24 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +1 -1
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +140 -12
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1231 -438
- package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -1
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +46 -24
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +16 -1
- package/src/patterns/UiFloatActions/types.ts +28 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +2 -2
- package/src/components/UiField/__tests__/UiFieldError.test.ts +0 -39
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
2
3
|
import UiCheckbox from './UiCheckbox.vue';
|
|
3
4
|
import { ref } from 'vue';
|
|
4
5
|
|
|
@@ -30,6 +31,11 @@ export default meta;
|
|
|
30
31
|
|
|
31
32
|
type Story = StoryObj<typeof UiCheckbox>;
|
|
32
33
|
|
|
34
|
+
// `UiCheckbox` forwards `defineModel`, so it emits `update:modelValue`. Play
|
|
35
|
+
// functions that need to assert the emit bind this module-level spy via
|
|
36
|
+
// `@update:model-value` and `mockClear()` it first.
|
|
37
|
+
const onUpdate = fn();
|
|
38
|
+
|
|
33
39
|
const defaultTemplateSource = `<script setup lang="ts">
|
|
34
40
|
import { ref } from 'vue'
|
|
35
41
|
import { UiCheckbox } from '@aleph-alpha/ui-library'
|
|
@@ -70,6 +76,31 @@ export const Default: Story = {
|
|
|
70
76
|
},
|
|
71
77
|
},
|
|
72
78
|
},
|
|
79
|
+
play: async ({ canvasElement, step }) => {
|
|
80
|
+
// Scenario (UiCheckbox): assistive tech sees a checkbox role, the label as its accessible
|
|
81
|
+
// name, and its unchecked state. These checks don't mutate state, so the
|
|
82
|
+
// visual snapshot stays stable.
|
|
83
|
+
const canvas = within(canvasElement);
|
|
84
|
+
const checkbox = canvas.getByRole('checkbox', {
|
|
85
|
+
name: 'Accept terms and conditions',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await step(
|
|
89
|
+
'screen-reader: exposes a checkbox role with its label as the accessible name (WCAG 1.3.1 / 4.1.2)',
|
|
90
|
+
async () => {
|
|
91
|
+
await expect(checkbox).toHaveAccessibleName(
|
|
92
|
+
'Accept terms and conditions',
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
await step(
|
|
98
|
+
'screen-reader: announces the unchecked state via aria-checked',
|
|
99
|
+
async () => {
|
|
100
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'false');
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
},
|
|
73
104
|
};
|
|
74
105
|
|
|
75
106
|
/**
|
|
@@ -245,7 +276,7 @@ const checked = ref(true)
|
|
|
245
276
|
<label for="terms-2" class="body-14-medium">
|
|
246
277
|
Accept terms and conditions
|
|
247
278
|
</label>
|
|
248
|
-
<p class="body-14-regular text-muted
|
|
279
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
249
280
|
By clicking this checkbox, you agree to the terms and conditions.
|
|
250
281
|
</p>
|
|
251
282
|
</div>
|
|
@@ -268,7 +299,7 @@ export const WithDescription: Story = {
|
|
|
268
299
|
<label for="terms-2" class="body-14-medium">
|
|
269
300
|
Accept terms and conditions
|
|
270
301
|
</label>
|
|
271
|
-
<p class="body-14-regular text-muted
|
|
302
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
272
303
|
By clicking this checkbox, you agree to the terms and conditions.
|
|
273
304
|
</p>
|
|
274
305
|
</div>
|
|
@@ -322,6 +353,21 @@ export const Disabled: Story = {
|
|
|
322
353
|
},
|
|
323
354
|
},
|
|
324
355
|
},
|
|
356
|
+
play: async ({ canvasElement, step }) => {
|
|
357
|
+
// Scenario (UiCheckbox): a disabled checkbox reports its disabled state to assistive
|
|
358
|
+
// tech (a disabled control is inherently out of the tab order).
|
|
359
|
+
const canvas = within(canvasElement);
|
|
360
|
+
const checkbox = canvas.getByRole('checkbox', {
|
|
361
|
+
name: 'Enable notifications',
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
await step(
|
|
365
|
+
'interaction: exposes the disabled state (WCAG 4.1.2)',
|
|
366
|
+
async () => {
|
|
367
|
+
await expect(checkbox).toBeDisabled();
|
|
368
|
+
},
|
|
369
|
+
);
|
|
370
|
+
},
|
|
325
371
|
};
|
|
326
372
|
|
|
327
373
|
const cardTemplateSource = `<script setup lang="ts">
|
|
@@ -333,19 +379,18 @@ const enabled = ref(true)
|
|
|
333
379
|
|
|
334
380
|
<template>
|
|
335
381
|
<label
|
|
336
|
-
class="hover:bg-accent/50 flex items-start gap-3 rounded-lg border p-3 has-[[aria-checked=true]]:border-
|
|
382
|
+
class="hover:bg-accent/50 flex items-start gap-3 rounded-lg border p-3 has-[[aria-checked=true]]:border-border-input-default has-[[aria-checked=true]]:bg-background-surface-secondary dark:has-[[aria-checked=true]]:border-blue-900 dark:has-[[aria-checked=true]]:bg-blue-950"
|
|
337
383
|
>
|
|
338
384
|
<UiCheckbox
|
|
339
385
|
id="notifications"
|
|
340
386
|
name="notifications"
|
|
341
387
|
v-model="enabled"
|
|
342
|
-
class="data-[state=checked]:border-blue-600 data-[state=checked]:bg-blue-600 data-[state=checked]:text-white dark:data-[state=checked]:border-blue-700 dark:data-[state=checked]:bg-blue-700"
|
|
343
388
|
/>
|
|
344
389
|
<div class="grid gap-1.5 font-normal">
|
|
345
390
|
<p class="body-14-medium leading-none">
|
|
346
391
|
Enable notifications
|
|
347
392
|
</p>
|
|
348
|
-
<p class="body-14-regular text-muted
|
|
393
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
349
394
|
You can enable or disable notifications at any time.
|
|
350
395
|
</p>
|
|
351
396
|
</div>
|
|
@@ -364,20 +409,19 @@ export const Card: Story = {
|
|
|
364
409
|
return { args, enabled };
|
|
365
410
|
},
|
|
366
411
|
template: `<label
|
|
367
|
-
class="
|
|
412
|
+
class="flex items-start gap-3 rounded-lg border p-3 has-[[aria-checked=true]]:border-border-input-default has-[[aria-checked=true]]:bg-background-surface-muted dark:has-[[aria-checked=true]]:border-blue-900 dark:has-[[aria-checked=true]]:bg-blue-950"
|
|
368
413
|
>
|
|
369
414
|
<UiCheckbox
|
|
370
415
|
id="notifications"
|
|
371
416
|
name="notifications"
|
|
372
417
|
v-model="enabled"
|
|
373
418
|
:disabled="args.disabled"
|
|
374
|
-
class="data-[state=checked]:border-blue-600 data-[state=checked]:bg-blue-600 data-[state=checked]:text-white dark:data-[state=checked]:border-blue-700 dark:data-[state=checked]:bg-blue-700"
|
|
375
419
|
/>
|
|
376
420
|
<div class="grid gap-1.5 font-normal">
|
|
377
|
-
<p class="body-14-medium leading-none">
|
|
421
|
+
<p class="body-14-medium leading-none text-content-on-surface-primary">
|
|
378
422
|
Enable notifications
|
|
379
423
|
</p>
|
|
380
|
-
<p class="body-14-regular text-muted
|
|
424
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
381
425
|
You can enable or disable notifications at any time.
|
|
382
426
|
</p>
|
|
383
427
|
</div>
|
|
@@ -391,3 +435,210 @@ export const Card: Story = {
|
|
|
391
435
|
},
|
|
392
436
|
},
|
|
393
437
|
};
|
|
438
|
+
|
|
439
|
+
const indeterminateTemplateSource = `<script setup lang="ts">
|
|
440
|
+
import { ref } from 'vue'
|
|
441
|
+
import { UiCheckbox } from '@aleph-alpha/ui-library'
|
|
442
|
+
|
|
443
|
+
const checked = ref<'indeterminate' | boolean>('indeterminate')
|
|
444
|
+
</script>
|
|
445
|
+
|
|
446
|
+
<template>
|
|
447
|
+
<div class="flex items-center gap-3">
|
|
448
|
+
<UiCheckbox id="select-all" name="select-all" v-model="checked" />
|
|
449
|
+
<label for="select-all" class="body-14-medium">
|
|
450
|
+
Select all
|
|
451
|
+
</label>
|
|
452
|
+
</div>
|
|
453
|
+
</template>`;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Indeterminate (mixed) state, typically used for "select all" controls whose
|
|
457
|
+
* children are only partially selected. It exposes `aria-checked="mixed"`.
|
|
458
|
+
*/
|
|
459
|
+
export const Indeterminate: Story = {
|
|
460
|
+
render: () => ({
|
|
461
|
+
components: { UiCheckbox },
|
|
462
|
+
setup() {
|
|
463
|
+
const checked = ref<'indeterminate' | boolean>('indeterminate');
|
|
464
|
+
return { checked };
|
|
465
|
+
},
|
|
466
|
+
template: `<div class="flex items-center gap-3">
|
|
467
|
+
<UiCheckbox id="select-all" name="select-all" v-model="checked" />
|
|
468
|
+
<label for="select-all" class="body-14-medium">
|
|
469
|
+
Select all
|
|
470
|
+
</label>
|
|
471
|
+
</div>`,
|
|
472
|
+
}),
|
|
473
|
+
parameters: {
|
|
474
|
+
docs: {
|
|
475
|
+
source: {
|
|
476
|
+
code: indeterminateTemplateSource,
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
play: async ({ canvasElement, step }) => {
|
|
481
|
+
// Scenario (UiCheckbox): the mixed selection state is announced to assistive tech via
|
|
482
|
+
// aria-checked="mixed".
|
|
483
|
+
const canvas = within(canvasElement);
|
|
484
|
+
const checkbox = canvas.getByRole('checkbox', { name: 'Select all' });
|
|
485
|
+
|
|
486
|
+
await step(
|
|
487
|
+
'screen-reader: announces the mixed state via aria-checked (WCAG 4.1.2)',
|
|
488
|
+
async () => {
|
|
489
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'mixed');
|
|
490
|
+
},
|
|
491
|
+
);
|
|
492
|
+
},
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* `UiCheckbox` is keyboard operable: `Tab` moves focus to it and `Space`
|
|
497
|
+
* toggles the checked state. Hidden test-only story.
|
|
498
|
+
*/
|
|
499
|
+
export const KeyboardNavigation: Story = {
|
|
500
|
+
name: 'test - Keyboard Navigation',
|
|
501
|
+
tags: ['!dev', '!autodocs'],
|
|
502
|
+
render: () => ({
|
|
503
|
+
components: { UiCheckbox },
|
|
504
|
+
setup() {
|
|
505
|
+
const checked = ref(false);
|
|
506
|
+
return { checked, onUpdate };
|
|
507
|
+
},
|
|
508
|
+
template: `<div class="flex items-center gap-3">
|
|
509
|
+
<UiCheckbox id="subscribe" name="subscribe" v-model="checked" @update:model-value="onUpdate" />
|
|
510
|
+
<label for="subscribe" class="body-14-medium">
|
|
511
|
+
Subscribe to updates
|
|
512
|
+
</label>
|
|
513
|
+
</div>`,
|
|
514
|
+
}),
|
|
515
|
+
parameters: {
|
|
516
|
+
// Focus moves during the play function; skip the visual snapshot so the
|
|
517
|
+
// focus ring doesn't register as a Chromatic diff.
|
|
518
|
+
chromatic: { disableSnapshot: true },
|
|
519
|
+
docs: {
|
|
520
|
+
description: {
|
|
521
|
+
story:
|
|
522
|
+
'Press `Tab` to focus the checkbox, then `Space` to toggle it on and off.',
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
play: async ({ canvasElement, step }) => {
|
|
527
|
+
// Scenario (UiCheckbox): a keyboard user tabs to the checkbox and toggles it with Space,
|
|
528
|
+
// which flips aria-checked and emits update:modelValue.
|
|
529
|
+
onUpdate.mockClear();
|
|
530
|
+
const canvas = within(canvasElement);
|
|
531
|
+
const checkbox = canvas.getByRole('checkbox', {
|
|
532
|
+
name: 'Subscribe to updates',
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
await step(
|
|
536
|
+
'keyboard: checkbox is reachable via Tab (WCAG 2.1.1)',
|
|
537
|
+
async () => {
|
|
538
|
+
await userEvent.tab();
|
|
539
|
+
await expect(checkbox).toHaveFocus();
|
|
540
|
+
},
|
|
541
|
+
);
|
|
542
|
+
|
|
543
|
+
await step(
|
|
544
|
+
'keyboard: Space toggles the checked state (WCAG 2.1.1)',
|
|
545
|
+
async () => {
|
|
546
|
+
await userEvent.keyboard(' ');
|
|
547
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'true');
|
|
548
|
+
await expect(onUpdate).toHaveBeenCalledWith(true);
|
|
549
|
+
},
|
|
550
|
+
);
|
|
551
|
+
},
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
const mobileBreakpointTemplateSource = `<script setup lang="ts">
|
|
555
|
+
import { ref } from 'vue'
|
|
556
|
+
import { UiCheckbox } from '@aleph-alpha/ui-library'
|
|
557
|
+
|
|
558
|
+
const checked = ref(false)
|
|
559
|
+
</script>
|
|
560
|
+
|
|
561
|
+
<template>
|
|
562
|
+
<div class="flex items-center gap-3">
|
|
563
|
+
<UiCheckbox id="mobile-terms" name="terms" v-model="checked" />
|
|
564
|
+
<label for="mobile-terms" class="body-14-medium">
|
|
565
|
+
Accept terms and conditions
|
|
566
|
+
</label>
|
|
567
|
+
</div>
|
|
568
|
+
</template>`;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
572
|
+
* toolbar. Stays operable, keyboard navigable, and remains sized for touch.
|
|
573
|
+
* Hidden test-only story.
|
|
574
|
+
*/
|
|
575
|
+
export const MobileBreakpoint: Story = {
|
|
576
|
+
name: 'test - Mobile Breakpoint',
|
|
577
|
+
tags: ['!dev', '!autodocs'],
|
|
578
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
579
|
+
render: () => ({
|
|
580
|
+
components: { UiCheckbox },
|
|
581
|
+
setup() {
|
|
582
|
+
const checked = ref(false);
|
|
583
|
+
return { checked, onUpdate };
|
|
584
|
+
},
|
|
585
|
+
template: `<div class="flex items-center gap-3">
|
|
586
|
+
<UiCheckbox id="mobile-terms" name="terms" v-model="checked" @update:model-value="onUpdate" />
|
|
587
|
+
<label for="mobile-terms" class="body-14-medium">
|
|
588
|
+
Accept terms and conditions
|
|
589
|
+
</label>
|
|
590
|
+
</div>`,
|
|
591
|
+
}),
|
|
592
|
+
parameters: {
|
|
593
|
+
// Focus moves and state toggles during the play function; skip the snapshot.
|
|
594
|
+
chromatic: { disableSnapshot: true },
|
|
595
|
+
docs: {
|
|
596
|
+
description: {
|
|
597
|
+
story:
|
|
598
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
599
|
+
},
|
|
600
|
+
source: { code: mobileBreakpointTemplateSource },
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
play: async ({ canvasElement, step }) => {
|
|
604
|
+
// Scenario (UiCheckbox): at the 320px mobile breakpoint the checkbox stays labelled,
|
|
605
|
+
// keyboard operable, and visible.
|
|
606
|
+
onUpdate.mockClear();
|
|
607
|
+
const canvas = within(canvasElement);
|
|
608
|
+
const checkbox = canvas.getByRole('checkbox', {
|
|
609
|
+
name: 'Accept terms and conditions',
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
await step(
|
|
613
|
+
'mobile: exposes a labelled, unchecked checkbox at the 320px breakpoint (WCAG 4.1.2)',
|
|
614
|
+
async () => {
|
|
615
|
+
await expect(checkbox).toBeVisible();
|
|
616
|
+
await expect(checkbox).toHaveAccessibleName(
|
|
617
|
+
'Accept terms and conditions',
|
|
618
|
+
);
|
|
619
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'false');
|
|
620
|
+
},
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
await step(
|
|
624
|
+
'mobile: stays keyboard operable — Tab focuses and Space toggles (WCAG 2.1.1)',
|
|
625
|
+
async () => {
|
|
626
|
+
await userEvent.tab();
|
|
627
|
+
await expect(checkbox).toHaveFocus();
|
|
628
|
+
await userEvent.keyboard(' ');
|
|
629
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'true');
|
|
630
|
+
await expect(onUpdate).toHaveBeenCalledWith(true);
|
|
631
|
+
},
|
|
632
|
+
);
|
|
633
|
+
|
|
634
|
+
await step(
|
|
635
|
+
'mobile: the checkbox control stays visible and rendered at the mobile breakpoint',
|
|
636
|
+
async () => {
|
|
637
|
+
await expect(checkbox).toBeVisible();
|
|
638
|
+
const { width, height } = checkbox.getBoundingClientRect();
|
|
639
|
+
await expect(width).toBeGreaterThan(0);
|
|
640
|
+
await expect(height).toBeGreaterThan(0);
|
|
641
|
+
},
|
|
642
|
+
);
|
|
643
|
+
},
|
|
644
|
+
};
|
|
@@ -4,26 +4,11 @@ import { describe, expect, test } from 'vitest';
|
|
|
4
4
|
import UiCheckbox from '../UiCheckbox.vue';
|
|
5
5
|
|
|
6
6
|
describe('UiCheckbox', () => {
|
|
7
|
-
|
|
7
|
+
// v-model wiring (the wrapper's own integration work) is unit-tested here.
|
|
8
|
+
test('emits update:modelValue on click', async () => {
|
|
8
9
|
const { getByRole, emitted } = render(UiCheckbox);
|
|
9
|
-
const checkbox = getByRole('checkbox');
|
|
10
|
-
expect(checkbox).toBeEnabled();
|
|
11
10
|
|
|
12
|
-
await userEvent.click(checkbox);
|
|
11
|
+
await userEvent.click(getByRole('checkbox'));
|
|
13
12
|
expect(emitted('update:modelValue')?.[0][0]).toBe(true);
|
|
14
13
|
});
|
|
15
|
-
|
|
16
|
-
test('renders disabled when disabled prop is true', () => {
|
|
17
|
-
const { getByRole } = render(UiCheckbox, {
|
|
18
|
-
props: { disabled: true },
|
|
19
|
-
});
|
|
20
|
-
expect(getByRole('checkbox')).toBeDisabled();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('renders indeterminate state with aria-checked="mixed"', () => {
|
|
24
|
-
const { getByRole } = render(UiCheckbox, {
|
|
25
|
-
props: { modelValue: 'indeterminate' },
|
|
26
|
-
});
|
|
27
|
-
expect(getByRole('checkbox')).toHaveAttribute('aria-checked', 'mixed');
|
|
28
|
-
});
|
|
29
14
|
});
|
|
@@ -136,7 +136,7 @@ const removableChipClass = computed(() =>
|
|
|
136
136
|
<button
|
|
137
137
|
data-slot="chip-remove"
|
|
138
138
|
type="button"
|
|
139
|
-
class="inline-flex size-5 items-center justify-center rounded-full outline-none hover-layer hover-layer-default
|
|
139
|
+
class="inline-flex size-5 items-center justify-center rounded-full outline-none hover-layer hover-layer-default ui-focus-ring disabled:pointer-events-none"
|
|
140
140
|
:aria-label="props.removeLabel"
|
|
141
141
|
:disabled="props.disabled"
|
|
142
142
|
@click="removeChip"
|
|
@@ -258,7 +258,7 @@ import {
|
|
|
258
258
|
|
|
259
259
|
<template>
|
|
260
260
|
<div class="gap-y-4">
|
|
261
|
-
<p class="body-14-regular text-muted
|
|
261
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
262
262
|
Non-modal drawer: you can still interact with the page while it is open.
|
|
263
263
|
</p>
|
|
264
264
|
<UiDrawer :modal="false">
|
|
@@ -304,7 +304,7 @@ export const NonModal: Story = {
|
|
|
304
304
|
},
|
|
305
305
|
template: `
|
|
306
306
|
<div class="gap-y-4">
|
|
307
|
-
<p class="body-14-regular text-muted
|
|
307
|
+
<p class="body-14-regular text-content-on-surface-muted">
|
|
308
308
|
Non-modal drawer: you can still interact with the page while it is open.
|
|
309
309
|
</p>
|
|
310
310
|
<UiDrawer :modal="false">
|
|
@@ -1057,9 +1057,9 @@ const open = ref(false)
|
|
|
1057
1057
|
</UiAvatar>
|
|
1058
1058
|
<div class="flex flex-col items-start overflow-hidden">
|
|
1059
1059
|
<span class="truncate label-14-medium">Sofia Davis</span>
|
|
1060
|
-
<span class="truncate label-12-regular text-muted
|
|
1060
|
+
<span class="truncate label-12-regular text-content-on-surface-muted font-normal">sofia@example.com</span>
|
|
1061
1061
|
</div>
|
|
1062
|
-
<UiIcon name="chevrons-up-down" :size="16" class="shrink-0 text-muted
|
|
1062
|
+
<UiIcon name="chevrons-up-down" :size="16" class="shrink-0 text-content-on-surface-muted" />
|
|
1063
1063
|
</UiButton>
|
|
1064
1064
|
</UiDropdownMenuTrigger>
|
|
1065
1065
|
<UiDropdownMenuContent class="w-56" align="start">
|
|
@@ -1115,9 +1115,9 @@ export const WithAvatarTrigger: Story = {
|
|
|
1115
1115
|
</UiAvatar>
|
|
1116
1116
|
<div class="flex flex-col items-start overflow-hidden">
|
|
1117
1117
|
<span class="truncate label-14-medium">Sofia Davis</span>
|
|
1118
|
-
<span class="truncate label-12-regular text-muted
|
|
1118
|
+
<span class="truncate label-12-regular text-content-on-surface-muted font-normal">sofia@example.com</span>
|
|
1119
1119
|
</div>
|
|
1120
|
-
<UiIcon name="chevrons-up-down" :size="16" class="shrink-0 text-muted
|
|
1120
|
+
<UiIcon name="chevrons-up-down" :size="16" class="shrink-0 text-content-on-surface-muted" />
|
|
1121
1121
|
</UiButton>
|
|
1122
1122
|
</UiDropdownMenuTrigger>
|
|
1123
1123
|
<UiDropdownMenuContent class="w-56" align="start">
|
|
@@ -15,7 +15,7 @@ const props = withDefaults(defineProps<UiEmptyProps>(), {
|
|
|
15
15
|
|
|
16
16
|
<template>
|
|
17
17
|
<div class="flex flex-col items-center justify-center py-12 text-center">
|
|
18
|
-
<div class="mb-4 text-muted
|
|
18
|
+
<div class="mb-4 text-content-on-surface-muted" aria-hidden="true">
|
|
19
19
|
<component :is="props.icon" v-if="props.icon" class="size-12" />
|
|
20
20
|
<UiIcon v-else name="inbox" :size="48" />
|
|
21
21
|
</div>
|
|
@@ -26,7 +26,7 @@ const props = withDefaults(defineProps<UiEmptyProps>(), {
|
|
|
26
26
|
|
|
27
27
|
<p
|
|
28
28
|
v-if="props.description"
|
|
29
|
-
class="body-14-regular max-w-sm text-muted
|
|
29
|
+
class="body-14-regular max-w-sm text-content-on-surface-muted"
|
|
30
30
|
>
|
|
31
31
|
{{ props.description }}
|
|
32
32
|
</p>
|