@aleph-alpha/ui-library 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/system/components/UiSlider/step-marks.d.ts +45 -0
- package/dist/system/components/UiSlider/types.d.ts +28 -0
- package/dist/system/components/core/slider/Slider.vue.d.ts +21 -1
- package/dist/system/icons/story-sidebar-icons.json +74 -17
- package/dist/system/lib.js +2026 -1912
- package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +74 -17
- package/package.json +15 -10
- package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
- package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
- package/src/components/UiAlert/UiAlert.guidance.md +66 -0
- package/src/components/UiAlert/UiAlert.stories.ts +167 -143
- package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
- package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
- package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
- package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
- package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
- package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
- package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
- package/src/components/UiBadge/UiBadge.guidance.md +65 -0
- package/src/components/UiBadge/UiBadge.stories.ts +325 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
- package/src/components/UiButton/UiButton.stories.ts +5 -2
- package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
- package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
- package/src/components/UiCard/UiCard.guidance.md +65 -0
- package/src/components/UiCard/UiCard.stories.ts +393 -0
- package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
- package/src/components/UiChip/UiChip.guidance.md +64 -0
- package/src/components/UiChip/UiChip.stories.ts +162 -138
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
- package/src/components/UiDialog/UiDialog.guidance.md +66 -0
- package/src/components/UiDialog/UiDialog.stories.ts +90 -66
- package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
- package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
- package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
- package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
- package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
- package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
- package/src/components/UiField/UiField.guidance.md +63 -0
- package/src/components/UiField/UiField.stories.ts +90 -113
- package/src/components/UiFileType/UiFileType.stories.ts +254 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
- package/src/components/UiIcon/UiIcon.stories.ts +256 -1
- package/src/components/UiInput/UiInput.guidance.md +64 -0
- package/src/components/UiInput/UiInput.stories.ts +132 -80
- package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
- package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
- package/src/components/UiItem/UiItem.guidance.md +66 -0
- package/src/components/UiItem/UiItem.stories.ts +81 -28
- package/src/components/UiKbd/UiKbd.guidance.md +65 -0
- package/src/components/UiKbd/UiKbd.stories.ts +373 -3
- package/src/components/UiLabel/UiLabel.guidance.md +65 -0
- package/src/components/UiLabel/UiLabel.stories.ts +163 -139
- package/src/components/UiListbox/UiListbox.stories.ts +197 -195
- package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
- package/src/components/UiPopover/UiPopover.guidance.md +65 -0
- package/src/components/UiPopover/UiPopover.stories.ts +115 -91
- package/src/components/UiProgress/UiProgress.guidance.md +65 -0
- package/src/components/UiProgress/UiProgress.stories.ts +300 -0
- package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
- package/src/components/UiResizable/UiResizable.guidance.md +65 -0
- package/src/components/UiResizable/UiResizable.stories.ts +176 -152
- package/src/components/UiSelect/UiSelect.guidance.md +66 -0
- package/src/components/UiSelect/UiSelect.stories.ts +150 -126
- package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
- package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
- package/src/components/UiSheet/UiSheet.guidance.md +66 -0
- package/src/components/UiSheet/UiSheet.stories.ts +194 -170
- package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
- package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
- package/src/components/UiSlider/UiSlider.guidance.md +66 -0
- package/src/components/UiSlider/UiSlider.stories.ts +885 -153
- package/src/components/UiSlider/UiSlider.vue +109 -1
- package/src/components/UiSlider/__tests__/UiSliderValueAndSteps.test.ts +210 -0
- package/src/components/UiSlider/__tests__/step-marks.test.ts +94 -0
- package/src/components/UiSlider/step-marks.ts +96 -0
- package/src/components/UiSlider/types.ts +32 -0
- package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
- package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
- package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
- package/src/components/UiStepper/UiStepper.guidance.md +66 -0
- package/src/components/UiStepper/UiStepper.stories.ts +142 -124
- package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
- package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
- package/src/components/UiTable/UiTable.guidance.md +66 -0
- package/src/components/UiTable/UiTable.stories.ts +530 -12
- package/src/components/UiTabs/UiTabs.guidance.md +66 -0
- package/src/components/UiTabs/UiTabs.stories.ts +174 -150
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
- package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
- package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
- package/src/components/UiToggle/UiToggle.guidance.md +66 -0
- package/src/components/UiToggle/UiToggle.stories.ts +183 -159
- package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
- package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
- package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
- package/src/components/core/slider/Slider.vue +16 -6
- package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
- package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
- package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
- package/src/patterns/UiPlaceholder/types.ts +1 -0
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +86 -84
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
|
@@ -3,6 +3,16 @@ import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
|
3
3
|
import UiTooltip from './UiTooltip.vue';
|
|
4
4
|
import { UiButton } from '@/components/UiButton';
|
|
5
5
|
import { UiIcon } from '@/components/UiIcon';
|
|
6
|
+
import {
|
|
7
|
+
accessibilityRequirementsTemplate,
|
|
8
|
+
designNotesStory,
|
|
9
|
+
guidanceLinks,
|
|
10
|
+
guidanceSectionClass,
|
|
11
|
+
parseGuidance,
|
|
12
|
+
} from '../../../.storybook/guidance';
|
|
13
|
+
import guidanceMarkdown from './UiTooltip.guidance.md?raw';
|
|
14
|
+
|
|
15
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
6
16
|
|
|
7
17
|
/**
|
|
8
18
|
* UiTooltip is a non-modal text hint that appears next to its trigger on hover or focus.
|
|
@@ -49,6 +59,9 @@ const meta: Meta<typeof UiTooltip> = {
|
|
|
49
59
|
delayDuration: 500,
|
|
50
60
|
disabled: false,
|
|
51
61
|
},
|
|
62
|
+
parameters: {
|
|
63
|
+
docs: { links: guidanceLinks(guidance) },
|
|
64
|
+
},
|
|
52
65
|
};
|
|
53
66
|
|
|
54
67
|
export default meta;
|
|
@@ -122,6 +135,83 @@ export const Default: Story = {
|
|
|
122
135
|
},
|
|
123
136
|
};
|
|
124
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
140
|
+
*/
|
|
141
|
+
export const DesignNotes: Story = {
|
|
142
|
+
...designNotesStory(guidance),
|
|
143
|
+
tags: ['!autodocs'],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Accessibility guidance for labelled triggers, tooltip naming, and contrast.
|
|
148
|
+
*/
|
|
149
|
+
export const Accessibility: Story = {
|
|
150
|
+
render: () => ({
|
|
151
|
+
components: { UiTooltip, UiButton },
|
|
152
|
+
template: `
|
|
153
|
+
<section class="${guidanceSectionClass}">
|
|
154
|
+
<div>
|
|
155
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
156
|
+
Accessibility
|
|
157
|
+
</h2>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
161
|
+
|
|
162
|
+
<div class="flex flex-col gap-6">
|
|
163
|
+
<div class="flex flex-col gap-2">
|
|
164
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
165
|
+
Enable accessibility theme
|
|
166
|
+
</h3>
|
|
167
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
168
|
+
When accessibility is required, enable our accessibility theme. This
|
|
169
|
+
increases contrast and ensures there are no color contrast issues.
|
|
170
|
+
</p>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
175
|
+
<div class="flex flex-col gap-3">
|
|
176
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
177
|
+
Default
|
|
178
|
+
</h3>
|
|
179
|
+
<div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
|
|
180
|
+
<UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
|
|
181
|
+
<UiButton>Hover me</UiButton>
|
|
182
|
+
</UiTooltip>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
187
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
188
|
+
Accessible
|
|
189
|
+
</h3>
|
|
190
|
+
<div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
|
|
191
|
+
<UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
|
|
192
|
+
<UiButton>Hover me</UiButton>
|
|
193
|
+
</UiTooltip>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
</section>
|
|
198
|
+
`,
|
|
199
|
+
}),
|
|
200
|
+
tags: ['!autodocs'],
|
|
201
|
+
parameters: {
|
|
202
|
+
surface: 'primary',
|
|
203
|
+
a11y: { test: 'off' },
|
|
204
|
+
chromatic: {
|
|
205
|
+
disableSnapshot: true,
|
|
206
|
+
},
|
|
207
|
+
docs: {
|
|
208
|
+
canvas: {
|
|
209
|
+
sourceState: 'none',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
125
215
|
/**
|
|
126
216
|
* Tooltip with an icon-only `UiButton`.
|
|
127
217
|
*/
|
|
@@ -599,72 +689,6 @@ export const CustomOffset: Story = {
|
|
|
599
689
|
}),
|
|
600
690
|
};
|
|
601
691
|
|
|
602
|
-
/**
|
|
603
|
-
* Accessibility guidance for labelled triggers, tooltip naming, and contrast.
|
|
604
|
-
*/
|
|
605
|
-
export const Accessibility: Story = {
|
|
606
|
-
render: () => ({
|
|
607
|
-
components: { UiTooltip, UiButton },
|
|
608
|
-
template: `
|
|
609
|
-
<section class="flex flex-col gap-6 p-4">
|
|
610
|
-
<div>
|
|
611
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
612
|
-
Accessibility
|
|
613
|
-
</h2>
|
|
614
|
-
</div>
|
|
615
|
-
|
|
616
|
-
<div class="flex flex-col gap-6">
|
|
617
|
-
<div class="flex flex-col gap-2">
|
|
618
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
619
|
-
Enable accessibility theme
|
|
620
|
-
</h3>
|
|
621
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
622
|
-
When accessibility is required, enable our accessibility theme. This
|
|
623
|
-
increases contrast and ensures there are no color contrast issues.
|
|
624
|
-
</p>
|
|
625
|
-
</div>
|
|
626
|
-
</div>
|
|
627
|
-
|
|
628
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
629
|
-
<div class="flex flex-col gap-3">
|
|
630
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
631
|
-
Default
|
|
632
|
-
</h3>
|
|
633
|
-
<div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
|
|
634
|
-
<UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
|
|
635
|
-
<UiButton>Hover me</UiButton>
|
|
636
|
-
</UiTooltip>
|
|
637
|
-
</div>
|
|
638
|
-
</div>
|
|
639
|
-
|
|
640
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
641
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
642
|
-
Accessible
|
|
643
|
-
</h3>
|
|
644
|
-
<div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
|
|
645
|
-
<UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
|
|
646
|
-
<UiButton>Hover me</UiButton>
|
|
647
|
-
</UiTooltip>
|
|
648
|
-
</div>
|
|
649
|
-
</div>
|
|
650
|
-
</div>
|
|
651
|
-
</section>
|
|
652
|
-
`,
|
|
653
|
-
}),
|
|
654
|
-
tags: ['!autodocs'],
|
|
655
|
-
parameters: {
|
|
656
|
-
a11y: { test: 'off' },
|
|
657
|
-
chromatic: {
|
|
658
|
-
disableSnapshot: true,
|
|
659
|
-
},
|
|
660
|
-
docs: {
|
|
661
|
-
canvas: {
|
|
662
|
-
sourceState: 'none',
|
|
663
|
-
},
|
|
664
|
-
},
|
|
665
|
-
},
|
|
666
|
-
};
|
|
667
|
-
|
|
668
692
|
/*
|
|
669
693
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
670
694
|
* Interaction & accessibility tests (play functions)
|
|
@@ -12,11 +12,15 @@ import {
|
|
|
12
12
|
import { cn } from '@/lib/utils';
|
|
13
13
|
|
|
14
14
|
const props = defineProps<
|
|
15
|
-
SliderRootProps & {
|
|
15
|
+
SliderRootProps & {
|
|
16
|
+
class?: HTMLAttributes['class'];
|
|
17
|
+
/** Text a screen reader announces for a handle's value, as `aria-valuetext`. */
|
|
18
|
+
thumbValueText?: (value: number) => string;
|
|
19
|
+
}
|
|
16
20
|
>();
|
|
17
21
|
const emits = defineEmits<SliderRootEmits>();
|
|
18
22
|
|
|
19
|
-
const delegatedProps = reactiveOmit(props, 'class');
|
|
23
|
+
const delegatedProps = reactiveOmit(props, 'class', 'thumbValueText');
|
|
20
24
|
|
|
21
25
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
22
26
|
</script>
|
|
@@ -27,7 +31,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
27
31
|
data-slot="slider"
|
|
28
32
|
:class="
|
|
29
33
|
cn(
|
|
30
|
-
'relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col',
|
|
34
|
+
'relative flex w-full touch-none items-center select-none [--slider-thumb-size:1rem] data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col',
|
|
31
35
|
props.class,
|
|
32
36
|
)
|
|
33
37
|
"
|
|
@@ -43,12 +47,18 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
43
47
|
/>
|
|
44
48
|
</SliderTrack>
|
|
45
49
|
|
|
50
|
+
<!-- Outside the track, which clips what it holds. -->
|
|
51
|
+
<slot name="track-overlay" />
|
|
52
|
+
|
|
46
53
|
<SliderThumb
|
|
47
|
-
v-for="(
|
|
54
|
+
v-for="(thumbValue, key) in modelValue"
|
|
48
55
|
:key="key"
|
|
49
56
|
data-slot="slider-thumb"
|
|
50
57
|
:aria-label="(modelValue?.length ?? 0) > 1 ? `Value ${key + 1}` : 'Value'"
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
:aria-valuetext="props.thumbValueText?.(thumbValue)"
|
|
59
|
+
class="bg-white border-accent-default ring-ring/50 block size-[var(--slider-thumb-size)] shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
60
|
+
>
|
|
61
|
+
<slot name="thumb" :value="thumbValue" />
|
|
62
|
+
</SliderThumb>
|
|
53
63
|
</SliderRoot>
|
|
54
64
|
</template>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29194:69848'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
The Data Table component presents a set of rows the user works with — filtering, sorting, choosing columns and acting on selections. The table is the task, not a way of laying out a page.
|
|
10
|
+
|
|
11
|
+
Use it where people come to interrogate data. When the rows only need reading, Table is lighter and quieter.
|
|
12
|
+
|
|
13
|
+
### The row is the unit
|
|
14
|
+
|
|
15
|
+
Everything is organised around the row:
|
|
16
|
+
|
|
17
|
+
- One row is one record, always
|
|
18
|
+
- Each column holds one kind of value, aligned by type
|
|
19
|
+
- Row actions sit in the same column on every row
|
|
20
|
+
- Selection persists while the user filters
|
|
21
|
+
|
|
22
|
+
### Controls above, data below
|
|
23
|
+
|
|
24
|
+
The controls belong in a fixed band at the top:
|
|
25
|
+
|
|
26
|
+
1. Search or filter field, narrowing the rows
|
|
27
|
+
2. Filters, for the dimensions the data is questioned by
|
|
28
|
+
3. Column control, for what the user wants to see
|
|
29
|
+
4. The table itself, unchanged in structure by any of them
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every data table is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Data table, with a header row and body rows
|
|
36
|
+
- Filter field and filter controls
|
|
37
|
+
- Column visibility control
|
|
38
|
+
- Row selection, and a count of what is selected
|
|
39
|
+
- Status and value cells, formatted by type
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Right-align numbers and keep decimal places consistent down a column
|
|
44
|
+
- Keep row actions in the same column on every row
|
|
45
|
+
- Say how many rows match once a filter is applied
|
|
46
|
+
- Keep selection while the user filters, and show the count
|
|
47
|
+
- Put the controls in a fixed band above the table
|
|
48
|
+
- Use a status badge with a word, so state is readable
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Mix two kinds of value in one column
|
|
53
|
+
- Let column widths shift as the user filters
|
|
54
|
+
- Hide the number of matching rows
|
|
55
|
+
- Put a different set of actions on different rows
|
|
56
|
+
- Use a data table where the rows are only read — use Table
|
|
57
|
+
- Rely on row colour alone to convey status
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- Status is carried by a word or icon in the cell, never by row colour alone
|
|
62
|
+
- The header row is clearly distinguishable from the body, by weight and surface
|
|
63
|
+
- Sort direction is shown by an arrow's direction, not by a colour change
|
|
64
|
+
- Row hover and row selection are distinguishable from each other
|
|
65
|
+
- Column widths hold steady as data changes, so the reader's place is not lost
|
|
66
|
+
- Row actions and checkboxes are comfortable targets even at the tightest row height
|
|
@@ -43,6 +43,16 @@ import {
|
|
|
43
43
|
MoreHorizontalIcon,
|
|
44
44
|
XIcon,
|
|
45
45
|
} from '@/icons/lucide';
|
|
46
|
+
import {
|
|
47
|
+
accessibilityRequirementsTemplate,
|
|
48
|
+
designNotesStory,
|
|
49
|
+
guidanceLinks,
|
|
50
|
+
guidanceSectionClass,
|
|
51
|
+
parseGuidance,
|
|
52
|
+
} from '../../../.storybook/guidance';
|
|
53
|
+
import guidanceMarkdown from './UiDataTable.guidance.md?raw';
|
|
54
|
+
|
|
55
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
46
56
|
|
|
47
57
|
// Basic columns
|
|
48
58
|
const basicColumns: ColumnDef<Payment>[] = [
|
|
@@ -184,6 +194,7 @@ const meta = {
|
|
|
184
194
|
tags: ['autodocs'],
|
|
185
195
|
parameters: {
|
|
186
196
|
docs: {
|
|
197
|
+
links: guidanceLinks(guidance),
|
|
187
198
|
description: {
|
|
188
199
|
component:
|
|
189
200
|
'A powerful data table component built with TanStack Table and Vue 3. Supports sorting, pagination, filtering, and row selection. Use `UiDataTable` for the core table, `UiDataTablePagination` for pagination controls, and `UiDataTableToolbar` for search and filters.',
|
|
@@ -944,6 +955,172 @@ export const Basic: Story = {
|
|
|
944
955
|
}),
|
|
945
956
|
};
|
|
946
957
|
|
|
958
|
+
/**
|
|
959
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
960
|
+
*/
|
|
961
|
+
export const DesignNotes: Story = {
|
|
962
|
+
...designNotesStory(guidance),
|
|
963
|
+
tags: ['!autodocs'],
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Accessibility guidance for data tables: descriptive headers, labelled sort
|
|
968
|
+
* controls and selection checkboxes, and sufficient contrast.
|
|
969
|
+
*/
|
|
970
|
+
export const Accessibility: Story = {
|
|
971
|
+
tags: ['!autodocs'],
|
|
972
|
+
parameters: {
|
|
973
|
+
surface: 'primary',
|
|
974
|
+
a11y: { test: 'off' },
|
|
975
|
+
chromatic: { disableSnapshot: true },
|
|
976
|
+
docs: {
|
|
977
|
+
canvas: {
|
|
978
|
+
sourceState: 'none',
|
|
979
|
+
},
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
render: () => ({
|
|
983
|
+
components: { UiDataTable },
|
|
984
|
+
setup() {
|
|
985
|
+
return { columns: basicColumns, data: a11yTestData };
|
|
986
|
+
},
|
|
987
|
+
template: `
|
|
988
|
+
<section class="${guidanceSectionClass}">
|
|
989
|
+
<div>
|
|
990
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
991
|
+
Accessibility
|
|
992
|
+
</h2>
|
|
993
|
+
</div>
|
|
994
|
+
|
|
995
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
996
|
+
|
|
997
|
+
<div class="flex flex-col gap-6">
|
|
998
|
+
<div class="flex flex-col gap-2">
|
|
999
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1000
|
+
Give every column a clear, unique header
|
|
1001
|
+
</h3>
|
|
1002
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1003
|
+
Column headers are exposed as <code>columnheader</code> cells and
|
|
1004
|
+
become the accessible name for the data in that column. Keep them
|
|
1005
|
+
concise and descriptive so screen-reader users can understand the
|
|
1006
|
+
table when navigating cell by cell.
|
|
1007
|
+
</p>
|
|
1008
|
+
</div>
|
|
1009
|
+
|
|
1010
|
+
<div class="flex flex-col gap-2">
|
|
1011
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1012
|
+
Label sort controls and selection checkboxes
|
|
1013
|
+
</h3>
|
|
1014
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1015
|
+
Sortable headers use <code>UiDataTableColumnHeader</code>, whose
|
|
1016
|
+
button announces the column and its current sort state (for
|
|
1017
|
+
example, "Status, sorted ascending"). Selection checkboxes need a
|
|
1018
|
+
per-row <code>aria-label</code> such as "Select row" so their
|
|
1019
|
+
purpose is clear out of context.
|
|
1020
|
+
</p>
|
|
1021
|
+
</div>
|
|
1022
|
+
|
|
1023
|
+
<div class="flex flex-col gap-2">
|
|
1024
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1025
|
+
Expandable rows
|
|
1026
|
+
</h3>
|
|
1027
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1028
|
+
Give the expand toggle a real button with an
|
|
1029
|
+
<code>aria-expanded</code> state and a label that reflects the
|
|
1030
|
+
action ("Expand row" / "Collapse row"). The expanded content is
|
|
1031
|
+
rendered in its own table row rather than overlaid, so the table
|
|
1032
|
+
structure stays valid for browsers and screen readers.
|
|
1033
|
+
</p>
|
|
1034
|
+
</div>
|
|
1035
|
+
|
|
1036
|
+
<div class="flex flex-col gap-2">
|
|
1037
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1038
|
+
Column visibility checklist
|
|
1039
|
+
</h3>
|
|
1040
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1041
|
+
The column menu exposes each column as a checkable menu item so
|
|
1042
|
+
assistive tech announces its checked state and lets users toggle
|
|
1043
|
+
columns from the keyboard. Give the trigger a clear accessible
|
|
1044
|
+
label such as "Toggle columns" since its icon alone is not
|
|
1045
|
+
self-explanatory.
|
|
1046
|
+
</p>
|
|
1047
|
+
</div>
|
|
1048
|
+
|
|
1049
|
+
<div class="flex flex-col gap-2">
|
|
1050
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1051
|
+
Row actions and filter menus
|
|
1052
|
+
</h3>
|
|
1053
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1054
|
+
Row action and filter popovers are menus: the trigger needs an
|
|
1055
|
+
accessible name (for example "Open menu" or "Toggle Filters"),
|
|
1056
|
+
opens on Enter/Space, and its items are reachable with the arrow
|
|
1057
|
+
keys and dismissed with Escape. Keep filter fields inside the
|
|
1058
|
+
popover individually labelled so each control makes sense on its
|
|
1059
|
+
own.
|
|
1060
|
+
</p>
|
|
1061
|
+
</div>
|
|
1062
|
+
|
|
1063
|
+
<div class="flex flex-col gap-2">
|
|
1064
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1065
|
+
Draggable columns
|
|
1066
|
+
</h3>
|
|
1067
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1068
|
+
Reordering must not rely on a pointer alone. A draggable header is
|
|
1069
|
+
focusable and can be moved with the Arrow Left / Arrow Right keys,
|
|
1070
|
+
and a focus indicator marks the column being moved so keyboard and
|
|
1071
|
+
low-vision users can follow the change.
|
|
1072
|
+
</p>
|
|
1073
|
+
</div>
|
|
1074
|
+
|
|
1075
|
+
<div class="flex flex-col gap-2">
|
|
1076
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1077
|
+
Clickable rows and pagination
|
|
1078
|
+
</h3>
|
|
1079
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1080
|
+
When rows are clickable, keep the real action on a focusable
|
|
1081
|
+
control inside the row so it is keyboard operable, and let clicks
|
|
1082
|
+
on nested buttons, links, or checkboxes take priority over the row
|
|
1083
|
+
handler. Pagination controls carry descriptive labels ("Go to
|
|
1084
|
+
next page") and announce the current page and selection count.
|
|
1085
|
+
</p>
|
|
1086
|
+
</div>
|
|
1087
|
+
|
|
1088
|
+
<div class="flex flex-col gap-2">
|
|
1089
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1090
|
+
Enable the accessibility theme
|
|
1091
|
+
</h3>
|
|
1092
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
1093
|
+
When accessibility is required, enable our accessibility theme. It
|
|
1094
|
+
increases contrast so table text and controls meet color-contrast
|
|
1095
|
+
requirements.
|
|
1096
|
+
</p>
|
|
1097
|
+
</div>
|
|
1098
|
+
</div>
|
|
1099
|
+
|
|
1100
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
1101
|
+
<div class="flex flex-col gap-3">
|
|
1102
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1103
|
+
Default
|
|
1104
|
+
</h3>
|
|
1105
|
+
<div class="border border-border-surface-default p-4">
|
|
1106
|
+
<UiDataTable :columns="columns" :data="data" />
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
|
|
1110
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
1111
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1112
|
+
Accessible
|
|
1113
|
+
</h3>
|
|
1114
|
+
<div class="border border-border-surface-default p-4">
|
|
1115
|
+
<UiDataTable :columns="columns" :data="data" />
|
|
1116
|
+
</div>
|
|
1117
|
+
</div>
|
|
1118
|
+
</div>
|
|
1119
|
+
</section>
|
|
1120
|
+
`,
|
|
1121
|
+
}),
|
|
1122
|
+
};
|
|
1123
|
+
|
|
947
1124
|
/**
|
|
948
1125
|
* Table with sortable columns using UiDataTableColumnHeader.
|
|
949
1126
|
*
|
|
@@ -2573,161 +2750,6 @@ const a11yTestData: Payment[] = [
|
|
|
2573
2750
|
{ id: '3', amount: 200, status: 'failed', email: 'bob@example.com' },
|
|
2574
2751
|
];
|
|
2575
2752
|
|
|
2576
|
-
/**
|
|
2577
|
-
* Accessibility guidance for data tables: descriptive headers, labelled sort
|
|
2578
|
-
* controls and selection checkboxes, and sufficient contrast.
|
|
2579
|
-
*/
|
|
2580
|
-
export const Accessibility: Story = {
|
|
2581
|
-
tags: ['!autodocs'],
|
|
2582
|
-
parameters: {
|
|
2583
|
-
a11y: { test: 'off' },
|
|
2584
|
-
chromatic: { disableSnapshot: true },
|
|
2585
|
-
docs: {
|
|
2586
|
-
canvas: {
|
|
2587
|
-
sourceState: 'none',
|
|
2588
|
-
},
|
|
2589
|
-
},
|
|
2590
|
-
},
|
|
2591
|
-
render: () => ({
|
|
2592
|
-
components: { UiDataTable },
|
|
2593
|
-
setup() {
|
|
2594
|
-
return { columns: basicColumns, data: a11yTestData };
|
|
2595
|
-
},
|
|
2596
|
-
template: `
|
|
2597
|
-
<section class="flex flex-col gap-6 p-4">
|
|
2598
|
-
<div>
|
|
2599
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
2600
|
-
Accessibility
|
|
2601
|
-
</h2>
|
|
2602
|
-
</div>
|
|
2603
|
-
|
|
2604
|
-
<div class="flex flex-col gap-6">
|
|
2605
|
-
<div class="flex flex-col gap-2">
|
|
2606
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2607
|
-
Give every column a clear, unique header
|
|
2608
|
-
</h3>
|
|
2609
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2610
|
-
Column headers are exposed as <code>columnheader</code> cells and
|
|
2611
|
-
become the accessible name for the data in that column. Keep them
|
|
2612
|
-
concise and descriptive so screen-reader users can understand the
|
|
2613
|
-
table when navigating cell by cell.
|
|
2614
|
-
</p>
|
|
2615
|
-
</div>
|
|
2616
|
-
|
|
2617
|
-
<div class="flex flex-col gap-2">
|
|
2618
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2619
|
-
Label sort controls and selection checkboxes
|
|
2620
|
-
</h3>
|
|
2621
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2622
|
-
Sortable headers use <code>UiDataTableColumnHeader</code>, whose
|
|
2623
|
-
button announces the column and its current sort state (for
|
|
2624
|
-
example, "Status, sorted ascending"). Selection checkboxes need a
|
|
2625
|
-
per-row <code>aria-label</code> such as "Select row" so their
|
|
2626
|
-
purpose is clear out of context.
|
|
2627
|
-
</p>
|
|
2628
|
-
</div>
|
|
2629
|
-
|
|
2630
|
-
<div class="flex flex-col gap-2">
|
|
2631
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2632
|
-
Expandable rows
|
|
2633
|
-
</h3>
|
|
2634
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2635
|
-
Give the expand toggle a real button with an
|
|
2636
|
-
<code>aria-expanded</code> state and a label that reflects the
|
|
2637
|
-
action ("Expand row" / "Collapse row"). The expanded content is
|
|
2638
|
-
rendered in its own table row rather than overlaid, so the table
|
|
2639
|
-
structure stays valid for browsers and screen readers.
|
|
2640
|
-
</p>
|
|
2641
|
-
</div>
|
|
2642
|
-
|
|
2643
|
-
<div class="flex flex-col gap-2">
|
|
2644
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2645
|
-
Column visibility checklist
|
|
2646
|
-
</h3>
|
|
2647
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2648
|
-
The column menu exposes each column as a checkable menu item so
|
|
2649
|
-
assistive tech announces its checked state and lets users toggle
|
|
2650
|
-
columns from the keyboard. Give the trigger a clear accessible
|
|
2651
|
-
label such as "Toggle columns" since its icon alone is not
|
|
2652
|
-
self-explanatory.
|
|
2653
|
-
</p>
|
|
2654
|
-
</div>
|
|
2655
|
-
|
|
2656
|
-
<div class="flex flex-col gap-2">
|
|
2657
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2658
|
-
Row actions and filter menus
|
|
2659
|
-
</h3>
|
|
2660
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2661
|
-
Row action and filter popovers are menus: the trigger needs an
|
|
2662
|
-
accessible name (for example "Open menu" or "Toggle Filters"),
|
|
2663
|
-
opens on Enter/Space, and its items are reachable with the arrow
|
|
2664
|
-
keys and dismissed with Escape. Keep filter fields inside the
|
|
2665
|
-
popover individually labelled so each control makes sense on its
|
|
2666
|
-
own.
|
|
2667
|
-
</p>
|
|
2668
|
-
</div>
|
|
2669
|
-
|
|
2670
|
-
<div class="flex flex-col gap-2">
|
|
2671
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2672
|
-
Draggable columns
|
|
2673
|
-
</h3>
|
|
2674
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2675
|
-
Reordering must not rely on a pointer alone. A draggable header is
|
|
2676
|
-
focusable and can be moved with the Arrow Left / Arrow Right keys,
|
|
2677
|
-
and a focus indicator marks the column being moved so keyboard and
|
|
2678
|
-
low-vision users can follow the change.
|
|
2679
|
-
</p>
|
|
2680
|
-
</div>
|
|
2681
|
-
|
|
2682
|
-
<div class="flex flex-col gap-2">
|
|
2683
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2684
|
-
Clickable rows and pagination
|
|
2685
|
-
</h3>
|
|
2686
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2687
|
-
When rows are clickable, keep the real action on a focusable
|
|
2688
|
-
control inside the row so it is keyboard operable, and let clicks
|
|
2689
|
-
on nested buttons, links, or checkboxes take priority over the row
|
|
2690
|
-
handler. Pagination controls carry descriptive labels ("Go to
|
|
2691
|
-
next page") and announce the current page and selection count.
|
|
2692
|
-
</p>
|
|
2693
|
-
</div>
|
|
2694
|
-
|
|
2695
|
-
<div class="flex flex-col gap-2">
|
|
2696
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
2697
|
-
Enable the accessibility theme
|
|
2698
|
-
</h3>
|
|
2699
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
2700
|
-
When accessibility is required, enable our accessibility theme. It
|
|
2701
|
-
increases contrast so table text and controls meet color-contrast
|
|
2702
|
-
requirements.
|
|
2703
|
-
</p>
|
|
2704
|
-
</div>
|
|
2705
|
-
</div>
|
|
2706
|
-
|
|
2707
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
2708
|
-
<div class="flex flex-col gap-3">
|
|
2709
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
2710
|
-
Default
|
|
2711
|
-
</h3>
|
|
2712
|
-
<div class="border border-border-surface-default p-4">
|
|
2713
|
-
<UiDataTable :columns="columns" :data="data" />
|
|
2714
|
-
</div>
|
|
2715
|
-
</div>
|
|
2716
|
-
|
|
2717
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
2718
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
2719
|
-
Accessible
|
|
2720
|
-
</h3>
|
|
2721
|
-
<div class="border border-border-surface-default p-4">
|
|
2722
|
-
<UiDataTable :columns="columns" :data="data" />
|
|
2723
|
-
</div>
|
|
2724
|
-
</div>
|
|
2725
|
-
</div>
|
|
2726
|
-
</section>
|
|
2727
|
-
`,
|
|
2728
|
-
}),
|
|
2729
|
-
};
|
|
2730
|
-
|
|
2731
2753
|
/**
|
|
2732
2754
|
* The data table is fully keyboard operable: sortable headers are reachable
|
|
2733
2755
|
* with `Tab` and cycle their sort direction with `Enter`.
|