@mozaic-ds/vue 2.17.0 → 2.19.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/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +158 -72
- package/dist/mozaic-vue.js +1728 -4748
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +6 -25
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +16 -10
- package/src/components/BrandPresets.mdx +20 -2
- package/src/components/Migration.mdx +651 -0
- package/src/components/accordionlistitem/MAccordionListItem.spec.ts +22 -3
- package/src/components/accordionlistitem/MAccordionListItem.vue +38 -28
- package/src/components/actionlistbox/MActionListbox.spec.ts +99 -0
- package/src/components/actionlistbox/MActionListbox.vue +54 -7
- package/src/components/breadcrumb/MBreadcrumb.vue +1 -1
- package/src/components/builtinmenu/MBuiltInMenu.spec.ts +30 -1
- package/src/components/builtinmenu/MBuiltInMenu.vue +26 -17
- package/src/components/builtinmenu/README.md +2 -0
- package/src/components/button/MButton.spec.ts +26 -0
- package/src/components/button/MButton.vue +2 -0
- package/src/components/callout/MCallout.spec.ts +35 -0
- package/src/components/callout/MCallout.stories.ts +0 -3
- package/src/components/callout/MCallout.vue +26 -7
- package/src/components/callout/README.md +4 -2
- package/src/components/carousel/MCarousel.spec.ts +26 -2
- package/src/components/carousel/MCarousel.vue +10 -4
- package/src/components/checklistmenu/MCheckListMenu.spec.ts +12 -1
- package/src/components/checklistmenu/MCheckListMenu.vue +6 -0
- package/src/components/checklistmenu/README.md +2 -0
- package/src/components/combobox/MCombobox.vue +7 -0
- package/src/components/datatable/datatable.mdx +3 -2
- package/src/components/drawer/MDrawer.spec.ts +102 -3
- package/src/components/drawer/MDrawer.vue +73 -14
- package/src/components/field/MField.vue +1 -0
- package/src/components/fileuploader/MFileUploader.vue +2 -2
- package/src/components/fileuploaderitem/MFileUploaderItem.vue +2 -7
- package/src/components/iconbutton/MIconButton.spec.ts +15 -0
- package/src/components/iconbutton/MIconButton.vue +1 -0
- package/src/components/kpiitem/MKpiItem.spec.ts +13 -0
- package/src/components/kpiitem/MKpiItem.vue +1 -1
- package/src/components/modal/MModal.spec.ts +115 -3
- package/src/components/modal/MModal.vue +91 -11
- package/src/components/modal/README.md +1 -1
- package/src/components/navigationindicator/MNavigationIndicator.spec.ts +75 -18
- package/src/components/navigationindicator/MNavigationIndicator.vue +10 -12
- package/src/components/optionListbox/MOptionListbox.vue +16 -1
- package/src/components/overlay/MOverlay.spec.ts +1 -1
- package/src/components/overlay/MOverlay.vue +1 -1
- package/src/components/phonenumber/MPhoneNumber.spec.ts +6 -2
- package/src/components/phonenumber/MPhoneNumber.vue +20 -16
- package/src/components/popover/MPopover.spec.ts +126 -0
- package/src/components/popover/MPopover.vue +36 -1
- package/src/components/segmentedcontrol/MSegmentedControl.spec.ts +92 -0
- package/src/components/segmentedcontrol/MSegmentedControl.vue +61 -2
- package/src/components/sidebarexpandableitem/MSidebarExpandableItem.spec.ts +12 -0
- package/src/components/sidebarexpandableitem/MSidebarExpandableItem.vue +1 -0
- package/src/components/starrating/MStarRating.spec.ts +19 -22
- package/src/components/starrating/MStarRating.vue +3 -2
- package/src/components/steppercompact/MStepperCompact.spec.ts +9 -0
- package/src/components/steppercompact/MStepperCompact.vue +1 -1
- package/src/components/stepperinline/MStepperInline.spec.ts +11 -0
- package/src/components/stepperinline/MStepperInline.vue +1 -1
- package/src/components/stepperstacked/MStepperStacked.spec.ts +13 -0
- package/src/components/stepperstacked/MStepperStacked.vue +1 -0
- package/src/components/tabs/MTabs.vue +90 -4
- package/src/components/tabs/Mtabs.spec.ts +162 -0
- package/src/components/textinput/MTextInput.vue +2 -2
- package/src/components/toggle/MToggle.vue +1 -1
- package/src/main.ts +1 -0
- package/src/components/ComponentsMapping.mdx +0 -98
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { nextTick } from 'vue';
|
|
2
3
|
import { mount } from '@vue/test-utils';
|
|
3
4
|
import MModal from './MModal.vue';
|
|
4
5
|
|
|
@@ -77,17 +78,17 @@ describe('MModal component', () => {
|
|
|
77
78
|
expect(wrapper.find('.link-slot').exists()).toBe(true);
|
|
78
79
|
});
|
|
79
80
|
|
|
80
|
-
it('has
|
|
81
|
+
it('has inert attribute set correctly based on open prop', async () => {
|
|
81
82
|
const wrapper = mount(MModal, {
|
|
82
83
|
props: { open: false, title: 'Title' },
|
|
83
84
|
global: { stubs },
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
expect(wrapper.find('.mc-modal').attributes('
|
|
87
|
+
expect(wrapper.find('.mc-modal').attributes('inert')).toBeDefined();
|
|
87
88
|
|
|
88
89
|
await wrapper.setProps({ open: true });
|
|
89
90
|
|
|
90
|
-
expect(wrapper.find('.mc-modal').attributes('
|
|
91
|
+
expect(wrapper.find('.mc-modal').attributes('inert')).toBeUndefined();
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
it('adds "is-open" class when open is true', async () => {
|
|
@@ -160,4 +161,115 @@ describe('MModal component', () => {
|
|
|
160
161
|
expect(document.body.style.overflow).toBe('');
|
|
161
162
|
expect(document.documentElement.style.overflow).toBe('');
|
|
162
163
|
});
|
|
164
|
+
|
|
165
|
+
it('has role="dialog" on the modal element', () => {
|
|
166
|
+
const wrapper = mount(MModal, {
|
|
167
|
+
props: { open: true, title: 'Title' },
|
|
168
|
+
global: { stubs },
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
expect(wrapper.find('.mc-modal').attributes('role')).toBe('dialog');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('sets aria-modal based on open prop', async () => {
|
|
175
|
+
const wrapper = mount(MModal, {
|
|
176
|
+
props: { open: false, title: 'Title' },
|
|
177
|
+
global: { stubs },
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
expect(wrapper.find('.mc-modal').attributes('aria-modal')).toBe('false');
|
|
181
|
+
|
|
182
|
+
await wrapper.setProps({ open: true });
|
|
183
|
+
|
|
184
|
+
expect(wrapper.find('.mc-modal').attributes('aria-modal')).toBe('true');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('links aria-labelledby to the title element', () => {
|
|
188
|
+
const wrapper = mount(MModal, {
|
|
189
|
+
props: { open: true, title: 'Accessible Title' },
|
|
190
|
+
global: { stubs },
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const modal = wrapper.find('.mc-modal');
|
|
194
|
+
const labelledBy = modal.attributes('aria-labelledby');
|
|
195
|
+
expect(labelledBy).toMatch(/^modalTitle-/);
|
|
196
|
+
|
|
197
|
+
const title = wrapper.find(`#${labelledBy}`);
|
|
198
|
+
expect(title.exists()).toBe(true);
|
|
199
|
+
expect(title.text()).toBe('Accessible Title');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('closes when Escape key is pressed', async () => {
|
|
203
|
+
const wrapper = mount(MModal, {
|
|
204
|
+
props: { open: true, title: 'Title' },
|
|
205
|
+
global: { stubs },
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
await wrapper.find('.mc-modal').trigger('keydown', { key: 'Escape' });
|
|
209
|
+
|
|
210
|
+
const emitted = wrapper.emitted('update:open');
|
|
211
|
+
expect(emitted).toBeTruthy();
|
|
212
|
+
expect(emitted![emitted!.length - 1]).toEqual([false]);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('moves focus to the modal when opened', async () => {
|
|
216
|
+
const wrapper = mount(MModal, {
|
|
217
|
+
props: { open: false, title: 'Title' },
|
|
218
|
+
global: { stubs },
|
|
219
|
+
attachTo: document.body,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
await wrapper.setProps({ open: true });
|
|
223
|
+
await nextTick();
|
|
224
|
+
|
|
225
|
+
expect(document.activeElement).toBe(wrapper.find('.mc-modal').element);
|
|
226
|
+
|
|
227
|
+
wrapper.unmount();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('traps focus from last to first element on Tab', async () => {
|
|
231
|
+
const wrapper = mount(MModal, {
|
|
232
|
+
props: { open: true, title: 'Title', closable: true },
|
|
233
|
+
slots: {
|
|
234
|
+
default: '<button data-test="last-focusable">Last</button>',
|
|
235
|
+
},
|
|
236
|
+
global: { stubs },
|
|
237
|
+
attachTo: document.body,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
await nextTick();
|
|
241
|
+
|
|
242
|
+
const closeButton = wrapper.find('button.mc-modal__close');
|
|
243
|
+
const lastFocusable = wrapper.find('[data-test="last-focusable"]');
|
|
244
|
+
|
|
245
|
+
(lastFocusable.element as HTMLButtonElement).focus();
|
|
246
|
+
await lastFocusable.trigger('keydown', { key: 'Tab' });
|
|
247
|
+
|
|
248
|
+
expect(document.activeElement).toBe(closeButton.element);
|
|
249
|
+
|
|
250
|
+
wrapper.unmount();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('traps focus from first to last element on Shift+Tab', async () => {
|
|
254
|
+
const wrapper = mount(MModal, {
|
|
255
|
+
props: { open: true, title: 'Title', closable: true },
|
|
256
|
+
slots: {
|
|
257
|
+
default: '<button data-test="last-focusable">Last</button>',
|
|
258
|
+
},
|
|
259
|
+
global: { stubs },
|
|
260
|
+
attachTo: document.body,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
await nextTick();
|
|
264
|
+
|
|
265
|
+
const closeButton = wrapper.find('button.mc-modal__close');
|
|
266
|
+
const lastFocusable = wrapper.find('[data-test="last-focusable"]');
|
|
267
|
+
|
|
268
|
+
(closeButton.element as HTMLButtonElement).focus();
|
|
269
|
+
await closeButton.trigger('keydown', { key: 'Tab', shiftKey: true });
|
|
270
|
+
|
|
271
|
+
expect(document.activeElement).toBe(lastFocusable.element);
|
|
272
|
+
|
|
273
|
+
wrapper.unmount();
|
|
274
|
+
});
|
|
163
275
|
});
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<MOverlay
|
|
2
|
+
<MOverlay
|
|
3
|
+
:is-visible="open"
|
|
4
|
+
:dialogLabel="`modalTitle-${id}`"
|
|
5
|
+
@click="onClickOverlay"
|
|
6
|
+
>
|
|
3
7
|
<section
|
|
8
|
+
ref="modalRef"
|
|
4
9
|
class="mc-modal"
|
|
5
10
|
:class="classObject"
|
|
6
11
|
role="dialog"
|
|
7
|
-
aria-labelledby="modalTitle"
|
|
8
|
-
:aria-modal="open ? 'true' : 'false'"
|
|
12
|
+
:aria-labelledby="`modalTitle-${id}`"
|
|
9
13
|
tabindex="-1"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
v-bind="{
|
|
15
|
+
...$attrs,
|
|
16
|
+
...(open
|
|
17
|
+
? {
|
|
18
|
+
'aria-modal': 'true',
|
|
19
|
+
onKeydown: onKeydown,
|
|
20
|
+
onClick: (event: MouseEvent) => {
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
'aria-modal': 'false',
|
|
26
|
+
inert: true,
|
|
27
|
+
}),
|
|
28
|
+
}"
|
|
14
29
|
>
|
|
15
30
|
<div class="mc-modal__dialog" role="document">
|
|
16
31
|
<header class="mc-modal__header">
|
|
17
32
|
<span v-if="$slots.icon" class="mc-modal__icon">
|
|
18
33
|
<slot name="icon" />
|
|
19
34
|
</span>
|
|
20
|
-
<h2 class="mc-modal__title" id="modalTitle">
|
|
35
|
+
<h2 v-if="title" class="mc-modal__title" :id="`modalTitle-${id}`">
|
|
21
36
|
{{ title }}
|
|
22
37
|
</h2>
|
|
23
38
|
<MIconButton
|
|
@@ -48,7 +63,16 @@
|
|
|
48
63
|
</template>
|
|
49
64
|
|
|
50
65
|
<script setup lang="ts">
|
|
51
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
computed,
|
|
68
|
+
onMounted,
|
|
69
|
+
onUnmounted,
|
|
70
|
+
ref,
|
|
71
|
+
watch,
|
|
72
|
+
nextTick,
|
|
73
|
+
type VNode,
|
|
74
|
+
useId,
|
|
75
|
+
} from 'vue';
|
|
52
76
|
import { Cross24 } from '@mozaic-ds/icons-vue';
|
|
53
77
|
import MIconButton from '../iconbutton/MIconButton.vue';
|
|
54
78
|
import MOverlay from '../overlay/MOverlay.vue';
|
|
@@ -64,7 +88,7 @@ const props = withDefaults(
|
|
|
64
88
|
/**
|
|
65
89
|
* Title of the modal.
|
|
66
90
|
*/
|
|
67
|
-
title
|
|
91
|
+
title?: string;
|
|
68
92
|
/**
|
|
69
93
|
* Description of the modal.
|
|
70
94
|
*/
|
|
@@ -107,6 +131,19 @@ defineSlots<{
|
|
|
107
131
|
footer?: VNode;
|
|
108
132
|
}>();
|
|
109
133
|
|
|
134
|
+
const id = useId();
|
|
135
|
+
|
|
136
|
+
const modalRef = ref<HTMLElement | null>(null);
|
|
137
|
+
|
|
138
|
+
const FOCUSABLE_SELECTOR = [
|
|
139
|
+
'a[href]',
|
|
140
|
+
'button:not([disabled])',
|
|
141
|
+
'input:not([disabled])',
|
|
142
|
+
'select:not([disabled])',
|
|
143
|
+
'textarea:not([disabled])',
|
|
144
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
145
|
+
].join(', ');
|
|
146
|
+
|
|
110
147
|
const classObject = computed(() => {
|
|
111
148
|
return {
|
|
112
149
|
'is-open': props.open,
|
|
@@ -131,12 +168,16 @@ const unlockScroll = () => {
|
|
|
131
168
|
onMounted(() => {
|
|
132
169
|
watch(
|
|
133
170
|
() => props.open,
|
|
134
|
-
(isOpen) => {
|
|
171
|
+
async (isOpen) => {
|
|
135
172
|
emit('update:open', isOpen);
|
|
136
173
|
if (props.scroll === false) {
|
|
137
174
|
if (isOpen) lockScroll();
|
|
138
175
|
else unlockScroll();
|
|
139
176
|
}
|
|
177
|
+
if (isOpen) {
|
|
178
|
+
await nextTick();
|
|
179
|
+
modalRef.value?.focus();
|
|
180
|
+
}
|
|
140
181
|
},
|
|
141
182
|
{ immediate: true },
|
|
142
183
|
);
|
|
@@ -156,6 +197,45 @@ const onClose = () => {
|
|
|
156
197
|
emit('update:open', false);
|
|
157
198
|
};
|
|
158
199
|
|
|
200
|
+
const onKeydown = (event: KeyboardEvent) => {
|
|
201
|
+
if (event.key === 'Escape') {
|
|
202
|
+
onClose();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (event.key !== 'Tab' || !props.open || !isClient) return;
|
|
207
|
+
|
|
208
|
+
const modalElement = modalRef.value;
|
|
209
|
+
if (!modalElement) return;
|
|
210
|
+
|
|
211
|
+
const focusableElements = Array.from(
|
|
212
|
+
modalElement.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),
|
|
213
|
+
).filter((element) => !element.hasAttribute('disabled'));
|
|
214
|
+
|
|
215
|
+
if (!focusableElements.length) {
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
modalElement.focus();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const firstFocusable = focusableElements[0];
|
|
222
|
+
const lastFocusable = focusableElements[focusableElements.length - 1];
|
|
223
|
+
const activeElement = document.activeElement as HTMLElement | null;
|
|
224
|
+
|
|
225
|
+
if (event.shiftKey) {
|
|
226
|
+
if (activeElement === firstFocusable || activeElement === modalElement) {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
lastFocusable.focus();
|
|
229
|
+
}
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (activeElement === lastFocusable || activeElement === modalElement) {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
firstFocusable.focus();
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
159
239
|
const emit = defineEmits<{
|
|
160
240
|
/**
|
|
161
241
|
* Emits when the modal display changes, updating the modelValue prop.
|
|
@@ -8,7 +8,7 @@ A modal is a dialog window that appears on top of the main content, requiring us
|
|
|
8
8
|
| Name | Description | Type | Default |
|
|
9
9
|
| --- | --- | --- | --- |
|
|
10
10
|
| `open` | if `true`, display the modal. | `boolean` | - |
|
|
11
|
-
| `title
|
|
11
|
+
| `title` | Title of the modal. | `string` | - |
|
|
12
12
|
| `description` | Description of the modal. | `string` | - |
|
|
13
13
|
| `closable` | if `true`, display the close button. | `boolean` | `true` |
|
|
14
14
|
| `scroll` | if `false`, lock the scroll when open. | `boolean` | `true` |
|
|
@@ -77,24 +77,6 @@ describe('MNavigationIndicator.vue', () => {
|
|
|
77
77
|
expect(emitted![0][0]).toBe(1);
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
it('emits update:modelValue when Enter is pressed on a step', async () => {
|
|
81
|
-
const wrapper = mount(MNavigationIndicator, {
|
|
82
|
-
props: { steps: 3, modelValue: 0 },
|
|
83
|
-
global: {
|
|
84
|
-
stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 },
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const stepButtons = wrapper.findAll(
|
|
89
|
-
'.mc-navigation-indicator__list .mc-navigation-indicator__button',
|
|
90
|
-
);
|
|
91
|
-
await stepButtons[2].trigger('keydown', { key: 'Enter' });
|
|
92
|
-
|
|
93
|
-
const emitted = wrapper.emitted('update:modelValue');
|
|
94
|
-
expect(emitted).toBeTruthy();
|
|
95
|
-
expect(emitted![0][0]).toBe(2);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
80
|
it('does not emit update:modelValue when a wrong key is pressed', async () => {
|
|
99
81
|
const wrapper = mount(MNavigationIndicator, {
|
|
100
82
|
props: { steps: 3, modelValue: 0 },
|
|
@@ -149,4 +131,79 @@ describe('MNavigationIndicator.vue', () => {
|
|
|
149
131
|
expect(button.text()).toContain('Pause');
|
|
150
132
|
expect(wrapper.find('[data-testid="pause-icon"]').exists()).toBe(true);
|
|
151
133
|
});
|
|
134
|
+
|
|
135
|
+
it('renders a navigation landmark with an aria-label', () => {
|
|
136
|
+
const wrapper = mount(MNavigationIndicator, {
|
|
137
|
+
props: { steps: 3, modelValue: 0 },
|
|
138
|
+
global: {
|
|
139
|
+
stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 },
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const navigation = wrapper.find('nav[aria-label="Navigation steps"]');
|
|
144
|
+
expect(navigation.exists()).toBe(true);
|
|
145
|
+
expect(navigation.attributes('aria-label')).toBe('Navigation steps');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('player icon button has aria-label reflecting action state', () => {
|
|
149
|
+
const wrapperPause = mount(MNavigationIndicator, {
|
|
150
|
+
props: { steps: 2, modelValue: 0, action: 'pause' },
|
|
151
|
+
global: { stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 } },
|
|
152
|
+
});
|
|
153
|
+
expect(
|
|
154
|
+
wrapperPause
|
|
155
|
+
.find('[data-testid="m-icon-button"]')
|
|
156
|
+
.attributes('aria-label'),
|
|
157
|
+
).toBe('Pause');
|
|
158
|
+
|
|
159
|
+
const wrapperResume = mount(MNavigationIndicator, {
|
|
160
|
+
props: { steps: 2, modelValue: 0, action: 'resume' },
|
|
161
|
+
global: { stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 } },
|
|
162
|
+
});
|
|
163
|
+
expect(
|
|
164
|
+
wrapperResume
|
|
165
|
+
.find('[data-testid="m-icon-button"]')
|
|
166
|
+
.attributes('aria-label'),
|
|
167
|
+
).toBe('Resume');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('gives each step button an action-oriented aria-label', () => {
|
|
171
|
+
const wrapper = mount(MNavigationIndicator, {
|
|
172
|
+
props: { steps: 3, modelValue: 1 },
|
|
173
|
+
global: {
|
|
174
|
+
stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 },
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const buttons = wrapper.findAll('.mc-navigation-indicator__button');
|
|
179
|
+
expect(buttons[0].attributes('aria-label')).toBe('Go to step 1 of 3');
|
|
180
|
+
expect(buttons[1].attributes('aria-label')).toBe('Current step, 2 of 3');
|
|
181
|
+
expect(buttons[2].attributes('aria-label')).toBe('Go to step 3 of 3');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('sets aria-current="step" only on the active step button', () => {
|
|
185
|
+
const wrapper = mount(MNavigationIndicator, {
|
|
186
|
+
props: { steps: 3, modelValue: 1 },
|
|
187
|
+
global: {
|
|
188
|
+
stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 },
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const buttons = wrapper.findAll('.mc-navigation-indicator__button');
|
|
193
|
+
expect(buttons[1].attributes('aria-current')).toBe('step');
|
|
194
|
+
expect(buttons[0].attributes('aria-current')).not.toBe('step');
|
|
195
|
+
expect(buttons[2].attributes('aria-current')).not.toBe('step');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('emits "action" when the player button is clicked', async () => {
|
|
199
|
+
const wrapper = mount(MNavigationIndicator, {
|
|
200
|
+
props: { steps: 2, modelValue: 0, action: 'resume' },
|
|
201
|
+
global: {
|
|
202
|
+
stubs: { MButton, MIconButton, PauseCircle24, PlayCircle24 },
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
await wrapper.find('[data-testid="m-icon-button"]').trigger('click');
|
|
207
|
+
expect(wrapper.emitted('action')).toBeTruthy();
|
|
208
|
+
});
|
|
152
209
|
});
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
class="mc-navigation-indicator"
|
|
4
|
-
role="navigation"
|
|
5
|
-
aria-label="Navigations steps"
|
|
6
|
-
>
|
|
2
|
+
<nav class="mc-navigation-indicator" aria-label="Navigation steps">
|
|
7
3
|
<ul class="mc-navigation-indicator__list">
|
|
8
4
|
<li
|
|
9
5
|
v-for="(_step, index) in steps"
|
|
@@ -11,14 +7,14 @@
|
|
|
11
7
|
class="mc-navigation-indicator__item"
|
|
12
8
|
>
|
|
13
9
|
<button
|
|
10
|
+
type="button"
|
|
14
11
|
:class="{
|
|
15
12
|
'mc-navigation-indicator__button': true,
|
|
16
13
|
'mc-navigation-indicator__button--active': active === index,
|
|
17
14
|
}"
|
|
18
|
-
aria-label="
|
|
15
|
+
:aria-label="getStepAriaLabel(index)"
|
|
19
16
|
:aria-current="active === index && 'step'"
|
|
20
17
|
@click="setActiveStep(index)"
|
|
21
|
-
@keydown="onKeydown($event, index)"
|
|
22
18
|
></button>
|
|
23
19
|
</li>
|
|
24
20
|
</ul>
|
|
@@ -43,14 +39,14 @@
|
|
|
43
39
|
size="s"
|
|
44
40
|
ghost
|
|
45
41
|
@click="emit('action')"
|
|
46
|
-
aria-label="
|
|
42
|
+
:aria-label="props.action === 'pause' ? 'Pause' : 'Resume'"
|
|
47
43
|
>
|
|
48
44
|
<template #icon>
|
|
49
45
|
<component :is="actionIcon" />
|
|
50
46
|
</template>
|
|
51
47
|
</MIconButton>
|
|
52
48
|
</template>
|
|
53
|
-
</
|
|
49
|
+
</nav>
|
|
54
50
|
</template>
|
|
55
51
|
|
|
56
52
|
<script setup lang="ts">
|
|
@@ -120,10 +116,12 @@ function setActiveStep(step: number) {
|
|
|
120
116
|
active.value = step;
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
function
|
|
124
|
-
if (
|
|
125
|
-
|
|
119
|
+
function getStepAriaLabel(step: number) {
|
|
120
|
+
if (active.value === step) {
|
|
121
|
+
return `Current step, ${step + 1} of ${props.steps}`;
|
|
126
122
|
}
|
|
123
|
+
|
|
124
|
+
return `Go to step ${step + 1} of ${props.steps}`;
|
|
127
125
|
}
|
|
128
126
|
</script>
|
|
129
127
|
|
|
@@ -137,7 +137,22 @@ import {
|
|
|
137
137
|
Less20,
|
|
138
138
|
Check20,
|
|
139
139
|
} from '@mozaic-ds/icons-vue';
|
|
140
|
-
|
|
140
|
+
|
|
141
|
+
function debounce<T extends (...args: unknown[]) => unknown>(
|
|
142
|
+
fn: T,
|
|
143
|
+
wait: number,
|
|
144
|
+
): (...args: Parameters<T>) => void {
|
|
145
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
146
|
+
|
|
147
|
+
return function (this: unknown, ...args: Parameters<T>) {
|
|
148
|
+
if (timeoutId) {
|
|
149
|
+
clearTimeout(timeoutId);
|
|
150
|
+
}
|
|
151
|
+
timeoutId = setTimeout(() => {
|
|
152
|
+
fn.apply(this, args);
|
|
153
|
+
}, wait);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
141
156
|
|
|
142
157
|
/**
|
|
143
158
|
* An Option Listbox is a customizable, accessible listbox component designed to power dropdowns and comboboxes with advanced selection capabilities. It supports single or multiple selection, optional search, grouped options with section headers, and full keyboard navigation.
|
|
@@ -67,7 +67,9 @@ describe('MPhoneNumber', () => {
|
|
|
67
67
|
describe('Country Selection', () => {
|
|
68
68
|
it('should render country selector and flag by default', () => {
|
|
69
69
|
expect(
|
|
70
|
-
wrapper
|
|
70
|
+
wrapper
|
|
71
|
+
.find('.mc-phone-number-input__select .mc-select__control')
|
|
72
|
+
.exists(),
|
|
71
73
|
).toBe(true);
|
|
72
74
|
expect(wrapper.find('.mc-phone-number-input__flag').exists()).toBe(true);
|
|
73
75
|
});
|
|
@@ -197,7 +199,9 @@ describe('MPhoneNumber', () => {
|
|
|
197
199
|
wrapper = mount(MPhoneNumber, {
|
|
198
200
|
props: { ...defaultProps, size: 's' },
|
|
199
201
|
});
|
|
200
|
-
expect(
|
|
202
|
+
expect(
|
|
203
|
+
wrapper.find('.mc-phone-number-input__select').classes(),
|
|
204
|
+
).toContain('mc-select--s');
|
|
201
205
|
expect(wrapper.find('.mc-phone-number-input__input').classes()).toContain(
|
|
202
206
|
'mc-text-input--s',
|
|
203
207
|
);
|
|
@@ -4,25 +4,29 @@
|
|
|
4
4
|
class="mc-phone-number-input__select-wrapper"
|
|
5
5
|
:class="selectWrapperClass"
|
|
6
6
|
>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
v-model="selectedCountry"
|
|
10
|
-
name="selectComponentName"
|
|
11
|
-
class="mc-select mc-phone-number-input__select"
|
|
7
|
+
<div
|
|
8
|
+
class="mc-select mc-phone-number-input__select"
|
|
12
9
|
:class="sizeSelectClass"
|
|
13
|
-
:disabled="isDisabled"
|
|
14
|
-
:readonly="isReadOnly"
|
|
15
10
|
>
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
:
|
|
11
|
+
<select
|
|
12
|
+
id="selectComponentId"
|
|
13
|
+
class="mc-select__control"
|
|
14
|
+
v-model="selectedCountry"
|
|
15
|
+
name="selectComponentName"
|
|
16
|
+
:disabled="isDisabled"
|
|
17
|
+
:readonly="isReadOnly"
|
|
22
18
|
>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
<option value="" selected hidden></option>
|
|
20
|
+
<option
|
|
21
|
+
v-for="country in countries"
|
|
22
|
+
:key="country"
|
|
23
|
+
:value="country"
|
|
24
|
+
:data-flag="country.toLowerCase()"
|
|
25
|
+
>
|
|
26
|
+
{{ getCountryName(country) }} (+{{ getCountryCallingCode(country) }})
|
|
27
|
+
</option>
|
|
28
|
+
</select>
|
|
29
|
+
</div>
|
|
26
30
|
|
|
27
31
|
<div class="mc-phone-number-input__select-display">
|
|
28
32
|
<div class="mc-phone-number-input__flag">
|