@cnamts/synapse 1.0.20 → 1.0.21

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 (135) hide show
  1. package/dist/{DateFilter-XURUmpMl.js → DateFilter-uN8OURoP.js} +1 -1
  2. package/dist/{NumberFilter-BZc0O8wV.js → NumberFilter-sm1dQNQi.js} +1 -1
  3. package/dist/{PeriodFilter-ZNdXcl3p.js → PeriodFilter-Cklsxnh9.js} +1 -1
  4. package/dist/{SelectFilter-DshYU5OK.js → SelectFilter-CWefj27Z.js} +1 -1
  5. package/dist/{TextFilter-D_c5dRPl.js → TextFilter-Ddyj885L.js} +1 -1
  6. package/dist/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.d.ts +160 -0
  7. package/dist/components/Customs/SyCheckBoxGroup/locales.d.ts +3 -0
  8. package/dist/components/Customs/SyCheckBoxGroup/types.d.ts +10 -0
  9. package/dist/components/Customs/SyCheckbox/SyCheckbox.d.ts +1545 -2
  10. package/dist/components/Customs/SyRadioGroup/SyRadioGroup.d.ts +1495 -2
  11. package/dist/components/DeclarationAccessibilityPage/DeclarationAccessibilityPage.d.ts +60 -0
  12. package/dist/components/ErrorPage/ErrorPage.d.ts +1 -12
  13. package/dist/components/ErrorPage/locales.d.ts +18 -3
  14. package/dist/components/FileUpload/FileUpload.d.ts +2 -0
  15. package/dist/components/MaintenancePage/locales.d.ts +18 -2
  16. package/dist/components/NotFoundPage/locales.d.ts +20 -4
  17. package/dist/components/StatusPage/StatusPage.d.ts +39 -0
  18. package/dist/components/UploadWorkflow/UploadWorkflow.d.ts +13 -3
  19. package/dist/components/index.d.ts +3 -0
  20. package/dist/design-system-v3.js +126 -123
  21. package/dist/design-system-v3.umd.cjs +163 -163
  22. package/dist/{main-CuI6xaPq.js → main-CWniLr0s.js} +15191 -14668
  23. package/dist/style.css +1 -1
  24. package/dist/utils/theme/index.d.ts +6 -0
  25. package/package.json +7 -4
  26. package/src/components/ContextualMenu/ContextualMenu.stories.ts +0 -3
  27. package/src/components/ContextualMenu/accessibilite/Accessibility.mdx +67 -11
  28. package/src/components/CookieBanner/CookieBanner.stories.ts +11 -20
  29. package/src/components/CookieBanner/CookieBanner.vue +20 -5
  30. package/src/components/CookieBanner/accessibilite/Accessibility.mdx +67 -11
  31. package/src/components/CookieBanner/tests/CookieBanner.spec.ts +48 -4
  32. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.mdx +32 -0
  33. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.stories.ts +856 -0
  34. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.vue +334 -0
  35. package/src/components/Customs/SyCheckBoxGroup/accessibilite/Accessibility.mdx +243 -0
  36. package/src/components/Customs/SyCheckBoxGroup/locales.ts +3 -0
  37. package/src/components/Customs/SyCheckBoxGroup/tests/SyCheckBoxGroup.a11y.spec.ts +30 -0
  38. package/src/components/Customs/SyCheckBoxGroup/tests/SyCheckBoxGroup.spec.ts +152 -0
  39. package/src/components/Customs/SyCheckBoxGroup/types.ts +10 -0
  40. package/src/components/Customs/SyCheckbox/SyCheckbox.vue +16 -27
  41. package/src/components/Customs/SyCheckbox/accessibilite/Accessibility.mdx +1 -1
  42. package/src/components/Customs/SyForm/SyForm.a11y.spec.ts +1 -1
  43. package/src/components/Customs/SyRadioGroup/SyRadioGroup.vue +16 -43
  44. package/src/components/DatePicker/CalendarMode/DatePicker.vue +35 -11
  45. package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.stories.ts +43 -2
  46. package/src/components/DatePicker/DateTextInput/DateTextInput.vue +48 -21
  47. package/src/components/DatePicker/DateTextInput/NoCalendar.stories.ts +98 -0
  48. package/src/components/DeclarationAccessibilityPage/DeclarationAccessibilityPage.mdx +83 -0
  49. package/src/components/DeclarationAccessibilityPage/DeclarationAccessibilityPage.stories.ts +502 -0
  50. package/src/components/DeclarationAccessibilityPage/DeclarationAccessibilityPage.vue +428 -0
  51. package/src/components/DeclarationAccessibilityPage/accessibilite/Accessibility.mdx +75 -0
  52. package/src/components/DeclarationAccessibilityPage/tests/DeclarationAccessibilityPage.a11y.spec.ts +53 -0
  53. package/src/components/DeclarationAccessibilityPage/tests/DeclarationAccessibilityPage.spec.ts +59 -0
  54. package/src/components/DiacriticPicker/DiacriticPicker.vue +20 -1
  55. package/src/components/ErrorPage/ErrorPage.mdx +6 -16
  56. package/src/components/ErrorPage/ErrorPage.stories.ts +16 -87
  57. package/src/components/ErrorPage/ErrorPage.vue +38 -125
  58. package/src/components/ErrorPage/accessibilite/Accessibility.mdx +68 -6
  59. package/src/components/ErrorPage/assets/error-ap.svg +1774 -0
  60. package/src/components/ErrorPage/locales.ts +21 -3
  61. package/src/components/ErrorPage/tests/ErrorPage.a11y.spec.ts +5 -13
  62. package/src/components/ErrorPage/tests/ErrorPage.spec.ts +2 -41
  63. package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +8 -266
  64. package/src/components/FileUpload/FileUpload.vue +5 -0
  65. package/src/components/FooterBar/FooterBar.stories.ts +18 -14
  66. package/src/components/FooterBar/defaultSocialMediaLinks.ts +6 -4
  67. package/src/components/MaintenancePage/MaintenancePage.mdx +1 -1
  68. package/src/components/MaintenancePage/MaintenancePage.vue +15 -7
  69. package/src/components/MaintenancePage/accessibilite/Accessibility.mdx +61 -6
  70. package/src/components/MaintenancePage/assets/maintenance-ap.svg +1718 -0
  71. package/src/components/MaintenancePage/locales.ts +24 -3
  72. package/src/components/MaintenancePage/tests/MaintenancePage.a11y.spec.ts +75 -3
  73. package/src/components/MaintenancePage/tests/MaintenancePage.spec.ts +42 -2
  74. package/src/components/MaintenancePage/tests/__snapshots__/MaintenancePage.spec.ts.snap +3 -2
  75. package/src/components/NotFoundPage/NotFoundPage.mdx +1 -1
  76. package/src/components/NotFoundPage/NotFoundPage.stories.ts +3 -3
  77. package/src/components/NotFoundPage/NotFoundPage.vue +16 -11
  78. package/src/components/NotFoundPage/accessibilite/Accessibility.mdx +78 -6
  79. package/src/components/NotFoundPage/assets/not-found-ap.svg +2061 -0
  80. package/src/components/NotFoundPage/locales.ts +24 -4
  81. package/src/components/NotFoundPage/tests/NotFoundPage.a11y.spec.ts +168 -4
  82. package/src/components/NotFoundPage/tests/NotFoundPage.spec.ts +100 -12
  83. package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +2 -2
  84. package/src/components/NotificationBar/NotificationBar.mdx +2 -2
  85. package/src/components/NotificationBar/accessibilite/Accessibility.mdx +68 -8
  86. package/src/components/PageContainer/tests/PageContainer.a11y.spec.ts +14 -7
  87. package/src/components/PhoneField/PhoneField.stories.ts +46 -38
  88. package/src/components/SocialMediaLinks/DefaultSocialMediaLinks.ts +6 -4
  89. package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +7 -5
  90. package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +17 -13
  91. package/src/components/SocialMediaLinks/SocialMediaLinks.vue +9 -1
  92. package/src/components/SocialMediaLinks/accessibilite/Accessibility.mdx +63 -11
  93. package/src/components/SocialMediaLinks/tests/DefaultSocialMediaLinks.spec.ts +5 -5
  94. package/src/components/SocialMediaLinks/tests/SocialMediaLinks.a11y.spec.ts +59 -0
  95. package/src/components/SocialMediaLinks/tests/SocialMediaLinks.spec.ts +9 -7
  96. package/src/components/StatusPage/StatusPage.mdx +22 -0
  97. package/src/components/StatusPage/StatusPage.stories.ts +193 -0
  98. package/src/components/StatusPage/StatusPage.vue +145 -0
  99. package/src/components/StatusPage/accessibilite/Accessibility.mdx +81 -0
  100. package/src/components/StatusPage/tests/StatusPage.a11y.spec.ts +29 -0
  101. package/src/components/StatusPage/tests/StatusPage.spec.ts +50 -0
  102. package/src/components/StatusPage/tests/__snapshots__/StatusPage.spec.ts.snap +270 -0
  103. package/src/components/TableToolbar/TableToolbar.stories.ts +6 -6
  104. package/src/components/TableToolbar/TableToolbar.vue +1 -1
  105. package/src/components/TableToolbar/tests/__snapshots__/TableToolbar.spec.ts.snap +0 -5
  106. package/src/components/UploadWorkflow/UploadWorkflow.mdx +11 -1
  107. package/src/components/UploadWorkflow/UploadWorkflow.stories.ts +107 -3
  108. package/src/components/UploadWorkflow/UploadWorkflow.vue +35 -24
  109. package/src/components/UploadWorkflow/tests/UploadWorkflow.spec.ts +48 -0
  110. package/src/components/UploadWorkflow/tests/__snapshots__/UploadWorkflow.spec.ts.snap +9 -5
  111. package/src/components/UploadWorkflow/useFileList.ts +7 -0
  112. package/src/components/index.ts +3 -0
  113. package/src/composables/rules/tests/useFieldValidation.spec.ts +39 -3
  114. package/src/composables/rules/useFieldValidation.ts +24 -9
  115. package/src/stories/Accessibilite/KitDePreAudit/Preaudit.mdx +7 -0
  116. package/src/utils/theme/index.ts +19 -0
  117. package/src/utils/theme/tests/useThemeLocales.spec.ts +245 -0
  118. package/dist/components/MaintenancePage/index.d.ts +0 -2
  119. package/src/components/Customs/SyPagination/tests/SyPagination.a11y.spec.ts +0 -27
  120. package/src/components/Customs/SyTabs/tests/SyTabs.a11y.spec.ts +0 -51
  121. package/src/components/DataListItem/tests/DataListItem.a11y.spec.ts +0 -31
  122. package/src/components/DatePicker/CalendarMode/tests/DatePicker.a11y.spec.ts +0 -27
  123. package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.a11y.spec.ts +0 -26
  124. package/src/components/DatePicker/DateTextInput/tests/DateTextInput.a11y.spec.ts +0 -27
  125. package/src/components/DownloadBtn/tests/DownloadBtn.a11y.spec.ts +0 -26
  126. package/src/components/ExternalLinks/tests/ExternalLinks.a11y.spec.ts +0 -39
  127. package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.a11y.spec.ts +0 -45
  128. package/src/components/HeaderToolbar/tests/HeaderToolbar.a11y.spec.ts +0 -25
  129. package/src/components/LunarCalendar/tests/LunarCalendar.a11y.spec.ts +0 -31
  130. package/src/components/MaintenancePage/index.ts +0 -3
  131. package/src/components/PageContainer/Accessibilite/AccessibilityGuide.mdx +0 -0
  132. package/src/components/PaginatedTable/tests/PaginatedTable.a11y.spec.ts +0 -43
  133. package/src/components/PhoneField/tests/PhoneField.a11y.spec.ts +0 -34
  134. /package/src/components/NotFoundPage/assets/{not-found.svg → not-found-cnam.svg} +0 -0
  135. /package/src/components/PageContainer/{Accessibilite → accessibilite}/Accessibility.mdx +0 -0
