@mozaic-ds/vue 2.15.0 → 2.17.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 (125) hide show
  1. package/dist/mozaic-vue.css +2 -1
  2. package/dist/mozaic-vue.d.ts +1040 -408
  3. package/dist/mozaic-vue.js +17183 -6742
  4. package/dist/mozaic-vue.js.map +1 -1
  5. package/dist/mozaic-vue.umd.cjs +26 -6
  6. package/dist/mozaic-vue.umd.cjs.map +1 -1
  7. package/package.json +11 -5
  8. package/src/components/BrandPresets.mdx +2 -2
  9. package/src/components/ComponentsMapping.mdx +98 -0
  10. package/src/components/accordionlist/MAccordionList.figma.ts +43 -0
  11. package/src/components/accordionlistitem/MAccordionListItem.figma.ts +27 -0
  12. package/src/components/actionbottombar/MActionBottomBar.figma.ts +24 -0
  13. package/src/components/actionlistbox/MActionListbox.figma.ts +30 -0
  14. package/src/components/actionlistbox/MActionListbox.spec.ts +14 -0
  15. package/src/components/actionlistbox/MActionListbox.stories.ts +15 -8
  16. package/src/components/actionlistbox/MActionListbox.vue +13 -1
  17. package/src/components/actionlistbox/README.md +2 -1
  18. package/src/components/avatar/MAvatar.figma.ts +31 -0
  19. package/src/components/breadcrumb/MBreadcrumb.figma.ts +31 -0
  20. package/src/components/builtinmenu/MBuiltInMenu.figma.ts +23 -0
  21. package/src/components/button/MButton.figma.ts +41 -0
  22. package/src/components/button/README.md +2 -0
  23. package/src/components/callout/MCallout.figma.ts +29 -0
  24. package/src/components/carousel/MCarousel.figma.ts +32 -0
  25. package/src/components/checkbox/MCheckbox.figma.ts +45 -0
  26. package/src/components/checkboxgroup/MCheckboxGroup.figma.ts +30 -0
  27. package/src/components/checklistmenu/MCheckListMenu.figma.ts +29 -0
  28. package/src/components/circularprogressbar/MCircularProgressbar.figma.ts +31 -0
  29. package/src/components/combobox/MCombobox.figma.ts +48 -0
  30. package/src/components/combobox/MCombobox.spec.ts +246 -0
  31. package/src/components/combobox/MCombobox.stories.ts +190 -0
  32. package/src/components/combobox/MCombobox.vue +286 -0
  33. package/src/components/combobox/README.md +52 -0
  34. package/src/components/container/MContainer.figma.ts +30 -0
  35. package/src/components/datatable/DataTable.stories.ts +277 -0
  36. package/src/components/datatable/DataTableCells.stories.ts +251 -0
  37. package/src/components/datatable/DataTableEmpty.stories.ts +102 -0
  38. package/src/components/datatable/DataTableExpandable.stories.ts +95 -0
  39. package/src/components/datatable/DataTableNested.stories.ts +96 -0
  40. package/src/components/datatable/DataTableSelectable.stories.ts +124 -0
  41. package/src/components/datatable/DataTableSortable.stories.ts +164 -0
  42. package/src/components/datatable/MDataTable.types.ts +54 -0
  43. package/src/components/datatable/assets/styles.scss +10 -0
  44. package/src/components/datatable/datatable.mdx +62 -0
  45. package/src/components/datatable/tools/data.js +8 -0
  46. package/src/components/datatable/tools/data.json +2018 -0
  47. package/src/components/datatable/utils.js +19 -0
  48. package/src/components/datepicker/MDatepicker.figma.ts +20 -0
  49. package/src/components/divider/MDivider.figma.ts +30 -0
  50. package/src/components/drawer/MDrawer.figma.ts +37 -0
  51. package/src/components/drawer/README.md +1 -1
  52. package/src/components/field/MField.figma.ts +30 -0
  53. package/src/components/field/MField.stories.ts +105 -0
  54. package/src/components/fileuploader/MFileUploader.figma.ts +23 -0
  55. package/src/components/fileuploaderitem/MFileUploaderItem.figma.ts +27 -0
  56. package/src/components/flag/MFlag.figma.ts +26 -0
  57. package/src/components/iconbutton/MIconButton.figma.ts +54 -0
  58. package/src/components/kpiitem/MKpiItem.figma.ts +33 -0
  59. package/src/components/linearprogressbarbuffer/MLinearProgressbarBuffer.figma.ts +31 -0
  60. package/src/components/linearprogressbarpercentage/MLinearProgressbarPercentage.figma.ts +26 -0
  61. package/src/components/link/MLink.figma.ts +32 -0
  62. package/src/components/loader/MLoader.figma.ts +30 -0
  63. package/src/components/loadingoverlay/MLoadingOverlay.figma.ts +18 -0
  64. package/src/components/modal/MModal.figma.ts +27 -0
  65. package/src/components/navigationindicator/MNavigationIndicator.figma.ts +24 -0
  66. package/src/components/numberbadge/MNumberBadge.figma.ts +31 -0
  67. package/src/components/optionListbox/MOptionListbox.figma.ts +36 -0
  68. package/src/components/optionListbox/MOptionListbox.spec.ts +527 -0
  69. package/src/components/optionListbox/MOptionListbox.vue +470 -0
  70. package/src/components/optionListbox/README.md +63 -0
  71. package/src/components/overlay/MOverlay.figma.ts +20 -0
  72. package/src/components/pageheader/MPageHeader.figma.ts +21 -0
  73. package/src/components/pagination/MPagination.figma.ts +34 -0
  74. package/src/components/passwordinput/MPasswordInput.figma.ts +30 -0
  75. package/src/components/phonenumber/MPhoneNumber.figma.ts +47 -0
  76. package/src/components/pincode/MPincode.figma.ts +41 -0
  77. package/src/components/pincode/MPincode.spec.ts +1 -4
  78. package/src/components/pincode/MPincode.vue +11 -15
  79. package/src/components/popover/MPopover.figma.ts +42 -0
  80. package/src/components/quantityselector/MQuantitySelector.figma.ts +50 -0
  81. package/src/components/radio/MRadio.figma.ts +40 -0
  82. package/src/components/radiogroup/MRadioGroup.figma.ts +30 -0
  83. package/src/components/segmentedcontrol/MSegmentedControl.figma.ts +33 -0
  84. package/src/components/select/MSelect.figma.ts +49 -0
  85. package/src/components/sidebar/MSidebar.figma.ts +28 -0
  86. package/src/components/sidebarexpandableitem/MSidebarExpandableItem.figma.ts +19 -0
  87. package/src/components/sidebarfooter/MSidebarFooter.figma.ts +21 -0
  88. package/src/components/sidebarheader/MSidebarHeader.figma.ts +18 -0
  89. package/src/components/sidebarnavitem/MSidebarNavItem.figma.ts +23 -0
  90. package/src/components/sidebarshortcutitem/MSidebarShortcutItem.figma.ts +20 -0
  91. package/src/components/starrating/MStarRating.figma.ts +35 -0
  92. package/src/components/statusbadge/MStatusBadge.figma.ts +27 -0
  93. package/src/components/statusdot/MStatusDot.figma.ts +31 -0
  94. package/src/components/statusmessage/MStatusMessage.figma.ts +28 -0
  95. package/src/components/statusmessage/MStatusMessage.spec.ts +15 -0
  96. package/src/components/statusmessage/MStatusMessage.stories.ts +4 -0
  97. package/src/components/statusmessage/MStatusMessage.vue +7 -0
  98. package/src/components/statusmessage/README.md +2 -0
  99. package/src/components/statusnotification/MStatusNotification.figma.ts +29 -0
  100. package/src/components/stepperbottombar/MStepperBottomBar.figma.ts +20 -0
  101. package/src/components/steppercompact/MStepperCompact.figma.ts +21 -0
  102. package/src/components/stepperinline/MStepperInline.figma.ts +23 -0
  103. package/src/components/stepperstacked/MStepperStacked.figma.ts +23 -0
  104. package/src/components/stepperstacked/MStepperStacked.spec.ts +162 -0
  105. package/src/components/stepperstacked/MStepperStacked.stories.ts +57 -0
  106. package/src/components/stepperstacked/MStepperStacked.vue +106 -0
  107. package/src/components/stepperstacked/README.md +15 -0
  108. package/src/components/tabs/MTabs.figma.ts +33 -0
  109. package/src/components/tag/MTag.figma.ts +26 -0
  110. package/src/components/tag/MTag.stories.ts +13 -3
  111. package/src/components/tag/MTag.vue +11 -1
  112. package/src/components/tag/README.md +6 -0
  113. package/src/components/textarea/MTextArea.figma.ts +28 -0
  114. package/src/components/textinput/MTextInput.figma.ts +51 -0
  115. package/src/components/textinput/MTextInput.vue +13 -1
  116. package/src/components/textinput/README.md +15 -1
  117. package/src/components/tile/MTile.figma.ts +31 -0
  118. package/src/components/tileclickable/MTileClickable.figma.ts +31 -0
  119. package/src/components/tileexpandable/MTileExpandable.figma.ts +31 -0
  120. package/src/components/tileselectable/MTileSelectable.figma.ts +29 -0
  121. package/src/components/toaster/MToaster.figma.ts +25 -0
  122. package/src/components/toggle/MToggle.figma.ts +39 -0
  123. package/src/components/togglegroup/MToggleGroup.figma.ts +30 -0
  124. package/src/components/tooltip/MTooltip.figma.ts +29 -0
  125. package/src/main.ts +1 -0
