@aleph-alpha/ui-library 5.6.0 → 5.8.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/README.md +4 -0
- package/config.d.ts +5 -1
- package/config.js +23 -1
- package/dist/system/components/UiBreadcrumb/UiBreadcrumb.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbEllipsis.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbItem.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbLink.vue.d.ts +18 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbList.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbPage.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbSeparator.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/index.d.ts +8 -0
- package/dist/system/components/UiBreadcrumb/types.d.ts +22 -0
- package/dist/system/components/UiField/types.d.ts +2 -1
- package/dist/system/components/UiToggleGroup/types.d.ts +0 -5
- package/dist/system/components/core/breadcrumb/Breadcrumb.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbEllipsis.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbItem.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbLink.vue.d.ts +24 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbList.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbPage.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbSeparator.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/index.d.ts +7 -0
- package/dist/system/components/core/listbox/Listbox.vue.d.ts +28 -2
- package/dist/system/components/core/listbox/context.d.ts +21 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/lib.js +10062 -9711
- package/dist/system/patterns/UiDatePicker/UiDatePicker.vue.d.ts +1 -1
- package/dist/system/story-sidebar-icons.json +6 -0
- package/package.json +5 -5
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +1 -1
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +1419 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbEllipsis.vue +22 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbItem.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbLink.vue +26 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbList.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbPage.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbSeparator.vue +22 -0
- package/src/components/UiBreadcrumb/index.ts +8 -0
- package/src/components/UiBreadcrumb/types.ts +28 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +625 -74
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +2 -0
- package/src/components/UiField/UiField.stories.ts +1 -1
- package/src/components/UiField/types.ts +2 -1
- package/src/components/UiListbox/UiListbox.stories.ts +1283 -30
- package/src/components/UiListbox/__tests__/UiListbox.test.ts +70 -35
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +995 -0
- package/src/components/UiSelect/UiSelect.stories.ts +1 -1
- package/src/components/UiSwitch/UiSwitch.stories.ts +706 -9
- package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +2 -6
- package/src/components/UiToggle/UiToggle.stories.ts +961 -130
- package/src/components/UiToggle/UiToggle.vue +8 -1
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +55 -65
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +1060 -173
- package/src/components/UiToggleGroup/UiToggleGroup.vue +4 -2
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +117 -325
- package/src/components/UiToggleGroup/types.ts +0 -5
- package/src/components/core/breadcrumb/Breadcrumb.vue +13 -0
- package/src/components/core/breadcrumb/BreadcrumbEllipsis.vue +23 -0
- package/src/components/core/breadcrumb/BreadcrumbItem.vue +17 -0
- package/src/components/core/breadcrumb/BreadcrumbLink.vue +29 -0
- package/src/components/core/breadcrumb/BreadcrumbList.vue +22 -0
- package/src/components/core/breadcrumb/BreadcrumbPage.vue +20 -0
- package/src/components/core/breadcrumb/BreadcrumbSeparator.vue +22 -0
- package/src/components/core/breadcrumb/index.ts +7 -0
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +3 -2
- package/src/components/core/field/FieldTitle.vue +1 -1
- package/src/components/core/listbox/Listbox.vue +14 -2
- package/src/components/core/listbox/ListboxContent.vue +61 -3
- package/src/components/core/listbox/ListboxItem.vue +6 -1
- package/src/components/core/listbox/context.ts +34 -0
- package/src/components/core/toggle/Toggle.vue +15 -1
- package/src/components/core/toggle/index.ts +2 -2
- package/src/components/core/toggle-group/ToggleGroup.vue +1 -1
- package/src/components/core/toggle-group/index.ts +5 -2
- package/src/components/index.ts +1 -0
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +0 -14
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +0 -412
|
@@ -1,46 +1,81 @@
|
|
|
1
1
|
import { render } from '@testing-library/vue';
|
|
2
2
|
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { nextTick } from 'vue';
|
|
3
4
|
import UiListbox from '../UiListbox.vue';
|
|
4
5
|
import UiListboxContent from '../UiListboxContent.vue';
|
|
5
6
|
import UiListboxItem from '../UiListboxItem.vue';
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders a two-option listbox.
|
|
10
|
+
* @param listboxAttrs Extra attributes for the listbox root.
|
|
11
|
+
* @param itemAttrs Extra attributes for the second option.
|
|
12
|
+
* @returns The testing-library render result.
|
|
13
|
+
*/
|
|
14
|
+
function renderListbox(listboxAttrs = '', itemAttrs = '') {
|
|
15
|
+
return render({
|
|
16
|
+
components: { UiListbox, UiListboxContent, UiListboxItem },
|
|
17
|
+
template: `
|
|
18
|
+
<UiListbox model-value="apple" ${listboxAttrs}>
|
|
19
|
+
<UiListboxContent aria-label="Fruits">
|
|
20
|
+
<UiListboxItem value="apple">Apple</UiListboxItem>
|
|
21
|
+
<UiListboxItem value="banana" ${itemAttrs}>Banana</UiListboxItem>
|
|
22
|
+
</UiListboxContent>
|
|
23
|
+
</UiListbox>
|
|
24
|
+
`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
7
27
|
|
|
8
28
|
describe('UiListbox', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
expect(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// reka-ui only renders `data-disabled` for styling, so the wrapper mirrors
|
|
30
|
+
// the state onto `aria-disabled` for assistive technology.
|
|
31
|
+
test('marks the list and every option as disabled when the listbox is disabled', () => {
|
|
32
|
+
const { getByRole, getAllByRole } = renderListbox('disabled');
|
|
33
|
+
|
|
34
|
+
expect(getByRole('listbox', { name: 'Fruits' })).toHaveAttribute(
|
|
35
|
+
'aria-disabled',
|
|
36
|
+
'true',
|
|
37
|
+
);
|
|
38
|
+
for (const option of getAllByRole('option')) {
|
|
39
|
+
expect(option).toHaveAttribute('aria-disabled', 'true');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('marks only the disabled option when a single option is disabled', () => {
|
|
44
|
+
const { getByRole } = renderListbox('', 'disabled');
|
|
45
|
+
|
|
46
|
+
expect(getByRole('listbox', { name: 'Fruits' })).not.toHaveAttribute(
|
|
47
|
+
'aria-disabled',
|
|
48
|
+
);
|
|
49
|
+
expect(getByRole('option', { name: 'Banana' })).toHaveAttribute(
|
|
50
|
+
'aria-disabled',
|
|
51
|
+
'true',
|
|
52
|
+
);
|
|
53
|
+
expect(getByRole('option', { name: 'Apple' })).not.toHaveAttribute(
|
|
54
|
+
'aria-disabled',
|
|
55
|
+
);
|
|
32
56
|
});
|
|
33
57
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
58
|
+
// reka-ui derives the container tabindex from its roving-focus state alone,
|
|
59
|
+
// which left a disabled listbox in the tab order, where it picked up the
|
|
60
|
+
// browser's default focus ring.
|
|
61
|
+
test('takes a disabled listbox out of the tab order', async () => {
|
|
62
|
+
const { getByRole } = renderListbox('disabled');
|
|
63
|
+
await nextTick();
|
|
64
|
+
|
|
65
|
+
expect(getByRole('listbox', { name: 'Fruits' })).toHaveAttribute(
|
|
66
|
+
'tabindex',
|
|
67
|
+
'-1',
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('leaves an enabled listbox without a disabled state', () => {
|
|
72
|
+
const { getByRole, getAllByRole } = renderListbox();
|
|
73
|
+
|
|
74
|
+
expect(getByRole('listbox', { name: 'Fruits' })).not.toHaveAttribute(
|
|
75
|
+
'aria-disabled',
|
|
76
|
+
);
|
|
77
|
+
for (const option of getAllByRole('option')) {
|
|
78
|
+
expect(option).not.toHaveAttribute('aria-disabled');
|
|
79
|
+
}
|
|
45
80
|
});
|
|
46
81
|
});
|