@mozaic-ds/vue 1.0.0-rc.2 → 2.1.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.
Files changed (222) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +76 -77
  3. package/dist/mozaic-vue.css +1 -1
  4. package/dist/mozaic-vue.d.ts +1664 -0
  5. package/dist/mozaic-vue.js +1943 -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 +78 -51
  11. package/src/components/Contributing.mdx +118 -0
  12. package/src/components/GettingStarted.mdx +45 -0
  13. package/src/components/Introduction.mdx +100 -0
  14. package/src/components/Support.mdx +18 -0
  15. package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
  16. package/src/components/breadcrumb/MBreadcrumb.stories.ts +82 -0
  17. package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
  18. package/src/components/button/MButton.spec.ts +191 -0
  19. package/src/components/button/MButton.stories.ts +59 -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/datepicker/MDatepicker.spec.ts +95 -0
  28. package/src/components/datepicker/MDatepicker.stories.ts +75 -0
  29. package/src/components/datepicker/MDatepicker.vue +114 -0
  30. package/src/components/divider/MDivider.spec.ts +57 -0
  31. package/src/components/divider/MDivider.stories.ts +64 -0
  32. package/src/components/divider/MDivider.vue +56 -0
  33. package/src/components/drawer/MDrawer.spec.ts +100 -0
  34. package/src/components/drawer/MDrawer.stories.ts +128 -0
  35. package/src/components/drawer/MDrawer.vue +140 -0
  36. package/src/components/field/MField.spec.ts +166 -0
  37. package/src/components/field/MField.stories.ts +369 -0
  38. package/src/components/field/MField.vue +78 -61
  39. package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
  40. package/src/components/fieldgroup/MFieldGroup.stories.ts +416 -0
  41. package/src/components/fieldgroup/MFieldGroup.vue +79 -0
  42. package/src/components/flag/MFlag.spec.ts +46 -0
  43. package/src/components/flag/MFlag.stories.ts +46 -0
  44. package/src/components/flag/MFlag.vue +28 -39
  45. package/src/components/iconbutton/MIconButton.spec.ts +108 -0
  46. package/src/components/iconbutton/MIconButton.stories.ts +74 -0
  47. package/src/components/iconbutton/MIconButton.vue +73 -0
  48. package/src/components/link/MLink.spec.ts +154 -0
  49. package/src/components/link/MLink.stories.ts +89 -0
  50. package/src/components/link/MLink.vue +86 -120
  51. package/src/components/loader/MLoader.spec.ts +104 -0
  52. package/src/components/loader/MLoader.stories.ts +43 -0
  53. package/src/components/loader/MLoader.vue +66 -55
  54. package/src/components/loadingoverlay/MLoadingOverlay.spec.ts +37 -0
  55. package/src/components/loadingoverlay/MLoadingOverlay.stories.ts +40 -0
  56. package/src/components/loadingoverlay/MLoadingOverlay.vue +28 -0
  57. package/src/components/modal/MModal.spec.ts +103 -0
  58. package/src/components/modal/MModal.stories.ts +127 -0
  59. package/src/components/modal/MModal.vue +106 -154
  60. package/src/components/numberbadge/MNumberBadge.spec.ts +56 -0
  61. package/src/components/numberbadge/MNumberBadge.stories.ts +48 -0
  62. package/src/components/numberbadge/MNumberBadge.vue +45 -0
  63. package/src/components/overlay/MOverlay.spec.ts +51 -0
  64. package/src/components/overlay/MOverlay.stories.ts +35 -0
  65. package/src/components/overlay/MOverlay.vue +27 -19
  66. package/src/components/pagination/MPagination.spec.ts +123 -0
  67. package/src/components/pagination/MPagination.stories.ts +83 -0
  68. package/src/components/pagination/MPagination.vue +120 -140
  69. package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
  70. package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
  71. package/src/components/passwordinput/MPasswordInput.vue +126 -77
  72. package/src/components/pincode/MPincode.spec.ts +126 -0
  73. package/src/components/pincode/MPincode.stories.ts +68 -0
  74. package/src/components/pincode/MPincode.vue +148 -0
  75. package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
  76. package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
  77. package/src/components/quantityselector/MQuantitySelector.vue +159 -148
  78. package/src/components/radio/MRadio.spec.ts +104 -0
  79. package/src/components/radio/MRadio.stories.ts +68 -0
  80. package/src/components/radio/MRadio.vue +56 -39
  81. package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
  82. package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
  83. package/src/components/radiogroup/MRadioGroup.vue +79 -0
  84. package/src/components/select/MSelect.spec.ts +114 -0
  85. package/src/components/select/MSelect.stories.ts +101 -0
  86. package/src/components/select/MSelect.vue +77 -119
  87. package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
  88. package/src/components/statusbadge/MStatusBadge.vue +40 -0
  89. package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
  90. package/src/components/statusdot/MStatusDot.spec.ts +51 -0
  91. package/src/components/statusdot/MStatusDot.stories.ts +48 -0
  92. package/src/components/statusdot/MStatusDot.vue +36 -0
  93. package/src/components/statusnotification/MStatusNotification.spec.ts +103 -0
  94. package/src/components/statusnotification/MStatusNotification.stories.ts +89 -0
  95. package/src/components/statusnotification/MStatusNotification.vue +106 -0
  96. package/src/components/tabs/MTabs.stories.ts +104 -0
  97. package/src/components/tabs/MTabs.vue +113 -0
  98. package/src/components/tabs/Mtabs.spec.ts +149 -0
  99. package/src/components/tag/MTag.spec.ts +107 -0
  100. package/src/components/tag/MTag.stories.ts +75 -0
  101. package/src/components/tag/MTag.vue +151 -0
  102. package/src/components/textarea/MTextArea.spec.ts +112 -0
  103. package/src/components/textarea/MTextArea.stories.ts +67 -0
  104. package/src/components/textarea/MTextArea.vue +81 -43
  105. package/src/components/textinput/MTextInput.spec.ts +121 -0
  106. package/src/components/textinput/MTextInput.stories.ts +107 -0
  107. package/src/components/textinput/MTextInput.vue +127 -47
  108. package/src/components/toggle/MToggle.spec.ts +99 -0
  109. package/src/components/toggle/MToggle.stories.ts +68 -0
  110. package/src/components/toggle/MToggle.vue +63 -103
  111. package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
  112. package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
  113. package/src/components/togglegroup/MToggleGroup.vue +97 -0
  114. package/src/components/usingIcons.mdx +35 -0
  115. package/src/components/usingPresets.mdx +128 -0
  116. package/src/main.ts +32 -0
  117. package/dist/demo.html +0 -1
  118. package/dist/mozaic-vue.adeo.css +0 -47
  119. package/dist/mozaic-vue.adeo.umd.js +0 -31109
  120. package/dist/mozaic-vue.common.js +0 -31099
  121. package/dist/mozaic-vue.common.js.map +0 -1
  122. package/dist/mozaic-vue.umd.js +0 -31110
  123. package/dist/mozaic-vue.umd.js.map +0 -1
  124. package/dist/mozaic-vue.umd.min.js +0 -4
  125. package/dist/mozaic-vue.umd.min.js.map +0 -1
  126. package/postinstall.js +0 -3
  127. package/src/components/accordion/MAccordion.vue +0 -128
  128. package/src/components/accordion/index.js +0 -7
  129. package/src/components/autocomplete/MAutocomplete.vue +0 -381
  130. package/src/components/autocomplete/index.js +0 -7
  131. package/src/components/badge/MBadge.vue +0 -43
  132. package/src/components/badge/index.js +0 -7
  133. package/src/components/breadcrumb/index.js +0 -7
  134. package/src/components/button/index.js +0 -7
  135. package/src/components/card/MCard.vue +0 -78
  136. package/src/components/card/index.js +0 -7
  137. package/src/components/checkbox/MCheckboxGroup.vue +0 -163
  138. package/src/components/checkbox/index.js +0 -12
  139. package/src/components/container/MContainer.vue +0 -33
  140. package/src/components/container/index.js +0 -7
  141. package/src/components/datatable/MDataTable.vue +0 -651
  142. package/src/components/datatable/MDataTableHeader.vue +0 -55
  143. package/src/components/datatable/MDataTableTop.vue +0 -35
  144. package/src/components/datatable/helpers.js +0 -132
  145. package/src/components/datatable/index.js +0 -12
  146. package/src/components/dropdown/MDropdown.vue +0 -317
  147. package/src/components/dropdown/index.js +0 -7
  148. package/src/components/field/index.js +0 -7
  149. package/src/components/fileuploader/MFileResult.vue +0 -149
  150. package/src/components/fileuploader/MFileUploader.vue +0 -142
  151. package/src/components/fileuploader/index.js +0 -7
  152. package/src/components/flag/index.js +0 -7
  153. package/src/components/heading/MHeading.vue +0 -75
  154. package/src/components/heading/index.js +0 -7
  155. package/src/components/hero/MHero.vue +0 -93
  156. package/src/components/hero/index.js +0 -7
  157. package/src/components/icon/MIcon.vue +0 -136
  158. package/src/components/icon/index.js +0 -7
  159. package/src/components/index.js +0 -44
  160. package/src/components/layer/MLayer.vue +0 -208
  161. package/src/components/layer/index.js +0 -7
  162. package/src/components/link/index.js +0 -7
  163. package/src/components/listbox/MListBox.vue +0 -146
  164. package/src/components/listbox/MListBoxActions.vue +0 -251
  165. package/src/components/listbox/index.js +0 -12
  166. package/src/components/loader/index.js +0 -7
  167. package/src/components/modal/index.js +0 -7
  168. package/src/components/notification/MNotification.vue +0 -110
  169. package/src/components/notification/index.js +0 -7
  170. package/src/components/optionbutton/MOptionButton.vue +0 -67
  171. package/src/components/optionbutton/index.js +0 -7
  172. package/src/components/optioncard/MOptionCard.vue +0 -132
  173. package/src/components/optioncard/index.js +0 -7
  174. package/src/components/optiongroup/MOptionGroup.vue +0 -18
  175. package/src/components/optiongroup/index.js +0 -7
  176. package/src/components/overlay/MOverlayLoader.vue +0 -43
  177. package/src/components/overlay/index.js +0 -12
  178. package/src/components/pagination/index.js +0 -7
  179. package/src/components/passwordinput/index.js +0 -7
  180. package/src/components/phonenumber/MPhoneNumber.vue +0 -398
  181. package/src/components/phonenumber/index.js +0 -7
  182. package/src/components/progressbar/MProgress.vue +0 -102
  183. package/src/components/progressbar/index.js +0 -7
  184. package/src/components/quantityselector/index.js +0 -7
  185. package/src/components/radio/MRadioGroup.vue +0 -111
  186. package/src/components/radio/index.js +0 -12
  187. package/src/components/ratingstars/MStarsInput.vue +0 -119
  188. package/src/components/ratingstars/MStarsResult.vue +0 -89
  189. package/src/components/ratingstars/index.js +0 -12
  190. package/src/components/select/index.js +0 -7
  191. package/src/components/stepper/MStepper.vue +0 -111
  192. package/src/components/stepper/index.js +0 -7
  193. package/src/components/tabs/MTab.vue +0 -198
  194. package/src/components/tabs/index.js +0 -7
  195. package/src/components/tags/MTag.vue +0 -173
  196. package/src/components/tags/index.js +0 -7
  197. package/src/components/textarea/index.js +0 -7
  198. package/src/components/textinput/MTextInputField.vue +0 -105
  199. package/src/components/textinput/MTextInputIcon.vue +0 -42
  200. package/src/components/textinput/index.js +0 -7
  201. package/src/components/toggle/index.js +0 -7
  202. package/src/components/tooltip/MTooltip.vue +0 -42
  203. package/src/components/tooltip/index.js +0 -7
  204. package/src/index.js +0 -63
  205. package/src/shims-tsx.d.ts +0 -13
  206. package/src/shims.vue.d.ts +0 -4
  207. package/src/tokens/adeo/android/colors.xml +0 -448
  208. package/src/tokens/adeo/android/font_dimens.xml +0 -18
  209. package/src/tokens/adeo/css/_variables.scss +0 -442
  210. package/src/tokens/adeo/css/root.scss +0 -444
  211. package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -456
  212. package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -468
  213. package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -451
  214. package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
  215. package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
  216. package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
  217. package/src/tokens/adeo/js/tokens.js +0 -540
  218. package/src/tokens/adeo/js/tokensObject.js +0 -11641
  219. package/src/tokens/adeo/scss/_tokens.scss +0 -1514
  220. package/src/utils/mozaicClasses.js +0 -16
  221. package/src/utils/theme.validator.js +0 -19
  222. package/types/index.d.ts +0 -104
