@mozaic-ds/vue 1.0.0-beta.3 → 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.
Files changed (191) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +224 -82
  3. package/dist/mozaic-vue.css +1 -1
  4. package/dist/mozaic-vue.d.ts +1202 -0
  5. package/dist/mozaic-vue.js +1220 -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 +81 -50
  11. package/src/components/Contributing.mdx +118 -0
  12. package/src/components/GettingStarted.mdx +50 -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/breadcrumb/MBreadcrumb.spec.ts +105 -0
  19. package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -0
  20. package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
  21. package/src/components/button/MButton.spec.ts +191 -0
  22. package/src/components/button/MButton.stories.ts +66 -0
  23. package/src/components/button/MButton.vue +98 -154
  24. package/src/components/checkbox/MCheckbox.spec.ts +104 -0
  25. package/src/components/checkbox/MCheckbox.stories.ts +83 -0
  26. package/src/components/checkbox/MCheckbox.vue +60 -101
  27. package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
  28. package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
  29. package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
  30. package/src/components/field/MField.spec.ts +166 -0
  31. package/src/components/field/MField.stories.ts +376 -0
  32. package/src/components/field/MField.vue +78 -61
  33. package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
  34. package/src/components/fieldgroup/MFieldGroup.stories.ts +423 -0
  35. package/src/components/fieldgroup/MFieldGroup.vue +79 -0
  36. package/src/components/iconbutton/MIconButton.spec.ts +108 -0
  37. package/src/components/iconbutton/MIconButton.stories.ts +66 -0
  38. package/src/components/iconbutton/MIconButton.vue +73 -0
  39. package/src/components/link/MLink.spec.ts +154 -0
  40. package/src/components/link/MLink.stories.ts +98 -0
  41. package/src/components/link/MLink.vue +86 -109
  42. package/src/components/loader/MLoader.spec.ts +104 -0
  43. package/src/components/loader/MLoader.stories.ts +45 -0
  44. package/src/components/loader/MLoader.vue +65 -55
  45. package/src/components/overlay/MOverlay.spec.ts +51 -0
  46. package/src/components/overlay/MOverlay.stories.ts +40 -0
  47. package/src/components/overlay/MOverlay.vue +27 -19
  48. package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
  49. package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
  50. package/src/components/passwordinput/MPasswordInput.vue +129 -76
  51. package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
  52. package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
  53. package/src/components/quantityselector/MQuantitySelector.vue +160 -136
  54. package/src/components/radio/MRadio.spec.ts +104 -0
  55. package/src/components/radio/MRadio.stories.ts +68 -0
  56. package/src/components/radio/MRadio.vue +56 -39
  57. package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
  58. package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
  59. package/src/components/radiogroup/MRadioGroup.vue +79 -0
  60. package/src/components/select/MSelect.spec.ts +114 -0
  61. package/src/components/select/MSelect.stories.ts +101 -0
  62. package/src/components/select/MSelect.vue +77 -119
  63. package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
  64. package/src/components/statusbadge/MStatusBadge.vue +40 -0
  65. package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
  66. package/src/components/statusdot/MStatusDot.spec.ts +51 -0
  67. package/src/components/statusdot/MStatusDot.stories.ts +48 -0
  68. package/src/components/statusdot/MStatusDot.vue +36 -0
  69. package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
  70. package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
  71. package/src/components/statusnotification/MStatusNotification.vue +106 -0
  72. package/src/components/textarea/MTextArea.spec.ts +112 -0
  73. package/src/components/textarea/MTextArea.stories.ts +67 -0
  74. package/src/components/textarea/MTextArea.vue +81 -42
  75. package/src/components/textinput/MTextInput.spec.ts +121 -0
  76. package/src/components/textinput/MTextInput.stories.ts +114 -0
  77. package/src/components/textinput/MTextInput.vue +127 -47
  78. package/src/components/toggle/MToggle.spec.ts +99 -0
  79. package/src/components/toggle/MToggle.stories.ts +68 -0
  80. package/src/components/toggle/MToggle.vue +63 -103
  81. package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
  82. package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
  83. package/src/components/togglegroup/MToggleGroup.vue +97 -0
  84. package/src/components/usingIcons.mdx +43 -0
  85. package/src/components/usingPresets.mdx +125 -0
  86. package/src/main.ts +47 -0
  87. package/dist/demo.html +0 -1
  88. package/dist/mozaic-vue.adeo.css +0 -45
  89. package/dist/mozaic-vue.adeo.umd.js +0 -41775
  90. package/dist/mozaic-vue.common.js +0 -41765
  91. package/dist/mozaic-vue.common.js.map +0 -1
  92. package/dist/mozaic-vue.umd.js +0 -41776
  93. package/dist/mozaic-vue.umd.js.map +0 -1
  94. package/dist/mozaic-vue.umd.min.js +0 -4
  95. package/dist/mozaic-vue.umd.min.js.map +0 -1
  96. package/postinstall.js +0 -3
  97. package/src/components/accordion/MAccordion.vue +0 -128
  98. package/src/components/accordion/index.js +0 -7
  99. package/src/components/autocomplete/MAutocomplete.vue +0 -198
  100. package/src/components/autocomplete/index.js +0 -7
  101. package/src/components/badge/index.js +0 -7
  102. package/src/components/breadcrumb/index.js +0 -7
  103. package/src/components/button/index.js +0 -7
  104. package/src/components/card/MCard.vue +0 -78
  105. package/src/components/card/index.js +0 -7
  106. package/src/components/checkbox/MCheckboxGroup.vue +0 -155
  107. package/src/components/checkbox/index.js +0 -12
  108. package/src/components/container/MContainer.vue +0 -33
  109. package/src/components/container/index.js +0 -7
  110. package/src/components/datatable/MDataTable.vue +0 -651
  111. package/src/components/datatable/MDataTableHeader.vue +0 -55
  112. package/src/components/datatable/MDataTableTop.vue +0 -35
  113. package/src/components/datatable/helpers.js +0 -132
  114. package/src/components/datatable/index.js +0 -12
  115. package/src/components/field/index.js +0 -7
  116. package/src/components/fileuploader/MFileResult.vue +0 -149
  117. package/src/components/fileuploader/MFileUploader.vue +0 -142
  118. package/src/components/fileuploader/index.js +0 -7
  119. package/src/components/flag/MFlag.vue +0 -46
  120. package/src/components/flag/index.js +0 -7
  121. package/src/components/heading/MHeading.vue +0 -75
  122. package/src/components/heading/index.js +0 -7
  123. package/src/components/hero/MHero.vue +0 -93
  124. package/src/components/hero/index.js +0 -7
  125. package/src/components/icon/MIcon.vue +0 -120
  126. package/src/components/icon/index.js +0 -7
  127. package/src/components/index.js +0 -43
  128. package/src/components/layer/MLayer.vue +0 -208
  129. package/src/components/layer/index.js +0 -7
  130. package/src/components/link/index.js +0 -7
  131. package/src/components/listbox/MListBox.vue +0 -106
  132. package/src/components/listbox/index.js +0 -7
  133. package/src/components/loader/index.js +0 -7
  134. package/src/components/modal/MModal.vue +0 -179
  135. package/src/components/modal/index.js +0 -7
  136. package/src/components/notification/MNotification.vue +0 -110
  137. package/src/components/notification/index.js +0 -7
  138. package/src/components/optionbutton/MOptionButton.vue +0 -67
  139. package/src/components/optionbutton/index.js +0 -7
  140. package/src/components/optioncard/MOptionCard.vue +0 -132
  141. package/src/components/optioncard/index.js +0 -7
  142. package/src/components/optiongroup/MOptionGroup.vue +0 -18
  143. package/src/components/optiongroup/index.js +0 -7
  144. package/src/components/overlay/MOverlayLoader.vue +0 -43
  145. package/src/components/overlay/index.js +0 -12
  146. package/src/components/pagination/MPagination.vue +0 -162
  147. package/src/components/pagination/index.js +0 -7
  148. package/src/components/passwordinput/index.js +0 -7
  149. package/src/components/phonenumber/MPhoneNumber.vue +0 -390
  150. package/src/components/phonenumber/index.js +0 -7
  151. package/src/components/progressbar/MProgress.vue +0 -102
  152. package/src/components/progressbar/index.js +0 -7
  153. package/src/components/quantityselector/index.js +0 -7
  154. package/src/components/radio/MRadioGroup.vue +0 -111
  155. package/src/components/radio/index.js +0 -12
  156. package/src/components/ratingstars/MStarsInput.vue +0 -118
  157. package/src/components/ratingstars/MStarsResult.vue +0 -89
  158. package/src/components/ratingstars/index.js +0 -12
  159. package/src/components/select/index.js +0 -7
  160. package/src/components/stepper/MStepper.vue +0 -70
  161. package/src/components/stepper/index.js +0 -7
  162. package/src/components/tabs/MTab.vue +0 -184
  163. package/src/components/tabs/index.js +0 -7
  164. package/src/components/tags/MTag.vue +0 -173
  165. package/src/components/tags/index.js +0 -7
  166. package/src/components/textarea/index.js +0 -7
  167. package/src/components/textinput/MTextInputField.vue +0 -105
  168. package/src/components/textinput/MTextInputIcon.vue +0 -42
  169. package/src/components/textinput/index.js +0 -7
  170. package/src/components/toggle/index.js +0 -7
  171. package/src/components/tooltip/MTooltip.vue +0 -42
  172. package/src/components/tooltip/index.js +0 -7
  173. package/src/index.js +0 -62
  174. package/src/shims-tsx.d.ts +0 -13
  175. package/src/shims.vue.d.ts +0 -4
  176. package/src/tokens/adeo/android/colors.xml +0 -391
  177. package/src/tokens/adeo/android/font_dimens.xml +0 -18
  178. package/src/tokens/adeo/css/_variables.scss +0 -385
  179. package/src/tokens/adeo/css/root.scss +0 -387
  180. package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -399
  181. package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -411
  182. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -394
  183. package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
  184. package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
  185. package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
  186. package/src/tokens/adeo/js/tokens.js +0 -483
  187. package/src/tokens/adeo/js/tokensObject.js +0 -10354
  188. package/src/tokens/adeo/scss/_tokens.scss +0 -1300
  189. package/src/utils/mozaicClasses.js +0 -16
  190. package/src/utils/theme.validator.js +0 -19
  191. package/types/index.d.ts +0 -100
