@mozaic-ds/vue 1.0.0-beta.1 → 1.0.0-beta.4

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.
Files changed (179) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +218 -84
  3. package/dist/mozaic-vue.css +1 -1
  4. package/dist/mozaic-vue.d.ts +920 -0
  5. package/dist/mozaic-vue.js +877 -0
  6. package/dist/mozaic-vue.js.map +1 -0
  7. package/dist/mozaic-vue.umd.cjs +2 -0
  8. package/dist/mozaic-vue.umd.cjs.map +1 -0
  9. package/env.d.ts +1 -0
  10. package/package.json +80 -50
  11. package/src/components/Contributing.mdx +118 -0
  12. package/src/components/GettingStarted.mdx +39 -0
  13. package/src/components/Introduction.mdx +54 -0
  14. package/src/components/Support.mdx +18 -0
  15. package/src/components/badge/MBadge.spec.ts +16 -0
  16. package/src/components/badge/MBadge.stories.ts +50 -0
  17. package/src/components/badge/MBadge.vue +36 -34
  18. package/src/components/button/MButton.spec.ts +191 -0
  19. package/src/components/button/MButton.stories.ts +66 -0
  20. package/src/components/button/MButton.vue +98 -154
  21. package/src/components/checkbox/MCheckbox.spec.ts +104 -0
  22. package/src/components/checkbox/MCheckbox.stories.ts +83 -0
  23. package/src/components/checkbox/MCheckbox.vue +60 -101
  24. package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
  25. package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
  26. package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
  27. package/src/components/field/MField.spec.ts +166 -0
  28. package/src/components/field/MField.stories.ts +376 -0
  29. package/src/components/field/MField.vue +78 -61
  30. package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
  31. package/src/components/fieldgroup/MFieldGroup.stories.ts +274 -0
  32. package/src/components/fieldgroup/MFieldGroup.vue +79 -0
  33. package/src/components/iconbutton/MIconButton.spec.ts +108 -0
  34. package/src/components/iconbutton/MIconButton.stories.ts +66 -0
  35. package/src/components/iconbutton/MIconButton.vue +73 -0
  36. package/src/components/link/MLink.spec.ts +154 -0
  37. package/src/components/link/MLink.stories.ts +98 -0
  38. package/src/components/link/MLink.vue +86 -109
  39. package/src/components/loader/MLoader.spec.ts +104 -0
  40. package/src/components/loader/MLoader.stories.ts +45 -0
  41. package/src/components/loader/MLoader.vue +65 -55
  42. package/src/components/overlay/MOverlay.spec.ts +51 -0
  43. package/src/components/overlay/MOverlay.stories.ts +40 -0
  44. package/src/components/overlay/MOverlay.vue +27 -19
  45. package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
  46. package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
  47. package/src/components/quantityselector/MQuantitySelector.vue +160 -136
  48. package/src/components/radio/MRadio.spec.ts +104 -0
  49. package/src/components/radio/MRadio.stories.ts +68 -0
  50. package/src/components/radio/MRadio.vue +56 -39
  51. package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
  52. package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
  53. package/src/components/radiogroup/MRadioGroup.vue +79 -0
  54. package/src/components/select/MSelect.spec.ts +114 -0
  55. package/src/components/select/MSelect.stories.ts +101 -0
  56. package/src/components/select/MSelect.vue +77 -119
  57. package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
  58. package/src/components/statusbadge/MStatusBadge.vue +40 -0
  59. package/src/components/statusbadge/MStatusDot.vue +32 -0
  60. package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
  61. package/src/components/textarea/MTextArea.spec.ts +112 -0
  62. package/src/components/textarea/MTextArea.stories.ts +67 -0
  63. package/src/components/textarea/MTextArea.vue +81 -42
  64. package/src/components/textinput/MTextInput.spec.ts +121 -0
  65. package/src/components/textinput/MTextInput.stories.ts +114 -0
  66. package/src/components/textinput/MTextInput.vue +127 -47
  67. package/src/components/toggle/MToggle.spec.ts +99 -0
  68. package/src/components/toggle/MToggle.stories.ts +68 -0
  69. package/src/components/toggle/MToggle.vue +63 -103
  70. package/src/components/usingIcons.mdx +43 -0
  71. package/src/components/usingPresets.mdx +125 -0
  72. package/src/main.ts +39 -0
  73. package/dist/demo.html +0 -1
  74. package/dist/mozaic-vue.adeo.css +0 -45
  75. package/dist/mozaic-vue.adeo.umd.js +0 -41775
  76. package/dist/mozaic-vue.common.js +0 -41765
  77. package/dist/mozaic-vue.common.js.map +0 -1
  78. package/dist/mozaic-vue.umd.js +0 -41776
  79. package/dist/mozaic-vue.umd.js.map +0 -1
  80. package/dist/mozaic-vue.umd.min.js +0 -4
  81. package/dist/mozaic-vue.umd.min.js.map +0 -1
  82. package/postinstall.js +0 -3
  83. package/src/components/accordion/MAccordion.vue +0 -128
  84. package/src/components/accordion/index.js +0 -7
  85. package/src/components/autocomplete/MAutocomplete.vue +0 -198
  86. package/src/components/autocomplete/index.js +0 -7
  87. package/src/components/badge/index.js +0 -7
  88. package/src/components/breadcrumb/MBreadcrumb.vue +0 -73
  89. package/src/components/breadcrumb/index.js +0 -7
  90. package/src/components/button/index.js +0 -7
  91. package/src/components/card/MCard.vue +0 -78
  92. package/src/components/card/index.js +0 -7
  93. package/src/components/checkbox/MCheckboxGroup.vue +0 -155
  94. package/src/components/checkbox/index.js +0 -12
  95. package/src/components/container/MContainer.vue +0 -33
  96. package/src/components/container/index.js +0 -7
  97. package/src/components/datatable/MDataTable.vue +0 -651
  98. package/src/components/datatable/MDataTableHeader.vue +0 -55
  99. package/src/components/datatable/MDataTableTop.vue +0 -35
  100. package/src/components/datatable/helpers.js +0 -132
  101. package/src/components/datatable/index.js +0 -12
  102. package/src/components/field/index.js +0 -7
  103. package/src/components/fileuploader/MFileResult.vue +0 -149
  104. package/src/components/fileuploader/MFileUploader.vue +0 -142
  105. package/src/components/fileuploader/index.js +0 -7
  106. package/src/components/flag/MFlag.vue +0 -46
  107. package/src/components/flag/index.js +0 -7
  108. package/src/components/heading/MHeading.vue +0 -75
  109. package/src/components/heading/index.js +0 -7
  110. package/src/components/hero/MHero.vue +0 -93
  111. package/src/components/hero/index.js +0 -7
  112. package/src/components/icon/MIcon.vue +0 -120
  113. package/src/components/icon/index.js +0 -7
  114. package/src/components/index.js +0 -43
  115. package/src/components/layer/MLayer.vue +0 -208
  116. package/src/components/layer/index.js +0 -7
  117. package/src/components/link/index.js +0 -7
  118. package/src/components/listbox/MListBox.vue +0 -106
  119. package/src/components/listbox/index.js +0 -7
  120. package/src/components/loader/index.js +0 -7
  121. package/src/components/modal/MModal.vue +0 -179
  122. package/src/components/modal/index.js +0 -7
  123. package/src/components/notification/MNotification.vue +0 -110
  124. package/src/components/notification/index.js +0 -7
  125. package/src/components/optionbutton/MOptionButton.vue +0 -67
  126. package/src/components/optionbutton/index.js +0 -7
  127. package/src/components/optioncard/MOptionCard.vue +0 -132
  128. package/src/components/optioncard/index.js +0 -7
  129. package/src/components/optiongroup/MOptionGroup.vue +0 -18
  130. package/src/components/optiongroup/index.js +0 -7
  131. package/src/components/overlay/MOverlayLoader.vue +0 -43
  132. package/src/components/overlay/index.js +0 -12
  133. package/src/components/pagination/MPagination.vue +0 -162
  134. package/src/components/pagination/index.js +0 -7
  135. package/src/components/passwordinput/MPasswordInput.vue +0 -96
  136. package/src/components/passwordinput/index.js +0 -7
  137. package/src/components/phonenumber/MPhoneNumber.vue +0 -390
  138. package/src/components/phonenumber/index.js +0 -7
  139. package/src/components/progressbar/MProgress.vue +0 -102
  140. package/src/components/progressbar/index.js +0 -7
  141. package/src/components/quantityselector/index.js +0 -7
  142. package/src/components/radio/MRadioGroup.vue +0 -111
  143. package/src/components/radio/index.js +0 -12
  144. package/src/components/ratingstars/MStarsInput.vue +0 -118
  145. package/src/components/ratingstars/MStarsResult.vue +0 -89
  146. package/src/components/ratingstars/index.js +0 -12
  147. package/src/components/select/index.js +0 -7
  148. package/src/components/stepper/MStepper.vue +0 -70
  149. package/src/components/stepper/index.js +0 -7
  150. package/src/components/tabs/MTab.vue +0 -184
  151. package/src/components/tabs/index.js +0 -7
  152. package/src/components/tags/MTag.vue +0 -173
  153. package/src/components/tags/index.js +0 -7
  154. package/src/components/textarea/index.js +0 -7
  155. package/src/components/textinput/MTextInputField.vue +0 -105
  156. package/src/components/textinput/MTextInputIcon.vue +0 -42
  157. package/src/components/textinput/index.js +0 -7
  158. package/src/components/toggle/index.js +0 -7
  159. package/src/components/tooltip/MTooltip.vue +0 -42
  160. package/src/components/tooltip/index.js +0 -7
  161. package/src/index.js +0 -62
  162. package/src/shims-tsx.d.ts +0 -13
  163. package/src/shims.vue.d.ts +0 -4
  164. package/src/tokens/adeo/android/colors.xml +0 -391
  165. package/src/tokens/adeo/android/font_dimens.xml +0 -18
  166. package/src/tokens/adeo/css/_variables.scss +0 -385
  167. package/src/tokens/adeo/css/root.scss +0 -387
  168. package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -399
  169. package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -411
  170. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -394
  171. package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
  172. package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
  173. package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
  174. package/src/tokens/adeo/js/tokens.js +0 -483
  175. package/src/tokens/adeo/js/tokensObject.js +0 -10354
  176. package/src/tokens/adeo/scss/_tokens.scss +0 -1300
  177. package/src/utils/mozaicClasses.js +0 -16
  178. package/src/utils/theme.validator.js +0 -19
  179. package/types/index.d.ts +0 -100
