@mozaic-ds/vue 1.0.0-beta.4 → 1.0.0-beta.5
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 +14 -6
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +349 -67
- package/dist/mozaic-vue.js +670 -327
- 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 +15 -4
- package/src/components/badge/MBadge.stories.ts +1 -1
- package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
- package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -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/loader/MLoader.stories.ts +1 -1
- 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 +8 -0
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import MBadge from './components/badge/MBadge.vue';
|
|
2
|
+
import MBreadcrumb from './components/breadcrumb/MBreadcrumb.vue';
|
|
2
3
|
import MButton from './components/button/MButton.vue';
|
|
3
4
|
import MCheckbox from './components/checkbox/MCheckbox.vue';
|
|
4
5
|
import MCheckboxGroup from './components/checkboxgroup/MCheckboxGroup.vue';
|
|
@@ -8,17 +9,21 @@ import MIconButton from './components/iconbutton/MIconButton.vue';
|
|
|
8
9
|
import MLink from './components/link/MLink.vue';
|
|
9
10
|
import MLoader from './components/loader/MLoader.vue';
|
|
10
11
|
import MOverlay from './components/overlay/MOverlay.vue';
|
|
12
|
+
import MPasswordInput from './components/passwordinput/MPasswordInput.vue';
|
|
11
13
|
import MQuantitySelector from './components/quantityselector/MQuantitySelector.vue';
|
|
12
14
|
import MRadio from './components/radio/MRadio.vue';
|
|
13
15
|
import MRadioGroup from './components/radiogroup/MRadioGroup.vue';
|
|
14
16
|
import MSelect from './components/select/MSelect.vue';
|
|
15
17
|
import MStatusBadge from './components/statusbadge/MStatusBadge.vue';
|
|
18
|
+
import MStatusNotification from './components/statusnotification/MStatusNotification.vue';
|
|
16
19
|
import MTextArea from './components/textarea/MTextArea.vue';
|
|
17
20
|
import MTextInput from './components/textinput/MTextInput.vue';
|
|
18
21
|
import MToggle from './components/toggle/MToggle.vue';
|
|
22
|
+
import MToggleGroup from './components/togglegroup/MToggleGroup.vue';
|
|
19
23
|
|
|
20
24
|
export {
|
|
21
25
|
MBadge,
|
|
26
|
+
MBreadcrumb,
|
|
22
27
|
MButton,
|
|
23
28
|
MCheckbox,
|
|
24
29
|
MCheckboxGroup,
|
|
@@ -28,12 +33,15 @@ export {
|
|
|
28
33
|
MLink,
|
|
29
34
|
MLoader,
|
|
30
35
|
MOverlay,
|
|
36
|
+
MPasswordInput,
|
|
31
37
|
MQuantitySelector,
|
|
32
38
|
MRadio,
|
|
33
39
|
MRadioGroup,
|
|
34
40
|
MSelect,
|
|
35
41
|
MStatusBadge,
|
|
42
|
+
MStatusNotification,
|
|
36
43
|
MTextArea,
|
|
37
44
|
MTextInput,
|
|
38
45
|
MToggle,
|
|
46
|
+
MToggleGroup,
|
|
39
47
|
};
|