@@ -0,0 +1,856 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import { ref } from 'vue'
3
+ import SyCheckBoxGroup from '@/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.vue'
4
+ import SyForm from '@/components/Customs/SyForm/SyForm.vue'
5
+ import { VBtn } from 'vuetify/components'
6
+
7
+ const meta: Meta<typeof SyCheckBoxGroup> = {
8
+ title: 'Composants/Formulaires/SyCheckBoxGroup',
9
+ component: SyCheckBoxGroup,
10
+ decorators: [
11
+ () => ({
12
+ template: '<div style="padding: 20px;"><story/></div>',
13
+ }),
14
+ ],
15
+ parameters: {
16
+ layout: 'fullscreen',
17
+ docs: {
18
+ description: {
19
+ component: 'SyCheckBoxGroup est un composant de groupe de cases à cocher basé sur SyCheckbox.',
20
+ },
21
+ },
22
+ },
23
+ argTypes: {
24
+ 'modelValue': { control: false },
25
+ 'onUpdate:modelValue': { action: 'update:modelValue' },
26
+ 'onChange': { action: 'change' },
27
+ 'label': { control: 'text' },
28
+ 'displayAsterisk': { control: 'boolean' },
29
+ 'disabled': { control: 'boolean' },
30
+ 'readonly': { control: 'boolean' },
31
+ 'required': { control: 'boolean' },
32
+ 'multiple': { control: 'boolean' },
33
+ 'hideDetails': { control: 'boolean' },
34
+ 'density': {
35
+ control: 'select',
36
+ options: ['default', 'comfortable', 'compact'],
37
+ },
38
+ 'options': { control: 'object' },
39
+ },
40
+ }
41
+
42
+ export default meta
43
+
44
+ type Story = StoryObj<typeof meta>
45
+
46
+ const baseOptions = [
47
+ { label: 'Option A', value: 'a' },
48
+ { label: 'Option B', value: 'b' },
49
+ { label: 'Option C', value: 'c' },
50
+ ]
51
+
52
+ export const Default: Story = {
53
+ parameters: {
54
+ sourceCode: [
55
+ {
56
+ name: 'Template',
57
+ code: `
58
+ <SyCheckBoxGroup
59
+ v-model="value"
60
+ label="Choisissez une option"
61
+ :options="options"
62
+ />
63
+ <div class="mt-2">Sélection : {{ value }}</div>
64
+ `,
65
+ },
66
+ {
67
+ name: 'Script',
68
+ code: `
69
+ <script setup lang="ts">
70
+ import { ref } from 'vue'
71
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
72
+
73
+ const value = ref<string | null>(null)
74
+ const options = [
75
+ { label: 'Option A', value: 'a' },
76
+ { label: 'Option B', value: 'b' },
77
+ { label: 'Option C', value: 'c' },
78
+ ]
79
+ </script>
80
+ `,
81
+ },
82
+ ],
83
+ },
84
+ args: {
85
+ label: 'Choisissez une option',
86
+ options: baseOptions,
87
+ multiple: false,
88
+ required: false,
89
+ },
90
+ render: args => ({
91
+ components: { SyCheckBoxGroup },
92
+ setup() {
93
+ const value = ref<string | null>(null)
94
+ return { args, value }
95
+ },
96
+ template: `
97
+ <div>
98
+ <SyCheckBoxGroup v-model="value" v-bind="args" />
99
+ <div class="mt-2">Sélection : {{ value }}</div>
100
+ </div>
101
+ `,
102
+ }),
103
+ }
104
+
105
+ export const Disabled: Story = {
106
+ parameters: {
107
+ sourceCode: [
108
+ {
109
+ name: 'Template',
110
+ code: `
111
+ <SyCheckBoxGroup
112
+ v-model="value"
113
+ label="CheckBoxGroup désactivé"
114
+ :options="options"
115
+ disabled
116
+ hide-details
117
+ />
118
+ <div class="mt-2">Sélection : {{ value }}</div>
119
+ `,
120
+ },
121
+ {
122
+ name: 'Script',
123
+ code: `
124
+ <script setup lang="ts">
125
+ import { ref } from 'vue'
126
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
127
+
128
+ const value = ref<string | null>('a')
129
+ const options = [
130
+ { label: 'Option A', value: 'a' },
131
+ { label: 'Option B', value: 'b' },
132
+ { label: 'Option C', value: 'c' },
133
+ ]
134
+ </script>
135
+ `,
136
+ },
137
+ ],
138
+ },
139
+ args: {
140
+ label: 'CheckBoxGroup désactivé',
141
+ disabled: true,
142
+ options: baseOptions,
143
+ multiple: false,
144
+ hideDetails: true,
145
+ },
146
+ render: args => ({
147
+ components: { SyCheckBoxGroup },
148
+ setup() {
149
+ const value = ref<string | null>('a')
150
+ return { args, value }
151
+ },
152
+ template: `
153
+ <div>
154
+ <SyCheckBoxGroup v-model="value" v-bind="args" />
155
+ <div class="mt-2">Sélection : {{ value }}</div>
156
+ </div>
157
+ `,
158
+ }),
159
+ }
160
+
161
+ export const Required: Story = {
162
+ parameters: {
163
+ sourceCode: [
164
+ {
165
+ name: 'Template',
166
+ code: `
167
+ <SyForm ref="form" @submit="onSubmit">
168
+ <SyCheckBoxGroup
169
+ v-model="value"
170
+ label="Choisissez une option (obligatoire)"
171
+ :options="options"
172
+ required
173
+ :is-validate-on-blur="false"
174
+ id="sy-checkbox-group-required"
175
+ />
176
+ <div class="mt-2">Sélection : {{ value }}</div>
177
+ <VBtn type="submit" class="mt-4" color="primary">Valider</VBtn>
178
+ </SyForm>
179
+ `,
180
+ },
181
+ {
182
+ name: 'Script',
183
+ code: `
184
+ <script setup lang="ts">
185
+ import { ref } from 'vue'
186
+ import { VBtn } from 'vuetify/components'
187
+ import { SyForm, SyCheckBoxGroup } from '@cnamts/synapse'
188
+
189
+ const value = ref<string | null>(null)
190
+ const options = [
191
+ { label: 'Option A', value: 'a' },
192
+ { label: 'Option B', value: 'b' },
193
+ ]
194
+
195
+ const onSubmit = (event: { isValid: boolean }) => {
196
+ if (event.isValid) {
197
+ alert('Formulaire valide !')
198
+ }
199
+ }
200
+ </script>
201
+ `,
202
+ },
203
+ ],
204
+ },
205
+ args: {
206
+ label: 'Choisissez une option (obligatoire)',
207
+ required: true,
208
+ options: [
209
+ { label: 'Option A', value: 'a' },
210
+ { label: 'Option B', value: 'b' },
211
+ ],
212
+ multiple: false,
213
+ id: 'sy-checkbox-group-required',
214
+ isValidateOnBlur: false,
215
+ },
216
+ render: args => ({
217
+ components: { SyCheckBoxGroup, SyForm, VBtn },
218
+ setup() {
219
+ const value = ref<string | null>(null)
220
+ const onSubmit = (event: { isValid: boolean }) => {
221
+ if (event.isValid) {
222
+ alert('Formulaire valide !')
223
+ }
224
+ }
225
+ return { args, value, onSubmit }
226
+ },
227
+ template: `
228
+ <SyForm ref="form" @submit="onSubmit">
229
+ <SyCheckBoxGroup v-model="value" required v-bind="args" />
230
+ <div class="mt-2">Sélection : {{ value }}</div>
231
+ <VBtn type="submit" class="mt-4" color="primary">Valider</VBtn>
232
+ </SyForm>
233
+ `,
234
+ }),
235
+ }
236
+
237
+ export const Multiple: Story = {
238
+ parameters: {
239
+ sourceCode: [
240
+ {
241
+ name: 'Template',
242
+ code: `
243
+ <SyCheckBoxGroup
244
+ v-model="values"
245
+ label="Choisissez plusieurs options"
246
+ :options="options"
247
+ multiple
248
+ />
249
+ <div class="mt-2">Sélection : {{ values }}</div>
250
+ `,
251
+ },
252
+ {
253
+ name: 'Script',
254
+ code: `
255
+ <script setup lang="ts">
256
+ import { ref } from 'vue'
257
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
258
+
259
+ const values = ref<Array<string>>([])
260
+ const options = [
261
+ { label: 'Option A', value: 'a' },
262
+ { label: 'Option B', value: 'b' },
263
+ { label: 'Option C', value: 'c' },
264
+ ]
265
+ </script>
266
+ `,
267
+ },
268
+ ],
269
+ },
270
+ args: {
271
+ label: 'Choisissez plusieurs options',
272
+ options: baseOptions,
273
+ multiple: true,
274
+ required: false,
275
+ },
276
+ render: args => ({
277
+ components: { SyCheckBoxGroup },
278
+ setup() {
279
+ const value = ref<Array<string>>(['a'])
280
+ return { args, value }
281
+ },
282
+ template: `
283
+ <div>
284
+ <SyCheckBoxGroup v-model="value" v-bind="args" />
285
+ <div class="mt-2">Sélection : {{ value }}</div>
286
+ </div>
287
+ `,
288
+ }),
289
+ }
290
+
291
+ export const MultipleRequired: Story = {
292
+ parameters: {
293
+ sourceCode: [
294
+ {
295
+ name: 'Template',
296
+ code: `
297
+ <SyForm ref="form" @submit="onSubmit">
298
+ <SyCheckBoxGroup
299
+ v-model="values"
300
+ label="Choisissez au moins une option"
301
+ :options="options"
302
+ multiple
303
+ required
304
+ :custom-rules="customRules"
305
+ :is-validate-on-blur="false"
306
+ id="sy-checkbox-group-multiple-required"
307
+ />
308
+ <div class="mt-2">Sélection : {{ values }}</div>
309
+ <VBtn type="submit" class="mt-2" color="primary">Valider</VBtn>
310
+ </SyForm>
311
+ `,
312
+ },
313
+ {
314
+ name: 'Script',
315
+ code: `
316
+ <script setup lang="ts">
317
+ import { ref } from 'vue'
318
+ import { VBtn } from 'vuetify/components'
319
+ import { SyForm, SyCheckBoxGroup } from '@cnamts/synapse'
320
+
321
+ const values = ref<Array<string>>([])
322
+ const options = [
323
+ { label: 'Option A', value: 'a' },
324
+ { label: 'Option B', value: 'b' },
325
+ { label: 'Option C', value: 'c' },
326
+ ]
327
+
328
+ const customRules = [
329
+ {
330
+ type: 'custom',
331
+ options: {
332
+ message: 'Veuillez sélectionner au moins 2 options.',
333
+ validate: (value: Array<string>) => Array.isArray(value) && value.length >= 2,
334
+ },
335
+ },
336
+ ]
337
+
338
+ const onSubmit = (event: { isValid: boolean }) => {
339
+ if (event.isValid) {
340
+ alert('Formulaire valide !')
341
+ }
342
+ }
343
+ </script>
344
+ `,
345
+ },
346
+ ],
347
+ },
348
+ args: {
349
+ label: 'Choisissez au moins une option (multiple requis)',
350
+ options: baseOptions,
351
+ multiple: true,
352
+ required: true,
353
+ customRules: [
354
+ {
355
+ type: 'custom',
356
+ options: {
357
+ message: 'Veuillez sélectionner au moins 2 options.',
358
+ validate: (value: Array<string>) => Array.isArray(value) && value.length >= 2,
359
+ },
360
+ },
361
+ ],
362
+ id: 'sy-checkbox-group-multiple-required',
363
+ isValidateOnBlur: false,
364
+ },
365
+ render: args => ({
366
+ components: { SyCheckBoxGroup, SyForm, VBtn },
367
+ setup() {
368
+ const value = ref<Array<string>>([])
369
+ const onSubmit = (event: { isValid: boolean }) => {
370
+ if (event.isValid) {
371
+ alert('Formulaire valide !')
372
+ }
373
+ }
374
+ return { args, value, onSubmit }
375
+ },
376
+ template: `
377
+ <SyForm ref="form" @submit="onSubmit">
378
+ <SyCheckBoxGroup v-model="value" required v-bind="args" />
379
+ <div class="mt-2">Sélection : {{ value }}</div>
380
+ <VBtn type="submit" class="mt-2" color="primary">Valider</VBtn>
381
+ </SyForm>
382
+ `,
383
+ }),
384
+ }
385
+
386
+ export const ListModel: Story = {
387
+ parameters: {
388
+ sourceCode: [
389
+ {
390
+ name: 'Template',
391
+ code: `
392
+ <SyCheckBoxGroup
393
+ v-model="selected"
394
+ label="v-model comme une liste (tableau)"
395
+ :options="options"
396
+ multiple
397
+ hide-details
398
+ />
399
+ <div class="mt-2">Sélection : {{ selected }}</div>
400
+ `,
401
+ },
402
+ {
403
+ name: 'Script',
404
+ code: `
405
+ <script setup lang="ts">
406
+ import { ref } from 'vue'
407
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
408
+
409
+ const selected = ref<Array<string>>(['a'])
410
+ const options = [
411
+ { label: 'Option A', value: 'a' },
412
+ { label: 'Option B', value: 'b' },
413
+ { label: 'Option C', value: 'c' },
414
+ ]
415
+ </script>
416
+ `,
417
+ },
418
+ ],
419
+ },
420
+ args: {
421
+ label: 'v-model comme une liste (tableau)',
422
+ options: baseOptions,
423
+ multiple: true,
424
+ required: false,
425
+ hideDetails: true,
426
+ },
427
+ render: args => ({
428
+ components: { SyCheckBoxGroup },
429
+ setup() {
430
+ const selected = ref<Array<string>>(['a'])
431
+ return { args, selected }
432
+ },
433
+ template: `
434
+ <div>
435
+ <SyCheckBoxGroup v-model="selected" v-bind="args" />
436
+ <div class="mt-2">Sélection : {{ selected }}</div>
437
+ </div>
438
+ `,
439
+ }),
440
+ }
441
+
442
+ export const FormValidation: Story = {
443
+ args: {
444
+ label: 'Choisissez une option (obligatoire)',
445
+ required: true,
446
+ options: [
447
+ { label: 'Option A', value: 'a' },
448
+ { label: 'Option B', value: 'b' },
449
+ ],
450
+ multiple: false,
451
+ id: 'sy-checkbox-group-form-validation',
452
+ isValidateOnBlur: false,
453
+ },
454
+ render: args => ({
455
+ components: { SyCheckBoxGroup, SyForm, VBtn },
456
+ setup() {
457
+ const value = ref<string | null>(null)
458
+ const onSubmit = (event: { isValid: boolean }) => {
459
+ if (event.isValid) {
460
+ alert('Formulaire valide !')
461
+ }
462
+ }
463
+ return { args, value, onSubmit }
464
+ },
465
+ template: `
466
+ <SyForm ref="form" @submit="onSubmit">
467
+ <SyCheckBoxGroup v-model="value" required v-bind="args" />
468
+ <div class="mt-2">Sélection : {{ value }}</div>
469
+ <VBtn type="submit" class="mt-4" color="primary">Valider</VBtn>
470
+ </SyForm>
471
+ `,
472
+ }),
473
+ parameters: {
474
+ sourceCode: [
475
+ {
476
+ name: 'Template',
477
+ code: `
478
+ <SyForm ref="form" @submit="onSubmit">
479
+ <SyCheckBoxGroup
480
+ v-model="value"
481
+ label="Choisissez une option (obligatoire)"
482
+ :options="options"
483
+ required
484
+ :is-validate-on-blur="false"
485
+ id="sy-checkbox-group-form-validation"
486
+ />
487
+ <div class="mt-2">Sélection : {{ value }}</div>
488
+ <VBtn type="submit" class="mt-4" color="primary">Valider</VBtn>
489
+ </SyForm>
490
+ `,
491
+ },
492
+ {
493
+ name: 'Script',
494
+ code: `
495
+ <script setup lang="ts">
496
+ import { ref } from 'vue'
497
+ import { VBtn } from 'vuetify/components'
498
+ import { SyForm, SyCheckBoxGroup } from '@cnamts/synapse'
499
+
500
+ const value = ref<string | null>(null)
501
+ const options = [
502
+ { label: 'Option A', value: 'a' },
503
+ { label: 'Option B', value: 'b' },
504
+ ]
505
+
506
+ const onSubmit = (event: { isValid: boolean }) => {
507
+ if (event.isValid) {
508
+ alert('Formulaire valide !')
509
+ }
510
+ }
511
+ </script>
512
+ `,
513
+ },
514
+ ],
515
+ },
516
+ }
517
+
518
+ export const CustomColors: Story = {
519
+ parameters: {
520
+ sourceCode: [
521
+ {
522
+ name: 'Template',
523
+ code: `
524
+ <div>
525
+ <SyCheckBoxGroup
526
+ v-model="value1"
527
+ color="primary"
528
+ label="Couleur primaire (par défaut)"
529
+ :options="options"
530
+ :show-success-messages="false"
531
+ />
532
+ <SyCheckBoxGroup
533
+ v-model="value2"
534
+ color="secondary"
535
+ label="Couleur secondaire"
536
+ :options="options"
537
+ :show-success-messages="false"
538
+ />
539
+ <SyCheckBoxGroup
540
+ v-model="value3"
541
+ color="success"
542
+ label="Couleur succès"
543
+ :options="options"
544
+ :show-success-messages="false"
545
+ />
546
+ <SyCheckBoxGroup
547
+ v-model="value4"
548
+ color="error"
549
+ label="Couleur erreur"
550
+ :options="options"
551
+ :show-success-messages="false"
552
+ />
553
+ <SyCheckBoxGroup
554
+ v-model="value5"
555
+ color="warning"
556
+ label="Couleur avertissement"
557
+ :options="options"
558
+ :show-success-messages="false"
559
+ />
560
+ </div>
561
+ `,
562
+ },
563
+ {
564
+ name: 'Script',
565
+ code: `<script setup lang="ts">
566
+ import { ref } from 'vue'
567
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
568
+
569
+ const value1 = ref<string | null>('a')
570
+ const value2 = ref<string | null>('a')
571
+ const value3 = ref<string | null>('a')
572
+ const value4 = ref<string | null>('a')
573
+ const value5 = ref<string | null>('a')
574
+
575
+ const options = [
576
+ { label: 'Value 1', value: 'a' },
577
+ { label: 'Value 2', value: 'b' },
578
+ ]
579
+ </script>`,
580
+ },
581
+ ],
582
+ docs: {
583
+ description: {
584
+ story: `
585
+ ### Couleurs personnalisées
586
+ Le composant SyCheckBoxGroup peut être personnalisé avec différentes couleurs pour s'adapter à votre thème.
587
+ `,
588
+ },
589
+ },
590
+ },
591
+ render: args => ({
592
+ components: { SyCheckBoxGroup },
593
+ setup() {
594
+ const options = [
595
+ { label: 'Value 1', value: 'a' },
596
+ { label: 'Value 2', value: 'b' },
597
+ ]
598
+ const value1 = ref<string | null>('a')
599
+ const value2 = ref<string | null>('a')
600
+ const value3 = ref<string | null>('a')
601
+ const value4 = ref<string | null>('a')
602
+ const value5 = ref<string | null>('a')
603
+ return { args, options, value1, value2, value3, value4, value5 }
604
+ },
605
+ template: `
606
+ <div>
607
+ <SyCheckBoxGroup v-model="value1" color="primary" label="Couleur primaire (par défaut)" :options="options" :show-success-messages="false" />
608
+ <SyCheckBoxGroup v-model="value2" color="secondary" label="Couleur secondaire" :options="options" :show-success-messages="false" />
609
+ <SyCheckBoxGroup v-model="value3" color="success" label="Couleur succès" :options="options" :show-success-messages="false" />
610
+ <SyCheckBoxGroup v-model="value4" color="error" label="Couleur erreur" :options="options" :show-success-messages="false" />
611
+ <SyCheckBoxGroup v-model="value5" color="warning" label="Couleur avertissement" :options="options" :show-success-messages="false" />
612
+ </div>
613
+ `,
614
+ }),
615
+ }
616
+
617
+ export const DifferentDensities: Story = {
618
+ parameters: {
619
+ sourceCode: [
620
+ {
621
+ name: 'Template',
622
+ code: `
623
+ <div>
624
+ <SyCheckBoxGroup
625
+ v-model="val1"
626
+ density="default"
627
+ label="Default density"
628
+ :options="options"
629
+ :show-success-messages="false"
630
+ />
631
+ <SyCheckBoxGroup
632
+ v-model="val2"
633
+ density="comfortable"
634
+ label="Comfortable"
635
+ :options="options"
636
+ :show-success-messages="false"
637
+ />
638
+ <SyCheckBoxGroup
639
+ v-model="val3"
640
+ density="compact"
641
+ label="Compact"
642
+ :options="options"
643
+ :show-success-messages="false"
644
+ />
645
+ </div>
646
+ `,
647
+ },
648
+ {
649
+ name: 'Script',
650
+ code: `<script setup lang="ts">
651
+ import { ref } from 'vue'
652
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
653
+
654
+ const val1 = ref<string | null>(null)
655
+ const val2 = ref<string | null>(null)
656
+ const val3 = ref<string | null>(null)
657
+
658
+ const options = [
659
+ { label: 'Value 1', value: 'a' },
660
+ { label: 'Value 2', value: 'b' },
661
+ ]
662
+ </script>`,
663
+ },
664
+ ],
665
+ docs: {
666
+ description: {
667
+ story: `
668
+ ### Différentes densités
669
+ Le composant SyCheckBoxGroup prend en charge différentes densités pour s'adapter à différents contextes d'interface utilisateur.
670
+ `,
671
+ },
672
+ },
673
+ },
674
+ render: () => ({
675
+ components: { SyCheckBoxGroup },
676
+ setup() {
677
+ const val1 = ref<string | null>(null)
678
+ const val2 = ref<string | null>(null)
679
+ const val3 = ref<string | null>(null)
680
+ const options = [
681
+ { label: 'Value 1', value: 'a' },
682
+ { label: 'Value 2', value: 'b' },
683
+ ]
684
+ return { val1, val2, val3, options }
685
+ },
686
+ template: `
687
+ <div>
688
+ <SyCheckBoxGroup v-model="val1" density="default" label="Default density" :options="options" :show-success-messages="false" />
689
+ <SyCheckBoxGroup v-model="val2" density="comfortable" label="Comfortable" :options="options" :show-success-messages="false" />
690
+ <SyCheckBoxGroup v-model="val3" density="compact" label="Compact" :options="options" :show-success-messages="false" />
691
+ </div>
692
+ `,
693
+ }),
694
+ }
695
+
696
+ export const Readonly: Story = {
697
+ args: {
698
+ readonly: true,
699
+ options: [
700
+ { label: 'Option A', value: 'a' },
701
+ { label: 'Option B', value: 'b' },
702
+ { label: 'Option C', value: 'c' },
703
+ ],
704
+ },
705
+ render: args => ({
706
+ components: { SyCheckBoxGroup },
707
+ setup() {
708
+ const value = ref<string | null>('a')
709
+ return { args, value }
710
+ },
711
+ template: `
712
+ <div>
713
+ <SyCheckBoxGroup v-model="value" v-bind="args" label="CheckBoxGroup en lecture seule" />
714
+ <div class="mt-2">Sélection : {{ value }}</div>
715
+ </div>
716
+ `,
717
+ }),
718
+ parameters: {
719
+ sourceCode: [
720
+ {
721
+ name: 'Template',
722
+ code: `
723
+ <SyCheckBoxGroup
724
+ v-model="value"
725
+ label="CheckBoxGroup en lecture seule"
726
+ :options="options"
727
+ readonly
728
+ />
729
+ <div class="mt-2">Sélection : {{ value }}</div>
730
+ `,
731
+ },
732
+ {
733
+ name: 'Script',
734
+ code: `
735
+ <script setup lang="ts">
736
+ import { ref } from 'vue'
737
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
738
+
739
+ const value = ref<string | null>('a')
740
+ const options = [
741
+ { label: 'Option A', value: 'a' },
742
+ { label: 'Option B', value: 'b' },
743
+ { label: 'Option C', value: 'c' },
744
+ ]
745
+ </script>
746
+ `,
747
+ },
748
+ ],
749
+ },
750
+ }
751
+
752
+ export const CustomRules: Story = {
753
+ parameters: {
754
+ sourceCode: [
755
+ {
756
+ name: 'Template',
757
+ code: `
758
+ <template>
759
+ <SyCheckBoxGroup
760
+ v-model="selected"
761
+ :options="options"
762
+ label="Options"
763
+ :custom-warning-rules="warningRules"
764
+ :custom-success-rules="successRules"
765
+ :is-validate-on-blur="false"
766
+ />
767
+ </template>
768
+ `,
769
+ },
770
+ {
771
+ name: 'Script',
772
+ code: `<script setup lang="ts">
773
+ import { ref } from 'vue'
774
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
775
+
776
+ const selected = ref<string | null>('A')
777
+
778
+ const options = [
779
+ { label: 'Option A', value: 'A' },
780
+ { label: 'Option B', value: 'B' },
781
+ ]
782
+
783
+ const warningRules = [
784
+ {
785
+ type: 'custom',
786
+ options: {
787
+ validate: (value: string | null) => {
788
+ if (value !== 'A') {
789
+ return 'Vous devez sélectionner l’option A'
790
+ }
791
+ return true
792
+ },
793
+ fieldIdentifier: 'option',
794
+ },
795
+ },
796
+ ]
797
+
798
+ const successRules = [
799
+ {
800
+ type: 'custom',
801
+ options: {
802
+ validate: (value: string | null) => value === 'A',
803
+ successMessage: 'Option A sélectionnée',
804
+ fieldIdentifier: 'option',
805
+ },
806
+ },
807
+ ]
808
+ </script>`,
809
+ },
810
+ ],
811
+ },
812
+
813
+ render: args => ({
814
+ components: { SyCheckBoxGroup },
815
+ setup() {
816
+ const selected = ref<string | null>('A')
817
+ const options = [
818
+ { label: 'Option A', value: 'A' },
819
+ { label: 'Option B', value: 'B' },
820
+ ]
821
+ const warningRules = [
822
+ {
823
+ type: 'custom',
824
+ options: {
825
+ validate: (value: string | null) => {
826
+ if (value !== 'A') {
827
+ return 'Vous devez sélectionner l’option A'
828
+ }
829
+ return true
830
+ },
831
+ },
832
+ },
833
+ ]
834
+ const successRules = [
835
+ {
836
+ type: 'custom',
837
+ options: {
838
+ validate: (value: string | null) => value === 'A',
839
+ successMessage: 'Option A sélectionnée',
840
+ },
841
+ },
842
+ ]
843
+ return { args, selected, options, warningRules, successRules }
844
+ },
845
+ template: `
846
+ <SyCheckBoxGroup
847
+ v-model="selected"
848
+ label="Options"
849
+ :options="options"
850
+ :custom-warning-rules="warningRules"
851
+ :custom-success-rules="successRules"
852
+ :is-validate-on-blur="false"
853
+ />
854
+ `,
855
+ }),
856
+ }