@mozaic-ds/vue 2.16.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 (110) hide show
  1. package/dist/mozaic-vue.css +2 -1
  2. package/dist/mozaic-vue.d.ts +134 -91
  3. package/dist/mozaic-vue.js +17184 -10878
  4. package/dist/mozaic-vue.js.map +1 -1
  5. package/dist/mozaic-vue.umd.cjs +23 -22
  6. package/dist/mozaic-vue.umd.cjs.map +1 -1
  7. package/package.json +10 -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/avatar/MAvatar.figma.ts +31 -0
  15. package/src/components/breadcrumb/MBreadcrumb.figma.ts +31 -0
  16. package/src/components/builtinmenu/MBuiltInMenu.figma.ts +23 -0
  17. package/src/components/button/MButton.figma.ts +41 -0
  18. package/src/components/callout/MCallout.figma.ts +29 -0
  19. package/src/components/carousel/MCarousel.figma.ts +32 -0
  20. package/src/components/checkbox/MCheckbox.figma.ts +45 -0
  21. package/src/components/checkboxgroup/MCheckboxGroup.figma.ts +30 -0
  22. package/src/components/checklistmenu/MCheckListMenu.figma.ts +29 -0
  23. package/src/components/circularprogressbar/MCircularProgressbar.figma.ts +31 -0
  24. package/src/components/combobox/MCombobox.figma.ts +48 -0
  25. package/src/components/combobox/MCombobox.spec.ts +1 -1
  26. package/src/components/combobox/MCombobox.vue +18 -9
  27. package/src/components/combobox/README.md +2 -2
  28. package/src/components/container/MContainer.figma.ts +30 -0
  29. package/src/components/datatable/DataTable.stories.ts +277 -0
  30. package/src/components/datatable/DataTableCells.stories.ts +251 -0
  31. package/src/components/datatable/DataTableEmpty.stories.ts +102 -0
  32. package/src/components/datatable/DataTableExpandable.stories.ts +95 -0
  33. package/src/components/datatable/DataTableNested.stories.ts +96 -0
  34. package/src/components/datatable/DataTableSelectable.stories.ts +124 -0
  35. package/src/components/datatable/DataTableSortable.stories.ts +164 -0
  36. package/src/components/datatable/MDataTable.types.ts +54 -0
  37. package/src/components/datatable/assets/styles.scss +10 -0
  38. package/src/components/datatable/datatable.mdx +62 -0
  39. package/src/components/datatable/tools/data.js +8 -0
  40. package/src/components/datatable/tools/data.json +2018 -0
  41. package/src/components/datatable/utils.js +19 -0
  42. package/src/components/datepicker/MDatepicker.figma.ts +20 -0
  43. package/src/components/divider/MDivider.figma.ts +30 -0
  44. package/src/components/drawer/MDrawer.figma.ts +37 -0
  45. package/src/components/drawer/README.md +1 -1
  46. package/src/components/field/MField.figma.ts +30 -0
  47. package/src/components/fileuploader/MFileUploader.figma.ts +23 -0
  48. package/src/components/fileuploaderitem/MFileUploaderItem.figma.ts +27 -0
  49. package/src/components/flag/MFlag.figma.ts +26 -0
  50. package/src/components/iconbutton/MIconButton.figma.ts +54 -0
  51. package/src/components/kpiitem/MKpiItem.figma.ts +33 -0
  52. package/src/components/linearprogressbarbuffer/MLinearProgressbarBuffer.figma.ts +31 -0
  53. package/src/components/linearprogressbarpercentage/MLinearProgressbarPercentage.figma.ts +26 -0
  54. package/src/components/link/MLink.figma.ts +32 -0
  55. package/src/components/loader/MLoader.figma.ts +30 -0
  56. package/src/components/loadingoverlay/MLoadingOverlay.figma.ts +18 -0
  57. package/src/components/modal/MModal.figma.ts +27 -0
  58. package/src/components/navigationindicator/MNavigationIndicator.figma.ts +24 -0
  59. package/src/components/numberbadge/MNumberBadge.figma.ts +31 -0
  60. package/src/components/optionListbox/MOptionListbox.figma.ts +36 -0
  61. package/src/components/optionListbox/MOptionListbox.vue +18 -18
  62. package/src/components/optionListbox/README.md +1 -1
  63. package/src/components/overlay/MOverlay.figma.ts +20 -0
  64. package/src/components/pageheader/MPageHeader.figma.ts +21 -0
  65. package/src/components/pagination/MPagination.figma.ts +34 -0
  66. package/src/components/passwordinput/MPasswordInput.figma.ts +30 -0
  67. package/src/components/phonenumber/MPhoneNumber.figma.ts +47 -0
  68. package/src/components/pincode/MPincode.figma.ts +41 -0
  69. package/src/components/pincode/MPincode.spec.ts +1 -4
  70. package/src/components/pincode/MPincode.vue +11 -15
  71. package/src/components/popover/MPopover.figma.ts +42 -0
  72. package/src/components/quantityselector/MQuantitySelector.figma.ts +50 -0
  73. package/src/components/radio/MRadio.figma.ts +40 -0
  74. package/src/components/radiogroup/MRadioGroup.figma.ts +30 -0
  75. package/src/components/segmentedcontrol/MSegmentedControl.figma.ts +33 -0
  76. package/src/components/select/MSelect.figma.ts +49 -0
  77. package/src/components/sidebar/MSidebar.figma.ts +28 -0
  78. package/src/components/sidebarexpandableitem/MSidebarExpandableItem.figma.ts +19 -0
  79. package/src/components/sidebarfooter/MSidebarFooter.figma.ts +21 -0
  80. package/src/components/sidebarheader/MSidebarHeader.figma.ts +18 -0
  81. package/src/components/sidebarnavitem/MSidebarNavItem.figma.ts +23 -0
  82. package/src/components/sidebarshortcutitem/MSidebarShortcutItem.figma.ts +20 -0
  83. package/src/components/starrating/MStarRating.figma.ts +35 -0
  84. package/src/components/statusbadge/MStatusBadge.figma.ts +27 -0
  85. package/src/components/statusdot/MStatusDot.figma.ts +31 -0
  86. package/src/components/statusmessage/MStatusMessage.figma.ts +28 -0
  87. package/src/components/statusmessage/MStatusMessage.spec.ts +15 -0
  88. package/src/components/statusmessage/MStatusMessage.stories.ts +4 -0
  89. package/src/components/statusmessage/MStatusMessage.vue +7 -0
  90. package/src/components/statusmessage/README.md +2 -0
  91. package/src/components/statusnotification/MStatusNotification.figma.ts +29 -0
  92. package/src/components/stepperbottombar/MStepperBottomBar.figma.ts +20 -0
  93. package/src/components/steppercompact/MStepperCompact.figma.ts +21 -0
  94. package/src/components/stepperinline/MStepperInline.figma.ts +23 -0
  95. package/src/components/stepperstacked/MStepperStacked.figma.ts +23 -0
  96. package/src/components/tabs/MTabs.figma.ts +33 -0
  97. package/src/components/tag/MTag.figma.ts +26 -0
  98. package/src/components/tag/MTag.stories.ts +13 -3
  99. package/src/components/tag/MTag.vue +11 -1
  100. package/src/components/tag/README.md +6 -0
  101. package/src/components/textarea/MTextArea.figma.ts +28 -0
  102. package/src/components/textinput/MTextInput.figma.ts +51 -0
  103. package/src/components/tile/MTile.figma.ts +31 -0
  104. package/src/components/tileclickable/MTileClickable.figma.ts +31 -0
  105. package/src/components/tileexpandable/MTileExpandable.figma.ts +31 -0
  106. package/src/components/tileselectable/MTileSelectable.figma.ts +29 -0
  107. package/src/components/toaster/MToaster.figma.ts +25 -0
  108. package/src/components/toggle/MToggle.figma.ts +39 -0
  109. package/src/components/togglegroup/MToggleGroup.figma.ts +30 -0
  110. package/src/components/tooltip/MTooltip.figma.ts +29 -0