@@ -1,58 +1,138 @@
1
1
  <template>
2
- <div
3
- v-if="icon"
4
- key="icon-input"
5
- class="mc-left-icon-input"
6
- :class="cssFieldElementClass"
7
- >
8
- <m-text-input-icon :icon="icon" />
9
- <m-text-input-field
10
- ref="mField"
11
- v-bind="[$attrs, $props]"
12
- :class="textInputFieldClass"
13
- v-on="$listeners"
2
+ <div class="mc-text-input" :class="classObject">
3
+ <span v-if="$slots.icon" class="mc-text-input__icon">
4
+ <slot name="icon" />
5
+ </span>
6
+
7
+ <input
8
+ :id="id"
9
+ class="mc-text-input__control"
10
+ :value="modelValue"
11
+ :type="inputType"
12
+ :name="name"
13
+ :placeholder="placeholder"
14
+ :disabled="disabled"
15
+ :aria-invalid="isInvalid"
16
+ :readonly="readonly"
17
+ v-bind="$attrs"
18
+ @input="
19
+ emit('update:modelValue', ($event.target as HTMLInputElement).value)
20
+ "
14
21
  />
15
- </div>
16
22
 
17
- <m-text-input-field
18
- v-else
19
- key="input-only"
20
- ref="mField"
21
- v-bind="[$attrs, $props]"
22
- :class="cssFieldElementClass"
23
- v-on="$listeners"
24
- />
23
+ <div v-if="isClearable && modelValue" class="mc-controls-options">
24
+ <button
25
+ type="button"
26
+ class="mc-controls-options__button"
27
+ @click="clearValue"
28
+ >
29
+ <CrossCircleFilled24
30
+ class="mc-controls-options__icon"
31
+ aria-hidden="true"
32
+ />
33
+ <span class="mc-controls-options__label">{clearLabel}</span>
34
+ </button>
35
+ </div>
36
+ </div>
25
37
  </template>
