@cnamts/synapse 0.0.9-alpha → 0.0.10-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 (55) hide show
  1. package/dist/design-system-v3.d.ts +631 -62
  2. package/dist/design-system-v3.js +3451 -2650
  3. package/dist/design-system-v3.umd.cjs +1 -1
  4. package/dist/style.css +1 -1
  5. package/package.json +1 -1
  6. package/src/components/DatePicker/Accessibilite.mdx +14 -0
  7. package/src/components/DatePicker/Accessibilite.stories.ts +191 -0
  8. package/src/components/DatePicker/AccessibiliteItems.ts +233 -0
  9. package/src/components/DatePicker/DatePicker.mdx +1 -6
  10. package/src/components/DatePicker/DatePicker.stories.ts +16 -16
  11. package/src/components/DatePicker/DatePicker.vue +20 -6
  12. package/src/components/DatePicker/constants/ExpertiseLevelEnum.ts +4 -0
  13. package/src/components/FileList/FileList.mdx +103 -0
  14. package/src/components/FileList/FileList.stories.ts +562 -0
  15. package/src/components/FileList/FileList.vue +78 -0
  16. package/src/components/FileList/UploadItem/UploadItem.vue +270 -0
  17. package/src/components/FileList/UploadItem/locales.ts +9 -0
  18. package/src/components/FileList/tests/FileList.spec.ts +176 -0
  19. package/src/components/FilePreview/FilePreview.mdx +82 -0
  20. package/src/components/FilePreview/FilePreview.stories.ts +242 -0
  21. package/src/components/FilePreview/FilePreview.vue +68 -0
  22. package/src/components/FilePreview/config.ts +10 -0
  23. package/src/components/FilePreview/locales.ts +4 -0
  24. package/src/components/FilePreview/tests/FilePreview.spec.ts +124 -0
  25. package/src/components/FilePreview/tests/__snapshots__/FilePreview.spec.ts.snap +11 -0
  26. package/src/components/PeriodField/PeriodField.mdx +32 -0
  27. package/src/components/PeriodField/PeriodField.stories.ts +807 -0
  28. package/src/components/PeriodField/PeriodField.vue +355 -0
  29. package/src/components/PeriodField/tests/PeriodField.spec.ts +348 -0
  30. package/src/components/RangeField/Accessibilite.mdx +14 -0
  31. package/src/components/RangeField/Accessibilite.stories.ts +191 -0
  32. package/src/components/RangeField/AccessibiliteItems.ts +179 -0
  33. package/src/components/RangeField/constants/ExpertiseLevelEnum.ts +4 -0
  34. package/src/components/RatingPicker/Accessibilite.mdx +14 -0
  35. package/src/components/RatingPicker/Accessibilite.stories.ts +191 -0
  36. package/src/components/RatingPicker/AccessibiliteItems.ts +208 -0
  37. package/src/components/RatingPicker/constants/ExpertiseLevelEnum.ts +4 -0
  38. package/src/components/SearchListField/Accessibilite.mdx +14 -0
  39. package/src/components/SearchListField/Accessibilite.stories.ts +191 -0
  40. package/src/components/SearchListField/AccessibiliteItems.ts +310 -0
  41. package/src/components/SearchListField/constants/ExpertiseLevelEnum.ts +4 -0
  42. package/src/components/SelectBtnField/Accessibilite.mdx +14 -0
  43. package/src/components/SelectBtnField/Accessibilite.stories.ts +191 -0
  44. package/src/components/SelectBtnField/AccessibiliteItems.ts +191 -0
  45. package/src/components/SelectBtnField/constants/ExpertiseLevelEnum.ts +4 -0
  46. package/src/components/SyAlert/SyAlert.vue +11 -9
  47. package/src/components/TableToolbar/TableToolbar.mdx +130 -0
  48. package/src/components/TableToolbar/TableToolbar.stories.ts +935 -0
  49. package/src/components/TableToolbar/TableToolbar.vue +168 -0
  50. package/src/components/TableToolbar/config.ts +24 -0
  51. package/src/components/TableToolbar/locales.ts +6 -0
  52. package/src/components/TableToolbar/tests/TableToolbar.spec.ts +166 -0
  53. package/src/components/TableToolbar/tests/__snapshots__/TableToolbar.spec.ts.snap +359 -0
  54. package/src/components/index.ts +3 -0
  55. package/src/composables/rules/useFieldValidation.ts +17 -15