@@ -0,0 +1,251 @@
1
+ import { ref } from 'vue';
2
+ import * as utils from './utils';
3
+
4
+ // Components
5
+ import { MDataTable, MDataTableColumn } from '@mozaic-ds/datatable-vue';
6
+ import MTextInput from '../textinput/MTextInput.vue';
7
+ import MStatusBadge from '../statusbadge/MStatusBadge.vue';
8
+ import MFlag from '../flag/MFlag.vue';
9
+ import MLink from '../link/MLink.vue';
10
+ import MActionListbox from '../actionlistbox/MActionListbox.vue';
11
+ import MKpiItem from '../kpiitem/MKpiItem.vue';
12
+ import MTag from '../tag/MTag.vue';
13
+
14
+ export default {
15
+ title: 'DataTable/MDataTable Table Cells',
16
+ component: MDataTable,
17
+ args: utils.args,
18
+ parameters: {
19
+ componentName: 'MDataTable',
20
+ docs: {
21
+ canvas: { sourceState: 'none' },
22
+ }
23
+ },
24
+ };
25
+
26
+ export const Default = {
27
+ args: {
28
+ selectable: true,
29
+ expandable: true,
30
+ pageable: true,
31
+ },
32
+ render: (args) => ({
33
+ components: {
34
+ MDataTable,
35
+ MDataTableColumn,
36
+ MStatusBadge,
37
+ MFlag,
38
+ MLink,
39
+ MActionListbox,
40
+ MKpiItem,
41
+ MTag,
42
+ MTextInput,
43
+ },
44
+ setup() {
45
+ const currentPage = ref(1);
46
+ const items = ref([]);
47
+ const itemsAPI = ref([]);
48
+ const itemsPerPage = ref(7);
49
+ const listbox = ref([
50
+ [
51
+ {
52
+ text: 'Edit',
53
+ icon: 'PublishEdit24',
54
+ },
55
+ {
56
+ text: 'Print',
57
+ icon: 'Print24',
58
+ disabled: true,
59
+ },
60
+ {
61
+ text: 'Mark as validated',
62
+ icon: 'NotificationCircleAvailable24',
63
+ },
64
+ ],
65
+ [
66
+ {
67
+ text: 'Open in a new window',
68
+ icon: 'DisplayExternalLink24',
69
+ },
70
+ ],
71
+ [
72
+ {
73
+ text: 'Delete',
74
+ icon: 'PublishTrashbin24',
75
+ danger: true,
76
+ },
77
+ ],
78
+ ]);
79
+ const loading = ref(false);
80
+ const totalItems = ref(0);
81
+
82
+ return {
83
+ args,
84
+ currentPage,
85
+ items,
86
+ itemsAPI,
87
+ itemsPerPage,
88
+ listbox,
89
+ loading,
90
+ totalItems,
91
+ };
92
+ },
93
+ template: `
94
+ <MDataTable
95
+ v-bind="args"
96
+ :items="items"
97
+ :loading="loading"
98
+ :totalItems="totalItems"
99
+ maxHeight="500px"
100
+ fixedHeader
101
+ @change="updatePage"
102
+ >
103
+ <!-- No Data -->
104
+ <template v-slot:no-data>
105
+ <p><strong>No data available at this time.</strong></p>
106
+ </template>
107
+
108
+ <!-- Siren -->
109
+ <MDataTableColumn label="Siren" value="siren" type="number" />
110
+
111
+ <!-- Nom -->
112
+ <MDataTableColumn label="Nom" value="nom" />
113
+ <template v-slot:header.nom="{ header }">
114
+ {{ header.label }}
115
+ <small>codeEpci</small>
116
+ </template>
117
+ <template v-slot:cell.nom="{ item }">
118
+ {{ item.nom }}
119
+ <small>codeEpci: {{ item.codeEpci }}</small>
120
+ </template>
121
+
122
+ <!-- Population -->
123
+ <MDataTableColumn label="Population" value="population" />
124
+ <template v-slot:cell.population="{ item }">
125
+ <MKpiItem
126
+ v-if="item.population > 50000"
127
+ :value="item.population"
128
+ status="success"
129
+ trend="increasing"
130
+ />
131
+ <MKpiItem
132
+ v-if="item.population > 20000 && item.population < 50000"
133
+ :value="item.population"
134
+ trend="increasing"
135
+ />
136
+ <MKpiItem
137
+ v-if="item.population > 5000 && item.population < 20000"
138
+ :value="item.population"
139
+ status="neutral"
140
+ trend="stable"
141
+ />
142
+ <MKpiItem
143
+ v-if="item.population > 2000 && item.population < 5000"
144
+ :value="item.population"
145
+ status="warning"
146
+ trend="decreasing"
147
+ />
148
+ <MKpiItem
149
+ v-if="item.population < 2000"
150
+ :value="item.population"
151
+ status="error"
152
+ trend="stable"
153
+ />
154
+ </template>
155
+
156
+ <!-- Codes Postaux -->
157
+ <MDataTableColumn label="Codes Postaux" value="codesPostaux" />
158
+ <template v-slot:cell.codesPostaux="{ item }">
159
+ <div class="codes-postaux" style="display: flex; gap: 0.25rem">
160
+ <MTag
161
+ v-for="tag in item.codesPostaux"
162
+ :key="tag"
163
+ :id="tag"
164
+ :label="tag"
165
+ />
166
+ </div>
167
+ </template>
168
+
169
+ <!-- Code INSEE -->
170
+ <MDataTableColumn label="Code INSEE" value="code" />
171
+ <template v-slot:cell.code="{ item }">
172
+ <MLink
173
+ size="s"
174
+ href="https://www.insee.fr/fr/metadonnees/cog/commune/COMitem.code-item.nom"
175
+ >
176
+ {{ item.code }}
177
+ </MLink>
178
+ </template>
179
+
180
+ <!-- Code INSEE -->
181
+ <MDataTableColumn label="Code EPCI" value="codeEpci" />
182
+ <template v-slot:cell.codeEpci="{ item }">
183
+ <MFlag :label="item.codeEpci" theme="bordered" />
184
+ </template>
185
+
186
+ <!-- Code Département -->
187
+ <MDataTableColumn
188
+ label="Code Département"
189
+ value="codeDepartement"
190
+ type="number"
191
+ />
192
+
193
+ <!-- Input -->
194
+ <MDataTableColumn label="Note" value="note" type="input" />
195
+ <template v-slot:cell.note="{ item }">
196
+ <MTextInput size="s" />
197
+ </template>
198
+
199
+ <!-- Code Région -->
200
+ <MDataTableColumn label="Code Région" value="codeRegion" />
201
+ <template v-slot:cell.codeRegion="{ item }">
202
+ <MStatusBadge :label="item.codeRegion"/>
203
+ </template>
204
+
205
+ <!-- Options -->
206
+ <!-- <MDataTableColumn label="" value="options" type="options" />
207
+ <template v-slot:cell.options="{ item }">
208
+ <MActionListbox :items="listbox" position="right" />
209
+ </template> -->
210
+ </MDataTable>
211
+ `,
212
+ async mounted() {
213
+ this.loading = true;
214
+ this.itemsAPI = await this.fetchAPI();
215
+ this.totalItems = this.itemsAPI.length;
216
+ this.items = this.paginateItems(this.itemsPerPage, this.currentPage);
217
+ this.loading = false;
218
+ },
219
+ methods: {
220
+ async fetchAPI() {
221
+ const apiUrl = 'https://geo.api.gouv.fr/departements/59/communes';
222
+ try {
223
+ // Try
224
+ const getData = await fetch(apiUrl, { method: 'GET' });
225
+ const data = await getData.json();
226
+
227
+ return data;
228
+ } catch (erreur) {
229
+ // Erreur
230
+ console.log(erreur);
231
+
232
+ return [];
233
+ }
234
+ },
235
+ paginateItems(size, page) {
236
+ const start = (page - 1) * size;
237
+ const end = page * size;
238
+
239
+ return this.itemsAPI.slice(start, end);
240
+ },
241
+ async updatePage({ size, page }) {
242
+ this.loading = true;
243
+
244
+ setTimeout(() => {
245
+ this.items = this.paginateItems(size, page);
246
+ this.loading = false;
247
+ }, 1000);
248
+ },
249
+ },
250
+ }),
251
+ };
@@ -0,0 +1,102 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import * as utils from './utils';
3
+
4
+ // Components
5
+ import { MDataTable } from '@mozaic-ds/datatable-vue';
6
+ import MButton from '../button/MButton.vue';
7
+ import { Filter24 } from '@mozaic-ds/icons-vue';
8
+
9
+ const meta: Meta<typeof MDataTable> = {
10
+ title: 'DataTable/MDataTable Empty states',
11
+ component: MDataTable,
12
+ args: utils.args,
13
+ parameters: {
14
+ componentName: 'MDataTable',
15
+ docs: {
16
+ canvas: { sourceState: 'none' },
17
+ }
18
+ },
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof MDataTable>;
23
+
24
+ export const Default: Story = {
25
+ args: {
26
+ items: [],
27
+ },
28
+ render: (args) => ({
29
+ components: { MDataTable },
30
+ setup() {
31
+ return { args };
32
+ },
33
+ template: `
34
+ <MDataTable v-bind="args">
35
+ <template v-slot:no-data>
36
+ <p>
37
+ <strong>There is nothing to display</strong><br />
38
+ Short explanation of why and/or how to do
39
+ </p>
40
+ </template>
41
+ </MDataTable>
42
+ `,
43
+ }),
44
+ };
45
+
46
+ export const Filters: Story = {
47
+ args: {
48
+ items: [],
49
+ },
50
+ render: (args) => ({
51
+ components: { MDataTable, MButton, Filter24 },
52
+ setup() {
53
+ return { args };
54
+ },
55
+ template: `
56
+ <MDataTable v-bind="args">
57
+ <template v-slot:no-data>
58
+ <p>
59
+ <strong>There is no result</strong><br />
60
+ Please try changing your filters
61
+ </p>
62
+ <MButton
63
+ outlined
64
+ size="s"
65
+ iconPosition="left"
66
+ >
67
+ <template #icon><Filter24/></template>
68
+ Change filters
69
+ </MButton>
70
+ </template>
71
+ </MDataTable>
72
+ `,
73
+ }),
74
+ };
75
+
76
+ export const Search: Story = {
77
+ args: {
78
+ items: [],
79
+ },
80
+ render: (args) => ({
81
+ components: { MDataTable, MButton },
82
+ setup() {
83
+ return { args };
84
+ },
85
+ template: `
86
+ <MDataTable v-bind="args">
87
+ <template v-slot:no-data>
88
+ <p>
89
+ <strong>There is no result</strong><br />
90
+ Please try changing your search
91
+ </p>
92
+ <MButton
93
+ outlined
94
+ size="s"
95
+ >
96
+ Reset search
97
+ </MButton>
98
+ </template>
99
+ </MDataTable>
100
+ `,
101
+ }),
102
+ };
@@ -0,0 +1,95 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import * as utils from './utils';
3
+
4
+ // Components
5
+ import { MDataTable, MDataTableColumn } from '@mozaic-ds/datatable-vue';
6
+
7
+ const meta: Meta<typeof MDataTable> = {
8
+ title: 'DataTable/MDataTable Expandable',
9
+ component: MDataTable,
10
+ args: utils.args,
11
+ parameters: {
12
+ componentName: 'MDataTable',
13
+ docs: {
14
+ canvas: { sourceState: 'none' },
15
+ }
16
+ },
17
+ render: (args) => ({
18
+ components: { MDataTable, MDataTableColumn },
19
+ setup() {
20
+ return { args };
21
+ },
22
+ template: `
23
+ <MDataTable v-bind="args">
24
+ <!--
25
+ Default content
26
+ -->
27
+ <MDataTableColumn label="Name" value="name" />
28
+ <MDataTableColumn label="Stock" value="stock" />
29
+
30
+ <!-- Start Date -->
31
+ <MDataTableColumn label="Start date" value="startDate" />
32
+ <template v-slot:cell.startDate="{ item }">
33
+ {{ formatDate(item.startDate) }}
34
+ </template>
35
+
36
+ <!-- End Date -->
37
+ <MDataTableColumn label="End date" value="endDate" />
38
+ <template v-slot:cell.endDate="{ item }">
39
+ {{ formatDate(item.startDate) }}
40
+ </template>
41
+
42
+ <!-- Status -->
43
+ <MDataTableColumn label="Statut" value="status" />
44
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
45
+
46
+ <!-- Expandable Row -->
47
+ <template v-slot:expandContent="expandProps">
48
+ <div
49
+ style="
50
+ display: flex;
51
+ justify-content: center;
52
+ align-items: center;
53
+ padding: 20px;
54
+ "
55
+ >
56
+ <p>
57
+ {{ expandProps }}
58
+ <strong>
59
+ This is the expand content for row n°{{ expandProps.rowIndex }}
60
+ </strong>
61
+ </p>
62
+ </div>
63
+ </template>
64
+ </MDataTable>
65
+ `,
66
+ methods: {
67
+ formatDate(date) {
68
+ return new Date(date).toLocaleString();
69
+ },
70
+ },
71
+ }),
72
+ };
73
+
74
+ export default meta;
75
+ type Story = StoryObj<typeof MDataTable>;
76
+
77
+ export const Default: Story = {
78
+ args: {
79
+ expandable: true,
80
+ },
81
+ };
82
+
83
+ export const ExpandedRows: Story = {
84
+ args: {
85
+ ...Default.args,
86
+ showExpandableContent: true,
87
+ },
88
+ };
89
+
90
+ export const SpecifiedRows: Story = {
91
+ args: {
92
+ ...Default.args,
93
+ expandableList: [1, 7, 9],
94
+ },
95
+ };
@@ -0,0 +1,96 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { ref } from 'vue';
3
+ import * as utils from './utils';
4
+
5
+ // Components
6
+ import { MDataTable, MDataTableColumn } from '@mozaic-ds/datatable-vue';
7
+
8
+ const meta: Meta<typeof MDataTable> = {
9
+ title: 'DataTable/MDataTable Nested',
10
+ component: MDataTable,
11
+ args: utils.args,
12
+ parameters: {
13
+ componentName: 'MDataTable',
14
+ docs: {
15
+ canvas: { sourceState: 'none' },
16
+ }
17
+ },
18
+ render: (args) => ({
19
+ components: { MDataTable, MDataTableColumn },
20
+ setup() {
21
+ const subItems = ref([...utils.addlDeals.slice(0, 5)]);
22
+ return { args, subItems };
23
+ },
24
+ template: `
25
+ <MDataTable v-bind="args">
26
+ <!-- Columns -->
27
+ <MDataTableColumn label="Name" value="name" />
28
+ <MDataTableColumn label="Stock" value="stock" />
29
+ <MDataTableColumn label="Start date" value="startDate" />
30
+ <MDataTableColumn label="End date" value="endDate" />
31
+ <MDataTableColumn label="Statut" value="status" />
32
+
33
+ <!-- Cells -->
34
+ <template v-slot:cell.startDate="{ item }">
35
+ {{ formatDate(item.startDate) }}
36
+ </template>
37
+ <template v-slot:cell.endDate="{ item }">
38
+ {{ formatDate(item.startDate) }}
39
+ </template>
40
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
41
+
42
+ <!-- Expandable Content -->
43
+ <template v-slot:expandContent="slotProps">
44
+ <MDataTable :items="subItems" nested>
45
+ <!-- Columns -->
46
+ <MDataTableColumn label="" value="button" type="button" />
47
+ <MDataTableColumn label="Name" value="name" />
48
+ <MDataTableColumn label="Stock" value="stock" />
49
+ <MDataTableColumn label="Start date" value="startDate" />
50
+ <MDataTableColumn label="End date" value="endDate" />
51
+ <MDataTableColumn label="Statut" value="status" />
52
+ <!-- Cells -->
53
+ <template v-slot:cell.startDate="{ item }">
54
+ {{ formatDate(item.startDate) }}
55
+ </template>
56
+ <template v-slot:cell.endDate="{ item }">
57
+ {{ formatDate(item.startDate) }}
58
+ </template>
59
+ <template v-slot:cell.status="{ item }">
60
+ {{ item.status.code }}
61
+ </template>
62
+ </MDataTable>
63
+ </template>
64
+ </MDataTable>
65
+ `,
66
+ methods: {
67
+ formatDate(date) {
68
+ return new Date(date).toLocaleString();
69
+ },
70
+ },
71
+ }),
72
+ };
73
+
74
+ export default meta;
75
+ type Story = StoryObj<typeof MDataTable>;
76
+
77
+ export const Default: Story = {
78
+ args: {
79
+ expandable: true,
80
+ },
81
+ };
82
+
83
+ export const MaxHeight: Story = {
84
+ args: {
85
+ ...Default.args,
86
+ maxHeight: '300px',
87
+ },
88
+ };
89
+
90
+ export const FixedHeader: Story = {
91
+ args: {
92
+ ...Default.args,
93
+ fixedHeader: true,
94
+ maxHeight: '400px',
95
+ },
96
+ };
@@ -0,0 +1,124 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import * as utils from './utils';
3
+
4
+ // Components
5
+ import { MDataTable, MDataTableColumn } from '@mozaic-ds/datatable-vue';
6
+ import MCheckbox from '../checkbox/MCheckbox.vue';
7
+
8
+
9
+ const meta: Meta<typeof MDataTable> = {
10
+ title: 'DataTable/MDataTable Selectable',
11
+ component: MDataTable,
12
+ args: utils.args,
13
+ parameters: {
14
+ componentName: 'MDataTable',
15
+ docs: {
16
+ canvas: { sourceState: 'none' },
17
+ }
18
+ },
19
+ render: (args) => ({
20
+ components: { MDataTable, MDataTableColumn },
21
+ setup() {
22
+ return { args };
23
+ },
24
+ template: `
25
+ <MDataTable v-bind="args">
26
+ <!--
27
+ Default content
28
+ -->
29
+ <MDataTableColumn label="Name" value="name" />
30
+ <MDataTableColumn label="Stock" value="stock" />
31
+
32
+ <!-- Start Date -->
33
+ <MDataTableColumn label="Start date" value="startDate" />
34
+ <template v-slot:cell.startDate="{ item }">
35
+ {{ formatDate(item.startDate) }}
36
+ </template>
37
+
38
+ <!-- End Date -->
39
+ <MDataTableColumn label="End date" value="endDate" />
40
+ <template v-slot:cell.endDate="{ item }">
41
+ {{ formatDate(item.startDate) }}
42
+ </template>
43
+
44
+ <!-- Status -->
45
+ <MDataTableColumn label="Statut" value="status" />
46
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
47
+ </MDataTable>
48
+ `,
49
+ methods: {
50
+ formatDate(date) {
51
+ return new Date(date).toLocaleString();
52
+ },
53
+ },
54
+ }),
55
+ };
56
+
57
+ export default meta;
58
+ type Story = StoryObj<typeof MDataTable>;
59
+
60
+ export const Default: Story = {
61
+ args: {
62
+ selectable: true,
63
+ },
64
+ };
65
+
66
+ export const SpecifiedRows: Story = {
67
+ render: (args) => ({
68
+ components: { MDataTable, MDataTableColumn, MCheckbox },
69
+ setup() {
70
+ return { args };
71
+ },
72
+ template: `
73
+ <MDataTable v-bind="args">
74
+ <!-- Headers -->
75
+ <MDataTableColumn
76
+ label="MasterCheckbox"
77
+ value="mastercheckbox"
78
+ class="mc-datatable__cell-checkbox"
79
+ />
80
+ <template v-slot:header.mastercheckbox>
81
+ <MCheckbox id="mastercheckbox" />
82
+ </template>
83
+
84
+ <MDataTableColumn label="Name" value="name" />
85
+ <MDataTableColumn label="Stock" value="stock" />
86
+ <MDataTableColumn label="Start date" value="startDate" />
87
+ <MDataTableColumn label="End date" value="endDate" />
88
+ <MDataTableColumn label="Statut" value="status" />
89
+
90
+ <!-- Cells -->
91
+
92
+ <!-- [Cell] => Master Checkbox -->
93
+ <template v-slot:cell.mastercheckbox="{ item }">
94
+ <MCheckbox :id="item.id" :disabled="isDisabled(item)" />
95
+ </template>
96
+
97
+ <!-- [Cell] => Start Date -->
98
+ <template v-slot:cell.startDate="{ item }">
99
+ {{ formatDate(item.startDate) }}
100
+ </template>
101
+
102
+ <!-- [Cell] => End Date -->
103
+ <template v-slot:cell.endDate="{ item }">
104
+ {{ formatDate(item.startDate) }}
105
+ </template>
106
+
107
+ <!-- [Cell] => Status -->
108
+ <template v-slot:cell.status="{ item }"> {{ item.status.code }} </template>
109
+ </MDataTable>
110
+ `,
111
+ methods: {
112
+ formatDate(date) {
113
+ return new Date(date).toLocaleString();
114
+ },
115
+ isDisabled(item) {
116
+ if (item.id % 2 == 0) {
117
+ return true;
118
+ }
119
+
120
+ return false;
121
+ },
122
+ },
123
+ }),
124
+ };