26
38
 
27
- <script>
28
- import MTextInputField from './MTextInputField.vue';
29
- import MTextInputIcon from './MTextInputIcon.vue';
39
+ <script setup lang="ts">
40
+ import { computed, ref, type VNode } from 'vue';
41
+ import CrossCircleFilled24 from '@mozaic-ds/icons-vue/src/components/CrossCircleFilled24/CrossCircleFilled24.vue';
30
42
 
31
- export default {
32
- name: 'MTextInput',
33
-
34
- components: {
35
- MTextInputField,
36
- MTextInputIcon,
43
+ /**
44
+ * Inputs are used to create input fields with text on a single line. Their states depends on the user interaction or the context.
45
+ */
46
+ const props = withDefaults(
47
+ defineProps<{
48
+ /**
49
+ * A unique identifier for the input element, used to associate the label with the form element.
50
+ */
51
+ id: string;
52
+ /**
53
+ * The name attribute for the input element, typically used for form submission.
54
+ */
55
+ name?: string;
56
+ /**
57
+ * The current value of the input field.
58
+ */
59
+ modelValue?: string | number;
60
+ /**
61
+ * A placeholder text to show in the input when it is empty.
62
+ */
63
+ placeholder?: string;
64
+ /**
65
+ * Defines the type of input
66
+ */
67
+ inputType?:
68
+ | 'date'
69
+ | 'email'
70
+ | 'number'
71
+ | 'password'
72
+ | 'search'
73
+ | 'tel'
74
+ | 'text';
75
+ /**
76
+ * If `true`, applies an invalid state to the input.
77
+ */
78
+ isInvalid?: boolean;
79
+ /**
80
+ * If `true`, disables the input, making it non-interactive.
81
+ */
82
+ disabled?: boolean;
83
+ /**
84
+ * Determines the size of the input
85
+ */
86
+ size?: 's' | 'm';
87
+ /**
88
+ * If `true`, the input is read-only (cannot be edited).
89
+ */
90
+ readonly?: boolean;
91
+ /**
92
+ * If `true`, a clear button will appear when the input has a value.
93
+ */
94
+ isClearable?: boolean;
95
+ /**
96
+ * The label text for the clear button
97
+ */
98
+ clearLabel?: string;
99
+ }>(),
100
+ {
101
+ inputType: 'text',
102
+ size: 'm',
103
+ clearLabel: 'clear content',
37
104
  },
105
+ );
38
106
 
39
- inject: {
40
- cssFieldElementClass: {
41
- default: '',
42
- },
43
- },
107
+ defineSlots<{
108
+ /**
109
+ * Use this slot to insert an icon in the input
110
+ */
111
+ icon?: VNode;
112
+ }>();
44
113
 
45
- inheritAttrs: false,
46
-
47
- props: {
48
- icon: {
49
- type: String,
50
- default: null,
51
- },
52
- textInputFieldClass: {
53
- type: String,
54
- default: null,
55
- },
56
- },
114
+ const classObject = computed(() => {
115
+ return {
116
+ [`mc-text-input--${props.size}`]: props.size && props.size != 'm',
117
+ 'is-invalid': props.isInvalid,
118
+ };
119
+ });
120
+
121
+ const modelValue = ref(props.modelValue);
122
+ const clearValue = () => {
123
+ modelValue.value = '';
124
+ emit('update:modelValue', '');
57
125
  };
126
+
127
+ const emit = defineEmits<{
128
+ /**
129
+ * Emits when the input value changes, updating the `modelValue` prop.
130
+ */
131
+ (on: 'update:modelValue', value: string | number): void;
132
+ }>();
58
133
  </script>
134
+
135
+ <style lang="scss" scoped>
136
+ @use '@mozaic-ds/styles/components/controls-options';
137
+ @use '@mozaic-ds/styles/components/text-input';
138
+ </style>
@@ -0,0 +1,99 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect } from 'vitest';
3
+ import MToggle from './MToggle.vue';
4
+
5
+ describe('MToggle Component', () => {
6
+ it('should render the toggle with default props', () => {
7
+ const wrapper = mount(MToggle, {
8
+ props: {
9
+ id: 'test-toggle',
10
+ },
11
+ });
12
+
13
+ const input = wrapper.find('input');
14
+ expect(input.exists()).toBe(true);
15
+ expect(input.attributes().id).toBe('test-toggle');
16
+ expect(input.classes()).toContain('mc-toggle__input');
17
+ });
18
+
19
+ it('should bind and update modelValue (v-model)', async () => {
20
+ const wrapper = mount(MToggle, {
21
+ props: {
22
+ id: 'test-toggle',
23
+ modelValue: false,
24
+ },
25
+ });
26
+
27
+ const input = wrapper.find('input');
28
+ expect(input.element.checked).toBe(false);
29
+
30
+ await input.setChecked(true);
31
+
32
+ const emittedEvent = wrapper.emitted()['update:modelValue'];
33
+ expect(emittedEvent).toBeDefined();
34
+ expect(emittedEvent![0]).toEqual([true]);
35
+ });
36
+
37
+ it('is disabled when the disabled prop is true', () => {
38
+ const wrapper = mount(MToggle, {
39
+ props: {
40
+ id: 'test-toggle',
41
+ disabled: true,
42
+ },
43
+ });
44
+
45
+ const checkbox = wrapper.find('input');
46
+ expect(checkbox.element.disabled).toBe(true);
47
+ });
48
+
49
+ it('should render the label if provided', () => {
50
+ const wrapper = mount(MToggle, {
51
+ props: {
52
+ id: 'test-toggle',
53
+ label: 'Enable feature',
54
+ },
55
+ });
56
+
57
+ const label = wrapper.find('.mc-toggle__label');
58
+ expect(label.exists()).toBe(true);
59
+ expect(label.text()).toBe('Enable feature');
60
+ });
61
+
62
+ it('should not render the label if not provided', () => {
63
+ const wrapper = mount(MToggle, {
64
+ props: {
65
+ id: 'test-toggle',
66
+ },
67
+ });
68
+
69
+ const label = wrapper.find('.mc-toggle__label');
70
+ expect(label.exists()).toBe(false);
71
+ });
72
+
73
+ it('should apply the correct size class based on the size prop', () => {
74
+ const wrapper = mount(MToggle, {
75
+ props: {
76
+ id: 'test-toggle',
77
+ size: 'm',
78
+ },
79
+ });
80
+
81
+ expect(wrapper.classes()).toContain('mc-toggle--m');
82
+ });
83
+
84
+ it('should emit updated modelValue on toggle change', async () => {
85
+ const wrapper = mount(MToggle, {
86
+ props: {
87
+ id: 'test-toggle',
88
+ modelValue: false,
89
+ },
90
+ });
91
+
92
+ const input = wrapper.find('input');
93
+ await input.setChecked(true);
94
+
95
+ const emittedEvent = wrapper.emitted()['update:modelValue'];
96
+ expect(emittedEvent).toBeDefined();
97
+ expect(emittedEvent![0]).toEqual([true]);
98
+ });
99
+ });
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import { action } from '@storybook/addon-actions';
3
+
4
+ import MToggle from './MToggle.vue';
5
+
6
+ const meta: Meta<typeof MToggle> = {
7
+ title: 'Form Elements/Toggle',
8
+ component: MToggle,
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component:
13
+ '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.',
14
+ },
15
+ },
16
+ },
17
+ args: {
18
+ id: 'ToggleId',
19
+ label: 'Label',
20
+ },
21
+ render: (args) => ({
22
+ components: { MToggle },
23
+ setup() {
24
+ const handleUpdate = action('update:modelValue');
25
+
26
+ return { args, handleUpdate };
27
+ },
28
+ template: `
29
+ <MToggle
30
+ v-bind="args"
31
+ @update:modelValue="handleUpdate"
32
+ />
33
+ `,
34
+ }),
35
+ };
36
+ export default meta;
37
+ type Story = StoryObj<typeof MToggle>;
38
+
39
+ export const Default: Story = {};
40
+
41
+ export const Checked: Story = {
42
+ args: {
43
+ modelValue: true,
44
+ id: 'checkedId',
45
+ },
46
+ };
47
+
48
+ export const Disabled: Story = {
49
+ args: {
50
+ disabled: true,
51
+ id: 'disabledId',
52
+ },
53
+ };
54
+
55
+ export const Size: Story = {
56
+ args: {
57
+ id: 'sizeId',
58
+ size: 's',
59
+ },
60
+ };
61
+
62
+ export const HideLabel: Story = {
63
+ args: {
64
+ id: 'hideLabelId',
65
+ label: undefined,
66
+ ariaLabel: 'Label',
67
+ },
68
+ };
@@ -1,117 +1,77 @@
1
1
  <template>
