@mozaic-ds/vue 2.16.0 → 2.18.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 +2 -1
- package/dist/mozaic-vue.d.ts +258 -137
- package/dist/mozaic-vue.js +14054 -10878
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +7 -25
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +22 -11
- package/src/components/BrandPresets.mdx +2 -2
- package/src/components/Migration.mdx +651 -0
- package/src/components/accordionlist/MAccordionList.figma.ts +43 -0
- package/src/components/accordionlistitem/MAccordionListItem.figma.ts +27 -0
- package/src/components/accordionlistitem/MAccordionListItem.spec.ts +22 -3
- package/src/components/accordionlistitem/MAccordionListItem.vue +38 -28
- package/src/components/actionbottombar/MActionBottomBar.figma.ts +24 -0
- package/src/components/actionlistbox/MActionListbox.figma.ts +30 -0
- package/src/components/avatar/MAvatar.figma.ts +31 -0
- package/src/components/breadcrumb/MBreadcrumb.figma.ts +31 -0
- package/src/components/builtinmenu/MBuiltInMenu.figma.ts +23 -0
- 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.figma.ts +41 -0
- package/src/components/callout/MCallout.figma.ts +29 -0
- package/src/components/callout/MCallout.spec.ts +35 -0
- package/src/components/callout/MCallout.vue +22 -4
- package/src/components/callout/README.md +2 -0
- package/src/components/carousel/MCarousel.figma.ts +32 -0
- package/src/components/checkbox/MCheckbox.figma.ts +45 -0
- package/src/components/checkboxgroup/MCheckboxGroup.figma.ts +30 -0
- package/src/components/checklistmenu/MCheckListMenu.figma.ts +29 -0
- 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/circularprogressbar/MCircularProgressbar.figma.ts +31 -0
- package/src/components/combobox/MCombobox.figma.ts +48 -0
- package/src/components/combobox/MCombobox.spec.ts +1 -1
- package/src/components/combobox/MCombobox.vue +18 -9
- package/src/components/combobox/README.md +2 -2
- package/src/components/container/MContainer.figma.ts +30 -0
- package/src/components/datatable/DataTable.stories.ts +277 -0
- package/src/components/datatable/DataTableCells.stories.ts +251 -0
- package/src/components/datatable/DataTableEmpty.stories.ts +102 -0
- package/src/components/datatable/DataTableExpandable.stories.ts +95 -0
- package/src/components/datatable/DataTableNested.stories.ts +96 -0
- package/src/components/datatable/DataTableSelectable.stories.ts +124 -0
- package/src/components/datatable/DataTableSortable.stories.ts +164 -0
- package/src/components/datatable/MDataTable.types.ts +54 -0
- package/src/components/datatable/assets/styles.scss +10 -0
- package/src/components/datatable/datatable.mdx +63 -0
- package/src/components/datatable/tools/data.js +8 -0
- package/src/components/datatable/tools/data.json +2018 -0
- package/src/components/datatable/utils.js +19 -0
- package/src/components/datepicker/MDatepicker.figma.ts +20 -0
- package/src/components/divider/MDivider.figma.ts +30 -0
- package/src/components/drawer/MDrawer.figma.ts +37 -0
- package/src/components/drawer/README.md +1 -1
- package/src/components/field/MField.figma.ts +30 -0
- package/src/components/fileuploader/MFileUploader.figma.ts +23 -0
- package/src/components/fileuploaderitem/MFileUploaderItem.figma.ts +27 -0
- package/src/components/flag/MFlag.figma.ts +26 -0
- package/src/components/iconbutton/MIconButton.figma.ts +54 -0
- package/src/components/kpiitem/MKpiItem.figma.ts +33 -0
- package/src/components/linearprogressbarbuffer/MLinearProgressbarBuffer.figma.ts +31 -0
- package/src/components/linearprogressbarpercentage/MLinearProgressbarPercentage.figma.ts +26 -0
- package/src/components/link/MLink.figma.ts +32 -0
- package/src/components/loader/MLoader.figma.ts +30 -0
- package/src/components/loadingoverlay/MLoadingOverlay.figma.ts +18 -0
- package/src/components/modal/MModal.figma.ts +27 -0
- package/src/components/navigationindicator/MNavigationIndicator.figma.ts +24 -0
- package/src/components/navigationindicator/MNavigationIndicator.spec.ts +75 -18
- package/src/components/navigationindicator/MNavigationIndicator.vue +10 -12
- package/src/components/numberbadge/MNumberBadge.figma.ts +31 -0
- package/src/components/optionListbox/MOptionListbox.figma.ts +36 -0
- package/src/components/optionListbox/MOptionListbox.vue +34 -19
- package/src/components/optionListbox/README.md +1 -1
- package/src/components/overlay/MOverlay.figma.ts +20 -0
- package/src/components/pageheader/MPageHeader.figma.ts +21 -0
- package/src/components/pagination/MPagination.figma.ts +34 -0
- package/src/components/passwordinput/MPasswordInput.figma.ts +30 -0
- package/src/components/phonenumber/MPhoneNumber.figma.ts +47 -0
- package/src/components/pincode/MPincode.figma.ts +41 -0
- package/src/components/pincode/MPincode.spec.ts +1 -4
- package/src/components/pincode/MPincode.vue +11 -15
- package/src/components/popover/MPopover.figma.ts +42 -0
- package/src/components/popover/MPopover.spec.ts +126 -0
- package/src/components/popover/MPopover.vue +36 -1
- package/src/components/quantityselector/MQuantitySelector.figma.ts +50 -0
- package/src/components/radio/MRadio.figma.ts +40 -0
- package/src/components/radiogroup/MRadioGroup.figma.ts +30 -0
- package/src/components/segmentedcontrol/MSegmentedControl.figma.ts +33 -0
- package/src/components/segmentedcontrol/MSegmentedControl.spec.ts +92 -0
- package/src/components/segmentedcontrol/MSegmentedControl.vue +61 -2
- package/src/components/select/MSelect.figma.ts +49 -0
- package/src/components/sidebar/MSidebar.figma.ts +28 -0
- package/src/components/sidebarexpandableitem/MSidebarExpandableItem.figma.ts +19 -0
- package/src/components/sidebarfooter/MSidebarFooter.figma.ts +21 -0
- package/src/components/sidebarheader/MSidebarHeader.figma.ts +18 -0
- package/src/components/sidebarnavitem/MSidebarNavItem.figma.ts +23 -0
- package/src/components/sidebarshortcutitem/MSidebarShortcutItem.figma.ts +20 -0
- package/src/components/starrating/MStarRating.figma.ts +35 -0
- package/src/components/starrating/MStarRating.spec.ts +19 -22
- package/src/components/starrating/MStarRating.vue +3 -2
- package/src/components/statusbadge/MStatusBadge.figma.ts +27 -0
- package/src/components/statusdot/MStatusDot.figma.ts +31 -0
- package/src/components/statusmessage/MStatusMessage.figma.ts +28 -0
- package/src/components/statusmessage/MStatusMessage.spec.ts +15 -0
- package/src/components/statusmessage/MStatusMessage.stories.ts +4 -0
- package/src/components/statusmessage/MStatusMessage.vue +7 -0
- package/src/components/statusmessage/README.md +2 -0
- package/src/components/statusnotification/MStatusNotification.figma.ts +29 -0
- package/src/components/stepperbottombar/MStepperBottomBar.figma.ts +20 -0
- package/src/components/steppercompact/MStepperCompact.figma.ts +21 -0
- package/src/components/stepperinline/MStepperInline.figma.ts +23 -0
- package/src/components/stepperstacked/MStepperStacked.figma.ts +23 -0
- package/src/components/tabs/MTabs.figma.ts +33 -0
- package/src/components/tabs/MTabs.vue +90 -4
- package/src/components/tabs/Mtabs.spec.ts +162 -0
- package/src/components/tag/MTag.figma.ts +26 -0
- package/src/components/tag/MTag.stories.ts +13 -3
- package/src/components/tag/MTag.vue +11 -1
- package/src/components/tag/README.md +6 -0
- package/src/components/textarea/MTextArea.figma.ts +28 -0
- package/src/components/textinput/MTextInput.figma.ts +51 -0
- package/src/components/tile/MTile.figma.ts +31 -0
- package/src/components/tileclickable/MTileClickable.figma.ts +31 -0
- package/src/components/tileexpandable/MTileExpandable.figma.ts +31 -0
- package/src/components/tileselectable/MTileSelectable.figma.ts +29 -0
- package/src/components/toaster/MToaster.figma.ts +25 -0
- package/src/components/toggle/MToggle.figma.ts +39 -0
- package/src/components/togglegroup/MToggleGroup.figma.ts +30 -0
- package/src/components/tooltip/MTooltip.figma.ts +29 -0
- package/src/main.ts +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCarousel
|
|
3
|
+
* Links Figma Carousel (ADS2) to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=5-6454',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
hasScrollbar: figma.boolean('Has scrollbar'),
|
|
12
|
+
hasPagination: figma.boolean('Has pagination'),
|
|
13
|
+
breakpoint: figma.enum('Breakpoint', {
|
|
14
|
+
'S to M (320 to 1023px)': 's',
|
|
15
|
+
'L to XXL (1024 and up)': 'l',
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
example: () =>
|
|
19
|
+
html`<script setup>
|
|
20
|
+
import { MCarousel } from '@mozaic-ds/vue';
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<MCarousel>
|
|
24
|
+
<template #header>
|
|
25
|
+
<h2>Carousel title</h2>
|
|
26
|
+
</template>
|
|
27
|
+
<div>Slide 1</div>
|
|
28
|
+
<div>Slide 2</div>
|
|
29
|
+
<div>Slide 3</div>
|
|
30
|
+
</MCarousel>`,
|
|
31
|
+
},
|
|
32
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCheckbox
|
|
3
|
+
* Links Figma Checkbox (stand-alone) (ADS2) to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=6-29180',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
modelValue: figma.enum('Is checked', {
|
|
12
|
+
True: true,
|
|
13
|
+
False: false,
|
|
14
|
+
}),
|
|
15
|
+
indeterminate: figma.enum('is Indeterminate', {
|
|
16
|
+
True: true,
|
|
17
|
+
False: false,
|
|
18
|
+
}),
|
|
19
|
+
disabled: figma.enum('State', {
|
|
20
|
+
Disabled: true,
|
|
21
|
+
Default: false,
|
|
22
|
+
Hovered: false,
|
|
23
|
+
Focused: false,
|
|
24
|
+
'Read-only': false,
|
|
25
|
+
}),
|
|
26
|
+
isInvalid: figma.enum('is invalid', {
|
|
27
|
+
True: true,
|
|
28
|
+
False: false,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
example: ({ modelValue, indeterminate, disabled, isInvalid }) =>
|
|
32
|
+
html`<script setup>
|
|
33
|
+
import { MCheckbox } from '@mozaic-ds/vue';
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<MCheckbox
|
|
37
|
+
id="checkbox-id"
|
|
38
|
+
label="Checkbox Label"
|
|
39
|
+
:model-value=${modelValue}
|
|
40
|
+
:indeterminate=${indeterminate}
|
|
41
|
+
disabled=${disabled}
|
|
42
|
+
:is-invalid=${isInvalid}
|
|
43
|
+
></MCheckbox>`,
|
|
44
|
+
},
|
|
45
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCheckboxGroup
|
|
3
|
+
* Links Figma Checkbox group (ADS2) to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=6-29096',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
inline: figma.enum('Layout', {
|
|
12
|
+
'Stacked (default)': false,
|
|
13
|
+
Inline: true,
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
example: ({ inline }) =>
|
|
17
|
+
html`<script setup>
|
|
18
|
+
import { MCheckboxGroup } from '@mozaic-ds/vue';
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<MCheckboxGroup
|
|
22
|
+
name="group"
|
|
23
|
+
:options="[
|
|
24
|
+
{ id: '1', label: 'Option 1', value: '1' },
|
|
25
|
+
{ id: '2', label: 'Option 2', value: '2' },
|
|
26
|
+
]"
|
|
27
|
+
inline=${inline}
|
|
28
|
+
/>`,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCheckListMenu
|
|
3
|
+
* Links Figma Check-list menu (ADS2) to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=72-30681',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
outlined: figma.enum('is outlined', {
|
|
12
|
+
'true': true,
|
|
13
|
+
'false': false,
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
example: ({ outlined }) =>
|
|
17
|
+
html`<script setup>
|
|
18
|
+
import { MCheckListMenu } from '@mozaic-ds/vue';
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<MCheckListMenu
|
|
22
|
+
:items="[
|
|
23
|
+
{ label: 'Label', checked: true },
|
|
24
|
+
{ label: 'Label', checked: false },
|
|
25
|
+
]"
|
|
26
|
+
outlined=${outlined}
|
|
27
|
+
/>`,
|
|
28
|
+
},
|
|
29
|
+
);
|
|
@@ -6,7 +6,7 @@ import type { MenuItem } from '../builtinmenu/MBuiltInMenu.vue';
|
|
|
6
6
|
|
|
7
7
|
const StubMBuiltInMenu = {
|
|
8
8
|
name: 'MBuiltInMenu',
|
|
9
|
-
props: ['modelValue', 'items', 'outlined'],
|
|
9
|
+
props: ['modelValue', 'items', 'outlined', 'label'],
|
|
10
10
|
emits: ['update:modelValue'],
|
|
11
11
|
template: '<div />',
|
|
12
12
|
};
|
|
@@ -60,6 +60,17 @@ describe('MCheckListMenu', () => {
|
|
|
60
60
|
expect(builtIn.props('outlined')).toBe(true);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it('forwards label prop to MBuiltInMenu', () => {
|
|
64
|
+
const items = [{ label: 'A', checked: false }];
|
|
65
|
+
const wrapper = mount(MCheckListMenu, {
|
|
66
|
+
props: { items, label: 'Checklist navigation' },
|
|
67
|
+
global: { components: { MBuiltInMenu: StubMBuiltInMenu } },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const builtIn = wrapper.findComponent(StubMBuiltInMenu);
|
|
71
|
+
expect(builtIn.props('label')).toBe('Checklist navigation');
|
|
72
|
+
});
|
|
73
|
+
|
|
63
74
|
it('emits update:modelValue when inner menu updates modelValue', async () => {
|
|
64
75
|
const items = [{ label: 'X', checked: false }];
|
|
65
76
|
const wrapper = mount(MCheckListMenu, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
v-model="currentMenuItem"
|
|
4
4
|
:items="menuItems"
|
|
5
5
|
:outlined="props.outlined"
|
|
6
|
+
:label="props.label"
|
|
6
7
|
/>
|
|
7
8
|
</template>
|
|
8
9
|
|
|
@@ -31,6 +32,11 @@ const props = defineProps<{
|
|
|
31
32
|
* When enabled, adds a visible border around the wrapper to highlight or separate its content.
|
|
32
33
|
*/
|
|
33
34
|
outlined?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible label for the navigation landmark. Should describe the purpose
|
|
37
|
+
* of this menu to distinguish it from other navigations on the page.
|
|
38
|
+
*/
|
|
39
|
+
label?: string;
|
|
34
40
|
}>();
|
|
35
41
|
|
|
36
42
|
const emit = defineEmits<{
|
|
@@ -10,6 +10,8 @@ A check-list menu is a structured vertical list where each item represents a dis
|
|
|
10
10
|
| `modelValue` | Specifies the key of the currently selected menu item. It allows the component to highlight or style the corresponding item to indicate it is selected or currently in use. | `number` | - |
|
|
11
11
|
| `items*` | Defines the menu items, each of which sets a checked state and act as a button, link, or router-link. | `CheckListMenuItem[]` | - |
|
|
12
12
|
| `outlined` | When enabled, adds a visible border around the wrapper to highlight or separate its content. | `boolean` | - |
|
|
13
|
+
| `label` | Accessible label for the navigation landmark. Should describe the purpose
|
|
14
|
+
of this menu to distinguish it from other navigations on the page. | `string` | - |
|
|
13
15
|
|
|
14
16
|
## Events
|
|
15
17
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCircularProgressbar
|
|
3
|
+
* Links Figma Circular progress bar (ADS2) to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=61-2204',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
size: figma.enum('Size', {
|
|
12
|
+
S: 's',
|
|
13
|
+
M: 'm',
|
|
14
|
+
L: 'l',
|
|
15
|
+
}),
|
|
16
|
+
value: figma.enum('Completion', {
|
|
17
|
+
'0%': 0,
|
|
18
|
+
'25%': 25,
|
|
19
|
+
'50%': 50,
|
|
20
|
+
'75%': 75,
|
|
21
|
+
'100%': 100,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
example: ({ size, value }) =>
|
|
25
|
+
html`<script setup>
|
|
26
|
+
import { MCircularProgressbar } from '@mozaic-ds/vue';
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<MCircularProgressbar size=${size} :value=${value} aria-label="Progress bar"></MCircularProgressbar>`,
|
|
30
|
+
},
|
|
31
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MCombobox
|
|
3
|
+
* Links Figma _combobox / base to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=19683-17907',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
size: figma.enum('Size', {
|
|
12
|
+
S: 's',
|
|
13
|
+
'M (default)': 'm',
|
|
14
|
+
}),
|
|
15
|
+
disabled: figma.enum('State', {
|
|
16
|
+
Disabled: true,
|
|
17
|
+
Default: false,
|
|
18
|
+
Hovered: false,
|
|
19
|
+
Focused: false,
|
|
20
|
+
'Read-only': false,
|
|
21
|
+
}),
|
|
22
|
+
readonly: figma.enum('State', {
|
|
23
|
+
'Read-only': true,
|
|
24
|
+
Default: false,
|
|
25
|
+
Hovered: false,
|
|
26
|
+
Focused: false,
|
|
27
|
+
Disabled: false,
|
|
28
|
+
}),
|
|
29
|
+
isInvalid: figma.enum('Is invalid', {
|
|
30
|
+
True: true,
|
|
31
|
+
False: false,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
example: ({ size, disabled, readonly, isInvalid }) =>
|
|
35
|
+
html`<script setup>
|
|
36
|
+
import { MCombobox } from '@mozaic-ds/vue';
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<MCombobox
|
|
40
|
+
id="combobox-id"
|
|
41
|
+
size=${size}
|
|
42
|
+
disabled=${disabled}
|
|
43
|
+
readonly=${readonly}
|
|
44
|
+
:is-invalid=${isInvalid}
|
|
45
|
+
:options="[{ label: 'Option 1', value: 'option1' }, { label: 'Option 2', value: 'option2' }]"
|
|
46
|
+
></MCombobox>`,
|
|
47
|
+
},
|
|
48
|
+
);
|
|
@@ -117,7 +117,7 @@ describe('MCombobox', () => {
|
|
|
117
117
|
},
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
expect(wrapper.find('.mc-combobox__control').text()).toBe('
|
|
120
|
+
expect(wrapper.find('.mc-combobox__control').text()).toBe('One, Two');
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
it('toggles listbox open/close on control click', async () => {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<div class="mc-combobox__input">
|
|
15
15
|
<button
|
|
16
16
|
ref="comboboxControl"
|
|
17
|
+
type="button"
|
|
17
18
|
:aria-expanded="isOpen ? 'true' : 'false'"
|
|
18
19
|
aria-haspopup="listbox"
|
|
19
20
|
:aria-controls="`listbox-${id}`"
|
|
@@ -33,7 +34,10 @@
|
|
|
33
34
|
>
|
|
34
35
|
{{ selectionLabel }}
|
|
35
36
|
</button>
|
|
36
|
-
<span
|
|
37
|
+
<span
|
|
38
|
+
v-if="multiple && hasValue && counterLabel"
|
|
39
|
+
class="mc-combobox__counter"
|
|
40
|
+
>
|
|
37
41
|
{{ counterLabel }}
|
|
38
42
|
</span>
|
|
39
43
|
|
|
@@ -80,8 +84,8 @@
|
|
|
80
84
|
}
|
|
81
85
|
"
|
|
82
86
|
>
|
|
83
|
-
<template #
|
|
84
|
-
<slot name="
|
|
87
|
+
<template #item="{ item }">
|
|
88
|
+
<slot name="item" v-bind="{ item }" />
|
|
85
89
|
</template>
|
|
86
90
|
</MOptionListbox>
|
|
87
91
|
</div>
|
|
@@ -173,7 +177,6 @@ const props = withDefaults(
|
|
|
173
177
|
}>(),
|
|
174
178
|
{
|
|
175
179
|
placeholder: 'Select an option',
|
|
176
|
-
counterLabel: '99 selected',
|
|
177
180
|
searchPlaceholder: 'Find an option...',
|
|
178
181
|
selectLabel: 'Select all',
|
|
179
182
|
clearLabel: 'Clear',
|
|
@@ -197,9 +200,9 @@ const emit = defineEmits<{
|
|
|
197
200
|
|
|
198
201
|
defineSlots<{
|
|
199
202
|
/**
|
|
200
|
-
* Use this slot to
|
|
203
|
+
* Use this slot to customize the content of each item.
|
|
201
204
|
*/
|
|
202
|
-
|
|
205
|
+
item(props: { item: ListboxOption }): VNode;
|
|
203
206
|
}>();
|
|
204
207
|
|
|
205
208
|
const id = useId();
|
|
@@ -227,12 +230,13 @@ const selection = computed({
|
|
|
227
230
|
const selectionLabel = computed(() => {
|
|
228
231
|
if (Array.isArray(selection.value)) {
|
|
229
232
|
if (!selection.value.length) return props.placeholder;
|
|
230
|
-
return (selection.value as (string | number)[])
|
|
233
|
+
return (selection.value as (string | number)[])
|
|
234
|
+
.map((value) => getOptionLabel(value))
|
|
235
|
+
.join(', ');
|
|
231
236
|
}
|
|
232
237
|
|
|
233
238
|
return (
|
|
234
|
-
|
|
235
|
-
props.placeholder
|
|
239
|
+
getOptionLabel(selection.value as string | number) || props.placeholder
|
|
236
240
|
);
|
|
237
241
|
});
|
|
238
242
|
|
|
@@ -267,6 +271,11 @@ function toggleListbox() {
|
|
|
267
271
|
return isOpen.value ? close() : open();
|
|
268
272
|
}
|
|
269
273
|
|
|
274
|
+
function getOptionLabel(value: string | number) {
|
|
275
|
+
const option = props.options.find((option) => option.value === value);
|
|
276
|
+
return option ? option.label : '';
|
|
277
|
+
}
|
|
278
|
+
|
|
270
279
|
onBeforeUnmount(() => {
|
|
271
280
|
document.removeEventListener('click', handleClickOutside);
|
|
272
281
|
});
|
|
@@ -18,7 +18,7 @@ A combobox is an input field that allows users to select an option from a dropdo
|
|
|
18
18
|
| `actions` | Show select all / clear buttons when multiple. | `boolean` | - |
|
|
19
19
|
| `checkableSections` | Enable checkable section headers in the listbox. | `boolean` | - |
|
|
20
20
|
| `placeholder` | Placeholder text when no value is selected. | `string` | `"Select an option"` |
|
|
21
|
-
| `counterLabel` | Label for the selected items counter. | `string` |
|
|
21
|
+
| `counterLabel` | Label for the selected items counter. | `string` | - |
|
|
22
22
|
| `searchPlaceholder` | Placeholder text for the search input. | `string` | `"Find an option..."` |
|
|
23
23
|
| `selectLabel` | Label for the "Select all" button. | `string` | `"Select all"` |
|
|
24
24
|
| `clearLabel` | Label for the "Clear selection" button. | `string` | `"Clear"` |
|
|
@@ -28,7 +28,7 @@ A combobox is an input field that allows users to select an option from a dropdo
|
|
|
28
28
|
|
|
29
29
|
| Name | Description |
|
|
30
30
|
| --- | --- |
|
|
31
|
-
| `
|
|
31
|
+
| `item` | Use this slot to customize the content of each item. |
|
|
32
32
|
|
|
33
33
|
## Events
|
|
34
34
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Connect mapping for MContainer
|
|
3
|
+
* Links Figma Container to @mozaic-ds/vue
|
|
4
|
+
*/
|
|
5
|
+
import figma, { html } from '@figma/code-connect/html';
|
|
6
|
+
|
|
7
|
+
figma.connect(
|
|
8
|
+
'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=20116-26427',
|
|
9
|
+
{
|
|
10
|
+
props: {
|
|
11
|
+
appearance: figma.enum('Appearance', {
|
|
12
|
+
Primary: 'primary',
|
|
13
|
+
Secondary: 'secondary',
|
|
14
|
+
Inverse: 'inverse',
|
|
15
|
+
}),
|
|
16
|
+
bordered: figma.enum('Is bordered', {
|
|
17
|
+
True: true,
|
|
18
|
+
False: false,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
example: () =>
|
|
22
|
+
html`<script setup>
|
|
23
|
+
import { MContainer } from '@mozaic-ds/vue';
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<MContainer>
|
|
27
|
+
<p>Container content</p>
|
|
28
|
+
</MContainer>`,
|
|
29
|
+
},
|
|
30
|
+
);
|