@aleph-alpha/ui-library 5.4.0 → 5.6.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 +9 -0
- package/config.js +12 -3
- package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +2 -0
- package/dist/system/components/UiButtonGroup/UiButtonGroup.vue.d.ts +20 -0
- package/dist/system/components/UiButtonGroup/index.d.ts +2 -0
- package/dist/system/components/UiButtonGroup/types.d.ts +20 -0
- package/dist/system/components/core/button-group/ButtonGroup.vue.d.ts +23 -0
- package/dist/system/components/core/button-group/ButtonGroupSeparator.vue.d.ts +9 -0
- package/dist/system/components/core/button-group/ButtonGroupText.vue.d.ts +26 -0
- package/dist/system/components/core/button-group/index.d.ts +8 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/lib.js +8878 -8692
- 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 +8 -1
- package/package.json +5 -3
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +620 -0
- package/src/components/UiAutocomplete/UiAutocomplete.vue +28 -3
- package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +14 -69
- package/src/components/UiButton/UiButton.stories.ts +9 -9
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +690 -0
- package/src/components/UiButtonGroup/UiButtonGroup.vue +18 -0
- package/src/components/UiButtonGroup/__tests__/UiButtonGroup.test.ts +68 -0
- package/src/components/UiButtonGroup/index.ts +2 -0
- package/src/components/UiButtonGroup/types.ts +21 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +253 -0
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
- package/src/components/UiField/UiField.stories.ts +608 -1
- package/src/components/UiField/UiFieldDescription.vue +7 -2
- package/src/components/UiInput/UiInput.stories.ts +336 -2
- 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/UiSelect/UiSelect.stories.ts +769 -0
- package/src/components/UiSelect/__tests__/UiSelect.test.ts +4 -73
- package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +3 -31
- package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +14 -5
- 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/core/button-group/ButtonGroup.vue +24 -0
- package/src/components/core/button-group/ButtonGroupSeparator.vue +29 -0
- package/src/components/core/button-group/ButtonGroupText.vue +33 -0
- package/src/components/core/button-group/index.ts +25 -0
- package/src/components/core/checkbox/Checkbox.vue +0 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/index.ts +1 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +495 -8
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +138 -11
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +890 -3
- 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/components/UiField/__tests__/UiFieldError.test.ts +0 -39
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
|
@@ -37,6 +37,7 @@ const props = withDefaults(defineProps<UiAutocompleteProps>(), {
|
|
|
37
37
|
|
|
38
38
|
const emit = defineEmits<UiAutocompleteEmits>();
|
|
39
39
|
|
|
40
|
+
const rootEl = ref<HTMLElement | null>(null);
|
|
40
41
|
const inputEl = ref<HTMLInputElement | null>(null);
|
|
41
42
|
const itemLabels = ref<Map<string, string>>(new Map());
|
|
42
43
|
const highlightedIndex = ref(-1);
|
|
@@ -143,7 +144,7 @@ const inputSlotProps = computed(() => ({
|
|
|
143
144
|
|
|
144
145
|
const shellClasses = computed(() =>
|
|
145
146
|
cn(
|
|
146
|
-
'border-input
|
|
147
|
+
'border-input ui-focus-ring-within aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-full min-w-0 items-center gap-2 rounded-md border bg-background-input-default px-3 py-2 label-14-regular transition-[color,box-shadow]',
|
|
147
148
|
props.disabled && 'pointer-events-none cursor-not-allowed opacity-50',
|
|
148
149
|
),
|
|
149
150
|
);
|
|
@@ -253,6 +254,21 @@ function handleFocus(event: FocusEvent) {
|
|
|
253
254
|
setOpen(true);
|
|
254
255
|
}
|
|
255
256
|
|
|
257
|
+
// Also open on click: an already-focused input fires no focus event, e.g.
|
|
258
|
+
// clicking the input again after dismissing the list with Escape.
|
|
259
|
+
function handleInputClick() {
|
|
260
|
+
setOpen(true);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// The input sits in the popover anchor, outside the floating content, so the
|
|
264
|
+
// dismissable layer would otherwise close the list on clicks/focus in our own shell.
|
|
265
|
+
function handleInteractOutside(event: CustomEvent) {
|
|
266
|
+
const target = event.target as Node | null;
|
|
267
|
+
if (target && rootEl.value?.contains(target)) {
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
256
272
|
function handleBlur(event: FocusEvent) {
|
|
257
273
|
emit('blur', event);
|
|
258
274
|
}
|
|
@@ -310,7 +326,7 @@ provideUiAutocompleteContext({
|
|
|
310
326
|
</script>
|
|
311
327
|
|
|
312
328
|
<template>
|
|
313
|
-
<div class="flex flex-col" :dir="props.dir">
|
|
329
|
+
<div ref="rootEl" class="flex flex-col" :dir="props.dir">
|
|
314
330
|
<ShadcnPopover v-model:open="openState">
|
|
315
331
|
<ShadcnPopoverAnchor as-child>
|
|
316
332
|
<div
|
|
@@ -354,6 +370,7 @@ provideUiAutocompleteContext({
|
|
|
354
370
|
"
|
|
355
371
|
@input="handleInput"
|
|
356
372
|
@focus="handleFocus"
|
|
373
|
+
@click="handleInputClick"
|
|
357
374
|
@blur="handleBlur"
|
|
358
375
|
@keydown="handleKeydown"
|
|
359
376
|
/>
|
|
@@ -383,14 +400,22 @@ provideUiAutocompleteContext({
|
|
|
383
400
|
</div>
|
|
384
401
|
</ShadcnPopoverAnchor>
|
|
385
402
|
|
|
403
|
+
<!--
|
|
404
|
+
Only external (slotted) items are force-mounted: they register their
|
|
405
|
+
labels on mount. Internal options come from props and can stay
|
|
406
|
+
unmounted while closed, keeping reka's focus guards out of the Tab
|
|
407
|
+
order.
|
|
408
|
+
-->
|
|
386
409
|
<ShadcnPopoverContent
|
|
387
410
|
data-slot="autocomplete-content"
|
|
411
|
+
aria-label="Suggestions"
|
|
388
412
|
side="bottom"
|
|
389
413
|
:side-offset="4"
|
|
390
414
|
align="start"
|
|
391
|
-
:force-mount="true"
|
|
415
|
+
:force-mount="hasInternalOptions ? undefined : true"
|
|
392
416
|
class="min-w-(--reka-popper-anchor-width) w-(--reka-popper-anchor-width) max-w-(--reka-popper-available-width) p-1 data-[state=closed]:hidden data-[state=closed]:pointer-events-none"
|
|
393
417
|
@open-auto-focus.prevent
|
|
418
|
+
@interact-outside="handleInteractOutside"
|
|
394
419
|
>
|
|
395
420
|
<div
|
|
396
421
|
role="listbox"
|
|
@@ -37,12 +37,10 @@ describe('UiAutocomplete', () => {
|
|
|
37
37
|
'[data-slot="autocomplete-trigger"]',
|
|
38
38
|
);
|
|
39
39
|
expect(trigger).toHaveAttribute('data-placeholder');
|
|
40
|
-
expect(trigger).toHaveClass(
|
|
41
|
-
'data-[placeholder]:bg-background-input-default',
|
|
42
|
-
);
|
|
40
|
+
expect(trigger).toHaveClass('bg-background-input-default');
|
|
43
41
|
});
|
|
44
42
|
|
|
45
|
-
test('
|
|
43
|
+
test('keeps the input surface in the filled state (value selected)', () => {
|
|
46
44
|
const { container } = render(UiAutocomplete, {
|
|
47
45
|
props: {
|
|
48
46
|
options,
|
|
@@ -55,29 +53,19 @@ describe('UiAutocomplete', () => {
|
|
|
55
53
|
'[data-slot="autocomplete-trigger"]',
|
|
56
54
|
);
|
|
57
55
|
expect(trigger).not.toHaveAttribute('data-placeholder');
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
// Filled state: same input surface as the empty state — only the muted
|
|
57
|
+
// placeholder text switches to regular value text. No accent background,
|
|
58
|
+
// and the focus-ring border stays reserved for focus.
|
|
59
|
+
expect(trigger).toHaveClass('bg-background-input-default');
|
|
60
|
+
expect(trigger).not.toHaveClass('bg-accent');
|
|
61
|
+
expect(trigger).not.toHaveClass(
|
|
60
62
|
'[&:not([data-placeholder])]:border-border-surface-focus-ring',
|
|
61
63
|
);
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
props: {
|
|
68
|
-
options,
|
|
69
|
-
placeholder: 'Search fruit',
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await user.type(getByRole('textbox'), 'ban');
|
|
74
|
-
|
|
75
|
-
await waitFor(() => {
|
|
76
|
-
expect(getByRole('listbox')).toBeInTheDocument();
|
|
77
|
-
expect(getByRole('option', { name: 'Banana' })).toBeInTheDocument();
|
|
78
|
-
expect(queryByRole('option', { name: 'Apple' })).not.toBeInTheDocument();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
66
|
+
// Opening the suggestions, filtering by input text, choosing a value, and
|
|
67
|
+
// the disabled-option guard are covered by the `test - Filter And Select`
|
|
68
|
+
// play function in UiAutocomplete.stories.ts.
|
|
81
69
|
|
|
82
70
|
test('selects a single option and emits its value', async () => {
|
|
83
71
|
const user = userEvent.setup();
|
|
@@ -108,52 +96,9 @@ describe('UiAutocomplete', () => {
|
|
|
108
96
|
});
|
|
109
97
|
});
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
components: { UiAutocomplete },
|
|
115
|
-
template: `
|
|
116
|
-
<UiAutocomplete v-model="value" :options="options" placeholder="Search fruit" />
|
|
117
|
-
`,
|
|
118
|
-
setup() {
|
|
119
|
-
const value = ref('');
|
|
120
|
-
return { value, options };
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await user.click(getByRole('textbox'));
|
|
125
|
-
await user.keyboard('{ArrowDown}');
|
|
126
|
-
|
|
127
|
-
await waitFor(() => {
|
|
128
|
-
expect(getByRole('option', { name: 'Apple' })).toHaveAttribute(
|
|
129
|
-
'data-highlighted',
|
|
130
|
-
'',
|
|
131
|
-
);
|
|
132
|
-
expect(
|
|
133
|
-
document.querySelector('[data-slot="autocomplete-value"]'),
|
|
134
|
-
).not.toBeInTheDocument();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
await user.keyboard('{ArrowDown}');
|
|
138
|
-
|
|
139
|
-
await waitFor(() => {
|
|
140
|
-
expect(getByRole('option', { name: 'Banana' })).toHaveAttribute(
|
|
141
|
-
'data-highlighted',
|
|
142
|
-
'',
|
|
143
|
-
);
|
|
144
|
-
expect(
|
|
145
|
-
document.querySelector('[data-slot="autocomplete-value"]'),
|
|
146
|
-
).not.toBeInTheDocument();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
await user.keyboard('{Enter}');
|
|
150
|
-
|
|
151
|
-
await waitFor(() => {
|
|
152
|
-
expect(
|
|
153
|
-
document.querySelector('[data-slot="autocomplete-value"]'),
|
|
154
|
-
).toHaveTextContent('Banana');
|
|
155
|
-
});
|
|
156
|
-
});
|
|
99
|
+
// Keyboard navigation through internal options (arrow-key highlight, Enter
|
|
100
|
+
// selection, Escape dismissal) is covered by the `test - Keyboard
|
|
101
|
+
// Navigation` play function in UiAutocomplete.stories.ts.
|
|
157
102
|
|
|
158
103
|
test('starts keyboard navigation from the selected internal option when open', async () => {
|
|
159
104
|
const user = userEvent.setup();
|
|
@@ -345,7 +345,7 @@ export const KeyboardNavigation: Story = {
|
|
|
345
345
|
},
|
|
346
346
|
},
|
|
347
347
|
play: async ({ canvasElement, step }) => {
|
|
348
|
-
// Scenario: a keyboard user tabs to the button and activates it with Enter,
|
|
348
|
+
// Scenario (UiButton): a keyboard user tabs to the button and activates it with Enter,
|
|
349
349
|
// Space, and a pointer click.
|
|
350
350
|
const canvas = within(canvasElement);
|
|
351
351
|
const button = canvas.getByRole('button', { name: 'Submit' });
|
|
@@ -430,7 +430,7 @@ export const KeyboardGroupNavigation: Story = {
|
|
|
430
430
|
`,
|
|
431
431
|
}),
|
|
432
432
|
play: async ({ canvasElement, step }) => {
|
|
433
|
-
// Scenario: a keyboard user tabs across the button group in DOM order and
|
|
433
|
+
// Scenario (UiButton): a keyboard user tabs across the button group in DOM order and
|
|
434
434
|
// activates the focused control with Space.
|
|
435
435
|
onClick.mockClear();
|
|
436
436
|
const canvas = within(canvasElement);
|
|
@@ -504,7 +504,7 @@ export const ZoomMagnification: Story = {
|
|
|
504
504
|
template: `<UiButton @click="onClick">Save changes</UiButton>`,
|
|
505
505
|
}),
|
|
506
506
|
play: async ({ canvasElement, step }) => {
|
|
507
|
-
// Scenario: at 200% page zoom the button stays visible, keeps its
|
|
507
|
+
// Scenario (UiButton): at 200% page zoom the button stays visible, keeps its
|
|
508
508
|
// accessible name, and remains clickable.
|
|
509
509
|
onClick.mockClear();
|
|
510
510
|
const canvas = within(canvasElement);
|
|
@@ -590,7 +590,7 @@ export const ScreenReader: Story = {
|
|
|
590
590
|
`,
|
|
591
591
|
}),
|
|
592
592
|
play: async ({ canvasElement, step }) => {
|
|
593
|
-
// Scenario: assistive tech reads each control's role and name, and hears the
|
|
593
|
+
// Scenario (UiButton): assistive tech reads each control's role and name, and hears the
|
|
594
594
|
// toggle's pressed state change via aria-pressed.
|
|
595
595
|
const canvas = within(canvasElement);
|
|
596
596
|
const toggle = canvas.getByRole('button', { name: 'Mute' });
|
|
@@ -658,7 +658,7 @@ export const MobileBreakpoint: Story = {
|
|
|
658
658
|
template: `<UiButton @click="onClick">Continue</UiButton>`,
|
|
659
659
|
}),
|
|
660
660
|
play: async ({ canvasElement, step }) => {
|
|
661
|
-
// Scenario: at the 320px mobile breakpoint the button stays operable and
|
|
661
|
+
// Scenario (UiButton): at the 320px mobile breakpoint the button stays operable and
|
|
662
662
|
// meets the minimum touch-target size.
|
|
663
663
|
onClick.mockClear();
|
|
664
664
|
const canvas = within(canvasElement);
|
|
@@ -951,7 +951,7 @@ export const IconUsage: Story = {
|
|
|
951
951
|
},
|
|
952
952
|
},
|
|
953
953
|
play: async ({ canvasElement, step }) => {
|
|
954
|
-
// Scenario: an icon-only button exposes an accessible name via aria-label
|
|
954
|
+
// Scenario (UiButton): an icon-only button exposes an accessible name via aria-label
|
|
955
955
|
// and still responds to clicks.
|
|
956
956
|
onClick.mockClear();
|
|
957
957
|
const canvas = within(canvasElement);
|
|
@@ -1003,7 +1003,7 @@ export const Loading: Story = {
|
|
|
1003
1003
|
},
|
|
1004
1004
|
},
|
|
1005
1005
|
play: async ({ canvasElement, step }) => {
|
|
1006
|
-
// Scenario: while loading, the button announces aria-busy, shows a labelled
|
|
1006
|
+
// Scenario (UiButton): while loading, the button announces aria-busy, shows a labelled
|
|
1007
1007
|
// spinner, drops out of the tab order, and ignores forced clicks.
|
|
1008
1008
|
onClick.mockClear();
|
|
1009
1009
|
const canvas = within(canvasElement);
|
|
@@ -1108,7 +1108,7 @@ export const AsChild: Story = {
|
|
|
1108
1108
|
},
|
|
1109
1109
|
},
|
|
1110
1110
|
play: async ({ canvasElement, step }) => {
|
|
1111
|
-
// Scenario: rendered as a link via asChild, it exposes the link role and
|
|
1111
|
+
// Scenario (UiButton): rendered as a link via asChild, it exposes the link role and
|
|
1112
1112
|
// href and does not expose a redundant button role.
|
|
1113
1113
|
const canvas = within(canvasElement);
|
|
1114
1114
|
const link = canvas.getByRole('link', { name: 'Login' });
|
|
@@ -1225,7 +1225,7 @@ export const Disabled: Story = {
|
|
|
1225
1225
|
},
|
|
1226
1226
|
},
|
|
1227
1227
|
play: async ({ canvasElement, step }) => {
|
|
1228
|
-
// Scenario: a disabled button reports its disabled state, is skipped by Tab,
|
|
1228
|
+
// Scenario (UiButton): a disabled button reports its disabled state, is skipped by Tab,
|
|
1229
1229
|
// and ignores forced clicks.
|
|
1230
1230
|
onClick.mockClear();
|
|
1231
1231
|
const canvas = within(canvasElement);
|