@mozaic-ds/vue 2.16.0 → 2.18.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.
- package/dist/mozaic-vue.css +2 -1
- package/dist/mozaic-vue.d.ts +258 -137
- package/dist/mozaic-vue.js +14054 -10878
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +7 -25
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +22 -11
- package/src/components/BrandPresets.mdx +2 -2
- package/src/components/Migration.mdx +651 -0
- package/src/components/accordionlist/MAccordionList.figma.ts +43 -0
- package/src/components/accordionlistitem/MAccordionListItem.figma.ts +27 -0
- package/src/components/accordionlistitem/MAccordionListItem.spec.ts +22 -3
- package/src/components/accordionlistitem/MAccordionListItem.vue +38 -28
- package/src/components/actionbottombar/MActionBottomBar.figma.ts +24 -0
- package/src/components/actionlistbox/MActionListbox.figma.ts +30 -0
- package/src/components/avatar/MAvatar.figma.ts +31 -0
- package/src/components/breadcrumb/MBreadcrumb.figma.ts +31 -0
- package/src/components/builtinmenu/MBuiltInMenu.figma.ts +23 -0
- package/src/components/builtinmenu/MBuiltInMenu.spec.ts +30 -1
- package/src/components/builtinmenu/MBuiltInMenu.vue +26 -17
- package/src/components/builtinmenu/README.md +2 -0
- package/src/components/button/MButton.figma.ts +41 -0
- package/src/components/callout/MCallout.figma.ts +29 -0
- package/src/components/callout/MCallout.spec.ts +35 -0
- package/src/components/callout/MCallout.vue +22 -4
- package/src/components/callout/README.md +2 -0
- package/src/components/carousel/MCarousel.figma.ts +32 -0
- package/src/components/checkbox/MCheckbox.figma.ts +45 -0
- package/src/components/checkboxgroup/MCheckboxGroup.figma.ts +30 -0
- package/src/components/checklistmenu/MCheckListMenu.figma.ts +29 -0
- package/src/components/checklistmenu/MCheckListMenu.spec.ts +12 -1
- package/src/components/checklistmenu/MCheckListMenu.vue +6 -0
- package/src/components/checklistmenu/README.md +2 -0
- package/src/components/circularprogressbar/MCircularProgressbar.figma.ts +31 -0
- package/src/components/combobox/MCombobox.figma.ts +48 -0
- package/src/components/combobox/MCombobox.spec.ts +1 -1
- package/src/components/combobox/MCombobox.vue +18 -9
- package/src/components/combobox/README.md +2 -2
- package/src/components/container/MContainer.figma.ts +30 -0
- package/src/components/datatable/DataTable.stories.ts +277 -0
- package/src/components/datatable/DataTableCells.stories.ts +251 -0
- package/src/components/datatable/DataTableEmpty.stories.ts +102 -0
- package/src/components/datatable/DataTableExpandable.stories.ts +95 -0
- package/src/components/datatable/DataTableNested.stories.ts +96 -0
- package/src/components/datatable/DataTableSelectable.stories.ts +124 -0
- package/src/components/datatable/DataTableSortable.stories.ts +164 -0
- package/src/components/datatable/MDataTable.types.ts +54 -0
- package/src/components/datatable/assets/styles.scss +10 -0
- package/src/components/datatable/datatable.mdx +63 -0
- package/src/components/datatable/tools/data.js +8 -0
- package/src/components/datatable/tools/data.json +2018 -0
- package/src/components/datatable/utils.js +19 -0
- package/src/components/datepicker/MDatepicker.figma.ts +20 -0
- package/src/components/divider/MDivider.figma.ts +30 -0
- package/src/components/drawer/MDrawer.figma.ts +37 -0
- package/src/components/drawer/README.md +1 -1
- package/src/components/field/MField.figma.ts +30 -0
- package/src/components/fileuploader/MFileUploader.figma.ts +23 -0
- package/src/components/fileuploaderitem/MFileUploaderItem.figma.ts +27 -0
- package/src/components/flag/MFlag.figma.ts +26 -0
- package/src/components/iconbutton/MIconButton.figma.ts +54 -0
- package/src/components/kpiitem/MKpiItem.figma.ts +33 -0
- package/src/components/linearprogressbarbuffer/MLinearProgressbarBuffer.figma.ts +31 -0
- package/src/components/linearprogressbarpercentage/MLinearProgressbarPercentage.figma.ts +26 -0
- package/src/components/link/MLink.figma.ts +32 -0
- package/src/components/loader/MLoader.figma.ts +30 -0
- package/src/components/loadingoverlay/MLoadingOverlay.figma.ts +18 -0
- package/src/components/modal/MModal.figma.ts +27 -0
- package/src/components/navigationindicator/MNavigationIndicator.figma.ts +24 -0
- package/src/components/navigationindicator/MNavigationIndicator.spec.ts +75 -18
- package/src/components/navigationindicator/MNavigationIndicator.vue +10 -12
- package/src/components/numberbadge/MNumberBadge.figma.ts +31 -0
- package/src/components/optionListbox/MOptionListbox.figma.ts +36 -0
- package/src/components/optionListbox/MOptionListbox.vue +34 -19
- package/src/components/optionListbox/README.md +1 -1
- package/src/components/overlay/MOverlay.figma.ts +20 -0
- package/src/components/pageheader/MPageHeader.figma.ts +21 -0
- package/src/components/pagination/MPagination.figma.ts +34 -0
- package/src/components/passwordinput/MPasswordInput.figma.ts +30 -0
- package/src/components/phonenumber/MPhoneNumber.figma.ts +47 -0
- package/src/components/pincode/MPincode.figma.ts +41 -0
- package/src/components/pincode/MPincode.spec.ts +1 -4
- package/src/components/pincode/MPincode.vue +11 -15
- package/src/components/popover/MPopover.figma.ts +42 -0
- package/src/components/popover/MPopover.spec.ts +126 -0
- package/src/components/popover/MPopover.vue +36 -1
- package/src/components/quantityselector/MQuantitySelector.figma.ts +50 -0
- package/src/components/radio/MRadio.figma.ts +40 -0
- package/src/components/radiogroup/MRadioGroup.figma.ts +30 -0
- package/src/components/segmentedcontrol/MSegmentedControl.figma.ts +33 -0
- package/src/components/segmentedcontrol/MSegmentedControl.spec.ts +92 -0
- package/src/components/segmentedcontrol/MSegmentedControl.vue +61 -2
- package/src/components/select/MSelect.figma.ts +49 -0
- package/src/components/sidebar/MSidebar.figma.ts +28 -0
- package/src/components/sidebarexpandableitem/MSidebarExpandableItem.figma.ts +19 -0
- package/src/components/sidebarfooter/MSidebarFooter.figma.ts +21 -0
- package/src/components/sidebarheader/MSidebarHeader.figma.ts +18 -0
- package/src/components/sidebarnavitem/MSidebarNavItem.figma.ts +23 -0
- package/src/components/sidebarshortcutitem/MSidebarShortcutItem.figma.ts +20 -0
- package/src/components/starrating/MStarRating.figma.ts +35 -0
- package/src/components/starrating/MStarRating.spec.ts +19 -22
- package/src/components/starrating/MStarRating.vue +3 -2
- package/src/components/statusbadge/MStatusBadge.figma.ts +27 -0
- package/src/components/statusdot/MStatusDot.figma.ts +31 -0
- package/src/components/statusmessage/MStatusMessage.figma.ts +28 -0
- package/src/components/statusmessage/MStatusMessage.spec.ts +15 -0
- package/src/components/statusmessage/MStatusMessage.stories.ts +4 -0
- package/src/components/statusmessage/MStatusMessage.vue +7 -0
- package/src/components/statusmessage/README.md +2 -0
- package/src/components/statusnotification/MStatusNotification.figma.ts +29 -0
- package/src/components/stepperbottombar/MStepperBottomBar.figma.ts +20 -0
- package/src/components/steppercompact/MStepperCompact.figma.ts +21 -0
- package/src/components/stepperinline/MStepperInline.figma.ts +23 -0
- package/src/components/stepperstacked/MStepperStacked.figma.ts +23 -0
- package/src/components/tabs/MTabs.figma.ts +33 -0
- package/src/components/tabs/MTabs.vue +90 -4
- package/src/components/tabs/Mtabs.spec.ts +162 -0
- package/src/components/tag/MTag.figma.ts +26 -0
- package/src/components/tag/MTag.stories.ts +13 -3
- package/src/components/tag/MTag.vue +11 -1
- package/src/components/tag/README.md +6 -0
- package/src/components/textarea/MTextArea.figma.ts +28 -0
- package/src/components/textinput/MTextInput.figma.ts +51 -0
- package/src/components/tile/MTile.figma.ts +31 -0
- package/src/components/tileclickable/MTileClickable.figma.ts +31 -0
- package/src/components/tileexpandable/MTileExpandable.figma.ts +31 -0
- package/src/components/tileselectable/MTileSelectable.figma.ts +29 -0
- package/src/components/toaster/MToaster.figma.ts +25 -0
- package/src/components/toggle/MToggle.figma.ts +39 -0
- package/src/components/togglegroup/MToggleGroup.figma.ts +30 -0
- package/src/components/tooltip/MTooltip.figma.ts +29 -0
- package/src/main.ts +1 -0
|
@@ -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
|
+
};
|
|
@@ -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
|
+
};
|