@@ -0,0 +1,103 @@
1
+ import {Controls, Canvas, Meta, Source} from '@storybook/blocks';
2
+ import * as FileListStories from './FileList.stories';
3
+
4
+ <Meta of={FileListStories} />
5
+
6
+ # FileList
7
+
8
+ Le composant `FileList` est utilisé pour afficher une liste de document à téléverser.
9
+
10
+ <Canvas of={FileListStories.Default} />
11
+
12
+ # API
13
+
14
+ <Controls of={FileListStories.Default}/>
15
+
16
+ # Exemple d'utilisation
17
+
18
+
19
+ ## Les différents états d'un fichier
20
+
21
+ Un fichier peut être dans différents états : « initial », « success », « error » et « loading ».
22
+ Lorsqu’il est dans l’état « loading », une barre de progression est affichée.
23
+
24
+ Renseigner la propriété `progress` permet de donner a l'utilisateur une indication de progression du téléversement.
25
+
26
+ <Canvas of={FileListStories.States} />
27
+
28
+ ## Fichiers optionnels
29
+
30
+ Il est possible de rendre un fichier optionnel en ajoutant la propriété `optional` à l'objet fichier.
31
+
32
+ <Canvas of={FileListStories.OptionalDocument} />
33
+
34
+ ## Actions
35
+
36
+ Une fichier permet trois actions : `upload` quand son état est `initial` ou `error`.
37
+ `delete` et `preview` quand son état est `success`.
38
+
39
+ Les boutons `upload` et `delete` sont affichés par défaut, le bouton `preview` est masqué par défaut.
40
+
41
+ Pour afficher ou masquer une action, il est possible d'utiliser les propriétés `showUploadBtn`, `showDeleteBtn` et `showPreviewBtn`, ces propriétés sont de type `boolean`.
42
+
43
+ Quand une action est cliqué, un événement `upload`, `delete` ou `preview` est émis avec l'objet de l'item en paramètre.
44
+
45
+ <Canvas of={FileListStories.Actions} />
46
+
47
+ ## Personnalisation des icônes de fichier
48
+
49
+ Il est possible de personnaliser les icônes de fichier en utilisant le slot dynamique `file-icon-<id du fichier>`.
50
+
51
+ <Canvas
52
+ of={FileListStories.Customization}
53
+ source={{
54
+ language: 'html',
55
+ format: 'dedent',
56
+ code: `
57
+ <script lang="ts" setup>
58
+ import { FileList } from '@cnamts/synapse'
59
+ import { mdiCardAccountDetailsOutline, mdiCertificateOutline } from '@mdi/js'
60
+ import { ref } from 'vue'
61
+
62
+ const uploadList = ref([
63
+ {
64
+ id: 'residenceCertificate',
65
+ title: 'Attestation de domicile',
66
+ state: 'initial',
67
+ },
68
+ {
69
+ id: 'identityCard',
70
+ title: 'Carte d\\'identité',
71
+ state: 'initial',
72
+ },
73
+ {
74
+ id: 'paySlip',
75
+ title: 'Fiche de paie',
76
+ state: 'initial',
77
+ },
78
+ ])
79
+ </script>
80
+
81
+ <FileList
82
+ :uploadList="args.uploadList"
83
+ :maxWidth="600"
84
+ :minWidth="400"
85
+ :width="'50%'"
86
+ @upload="console.log"
87
+ @delete="console.log"
88
+ @preview="console.log"
89
+ >
90
+ <template #file-icon-residenceCertificate>
91
+ <VIcon
92
+ color="primary"
93
+ >{{ mdiCertificateOutline }}</VIcon>
94
+ </template>
95
+ <template #file-icon-identityCard>
96
+ <VIcon
97
+ color="primary"
98
+ >{{ mdiCardAccountDetailsOutline }}</VIcon>
99
+ </template>
100
+ </FileList>
101
+ `
102
+ }}
103
+ />
@@ -0,0 +1,562 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import FileList from './FileList.vue'
3
+ import { fn } from '@storybook/test'
4
+ import { VIcon } from 'vuetify/components'
5
+ import { mdiCardAccountDetailsOutline, mdiCertificateOutline } from '@mdi/js'
6
+
7
+ const meta = {
8
+ title: 'Composants/Données/FileList',
9
+ component: FileList,
10
+ argTypes: {
11
+ 'uploadList': {
12
+ description: 'Liste des fichiers à uploader',
13
+ control: 'object',
14
+ table: {
15
+ type: {
16
+ summary: 'Object[]',
17
+ detail: `Array<{
18
+ id: string,
19
+ title: string,
20
+ state: 'initial' | 'success' | 'error' | 'loading'
21
+ fileName?: string,
22
+ optional?: boolean,
23
+ progress?: number,
24
+ showUploadBtn?: boolean
25
+ showPreviewBtn?: boolean
26
+ showDeleteBtn?: boolean
27
+ }>`,
28
+ },
29
+ category: 'props',
30
+ },
31
+ },
32
+ 'locales': {
33
+ description: 'Traductions',
34
+ control: false,
35
+ table: {
36
+ category: 'props',
37
+ type: {
38
+ summary: undefined,
39
+ },
40
+ defaultValue: {
41
+ summary: `Locales`,
42
+ detail: `{
43
+ optionalDocument: 'Document facultatif',
44
+ see: 'Voir',
45
+ delete: 'Supprimer',
46
+ uploading: 'En cours',
47
+ success: 'Téléchargé',
48
+ error: 'Erreur',
49
+ errorOccurred: 'Une erreur est survenue pendant le téléchargement.',
50
+ }`,
51
+ },
52
+ },
53
+ },
54
+ 'maxWidth': {
55
+ description: 'Largeur maximale du composant',
56
+ control: 'text',
57
+ table: {
58
+ type: {
59
+ summary: 'number | string',
60
+ },
61
+ category: 'props',
62
+ },
63
+ },
64
+ 'minWidth': {
65
+ description: 'Largeur minimale du composant',
66
+ control: 'text',
67
+ table: {
68
+ type: {
69
+ summary: 'number | string',
70
+ },
71
+ category: 'props',
72
+ },
73
+ },
74
+ 'width': {
75
+ description: 'Largeur du composant',
76
+ control: 'text',
77
+ table: {
78
+ type: {
79
+ summary: 'number | string',
80
+ },
81
+ category: 'props',
82
+ },
83
+ },
84
+ 'onUpload': {
85
+ description: 'Événement déclenché lors du clic sur le bouton d\'upload',
86
+ action: 'upload',
87
+ table: {
88
+ category: 'events',
89
+ type: {
90
+ summary: 'Object',
91
+ detail: `{
92
+ id: string,
93
+ title: string,
94
+ state: 'initial' | 'error',
95
+ fileName: undefined,
96
+ optional?: boolean,
97
+ progress?: number,
98
+ showUploadBtn: true
99
+ showPreviewBtn?: boolean
100
+ showDeleteBtn?: boolean
101
+ }`,
102
+ },
103
+ },
104
+ },
105
+ 'onDelete': {
106
+ description: 'Événement déclenché lors du clic sur le bouton de suppression',
107
+ action: 'delete',
108
+ table: {
109
+ category: 'events',
110
+ type: {
111
+ summary: 'Object',
112
+ detail: `{
113
+ id: string,
114
+ title: string,
115
+ state: 'success',
116
+ fileName?: string,
117
+ optional?: boolean,
118
+ showUploadBtn?: boolean
119
+ showPreviewBtn?: boolean
120
+ showDeleteBtn: true
121
+ }`,
122
+ },
123
+ },
124
+ },
125
+ 'onPreview': {
126
+ description: 'Événement déclenché lors du clic sur le bouton de prévisualisation',
127
+ action: 'preview',
128
+ table: {
129
+ category: 'events',
130
+ type: {
131
+ summary: 'Object',
132
+ detail: `{
133
+ id: string,
134
+ title: string,
135
+ state: 'success',
136
+ fileName: string,
137
+ optional?: boolean,
138
+ showUploadBtn?: boolean
139
+ showPreviewBtn: true
140
+ showDeleteBtn?: boolean
141
+ }`,
142
+ },
143
+ },
144
+ },
145
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
146
+ // @ts-ignore - 'file-icon-${item.id}' storybook can't infer dynamic slot name
147
+ 'file-icon-${item.id}': {
148
+ description: 'Icône du fichier',
149
+ control: 'none',
150
+ table: {
151
+ category: 'slots',
152
+ type: {
153
+ summary: 'Object',
154
+ detail: `{
155
+ state: 'initial' | 'success' | 'error' | 'loading',
156
+ }`,
157
+ },
158
+ },
159
+ },
160
+ },
161
+ parameters: {
162
+ controls: {
163
+ exclude: ['upload', 'preview', 'delete', '`file-icon-${item.id}`'],
164
+ },
165
+ },
166
+ } satisfies Meta<typeof FileList>
167
+
168
+ export default meta
169
+
170
+ type Story = StoryObj<typeof meta>
171
+
172
+ export const Default: Story = {
173
+ args: {
174
+ uploadList: [
175
+ {
176
+ id: 'residenceCertificate',
177
+ title: 'Attestation de domicile',
178
+ state: 'initial',
179
+ },
180
+ {
181
+ id: 'identityCard',
182
+ title: 'Carte d\'identité',
183
+ state: 'initial',
184
+ },
185
+ {
186
+ id: 'paySlip',
187
+ title: 'Fiche de paie',
188
+ state: 'initial',
189
+ },
190
+ ],
191
+ onUpload: fn(),
192
+ onDelete: fn(),
193
+ onPreview: fn(),
194
+ },
195
+ parameters: {
196
+ sourceCode: [
197
+ {
198
+ name: 'Template',
199
+ code: `
200
+ <template>
201
+ <FileList
202
+ :uploadList="uploadList"
203
+ />
204
+ </template>
205
+ `,
206
+ },
207
+ {
208
+ name: 'Script',
209
+ code: `
210
+ <script setup lang="ts">
211
+ import { FileList } from '@cnamts/synapse'
212
+ import { ref } from 'vue'
213
+
214
+ const uploadList = ref([
215
+ {
216
+ id: 'residenceCertificate',
217
+ title: 'Attestation de domicile',
218
+ state: 'initial',
219
+ },
220
+ {
221
+ id: 'identityCard',
222
+ title: 'Carte d\\'identité',
223
+ state: 'initial',
224
+ },
225
+ {
226
+ id: 'paySlip',
227
+ title: 'Fiche de paie',
228
+ state: 'initial',
229
+ },
230
+ ])
231
+
232
+ </script>
233
+ `,
234
+ },
235
+ ],
236
+ },
237
+
238
+ }
239
+
240
+ export const States: Story = {
241
+ args: {
242
+ uploadList: [
243
+ {
244
+ id: 'residenceCertificate',
245
+ title: 'Attestation de domicile',
246
+ fileName: 'file1.jpg',
247
+ state: 'success',
248
+ },
249
+ {
250
+ id: 'identityCard',
251
+ title: 'Carte d\'identité',
252
+ state: 'loading',
253
+ },
254
+ {
255
+ id: 'paySlip',
256
+ title: 'Fiche de paie',
257
+ state: 'error',
258
+ },
259
+ ],
260
+ onUpload: fn(),
261
+ onDelete: fn(),
262
+ onPreview: fn(),
263
+ },
264
+ parameters: {
265
+ sourceCode: [
266
+ {
267
+ name: 'Template',
268
+ code: `
269
+ <template>
270
+ <FileList
271
+ :uploadList="uploadList"
272
+ />
273
+ </template>
274
+ `,
275
+ },
276
+ {
277
+ name: 'Script',
278
+ code: `
279
+ <script setup lang="ts">
280
+ import { FileList } from '@cnamts/synapse'
281
+ import { ref } from 'vue'
282
+
283
+ const uploadList = ref([
284
+ {
285
+ id: 'residenceCertificate',
286
+ title: 'Attestation de domicile',
287
+ fileName: 'file1.jpg',
288
+ state: 'success',
289
+ },
290
+ {
291
+ id: 'identityCard',
292
+ title: 'Carte d\\'identité',
293
+ state: 'loading',
294
+ },
295
+ {
296
+ id: 'paySlip',
297
+ title: 'Fiche de paie',
298
+ state: 'error',
299
+ },
300
+ ])
301
+
302
+ </script>
303
+ `,
304
+ },
305
+ ],
306
+ },
307
+ }
308
+
309
+ export const OptionalDocument: Story = {
310
+ args: {
311
+ uploadList: [
312
+ {
313
+ id: 'residenceCertificate',
314
+ title: 'Attestation de domicile',
315
+ state: 'initial',
316
+ },
317
+ {
318
+ id: 'identityCard',
319
+ title: 'Carte d\'identité',
320
+ state: 'initial',
321
+ optional: true,
322
+ },
323
+ {
324
+ id: 'paySlip',
325
+ title: 'Fiche de paie',
326
+ state: 'initial',
327
+ optional: true,
328
+ },
329
+ ],
330
+ onUpload: fn(),
331
+ onDelete: fn(),
332
+ onPreview: fn(),
333
+ },
334
+ parameters: {
335
+ sourceCode: [
336
+ {
337
+ name: 'Template',
338
+ code: `
339
+ <template>
340
+ <FileList
341
+ :uploadList="uploadList"
342
+ />
343
+ </template>
344
+ `,
345
+ },
346
+ {
347
+ name: 'Script',
348
+ code: `
349
+ <script setup lang="ts">
350
+ import { FileList } from '@cnamts/synapse'
351
+ import { ref } from 'vue'
352
+
353
+ const uploadList = ref([
354
+ {
355
+ id: 'residenceCertificate',
356
+ title: 'Attestation de domicile',
357
+ state: 'initial',
358
+ },
359
+ {
360
+ id: 'identityCard',
361
+ title: 'Carte d\\'identité',
362
+ state: 'initial',
363
+ optional: true,
364
+ },
365
+ {
366
+ id: 'paySlip',
367
+ title: 'Fiche de paie',
368
+ state: 'initial',
369
+ optional: true,
370
+ },
371
+ ])
372
+
373
+ </script>
374
+ `,
375
+ },
376
+ ],
377
+ },
378
+ }
379
+
380
+ export const Actions: Story = {
381
+ args: {
382
+ uploadList: [
383
+ {
384
+ id: 'residenceCertificate',
385
+ title: 'Attestation de domicile',
386
+ fileName: 'file1.jpg',
387
+ state: 'success',
388
+ showDeleteBtn: true,
389
+ showPreviewBtn: true,
390
+ },
391
+ {
392
+ id: 'identityCard',
393
+ title: 'Carte d\'identité',
394
+ state: 'initial',
395
+ showUploadBtn: false,
396
+ },
397
+ {
398
+ id: 'paySlip',
399
+ title: 'Fiche de paie',
400
+ fileName: 'file2.jpg',
401
+ state: 'success',
402
+ showDeleteBtn: false,
403
+ showPreviewBtn: false,
404
+ },
405
+ ],
406
+ onUpload: fn(),
407
+ onDelete: fn(),
408
+ onPreview: fn(),
409
+ },
410
+ parameters: {
411
+ sourceCode: [
412
+ {
413
+ name: 'Template',
414
+ code: `
415
+ <template>
416
+ <FileList
417
+ :uploadList="uploadList"
418
+ />
419
+ </template>
420
+ `,
421
+ },
422
+ {
423
+ name: 'Script',
424
+ code: `
425
+ <script setup lang="ts">
426
+ import { FileList } from '@cnamts/synapse'
427
+ import { ref } from 'vue'
428
+
429
+ const uploadList = ref([
430
+ {
431
+ id: 'residenceCertificate',
432
+ title: 'Attestation de domicile',
433
+ fileName: 'file1.jpg',
434
+ state: 'success',
435
+ showDeleteBtn: true,
436
+ showPreviewBtn: true,
437
+ },
438
+ {
439
+ id: 'identityCard',
440
+ title: 'Carte d\\'identité',
441
+ state: 'initial',
442
+ showUploadBtn: false,
443
+ },
444
+ {
445
+ id: 'paySlip',
446
+ title: 'Fiche de paie',
447
+ fileName: 'file2.jpg',
448
+ state: 'success',
449
+ showDeleteBtn: false,
450
+ showPreviewBtn: false,
451
+ },
452
+ ])
453
+
454
+ </script>
455
+ `,
456
+ },
457
+ ],
458
+ },
459
+ }
460
+
461
+ export const Customization: Story = {
462
+ args: {
463
+ uploadList: [
464
+ {
465
+ id: 'residenceCertificate',
466
+ title: 'Attestation de domicile',
467
+ state: 'initial',
468
+ },
469
+ {
470
+ id: 'identityCard',
471
+ title: 'Carte d\'identité',
472
+ state: 'initial',
473
+ },
474
+ ],
475
+ onUpload: fn(),
476
+ onDelete: fn(),
477
+ onPreview: fn(),
478
+ },
479
+ render: args => ({
480
+ components: { FileList, VIcon },
481
+ setup() {
482
+ return { args, mdiCertificateOutline, mdiCardAccountDetailsOutline }
483
+ },
484
+ template: `
485
+ <FileList
486
+ :uploadList="args.uploadList"
487
+ :maxWidth="600"
488
+ :minWidth="400"
489
+ :width="'50%'"
490
+ @upload="args.onUpload"
491
+ @delete="args.onDelete"
492
+ @preview="args.onPreview"
493
+ >
494
+ <template #file-icon-residenceCertificate>
495
+ <VIcon
496
+ color="primary"
497
+ >{{ mdiCertificateOutline }}</VIcon>
498
+ </template>
499
+ <template #file-icon-identityCard>
500
+ <VIcon
501
+ color="primary"
502
+ >{{ mdiCardAccountDetailsOutline }}</VIcon>
503
+ </template>
504
+ </FileList>
505
+ `,
506
+ }),
507
+ parameters: {
508
+ sourceCode: [
509
+ {
510
+ name: 'Template',
511
+ code: `
512
+ <template>
513
+ <FileList
514
+ :uploadList="uploadList"
515
+ :maxWidth="600"
516
+ :minWidth="400"
517
+ :width="'50%'"
518
+ @upload="console.log"
519
+ @delete="console.log"
520
+ @preview="console.log"
521
+ >
522
+ <template #file-icon-residenceCertificate>
523
+ <VIcon
524
+ color="primary"
525
+ >{{ mdiCertificateOutline }}</VIcon>
526
+ </template>
527
+ <template #file-icon-identityCard>
528
+ <VIcon
529
+ color="primary"
530
+ >{{ mdiCardAccountDetailsOutline }}</VIcon>
531
+ </template>
532
+ </FileList>
533
+ </template>
534
+ `,
535
+ },
536
+ {
537
+ name: 'Script',
538
+ code: `
539
+ <script setup lang="ts">
540
+ import { FileList } from '@cnamts/synapse'
541
+ import { ref } from 'vue'
542
+ import { mdiCertificateOutline, mdiCardAccountDetailsOutline } from '@mdi/js'
543
+
544
+ const uploadList = ref([
545
+ {
546
+ id: 'residenceCertificate',
547
+ title: 'Attestation de domicile',
548
+ state: 'initial',
549
+ },
550
+ {
551
+ id: 'identityCard',
552
+ title: 'Carte d\\'identité',
553
+ state: 'initial',
554
+ },
555
+ ])
556
+
557
+ </script>
558
+ `,
559
+ },
560
+ ],
561
+ },
562
+ }