@mozaic-ds/vue 1.0.0-beta.4 → 1.0.0-beta.7
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 +33 -166
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +347 -65
- package/dist/mozaic-vue.js +670 -328
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +1 -1
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +3 -2
- package/src/components/GettingStarted.mdx +16 -5
- package/src/components/Introduction.mdx +35 -9
- package/src/components/Support.mdx +1 -1
- package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
- package/src/components/breadcrumb/MBreadcrumb.stories.ts +84 -0
- package/src/components/breadcrumb/MBreadcrumb.vue +70 -0
- package/src/components/button/MButton.stories.ts +1 -1
- package/src/components/checkbox/MCheckbox.stories.ts +1 -1
- package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +1 -1
- package/src/components/checkboxgroup/MCheckboxGroup.vue +2 -2
- package/src/components/field/MField.stories.ts +1 -1
- package/src/components/fieldgroup/MFieldGroup.stories.ts +175 -26
- package/src/components/iconbutton/MIconButton.stories.ts +1 -1
- package/src/components/link/MLink.vue +1 -1
- package/src/components/loader/MLoader.stories.ts +1 -1
- package/src/components/numberbadge/MNumberBadge.spec.ts +56 -0
- package/src/components/{badge/MBadge.stories.ts → numberbadge/MNumberBadge.stories.ts} +8 -8
- package/src/components/{badge/MBadge.vue → numberbadge/MNumberBadge.vue} +4 -4
- package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
- package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
- package/src/components/passwordinput/MPasswordInput.vue +149 -0
- package/src/components/quantityselector/MQuantitySelector.stories.ts +1 -1
- package/src/components/radio/MRadio.stories.ts +1 -1
- package/src/components/radiogroup/MRadioGroup.stories.ts +1 -1
- package/src/components/select/MSelect.stories.ts +1 -1
- package/src/components/statusbadge/MStatusBadge.stories.ts +5 -5
- package/src/components/statusbadge/MStatusBadge.vue +6 -6
- package/src/components/statusdot/MStatusDot.spec.ts +51 -0
- package/src/components/statusdot/MStatusDot.stories.ts +48 -0
- package/src/components/{statusbadge → statusdot}/MStatusDot.vue +8 -4
- package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
- package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
- package/src/components/statusnotification/MStatusNotification.vue +106 -0
- package/src/components/textarea/MTextArea.stories.ts +1 -1
- package/src/components/textinput/MTextInput.stories.ts +1 -1
- package/src/components/toggle/MToggle.stories.ts +2 -2
- package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
- package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
- package/src/components/togglegroup/MToggleGroup.vue +97 -0
- package/src/main.ts +22 -39
- package/src/components/badge/MBadge.spec.ts +0 -16
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import MStatusNotification from './MStatusNotification.vue';
|
|
3
|
+
import { action } from '@storybook/addon-actions';
|
|
4
|
+
import MButton from '../button/MButton.vue';
|
|
5
|
+
import MLink from '../link/MLink.vue';
|
|
6
|
+
import ArrowNext20 from '@mozaic-ds/icons-vue/src/components/ArrowNext20/ArrowNext20.vue';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof MStatusNotification> = {
|
|
9
|
+
title: 'Status/Status Notification',
|
|
10
|
+
component: MStatusNotification,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component:
|
|
15
|
+
'A Status Notification is used to draw the user’s attention to important information that needs to be acknowledged. It often provides feedback on a process, highlights a status update, or alerts users about an issue. Notifications are typically triggered by user actions or system events and are designed to be easily noticeable while maintaining a non-intrusive experience.',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
title:
|
|
21
|
+
'This is a title, be concise and use the description message to give details.',
|
|
22
|
+
description: 'Description message.',
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
$slots: {
|
|
26
|
+
table: {
|
|
27
|
+
disable: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
render: (args) => ({
|
|
32
|
+
components: { MStatusNotification, MButton, MLink, ArrowNext20 },
|
|
33
|
+
setup() {
|
|
34
|
+
const handleClick = action('close');
|
|
35
|
+
|
|
36
|
+
return { args, handleClick };
|
|
37
|
+
},
|
|
38
|
+
template: `
|
|
39
|
+
<MStatusNotification
|
|
40
|
+
v-bind="args"
|
|
41
|
+
@click="handleClick"
|
|
42
|
+
>
|
|
43
|
+
<template v-if="${'footer' in args}" v-slot:footer>${args.footer}</template>
|
|
44
|
+
</MStatusNotification>
|
|
45
|
+
`,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
export default meta;
|
|
49
|
+
type Story = StoryObj<typeof MStatusNotification>;
|
|
50
|
+
|
|
51
|
+
export const Info: Story = {};
|
|
52
|
+
|
|
53
|
+
export const Success: Story = {
|
|
54
|
+
args: { status: 'success' },
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Warning: Story = {
|
|
58
|
+
args: { status: 'warning' },
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Error: Story = {
|
|
62
|
+
args: { status: 'error' },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const Closable: Story = {
|
|
66
|
+
args: { closable: true },
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithButton = {
|
|
70
|
+
args: {
|
|
71
|
+
footer: `
|
|
72
|
+
<MButton outlined>Button Label</MButton>
|
|
73
|
+
`,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const WithLink = {
|
|
78
|
+
args: {
|
|
79
|
+
footer: `
|
|
80
|
+
<MLink href="#" iconPosition="right">
|
|
81
|
+
Stand-alone link
|
|
82
|
+
|
|
83
|
+
<template #icon><ArrowNext20 /></template>
|
|
84
|
+
</MLink>
|
|
85
|
+
`,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const WithButtons = {
|
|
90
|
+
args: {
|
|
91
|
+
footer: `
|
|
92
|
+
<MButton>Button Label</MButton>
|
|
93
|
+
<MButton outlined>Button Label</MButton>
|
|
94
|
+
`,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="mc-status-notification" role="status" :class="classObject">
|
|
3
|
+
<component
|
|
4
|
+
:is="iconComponent"
|
|
5
|
+
class="mc-status-notification__icon"
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
/>
|
|
8
|
+
<div class="mc-status-notification__content">
|
|
9
|
+
<h2 class="mc-status-notification__title">{{ title }}</h2>
|
|
10
|
+
|
|
11
|
+
<p class="mc-status-notification__message">
|
|
12
|
+
{{ description }}
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<div v-if="$slots.footer" class="mc-status-notification__footer">
|
|
16
|
+
<slot name="footer" />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<button
|
|
21
|
+
v-if="closable"
|
|
22
|
+
class="mc-status-notification-closable__close"
|
|
23
|
+
@click="emit('close')"
|
|
24
|
+
>
|
|
25
|
+
<Cross20
|
|
26
|
+
class="mc-status-notification-closable__icon"
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
/>
|
|
29
|
+
<span class="mc-status-notification-closable__text">Close</span>
|
|
30
|
+
</button>
|
|
31
|
+
</section>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { computed, type VNode } from 'vue';
|
|
36
|
+
import Cross20 from '@mozaic-ds/icons-vue/src/components/Cross20/Cross20.vue';
|
|
37
|
+
import InfoCircle32 from '@mozaic-ds/icons-vue/src/components/InfoCircle32/InfoCircle32.vue';
|
|
38
|
+
import WarningCircle32 from '@mozaic-ds/icons-vue/src/components/WarningCircle32/WarningCircle32.vue';
|
|
39
|
+
import CrossCircle32 from '@mozaic-ds/icons-vue/src/components/CrossCircle32/CrossCircle32.vue';
|
|
40
|
+
import CheckCircle32 from '@mozaic-ds/icons-vue/src/components/CheckCircle32/CheckCircle32.vue';
|
|
41
|
+
/**
|
|
42
|
+
* A Status Notification is used to draw the user’s attention to important information that needs to be acknowledged. It often provides feedback on a process, highlights a status update, or alerts users about an issue. Notifications are typically triggered by user actions or system events and are designed to be easily noticeable while maintaining a non-intrusive experience.
|
|
43
|
+
*/
|
|
44
|
+
const props = withDefaults(
|
|
45
|
+
defineProps<{
|
|
46
|
+
/**
|
|
47
|
+
* Title of the Status Notification
|
|
48
|
+
*/
|
|
49
|
+
title: string;
|
|
50
|
+
/**
|
|
51
|
+
* Description of the Status Notification
|
|
52
|
+
*/
|
|
53
|
+
description: string;
|
|
54
|
+
/**
|
|
55
|
+
* Allows to define the Status Notification style
|
|
56
|
+
*/
|
|
57
|
+
status?: 'info' | 'success' | 'warning' | 'error';
|
|
58
|
+
/**
|
|
59
|
+
* if `true`, display the close button.
|
|
60
|
+
*/
|
|
61
|
+
closable?: boolean;
|
|
62
|
+
}>(),
|
|
63
|
+
{
|
|
64
|
+
status: 'info',
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
defineSlots<{
|
|
69
|
+
/**
|
|
70
|
+
* Use this slot to insert a button or a link in the footer
|
|
71
|
+
*/
|
|
72
|
+
footer?: VNode;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
75
|
+
const classObject = computed(() => {
|
|
76
|
+
return {
|
|
77
|
+
[`mc-status-notification--${props.status}`]:
|
|
78
|
+
props.status && props.status != 'info',
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const iconComponent = computed(() => {
|
|
83
|
+
switch (props.status) {
|
|
84
|
+
case 'success':
|
|
85
|
+
return CheckCircle32;
|
|
86
|
+
case 'warning':
|
|
87
|
+
return WarningCircle32;
|
|
88
|
+
case 'error':
|
|
89
|
+
return CrossCircle32;
|
|
90
|
+
case 'info':
|
|
91
|
+
default:
|
|
92
|
+
return InfoCircle32;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const emit = defineEmits<{
|
|
97
|
+
/**
|
|
98
|
+
* Emits when closing the notification.
|
|
99
|
+
*/
|
|
100
|
+
(on: 'close'): void;
|
|
101
|
+
}>();
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style lang="scss" scoped>
|
|
105
|
+
@use '@mozaic-ds/styles/components/status-notification';
|
|
106
|
+
</style>
|
|
@@ -10,7 +10,7 @@ const meta: Meta<typeof MTextArea> = {
|
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
12
|
component:
|
|
13
|
-
'A
|
|
13
|
+
'A text area is an input designed for multi-line text entry, allowing users to input longer content compared to a standard text input. It is commonly used for comments, feedback, descriptions, and messaging. Text areas can be resizable or fixed in height, depending on the context, and often include placeholder text, character limits, and validation messages to guide users.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field section](/docs/form-elements-field--docs#textarea).',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
@@ -11,7 +11,7 @@ const meta: Meta<typeof MTextInput> = {
|
|
|
11
11
|
docs: {
|
|
12
12
|
description: {
|
|
13
13
|
component:
|
|
14
|
-
'
|
|
14
|
+
'A text input is a single-line input that allows users to enter and edit short text-based content. It is commonly used for names, email addresses, search queries, and form entries. Text Inputs often include placeholders, validation rules, and assistive text to guide users and ensure accurate data entry.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field section](/docs/form-elements-field--docs#input).',
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
},
|
|
@@ -10,13 +10,13 @@ const meta: Meta<typeof MToggle> = {
|
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
12
|
component:
|
|
13
|
-
'A toggle is
|
|
13
|
+
'A toggle is a switch component that allows users to enable or disable a setting, representing a binary state such as on/off or active/inactive. It provides a quick and intuitive way to control preferences or system settings. Toggles are commonly used in settings menus, dark mode switches, and feature activations, offering an alternative to checkboxes for immediate visual feedback.',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
args: {
|
|
18
18
|
id: 'ToggleId',
|
|
19
|
-
label: 'Label',
|
|
19
|
+
label: 'Toggle Label',
|
|
20
20
|
},
|
|
21
21
|
render: (args) => ({
|
|
22
22
|
components: { MToggle },
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import MToggleGroup from './MToggleGroup.vue';
|
|
4
|
+
import MToggle from '@/components/toggle/MToggle.vue';
|
|
5
|
+
|
|
6
|
+
describe('MToggleGroup.vue', () => {
|
|
7
|
+
it('renders toggles based on options', async () => {
|
|
8
|
+
const options = [
|
|
9
|
+
{ id: '1', label: 'Option 1', value: 'option1' },
|
|
10
|
+
{ id: '2', label: 'Option 2', value: 'option2' },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const wrapper = mount(MToggleGroup, {
|
|
14
|
+
props: {
|
|
15
|
+
name: 'test-name',
|
|
16
|
+
options,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const toggles = wrapper.findAllComponents(MToggle);
|
|
21
|
+
expect(toggles.length).toBe(2);
|
|
22
|
+
|
|
23
|
+
expect(toggles[0].props('label')).toBe('Option 1');
|
|
24
|
+
expect(toggles[1].props('label')).toBe('Option 2');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('updates modelValue when a toggle is checked', async () => {
|
|
28
|
+
const options = [
|
|
29
|
+
{ id: '1', label: 'Option 1', value: 'option1' },
|
|
30
|
+
{ id: '2', label: 'Option 2', value: 'option2' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const wrapper = mount(MToggleGroup, {
|
|
34
|
+
props: {
|
|
35
|
+
name: 'test-name',
|
|
36
|
+
options,
|
|
37
|
+
modelValue: [],
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const toggle1 = wrapper.findAllComponents(MToggle)[0].find('input');
|
|
42
|
+
await toggle1.setChecked(true);
|
|
43
|
+
|
|
44
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
45
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([['option1']]);
|
|
46
|
+
|
|
47
|
+
const toggle2 = wrapper.findAllComponents(MToggle)[1].find('input');
|
|
48
|
+
await toggle2.setChecked(true);
|
|
49
|
+
|
|
50
|
+
expect(wrapper.emitted('update:modelValue')[1]).toEqual([
|
|
51
|
+
['option1', 'option2'],
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('syncs with the v-model when initial value is passed', async () => {
|
|
56
|
+
const options = [
|
|
57
|
+
{ id: '1', label: 'Option 1', value: 'option1' },
|
|
58
|
+
{ id: '2', label: 'Option 2', value: 'option2' },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const wrapper = mount(MToggleGroup, {
|
|
62
|
+
props: {
|
|
63
|
+
name: 'test-name',
|
|
64
|
+
options,
|
|
65
|
+
modelValue: ['option1'],
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const toggles = wrapper.findAllComponents(MToggle);
|
|
70
|
+
expect(toggles[0].props('modelValue')).toBe(true);
|
|
71
|
+
expect(toggles[1].props('modelValue')).toBe(false);
|
|
72
|
+
|
|
73
|
+
await wrapper.setProps({ modelValue: ['option2'] });
|
|
74
|
+
|
|
75
|
+
expect(toggles[0].props('modelValue')).toBe(false);
|
|
76
|
+
expect(toggles[1].props('modelValue')).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
|
|
4
|
+
import MToggleGroup from './MToggleGroup.vue';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof MToggleGroup> = {
|
|
7
|
+
title: 'Form Elements/Toggle Group',
|
|
8
|
+
component: MToggleGroup,
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component:
|
|
13
|
+
'A toggle is a switch component that allows users to enable or disable a setting, representing a binary state such as on/off or active/inactive. It provides a quick and intuitive way to control preferences or system settings. Toggles are commonly used in settings menus, dark mode switches, and feature activations, offering an alternative to checkboxes for immediate visual feedback.<br><br> To put a label, requierement text, help text or to apply a valid or invalid message, the examples are available in the [Field Group section](/docs/form-elements-field-group--docs#toggle-group).',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
name: 'toggleGroupName',
|
|
19
|
+
modelValue: ['toggle2'],
|
|
20
|
+
options: [
|
|
21
|
+
{
|
|
22
|
+
id: 'toggle-01',
|
|
23
|
+
label: 'Toggle Label',
|
|
24
|
+
value: 'toggle1',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'toggle-02',
|
|
28
|
+
label: 'Toggle Label',
|
|
29
|
+
value: 'toggle2',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'toggle-03',
|
|
33
|
+
label: 'Toggle Label',
|
|
34
|
+
value: 'toggle3',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'toggle-04',
|
|
38
|
+
label: 'Toggle Label',
|
|
39
|
+
value: 'toggle4',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
render: (args) => ({
|
|
44
|
+
components: { MToggleGroup },
|
|
45
|
+
setup() {
|
|
46
|
+
const handleUpdate = action('update:modelValue');
|
|
47
|
+
|
|
48
|
+
return { args, handleUpdate };
|
|
49
|
+
},
|
|
50
|
+
template: `
|
|
51
|
+
<MToggleGroup
|
|
52
|
+
v-bind="args"
|
|
53
|
+
@update:modelValue="handleUpdate"
|
|
54
|
+
/>
|
|
55
|
+
`,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
export default meta;
|
|
59
|
+
type Story = StoryObj<typeof MToggleGroup>;
|
|
60
|
+
|
|
61
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classObjectContainer">
|
|
3
|
+
<MToggle
|
|
4
|
+
v-for="option in options"
|
|
5
|
+
:id="option.id"
|
|
6
|
+
:key="option.id"
|
|
7
|
+
:label="option.label"
|
|
8
|
+
:is-invalid="option.isInvalid"
|
|
9
|
+
:name="name"
|
|
10
|
+
:class="classObjectItem"
|
|
11
|
+
:model-value="modelValue ? modelValue.includes(option.value) : undefined"
|
|
12
|
+
:disabled="option.disabled"
|
|
13
|
+
@update:model-value="(v: boolean) => onChange(v, option.value)"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { computed, ref, watch } from 'vue';
|
|
20
|
+
import MToggle from '../toggle/MToggle.vue';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A toggle is used to choose between two possibilities and when the user needs instant feedback. It is common to use toggles when you need to show or hide content and "on/off" switch.
|
|
24
|
+
*/
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
/**
|
|
27
|
+
* The name attribute for the toggle element, typically used for form submission.
|
|
28
|
+
*/
|
|
29
|
+
name: string;
|
|
30
|
+
/**
|
|
31
|
+
* Property used to manage the values checked by v-model
|
|
32
|
+
* (Do not use directly)
|
|
33
|
+
*/
|
|
34
|
+
modelValue?: Array<string>;
|
|
35
|
+
/**
|
|
36
|
+
* list of properties of each toggle of the toggle group
|
|
37
|
+
*/
|
|
38
|
+
options: Array<{
|
|
39
|
+
id: string;
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
isInvalid?: boolean;
|
|
44
|
+
size?: 's' | 'm';
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, make the form element of the group inline.
|
|
48
|
+
*/
|
|
49
|
+
inline?: boolean;
|
|
50
|
+
}>();
|
|
51
|
+
|
|
52
|
+
const selectedValue = ref<string[]>([]);
|
|
53
|
+
|
|
54
|
+
watch(
|
|
55
|
+
() => props.modelValue,
|
|
56
|
+
(newValue) => {
|
|
57
|
+
selectedValue.value = newValue || [];
|
|
58
|
+
},
|
|
59
|
+
{ immediate: true },
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const onChange = (isChecked: boolean, value: string) => {
|
|
63
|
+
let values = [...selectedValue.value];
|
|
64
|
+
|
|
65
|
+
if (isChecked && !values.includes(value)) {
|
|
66
|
+
values.push(value);
|
|
67
|
+
} else {
|
|
68
|
+
values = values.filter((val) => val !== value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
emit('update:modelValue', values);
|
|
72
|
+
selectedValue.value = values;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const classObjectContainer = computed(() => {
|
|
76
|
+
return {
|
|
77
|
+
'mc-field__container--inline': props.inline,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const classObjectItem = computed(() => {
|
|
82
|
+
return {
|
|
83
|
+
'mc-field__container--inline__item': props.inline,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const emit = defineEmits<{
|
|
88
|
+
/**
|
|
89
|
+
* Emits when the toggle group value changes, updating the modelValue prop.
|
|
90
|
+
*/
|
|
91
|
+
(on: 'update:modelValue', value: Array<string>): void;
|
|
92
|
+
}>();
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<style lang="scss" scoped>
|
|
96
|
+
@use '@mozaic-ds/styles/components/field';
|
|
97
|
+
</style>
|
package/src/main.ts
CHANGED
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
MCheckbox,
|
|
24
|
-
MCheckboxGroup,
|
|
25
|
-
MField,
|
|
26
|
-
MFieldGroup,
|
|
27
|
-
MIconButton,
|
|
28
|
-
MLink,
|
|
29
|
-
MLoader,
|
|
30
|
-
MOverlay,
|
|
31
|
-
MQuantitySelector,
|
|
32
|
-
MRadio,
|
|
33
|
-
MRadioGroup,
|
|
34
|
-
MSelect,
|
|
35
|
-
MStatusBadge,
|
|
36
|
-
MTextArea,
|
|
37
|
-
MTextInput,
|
|
38
|
-
MToggle,
|
|
39
|
-
};
|
|
1
|
+
export { default as MBreadcrumb } from './components/breadcrumb/MBreadcrumb.vue';
|
|
2
|
+
export { default as MButton } from './components/button/MButton.vue';
|
|
3
|
+
export { default as MCheckbox } from './components/checkbox/MCheckbox.vue';
|
|
4
|
+
export { default as MCheckboxGroup } from './components/checkboxgroup/MCheckboxGroup.vue';
|
|
5
|
+
export { default as MField } from './components/field/MField.vue';
|
|
6
|
+
export { default as MFieldGroup } from './components/fieldgroup/MFieldGroup.vue';
|
|
7
|
+
export { default as MIconButton } from './components/iconbutton/MIconButton.vue';
|
|
8
|
+
export { default as MLink } from './components/link/MLink.vue';
|
|
9
|
+
export { default as MLoader } from './components/loader/MLoader.vue';
|
|
10
|
+
export { default as MNumberBadge } from './components/numberbadge/MNumberBadge.vue';
|
|
11
|
+
export { default as MOverlay } from './components/overlay/MOverlay.vue';
|
|
12
|
+
export { default as MPasswordInput } from './components/passwordinput/MPasswordInput.vue';
|
|
13
|
+
export { default as MQuantitySelector } from './components/quantityselector/MQuantitySelector.vue';
|
|
14
|
+
export { default as MRadio } from './components/radio/MRadio.vue';
|
|
15
|
+
export { default as MRadioGroup } from './components/radiogroup/MRadioGroup.vue';
|
|
16
|
+
export { default as MSelect } from './components/select/MSelect.vue';
|
|
17
|
+
export { default as MStatusBadge } from './components/statusbadge/MStatusBadge.vue';
|
|
18
|
+
export { default as MStatusNotification } from './components/statusnotification/MStatusNotification.vue';
|
|
19
|
+
export { default as MTextArea } from './components/textarea/MTextArea.vue';
|
|
20
|
+
export { default as MTextInput } from './components/textinput/MTextInput.vue';
|
|
21
|
+
export { default as MToggle } from './components/toggle/MToggle.vue';
|
|
22
|
+
export { default as MToggleGroup } from './components/togglegroup/MToggleGroup.vue';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { mount } from '@vue/test-utils';
|
|
4
|
-
import MBadge from './MBadge.vue';
|
|
5
|
-
|
|
6
|
-
describe('MBadge component', () => {
|
|
7
|
-
it('renders properly', () => {
|
|
8
|
-
const wrapper = mount(MBadge, {
|
|
9
|
-
props: {
|
|
10
|
-
label: 99,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(wrapper.text()).toContain('99');
|
|
15
|
-
});
|
|
16
|
-
});
|