2
- <div class="mc-toggle" :class="setClasses">
3
- <input
4
- :id="id"
5
- :name="name"
6
- type="checkbox"
7
- class="mc-toggle__input"
8
- :checked="checked"
9
- :disabled="disabled"
10
- @change="$emit('change', $event.target.checked)"
11
- />
12
- <label :for="id" class="mc-toggle__label">
13
- <span class="mc-toggle__content">
2
+ <div class="mc-toggle" :class="classObject">
3
+ <label class="mc-toggle__container" :for="id">
4
+ <input
5
+ :id="id"
6
+ type="checkbox"
7
+ class="mc-toggle__input"
8
+ :name="name"
9
+ :checked="modelValue"
10
+ :disabled="disabled"
11
+ v-bind="$attrs"
12
+ @change="
13
+ emit('update:modelValue', ($event.target as HTMLInputElement).checked)
14
+ "
15
+ />
16
+ <span v-if="label" :for="id" class="mc-toggle__label">
14
17
  {{ label }}
15
- <span
16
- v-if="stateLabelOff && stateLabelOn"
17
- class="mc-toggle__state"
18
- aria-hidden="true"
19
- >
20
- <span class="mc-toggle__off">{{ stateLabelOff }}</span>
21
- <span class="mc-toggle__on">{{ stateLabelOn }}</span>
22
- </span>
23
18
  </span>
