@aleph-alpha/ui-library 6.3.3 → 6.3.4
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/UiFileUploadBox/types.d.ts +8 -5
- package/dist/system/components/UiStepper/context.d.ts +8 -0
- package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +14776 -14598
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +217 -5
- package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +227 -0
- package/dist/system/story-sidebar-icons.json +7 -0
- package/package.json +1 -1
- 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/UiDropdownMenuTrigger.vue +3 -1
- 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 +1017 -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/core/calendar/Calendar.vue +234 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
- 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/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/UiTopBar/UiTopBar.stories.ts +245 -36
- package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
- package/src/patterns/UiTopBar/accessory-dropdown.ts +97 -0
|
@@ -89,6 +89,13 @@ const rangeValue = computed((): DateRange | undefined => {
|
|
|
89
89
|
: undefined;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
+
// Open the popover calendar on the month of the current selection. Without
|
|
93
|
+
// this the calendar defaults to today's month even when a date is already
|
|
94
|
+
// chosen, because the placeholder is not derived from the value.
|
|
95
|
+
const calendarPlaceholder = computed(() =>
|
|
96
|
+
props.mode === 'range' ? rangeValue.value?.start : singleValue.value,
|
|
97
|
+
);
|
|
98
|
+
|
|
92
99
|
const dateFormatter = computed(
|
|
93
100
|
() => new DateFormatter(props.locale, props.dateFormat),
|
|
94
101
|
);
|
|
@@ -171,6 +178,7 @@ const handleRangeDateUpdate = (value: DateRange | undefined) => {
|
|
|
171
178
|
<UiCalendar
|
|
172
179
|
v-if="props.mode === 'single'"
|
|
173
180
|
:model-value="singleValue"
|
|
181
|
+
:default-placeholder="calendarPlaceholder"
|
|
174
182
|
:min-value="props.minValue"
|
|
175
183
|
:max-value="props.maxValue"
|
|
176
184
|
:disabled="props.disabled"
|
|
@@ -192,6 +200,7 @@ const handleRangeDateUpdate = (value: DateRange | undefined) => {
|
|
|
192
200
|
<UiRangeCalendar
|
|
193
201
|
v-else
|
|
194
202
|
:model-value="rangeValue"
|
|
203
|
+
:default-placeholder="calendarPlaceholder"
|
|
195
204
|
:min-value="props.minValue"
|
|
196
205
|
:max-value="props.maxValue"
|
|
197
206
|
:disabled="props.disabled"
|
|
@@ -5,20 +5,25 @@ import type { DateRange } from 'reka-ui';
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
import UiDatePicker from '../UiDatePicker.vue';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// Day cell triggers expose role="button" but are not necessarily native
|
|
9
|
+
// <button> elements (that would break the grid's roving tabindex), so query
|
|
10
|
+
// them via their data-slot — single and range calendars use different slots.
|
|
11
|
+
const DAY_TRIGGER_SELECTOR =
|
|
12
|
+
'[data-slot="calendar-cell-trigger"], [data-slot="range-calendar-trigger"]';
|
|
13
|
+
|
|
14
|
+
function getEnabledDateButton(cells: HTMLElement[], index = 0): HTMLElement {
|
|
12
15
|
const enabledCells = cells.filter(
|
|
13
|
-
(cell) =>
|
|
16
|
+
(cell) =>
|
|
17
|
+
!cell.querySelector(DAY_TRIGGER_SELECTOR)?.hasAttribute('data-disabled'),
|
|
14
18
|
);
|
|
15
|
-
const
|
|
19
|
+
const dayTrigger =
|
|
20
|
+
enabledCells[index]?.querySelector<HTMLElement>(DAY_TRIGGER_SELECTOR);
|
|
16
21
|
|
|
17
|
-
if (!
|
|
22
|
+
if (!dayTrigger) {
|
|
18
23
|
throw new Error(`Expected enabled date button at index ${index}`);
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
return
|
|
26
|
+
return dayTrigger;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
describe('UiDatePicker', () => {
|
|
@@ -68,8 +68,12 @@ const meta: Meta<typeof UiFileItem> = {
|
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
70
|
decorators: [
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// The Accessibility story renders Default/Accessible panels side by side,
|
|
72
|
+
// so it needs more room than the single-row stories.
|
|
73
|
+
(story, context) => ({
|
|
74
|
+
template: `<div class="p-4 ${
|
|
75
|
+
context.name === 'Accessibility' ? 'max-w-3xl' : 'max-w-md'
|
|
76
|
+
}"><story /></div>`,
|
|
73
77
|
}),
|
|
74
78
|
],
|
|
75
79
|
};
|
|
@@ -672,23 +676,25 @@ export const Accessibility: Story = {
|
|
|
672
676
|
</div>
|
|
673
677
|
</div>
|
|
674
678
|
|
|
675
|
-
<div class="
|
|
676
|
-
<
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
<
|
|
681
|
-
|
|
679
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
680
|
+
<div class="flex flex-col gap-3">
|
|
681
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
682
|
+
Default
|
|
683
|
+
</h3>
|
|
684
|
+
<div class="flex flex-col gap-3 border border-border-surface-default p-4">
|
|
685
|
+
<UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
|
|
686
|
+
<UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
|
|
687
|
+
</div>
|
|
682
688
|
</div>
|
|
683
|
-
</div>
|
|
684
689
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
691
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
692
|
+
Accessible
|
|
693
|
+
</h3>
|
|
694
|
+
<div class="flex flex-col gap-3 border border-border-surface-default p-4">
|
|
695
|
+
<UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
|
|
696
|
+
<UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
|
|
697
|
+
</div>
|
|
692
698
|
</div>
|
|
693
699
|
</div>
|
|
694
700
|
</section>
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
expect,
|
|
5
|
+
fireEvent,
|
|
6
|
+
fn,
|
|
7
|
+
userEvent,
|
|
8
|
+
waitFor,
|
|
9
|
+
within,
|
|
10
|
+
} from 'storybook/test';
|
|
4
11
|
import { onBeforeUnmount, ref } from 'vue';
|
|
5
12
|
import { UiButton } from '@/components/UiButton';
|
|
6
13
|
import {
|
|
@@ -20,8 +27,12 @@ const meta: Meta<typeof UiFileUpload> = {
|
|
|
20
27
|
component: UiFileUpload,
|
|
21
28
|
tags: ['autodocs'],
|
|
22
29
|
decorators: [
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
// The Accessibility story renders Default/Accessible panels side by side,
|
|
31
|
+
// so it needs more room than the single-uploader stories.
|
|
32
|
+
(story, context) => ({
|
|
33
|
+
template: `<div class="w-full p-4 ${
|
|
34
|
+
context.name === 'Accessibility' ? 'max-w-3xl' : 'max-w-lg'
|
|
35
|
+
}"><story /></div>`,
|
|
25
36
|
}),
|
|
26
37
|
],
|
|
27
38
|
args: {
|
|
@@ -33,7 +44,6 @@ const meta: Meta<typeof UiFileUpload> = {
|
|
|
33
44
|
maxSizeLabel: '',
|
|
34
45
|
dropLabel: 'Drop files here',
|
|
35
46
|
chooseLabel: 'Choose files',
|
|
36
|
-
ariaLabel: 'File upload',
|
|
37
47
|
},
|
|
38
48
|
argTypes: {
|
|
39
49
|
accept: { control: 'text' },
|
|
@@ -750,12 +760,11 @@ export const Disabled: Story = {
|
|
|
750
760
|
),
|
|
751
761
|
};
|
|
752
762
|
|
|
753
|
-
/** Custom title
|
|
763
|
+
/** Custom title and button label; the drop zone's accessible name follows the visible text. */
|
|
754
764
|
export const CustomLabels: Story = {
|
|
755
765
|
args: {
|
|
756
766
|
dropLabel: 'Add attachments',
|
|
757
767
|
chooseLabel: 'Browse...',
|
|
758
|
-
ariaLabel: 'Attachment upload',
|
|
759
768
|
accept: '.zip,.tar,.gz',
|
|
760
769
|
supportedTypesLabel: 'Archives: ZIP, TAR, GZ',
|
|
761
770
|
},
|
|
@@ -763,18 +772,53 @@ export const CustomLabels: Story = {
|
|
|
763
772
|
parameters: docsSource(
|
|
764
773
|
dialogDocsCode(`drop-label="Add attachments"
|
|
765
774
|
choose-label="Browse..."
|
|
766
|
-
aria-label="Attachment upload"
|
|
767
775
|
accept=".zip,.tar,.gz"
|
|
768
776
|
supported-types-label="Archives: ZIP, TAR, GZ"`),
|
|
769
777
|
),
|
|
770
778
|
};
|
|
771
779
|
|
|
772
780
|
/**
|
|
773
|
-
*
|
|
781
|
+
* Drag-over state: while files are dragged over the drop zone, its border, icon,
|
|
782
|
+
* and title change together so the state does not rely on colour alone.
|
|
783
|
+
* Rendered without the dialog, since the state only exists mid-gesture.
|
|
784
|
+
*/
|
|
785
|
+
export const DragOver: Story = {
|
|
786
|
+
render: (args) => renderBareUpload(args),
|
|
787
|
+
parameters: docsSource(`<UiFileUpload accept=".pdf,.docx,.txt" />`),
|
|
788
|
+
play: async ({ canvasElement, step }) => {
|
|
789
|
+
const canvas = within(canvasElement);
|
|
790
|
+
const zone = canvas.getByRole('button', { name: /Drop files here/ });
|
|
791
|
+
|
|
792
|
+
await step(
|
|
793
|
+
'interaction: dragging files over the drop zone shows the drag-over state',
|
|
794
|
+
async () => {
|
|
795
|
+
await fireEvent.dragEnter(canvas.getByText('Choose files'));
|
|
796
|
+
await expect(zone).toHaveAttribute('data-dragging', 'true');
|
|
797
|
+
},
|
|
798
|
+
);
|
|
799
|
+
|
|
800
|
+
await step(
|
|
801
|
+
'interaction: leaving the drop zone clears the drag-over state',
|
|
802
|
+
async () => {
|
|
803
|
+
await fireEvent.dragLeave(canvas.getByText('Choose files'));
|
|
804
|
+
await expect(zone).not.toHaveAttribute('data-dragging');
|
|
805
|
+
},
|
|
806
|
+
);
|
|
807
|
+
|
|
808
|
+
// Re-enter so the snapshot captures the drag-over state.
|
|
809
|
+
await fireEvent.dragEnter(zone);
|
|
810
|
+
},
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Accessibility guidance for the uploader: an interactive drop zone at rest,
|
|
815
|
+
* drag-over shown beyond colour, progress/success/error distinguishable by
|
|
816
|
+
* icon and text, legible in-row error text, comfortable remove/menu targets,
|
|
817
|
+
* and visible focus — shown side by side in the default and accessible themes.
|
|
774
818
|
*/
|
|
775
819
|
export const Accessibility: Story = {
|
|
776
820
|
render: () => ({
|
|
777
|
-
components: { UiFileItem
|
|
821
|
+
components: { UiFileItem },
|
|
778
822
|
template: `
|
|
779
823
|
<section class="flex flex-col gap-6 p-4">
|
|
780
824
|
<div>
|
|
@@ -786,71 +830,73 @@ export const Accessibility: Story = {
|
|
|
786
830
|
<div class="flex flex-col gap-6">
|
|
787
831
|
<div class="flex flex-col gap-2">
|
|
788
832
|
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
789
|
-
|
|
833
|
+
Requirements
|
|
790
834
|
</h3>
|
|
791
|
-
<
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
835
|
+
<ul class="body-16-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
|
|
836
|
+
<li>
|
|
837
|
+
The drop zone reads as an interactive target at rest, not only
|
|
838
|
+
while a file is dragged over it
|
|
839
|
+
</li>
|
|
840
|
+
<li>
|
|
841
|
+
Drag over is shown by border and fill together, so the change
|
|
842
|
+
survives without colour
|
|
843
|
+
</li>
|
|
844
|
+
<li>
|
|
845
|
+
Progress, success and error are each distinguishable by icon
|
|
846
|
+
and text, never by colour alone
|
|
847
|
+
</li>
|
|
848
|
+
<li>
|
|
849
|
+
Error text sits in the row it belongs to and stays legible at
|
|
850
|
+
the small size
|
|
851
|
+
</li>
|
|
852
|
+
<li>
|
|
853
|
+
Remove and menu controls stay comfortable targets for touch as
|
|
854
|
+
well as pointer
|
|
855
|
+
</li>
|
|
856
|
+
<li>
|
|
857
|
+
Focus is clearly visible on the picker, on each file row and on
|
|
858
|
+
its controls
|
|
859
|
+
</li>
|
|
860
|
+
</ul>
|
|
803
861
|
</div>
|
|
804
862
|
|
|
805
863
|
<div class="flex flex-col gap-2">
|
|
806
864
|
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
807
|
-
|
|
865
|
+
Enable accessibility theme
|
|
808
866
|
</h3>
|
|
809
867
|
<p class="body-16-regular text-content-on-surface-primary">
|
|
810
|
-
|
|
868
|
+
When accessibility is required, enable our accessibility theme.
|
|
869
|
+
This increases contrast and ensures there are no color contrast
|
|
870
|
+
issues.
|
|
811
871
|
</p>
|
|
812
872
|
</div>
|
|
813
873
|
</div>
|
|
814
874
|
|
|
815
|
-
<div class="
|
|
816
|
-
<
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
<
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
filename="Quarterly report.csv"
|
|
828
|
-
type-label="CSV"
|
|
829
|
-
size-label="320 KB"
|
|
830
|
-
remove-label="Remove Quarterly report.csv"
|
|
831
|
-
/>
|
|
832
|
-
<UiFileItem filename="Archive.zip" error="Unsupported file type" remove-label="Dismiss Archive.zip" />
|
|
875
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
876
|
+
<div class="flex flex-col gap-3">
|
|
877
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
878
|
+
Default
|
|
879
|
+
</h3>
|
|
880
|
+
<div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
|
|
881
|
+
<UiFileItem
|
|
882
|
+
filename="Filename"
|
|
883
|
+
error="Upload failed"
|
|
884
|
+
remove-label="Remove Filename"
|
|
885
|
+
/>
|
|
886
|
+
</div>
|
|
833
887
|
</div>
|
|
834
|
-
</div>
|
|
835
888
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
<UiFileItem
|
|
848
|
-
filename="Quarterly report.csv"
|
|
849
|
-
type-label="CSV"
|
|
850
|
-
size-label="320 KB"
|
|
851
|
-
remove-label="Remove Quarterly report.csv"
|
|
852
|
-
/>
|
|
853
|
-
<UiFileItem filename="Archive.zip" error="Unsupported file type" remove-label="Dismiss Archive.zip" />
|
|
889
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
890
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
891
|
+
Accessible
|
|
892
|
+
</h3>
|
|
893
|
+
<div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
|
|
894
|
+
<UiFileItem
|
|
895
|
+
filename="Filename"
|
|
896
|
+
error="Upload failed"
|
|
897
|
+
remove-label="Remove Filename"
|
|
898
|
+
/>
|
|
899
|
+
</div>
|
|
854
900
|
</div>
|
|
855
901
|
</div>
|
|
856
902
|
</section>
|
|
@@ -876,11 +922,12 @@ export const Accessibility: Story = {
|
|
|
876
922
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
877
923
|
* How these tests are built and reported:
|
|
878
924
|
*
|
|
879
|
-
* -
|
|
925
|
+
* - The visible stories above render the uploader inside a *closed* dialog, so
|
|
880
926
|
* there is nothing to assert until the dialog opens — which would invalidate
|
|
881
|
-
* its Chromatic snapshot.
|
|
882
|
-
*
|
|
883
|
-
*
|
|
927
|
+
* its Chromatic snapshot. Coverage therefore lives in the hidden `test - …`
|
|
928
|
+
* stories below, which render the uploader directly; the dialog composition
|
|
929
|
+
* itself is covered by `test - Dialog Integration`. `DragOver` is the
|
|
930
|
+
* exception: it renders bare and asserts its own state.
|
|
884
931
|
* - Assertions are grouped into category-labelled `step()` calls, which are
|
|
885
932
|
* parsed statically into the per-story CI summary. Between them these stories
|
|
886
933
|
* cover every report column:
|
|
@@ -925,7 +972,7 @@ function renderBareUpload(args: Story['args']) {
|
|
|
925
972
|
}
|
|
926
973
|
|
|
927
974
|
/**
|
|
928
|
-
* The drop zone
|
|
975
|
+
* The whole drop zone is one button that opens the file picker, from pointer and
|
|
929
976
|
* from keyboard. Hidden test-only story.
|
|
930
977
|
*/
|
|
931
978
|
export const KeyboardNavigation: Story = {
|
|
@@ -950,13 +997,12 @@ export const KeyboardNavigation: Story = {
|
|
|
950
997
|
},
|
|
951
998
|
render: (args) => renderBareUpload(args),
|
|
952
999
|
play: async ({ canvasElement, step }) => {
|
|
953
|
-
// Scenario (UiFileUpload): a keyboard-only user reaches the drop zone
|
|
954
|
-
// the picker with either activation key
|
|
955
|
-
//
|
|
1000
|
+
// Scenario (UiFileUpload): a keyboard-only user reaches the drop zone and
|
|
1001
|
+
// opens the picker with either activation key — so the uploader never
|
|
1002
|
+
// depends on drag-and-drop.
|
|
956
1003
|
onPickerOpen.mockClear();
|
|
957
1004
|
const canvas = within(canvasElement);
|
|
958
|
-
const zone = canvas.getByRole('button', { name:
|
|
959
|
-
const choose = canvas.getByRole('button', { name: 'Choose files' });
|
|
1005
|
+
const zone = canvas.getByRole('button', { name: /Drop files here/ });
|
|
960
1006
|
|
|
961
1007
|
await step(
|
|
962
1008
|
'keyboard: the drop zone is the first tab stop (WCAG 2.1.1)',
|
|
@@ -977,20 +1023,18 @@ export const KeyboardNavigation: Story = {
|
|
|
977
1023
|
});
|
|
978
1024
|
|
|
979
1025
|
await step(
|
|
980
|
-
'keyboard: the
|
|
1026
|
+
'keyboard: the drop zone is the only tab stop (WCAG 2.4.3)',
|
|
981
1027
|
async () => {
|
|
982
1028
|
await userEvent.tab();
|
|
983
|
-
await expect(
|
|
984
|
-
await userEvent.keyboard('{Enter}');
|
|
985
|
-
await expect(onPickerOpen).toHaveBeenCalledTimes(3);
|
|
1029
|
+
await expect(zone).not.toHaveFocus();
|
|
986
1030
|
},
|
|
987
1031
|
);
|
|
988
1032
|
|
|
989
1033
|
await step(
|
|
990
|
-
'interaction: clicking the drop zone opens the picker
|
|
1034
|
+
'interaction: clicking anywhere in the drop zone opens the picker',
|
|
991
1035
|
async () => {
|
|
992
|
-
await userEvent.click(
|
|
993
|
-
await expect(onPickerOpen).toHaveBeenCalledTimes(
|
|
1036
|
+
await userEvent.click(canvas.getByText('Choose files'));
|
|
1037
|
+
await expect(onPickerOpen).toHaveBeenCalledTimes(3);
|
|
994
1038
|
},
|
|
995
1039
|
);
|
|
996
1040
|
},
|
|
@@ -1025,7 +1069,7 @@ export const DisabledGuards: Story = {
|
|
|
1025
1069
|
// operable to any input method — no tab stop, no click-through to the picker.
|
|
1026
1070
|
onPickerOpen.mockClear();
|
|
1027
1071
|
const canvas = within(canvasElement);
|
|
1028
|
-
const zone = canvas.getByRole('button', { name:
|
|
1072
|
+
const zone = canvas.getByRole('button', { name: /Drop files here/ });
|
|
1029
1073
|
|
|
1030
1074
|
await step(
|
|
1031
1075
|
'screen-reader: the drop zone reports its disabled state (WCAG 4.1.2)',
|
|
@@ -1047,19 +1091,6 @@ export const DisabledGuards: Story = {
|
|
|
1047
1091
|
await userEvent.click(zone);
|
|
1048
1092
|
await expect(onPickerOpen).not.toHaveBeenCalled();
|
|
1049
1093
|
});
|
|
1050
|
-
|
|
1051
|
-
await step(
|
|
1052
|
-
'interaction: the choose button is disabled and stays silent',
|
|
1053
|
-
async () => {
|
|
1054
|
-
const choose = canvas.getByRole('button', { name: 'Choose files' });
|
|
1055
|
-
await expect(choose).toBeDisabled();
|
|
1056
|
-
// A disabled UiButton sets `pointer-events: none`, which makes
|
|
1057
|
-
// `userEvent.click` throw instead of no-op; bypass the check so the
|
|
1058
|
-
// guard itself is what gets asserted.
|
|
1059
|
-
await userEvent.click(choose, { pointerEventsCheck: 0 });
|
|
1060
|
-
await expect(onPickerOpen).not.toHaveBeenCalled();
|
|
1061
|
-
},
|
|
1062
|
-
);
|
|
1063
1094
|
},
|
|
1064
1095
|
};
|
|
1065
1096
|
|
|
@@ -1072,7 +1103,6 @@ export const ScreenReader: Story = {
|
|
|
1072
1103
|
name: 'test - Screen Reader',
|
|
1073
1104
|
tags: ['!dev', '!autodocs'],
|
|
1074
1105
|
args: {
|
|
1075
|
-
ariaLabel: 'Attachment upload',
|
|
1076
1106
|
dropLabel: 'Drop files here',
|
|
1077
1107
|
chooseLabel: 'Choose files',
|
|
1078
1108
|
accept: '.pdf,.csv',
|
|
@@ -1092,16 +1122,16 @@ export const ScreenReader: Story = {
|
|
|
1092
1122
|
render: (args) => renderBareUpload(args),
|
|
1093
1123
|
play: async ({ canvasElement, step }) => {
|
|
1094
1124
|
// Scenario (UiFileUpload): assistive tech finds one named button for the drop
|
|
1095
|
-
// zone
|
|
1096
|
-
//
|
|
1125
|
+
// zone, is not told about the cloud illustration or the hidden input, and can
|
|
1126
|
+
// still read the accept/size hints.
|
|
1097
1127
|
const canvas = within(canvasElement);
|
|
1098
1128
|
|
|
1099
1129
|
await step(
|
|
1100
|
-
'screen-reader: the drop zone
|
|
1130
|
+
'screen-reader: the drop zone is one button named by its visible text (WCAG 4.1.2, 2.5.3)',
|
|
1101
1131
|
async () => {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1132
|
+
await expect(canvas.getByRole('button')).toHaveAccessibleName(
|
|
1133
|
+
'Drop files here Choose files',
|
|
1134
|
+
);
|
|
1105
1135
|
},
|
|
1106
1136
|
);
|
|
1107
1137
|
|
|
@@ -1122,8 +1152,8 @@ export const ScreenReader: Story = {
|
|
|
1122
1152
|
await expect(input).toHaveAttribute('aria-hidden', 'true');
|
|
1123
1153
|
await expect(input).toHaveAttribute('tabindex', '-1');
|
|
1124
1154
|
// The cloud illustration sits inside the drop zone, so it must be hidden
|
|
1125
|
-
//
|
|
1126
|
-
const zone = canvas.getByRole('button'
|
|
1155
|
+
// from assistive tech.
|
|
1156
|
+
const zone = canvas.getByRole('button');
|
|
1127
1157
|
await expect(
|
|
1128
1158
|
zone.querySelector('[aria-hidden="true"]'),
|
|
1129
1159
|
).toBeInTheDocument();
|
|
@@ -1163,7 +1193,7 @@ export const ZoomMagnification: Story = {
|
|
|
1163
1193
|
// drag-and-drop.
|
|
1164
1194
|
onPickerOpen.mockClear();
|
|
1165
1195
|
const canvas = within(canvasElement);
|
|
1166
|
-
const zone = canvas.getByRole('button', { name:
|
|
1196
|
+
const zone = canvas.getByRole('button', { name: /Drop files here/ });
|
|
1167
1197
|
|
|
1168
1198
|
await step(
|
|
1169
1199
|
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
@@ -1187,7 +1217,7 @@ export const ZoomMagnification: Story = {
|
|
|
1187
1217
|
|
|
1188
1218
|
/**
|
|
1189
1219
|
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
1190
|
-
* toolbar. The uploader fits without sideways scrolling and
|
|
1220
|
+
* toolbar. The uploader fits without sideways scrolling and the drop zone stays
|
|
1191
1221
|
* tappable. Hidden test-only story.
|
|
1192
1222
|
*/
|
|
1193
1223
|
export const MobileBreakpoint: Story = {
|
|
@@ -1214,12 +1244,10 @@ export const MobileBreakpoint: Story = {
|
|
|
1214
1244
|
render: (args) => renderBareUpload(args),
|
|
1215
1245
|
play: async ({ canvasElement, step }) => {
|
|
1216
1246
|
// Scenario (UiFileUpload): at 320px the drop zone and its footer reflow into
|
|
1217
|
-
// the narrow column, and
|
|
1218
|
-
// enough to tap.
|
|
1247
|
+
// the narrow column, and the zone stays large enough to tap.
|
|
1219
1248
|
onPickerOpen.mockClear();
|
|
1220
1249
|
const canvas = within(canvasElement);
|
|
1221
|
-
const zone = canvas.getByRole('button', { name:
|
|
1222
|
-
const choose = canvas.getByRole('button', { name: 'Choose files' });
|
|
1250
|
+
const zone = canvas.getByRole('button', { name: /Drop files here/ });
|
|
1223
1251
|
|
|
1224
1252
|
await step(
|
|
1225
1253
|
'mobile: the uploader fits the 320px viewport without sideways scrolling (WCAG 1.4.10 Reflow)',
|
|
@@ -1232,19 +1260,16 @@ export const MobileBreakpoint: Story = {
|
|
|
1232
1260
|
);
|
|
1233
1261
|
|
|
1234
1262
|
await step(
|
|
1235
|
-
'mobile:
|
|
1263
|
+
'mobile: the drop zone meets the minimum touch-target size (WCAG 2.5.8)',
|
|
1236
1264
|
async () => {
|
|
1237
1265
|
const zoneBox = zone.getBoundingClientRect();
|
|
1238
1266
|
await expect(zoneBox.width).toBeGreaterThanOrEqual(24);
|
|
1239
1267
|
await expect(zoneBox.height).toBeGreaterThanOrEqual(24);
|
|
1240
|
-
const chooseBox = choose.getBoundingClientRect();
|
|
1241
|
-
await expect(chooseBox.width).toBeGreaterThanOrEqual(24);
|
|
1242
|
-
await expect(chooseBox.height).toBeGreaterThanOrEqual(24);
|
|
1243
1268
|
},
|
|
1244
1269
|
);
|
|
1245
1270
|
|
|
1246
1271
|
await step('mobile: the picker still opens at 320px', async () => {
|
|
1247
|
-
await userEvent.click(
|
|
1272
|
+
await userEvent.click(zone);
|
|
1248
1273
|
await expect(onPickerOpen).toHaveBeenCalledTimes(1);
|
|
1249
1274
|
});
|
|
1250
1275
|
},
|
|
@@ -1290,7 +1315,7 @@ export const DialogIntegration: Story = {
|
|
|
1290
1315
|
await expect(dialog).toBeVisible();
|
|
1291
1316
|
});
|
|
1292
1317
|
await expect(
|
|
1293
|
-
body.getByRole('button', { name:
|
|
1318
|
+
body.getByRole('button', { name: /Drop files here/ }),
|
|
1294
1319
|
).toBeVisible();
|
|
1295
1320
|
await expect(
|
|
1296
1321
|
body.getByText('Supported file types: PDF, DOCX, TXT'),
|
|
@@ -16,7 +16,7 @@ const props = withDefaults(defineProps<UiFileUploadProps>(), {
|
|
|
16
16
|
maxSizeLabel: '',
|
|
17
17
|
dropLabel: 'Drop files here',
|
|
18
18
|
chooseLabel: 'Choose files',
|
|
19
|
-
ariaLabel:
|
|
19
|
+
ariaLabel: undefined,
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const emit = defineEmits<UiFileUploadBoxEmits>();
|
|
@@ -11,7 +11,7 @@ describe('UiFileUpload', () => {
|
|
|
11
11
|
|
|
12
12
|
test('emits dragenter and drop with DragEvent', async () => {
|
|
13
13
|
const { getByRole, emitted } = render(UiFileUpload);
|
|
14
|
-
const zone = getByRole('button'
|
|
14
|
+
const zone = getByRole('button');
|
|
15
15
|
const file = new File(['x'], 'a.txt', { type: 'text/plain' });
|
|
16
16
|
const files = {
|
|
17
17
|
length: 1,
|
|
@@ -44,7 +44,7 @@ describe('UiFileUpload', () => {
|
|
|
44
44
|
accept: '.txt,text/plain',
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
-
const zone = getByRole('button'
|
|
47
|
+
const zone = getByRole('button');
|
|
48
48
|
const first = new File(['a'], 'a.txt', { type: 'text/plain' });
|
|
49
49
|
const second = new File(['b'], 'b.txt', { type: 'text/plain' });
|
|
50
50
|
const list = [first, second];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
3
3
|
import { renderShell, templateSource } from './layout-shell';
|
|
4
|
+
import { ACCESSORY_TRIGGER_NAME } from '../UiTopBar/accessory-dropdown';
|
|
4
5
|
|
|
5
6
|
const meta = {
|
|
6
7
|
title: 'Patterns/UiLayout/Desktop',
|
|
@@ -82,6 +83,21 @@ export const Default: Story = {
|
|
|
82
83
|
).toBeVisible();
|
|
83
84
|
},
|
|
84
85
|
);
|
|
86
|
+
|
|
87
|
+
await step(
|
|
88
|
+
'screen-reader: the bar carries the accessibility menu, closed and named (WCAG 4.1.2)',
|
|
89
|
+
async () => {
|
|
90
|
+
// What the menu does once opened belongs to the control, so it is
|
|
91
|
+
// tested in `Patterns/UiTopBar`; the shell only shows that it is here.
|
|
92
|
+
const accessory = canvas.getByRole('button', {
|
|
93
|
+
name: ACCESSORY_TRIGGER_NAME,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
await expect(accessory).toBeVisible();
|
|
97
|
+
await expect(accessory).toHaveAttribute('aria-haspopup', 'menu');
|
|
98
|
+
await expect(accessory).toHaveAttribute('aria-expanded', 'false');
|
|
99
|
+
},
|
|
100
|
+
);
|
|
85
101
|
},
|
|
86
102
|
};
|
|
87
103
|
|
|
@@ -262,6 +278,15 @@ export const ZoomMagnification: Story = {
|
|
|
262
278
|
await expect(canvas.getByRole('main')).toBeVisible();
|
|
263
279
|
});
|
|
264
280
|
|
|
281
|
+
await step(
|
|
282
|
+
'zoom: the bar keeps its accessibility menu rather than dropping it (WCAG 1.4.4)',
|
|
283
|
+
async () => {
|
|
284
|
+
await expect(
|
|
285
|
+
canvas.getByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
|
|
286
|
+
).toBeVisible();
|
|
287
|
+
},
|
|
288
|
+
);
|
|
289
|
+
|
|
265
290
|
await step('zoom: the toggle still collapses the navigation', async () => {
|
|
266
291
|
const nav = canvas.getByRole('navigation', { name: 'Main' });
|
|
267
292
|
|