@@ -0,0 +1,286 @@
1
+ <template>
2
+ <div
3
+ ref="combobox"
4
+ :class="{
5
+ 'mc-combobox': true,
6
+ 'mc-combobox--open': isOpen,
7
+ 'mc-combobox--multiple': multiple,
8
+ 'mc-combobox--invalid': invalid,
9
+ 'mc-combobox--s': size === 's',
10
+ 'mc-combobox--disabled': disabled,
11
+ 'mc-combobox--readonly': readonly,
12
+ }"
13
+ >
14
+ <div class="mc-combobox__input">
15
+ <button
16
+ ref="comboboxControl"
17
+ type="button"
18
+ :aria-expanded="isOpen ? 'true' : 'false'"
19
+ aria-haspopup="listbox"
20
+ :aria-controls="`listbox-${id}`"
21
+ :disabled="disabled"
22
+ class="mc-combobox__control"
23
+ aria-label="Combobox input"
24
+ @click="toggleListbox"
25
+ v-bind="
26
+ search
27
+ ? {}
28
+ : {
29
+ role: 'combobox',
30
+ 'aria-activedescendant': activeDescendantId,
31
+ onKeydown: listbox?.handleKeydown,
32
+ }
33
+ "
34
+ >
35
+ {{ selectionLabel }}
36
+ </button>
37
+ <span
38
+ v-if="multiple && hasValue && counterLabel"
39
+ class="mc-combobox__counter"
40
+ >
41
+ {{ counterLabel }}
42
+ </span>
43
+
44
+ <button
45
+ v-if="clearable && hasValue"
46
+ type="button"
47
+ class="mc-combobox__clear"
48
+ aria-label="Clear selection"
49
+ @click="listbox?.clearSelection"
50
+ >
51
+ <CrossCircleFilled24 />
52
+ </button>
53
+
54
+ <button
55
+ type="button"
56
+ :tabindex="-1"
57
+ class="mc-combobox__icon"
58
+ aria-label="Expand options list"
59
+ @click="toggleListbox"
60
+ >
61
+ <ChevronDown24 />
62
+ </button>
63
+ </div>
64
+
65
+ <MOptionListbox
66
+ ref="listbox"
67
+ v-model="selection"
68
+ :id
69
+ :open="isOpen"
70
+ :multiple
71
+ :search
72
+ :actions
73
+ :checkable-sections
74
+ :search-placeholder
75
+ :select-label
76
+ :clear-label
77
+ :options
78
+ class="mc-combobox__listbox"
79
+ @open="open"
80
+ @close="
81
+ () => {
82
+ close();
83
+ comboboxControl?.focus();
84
+ }
85
+ "
86
+ >
87
+ <template #item="{ item }">
88
+ <slot name="item" v-bind="{ item }" />
89
+ </template>
90
+ </MOptionListbox>
91
+ </div>
92
+ </template>
93
+
94
+ <script setup lang="ts">
95
+ import MOptionListbox, {
96
+ type ListboxOption,
97
+ } from '../optionListbox/MOptionListbox.vue';
98
+ import { CrossCircleFilled24, ChevronDown24 } from '@mozaic-ds/icons-vue';
99
+ import {
100
+ computed,
101
+ onBeforeUnmount,
102
+ ref,
103
+ useId,
104
+ useTemplateRef,
105
+ type VNode,
106
+ } from 'vue';
107
+
108
+ /**
109
+ * A combobox is an input field that allows users to select an option from a dropdown list or enter a custom value. It combines the functionality of a text input and a dropdown menu, providing flexibility and ease of use in forms and user interfaces.
110
+ */
111
+ const props = withDefaults(
112
+ defineProps<{
113
+ /**
114
+ * The current selected value(s) of the combobox.
115
+ */
116
+ modelValue: string | number | null | (string | number)[];
117
+ /**
118
+ * Enable multiple selection mode.
119
+ */
120
+ multiple?: boolean;
121
+ /**
122
+ * Size of the combobox: small ('s') or medium ('m').
123
+ */
124
+ size?: 's' | 'm';
125
+ /**
126
+ * Disable the combobox input.
127
+ */
128
+ disabled?: boolean;
129
+ /**
130
+ * Make the combobox read-only.
131
+ */
132
+ readonly?: boolean;
133
+ /**
134
+ * Mark the combobox as invalid.
135
+ */
136
+ invalid?: boolean;
137
+ /**
138
+ * Show a clear selection button.
139
+ */
140
+ clearable?: boolean;
141
+ /**
142
+ * Enable the search input inside the listbox.
143
+ */
144
+ search?: boolean;
145
+ /**
146
+ * Show select all / clear buttons when multiple.
147
+ */
148
+ actions?: boolean;
149
+ /**
150
+ * Enable checkable section headers in the listbox.
151
+ */
152
+ checkableSections?: boolean;
153
+ /**
154
+ * Placeholder text when no value is selected.
155
+ */
156
+ placeholder?: string;
157
+ /**
158
+ * Label for the selected items counter.
159
+ */
160
+ counterLabel?: string;
161
+ /**
162
+ * Placeholder text for the search input.
163
+ */
164
+ searchPlaceholder?: string;
165
+ /**
166
+ * Label for the "Select all" button.
167
+ */
168
+ selectLabel?: string;
169
+ /**
170
+ * Label for the "Clear selection" button.
171
+ */
172
+ clearLabel?: string;
173
+ /**
174
+ * Array of options to display in the listbox.
175
+ */
176
+ options: Array<ListboxOption>;
177
+ }>(),
178
+ {
179
+ placeholder: 'Select an option',
180
+ searchPlaceholder: 'Find an option...',
181
+ selectLabel: 'Select all',
182
+ clearLabel: 'Clear',
183
+ size: 'm',
184
+ },
185
+ );
186
+
187
+ const emit = defineEmits<{
188
+ /**
189
+ * Emitted when the selected value(s) change.
190
+ */
191
+ (
192
+ on: 'update:modelValue',
193
+ value: string | number | null | (string | number)[],
194
+ ): void;
195
+ /**
196
+ * Emitted when the listbox is opened or closed.
197
+ */
198
+ (on: 'update:open', value: boolean): void;
199
+ }>();
200
+
201
+ defineSlots<{
202
+ /**
203
+ * Use this slot to customize the content of each item.
204
+ */
205
+ item(props: { item: ListboxOption }): VNode;
206
+ }>();
207
+
208
+ const id = useId();
209
+
210
+ const combobox = useTemplateRef('combobox');
211
+ const listbox = useTemplateRef('listbox');
212
+ const comboboxControl = useTemplateRef('comboboxControl');
213
+
214
+ const isOpen = ref(false);
215
+
216
+ const activeDescendantId = computed(() => {
217
+ const activeIndex = listbox.value?.activeIndex || -1;
218
+ return activeIndex >= 0 ? `option-${id}-${activeIndex}` : undefined;
219
+ });
220
+
221
+ const selection = computed({
222
+ get() {
223
+ return props.modelValue;
224
+ },
225
+ set(value: string | number | null | (string | number)[]) {
226
+ emit('update:modelValue', value);
227
+ },
228
+ });
229
+
230
+ const selectionLabel = computed(() => {
231
+ if (Array.isArray(selection.value)) {
232
+ if (!selection.value.length) return props.placeholder;
233
+ return (selection.value as (string | number)[])
234
+ .map((value) => getOptionLabel(value))
235
+ .join(', ');
236
+ }
237
+
238
+ return (
239
+ getOptionLabel(selection.value as string | number) || props.placeholder
240
+ );
241
+ });
242
+
243
+ const hasValue = computed(() =>
244
+ props.multiple
245
+ ? !!(selection.value as (string | number)[]).length
246
+ : !!selection.value,
247
+ );
248
+
249
+ function handleClickOutside(event: MouseEvent) {
250
+ if (
251
+ !combobox.value?.contains(event.target as Node) &&
252
+ !listbox.value?.listboxEl?.contains(event.target as Node)
253
+ ) {
254
+ close();
255
+ }
256
+ }
257
+
258
+ function open() {
259
+ isOpen.value = true;
260
+ emit('update:open', true);
261
+ document.addEventListener('click', handleClickOutside);
262
+ }
263
+
264
+ function close() {
265
+ isOpen.value = false;
266
+ emit('update:open', false);
267
+ document.removeEventListener('click', handleClickOutside);
268
+ }
269
+
270
+ function toggleListbox() {
271
+ return isOpen.value ? close() : open();
272
+ }
273
+
274
+ function getOptionLabel(value: string | number) {
275
+ const option = props.options.find((option) => option.value === value);
276
+ return option ? option.label : '';
277
+ }
278
+
279
+ onBeforeUnmount(() => {
280
+ document.removeEventListener('click', handleClickOutside);
281
+ });
282
+ </script>
283
+
284
+ <style lang="scss" scoped>
285
+ @use '@mozaic-ds/styles/components/combobox';
286
+ </style>
@@ -0,0 +1,52 @@
1
+ # MCombobox
2
+
3
+ A combobox is an input field that allows users to select an option from a dropdown list or enter a custom value. It combines the functionality of a text input and a dropdown menu, providing flexibility and ease of use in forms and user interfaces.
4
+
5
+
6
+ ## Props
7
+
8
+ | Name | Description | Type | Default |
9
+ | --- | --- | --- | --- |
10
+ | `modelValue*` | The current selected value(s) of the combobox. | `string` `number` `(string` `number)[]` `null` | - |
11
+ | `multiple` | Enable multiple selection mode. | `boolean` | - |
12
+ | `size` | Size of the combobox: small ('s') or medium ('m'). | `"s"` `"m"` | `"m"` |
13
+ | `disabled` | Disable the combobox input. | `boolean` | - |
14
+ | `readonly` | Make the combobox read-only. | `boolean` | - |
15
+ | `invalid` | Mark the combobox as invalid. | `boolean` | - |
16
+ | `clearable` | Show a clear selection button. | `boolean` | - |
17
+ | `search` | Enable the search input inside the listbox. | `boolean` | - |
18
+ | `actions` | Show select all / clear buttons when multiple. | `boolean` | - |
19
+ | `checkableSections` | Enable checkable section headers in the listbox. | `boolean` | - |
20
+ | `placeholder` | Placeholder text when no value is selected. | `string` | `"Select an option"` |
21
+ | `counterLabel` | Label for the selected items counter. | `string` | - |
22
+ | `searchPlaceholder` | Placeholder text for the search input. | `string` | `"Find an option..."` |
23
+ | `selectLabel` | Label for the "Select all" button. | `string` | `"Select all"` |
24
+ | `clearLabel` | Label for the "Clear selection" button. | `string` | `"Clear"` |
25
+ | `options*` | Array of options to display in the listbox. | `ListboxOption[]` | - |
26
+
27
+ ## Slots
28
+
29
+ | Name | Description |
30
+ | --- | --- |
31
+ | `item` | Use this slot to customize the content of each item. |
32
+
33
+ ## Events
34
+
35
+ | Name | Description | Type |
36
+ | --- | --- | --- |
37
+ | `update:modelValue` | - | `[value: string` `number` `(string` `number)[]` `null]` |
38
+ | `update:open` | Emitted when the selected value(s) change. / ( on: 'update:modelValue', value: string | number | null | (string | number)[], ): void; /** Emitted when the listbox is opened or closed. | [value: boolean] |
39
+
40
+ ## Dependencies
41
+
42
+ ### Depends on
43
+
44
+ - [MOptionListbox](../optionListbox)
45
+
46
+ ### Graph
47
+
48
+ ```mermaid
49
+ graph TD;
50
+ MCombobox --> MOptionListbox
51
+ style MCombobox fill:#008240,stroke:#333,stroke-width:4px
52
+ ```
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Code Connect mapping for MContainer
3
+ * Links Figma Container to @mozaic-ds/vue
4
+ */
5
+ import figma, { html } from '@figma/code-connect/html';
6
+
7
+ figma.connect(
8
+ 'https://www.figma.com/design/Zyh9RyabNaqkjbuFWP9Aqj/%E2%9C%A8-Components--ADS2---Stable-version-?node-id=20116-26427',
9
+ {
10
+ props: {
11
+ appearance: figma.enum('Appearance', {
12
+ Primary: 'primary',
13
+ Secondary: 'secondary',
14
+ Inverse: 'inverse',
15
+ }),
16
+ bordered: figma.enum('Is bordered', {
17
+ True: true,
18
+ False: false,
19
+ }),
20
+ },
21
+ example: () =>
22
+ html`<script setup>
23
+ import { MContainer } from '@mozaic-ds/vue';
24
+ </script>
25
+
26
+ <MContainer>
27
+ <p>Container content</p>
28
+ </MContainer>`,
29
+ },
30
+ );
@@ -0,0 +1,277 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import * as utils from './utils';
3
+
4
+ // Components
5
+ import '@mozaic-ds/datatable-vue/style.css';
6
+ import { MDataTable, MDataTableColumn, MDataTableTop } from '@mozaic-ds/datatable-vue';
7
+ import MButton from '../button/MButton.vue';
8
+ import MIconButton from '../iconbutton/MIconButton.vue';
9
+ import { Settings24, Edit24, Download24, Filter24, Search24 } from '@mozaic-ds/icons-vue';
10
+ import MToggle from '../toggle/MToggle.vue';
11
+ import MTextInput from '../textinput/MTextInput.vue';
12
+ import MTag from '../tag/MTag.vue';
13
+
14
+ const meta: Meta<typeof MDataTable> = {
15
+ title: 'DataTable/MDataTable Default',
16
+ component: MDataTable,
17
+ args: {
18
+ ...utils.args,
19
+ default: `
20
+ <!--
21
+ Default content
22
+ -->
23
+ <MDataTableColumn label="Name" value="name" />
24
+ <MDataTableColumn label="Stock" value="stock" />
25
+
26
+ <!-- Start Date -->
27
+ <MDataTableColumn label="Start date" value="startDate" />
28
+ <template v-slot:cell.startDate="{ item }">
29
+ {{ formatDate(item.startDate) }}
30
+ </template>
31
+
32
+ <!-- End Date -->
33
+ <MDataTableColumn label="End date" value="endDate" />
34
+ <template v-slot:cell.endDate="{ item }">
35
+ {{ formatDate(item.startDate) }}
36
+ </template>
37
+
38
+ <!-- Status -->
39
+ <MDataTableColumn label="Statut" value="status" />
40
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
41
+ `
42
+ },
43
+ argTypes: utils.argtypes,
44
+ parameters: {
45
+ componentName: 'MDataTable',
46
+ backgrounds: utils.backgrounds,
47
+ docs: {
48
+ canvas: { sourceState: 'none' },
49
+ }
50
+ },
51
+ render: (args) => ({
52
+ components: { MDataTable, MDataTableColumn, MDataTableTop, MButton },
53
+ setup() {
54
+ return { args };
55
+ },
56
+ template: `
57
+ <MDataTable v-bind="args">
58
+ ${args.default}
59
+ </MDataTable>
60
+ `,
61
+ methods: {
62
+ formatDate(date) {
63
+ return new Date(date).toLocaleString();
64
+ },
65
+ },
66
+ }),
67
+ };
68
+
69
+ export default meta;
70
+ type Story = StoryObj<typeof MDataTable>;
71
+
72
+ export const Default: Story = {};
73
+
74
+ export const SizeS: Story = {
75
+ args: {
76
+ size: 's',
77
+ },
78
+ };
79
+
80
+ export const SizeL: Story = {
81
+ args: {
82
+ size: 'l',
83
+ },
84
+ };
85
+
86
+ export const LoadingState: Story = {
87
+ args: {
88
+ loading: true,
89
+ },
90
+ };
91
+
92
+ export const MaxHeight: Story = {
93
+ args: {
94
+ maxHeight: '300px',
95
+ },
96
+ };
97
+
98
+ export const FixedHeader: Story = {
99
+ args: {
100
+ fixedHeader: true,
101
+ maxHeight: '400px',
102
+ },
103
+ };
104
+
105
+ export const TopbarActions: Story = {
106
+ render: (args) => ({
107
+ components: { MDataTable, MDataTableColumn, MDataTableTop, MButton, Settings24, Filter24, MToggle },
108
+ setup() {
109
+ return { args };
110
+ },
111
+ template: `
112
+ <MDataTable v-bind="args">
113
+ <!-- Topbar - With Actions tools -->
114
+ <template v-slot:topbar>
115
+ <MDataTableTop>
116
+ <template v-slot:actions>
117
+ <MToggle size="s" label="Toggle Label" />
118
+ <MButton iconPosition="left" outlined size="s"><template #icon><Filter24 /></template> Filter</MButton>
119
+ <MButton iconPosition="only" outlined size="s"><template #icon><Settings24 /></template></MButton>
120
+ <MButton appearance="accent" size="s" >Primary action</MButton>
121
+ <MButton outlined appearance="danger" size="s">Negative action</MButton>
122
+ </template>
123
+ </MDataTableTop>
124
+ </template>
125
+
126
+ <!-- Default content -->
127
+ <MDataTableColumn label="Name" value="name" />
128
+ <MDataTableColumn label="Stock" value="stock" />
129
+ <!-- Start Date -->
130
+ <MDataTableColumn label="Start date" value="startDate" />
131
+ <template v-slot:cell.startDate="{ item }">
132
+ {{ formatDate(item.startDate) }}
133
+ </template>
134
+
135
+ <!-- End Date -->
136
+ <MDataTableColumn label="End date" value="endDate" />
137
+ <template v-slot:cell.endDate="{ item }">
138
+ {{ formatDate(item.startDate) }}
139
+ </template>
140
+
141
+ <!-- Status -->
142
+ <MDataTableColumn label="Statut" value="status" />
143
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
144
+ </MDataTable>
145
+ `,
146
+ methods: {
147
+ formatDate(date) {
148
+ return new Date(date).toLocaleString();
149
+ },
150
+ },
151
+ }),
152
+ };
153
+
154
+ export const TopbarEdition: Story = {
155
+ render: (args) => ({
156
+ components: { MDataTable, MDataTableColumn, MDataTableTop, MButton, MIconButton, Edit24, Download24 },
157
+ setup() {
158
+ return { args };
159
+ },
160
+ template: `
161
+ <MDataTable v-bind="args">
162
+ <!-- Topbar - With Edition tools -->
163
+ <template v-slot:topbar>
164
+ <MDataTableTop>
165
+ <template v-slot:edition>
166
+ <MIconButton ghost size="s"><template #icon><Edit24/></template></MIconButton>
167
+ <MIconButton ghost size="s"><template #icon><Download24/></template></MIconButton>
168
+ <div style="display: flex;align-items: center;">999 selected</div>
169
+ </template>
170
+ </MDataTableTop>
171
+ </template>
172
+
173
+ <!-- Default content -->
174
+ <MDataTableColumn label="Name" value="name" />
175
+ <MDataTableColumn label="Stock" value="stock" />
176
+
177
+ <!-- Start Date -->
178
+ <MDataTableColumn label="Start date" value="startDate" />
179
+ <template v-slot:cell.startDate="{ item }">
180
+ {{ formatDate(item.startDate) }}
181
+ </template>
182
+
183
+ <!-- End Date -->
184
+ <MDataTableColumn label="End date" value="endDate" />
185
+ <template v-slot:cell.endDate="{ item }">
186
+ {{ formatDate(item.startDate) }}
187
+ </template>
188
+
189
+ <!-- Status -->
190
+ <MDataTableColumn label="Statut" value="status" />
191
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
192
+ </MDataTable>
193
+ `,
194
+ methods: {
195
+ formatDate(date) {
196
+ return new Date(date).toLocaleString();
197
+ },
198
+ },
199
+ }),
200
+ };
201
+
202
+ export const TopbarFull: Story = {
203
+ render: (args) => ({
204
+ components: {
205
+ MDataTable,
206
+ MDataTableColumn,
207
+ MDataTableTop,
208
+ MButton,
209
+ MIconButton,
210
+ MToggle,
211
+ MTextInput,
212
+ Edit24,
213
+ Download24,
214
+ Settings24,
215
+ Filter24,
216
+ Search24,
217
+ MTag
218
+ },
219
+ setup() {
220
+ return { args };
221
+ },
222
+ template: `
223
+ <MDataTable v-bind="args">
224
+ <!-- Topbar - Full topbar -->
225
+ <template v-slot:topbar>
226
+ <MDataTableTop>
227
+ <template v-slot:edition>
228
+ <MIconButton ghost size="s"><template #icon><Edit24/></template></MIconButton>
229
+ <MIconButton ghost size="s"><template #icon><Download24/></template></MIconButton>
230
+ <div style="display: flex;align-items: center;">999 selected</div>
231
+ </template>
232
+ <template v-slot:actions>
233
+ <MToggle size="s" label="Toggle Label" />
234
+ <MButton iconPosition="left" outlined size="s"><template #icon><Filter24 /></template> Filter</MButton>
235
+ <MButton iconPosition="only" outlined size="s"><template #icon><Settings24 /></template></MButton>
236
+ <MButton appearance="accent" size="s" >Primary action</MButton>
237
+ <MButton outlined appearance="danger" size="s">Negative action</MButton>
238
+ </template>
239
+ <template v-slot:filters>
240
+ <MTag type="removable" label="Filter label" size="s" />
241
+ <MTag type="removable" label="Filter label" size="s" />
242
+ <MTag type="removable" label="Filter label" size="s" />
243
+ <MTag type="removable" label="Filter label" size="s" />
244
+ <MTag type="removable" label="Filter label" size="s" />
245
+ <MButton ghost size="s">reset</MButton>
246
+ </template>
247
+ </MDataTableTop>
248
+ </template>
249
+
250
+ <!-- Default content -->
251
+ <MDataTableColumn label="Name" value="name" />
252
+ <MDataTableColumn label="Stock" value="stock" />
253
+
254
+ <!-- Start Date -->
255
+ <MDataTableColumn label="Start date" value="startDate" />
256
+ <template v-slot:cell.startDate="{ item }">
257
+ {{ formatDate(item.startDate) }}
258
+ </template>
259
+
260
+ <!-- End Date -->
261
+ <MDataTableColumn label="End date" value="endDate" />
262
+ <template v-slot:cell.endDate="{ item }">
263
+ {{ formatDate(item.startDate) }}
264
+ </template>
265
+
266
+ <!-- Status -->
267
+ <MDataTableColumn label="Statut" value="status" />
268
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
269
+ </MDataTable>
270
+ `,
271
+ methods: {
272
+ formatDate(date) {
273
+ return new Date(date).toLocaleString();
274
+ },
275
+ },
276
+ }),
277
+ };