@cnamts/synapse 0.0.11-alpha → 0.0.12-alpha

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 (108) hide show
  1. package/dist/design-system-v3.js +3878 -3189
  2. package/dist/design-system-v3.umd.cjs +1 -1
  3. package/dist/src/components/Amelipro/types/languages.d.ts +6 -0
  4. package/dist/src/components/Amelipro/types/types.d.ts +65 -0
  5. package/dist/src/components/CookieBanner/CookieBanner.d.ts +1 -1
  6. package/dist/src/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
  7. package/dist/src/components/Customs/SyTextField/SyTextField.d.ts +29 -23
  8. package/dist/src/components/Customs/SyTextField/types.d.ts +1 -0
  9. package/dist/src/components/DatePicker/DatePicker.d.ts +70 -59
  10. package/dist/src/components/DatePicker/DateTextInput.d.ts +67 -56
  11. package/dist/src/components/ErrorPage/ErrorPage.d.ts +1 -1
  12. package/dist/src/components/FileList/FileList.d.ts +1 -0
  13. package/dist/src/components/FileList/UploadItem/UploadItem.d.ts +1 -1
  14. package/dist/src/components/FilterSideBar/FilterSideBar.d.ts +31 -0
  15. package/dist/src/components/FilterSideBar/locales.d.ts +7 -0
  16. package/dist/src/components/FilterSideBar/tests/FilterSideBar.spec.d.ts +1 -0
  17. package/dist/src/components/LangBtn/LangBtn.d.ts +2 -2
  18. package/dist/src/components/NirField/NirField.d.ts +940 -0
  19. package/dist/src/components/NotificationBar/NotificationBar.d.ts +1 -1
  20. package/dist/src/components/PasswordField/PasswordField.d.ts +40 -8
  21. package/dist/src/components/PeriodField/PeriodField.d.ts +142 -120
  22. package/dist/src/components/PhoneField/PhoneField.d.ts +11 -2
  23. package/dist/src/components/RatingPicker/EmotionPicker/EmotionPicker.d.ts +1 -1
  24. package/dist/src/components/RatingPicker/NumberPicker/NumberPicker.d.ts +1 -1
  25. package/dist/src/components/RatingPicker/StarsPicker/StarsPicker.d.ts +1 -1
  26. package/dist/src/components/UploadWorkflow/config.d.ts +29 -0
  27. package/dist/src/components/UploadWorkflow/locales.d.ts +7 -0
  28. package/dist/src/components/UploadWorkflow/tests/UploadWorkflow.spec.d.ts +1 -0
  29. package/dist/src/components/UploadWorkflow/types.d.ts +19 -0
  30. package/dist/src/components/UploadWorkflow/useFileList.d.ts +10 -0
  31. package/dist/src/components/UploadWorkflow/useFileUploadJourney.d.ts +9 -0
  32. package/dist/src/components/index.d.ts +2 -0
  33. package/dist/src/composables/rules/useFieldValidation.d.ts +1 -0
  34. package/dist/src/composables/validation/tests/useValidation.spec.d.ts +1 -0
  35. package/dist/src/composables/validation/useValidation.d.ts +39 -0
  36. package/dist/src/designTokens/index.d.ts +3 -1
  37. package/dist/src/vuetifyConfig.d.ts +81 -0
  38. package/dist/style.css +1 -1
  39. package/package.json +1 -1
  40. package/src/assets/_elevations.scss +89 -0
  41. package/src/assets/_fonts.scss +6 -0
  42. package/src/assets/_radius.scss +86 -0
  43. package/src/assets/_spacers.scss +149 -0
  44. package/src/assets/settings.scss +7 -3
  45. package/src/assets/tokens.scss +32 -29
  46. package/src/components/Amelipro/types/languages.d.ts +6 -0
  47. package/src/components/Amelipro/types/types.d.ts +65 -0
  48. package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +65 -0
  49. package/src/components/Customs/SyInputSelect/SyInputSelect.vue +13 -3
  50. package/src/components/Customs/SySelect/SySelect.stories.ts +88 -5
  51. package/src/components/Customs/SySelect/SySelect.vue +36 -10
  52. package/src/components/Customs/SySelect/tests/SySelect.spec.ts +135 -2
  53. package/src/components/Customs/SyTextField/SyTextField.stories.ts +576 -85
  54. package/src/components/Customs/SyTextField/SyTextField.vue +132 -104
  55. package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +190 -38
  56. package/src/components/Customs/SyTextField/types.d.ts +1 -0
  57. package/src/components/DatePicker/DatePicker.vue +405 -137
  58. package/src/components/DatePicker/DateTextInput.vue +15 -0
  59. package/src/components/DatePicker/tests/DatePicker.spec.ts +8 -15
  60. package/src/components/FileList/FileList.vue +2 -1
  61. package/src/components/FileList/UploadItem/UploadItem.vue +10 -0
  62. package/src/components/FileUpload/FileUpload.stories.ts +84 -0
  63. package/src/components/FileUpload/FileUpload.vue +1 -0
  64. package/src/components/FileUpload/tests/FileUpload.spec.ts +4 -4
  65. package/src/components/FilterInline/FilterInline.mdx +180 -34
  66. package/src/components/FilterInline/FilterInline.stories.ts +363 -6
  67. package/src/components/FilterSideBar/FilterSideBar.mdx +237 -0
  68. package/src/components/FilterSideBar/FilterSideBar.stories.ts +798 -0
  69. package/src/components/FilterSideBar/FilterSideBar.vue +193 -0
  70. package/src/components/FilterSideBar/locales.ts +8 -0
  71. package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +305 -0
  72. package/src/components/FilterSideBar/tests/__snapshots__/FilterSideBar.spec.ts.snap +39 -0
  73. package/src/components/HeaderBar/Usages.mdx +1 -1
  74. package/src/components/NirField/NirField.stories.ts +573 -29
  75. package/src/components/NirField/NirField.vue +397 -359
  76. package/src/components/NirField/tests/NirField.spec.ts +88 -52
  77. package/src/components/NirField/tests//342/200/257dataset/342/200/257.md +12 -0
  78. package/src/components/NotificationBar/Accessibilite.stories.ts +4 -0
  79. package/src/components/NotificationBar/NotificationBar.stories.ts +18 -13
  80. package/src/components/PasswordField/PasswordField.mdx +129 -47
  81. package/src/components/PasswordField/PasswordField.stories.ts +924 -120
  82. package/src/components/PasswordField/PasswordField.vue +209 -99
  83. package/src/components/PasswordField/tests/PasswordField.spec.ts +138 -9
  84. package/src/components/PeriodField/PeriodField.vue +55 -54
  85. package/src/components/PhoneField/PhoneField.stories.ts +69 -0
  86. package/src/components/PhoneField/PhoneField.vue +3 -0
  87. package/src/components/PhoneField/indicatifs.ts +1 -1
  88. package/src/components/UploadWorkflow/UploadWorkflow.mdx +75 -0
  89. package/src/components/UploadWorkflow/UploadWorkflow.stories.ts +943 -0
  90. package/src/components/UploadWorkflow/UploadWorkflow.vue +230 -0
  91. package/src/components/UploadWorkflow/config.ts +29 -0
  92. package/src/components/UploadWorkflow/locales.ts +8 -0
  93. package/src/components/UploadWorkflow/tests/UploadWorkflow.spec.ts +257 -0
  94. package/src/components/UploadWorkflow/tests/__snapshots__/UploadWorkflow.spec.ts.snap +54 -0
  95. package/src/components/UploadWorkflow/types.ts +21 -0
  96. package/src/components/UploadWorkflow/useFileList.ts +84 -0
  97. package/src/components/UploadWorkflow/useFileUploadJourney.ts +18 -0
  98. package/src/components/index.ts +2 -0
  99. package/src/composables/rules/useFieldValidation.ts +5 -2
  100. package/src/composables/validation/tests/useValidation.spec.ts +154 -0
  101. package/src/composables/validation/useValidation.ts +165 -0
  102. package/src/designTokens/index.ts +4 -0
  103. package/src/stories/Demarrer/Accueil.mdx +1 -1
  104. package/src/stories/DesignTokens/ThemePA.mdx +4 -30
  105. package/src/stories/GuideDuDev/UtiliserLesRules.mdx +319 -76
  106. package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
  107. package/src/vuetifyConfig.ts +61 -0
  108. package/src/composables/useFilterable/__snapshots__/useFilterable.spec.ts.snap +0 -3