@@ -0,0 +1,423 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import { action } from '@storybook/addon-actions';
3
+
4
+ import MFieldGroup from './MFieldGroup.vue';
5
+ import MCheckboxGroup from '../checkboxgroup/MCheckboxGroup.vue';
6
+ import MRadioGroup from '../radiogroup/MRadioGroup.vue';
7
+ import MToggleGroup from '../togglegroup/MToggleGroup.vue';
8
+
9
+ const meta: Meta<typeof MFieldGroup> = {
10
+ title: 'Form Elements/Field Group',
11
+ component: MFieldGroup,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component:
16
+ 'A field label is a text element that identifies the purpose of an input field, providing users with clear guidance on what information to enter. It is typically placed above the input field and may include indicators for required or optional fields. Field Labels improve form usability, accessibility, and data entry accuracy by ensuring users understand the expected input.',
17
+ },
18
+ },
19
+ },
20
+ args: {
21
+ legend: 'Label',
22
+ id: 'ReplaceByInputId',
23
+ requirementText: 'required',
24
+ helpText: 'Help text',
25
+ default: `
26
+ <MCheckboxGroup
27
+ name="checkboxGroupName"
28
+ :options="
29
+ [
30
+ {
31
+ id: 'checkbox-01',
32
+ label: 'checkbox Label',
33
+ value: 'checkbox1',
34
+ },
35
+ {
36
+ id: 'checkbox-02',
37
+ label: 'checkbox Label',
38
+ value: 'checkbox2',
39
+ },
40
+ {
41
+ id: 'checkbox-03',
42
+ label: 'checkbox Label',
43
+ value: 'checkbox3',
44
+ },
45
+ {
46
+ id: 'checkbox-04',
47
+ label: 'checkbox Label',
48
+ value: 'checkbox4',
49
+ },
50
+ ]
51
+ "
52
+ @update:modelValue="handleUpdate"
53
+ />
54
+ `,
55
+ },
56
+ argTypes: {
57
+ $slots: {
58
+ table: {
59
+ disable: true,
60
+ },
61
+ },
62
+ },
63
+ render: (args) => ({
64
+ components: { MFieldGroup, MCheckboxGroup, MRadioGroup, MToggleGroup },
65
+ setup() {
66
+ const handleUpdate = action('update:modelValue');
67
+
68
+ return { args, handleUpdate };
69
+ },
70
+ template: `
71
+ <MFieldGroup v-bind="args">
72
+ ${args.default}
73
+ </MFieldGroup>
74
+ `,
75
+ }),
76
+ };
77
+ export default meta;
78
+ type Story = StoryObj<typeof MFieldGroup>;
79
+
80
+ export const Default: Story = {
81
+ args: {
82
+ legend: 'Label',
83
+ id: 'ReplaceByInputId',
84
+ helpText: 'Help text',
85
+ requirementText: 'optional',
86
+ default: `
87
+ <!-- All the code below must be replaced by a form element. -->
88
+ <div class="content-slot">
89
+ Insert a form element here to replace this slot.
90
+ </div>
91
+ `,
92
+ },
93
+ render: (args) => ({
94
+ components: { MFieldGroup },
95
+ setup() {
96
+ return { args };
97
+ },
98
+ template: `
99
+ <MFieldGroup v-bind="args">
100
+ ${args.default}
101
+ </MFieldGroup>
102
+ `,
103
+ }),
104
+ };
105
+
106
+ export const CheckboxGroup: Story = {};
107
+
108
+ export const CheckboxGroupValid: Story = {
109
+ args: {
110
+ legend: 'Label',
111
+ id: 'ReplaceByInputId',
112
+ requirementText: 'required',
113
+ isValid: true,
114
+ message: 'Validation message (Be concise and use comprehensive words).',
115
+ default: `
116
+ <MCheckboxGroup
117
+ name="checkboxGroupName"
118
+ :options="
119
+ [
120
+ {
121
+ id: 'checkbox-05',
122
+ label: 'checkbox Label',
123
+ value: 'checkbox5',
124
+ },
125
+ {
126
+ id: 'checkbox-06',
127
+ label: 'checkbox Label',
128
+ value: 'checkbox6',
129
+ },
130
+ {
131
+ id: 'checkbox-07',
132
+ label: 'checkbox Label',
133
+ value: 'checkbox7',
134
+ },
135
+ {
136
+ id: 'checkbox-08',
137
+ label: 'checkbox Label',
138
+ value: 'checkbox8',
139
+ },
140
+ ]
141
+ "
142
+ @update:modelValue="handleUpdate"
143
+ />
144
+ `,
145
+ },
146
+ };
147
+
148
+ export const CheckboxGroupInvalid: Story = {
149
+ args: {
150
+ legend: 'Label',
151
+ id: 'ReplaceByInputId',
152
+ requirementText: 'required',
153
+ isInvalid: true,
154
+ message: 'Error message (Be concise and use comprehensive words)',
155
+ default: `
156
+ <MCheckboxGroup
157
+ name="checkboxGroupName"
158
+ isInvalid
159
+ :options="
160
+ [
161
+ {
162
+ id: 'checkbox-09',
163
+ label: 'checkbox Label',
164
+ value: 'checkbox9',
165
+ },
166
+ {
167
+ id: 'checkbox-10',
168
+ label: 'checkbox Label',
169
+ value: 'checkbox10',
170
+ },
171
+ {
172
+ id: 'checkbox-11',
173
+ label: 'checkbox Label',
174
+ value: 'checkbox11',
175
+ },
176
+ {
177
+ id: 'checkbox-12',
178
+ label: 'checkbox Label',
179
+ value: 'checkbox12',
180
+ },
181
+ ]
182
+ "
183
+ @update:modelValue="handleUpdate"
184
+ />
185
+ `,
186
+ },
187
+ };
188
+
189
+ export const RadioGroup: Story = {
190
+ args: {
191
+ legend: 'Label',
192
+ id: 'ReplaceByInputId',
193
+ default: `
194
+ <MRadioGroup
195
+ name="radioGroupName"
196
+ :options="
197
+ [
198
+ {
199
+ id: 'radio-01',
200
+ label: 'Radio button Label',
201
+ value: 'radio1'
202
+ },
203
+ {
204
+ id: 'radio-02',
205
+ label: 'Radio button Label',
206
+ value: 'radio2'
207
+ },
208
+ {
209
+ id: 'radio-03',
210
+ label: 'Radio button Label',
211
+ value: 'radio3'
212
+ },
213
+ {
214
+ id: 'radio-04',
215
+ label: 'Radio button Label',
216
+ value: 'radio4'
217
+ }
218
+ ]
219
+ "
220
+ @update:modelValue="handleUpdate"
221
+ />
222
+ `,
223
+ },
224
+ };
225
+
226
+ export const RadioGroupValid: Story = {
227
+ args: {
228
+ legend: 'Label',
229
+ id: 'ReplaceByInputId',
230
+ requirementText: 'required',
231
+ isValid: true,
232
+ message: 'Validation message (Be concise and use comprehensive words).',
233
+ default: `
234
+ <MRadioGroup
235
+ name="radioGroupValidName"
236
+ :options="
237
+ [
238
+ {
239
+ id: 'radio05',
240
+ label: 'Radio button Label',
241
+ value: 'radio5'
242
+ },
243
+ {
244
+ id: 'radio06',
245
+ label: 'Radio button Label',
246
+ value: 'radio6'
247
+ },
248
+ {
249
+ id: 'radio07',
250
+ label: 'Radio button Label',
251
+ value: 'radio7'
252
+ },
253
+ {
254
+ id: 'radio08',
255
+ label: 'Radio button Label',
256
+ value: 'radio8'
257
+ }
258
+ ]
259
+ "
260
+ @update:modelValue="handleUpdate"
261
+ />
262
+ `,
263
+ },
264
+ };
265
+
266
+ export const RadioGroupInvalid: Story = {
267
+ args: {
268
+ legend: 'Label',
269
+ id: 'ReplaceByInputId',
270
+ requirementText: 'required',
271
+ isInvalid: true,
272
+ message: 'Error message (Be concise and use comprehensive words)',
273
+ default: `
274
+ <MRadioGroup
275
+ name="radioGroupInvalidName"
276
+ isInvalid
277
+ :options="
278
+ [
279
+ {
280
+ id: 'radio-9',
281
+ label: 'Radio button Label',
282
+ value: 'radio9'
283
+ },
284
+ {
285
+ id: 'radio-10',
286
+ label: 'Radio button Label',
287
+ value: 'radio10'
288
+ },
289
+ {
290
+ id: 'radio-11',
291
+ label: 'Radio button Label',
292
+ value: 'radio11'
293
+ },
294
+ {
295
+ id: 'radio-12',
296
+ label: 'Radio button Label',
297
+ value: 'radio12'
298
+ }
299
+ ]
300
+ "
301
+ @update:modelValue="handleUpdate"
302
+ />
303
+ `,
304
+ },
305
+ };
306
+
307
+ export const ToggleGroup: Story = {
308
+ args: {
309
+ legend: 'Label',
310
+ id: 'ToggleGroupId',
311
+ requirementText: 'required',
312
+ default: `
313
+ <MToggleGroup
314
+ name="ToggleGroupName"
315
+ :options="
316
+ [
317
+ {
318
+ id: 'toggle-01',
319
+ label: 'Toggle Label',
320
+ value: 'toggle1',
321
+ },
322
+ {
323
+ id: 'toggle-02',
324
+ label: 'Toggle Label',
325
+ value: 'toggle2',
326
+ },
327
+ {
328
+ id: 'toggle-03',
329
+ label: 'Toggle Label',
330
+ value: 'toggle3',
331
+ },
332
+ {
333
+ id: 'toggle-04',
334
+ label: 'Toggle Label',
335
+ value: 'toggle4',
336
+ },
337
+ ]
338
+ "
339
+ @update:modelValue="handleUpdate"
340
+ />
341
+ `,
342
+ },
343
+ };
344
+
345
+ export const ToggleGroupValid: Story = {
346
+ args: {
347
+ legend: 'Label',
348
+ id: 'ToggleGroupId',
349
+ requirementText: 'required',
350
+ isValid: true,
351
+ message: 'Validation message (Be concise and use comprehensive words).',
352
+ default: `
353
+ <MToggleGroup
354
+ name="ToggleGroupName"
355
+ :options="
356
+ [
357
+ {
358
+ id: 'toggle-05',
359
+ label: 'Toggle Label',
360
+ value: 'toggle5',
361
+ },
362
+ {
363
+ id: 'toggle-06',
364
+ label: 'Toggle Label',
365
+ value: 'toggle6',
366
+ },
367
+ {
368
+ id: 'toggle-07',
369
+ label: 'Toggle Label',
370
+ value: 'toggle7',
371
+ },
372
+ {
373
+ id: 'toggle-08',
374
+ label: 'Toggle Label',
375
+ value: 'toggle8',
376
+ },
377
+ ]
378
+ "
379
+ @update:modelValue="handleUpdate"
380
+ />
381
+ `,
382
+ },
383
+ };
384
+
385
+ export const ToggleGroupInvalid: Story = {
386
+ args: {
387
+ legend: 'Label',
388
+ id: 'ToggleGroupId',
389
+ requirementText: 'required',
390
+ isInvalid: true,
391
+ message: 'Error message (Be concise and use comprehensive words)',
392
+ default: `
393
+ <MToggleGroup
394
+ name="ToggleGroupName"
395
+ :options="
396
+ [
397
+ {
398
+ id: 'toggle-09',
399
+ label: 'Toggle Label',
400
+ value: 'toggle9',
401
+ },
402
+ {
403
+ id: 'toggle-10',
404
+ label: 'Toggle Label',
405
+ value: 'toggle10',
406
+ },
407
+ {
408
+ id: 'toggle-11',
409
+ label: 'Toggle Label',
410
+ value: 'toggle11',
411
+ },
412
+ {
413
+ id: 'toggle-12',
414
+ label: 'Toggle Label',
415
+ value: 'toggle12',
416
+ },
417
+ ]
418
+ "
419
+ @update:modelValue="handleUpdate"
420
+ />
421
+ `,
422
+ },
423
+ };
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <fieldset class="mc-field--group">
3
+ <legend class="mc-field__legend" :for="id">
4
+ {{ legend }}
5
+ <span v-if="requirementText" class="mc-field__requirement"
6
+ >({{ requirementText }})</span
7
+ >
8
+ </legend>
9
+
10
+ <span v-if="helpText" class="mc-field__help">{{ helpText }}</span>
11
+
12
+ <div class="mc-field__content">
13
+ <slot />
14
+ </div>
15
+
16
+ <span
17
+ v-if="(isValid || isInvalid) && message"
18
+ class="mc-field__validation-message"
19
+ :class="classObjectValidation"
20
+ >
21
+ {{ message }}
22
+ </span>
23
+ </fieldset>
24
+ </template>
25
+
26
+ <script setup lang="ts">
27
+ import { computed, type VNode } from 'vue';
28
+ /**
29
+ * This component creates a structured form field for group field such as Radio Group, Checkbox Group or Toggle Group with a label, optional help text, error and validation message handling.
30
+ */
31
+ const props = defineProps<{
32
+ /**
33
+ * A unique identifier for the form field, used to associate the label with the form element.
34
+ */
35
+ id: string;
36
+ /**
37
+ * The text displayed as the legend for the form fieldset.
38
+ */
39
+ legend: string;
40
+ /**
41
+ * Additional text displayed alongside the label, typically used to indicate if the form field is required or optional
42
+ */
43
+ requirementText?: string;
44
+ /**
45
+ * Text shown below the form field to provide additional context or instructions for the user.
46
+ */
47
+ helpText?: string;
48
+ /**
49
+ * If `true`, applies a valid state to the form field.
50
+ */
51
+ isValid?: boolean;
52
+ /**
53
+ * If `true`, applies an invalid state to the form field.
54
+ */
55
+ isInvalid?: boolean;
56
+ /**
57
+ * message displayed when the form field has a valid or invalid state, usually indicating validation or errors.
58
+ */
59
+ message?: string;
60
+ }>();
61
+
62
+ defineSlots<{
63
+ /**
64
+ * Use this slot to insert the form element of your choice
65
+ */
66
+ default: VNode;
67
+ }>();
68
+
69
+ const classObjectValidation = computed(() => {
70
+ return {
71
+ 'is-valid': props.isValid,
72
+ 'is-invalid': props.isInvalid,
73
+ };
74
+ });
75
+ </script>
76
+
77
+ <style lang="scss" scoped>
78
+ @use '@mozaic-ds/styles/components/field';
79
+ </style>
@@ -0,0 +1,108 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect } from 'vitest';
3
+ import MIconButton from './MIconButton.vue';
4
+ import ChevronRight24 from '@mozaic-ds/icons-vue/src/components/ChevronRight24/ChevronRight24.vue';
5
+
6
+ describe('MButton component', () => {
7
+ it('renders with an icon', () => {
8
+ const wrapper = mount(MIconButton, {
9
+ slots: {
10
+ icon: [ChevronRight24],
11
+ },
12
+ });
13
+
14
+ const icon = wrapper.findComponent(ChevronRight24);
15
+ expect(icon.exists()).toBe(true);
16
+ });
17
+
18
+ it('applies the correct appearance class based on the appearance prop', () => {
19
+ const wrapper = mount(MIconButton, {
20
+ props: {
21
+ appearance: 'accent',
22
+ },
23
+ slots: {
24
+ icon: [ChevronRight24],
25
+ },
26
+ });
27
+
28
+ expect(wrapper.classes()).toContain('mc-button--accent');
29
+ });
30
+
31
+ it('applies the correct size class based on the size prop', () => {
32
+ const wrapper = mount(MIconButton, {
33
+ props: {
34
+ size: 'l',
35
+ },
36
+ slots: {
37
+ icon: [ChevronRight24],
38
+ },
39
+ });
40
+
41
+ expect(wrapper.classes()).toContain('mc-button--l');
42
+ });
43
+
44
+ it('disables the button when the disabled prop is true', async () => {
45
+ const wrapper = mount(MIconButton, {
46
+ props: {
47
+ disabled: true,
48
+ },
49
+ slots: {
50
+ icon: [ChevronRight24],
51
+ },
52
+ });
53
+
54
+ const button = wrapper.find('button');
55
+ expect(button.attributes('disabled')).toBeDefined();
56
+ });
57
+
58
+ it('applies the correct ghost class when ghost prop is true', () => {
59
+ const wrapper = mount(MIconButton, {
60
+ props: {
61
+ ghost: true,
62
+ },
63
+ slots: {
64
+ icon: [ChevronRight24],
65
+ },
66
+ });
67
+
68
+ expect(wrapper.classes()).toContain('mc-button--ghost');
69
+ });
70
+
71
+ it('applies the outlined class when outlined prop is true', () => {
72
+ const wrapper = mount(MIconButton, {
73
+ props: {
74
+ outlined: true,
75
+ },
76
+ slots: {
77
+ icon: [ChevronRight24],
78
+ },
79
+ });
80
+
81
+ expect(wrapper.classes()).toContain('mc-button--outlined');
82
+ });
83
+
84
+ it('has type="button" by default', () => {
85
+ const wrapper = mount(MIconButton, {
86
+ slots: {
87
+ icon: [ChevronRight24],
88
+ },
89
+ });
90
+
91
+ const button = wrapper.find('button');
92
+ expect(button.attributes('type')).toBe('button');
93
+ });
94
+
95
+ it('can have type="submit" when the type prop is "submit"', () => {
96
+ const wrapper = mount(MIconButton, {
97
+ props: {
98
+ type: 'submit',
99
+ },
100
+ slots: {
101
+ icon: [ChevronRight24],
102
+ },
103
+ });
104
+
105
+ const button = wrapper.find('button');
106
+ expect(button.attributes('type')).toBe('submit');
107
+ });
108
+ });
@@ -0,0 +1,66 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+
3
+ import MIconButton from './MIconButton.vue';
4
+ import ChevronRight24 from '@mozaic-ds/icons-vue/src/components/ChevronRight24/ChevronRight24.vue';
5
+
6
+ const meta: Meta<typeof MIconButton> = {
7
+ title: 'Action/Icon Button',
8
+ component: MIconButton,
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component:
13
+ 'Buttons are key interactive elements used to perform actions and can be used as standalone element, or as part of another component. Their appearance depends on the type of action required from the user and the context in which they are used.',
14
+ },
15
+ },
16
+ },
17
+ args: {
18
+ icon: '<ChevronRight24/>',
19
+ ariaLabel: 'Go to next page',
20
+ },
21
+ argTypes: {
22
+ ariaLabel: {
23
+ table: {
24
+ disable: true,
25
+ },
26
+ },
27
+ $slots: {
28
+ table: {
29
+ disable: true,
30
+ },
31
+ },
32
+ },
33
+ render: (args) => ({
34
+ components: { MIconButton, ChevronRight24 },
35
+ setup() {
36
+ return { args };
37
+ },
38
+ template: `
39
+ <MIconButton
40
+ v-bind="args"
41
+ >
42
+ <template v-if="${'icon' in args}" v-slot:icon>${args.icon}</template>
43
+ </MIconButton>
44
+ `,
45
+ }),
46
+ };
47
+ export default meta;
48
+ type Story = StoryObj<typeof MIconButton>;
49
+
50
+ export const Standard: Story = {};
51
+
52
+ export const Outline: Story = {
53
+ args: { outlined: true },
54
+ };
55
+
56
+ export const Ghost: Story = {
57
+ args: { ghost: true },
58
+ };
59
+
60
+ export const SizeS: Story = {
61
+ args: { size: 's' },
62
+ };
63
+
64
+ export const SizeL: Story = {
65
+ args: { size: 'l' },
66
+ };