@aleph-alpha/ui-library 5.3.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.d.ts +38 -3
- package/config.js +103 -6
- package/dist/system/lib.js +8926 -8768
- package/dist/system/patterns/UiDataTable/UiDataTableFilterMenu.vue.d.ts +24 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +1 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +23 -1
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +173 -2
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +15 -1
- package/dist/system/patterns/UiFloatActions/types.d.ts +25 -1
- package/dist/system/story-sidebar-icons.json +5 -1
- package/docs/public-docs/getting-started-designers.md +3 -1
- package/package.json +5 -3
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +2 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +5 -5
- package/src/components/UiButton/UiButton.stories.ts +14 -14
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +260 -9
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +2 -2
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiEmpty/UiEmpty.vue +2 -2
- package/src/components/UiField/UiField.stories.ts +610 -3
- package/src/components/UiField/UiFieldDescription.vue +7 -2
- package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +2 -2
- package/src/components/UiInput/UiInput.stories.ts +336 -2
- package/src/components/UiInput/UiInput.vue +3 -3
- package/src/components/UiInput/__tests__/UiInput.test.ts +20 -28
- package/src/components/UiItem/UiItem.stories.ts +236 -1
- package/src/components/UiItem/__tests__/UiItem.test.ts +11 -72
- package/src/components/UiKbd/UiKbd.stories.ts +14 -14
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +42 -42
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +2 -2
- package/src/components/UiResizable/UiResizable.stories.ts +6 -5
- package/src/components/UiSeparator/UiSeparator.stories.ts +6 -6
- package/src/components/UiSheet/UiSheet.stories.ts +2 -2
- package/src/components/UiSlider/UiSlider.stories.ts +8 -8
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.vue +4 -4
- package/src/components/UiSnackbar/UiSnackbarContent.vue +4 -4
- package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
- package/src/components/UiSwitch/UiSwitch.stories.ts +2 -2
- package/src/components/UiTabs/UiTabs.stories.ts +30 -30
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +5 -3
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +9 -9
- package/src/components/UiTooltip/UiTooltip.stories.ts +3 -3
- package/src/components/core/accordion/AccordionTrigger.vue +2 -2
- package/src/components/core/alert/AlertDescription.vue +1 -1
- package/src/components/core/badge/index.ts +1 -1
- package/src/components/core/button/index.ts +2 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +2 -2
- package/src/components/core/calendar/CalendarHeadCell.vue +1 -1
- package/src/components/core/card/CardDescription.vue +1 -1
- package/src/components/core/checkbox/Checkbox.vue +1 -2
- package/src/components/core/drawer/DrawerDescription.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/FieldSeparator.vue +1 -1
- package/src/components/core/input/Input.vue +2 -2
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/kbd/Kbd.vue +1 -1
- package/src/components/core/listbox/ListboxFilter.vue +1 -1
- package/src/components/core/listbox/ListboxGroupLabel.vue +4 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +3 -3
- package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
- package/src/components/core/navigation-menu/index.ts +1 -1
- package/src/components/core/radio-group/RadioGroupItem.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +2 -2
- package/src/components/core/range-calendar/RangeCalendarHeadCell.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/select/SelectLabel.vue +4 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/sheet/SheetDescription.vue +3 -1
- package/src/components/core/switch/Switch.vue +1 -1
- package/src/components/core/table/TableCaption.vue +3 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputItemDelete.vue +1 -1
- package/src/components/core/textarea/Textarea.vue +1 -1
- package/src/components/core/toggle/index.ts +3 -3
- package/src/components/core/toggle-group/index.ts +2 -2
- package/src/lib/useDrag.stories.ts +8 -8
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +913 -16
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +91 -0
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
- package/src/patterns/UiDataTable/constants.ts +12 -0
- package/src/patterns/UiDataTable/index.ts +1 -0
- package/src/patterns/UiDataTable/types.ts +24 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +1 -1
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +140 -12
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1231 -438
- package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -1
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +46 -24
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +16 -1
- package/src/patterns/UiFloatActions/types.ts +28 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +2 -2
- package/src/components/UiField/__tests__/UiFieldError.test.ts +0 -39
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
|
@@ -130,7 +130,7 @@ const hasPopupA11y = computed(() => usesButtonAnchor.value);
|
|
|
130
130
|
const anchorClass = computed(() =>
|
|
131
131
|
cn(
|
|
132
132
|
usesButtonAnchor.value &&
|
|
133
|
-
'inline-flex max-w-full cursor-default rounded-md border border-transparent bg-transparent p-0 text-left font-inherit text-inherit
|
|
133
|
+
'ui-focus-ring inline-flex max-w-full cursor-default rounded-md border border-transparent bg-transparent p-0 text-left font-inherit text-inherit',
|
|
134
134
|
isClickTrigger.value && 'cursor-pointer',
|
|
135
135
|
attrs.class ?? '',
|
|
136
136
|
),
|
|
@@ -57,48 +57,70 @@ describe('UiFloatActionItems', () => {
|
|
|
57
57
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
test('
|
|
60
|
+
test('marks the active item and emits update:modelValue when v-model is used', async () => {
|
|
61
|
+
const onUpdate = vi.fn();
|
|
61
62
|
const { getByRole } = render({
|
|
62
63
|
components: { UiFloatActionItems },
|
|
64
|
+
setup() {
|
|
65
|
+
return { onUpdate };
|
|
66
|
+
},
|
|
63
67
|
template: `
|
|
64
|
-
<UiFloatActionItems
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
<UiFloatActionItems
|
|
69
|
+
aria-label="View"
|
|
70
|
+
model-value="grid"
|
|
71
|
+
@update:model-value="onUpdate"
|
|
72
|
+
>
|
|
73
|
+
<UiFloatActionItems type="button" value="grid" aria-label="Grid">Grid</UiFloatActionItems>
|
|
74
|
+
<UiFloatActionItems type="button" value="list" aria-label="List">List</UiFloatActionItems>
|
|
70
75
|
</UiFloatActionItems>
|
|
71
76
|
`,
|
|
72
77
|
});
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
79
|
+
const grid = getByRole('button', { name: 'Grid' });
|
|
80
|
+
const list = getByRole('button', { name: 'List' });
|
|
81
|
+
|
|
82
|
+
expect(grid).toHaveAttribute('aria-pressed', 'true');
|
|
83
|
+
expect(list).toHaveAttribute('aria-pressed', 'false');
|
|
84
|
+
|
|
85
|
+
await list.click();
|
|
86
|
+
expect(onUpdate).toHaveBeenCalledWith('list');
|
|
78
87
|
});
|
|
79
88
|
|
|
80
|
-
test('
|
|
81
|
-
const { getByRole } = render({
|
|
89
|
+
test('renders no active indicator or pressed state without v-model', () => {
|
|
90
|
+
const { getByRole, container } = render({
|
|
82
91
|
components: { UiFloatActionItems },
|
|
83
92
|
template: `
|
|
84
93
|
<UiFloatActionItems aria-label="Actions">
|
|
85
|
-
<UiFloatActionItems type="button" aria-label="
|
|
86
|
-
<UiFloatActionItems type="button" aria-label="Copy">Copy</UiFloatActionItems>
|
|
94
|
+
<UiFloatActionItems type="button" value="grid" aria-label="Grid">Grid</UiFloatActionItems>
|
|
87
95
|
</UiFloatActionItems>
|
|
88
96
|
`,
|
|
89
97
|
});
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
expect(getByRole('button', { name: 'Grid' })).not.toHaveAttribute(
|
|
100
|
+
'aria-pressed',
|
|
101
|
+
);
|
|
102
|
+
expect(
|
|
103
|
+
container.querySelector('[data-slot="float-item-indicator"]'),
|
|
104
|
+
).toBeNull();
|
|
105
|
+
});
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
|
|
107
|
+
test('renders input item with accessible label', () => {
|
|
108
|
+
const { getByRole } = render({
|
|
109
|
+
components: { UiFloatActionItems },
|
|
110
|
+
template: `
|
|
111
|
+
<UiFloatActionItems aria-label="Search actions">
|
|
112
|
+
<UiFloatActionItems
|
|
113
|
+
type="input"
|
|
114
|
+
aria-label="Search"
|
|
115
|
+
placeholder="Filter..."
|
|
116
|
+
/>
|
|
117
|
+
</UiFloatActionItems>
|
|
118
|
+
`,
|
|
119
|
+
});
|
|
97
120
|
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
expect(getByRole('textbox', { name: 'Search' })).toHaveAttribute(
|
|
122
|
+
'placeholder',
|
|
123
|
+
'Filter...',
|
|
100
124
|
);
|
|
101
|
-
|
|
102
|
-
expect(document.activeElement).toBe(copyButton);
|
|
103
125
|
});
|
|
104
126
|
});
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import type { UiFloatActionItemsValue } from './types';
|
|
3
|
+
|
|
4
|
+
/** Metadata a child item shares with the toolbar when it registers. */
|
|
5
|
+
export interface FloatActionItemRegistration {
|
|
6
|
+
/** Live getter for the item's root element (used to position the indicator). */
|
|
7
|
+
el: () => HTMLElement | null;
|
|
8
|
+
/** Live getter for the item's `value`, if it is a selectable item. */
|
|
9
|
+
value: () => UiFloatActionItemsValue | undefined;
|
|
10
|
+
}
|
|
2
11
|
|
|
3
12
|
/** Shared toolbar state used to coordinate roving-tabindex focus across items. */
|
|
4
13
|
export interface FloatActionItemContext {
|
|
5
14
|
/** Registers a focusable item so the toolbar can manage roving tabindex. */
|
|
6
|
-
registerItem: (id: symbol) => void;
|
|
15
|
+
registerItem: (id: symbol, registration: FloatActionItemRegistration) => void;
|
|
7
16
|
/** Removes an item from roving-tabindex tracking. */
|
|
8
17
|
unregisterItem: (id: symbol) => void;
|
|
9
18
|
/** Marks an item as the active (tabbable) one when it receives focus. */
|
|
@@ -12,6 +21,12 @@ export interface FloatActionItemContext {
|
|
|
12
21
|
getTabIndex: (id: symbol) => number;
|
|
13
22
|
/** Keyboard navigation direction for the toolbar. */
|
|
14
23
|
orientation: Ref<'horizontal' | 'vertical'>;
|
|
24
|
+
/** Whether the toolbar is a `v-model`-driven single-select control. */
|
|
25
|
+
hasModel: Ref<boolean>;
|
|
26
|
+
/** Currently selected value when the toolbar is `v-model`-driven. */
|
|
27
|
+
modelValue: Ref<UiFloatActionItemsValue | undefined>;
|
|
28
|
+
/** Selects a value, emitting `update:modelValue` from the toolbar. */
|
|
29
|
+
select: (value: UiFloatActionItemsValue) => void;
|
|
15
30
|
}
|
|
16
31
|
|
|
17
32
|
export const FLOAT_ACTION_ITEM_CONTEXT: InjectionKey<FloatActionItemContext> =
|
|
@@ -102,6 +102,9 @@ export type UiFloatActionItemsType =
|
|
|
102
102
|
/** Arrow-key navigation direction for toolbar roving focus. */
|
|
103
103
|
export type UiFloatActionItemsOrientation = 'horizontal' | 'vertical';
|
|
104
104
|
|
|
105
|
+
/** Value identifying a selectable `button` item within a toolbar. */
|
|
106
|
+
export type UiFloatActionItemsValue = string | number;
|
|
107
|
+
|
|
105
108
|
/**
|
|
106
109
|
* Pill-shaped floating toolbar and its action items.
|
|
107
110
|
*
|
|
@@ -144,12 +147,36 @@ export interface UiFloatActionItemsProps {
|
|
|
144
147
|
* Placeholder text for `input` items.
|
|
145
148
|
*/
|
|
146
149
|
placeholder?: string;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Selected item value for the `toolbar` container.
|
|
153
|
+
* Use `v-model` to turn the toolbar into a single-select control: the active
|
|
154
|
+
* `button` item (the one whose `value` matches) gets a sliding background
|
|
155
|
+
* indicator. Omit for a plain, stateless action bar.
|
|
156
|
+
* @example
|
|
157
|
+
* ```vue
|
|
158
|
+
* <UiFloatActionItems v-model="view" aria-label="View">
|
|
159
|
+
* <UiFloatActionItems type="button" value="grid" aria-label="Grid" />
|
|
160
|
+
* <UiFloatActionItems type="button" value="list" aria-label="List" />
|
|
161
|
+
* </UiFloatActionItems>
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
modelValue?: UiFloatActionItemsValue;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Value of a selectable `button` item.
|
|
168
|
+
* When the parent toolbar uses `v-model`, clicking this item selects its
|
|
169
|
+
* `value` and moves the active indicator onto it.
|
|
170
|
+
*/
|
|
171
|
+
value?: UiFloatActionItemsValue;
|
|
147
172
|
}
|
|
148
173
|
|
|
149
|
-
/** Events emitted by {@link UiFloatActionItems}
|
|
174
|
+
/** Events emitted by {@link UiFloatActionItems}. */
|
|
150
175
|
export interface UiFloatActionItemsEmits {
|
|
151
176
|
/** Emitted when a `button` item is activated. */
|
|
152
177
|
click: [event: MouseEvent];
|
|
178
|
+
/** Emitted by a `toolbar` with `v-model` when the selected value changes. */
|
|
179
|
+
'update:modelValue': [value: UiFloatActionItemsValue];
|
|
153
180
|
}
|
|
154
181
|
|
|
155
182
|
export type UiFloatActionItemsClass = HTMLAttributes['class'];
|
|
@@ -109,7 +109,7 @@ const renderMode = (mode: MenuButtonStoryConfig) => ({
|
|
|
109
109
|
<template #start-icon>
|
|
110
110
|
<span
|
|
111
111
|
v-if="mode.checkbox"
|
|
112
|
-
class="flex size-4 items-center justify-center rounded-
|
|
112
|
+
class="flex size-4 items-center justify-center rounded-sm bg-background-accent-default text-content-on-accent-default"
|
|
113
113
|
>
|
|
114
114
|
<UiIcon name="check" size="s" />
|
|
115
115
|
</span>
|
|
@@ -147,7 +147,7 @@ const renderMode = (mode: MenuButtonStoryConfig) => ({
|
|
|
147
147
|
<template #start-icon>
|
|
148
148
|
<span
|
|
149
149
|
v-if="mode.checkbox"
|
|
150
|
-
class="flex size-4 items-center justify-center rounded-
|
|
150
|
+
class="flex size-4 items-center justify-center rounded-sm bg-background-accent-default text-content-on-accent-default"
|
|
151
151
|
>
|
|
152
152
|
<UiIcon name="check" size="s" />
|
|
153
153
|
</span>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/vue';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
import { UiFieldError } from '../index';
|
|
4
|
-
|
|
5
|
-
describe('UiFieldError', () => {
|
|
6
|
-
test('renders single error as text', () => {
|
|
7
|
-
const { getByRole } = render(UiFieldError, {
|
|
8
|
-
props: { errors: ['Required'] },
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
expect(getByRole('alert')).toHaveTextContent('Required');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('renders an alert when errors are provided', () => {
|
|
15
|
-
const { getByRole } = render(UiFieldError, {
|
|
16
|
-
props: {
|
|
17
|
-
errors: [
|
|
18
|
-
'Too short',
|
|
19
|
-
{ message: 'Too short' },
|
|
20
|
-
{ message: 'Invalid format' },
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
expect(getByRole('alert')).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('prefers slot content over errors rendering', () => {
|
|
29
|
-
const { getByRole } = render(UiFieldError, {
|
|
30
|
-
props: { errors: ['Required'] },
|
|
31
|
-
slots: {
|
|
32
|
-
default: 'Custom error slot',
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(getByRole('alert')).toHaveTextContent('Custom error slot');
|
|
37
|
-
expect(getByRole('alert')).not.toHaveTextContent('Required');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/vue';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
import { nextTick } from 'vue';
|
|
4
|
-
import { UiFloatActions, UiFloatActionItems } from '../index';
|
|
5
|
-
|
|
6
|
-
describe('UiFloatActions accessibility', () => {
|
|
7
|
-
test('focus trigger opens panel and exposes popup semantics', async () => {
|
|
8
|
-
const { getByRole } = render({
|
|
9
|
-
components: { UiFloatActions, UiFloatActionItems },
|
|
10
|
-
template: `
|
|
11
|
-
<UiFloatActions trigger="focus" aria-label="Paragraph actions">
|
|
12
|
-
<template #container>
|
|
13
|
-
<span>Target paragraph</span>
|
|
14
|
-
</template>
|
|
15
|
-
<template #action>
|
|
16
|
-
<UiFloatActionItems aria-label="Actions">
|
|
17
|
-
<UiFloatActionItems type="button" aria-label="Edit">Edit</UiFloatActionItems>
|
|
18
|
-
</UiFloatActionItems>
|
|
19
|
-
</template>
|
|
20
|
-
</UiFloatActions>
|
|
21
|
-
`,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const anchor = getByRole('button', { name: 'Paragraph actions' });
|
|
25
|
-
expect(anchor.tagName).toBe('BUTTON');
|
|
26
|
-
expect(anchor).toHaveAttribute('aria-haspopup', 'true');
|
|
27
|
-
expect(anchor).toHaveAttribute('aria-expanded', 'false');
|
|
28
|
-
|
|
29
|
-
anchor.focus();
|
|
30
|
-
await nextTick();
|
|
31
|
-
|
|
32
|
-
expect(anchor).toHaveAttribute('aria-expanded', 'true');
|
|
33
|
-
expect(anchor).toHaveAttribute('aria-controls');
|
|
34
|
-
expect(getByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
35
|
-
expect(getByRole('toolbar', { name: 'Actions' })).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('hover trigger opens panel on keyboard focus', async () => {
|
|
39
|
-
const { getByRole, queryByText } = render({
|
|
40
|
-
components: { UiFloatActions, UiFloatActionItems },
|
|
41
|
-
template: `
|
|
42
|
-
<UiFloatActions trigger="hover" aria-label="Text actions">
|
|
43
|
-
<template #container>
|
|
44
|
-
<span>Hover me</span>
|
|
45
|
-
</template>
|
|
46
|
-
<template #action>
|
|
47
|
-
<UiFloatActionItems aria-label="Actions">
|
|
48
|
-
<UiFloatActionItems type="button" aria-label="Copy">Copy</UiFloatActionItems>
|
|
49
|
-
</UiFloatActionItems>
|
|
50
|
-
</template>
|
|
51
|
-
</UiFloatActions>
|
|
52
|
-
`,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const anchor = getByRole('button', { name: 'Text actions' });
|
|
56
|
-
expect(anchor).toHaveAttribute('aria-haspopup', 'true');
|
|
57
|
-
|
|
58
|
-
anchor.focus();
|
|
59
|
-
await nextTick();
|
|
60
|
-
|
|
61
|
-
expect(anchor).toHaveAttribute('aria-expanded', 'true');
|
|
62
|
-
expect(queryByText('Copy')).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('focus trigger keeps focus on the anchor', async () => {
|
|
66
|
-
const { getByRole } = render({
|
|
67
|
-
components: { UiFloatActions, UiFloatActionItems },
|
|
68
|
-
template: `
|
|
69
|
-
<UiFloatActions trigger="focus" aria-label="Paragraph actions">
|
|
70
|
-
<template #container>
|
|
71
|
-
<span>Target paragraph</span>
|
|
72
|
-
</template>
|
|
73
|
-
<template #action>
|
|
74
|
-
<UiFloatActionItems aria-label="Actions">
|
|
75
|
-
<UiFloatActionItems type="button" aria-label="Edit">Edit</UiFloatActionItems>
|
|
76
|
-
<UiFloatActionItems type="button" aria-label="Copy">Copy</UiFloatActionItems>
|
|
77
|
-
</UiFloatActionItems>
|
|
78
|
-
</template>
|
|
79
|
-
</UiFloatActions>
|
|
80
|
-
`,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const anchor = getByRole('button', { name: 'Paragraph actions' });
|
|
84
|
-
anchor.focus();
|
|
85
|
-
await nextTick();
|
|
86
|
-
|
|
87
|
-
expect(document.activeElement).toBe(anchor);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('closes on Escape and restores expanded state', async () => {
|
|
91
|
-
const { getByRole, queryByRole } = render({
|
|
92
|
-
components: { UiFloatActions, UiFloatActionItems },
|
|
93
|
-
template: `
|
|
94
|
-
<UiFloatActions trigger="focus" aria-label="Paragraph actions">
|
|
95
|
-
<template #container>
|
|
96
|
-
<span>Target paragraph</span>
|
|
97
|
-
</template>
|
|
98
|
-
<template #action>
|
|
99
|
-
<UiFloatActionItems aria-label="Actions">
|
|
100
|
-
<UiFloatActionItems type="button" aria-label="Copy">Copy</UiFloatActionItems>
|
|
101
|
-
</UiFloatActionItems>
|
|
102
|
-
</template>
|
|
103
|
-
</UiFloatActions>
|
|
104
|
-
`,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const anchor = getByRole('button', { name: 'Paragraph actions' });
|
|
108
|
-
anchor.focus();
|
|
109
|
-
await nextTick();
|
|
110
|
-
|
|
111
|
-
document.dispatchEvent(
|
|
112
|
-
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
|
|
113
|
-
);
|
|
114
|
-
await nextTick();
|
|
115
|
-
|
|
116
|
-
expect(anchor).toHaveAttribute('aria-expanded', 'false');
|
|
117
|
-
expect(queryByRole('button', { name: 'Copy' })).not.toBeInTheDocument();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('click trigger toggles with Enter and Space', async () => {
|
|
121
|
-
const { getByRole, queryByRole } = render({
|
|
122
|
-
components: { UiFloatActions, UiFloatActionItems },
|
|
123
|
-
template: `
|
|
124
|
-
<UiFloatActions trigger="click" aria-label="Open actions">
|
|
125
|
-
<template #container>
|
|
126
|
-
<span>Target</span>
|
|
127
|
-
</template>
|
|
128
|
-
<template #action>
|
|
129
|
-
<UiFloatActionItems aria-label="Actions">
|
|
130
|
-
<UiFloatActionItems type="button" aria-label="Edit">Edit</UiFloatActionItems>
|
|
131
|
-
</UiFloatActionItems>
|
|
132
|
-
</template>
|
|
133
|
-
</UiFloatActions>
|
|
134
|
-
`,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const anchor = getByRole('button', { name: 'Open actions' });
|
|
138
|
-
|
|
139
|
-
anchor.focus();
|
|
140
|
-
anchor.dispatchEvent(
|
|
141
|
-
new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }),
|
|
142
|
-
);
|
|
143
|
-
await nextTick();
|
|
144
|
-
expect(queryByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
145
|
-
|
|
146
|
-
anchor.dispatchEvent(
|
|
147
|
-
new KeyboardEvent('keydown', { key: ' ', bubbles: true }),
|
|
148
|
-
);
|
|
149
|
-
await nextTick();
|
|
150
|
-
expect(queryByRole('button', { name: 'Edit' })).not.toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
});
|