@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,807 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import PeriodField from './PeriodField.vue'
3
+ import { ref } from 'vue'
4
+
5
+ const meta: Meta<typeof PeriodField> = {
6
+ title: 'Composants/Formulaires/PeriodField',
7
+ component: PeriodField,
8
+ decorators: [
9
+ () => ({
10
+ template: '<div style="padding: 20px;"><story/></div>',
11
+ }),
12
+ ],
13
+ parameters: {
14
+ layout: 'fullscreen',
15
+ controls: { exclude: ['modelValue'] },
16
+ },
17
+ argTypes: {
18
+ modelValue: {
19
+ control: 'text',
20
+ description: 'Valeur du champ',
21
+ table: {
22
+ type: {
23
+ summary: 'object',
24
+ },
25
+ },
26
+ },
27
+ placeholderFrom: {
28
+ control: 'text',
29
+ description: 'Placeholder pour la date de début',
30
+ },
31
+ placeholderTo: {
32
+ control: 'text',
33
+ description: 'Placeholder pour la date de fin',
34
+ },
35
+ format: {
36
+ control: 'select',
37
+ options: ['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD'],
38
+ description: 'Format d\'affichage de la date',
39
+ },
40
+ dateFormatReturn: {
41
+ control: 'select',
42
+ options: ['', 'DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD'],
43
+ description: 'Format de la date pour la valeur de retour',
44
+ },
45
+ isOutlined: {
46
+ control: 'boolean',
47
+ description: 'Affiche le champ en contour',
48
+ },
49
+ required: {
50
+ control: 'boolean',
51
+ description: 'Champ obligatoire',
52
+ },
53
+ displayIcon: {
54
+ control: 'boolean',
55
+ description: 'Affiche l\'icône calendrier',
56
+ },
57
+ displayAppendIcon: {
58
+ control: 'boolean',
59
+ description: 'Icône à la fin du champ',
60
+ },
61
+ isDisabled: {
62
+ control: 'boolean',
63
+ description: 'Désactive le champ',
64
+ },
65
+ noIcon: {
66
+ control: 'boolean',
67
+ description: 'Masque toutes les icônes',
68
+ },
69
+ noCalendar: {
70
+ control: 'boolean',
71
+ description: 'Désactive le calendrier',
72
+ },
73
+ customRules: {
74
+ control: 'object',
75
+ description: 'Règles de validation',
76
+ },
77
+ customWarningRules: {
78
+ control: 'object',
79
+ description: 'Règles d\'avertissement',
80
+ },
81
+ },
82
+ } as Meta<typeof PeriodField>
83
+
84
+ export default meta
85
+
86
+ type Story = StoryObj<typeof meta>
87
+
88
+ export const Default: Story = {
89
+ parameters: {
90
+ sourceCode: [
91
+ {
92
+ name: 'Template',
93
+ code: `
94
+ <template>
95
+ <PeriodField v-model="selectedPeriod" />
96
+ <p>Période sélectionnée : <pre>{{ selectedPeriod }}</pre></p>
97
+ </template>
98
+ `,
99
+ },
100
+ {
101
+ name: 'Script',
102
+ code: `
103
+ <script setup lang="ts">
104
+ import { ref } from 'vue'
105
+ import { PeriodField } from '@cnamts/synapse'
106
+
107
+ const selectedPeriod = ref({ from: null, to: null })
108
+ </script>
109
+ `,
110
+ },
111
+ ],
112
+ },
113
+ args: {
114
+ placeholderFrom: 'Début',
115
+ placeholderTo: 'Fin',
116
+ format: 'DD/MM/YYYY',
117
+ dateFormatReturn: '',
118
+ required: false,
119
+ displayIcon: true,
120
+ displayAppendIcon: false,
121
+ isDisabled: false,
122
+ noIcon: false,
123
+ modelValue: { from: null, to: null },
124
+ },
125
+ render: (args) => {
126
+ return {
127
+ components: { PeriodField: PeriodField },
128
+ setup() {
129
+ const value = ref({ from: null, to: null })
130
+ return { args, value }
131
+ },
132
+ template: `
133
+ <div class="pa-4">
134
+ <PeriodField v-bind="args" v-model="value"/>
135
+ <p>Période sélectionnée : {{ value }}</p>
136
+ </div>
137
+ `,
138
+ }
139
+ },
140
+ }
141
+
142
+ export const CustomPlaceholders: Story = {
143
+ parameters: {
144
+ sourceCode: [
145
+ {
146
+ name: 'Template',
147
+ code: `
148
+ <template>
149
+ <PeriodField
150
+ v-model="selectedPeriod"
151
+ placeholder-from="Début de la période"
152
+ placeholder-to="Fin de la période"
153
+ />
154
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
155
+ </template>
156
+ `,
157
+ },
158
+ {
159
+ name: 'Script',
160
+ code: `
161
+ <script setup lang="ts">
162
+ import { ref } from 'vue'
163
+ import { PeriodField } from '@cnamts/synapse'
164
+
165
+ const selectedPeriod = ref({ from: null, to: null })
166
+ </script>
167
+ `,
168
+ },
169
+ ],
170
+ },
171
+ args: {
172
+ placeholderFrom: 'Début de la période',
173
+ placeholderTo: 'Fin de la période',
174
+ format: 'DD/MM/YYYY',
175
+ dateFormatReturn: '',
176
+ required: false,
177
+ displayIcon: true,
178
+ displayAppendIcon: false,
179
+ isDisabled: false,
180
+ noIcon: false,
181
+ modelValue: { from: null, to: null },
182
+ },
183
+ render: (args) => {
184
+ return {
185
+ components: { PeriodField: PeriodField },
186
+ setup() {
187
+ const value = ref({ from: null, to: null })
188
+ return { args, value }
189
+ },
190
+ template: `
191
+ <div class="pa-4">
192
+ <PeriodField v-bind="args" v-model="value"/>
193
+ <p>Période sélectionnée : {{ value }}</p>
194
+ </div>
195
+ `,
196
+ }
197
+ },
198
+ }
199
+
200
+ export const Disabled: Story = {
201
+ parameters: {
202
+ sourceCode: [
203
+ {
204
+ name: 'Template',
205
+ code: `
206
+ <template>
207
+ <PeriodField
208
+ v-model="selectedPeriod"
209
+ is-disabled
210
+ />
211
+ </template>
212
+ `,
213
+ },
214
+ {
215
+ name: 'Script',
216
+ code: `
217
+ <script setup lang="ts">
218
+ import { ref } from 'vue'
219
+ import { PeriodField } from '@cnamts/synapse'
220
+
221
+ const selectedPeriod = ref({ from: null, to: null })
222
+ </script>
223
+ `,
224
+ },
225
+ ],
226
+ },
227
+ args: {
228
+ placeholderFrom: 'Début',
229
+ placeholderTo: 'Fin',
230
+ format: 'DD/MM/YYYY',
231
+ dateFormatReturn: '',
232
+ required: false,
233
+ displayIcon: true,
234
+ displayAppendIcon: false,
235
+ isDisabled: true,
236
+ noIcon: false,
237
+ modelValue: { from: null, to: null },
238
+ },
239
+ render: (args) => {
240
+ return {
241
+ components: { PeriodField: PeriodField },
242
+ setup() {
243
+ const value = ref({ from: null, to: null })
244
+ return { args, value }
245
+ },
246
+ template: `
247
+ <div class="pa-4">
248
+ <PeriodField v-bind="args" v-model="value"/>
249
+ </div>
250
+ `,
251
+ }
252
+ },
253
+ }
254
+
255
+ export const Required: Story = {
256
+ parameters: {
257
+ sourceCode: [
258
+ {
259
+ name: 'Template',
260
+ code: `
261
+ <template>
262
+ <PeriodField
263
+ v-model="selectedPeriod"
264
+ required
265
+ />
266
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
267
+ </template>
268
+ `,
269
+ },
270
+ {
271
+ name: 'Script',
272
+ code: `
273
+ <script setup lang="ts">
274
+ import { ref } from 'vue'
275
+ import { PeriodField } from '@cnamts/synapse'
276
+
277
+ const selectedPeriod = ref({ from: null, to: null })
278
+ </script>
279
+ `,
280
+ },
281
+ ],
282
+ },
283
+ args: {
284
+ placeholderFrom: 'Début',
285
+ placeholderTo: 'Fin',
286
+ format: 'DD/MM/YYYY',
287
+ dateFormatReturn: '',
288
+ required: true,
289
+ displayIcon: true,
290
+ displayAppendIcon: false,
291
+ isDisabled: false,
292
+ noIcon: false,
293
+ modelValue: { from: null, to: null },
294
+ },
295
+ render: (args) => {
296
+ return {
297
+ components: { PeriodField: PeriodField },
298
+ setup() {
299
+ const value = ref({ from: null, to: null })
300
+ return { args, value }
301
+ },
302
+ template: `
303
+ <div class="pa-4">
304
+ <PeriodField v-bind="args" v-model="value"/>
305
+ <p>Période sélectionnée : {{ value }}</p>
306
+ </div>
307
+ `,
308
+ }
309
+ },
310
+ }
311
+
312
+ export const AppendIcon: Story = {
313
+ parameters: {
314
+ sourceCode: [
315
+ {
316
+ name: 'Template',
317
+ code: `
318
+ <template>
319
+ <PeriodField
320
+ v-model="selectedPeriod"
321
+ displayAppendIcon
322
+ />
323
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
324
+ </template>
325
+ `,
326
+ },
327
+ {
328
+ name: 'Script',
329
+ code: `
330
+ <script setup lang="ts">
331
+ import { ref } from 'vue'
332
+ import { PeriodField } from '@cnamts/synapse'
333
+
334
+ const selectedPeriod = ref({ from: null, to: null })
335
+ </script>
336
+ `,
337
+ },
338
+ ],
339
+ },
340
+ args: {
341
+ placeholderFrom: 'Début',
342
+ placeholderTo: 'Fin',
343
+ format: 'DD/MM/YYYY',
344
+ required: true,
345
+ displayIcon: true,
346
+ displayAppendIcon: true,
347
+ isDisabled: false,
348
+ noIcon: false,
349
+ modelValue: { from: null, to: null },
350
+ },
351
+ render: (args) => {
352
+ return {
353
+ components: { PeriodField: PeriodField },
354
+ setup() {
355
+ const value = ref({ from: null, to: null })
356
+ return { args, value }
357
+ },
358
+ template: `
359
+ <div class="pa-4">
360
+ <PeriodField v-bind="args" v-model="value"/>
361
+ <p>Période sélectionnée : {{ value }}</p>
362
+ </div>
363
+ `,
364
+ }
365
+ },
366
+ }
367
+
368
+ export const WithoutIcon: Story = {
369
+ parameters: {
370
+ sourceCode: [
371
+ {
372
+ name: 'Template',
373
+ code: `
374
+ <template>
375
+ <PeriodField
376
+ v-model="selectedPeriod"
377
+ :display-icon="false"
378
+ />
379
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
380
+ </template>
381
+ `,
382
+ },
383
+ {
384
+ name: 'Script',
385
+ code: `
386
+ <script setup lang="ts">
387
+ import { ref } from 'vue'
388
+ import { PeriodField } from '@cnamts/synapse'
389
+
390
+ const selectedPeriod = ref({ from: null, to: null })
391
+ </script>
392
+ `,
393
+ },
394
+ ],
395
+ },
396
+ args: {
397
+ placeholderFrom: 'Début',
398
+ placeholderTo: 'Fin',
399
+ format: 'DD/MM/YYYY',
400
+ dateFormatReturn: '',
401
+ required: true,
402
+ displayIcon: false,
403
+ displayAppendIcon: true,
404
+ isDisabled: false,
405
+ noIcon: false,
406
+ modelValue: { from: null, to: null },
407
+ },
408
+ render: (args) => {
409
+ return {
410
+ components: { PeriodField: PeriodField },
411
+ setup() {
412
+ const value = ref({ from: null, to: null })
413
+ return { args, value }
414
+ },
415
+ template: `
416
+ <div class="pa-4">
417
+ <PeriodField v-bind="args" v-model="value"/>
418
+ <p>Période sélectionnée : {{ value }}</p>
419
+ </div>
420
+ `,
421
+ }
422
+ },
423
+ }
424
+
425
+ export const WithError: Story = {
426
+ parameters: {
427
+ sourceCode: [
428
+ {
429
+ name: 'Template',
430
+ code: `
431
+ <template>
432
+ <PeriodField
433
+ v-model="selectedPeriod"
434
+ :custom-rules="[
435
+ { type: 'notAfterToday', options: { message: 'La date ne peut pas être après aujourd'hui' } }
436
+ ]"
437
+ />
438
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
439
+ </template>
440
+ `,
441
+ },
442
+ {
443
+ name: 'Script',
444
+ code: `
445
+ <script setup lang="ts">
446
+ import { ref } from 'vue'
447
+ import { PeriodField } from '@cnamts/synapse'
448
+
449
+ const selectedPeriod = ref({ from: '01/01/2100', to: '05/01/2100' })
450
+ </script>
451
+ `,
452
+ },
453
+ ],
454
+ },
455
+ args: {
456
+ placeholderFrom: 'Début',
457
+ placeholderTo: 'Fin',
458
+ format: 'DD/MM/YYYY',
459
+ dateFormatReturn: '',
460
+ required: true,
461
+ displayIcon: false,
462
+ displayAppendIcon: true,
463
+ isDisabled: false,
464
+ noIcon: false,
465
+ modelValue: { from: '01/01/2100', to: '05/01/2100' },
466
+ customRules: [
467
+ { type: 'notAfterToday', options: { message: 'La date ne peut pas être après aujourd\'hui' } },
468
+ ],
469
+ },
470
+ render: (args) => {
471
+ return {
472
+ components: { PeriodField: PeriodField },
473
+ setup() {
474
+ const value = ref({ from: '01/01/2100', to: '05/01/2100' })
475
+ return { args, value }
476
+ },
477
+ template: `
478
+ <div class="pa-4">
479
+ <PeriodField v-bind="args" v-model="value"/>
480
+ <p>Période sélectionnée : {{ value }}</p>
481
+ </div>
482
+ `,
483
+ }
484
+ },
485
+ }
486
+
487
+ export const WithWarning: Story = {
488
+ parameters: {
489
+ sourceCode: [
490
+ {
491
+ name: 'Template',
492
+ code: `
493
+ <template>
494
+ <PeriodField
495
+ v-model="selectedPeriod"
496
+ :custom-warning-rules="[
497
+ { type: 'notBeforeDate', options: {
498
+ warningMessage: 'Attention : les dates sont antérieures au 02/01/2031',
499
+ date: '02/01/2031',
500
+ isWarning: true,
501
+ fieldIdentifier: 'fromDate'
502
+ } }
503
+ ]"
504
+ />
505
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
506
+ </template>
507
+ `,
508
+ },
509
+ {
510
+ name: 'Script',
511
+ code: `
512
+ <script setup lang="ts">
513
+ import { ref } from 'vue'
514
+ import { PeriodField } from '@cnamts/synapse'
515
+
516
+ const date = ref('20/12/2031')
517
+ </script>
518
+ `,
519
+ },
520
+ ],
521
+ },
522
+ args: {
523
+ placeholderFrom: 'Début',
524
+ placeholderTo: 'Fin',
525
+ format: 'DD/MM/YYYY',
526
+ dateFormatReturn: '',
527
+ required: true,
528
+ displayIcon: false,
529
+ displayAppendIcon: true,
530
+ isDisabled: false,
531
+ noIcon: false,
532
+ modelValue: { from: '20/12/2023', to: '21/12/2023' },
533
+ customWarningRules: [
534
+ {
535
+ type: 'notBeforeDate', options: {
536
+ warningMessage: 'Attention : les dates sont antérieures au 02/01/2031',
537
+ date: '02/01/2031',
538
+ isWarning: true,
539
+ },
540
+ },
541
+ ],
542
+ },
543
+ render: (args) => {
544
+ return {
545
+ components: { PeriodField: PeriodField },
546
+ setup() {
547
+ const value = ref({ from: '20/12/2023', to: '21/12/2023' })
548
+ return { args, value }
549
+ },
550
+ template: `
551
+ <div class="pa-4">
552
+ <PeriodField v-bind="args" v-model="value"/>
553
+ <p>Période sélectionnée : {{ value }}</p>
554
+ </div>
555
+ `,
556
+ }
557
+ },
558
+ }
559
+
560
+ export const WithSuccess: Story = {
561
+ parameters: {
562
+ sourceCode: [
563
+ {
564
+ name: 'Template',
565
+ code: `
566
+ <template>
567
+ <PeriodField
568
+ v-model="selectedPeriod"
569
+ :custom-rules="[
570
+ { type: 'notWeekend', options: { message: 'La date ne peut pas être un weekend', successMessage: 'La date n\\'est pas un week-end' } }
571
+ ]"
572
+ />
573
+ <p>Période sélectionnée : {{ selectedPeriod }}</p>
574
+ </template>
575
+ `,
576
+ },
577
+ {
578
+ name: 'Script',
579
+ code: `
580
+ <script setup lang="ts">
581
+ import { ref } from 'vue'
582
+ import { PeriodField } from '@cnamts/synapse'
583
+
584
+ const selectedPeriod = ref({ from: '22/01/2024', to: '23/01/2024 })
585
+ </script>
586
+ `,
587
+ },
588
+ ],
589
+ },
590
+ args: {
591
+ placeholderFrom: 'Début',
592
+ placeholderTo: 'Fin',
593
+ format: 'DD/MM/YYYY',
594
+ dateFormatReturn: '',
595
+ displayIcon: false,
596
+ displayAppendIcon: true,
597
+ isDisabled: false,
598
+ noIcon: false,
599
+ modelValue: { from: '22/01/2024', to: '23/01/2024' },
600
+ customRules: [
601
+ {
602
+ type: 'notWeekend',
603
+ options: {
604
+ message: 'La date ne peut pas être un weekend',
605
+ successMessage: 'La date n\'est pas un week-end',
606
+ },
607
+ },
608
+ ],
609
+ },
610
+ render: (args) => {
611
+ return {
612
+ components: { PeriodField: PeriodField },
613
+ setup() {
614
+ const value = ref({ from: '22/01/2024', to: '23/01/2024' })
615
+ return { args, value }
616
+ },
617
+ template: `
618
+ <div class="pa-4">
619
+ <PeriodField v-bind="args" v-model="value"/>
620
+ <p>Période sélectionnée : {{ value }}</p>
621
+ </div>
622
+ `,
623
+ }
624
+ },
625
+ }
626
+
627
+ export const DifferentFormats: Story = {
628
+ parameters: {
629
+ sourceCode: [
630
+ {
631
+ name: 'Template',
632
+ code: `
633
+ <template>
634
+ <PeriodField
635
+ v-model="selectedPeriod"
636
+ format="DD/MM/YYYY"
637
+ class="mb-4"
638
+ />
639
+ <PeriodField
640
+ v-model="selectedPeriod"
641
+ format="MM/DD/YYYY"
642
+ class="mb-4"
643
+ />
644
+ <PeriodField
645
+ v-model="selectedPeriod"
646
+ format="YYYY-MM-DD"
647
+ class="mb-4"
648
+ />
649
+ <PeriodField
650
+ v-model="selectedPeriod"
651
+ format="DD-MM-YY"
652
+ class="mb-4"
653
+ />
654
+ <PeriodField
655
+ v-model="selectedPeriod"
656
+ format="DD.MM.YYYY"
657
+ />
658
+ </template>
659
+ `,
660
+ },
661
+ {
662
+ name: 'Script',
663
+ code: `
664
+ <script setup lang="ts">
665
+ import { ref } from 'vue'
666
+ import { PeriodField } from '@cnamts/synapse'
667
+
668
+ const selectedPeriod = ref({ from: '12/10/2023', to: '15/10/2023' })
669
+ </script>
670
+ `,
671
+ },
672
+ ],
673
+ },
674
+ args: {
675
+ placeholderFrom: 'Début',
676
+ placeholderTo: 'Fin',
677
+ format: 'DD/MM/YYYY',
678
+ dateFormatReturn: '',
679
+ required: false,
680
+ displayIcon: true,
681
+ displayAppendIcon: false,
682
+ isDisabled: false,
683
+ noIcon: false,
684
+ modelValue: { from: '12/10/2023', to: '15/10/2023' },
685
+ },
686
+ render: (args) => {
687
+ return {
688
+ components: { PeriodField: PeriodField },
689
+ setup() {
690
+ const value1 = ref({ from: '12/10/2023', to: '15/10/2023' })
691
+ const value2 = ref({ from: '10/12/2023', to: '10/15/2023' })
692
+ const value3 = ref({ from: '2023-10-12', to: '2023-10-15' })
693
+ const value4 = ref({ from: '12-10-23', to: '15-10-23' })
694
+ const value5 = ref({ from: '12.10.2023', to: '15.10.2023' })
695
+ return { args, value1, value2, value3, value4, value5 }
696
+ },
697
+ template: `
698
+ <div class="pa-4">
699
+ <PeriodField v-bind="args" v-model="value1" format="DD/MM/YYYY" class="mb-4" />
700
+ <PeriodField v-bind="args" v-model="value2" format="MM/DD/YYYY" class="mb-4" />
701
+ <PeriodField v-bind="args" v-model="value3" format="YYYY-MM-DD" class="mb-4" />
702
+ <PeriodField v-bind="args" v-model="value4" format="DD-MM-YY" class="mb-4" />
703
+ <PeriodField v-bind="args" v-model="value5" format="DD.MM.YYYY"/>
704
+ </div>
705
+ `,
706
+ }
707
+ },
708
+ }
709
+
710
+ export const WithDateFormatReturn: Story = {
711
+ parameters: {
712
+ sourceCode: [
713
+ {
714
+ name: 'Template',
715
+ code: `
716
+ <template>
717
+ <span class="mb-4">Période de retour : {{ value1 }}</span>
718
+ <PeriodField
719
+ v-model="value1"
720
+ format="DD/MM/YYYY"
721
+ />
722
+
723
+ <span class="mb-4">Période de retour : {{ value2 }}</span>
724
+ <PeriodField
725
+ v-model="value2"
726
+ format="DD/MM/YYYY"
727
+ date-format-return="MM/DD/YYYY"
728
+ />
729
+
730
+ <span class="mb-4">Période de retour : {{ value3 }}</span>
731
+ <PeriodField
732
+ v-model="value3"
733
+ format="DD/MM/YYYY"
734
+ date-format-return="YYYY-MM-DD"
735
+ />
736
+ </template>
737
+ `,
738
+ },
739
+ {
740
+ name: 'Script',
741
+ code: `
742
+ <script setup lang="ts">
743
+ import { ref } from 'vue'
744
+ import { PeriodField } from '@cnamts/synapse'
745
+
746
+ const value1 = ref({ from: '12/10/2023', to: '15/10/2023' })
747
+ const value2 = ref({ from: '12/10/2023', to: '15/10/2023' })
748
+ const value3 = ref({ from: '12/10/2023', to: '15/10/2023' })
749
+ </script>
750
+ `,
751
+ },
752
+ ],
753
+ },
754
+ args: {
755
+ placeholderFrom: 'Début',
756
+ placeholderTo: 'Fin',
757
+ format: 'DD/MM/YYYY',
758
+ dateFormatReturn: '',
759
+ required: false,
760
+ displayIcon: true,
761
+ displayAppendIcon: false,
762
+ isDisabled: false,
763
+ noIcon: false,
764
+ modelValue: { from: null, to: null },
765
+ },
766
+ render: (args) => {
767
+ return {
768
+ components: { PeriodField: PeriodField },
769
+ setup() {
770
+ const value1 = ref({ from: '12/10/2023', to: '15/10/2023' })
771
+ const value2 = ref({ from: '12/10/2023', to: '15/10/2023' })
772
+ const value3 = ref({ from: '12/10/2023', to: '15/10/2023' })
773
+ const valueReturn1 = ref({ from: '12/10/2023', to: '15/10/2023' })
774
+ const valueReturn2 = ref({ from: '10/12/2023', to: '10/15/2023' })
775
+ const valueReturn3 = ref({ from: '2023/12/10', to: '2023/15/10' })
776
+ return { args, value1, value2, value3, valueReturn1, valueReturn2, valueReturn3 }
777
+ },
778
+ template: `
779
+ <div class="pa-4">
780
+ <span>Période de retour : {{ valueReturn1 }}<br/><br/></span>
781
+ <PeriodField
782
+ v-bind="args"
783
+ v-model="value1"
784
+ format="DD/MM/YYYY"
785
+ date-format-return="DD/MM/YYYY"
786
+ />
787
+
788
+ <span>Période de retour : {{ valueReturn2 }}<br/><br/></span>
789
+ <PeriodField
790
+ v-bind="args"
791
+ v-model="value2"
792
+ format="DD/MM/YYYY"
793
+ date-format-return="MM/DD/YYYY"
794
+ />
795
+
796
+ <span>Période de retour : {{ valueReturn3 }}<br/><br/></span>
797
+ <PeriodField
798
+ v-bind="args"
799
+ v-model="value3"
800
+ format="DD/MM/YYYY"
801
+ date-format-return="YYYY-MM-DD"
802
+ />
803
+ </div>
804
+ `,
805
+ }
806
+ },
807
+ }