@@ -0,0 +1,943 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import UploadWorkflow from './UploadWorkflow.vue'
3
+ import { fn } from '@storybook/test'
4
+ import { VBtn, VSnackbar } from 'vuetify/components'
5
+ import { ref } from 'vue'
6
+
7
+ const meta: Meta<typeof UploadWorkflow> = {
8
+ title: 'Composants/Formulaires/UploadWorkflow',
9
+ component: UploadWorkflow,
10
+ parameters: {
11
+ controls: { exclude: ['update:modelValue', 'error'] },
12
+ },
13
+ argTypes: {
14
+ 'modelValue': {
15
+ description: 'La valeur du modèle pour le champ.',
16
+ control: false,
17
+ table: {
18
+ category: 'props',
19
+ type: {
20
+ summary: 'array',
21
+ detail: `{
22
+ id: Readonly<string>
23
+ title: Readonly<string>
24
+ state: 'initial' | 'success' | 'error' | 'loading'
25
+ optional?: Readonly<boolean>
26
+ showPreviewBtn?: Readonly<boolean>
27
+ fileName: string
28
+ file: File
29
+ )[]`,
30
+ },
31
+ },
32
+ },
33
+ 'uploadList': {
34
+ description: 'La liste des fichiers à uploader.',
35
+ control: 'object',
36
+ table: {
37
+ category: 'props',
38
+ type: {
39
+ summary: 'Array',
40
+ detail: `{
41
+ id: string
42
+ title: string
43
+ state?: 'initial' | 'success' | 'error' | 'loading'
44
+ optional?: boolean
45
+ showPreviewBtn?: boolean
46
+ } & ({
47
+ fileName: string
48
+ file: File
49
+ } | {
50
+ fileName?: undefined
51
+ file?: undefined
52
+ })[]`,
53
+ },
54
+ },
55
+ },
56
+ 'showFilePreview': {
57
+ description: 'Active la prévisualisation du fichier avant validation.',
58
+ control: 'boolean',
59
+ table: {
60
+ type: {
61
+ summary: 'boolean',
62
+ },
63
+ defaultValue: {
64
+ summary: 'false',
65
+ },
66
+ },
67
+ },
68
+ 'sectionTitle': {
69
+ description: 'Le titre de la section.',
70
+ control: 'text',
71
+ table: {
72
+ category: 'props',
73
+ type: {
74
+ summary: 'string',
75
+ },
76
+ },
77
+ },
78
+ 'vuetifyOptions': {
79
+ description: 'Les options pour les composants enfants.',
80
+ control: 'object',
81
+ table: {
82
+ category: 'props',
83
+ type: {
84
+ summary: 'object',
85
+ detail: `{
86
+ fileUpload: Record<string, unknown>
87
+ dialog: Record<string, unknown>
88
+ card: Record<string, unknown>
89
+ select: Record<string, unknown>
90
+ layout: Record<string, unknown>
91
+ cancelBtn: Record<string, unknown>
92
+ confirmBtn: Record<string, unknown>
93
+ }`,
94
+ },
95
+ defaultValue: {
96
+ summary: '{}',
97
+ detail: `{
98
+ fileUpload: {
99
+ class: 'mt-6',
100
+ },
101
+ dialog: {
102
+ persistent: true,
103
+ width: '550',
104
+ },
105
+ card: {
106
+ class: 'pa-4',
107
+ },
108
+ select: {
109
+ variant: 'outlined',
110
+ validateOnBlur: true,
111
+ label: 'Nature du fichier',
112
+ },
113
+ layout: {
114
+ wrap: true,
115
+ class: 'mt-2',
116
+ },
117
+ cancelBtn: {
118
+ text: true,
119
+ class: 'mr-4',
120
+ color: 'accent',
121
+ },
122
+ confirmBtn: {
123
+ color: 'accent',
124
+ },
125
+ }`,
126
+ },
127
+ },
128
+ },
129
+ 'locales': {
130
+ description: 'Les locales pour les textes.',
131
+ control: 'object',
132
+ table: {
133
+ category: 'props',
134
+ type: {
135
+ summary: 'object',
136
+ },
137
+ defaultValue: {
138
+ summary: '{}',
139
+ detail: `{
140
+ title: (plural: boolean): string =>
141
+ \`Document\${plural ? 's' : ''} à nous transmettre\`,
142
+ importTitle: 'Importer des fichiers',
143
+ modalTitle: 'Fichier transmis',
144
+ cancelBtn: 'Retour',
145
+ confirmBtn: 'Confirmer',
146
+ }`,
147
+ },
148
+ },
149
+ },
150
+ 'maxWidth': {
151
+ description: 'Largeur maximale du composant',
152
+ control: 'text',
153
+ table: {
154
+ type: {
155
+ summary: 'number | string',
156
+ },
157
+ category: 'props',
158
+ },
159
+ },
160
+ 'minWidth': {
161
+ description: 'Largeur minimale du composant',
162
+ control: 'text',
163
+ table: {
164
+ type: {
165
+ summary: 'number | string',
166
+ },
167
+ category: 'props',
168
+ },
169
+ },
170
+ 'width': {
171
+ description: 'Largeur du composant',
172
+ control: 'text',
173
+ table: {
174
+ type: {
175
+ summary: 'number | string',
176
+ },
177
+ category: 'props',
178
+ },
179
+ },
180
+ 'onError': {
181
+ description: 'Événement émis lorsqu\'une erreur survient.',
182
+ table: {
183
+ category: 'events',
184
+ type: {
185
+ summary: 'string[]',
186
+ },
187
+ },
188
+ },
189
+ 'onUpdate:modelValue': {
190
+ description: 'Événement émis lorsqu\'un fichier est ajouté ou supprimé.',
191
+ table: {
192
+ category: 'events',
193
+ type: {
194
+ summary: 'Object[]',
195
+ detail: `{
196
+ id: string
197
+ title: string
198
+ state: 'initial' | 'success' | 'error' | 'loading'
199
+ optional?: boolean
200
+ showPreviewBtn?: boolean
201
+ fileName: string
202
+ file: File
203
+ }[]`,
204
+ },
205
+ },
206
+ },
207
+ // slots
208
+ 'title': {
209
+ description: 'Slot pour le titre de la section.',
210
+ table: {
211
+ category: 'slots',
212
+ type: {
213
+ summary: '{}',
214
+ },
215
+ },
216
+ control: 'text',
217
+ },
218
+ 'modal-title': {
219
+ description: 'Slot pour le titre de la modale.',
220
+ table: {
221
+ category: 'slots',
222
+ type: {
223
+ summary: '{}',
224
+ },
225
+ },
226
+ control: 'text',
227
+ },
228
+ 'modal-description': {
229
+ description: 'Slot pour la description de la modale.',
230
+ table: {
231
+ category: 'slots',
232
+ type: {
233
+ summary: '{}',
234
+ },
235
+ },
236
+ control: 'text',
237
+ },
238
+ 'preview-description': {
239
+ description: 'Slot pour la description de la prévisualisation.',
240
+ table: {
241
+ category: 'slots',
242
+ type: {
243
+ summary: '{}',
244
+ },
245
+ },
246
+ control: 'text',
247
+ },
248
+ },
249
+ } satisfies Meta<typeof UploadWorkflow>
250
+
251
+ export default meta
252
+
253
+ type Story = StoryObj<typeof meta>
254
+
255
+ export const Default: Story = {
256
+ args: {
257
+ 'modelValue': [],
258
+ 'uploadList': [
259
+ {
260
+ id: '1',
261
+ title: 'Carte d\'identité',
262
+ },
263
+ {
264
+ id: '2',
265
+ title: 'Facture de soin',
266
+ },
267
+ ],
268
+ 'onUpdate:modelValue': fn(),
269
+ 'onError': fn(),
270
+ },
271
+ parameters: {
272
+ sourceCode: [
273
+ {
274
+ name: 'Template',
275
+ code: `<template>
276
+ <UploadWorkflow
277
+ v-model="files"
278
+ :uploadList="uploadList"
279
+ />
280
+ </template>`,
281
+ },
282
+ {
283
+ name: 'Script',
284
+ code: `<script setup lang="ts">
285
+ import { ref } from 'vue'
286
+ import { UploadWorkflow } from '@cnamts/synapse'
287
+
288
+ const files = ref([])
289
+
290
+ const uploadList = [
291
+ {
292
+ id: '1',
293
+ title: 'Carte d\\'identité',
294
+ },
295
+ {
296
+ id: '2',
297
+ title: 'Facture de soin',
298
+ },
299
+ ]
300
+ </script>`,
301
+ },
302
+ ],
303
+ },
304
+ }
305
+
306
+ export const OptionalDocument: Story = {
307
+ args: {
308
+ 'modelValue': [],
309
+ 'uploadList': [
310
+ {
311
+ id: '1',
312
+ title: 'Carte d\'identité',
313
+ },
314
+ {
315
+ id: '2',
316
+ title: 'Facture de soin',
317
+ optional: true,
318
+ },
319
+ {
320
+ id: '3',
321
+ title: 'Relevé d\'identité bancaire',
322
+ optional: true,
323
+ },
324
+ ],
325
+ 'onUpdate:modelValue': fn(),
326
+ 'onError': fn(),
327
+ },
328
+ parameters: {
329
+ sourceCode: [
330
+ {
331
+ name: 'Template',
332
+ code: `<template>
333
+ <UploadWorkflow
334
+ v-model="files"
335
+ :uploadList="uploadList"
336
+ />
337
+ </template>`,
338
+ },
339
+ {
340
+ name: 'Script',
341
+ code: `<script setup lang="ts">
342
+ import { ref } from 'vue'
343
+ import { UploadWorkflow } from '@cnamts/synapse'
344
+
345
+ const files = ref([])
346
+ const uploadList = [
347
+ {
348
+ id: '1',
349
+ title: 'Carte d'identité',
350
+ },
351
+ {
352
+ id: '2',
353
+ title: 'Facture de soin',
354
+ optional: true,
355
+ },
356
+ {
357
+ id: '3',
358
+ title: 'Relevé d'identité bancaire',
359
+ optional: true,
360
+ },
361
+ ]
362
+ </script>`,
363
+ },
364
+ ],
365
+ },
366
+ }
367
+
368
+ export const WithPreviewStep: Story = {
369
+ args: {
370
+ 'modelValue': [],
371
+ 'uploadList': [
372
+ {
373
+ id: 'ID',
374
+ title: 'Carte d\'identité',
375
+ },
376
+ {
377
+ id: 'Bill',
378
+ title: 'Facture de soin',
379
+ },
380
+ ],
381
+ 'onUpdate:modelValue': fn(),
382
+ 'onError': fn(),
383
+ 'showFilePreview': true,
384
+ },
385
+ parameters: {
386
+ sourceCode: [
387
+ {
388
+ name: 'Template',
389
+ code: `<template>
390
+ <UploadWorkflow
391
+ v-model="files"
392
+ :uploadList="uploadList"
393
+ :showFilePreview="true"
394
+ />
395
+ </template>`,
396
+
397
+ },
398
+ {
399
+ name: 'Script',
400
+ code: `<script setup lang="ts">
401
+ import { ref } from 'vue'
402
+ import { UploadWorkflow } from '@cnamts/synapse'
403
+
404
+ const files = ref([])
405
+ const uploadList = [
406
+ {
407
+ id: 'ID',
408
+ title: 'Carte d'identité',
409
+ },
410
+ {
411
+ id: 'Bill',
412
+ title: 'Facture de soin',
413
+ },
414
+ ]
415
+ </script>`,
416
+ },
417
+ ],
418
+ },
419
+ }
420
+
421
+ export const OneFile: Story = {
422
+ args: {
423
+ 'modelValue': [],
424
+ 'uploadList': [
425
+ {
426
+ id: 'ID',
427
+ title: 'Carte d\'identité',
428
+ },
429
+ ],
430
+ 'onUpdate:modelValue': fn(),
431
+ 'onError': fn(),
432
+ },
433
+ parameters: {
434
+ sourceCode: [
435
+ {
436
+ name: 'Template',
437
+ code: `<template>
438
+ <UploadWorkflow
439
+ v-model="files"
440
+ :uploadList="uploadList"
441
+ />
442
+ </template>`,
443
+ },
444
+ {
445
+ name: 'Script',
446
+ code: `<script setup lang="ts">
447
+ import { ref } from 'vue'
448
+ import { UploadWorkflow } from '@cnamts/synapse'
449
+
450
+ const files = ref([])
451
+ const uploadList = [
452
+ {
453
+ id: 'ID',
454
+ title: 'Carte d'identité',
455
+ },
456
+ ]
457
+
458
+ </script>`,
459
+ },
460
+ ],
461
+ },
462
+ }
463
+
464
+ export const Events: Story = {
465
+ args: {
466
+ 'modelValue': [],
467
+ 'uploadList': [
468
+ {
469
+ id: 'ID',
470
+ title: 'Carte d\'identité',
471
+ },
472
+ {
473
+ id: 'Bill',
474
+ title: 'Facture de soin',
475
+ },
476
+ ],
477
+ 'onUpdate:modelValue': fn(),
478
+ 'onError': fn(),
479
+ },
480
+ render: (args) => {
481
+ return {
482
+ components: { UploadWorkflow, VSnackbar, VBtn },
483
+ setup() {
484
+ const snackbar = ref(false)
485
+ const snackbarText = ref('')
486
+ const snackbarColor = ref('')
487
+ const options = {
488
+ fileUpload: {
489
+ allowedExtensions: [
490
+ 'png',
491
+ 'jpg',
492
+ 'jpeg',
493
+ ],
494
+ },
495
+ }
496
+
497
+ function showError(errors: string[]) {
498
+ snackbarText.value = errors.join(', ')
499
+ snackbarColor.value = 'error'
500
+ snackbar.value = true
501
+ }
502
+
503
+ function valueUpdated(items: { fileName: string, file: File }[]) {
504
+ if (items.length === 0) {
505
+ return
506
+ }
507
+ snackbarText.value = `Le fichier "${items.at(-1)!.fileName}" a été ajouté avec succès.`
508
+ snackbarColor.value = 'success'
509
+ snackbar.value = true
510
+ }
511
+ return { args, snackbar, snackbarText, snackbarColor, options, showError, valueUpdated }
512
+ },
513
+ template: `
514
+ <div>
515
+ <UploadWorkflow
516
+ v-model="args.modelValue"
517
+ :uploadList="args.uploadList"
518
+ :vuetify-options="options"
519
+ @error="[showError, args.onError]"
520
+ @update:modelValue="[valueUpdated, args['onUpdate:modelValue']]"
521
+ />
522
+ <VSnackbar
523
+ v-model="snackbar"
524
+ :color="snackbarColor"
525
+ >
526
+ {{ snackbarText }}
527
+
528
+ <template #action="{ attrs }">
529
+ <VBtn
530
+ v-bind="attrs"
531
+ variant="text"
532
+ @click="snackbar = false"
533
+ >
534
+ Fermer
535
+ </VBtn>
536
+ </template>
537
+ </VSnackbar>
538
+ </div>
539
+ `,
540
+ }
541
+ },
542
+ parameters: {
543
+ sourceCode: [
544
+ {
545
+ name: 'Template',
546
+ code: `<template>
547
+ <UploadWorkflow
548
+ v-model="files"
549
+ :uploadList="uploadList"
550
+ vuetify-options="options"
551
+ @onError="showError"
552
+ @onUpdate:modelValue="valueUpdated"
553
+ />
554
+ </template>`,
555
+ },
556
+ {
557
+ name: 'Script',
558
+ code: `<script setup lang="ts">
559
+ import { ref } from 'vue'
560
+ import { UploadWorkflow } from '@cnamts/synapse'
561
+
562
+ const files = ref([])
563
+ const uploadList = [
564
+ {
565
+ id: 'ID',
566
+ title: 'Carte d'identité',
567
+ },
568
+ {
569
+ id: 'Bill',
570
+ title: 'Facture de soin',
571
+ },
572
+ ]
573
+
574
+ const options = {
575
+ fileUpload: {
576
+ allowedExtensions: [
577
+ 'png',
578
+ 'jpg',
579
+ 'jpeg'
580
+ ]
581
+ }
582
+ }
583
+
584
+ function showError (errors: string[]) {
585
+ snackbarText.value = errors.join(', ')
586
+ snackbarColor.value = 'error';
587
+ snackbar.value = true
588
+ }
589
+
590
+ function valueUpdated (items: {fileName: string, file: File}[]) {
591
+ if(items.length === 0) {
592
+ return
593
+ }
594
+ snackbarText.value = \`Le fichier "\${items[0].fileName}" a été ajouté avec succès.\`;
595
+ snackbarColor.value = 'success';
596
+ snackbar.value = true
597
+ }
598
+ </script>`,
599
+ },
600
+ ],
601
+ },
602
+ }
603
+
604
+ export const Slots: Story = {
605
+ args: {
606
+ 'modelValue': [],
607
+ 'uploadList': [
608
+ {
609
+ id: 'ID',
610
+ title: 'Carte d\'identité',
611
+ showPreviewBtn: true,
612
+ },
613
+ {
614
+ id: 'Bill',
615
+ title: 'Facture de soin',
616
+ showPreviewBtn: true,
617
+ },
618
+ ],
619
+ 'onUpdate:modelValue': fn(),
620
+ 'onError': fn(),
621
+ },
622
+ render: (args) => {
623
+ return {
624
+ components: { UploadWorkflow },
625
+ setup() {
626
+ return { args }
627
+ },
628
+ template: `
629
+ <UploadWorkflow
630
+ v-model="args.modelValue"
631
+ :uploadList="args.uploadList"
632
+ >
633
+ <template #title>
634
+ <h2>Title slot</h2>
635
+ </template>
636
+ <template #modal-title>
637
+ <h2>Modal Title slot</h2>
638
+ </template>
639
+ <template #modal-description>
640
+ <p>Modal Description slot</p>
641
+ </template>
642
+ <template #preview-description>
643
+ <p>Preview Description slot</p>
644
+ </template>
645
+ </UploadWorkflow>
646
+ `,
647
+ }
648
+ },
649
+ parameters: {
650
+ sourceCode: [
651
+ {
652
+ name: 'Template',
653
+ code: `<template>
654
+ <UploadWorkflow
655
+ v-model="files"
656
+ :uploadList="uploadList"
657
+ >
658
+ <template #title>
659
+ <h2>Title slot</h2>
660
+ </template>
661
+ <template #modal-title>
662
+ <h2>Modal Title slot</h2>
663
+ </template>
664
+ <template #modal-description>
665
+ <p>Modal Description slot</p>
666
+ </template>
667
+ <template #preview-description>
668
+ <p>Preview Description slot</p>
669
+ </template>
670
+ </UploadWorkflow>
671
+ </template>`,
672
+ },
673
+ {
674
+ name: 'Script',
675
+ code: `<script setup lang="ts">
676
+ import { ref } from 'vue'
677
+ import { UploadWorkflow } from '@cnamts/synapse'
678
+
679
+ const files = ref([])
680
+ const uploadList = [
681
+ {
682
+ id: 'ID',
683
+ title: 'Carte d'identité',
684
+ },
685
+ {
686
+ id: 'Bill',
687
+ title: 'Facture de soin',
688
+ },
689
+ ]
690
+ </script>`,
691
+ },
692
+ ],
693
+ },
694
+ }
695
+
696
+ export const Customization: Story = {
697
+ args: {
698
+ 'modelValue': [],
699
+ 'uploadList': [
700
+ {
701
+ id: '1',
702
+ title: 'Carte d\'identité',
703
+ },
704
+ {
705
+ id: '2',
706
+ title: 'Facture de soin',
707
+ },
708
+ ],
709
+ 'vuetifyOptions': {
710
+ fileUpload: {
711
+ allowedExtensions: [
712
+ 'pdf',
713
+ ],
714
+ },
715
+ select: {
716
+ variant: 'solo-filled',
717
+ },
718
+ dialog: {
719
+ width: '400px',
720
+ },
721
+ },
722
+ 'onUpdate:modelValue': fn(),
723
+ 'onError': fn(),
724
+ },
725
+ parameters: {
726
+ sourceCode: [
727
+ {
728
+ name: 'Template',
729
+ code: `<template>
730
+ <UploadWorkflow
731
+ v-model="files"
732
+ :uploadList="uploadList"
733
+ :vuetify-options="options"
734
+ />
735
+ </template>`,
736
+ },
737
+ {
738
+ name: 'Script',
739
+ code: `<script setup lang="ts">
740
+ import { ref } from 'vue'
741
+ import { UploadWorkflow } from '@cnamts/synapse'
742
+
743
+ const files = ref([])
744
+
745
+ const uploadList = [
746
+ {
747
+ id: '1',
748
+ title: 'Carte d'identité',
749
+ },
750
+ {
751
+ id: '2',
752
+ title: 'Facture de soin',
753
+ },
754
+ ]
755
+
756
+ const options = {
757
+ fileUpload: {
758
+ allowedExtensions: [
759
+ 'pdf',
760
+ ],
761
+ },
762
+ select: {
763
+ variant: 'solo-filled',
764
+ },
765
+ dialog: {
766
+ width: '400px',
767
+ },
768
+ }
769
+ </script>`,
770
+ },
771
+ ],
772
+ },
773
+ }
774
+
775
+ export const ManuallySetFile: Story = {
776
+ args: {
777
+ 'modelValue': [
778
+ {
779
+ id: '1',
780
+ title: 'Carte d\'identité',
781
+ state: 'success',
782
+ fileName: 'carte_identite.jpg',
783
+ optional: false,
784
+ showPreviewBtn: false,
785
+ file: new File([''], 'carte_identite.jpg', { type: 'image/jpeg' }),
786
+ },
787
+ {
788
+ id: '2',
789
+ title: 'Facture de soin',
790
+ state: 'success',
791
+ fileName: 'facture_soin.pdf',
792
+ optional: false,
793
+ showPreviewBtn: false,
794
+ file: new File([''], 'facture_soin.pdf', { type: 'application/pdf' }),
795
+ },
796
+ ],
797
+ 'uploadList': [
798
+ {
799
+ id: '1',
800
+ title: 'Carte d\'identité',
801
+ },
802
+ {
803
+ id: '2',
804
+ title: 'Facture de soin',
805
+ },
806
+ ],
807
+ 'onUpdate:modelValue': fn(),
808
+ 'onError': fn(),
809
+ },
810
+ parameters: {
811
+ sourceCode: [
812
+ {
813
+ name: 'Template',
814
+ code: `<template>
815
+ <UploadWorkflow
816
+ v-model="files"
817
+ :uploadList="uploadList"
818
+ />
819
+ </template>`,
820
+ },
821
+ {
822
+ name: 'Script',
823
+ code: `<script setup lang="ts">
824
+ import { ref } from 'vue'
825
+ import { UploadWorkflow } from '@cnamts/synapse'
826
+
827
+ const files = ref([
828
+ {
829
+ id: '1',
830
+ title: 'Carte d'identité',
831
+ state: 'success',
832
+ fileName: 'carte_identite.jpg',
833
+ optional: false,
834
+ showPreviewBtn: false,
835
+ file: new File([''], 'carte_identite.jpg', { type: 'image/jpeg' }),
836
+ },
837
+ {
838
+ id: '2',
839
+ title: 'Facture de soin',
840
+ state: 'success',
841
+ fileName: 'facture_soin.pdf',
842
+ optional: false,
843
+ showPreviewBtn: false,
844
+ file: new File([''], 'facture_soin.pdf', { type: 'application/pdf' }),
845
+ },
846
+ ])
847
+
848
+ const uploadList = [
849
+ {
850
+ id: '1',
851
+ title: 'Carte d'identité',
852
+ },
853
+ {
854
+ id: '2',
855
+ title: 'Facture de soin',
856
+ },
857
+ ]
858
+ </script>`,
859
+ },
860
+ ],
861
+ },
862
+ }
863
+
864
+ export const ManuallySetStates: Story = {
865
+ args: {
866
+ 'modelValue': [
867
+ {
868
+ id: '1',
869
+ title: 'Carte d\'identité',
870
+ state: 'error',
871
+ fileName: 'carte_identite.jpg',
872
+ optional: false,
873
+ showPreviewBtn: false,
874
+ file: new File([''], 'carte_identite.jpg', { type: 'image/jpeg' }),
875
+ },
876
+ {
877
+ id: '2',
878
+ title: 'Facture de soin',
879
+ state: 'loading',
880
+ progress: 50,
881
+ fileName: 'facture_soin.pdf',
882
+ optional: false,
883
+ showPreviewBtn: false,
884
+ file: new File([''], 'facture_soin.pdf', { type: 'application/pdf' }),
885
+ },
886
+ ],
887
+ 'uploadList': [
888
+ {
889
+ id: '1',
890
+ title: 'Carte d\'identité',
891
+ },
892
+ {
893
+ id: '2',
894
+ title: 'Facture de soin',
895
+ },
896
+ ],
897
+ 'onUpdate:modelValue': fn(),
898
+ 'onError': fn(),
899
+ },
900
+ parameters: {
901
+ sourceCode: [
902
+ {
903
+ name: 'Template',
904
+ code: `<template>
905
+ <UploadWorkflow
906
+ v-model="files"
907
+ :uploadList="uploadList"
908
+ />
909
+ </template>`,
910
+ },
911
+ {
912
+ name: 'Script',
913
+ code: `<script setup lang="ts">
914
+ import { ref } from 'vue'
915
+ import { UploadWorkflow } from '@cnamts/synapse'
916
+
917
+ const files = ref([
918
+ {
919
+ id: '1',
920
+ title: 'Carte d'identité',
921
+ state: 'error',
922
+ fileName: 'carte_identite.jpg',
923
+ optional: false,
924
+ showPreviewBtn: false,
925
+ file: new File([''], 'carte_identite.jpg', { type: 'image/jpeg' }),
926
+ },
927
+ {
928
+ id: '2',
929
+ title: 'Facture de soin',
930
+ state: 'loading',
931
+ progress: 50,
932
+ fileName: 'facture_soin.pdf',
933
+ optional: false,
934
+ showPreviewBtn: false,
935
+ file: new File([''], 'facture_soin.pdf', { type: 'application/pdf' }),
936
+ },
937
+ ])
938
+
939
+ </script>`,
940
+ },
941
+ ],
942
+ },
943
+ }