@@ -0,0 +1,57 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, it, expect } from 'vitest';
3
+ import MDivider from './MDivider.vue';
4
+
5
+ describe('MDivider component', () => {
6
+ it('renders correctly with default props', () => {
7
+ const wrapper = mount(MDivider);
8
+ expect(wrapper.classes()).toContain('mc-divider');
9
+
10
+ const innerDiv = wrapper.find('.mc-divider > div');
11
+ expect(innerDiv.classes()).toContain('mc-divider-horizontal');
12
+ });
13
+
14
+ it('renders with vertical orientation', () => {
15
+ const wrapper = mount(MDivider, {
16
+ props: { orientation: 'vertical' },
17
+ });
18
+ const innerDiv = wrapper.find('.mc-divider > div');
19
+ expect(innerDiv.classes()).toContain('mc-divider-vertical');
20
+ });
21
+
22
+ it('applies the correct style class', () => {
23
+ const wrapper = mount(MDivider, {
24
+ props: { style: 'secondary' },
25
+ });
26
+ const innerDiv = wrapper.find('.mc-divider > div');
27
+ expect(innerDiv.classes()).toContain('mc-divider-horizontal--secondary');
28
+ });
29
+
30
+ it('applies the correct size class', () => {
31
+ const wrapper = mount(MDivider, {
32
+ props: { size: 'm' },
33
+ });
34
+ const innerDiv = wrapper.find('.mc-divider > div');
35
+ expect(innerDiv.classes()).toContain('mc-divider-horizontal--m');
36
+ });
37
+
38
+ it('uses default props when none are provided', () => {
39
+ const wrapper = mount(MDivider);
40
+ expect(wrapper.props().orientation).toBe('horizontal');
41
+ expect(wrapper.props().style).toBe('primary');
42
+ expect(wrapper.props().size).toBe('s');
43
+ });
44
+
45
+ it('handles custom props correctly', () => {
46
+ const wrapper = mount(MDivider, {
47
+ props: {
48
+ orientation: 'vertical',
49
+ style: 'tertiary',
50
+ size: 'l',
51
+ },
52
+ });
53
+ expect(wrapper.props().orientation).toBe('vertical');
54
+ expect(wrapper.props().style).toBe('tertiary');
55
+ expect(wrapper.props().size).toBe('l');
56
+ });
57
+ });
@@ -0,0 +1,64 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import MDivider from './MDivider.vue';
3
+
4
+ const meta: Meta<typeof MDivider> = {
5
+ title: 'Structure/Divider',
6
+ component: MDivider,
7
+ argTypes: {
8
+ orientation: {
9
+ control: 'radio',
10
+ options: ['horizontal', 'vertical'],
11
+ },
12
+ style: {
13
+ control: 'radio',
14
+ options: ['primary', 'secondary', 'tertiary', 'inverse'],
15
+ },
16
+ size: {
17
+ control: 'radio',
18
+ options: ['s', 'm', 'l'],
19
+ },
20
+ },
21
+ render: (args) => ({
22
+ components: { MDivider },
23
+ setup() {
24
+ return { args };
25
+ },
26
+ template: `
27
+ <div>
28
+ <MDivider v-bind="args"></MDivider>
29
+ <p style="padding: 1rem">Horizontal Divider</p>
30
+ </div>
31
+ `,
32
+ }),
33
+ };
34
+ export default meta;
35
+ type Story = StoryObj<typeof MDivider>;
36
+
37
+ export const Standard: Story = {};
38
+
39
+ export const Vertical: Story = {
40
+ args: {
41
+ orientation: 'vertical',
42
+ },
43
+ render: (args) => ({
44
+ components: { MDivider },
45
+ setup() {
46
+ return { args };
47
+ },
48
+ template: `
49
+ <div>
50
+ <MDivider v-bind="args">
51
+ <p style="padding: 1rem">Vertical Divider</p>
52
+ </MDivider>
53
+ </div>
54
+ `,
55
+ }),
56
+ };
57
+
58
+ export const Size: Story = {
59
+ args: { size: 'm' },
60
+ };
61
+
62
+ export const Secondary: Story = {
63
+ args: { style: 'secondary' },
64
+ };
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div class="mc-divider">
3
+ <div :class="classObject"></div>
4
+ <slot />
5
+ </div>
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import { computed } from 'vue';
10
+ /**
11
+ * A Divider serves as a visual divider to separate content, providing a clear distinction between sections.
12
+ */
13
+ const props = withDefaults(
14
+ defineProps<{
15
+ /**
16
+ * Determines the orientation of the divider
17
+ */
18
+ orientation?: 'vertical' | 'horizontal';
19
+ /**
20
+ * Determines the style of the divider
21
+ */
22
+ style?: 'primary' | 'secondary' | 'tertiary' | 'inverse';
23
+ /**
24
+ * Determines the size of the divider
25
+ */
26
+ size?: 's' | 'm' | 'l';
27
+ }>(),
28
+ {
29
+ orientation: 'horizontal',
30
+ style: 'primary',
31
+ size: 's',
32
+ },
33
+ );
34
+
35
+ const classObject = computed(() => {
36
+ return {
37
+ [`mc-divider-${props.orientation}`]: props.orientation,
38
+ [`mc-divider-horizontal--${props.style}`]:
39
+ props.style && props.style != 'primary',
40
+ [`mc-divider-horizontal--${props.size}`]: props.size && props.size != 's',
41
+ };
42
+ });
43
+ </script>
44
+
45
+ <style lang="scss" scoped>
46
+ @use '@mozaic-ds/styles/components/divider';
47
+
48
+ .mc-divider-vertical {
49
+ content: '';
50
+ display: block;
51
+ height: 100%;
52
+ position: absolute;
53
+ top: 50%;
54
+ transform: translateY(-50%);
55
+ }
56
+ </style>
@@ -0,0 +1,100 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import MDrawer from '@/components/drawer/MDrawer.vue';
4
+
5
+ describe('MDrawer component', () => {
6
+ it('renders title and contentTitle when provided', () => {
7
+ const wrapper = mount(MDrawer, {
8
+ props: {
9
+ open: true,
10
+ title: 'Main Drawer Title',
11
+ contentTitle: 'Drawer Content Title',
12
+ },
13
+ slots: {
14
+ default: '<p>Drawer content</p>',
15
+ },
16
+ });
17
+
18
+ expect(wrapper.find('.mc-drawer__title').text()).toBe('Main Drawer Title');
19
+ expect(wrapper.find('.mc-drawer__content__title').text()).toBe(
20
+ 'Drawer Content Title',
21
+ );
22
+ expect(wrapper.find('.mc-drawer__content').text()).toContain(
23
+ 'Drawer content',
24
+ );
25
+ });
26
+
27
+ it('emits update:open false when close button is clicked', async () => {
28
+ const wrapper = mount(MDrawer, {
29
+ props: {
30
+ open: true,
31
+ title: 'Test Title',
32
+ },
33
+ });
34
+
35
+ const closeButton = wrapper.find('.mc-drawer__close');
36
+ await closeButton.trigger('click');
37
+
38
+ expect(wrapper.emitted('update:open')).toBeTruthy();
39
+ expect(wrapper.emitted('update:open')![0]).toEqual([false]);
40
+ });
41
+
42
+ it('emits back event when back button is clicked', async () => {
43
+ const wrapper = mount(MDrawer, {
44
+ props: {
45
+ open: true,
46
+ title: 'Test Title',
47
+ back: true,
48
+ },
49
+ });
50
+
51
+ const backButton = wrapper.find('.mc-drawer__back');
52
+ await backButton.trigger('click');
53
+
54
+ expect(wrapper.emitted('back')).toBeTruthy();
55
+ });
56
+
57
+ it('renders footer slot when provided', () => {
58
+ const wrapper = mount(MDrawer, {
59
+ props: {
60
+ open: true,
61
+ title: 'Test Title',
62
+ },
63
+ slots: {
64
+ footer: '<button>Footer Button</button>',
65
+ },
66
+ });
67
+
68
+ expect(wrapper.find('.mc-drawer__footer').exists()).toBe(true);
69
+ expect(wrapper.find('.mc-drawer__footer button').text()).toBe(
70
+ 'Footer Button',
71
+ );
72
+ });
73
+
74
+ it('applies correct class when extended and position is left', () => {
75
+ const wrapper = mount(MDrawer, {
76
+ props: {
77
+ open: true,
78
+ title: 'Test Title',
79
+ extended: true,
80
+ position: 'left',
81
+ },
82
+ });
83
+
84
+ const section = wrapper.find('section.mc-drawer');
85
+ expect(section.classes()).toContain('mc-drawer--extend');
86
+ expect(section.classes()).toContain('mc-drawer--left');
87
+ expect(section.classes()).toContain('is-open');
88
+ });
89
+
90
+ it('does not render back button if prop `back` is false', () => {
91
+ const wrapper = mount(MDrawer, {
92
+ props: {
93
+ open: true,
94
+ title: 'Test Title',
95
+ },
96
+ });
97
+
98
+ expect(wrapper.find('.mc-drawer__back').exists()).toBe(false);
99
+ });
100
+ });
@@ -0,0 +1,128 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { action } from 'storybook/actions';
3
+ import MDrawer from './MDrawer.vue';
4
+ import MButton from '../button/MButton.vue';
5
+ import { ref, watch } from 'vue';
6
+
7
+ const meta: Meta<typeof MDrawer> = {
8
+ title: 'Overlay/Drawer',
9
+ component: MDrawer,
10
+ parameters: {
11
+ layout: 'fullscreen',
12
+ docs: {
13
+ story: { height: '600px' },
14
+ description: {
15
+ component:
16
+ 'A drawer is a sliding panel that appears from the side of the screen, providing additional content, settings, or actions without disrupting the main view. It is often used for filtering options, or contextual details. It enhances usability by keeping interfaces clean while offering expandable functionality.',
17
+ },
18
+ },
19
+ },
20
+ args: {
21
+ open: true,
22
+ title: 'Drawer title (optionnal)',
23
+ contentTitle: 'Content title',
24
+ default: `
25
+ <p>
26
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod itaque
27
+ odit, eligendi non, minus soluta dicta, excepturi harum tempora
28
+ possimus dignissimos dolor rerum natus voluptatum quia. Architecto
29
+ temporibus repellendus sed.
30
+ </p>
31
+ <p>
32
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod itaque
33
+ odit, eligendi non, minus soluta dicta, excepturi harum tempora
34
+ possimus dignissimos dolor rerum natus voluptatum quia. Architecto
35
+ temporibus repellendus sed.
36
+ </p>
37
+ `,
38
+ footer: `
39
+ <MButton>Button label</MButton>
40
+ <MButton ghost>Button label</MButton>
41
+ `,
42
+ },
43
+ render: (args) => ({
44
+ components: { MDrawer, MButton },
45
+ setup() {
46
+ const handleUpdate = action('update:open');
47
+ const openState = ref(args.open);
48
+
49
+ watch(
50
+ () => args.open,
51
+ (val) => {
52
+ openState.value = val;
53
+ },
54
+ );
55
+
56
+ const onUpdateOpen = (val: boolean) => {
57
+ openState.value = val;
58
+ handleUpdate(val);
59
+ args.open = val;
60
+ };
61
+
62
+ return { args, openState, onUpdateOpen };
63
+ },
64
+ template: `
65
+ <MDrawer
66
+ v-bind="args"
67
+ @update:open="onUpdateOpen"
68
+ v-model:open="openState"
69
+ >
70
+ <template v-if="${'default' in args}" v-slot>${args.default}</template>
71
+ <template v-if="${'footer' in args}" v-slot:footer>${args.footer}</template>
72
+ </MDrawer>
73
+ `,
74
+ }),
75
+ };
76
+ export default meta;
77
+ type Story = StoryObj<typeof MDrawer>;
78
+
79
+ export const Default: Story = {
80
+ args: {
81
+ default: `
82
+ <!-- All the code below must be replaced by a form element. -->
83
+ <div class="content-slot content-slot-full">
84
+ Insert a form element here to replace this slot.
85
+ </div>
86
+ `,
87
+ },
88
+ };
89
+
90
+ export const Left = {
91
+ args: {
92
+ position: 'left',
93
+ },
94
+ };
95
+
96
+ export const Back = {
97
+ args: {
98
+ back: true,
99
+ },
100
+ };
101
+
102
+ export const ValidationOnly = {
103
+ args: {
104
+ footer: `
105
+ <MButton>Button label</MButton>
106
+ `,
107
+ },
108
+ };
109
+
110
+ export const TwoOptions = {
111
+ args: {
112
+ footer: `
113
+ <MButton>Button label</MButton>
114
+ <MButton outlined>Button label</MButton>
115
+ `,
116
+ },
117
+ };
118
+
119
+ export const Cancel = {
120
+ args: {
121
+ extended: true,
122
+ footer: `
123
+ <MButton>Button label</MButton>
124
+ <MButton outlined>Button label</MButton>
125
+ <MButton ghost>Button label</MButton>
126
+ `,
127
+ },
128
+ };
@@ -0,0 +1,140 @@
1
+ <template>
2
+ <MOverlay :is-visible="open" dialogLabel="drawerTitle">
3
+ <section
4
+ class="mc-drawer"
5
+ :class="classObject"
6
+ role="dialog"
7
+ aria-labelledby="drawerTitle"
8
+ :aria-modal="open ? 'true' : 'false'"
9
+ tabindex="-1"
10
+ :aria-hidden="!open"
11
+ v-bind="$attrs"
12
+ @keydown.esc="onClose"
13
+ >
14
+ <div class="mc-drawer__dialog" role="document">
15
+ <div class="mc-drawer__header">
16
+ <MIconButton
17
+ v-if="back"
18
+ class="mc-drawer__back"
19
+ aria-label="Back"
20
+ ghost
21
+ @click="emit('back')"
22
+ >
23
+ <template #icon>
24
+ <ArrowBack24 aria-hidden="true" />
25
+ </template>
26
+ </MIconButton>
27
+ <h2 class="mc-drawer__title" id="drawerTitle">{{ title }}</h2>
28
+ <MIconButton
29
+ class="mc-drawer__close"
30
+ aria-label="Close"
31
+ ghost
32
+ @click="onClose"
33
+ >
34
+ <template #icon>
35
+ <Cross24 aria-hidden="true" />
36
+ </template>
37
+ </MIconButton>
38
+ </div>
39
+ <div class="mc-drawer__body">
40
+ <div class="mc-drawer__content" tabindex="0">
41
+ <h2 v-if="contentTitle" class="mc-drawer__content__title">
42
+ {{ contentTitle }}
43
+ </h2>
44
+ <slot />
45
+ </div>
46
+ </div>
47
+ <div v-if="$slots.footer" class="mc-drawer__footer">
48
+ <slot name="footer" />
49
+ </div>
50
+ </div>
51
+ </section>
52
+ </MOverlay>
53
+ </template>
54
+
55
+ <script setup lang="ts">
56
+ import { computed, watch, type VNode } from 'vue';
57
+ import ArrowBack24 from '@mozaic-ds/icons-vue/src/components/ArrowBack24/ArrowBack24.vue';
58
+ import Cross24 from '@mozaic-ds/icons-vue/src/components/Cross24/Cross24.vue';
59
+ import MIconButton from '../iconbutton/MIconButton.vue';
60
+ import MOverlay from '../overlay/MOverlay.vue';
61
+ /**
62
+ * A drawer is a sliding panel that appears from the side of the screen, providing additional content, settings, or actions without disrupting the main view. It is often used for filtering options, or contextual details. It enhances usability by keeping interfaces clean while offering expandable functionality.
63
+ */
64
+ const props = defineProps<{
65
+ /**
66
+ * If `true`, display the drawer.
67
+ */
68
+ open?: boolean;
69
+ /**
70
+ * Position of the drawer
71
+ */
72
+ position?: 'left' | 'right';
73
+ /**
74
+ * If `true`, the drawer have a bigger width.
75
+ */
76
+ extended?: boolean;
77
+ /**
78
+ * If `true`, display the back button.
79
+ */
80
+ back?: boolean;
81
+ /**
82
+ * Title of the drawer
83
+ */
84
+ title: string;
85
+ /**
86
+ * Title of the content of the drawer
87
+ */
88
+ contentTitle?: string;
89
+ }>();
90
+
91
+ defineSlots<{
92
+ /**
93
+ * Use this slot to insert the content of the drawer
94
+ */
95
+ default?: VNode;
96
+ /**
97
+ * Use this slot to insert buttons in the footer
98
+ */
99
+ footer?: VNode;
100
+ }>();
101
+
102
+ const classObject = computed(() => {
103
+ return {
104
+ 'is-open': props.open,
105
+ 'mc-drawer--extend': props.extended,
106
+ [`mc-drawer--${props.position}`]:
107
+ props.position && props.position != 'right',
108
+ };
109
+ });
110
+
111
+ watch(
112
+ () => props.open,
113
+ (newValue) => {
114
+ emit('update:open', newValue);
115
+ },
116
+ );
117
+
118
+ const onClose = () => {
119
+ emit('update:open', false);
120
+ };
121
+
122
+ const emit = defineEmits<{
123
+ /**
124
+ * Emits when the drawer open state changes, updating the modelValue prop.
125
+ */
126
+ (on: 'update:open', value: boolean): void;
127
+ /**
128
+ * Emits when click back button of the drawer.
129
+ */
130
+ (on: 'back'): void;
131
+ }>();
132
+ </script>
133
+
134
+ <style lang="scss" scoped>
135
+ @use '@mozaic-ds/styles/components/drawer';
136
+
137
+ .mc-overlay {
138
+ filter: none;
139
+ }
140
+ </style>