24
19
  </label>
25
20
  </div>
26
21
  </template>
27
22
 
28
- <script>
29
- import {
30
- responsiveModifierValidators,
31
- responsiveModifiers,
32
- } from '../../utils/mozaicClasses';
23
+ <script setup lang="ts">
24
+ import { computed } from 'vue';
33
25
 
34
- export default {
35
- name: 'MToggle',
36
-
37
- props: {
38
- id: {
39
- type: String,
40
- required: true,
41
- },
42
- label: {
43
- type: String,
44
- default: null,
45
- },
46
- name: {
47
- type: String,
48
- default: null,
49
- },
50
- checked: {
51
- type: Boolean,
52
- default: false,
53
- },
54
- disabled: {
55
- type: Boolean,
56
- default: false,
57
- },
58
- size: {
59
- type: String,
60
- default: 'm',
61
- validator: (value) => responsiveModifierValidators(value, ['s', 'm']),
62
- },
63
- // Experimental solution waiting on this issue https://github.com/adeo/mozaic-vue/issues/52
64
- responsiveSizeModifiers: {
65
- type: Array,
66
- default: null,
67
- validator: (array) =>
68
- array.every((e) =>
69
- responsiveModifierValidators(e, [
70
- 's@from-m',
71
- 's@from-l',
72
- 's@from-xl',
73
- 's@from-xxl',
74
- 'm@from-m',
75
- 'm@from-l',
76
- 'm@from-xl',
77
- 'm@from-xxl',
78
- ])
79
- ),
80
- },
81
- stateLabelOff: {
82
- type: String,
83
- default: null,
84
- },
85
- stateLabelOn: {
86
- type: String,
87
- default: null,
88
- },
26
+ /**
27
+ * 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.
28
+ */
29
+ const props = withDefaults(
30
+ defineProps<{
31
+ /**
32
+ * A unique identifier for the toggle, used to associate the label with the form element.
33
+ */
34
+ id: string;
35
+ /**
36
+ * The name attribute for the toggle element, typically used for form submission.
37
+ */
38
+ name?: string;
39
+ /**
40
+ * The text label displayed next to the toggle.
41
+ */
42
+ label?: string;
43
+ /**
44
+ * The toggle's checked state, bound via v-model.
45
+ */
46
+ modelValue?: boolean;
47
+ /**
48
+ * Determines the size of the toggle
49
+ */
50
+ size?: 's' | 'm';
51
+ /**
52
+ * If `true`, disables the toggle, making it non-interactive.
53
+ */
54
+ disabled?: boolean;
55
+ }>(),
56
+ {
57
+ size: 's',
89
58
  },
59
+ );
90
60
 
91
- computed: {
92
- setClasses() {
93
- const classes = [];
94
-
95
- if (this.size) {
96
- classes.push(`mc-toggle--${this.size}`);
97
- }
61
+ const classObject = computed(() => {
62
+ return {
63
+ [`mc-toggle--${props.size}`]: props.size && props.size != 's',
64
+ };
65
+ });
98
66
 
99
- if (
100
- this.responsiveSizeModifiers &&
101
- this.responsiveSizeModifiers.length > 0
102
- ) {
103
- for (const modifier of this.responsiveSizeModifiers) {
104
- responsiveModifiers('mc-toggle', modifier, classes);
105
- }
106
- }
107
-
108
- return classes;
109
- },
110
- },
111
- };
67
+ const emit = defineEmits<{
68
+ /**
69
+ * Emits when the toggle value changes, updating the modelValue prop.
70
+ */
71
+ (on: 'update:modelValue', value: boolean): void;
72
+ }>();
112
73
  </script>
113
74
 
114
- <style lang="scss">
115
- @import 'settings-tools/_all-settings';
116
- @import 'components/c.toggle';
75
+ <style lang="scss" scoped>
76
+ @use '@mozaic-ds/styles/components/toggle';
117
77
  </style>
@@ -0,0 +1,43 @@
1
+ import { Meta } from '@storybook/blocks';
2
+ import { Source } from '@storybook/addon-docs';
3
+
4
+ <Meta title="Using Icons" />
5
+
6
+ # Using Icons
7
+
8
+ To use icons in Vue applications, you need to install a dedicated package.
9
+
10
+ You must first install the [npm package](https://www.npmjs.com/package/@mozaic-ds/icons-vue):
11
+
12
+ <Source
13
+ language="bash"
14
+ dark
15
+ code="npm install @mozaic-ds/icons-vue"
16
+ />
17
+
18
+ Or with **Yarn**:
19
+
20
+ <Source
21
+ language="bash"
22
+ dark
23
+ code="yarn add @mozaic-ds/icons-vue"
24
+ />
25
+
26
+ You can then start importing the icon of your choice into your Vue component:
27
+
28
+ <Source
29
+ language='html'
30
+ dark
31
+ code={`
32
+ // In one of the .vue file of your application
33
+
34
+ <template>
35
+ <A11y20 fill="#333" />
36
+ </template>
37
+
38
+ <script setup>
39
+ import A11y20 from '@mozaic-ds/icons-vue/src/components/A11y20/A11y20.vue';
40
+ </script>
41
+ `} />
42
+
43
+ [The full list of icons is available here](https://github.com/adeo/mozaic-icons-vue/tree/main/src/components).