@cnamts/synapse 1.1.0 → 1.1.1

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 (202) hide show
  1. package/dist/{AutocompleteFilter-DXd4szWO.js → AutocompleteFilter-CGF33skz.js} +1 -1
  2. package/dist/{DateFilter-BD59Kgwf.js → DateFilter-D7-MsKtx.js} +1 -1
  3. package/dist/{NumberFilter-BSMZE7uw.js → NumberFilter-bjQPPfsj.js} +1 -1
  4. package/dist/{PeriodFilter-keUdSSk0.js → PeriodFilter-B3wJpK8-.js} +1 -1
  5. package/dist/{SelectFilter-Dhvvwazl.js → SelectFilter-BN6DbKAV.js} +1 -1
  6. package/dist/{TextFilter-CU8FpXz0.js → TextFilter-BffP0J2f.js} +1 -1
  7. package/dist/{apLightTheme2026-DbS7BPUf.js → apLightTheme2026-C4ygwMHC.js} +11 -11
  8. package/dist/components/Amelipro/AmeliproAutoCompleteField/AmeliproAutoCompleteField.d.ts +6 -6
  9. package/dist/components/Amelipro/AmeliproSelect/AmeliproSelect.d.ts +6 -6
  10. package/dist/components/Amelipro/AmeliproTabs/AmeliproTabs.d.ts +6 -6
  11. package/dist/components/Captcha/Captcha.d.ts +27 -16
  12. package/dist/components/Captcha/CaptchaForm.d.ts +29 -3
  13. package/dist/components/Captcha/types.d.ts +14 -0
  14. package/dist/components/Captcha/useCaptchaValidation.d.ts +37 -0
  15. package/dist/components/Customs/Selects/SelectBtnField/SelectBtnField.d.ts +33 -13
  16. package/dist/components/Customs/Selects/SelectBtnField/composables/useSelectBtnFieldValidation.d.ts +23 -0
  17. package/dist/components/Customs/Selects/SyAutocomplete/composables/useSyAutocompleteValidation.d.ts +2 -2
  18. package/dist/components/Customs/Selects/SySelect/composables/useSySelectValidation.d.ts +2 -2
  19. package/dist/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.d.ts +17 -48
  20. package/dist/components/Customs/SyCheckBoxGroup/composables/useSyCheckBoxGroupValidation.d.ts +29 -0
  21. package/dist/components/Customs/SyCheckBoxGroup/types.d.ts +46 -0
  22. package/dist/components/Customs/SyCheckbox/SyCheckbox.d.ts +16 -51
  23. package/dist/components/Customs/SyCheckbox/composables/useSyCheckboxValidation.d.ts +27 -0
  24. package/dist/components/Customs/SyCheckbox/types.d.ts +49 -0
  25. package/dist/components/Customs/SyTextField/FieldState.d.ts +5 -0
  26. package/dist/components/Customs/SyTextField/useSyTextFieldValidation.d.ts +3 -3
  27. package/dist/components/DialogBox/DialogBox.d.ts +2 -0
  28. package/dist/components/DialogBox/locales.d.ts +1 -0
  29. package/dist/components/FilterSideBar/FilterSideBar.d.ts +4 -0
  30. package/dist/components/LunarCalendar/LunarCalendar.d.ts +43 -14
  31. package/dist/components/LunarCalendar/types.d.ts +35 -0
  32. package/dist/components/LunarCalendar/useLunarCalendarValidation.d.ts +11 -12
  33. package/dist/components/MonthPicker/MonthPicker.d.ts +72 -1747
  34. package/dist/components/MonthPicker/MonthPickerText/MonthPickerInput.d.ts +21 -1733
  35. package/dist/components/MonthPicker/MonthPickerText/useTextField.d.ts +5 -0
  36. package/dist/components/MonthPicker/locales.d.ts +1 -0
  37. package/dist/components/MonthPicker/types.d.ts +11 -0
  38. package/dist/components/MonthPicker/useMonthPickerValidation.d.ts +37 -24
  39. package/dist/components/NirField/NirField.d.ts +6 -4
  40. package/dist/components/NirField/useNirValidation.d.ts +7 -5
  41. package/dist/components/PageContainer/PageContainer.d.ts +8 -0
  42. package/dist/components/PasswordField/PasswordField.d.ts +2 -2
  43. package/dist/components/PasswordField/usePasswordFieldValidation.d.ts +2 -2
  44. package/dist/components/PhoneField/PhoneField.d.ts +960 -1938
  45. package/dist/components/PhoneField/indicatifs.d.ts +715 -8
  46. package/dist/components/PhoneField/locales.d.ts +7 -0
  47. package/dist/components/PhoneField/types.d.ts +29 -0
  48. package/dist/components/PhoneField/usePhoneFieldValidation.d.ts +45 -0
  49. package/dist/components/PhoneField/usePhoneIndicatifs.d.ts +947 -0
  50. package/dist/components/SyTextArea/composables/useSyTextAreaValidation.d.ts +2 -2
  51. package/dist/composables/unifyValidation/documentationValidationProps.d.ts +1 -1
  52. package/dist/composables/unifyValidation/useValidation.d.ts +4 -5
  53. package/dist/design-system-v3.js +2 -2
  54. package/dist/designTokens/tokens/amelipro/apLightTheme.d.ts +10 -10
  55. package/dist/designTokens/tokens/baseTokens.d.ts +18 -18
  56. package/dist/designTokens/tokens/cnam/cnamLightTheme.d.ts +10 -10
  57. package/dist/designTokens/tokens/pa/paLightTheme.d.ts +10 -10
  58. package/dist/designTokens/tokens/semanticTokens.d.ts +14 -14
  59. package/dist/{main-D8ryUoS5.js → main-C4wAktOs.js} +13718 -12991
  60. package/dist/synapse.css +1 -1
  61. package/dist/vuetifyConfig.js +1 -1
  62. package/package.json +7 -7
  63. package/src/assets/compat/_legacy-tokens.scss +91 -0
  64. package/src/assets/overrides/_utilities.scss +23 -0
  65. package/src/components/Accordion/Accordion.stories.ts +121 -1
  66. package/src/components/BackBtn/BackBtn.mdx +1 -1
  67. package/src/components/BackToTopBtn/BackToTopBtn.mdx +0 -1
  68. package/src/components/Captcha/Captcha.stories.ts +134 -31
  69. package/src/components/Captcha/Captcha.vue +95 -28
  70. package/src/components/Captcha/CaptchaForm.vue +51 -22
  71. package/src/components/Captcha/tests/Captcha.focus.spec.ts +214 -0
  72. package/src/components/Captcha/tests/Captcha.spec.ts +233 -24
  73. package/src/components/Captcha/tests/CaptchaForm.spec.ts +82 -0
  74. package/src/components/Captcha/tests/__snapshots__/Captcha.spec.ts.snap +16 -42
  75. package/src/components/Captcha/types.ts +15 -0
  76. package/src/components/Captcha/useCaptchaValidation.ts +87 -0
  77. package/src/components/Captcha/validation/validation.stories.ts +1194 -0
  78. package/src/components/ChipList/ChipList.mdx +0 -1
  79. package/src/components/CollapsibleList/CollapsibleList.mdx +0 -1
  80. package/src/components/CookieBanner/CookieBanner.mdx +0 -1
  81. package/src/components/CopyBtn/CopyBtn.mdx +0 -1
  82. package/src/components/Customs/Selects/SelectBtnField/SelectBtnField.stories.ts +123 -439
  83. package/src/components/Customs/Selects/SelectBtnField/SelectBtnField.vue +147 -41
  84. package/src/components/Customs/Selects/SelectBtnField/Validation/Validation.stories.ts +600 -0
  85. package/src/components/Customs/Selects/SelectBtnField/composables/useSelectBtnFieldValidation.ts +87 -0
  86. package/src/components/Customs/Selects/SelectBtnField/tests/SelectBtnField.spec.ts +402 -33
  87. package/src/components/Customs/Selects/SelectBtnField/tests/__snapshots__/SelectBtnField.spec.ts.snap +52 -38
  88. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.stories.ts +342 -162
  89. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.vue +77 -129
  90. package/src/components/Customs/SyCheckBoxGroup/Validation/Validation.stories.ts +1008 -0
  91. package/src/components/Customs/SyCheckBoxGroup/composables/useSyCheckBoxGroupValidation.ts +107 -0
  92. package/src/components/Customs/SyCheckBoxGroup/tests/SyCheckBoxGroup.spec.ts +180 -7
  93. package/src/components/Customs/SyCheckBoxGroup/types.ts +49 -0
  94. package/src/components/Customs/SyCheckbox/SyCheckbox.stories.ts +41 -161
  95. package/src/components/Customs/SyCheckbox/SyCheckbox.vue +71 -148
  96. package/src/components/Customs/SyCheckbox/Validation/Validation.stories.ts +654 -0
  97. package/src/components/Customs/SyCheckbox/composables/useSyCheckboxValidation.ts +105 -0
  98. package/src/components/Customs/SyCheckbox/tests/SyCheckbox.spec.ts +106 -0
  99. package/src/components/Customs/SyCheckbox/tests/useSyCheckboxValidation.spec.ts +98 -0
  100. package/src/components/Customs/SyCheckbox/types.ts +51 -0
  101. package/src/components/Customs/SyTextField/FieldState.vue +50 -0
  102. package/src/components/Customs/SyTextField/SyTextField.vue +12 -9
  103. package/src/components/Customs/SyTextField/useSyTextFieldValidation.ts +2 -11
  104. package/src/components/DataList/DataList.mdx +0 -1
  105. package/src/components/DataListGroup/DataListGroup.mdx +0 -1
  106. package/src/components/DiacriticPicker/DiacriticPicker.mdx +0 -1
  107. package/src/components/DialogBox/DialogBox.mdx +0 -1
  108. package/src/components/DialogBox/DialogBox.stories.ts +399 -4
  109. package/src/components/DialogBox/DialogBox.vue +20 -0
  110. package/src/components/DialogBox/locales.ts +1 -0
  111. package/src/components/DialogBox/tests/DialogBox.spec.ts +73 -0
  112. package/src/components/DialogBox/tests/DialogBox.visual.cy.ts +24 -0
  113. package/src/components/ErrorPage/ErrorPage.mdx +1 -1
  114. package/src/components/ExternalLinks/ExternalLinks.mdx +0 -1
  115. package/src/components/FileList/FileList.mdx +0 -1
  116. package/src/components/FilterInline/FilterInline.mdx +0 -1
  117. package/src/components/FilterSideBar/FilterSideBar.mdx +8 -1
  118. package/src/components/FilterSideBar/FilterSideBar.stories.ts +133 -1
  119. package/src/components/FilterSideBar/FilterSideBar.vue +19 -2
  120. package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +55 -0
  121. package/src/components/FooterBar/FooterBar.mdx +0 -1
  122. package/src/components/FranceConnectBtn/FranceConnectBtn.mdx +0 -1
  123. package/src/components/HeaderBar/HeaderBar.mdx +0 -1
  124. package/src/components/HeaderLoading/HeaderLoading.mdx +0 -1
  125. package/src/components/LangBtn/LangBtn.mdx +0 -1
  126. package/src/components/Logo/Logo.mdx +1 -1
  127. package/src/components/LunarCalendar/LunarCalendar.mdx +6 -9
  128. package/src/components/LunarCalendar/LunarCalendar.stories.ts +243 -46
  129. package/src/components/LunarCalendar/LunarCalendar.vue +61 -26
  130. package/src/components/LunarCalendar/Validation/Validation.stories.ts +717 -0
  131. package/src/components/LunarCalendar/tests/LunarCalendar.a11y.spec.ts +1 -1
  132. package/src/components/LunarCalendar/tests/LunarCalendar.spec.ts +197 -6
  133. package/src/components/LunarCalendar/tests/useLunarCalendarValidation.spec.ts +287 -0
  134. package/src/components/LunarCalendar/types.ts +39 -0
  135. package/src/components/LunarCalendar/useLunarCalendarValidation.ts +115 -39
  136. package/src/components/MonthPicker/MonthPicker.stories.ts +38 -281
  137. package/src/components/MonthPicker/MonthPicker.vue +66 -17
  138. package/src/components/MonthPicker/MonthPickerText/MonthPickerInput.vue +44 -20
  139. package/src/components/MonthPicker/MonthPickerText/useTextField.ts +5 -0
  140. package/src/components/MonthPicker/Validation/Validation.stories.ts +1117 -0
  141. package/src/components/MonthPicker/locales.ts +1 -0
  142. package/src/components/MonthPicker/tests/MonthPicker.spec.ts +353 -2
  143. package/src/components/MonthPicker/tests/__snapshots__/MonthPicker.spec.ts.snap +12 -8
  144. package/src/components/MonthPicker/types.ts +16 -0
  145. package/src/components/MonthPicker/useMonthPickerValidation.ts +64 -27
  146. package/src/components/NirField/NirField.mdx +120 -66
  147. package/src/components/NirField/NirField.stories.ts +216 -0
  148. package/src/components/NirField/useNirValidation.ts +16 -17
  149. package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +263 -245
  150. package/src/components/NotificationBar/NotificationBar.mdx +0 -1
  151. package/src/components/PageContainer/PageContainer.mdx +0 -1
  152. package/src/components/PageContainer/PageContainer.stories.ts +170 -2
  153. package/src/components/PageContainer/PageContainer.vue +63 -8
  154. package/src/components/PageContainer/tests/__snapshots__/PageContainer.spec.ts.snap +19 -11
  155. package/src/components/PaginatedTable/PaginatedTable.mdx +0 -1
  156. package/src/components/PeriodField/PeriodField.mdx +0 -1
  157. package/src/components/PhoneField/PhoneField.mdx +2 -3
  158. package/src/components/PhoneField/PhoneField.stories.ts +227 -410
  159. package/src/components/PhoneField/PhoneField.vue +204 -438
  160. package/src/components/PhoneField/indicatifs.ts +1 -1
  161. package/src/components/PhoneField/locales.ts +7 -0
  162. package/src/components/PhoneField/tests/PhoneField.a11y.spec.ts +0 -1
  163. package/src/components/PhoneField/tests/PhoneField.spec.ts +517 -220
  164. package/src/components/PhoneField/types.ts +30 -0
  165. package/src/components/PhoneField/usePhoneFieldValidation.ts +119 -0
  166. package/src/components/PhoneField/usePhoneIndicatifs.ts +89 -0
  167. package/src/components/PhoneField/validation/validation.stories.ts +717 -0
  168. package/src/components/RangeField/RangeField.mdx +0 -1
  169. package/src/components/RatingPicker/RatingPicker.mdx +0 -1
  170. package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +0 -1
  171. package/src/components/StatusPage/StatusPage.vue +1 -0
  172. package/src/components/StatusPage/tests/__snapshots__/StatusPage.spec.ts.snap +248 -230
  173. package/src/components/SubHeader/SubHeader.mdx +5 -6
  174. package/src/components/Tables/common/tests/SyTableFilter.spec.ts +11 -12
  175. package/src/components/UploadWorkflow/UploadWorkflow.mdx +0 -1
  176. package/src/components/UserMenuBtn/UserMenuBtn.mdx +0 -1
  177. package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +177 -0
  178. package/src/composables/unifyValidation/documentationValidationProps.ts +1 -1
  179. package/src/composables/unifyValidation/tests/useValidation.spec.ts +13 -1
  180. package/src/composables/unifyValidation/useValidation.ts +37 -33
  181. package/src/composantsVuetify/VCard/VCard.mdx +4 -0
  182. package/src/composantsVuetify/VCard/v-card.stories.ts +93 -1
  183. package/src/composantsVuetify/VCarousel/VCarousel.mdx +74 -0
  184. package/src/composantsVuetify/VCarousel/v-carousel.stories.ts +531 -0
  185. package/src/composantsVuetify/VNavigationDrawer/VNavgationDrawer.mdx +53 -0
  186. package/src/composantsVuetify/VNavigationDrawer/v-navigation-drawer.stories.ts +310 -0
  187. package/src/composantsVuetify/VSlideGroup/VSlideGroup.mdx +105 -0
  188. package/src/composantsVuetify/VSlideGroup/v-slide-group.stories.ts +463 -0
  189. package/src/designTokens/tokens/baseColors.ts +1 -1
  190. package/src/designTokens/tokens/baseTokens.ts +18 -18
  191. package/src/stories/Components/Components.stories.ts +34 -1
  192. package/src/stories/Demarrer/Releases.stories.ts +16 -2
  193. package/src/stories/DesignTokens/Arrondis.mdx +1 -1
  194. package/src/stories/DesignTokens/Correspondances.mdx +219 -0
  195. package/src/stories/DesignTokens/UtiliserLesTokens.mdx +235 -0
  196. package/src/stories/DesignTokens/colors.stories.ts +569 -569
  197. package/src/stories/GuideDuDev/Amelipro.stories.ts +335 -267
  198. package/dist/components/LunarCalendar/useLunarCalendarRules.d.ts +0 -5
  199. package/dist/components/PhoneField/tests/types.d.ts +0 -18
  200. package/src/components/LunarCalendar/tests/useLunarCalendarRules.spec.ts +0 -184
  201. package/src/components/LunarCalendar/useLunarCalendarRules.ts +0 -96
  202. package/src/components/PhoneField/tests/types.d.ts +0 -19
@@ -1,10 +1,12 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import { ref } from 'vue'
3
- import SyCheckBoxGroup from '@/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.vue'
3
+ import SyCheckBoxGroup from './SyCheckBoxGroup.vue'
4
4
  import SyForm from '@/components/Customs/SyForm/SyForm.vue'
5
5
  import { VBtn } from 'vuetify/components'
6
+ import { getValidationDocumentation } from '@/composables/unifyValidation/documentationValidationProps'
7
+ import type { SyCheckBoxGroupProps } from './types'
6
8
 
7
- const meta: Meta<typeof SyCheckBoxGroup> = {
9
+ const meta: Meta<SyCheckBoxGroupProps> = {
8
10
  title: 'Composants/Formulaires/SyCheckBoxGroup',
9
11
  component: SyCheckBoxGroup,
10
12
  decorators: [
@@ -16,32 +18,68 @@ const meta: Meta<typeof SyCheckBoxGroup> = {
16
18
  layout: 'fullscreen',
17
19
  docs: {
18
20
  description: {
19
- component: 'SyCheckBoxGroup est un composant de groupe de cases à cocher basé sur SyCheckbox.',
21
+ component: `
22
+ SyCheckBoxGroup est un composant de groupe de cases à cocher.
23
+ Il permet de choisir **une ou plusieurs valeurs** parmi une liste d'options.
24
+ `,
20
25
  },
21
26
  },
22
27
  },
23
28
  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': {
29
+ ...getValidationDocumentation(),
30
+ modelValue: { control: false },
31
+ helpText: {
32
+ description: 'Texte d\'aide affiché sous le groupe (disparaît en cas de message de validation)',
33
+ control: 'text',
34
+ },
35
+ label: {
36
+ description: 'Label du groupe',
37
+ control: 'text',
38
+ },
39
+ options: {
40
+ description: 'Liste des options du checkbox-group',
41
+ control: 'object',
42
+ },
43
+ color: {
44
+ control: 'select',
45
+ options: ['primary', 'secondary', 'success', 'error', 'warning'],
46
+ description: 'Couleur du groupe',
47
+ },
48
+ density: {
35
49
  control: 'select',
36
50
  options: ['default', 'comfortable', 'compact'],
51
+ description: 'Densité du groupe',
52
+ },
53
+ displayAsterisk: {
54
+ description: 'Affiche un astérisque pour les champs requis',
55
+ control: 'boolean',
56
+ },
57
+ multiple: {
58
+ description: 'Permet la sélection multiple (tableau)',
59
+ control: 'boolean',
60
+ },
61
+ ariaLabel: {
62
+ description: 'Label ARIA pour les lecteurs d\'écran',
63
+ control: 'text',
64
+ },
65
+ ariaLabelledby: {
66
+ description: 'ID d\'un élément qui labelise le groupe',
67
+ control: 'text',
68
+ },
69
+ title: {
70
+ description: 'Attribut title du groupe',
71
+ control: 'text',
72
+ },
73
+ name: {
74
+ description: 'Nom du groupe (attribut name)',
75
+ control: 'text',
37
76
  },
38
- 'options': { control: 'object' },
39
77
  },
40
78
  }
41
79
 
42
80
  export default meta
43
81
 
44
- type Story = StoryObj<typeof meta>
82
+ type Story = StoryObj<SyCheckBoxGroupProps>
45
83
 
46
84
  const baseOptions = [
47
85
  { label: 'Option A', value: 'a' },
@@ -234,6 +272,71 @@ export const Required: Story = {
234
272
  }),
235
273
  }
236
274
 
275
+ export const RequiredWithAsterisk: Story = {
276
+ args: {
277
+ label: 'Champ obligatoire',
278
+ required: true,
279
+ displayAsterisk: true,
280
+ options: [
281
+ { label: 'Option A', value: 'a' },
282
+ { label: 'Option B', value: 'b' },
283
+ ],
284
+ multiple: false,
285
+ },
286
+
287
+ parameters: {
288
+ docs: {
289
+ description: {
290
+ story: `
291
+ ### Affichage de l'astérisque
292
+ Ce story démontre l'affichage d'un astérisque (*) sur le label pour indiquer qu'un champ est obligatoire.
293
+ `,
294
+ },
295
+ },
296
+ sourceCode: [
297
+ {
298
+ name: 'Template',
299
+ code: `
300
+ <SyCheckBoxGroup
301
+ v-model="selected"
302
+ label="Champ obligatoire"
303
+ :options="options"
304
+ required
305
+ display-asterisk
306
+ />`,
307
+ },
308
+ {
309
+ name: 'Script',
310
+ code: `<script setup lang="ts">
311
+ import { ref } from 'vue'
312
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
313
+
314
+ const selected = ref<string | null>(null)
315
+
316
+ const options = [
317
+ { label: 'Option A', value: 'a' },
318
+ { label: 'Option B', value: 'b' },
319
+ ]
320
+ </script>`,
321
+ },
322
+ ],
323
+ },
324
+
325
+ render: args => ({
326
+ components: { SyCheckBoxGroup },
327
+ setup() {
328
+ const selected = ref<string | null>(null)
329
+ return { args, selected }
330
+ },
331
+ template: `
332
+ <SyCheckBoxGroup
333
+ v-model="selected"
334
+ v-bind="args"
335
+ />
336
+ `,
337
+ }),
338
+ }
339
+
237
340
  export const Multiple: Story = {
238
341
  parameters: {
239
342
  sourceCode: [
@@ -439,82 +542,6 @@ export const ListModel: Story = {
439
542
  }),
440
543
  }
441
544
 
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
545
  export const CustomColors: Story = {
519
546
  parameters: {
520
547
  sourceCode: [
@@ -760,23 +787,38 @@ export const Readonly: Story = {
760
787
  },
761
788
  }
762
789
 
763
- export const CustomRules: Story = {
790
+ export const EventShowcase: Story = {
764
791
  parameters: {
792
+ docs: {
793
+ description: {
794
+ story: `
795
+ ### Événements
796
+ Ce story démontre les événements émis par le composant :
797
+ - **update:modelValue** : Émis lorsque la valeur change
798
+ - **change** : Émis lorsque la sélection change
799
+ `,
800
+ },
801
+ },
765
802
  sourceCode: [
766
803
  {
767
804
  name: 'Template',
768
805
  code: `
769
- <template>
770
- <SyCheckBoxGroup
771
- v-model="selected"
772
- :options="options"
773
- label="Options"
774
- :custom-warning-rules="warningRules"
775
- :custom-success-rules="successRules"
776
- :is-validate-on-blur="false"
777
- />
778
- </template>
779
- `,
806
+ <template>
807
+ <div>
808
+ <SyCheckBoxGroup
809
+ v-model="selected"
810
+ label="Sélectionnez une ou plusieurs options"
811
+ :options="options"
812
+ :multiple="multiple"
813
+ @update:model-value="onUpdate"
814
+ @change="onChange"
815
+ />
816
+ <div class="mt-4">
817
+ <p>Valeur sélectionnée : {{ selected }}</p>
818
+ <p>Dernier événement : {{ lastEvent }}</p>
819
+ </div>
820
+ </div>
821
+ </template>`,
780
822
  },
781
823
  {
782
824
  name: 'Script',
@@ -784,84 +826,222 @@ export const CustomRules: Story = {
784
826
  import { ref } from 'vue'
785
827
  import { SyCheckBoxGroup } from '@cnamts/synapse'
786
828
 
787
- const selected = ref<string | null>('A')
829
+ const selected = ref<string | null>(null)
830
+ const lastEvent = ref('')
831
+ const multiple = ref(true)
788
832
 
789
833
  const options = [
790
- { label: 'Option A', value: 'A' },
791
- { label: 'Option B', value: 'B' },
834
+ { label: 'Option A', value: 'a' },
835
+ { label: 'Option B', value: 'b' },
836
+ { label: 'Option C', value: 'c' },
792
837
  ]
793
838
 
794
- const warningRules = [
795
- {
796
- type: 'custom',
797
- options: {
798
- validate: (value: string | null) => {
799
- if (value !== 'A') {
800
- return 'Vous devez sélectionner l’option A'
801
- }
802
- return true
839
+ const onUpdate = (value: string | null) => {
840
+ lastEvent.value = \`update:modelValue: \${value}\`
841
+ console.log('update:modelValue', value)
842
+ }
843
+
844
+ const onChange = (value: string | null) => {
845
+ lastEvent.value = \`change: \${value}\`
846
+ console.log('change', value)
847
+ }
848
+ </script>`,
803
849
  },
804
- fieldIdentifier: 'option',
805
- },
850
+ ],
806
851
  },
807
- ]
808
852
 
809
- const successRules = [
810
- {
811
- type: 'custom',
812
- options: {
813
- validate: (value: string | null) => value === 'A',
814
- successMessage: 'Option A sélectionnée',
815
- fieldIdentifier: 'option',
853
+ render: args => ({
854
+ components: { SyCheckBoxGroup },
855
+ setup() {
856
+ const selected = ref<(string | number) | (string | number)[] | null>(null)
857
+ const lastEvent = ref('Aucun événement')
858
+ const multiple = ref(true)
859
+
860
+ const options = [
861
+ { label: 'Option A', value: 'a' },
862
+ { label: 'Option B', value: 'b' },
863
+ { label: 'Option C', value: 'c' },
864
+ ]
865
+
866
+ const onUpdate = (value: (string | number) | (string | number)[] | null) => {
867
+ lastEvent.value = `update:modelValue: ${JSON.stringify(value)}`
868
+ }
869
+
870
+ const onChange = (value: (string | number) | (string | number)[] | null) => {
871
+ lastEvent.value = `change: ${JSON.stringify(value)}`
872
+ }
873
+
874
+ return { args, selected, options, multiple, lastEvent, onUpdate, onChange }
875
+ },
876
+ template: `
877
+ <div>
878
+ <SyCheckBoxGroup
879
+ v-model="selected"
880
+ label="Sélectionnez une ou plusieurs options"
881
+ :options="options"
882
+ :multiple="multiple"
883
+ @update:model-value="onUpdate"
884
+ @change="onChange"
885
+ />
886
+ <div class="mt-4 pa-4 bg-grey-lighten-4 rounded">
887
+ <p><strong>Valeur sélectionnée :</strong> {{ selected || 'Aucune' }}</p>
888
+ <p><strong>Dernier événement :</strong> {{ lastEvent }}</p>
889
+ </div>
890
+ </div>
891
+ `,
892
+ }),
893
+ }
894
+
895
+ export const HelpText: Story = {
896
+ parameters: {
897
+ docs: {
898
+ description: {
899
+ story: `
900
+ ### Texte d'aide (helpText)
901
+ Affiche un texte d'aide sous les options du groupe. Il disparaît automatiquement lorsqu'un message de validation (erreur, avertissement, succès) est présent, et réapparaît en dessous une fois les messages affichés.
902
+ `,
903
+ },
816
904
  },
905
+ sourceCode: [
906
+ {
907
+ name: 'Template',
908
+ code: `
909
+ <SyCheckBoxGroup
910
+ v-model="value"
911
+ label="Choisissez une option"
912
+ :options="options"
913
+ required
914
+ help-text="Sélectionnez au moins une option dans la liste."
915
+ :is-validate-on-blur="false"
916
+ />`,
917
+ },
918
+ {
919
+ name: 'Script',
920
+ code: `<script setup lang="ts">
921
+ import { ref } from 'vue'
922
+ import { SyCheckBoxGroup } from '@cnamts/synapse'
923
+
924
+ const value = ref<string | null>(null)
925
+ const options = [
926
+ { label: 'Option A', value: 'a' },
927
+ { label: 'Option B', value: 'b' },
928
+ ]
929
+ </script>`,
930
+ },
931
+ ],
817
932
  },
933
+ args: {
934
+ label: 'Choisissez une option',
935
+ required: true,
936
+ helpText: 'Sélectionnez au moins une option dans la liste.',
937
+ options: [
938
+ { label: 'Option A', value: 'a' },
939
+ { label: 'Option B', value: 'b' },
940
+ ],
941
+ multiple: false,
942
+ isValidateOnBlur: false,
943
+ },
944
+ render: args => ({
945
+ components: { SyCheckBoxGroup, SyForm, VBtn },
946
+ setup() {
947
+ const value = ref<string | null>(null)
948
+ const onSubmit = (event: { isValid: boolean }) => {
949
+ if (event.isValid) {
950
+ alert('Formulaire valide !')
951
+ }
952
+ }
953
+ return { args, value, onSubmit }
954
+ },
955
+ template: `
956
+ <SyForm @submit="onSubmit">
957
+ <SyCheckBoxGroup v-model="value" v-bind="args" />
958
+ <VBtn type="submit" class="mt-4" color="primary">Valider</VBtn>
959
+ </SyForm>
960
+ `,
961
+ }),
962
+ }
963
+
964
+ export const HideDetails: Story = {
965
+ parameters: {
966
+ docs: {
967
+ description: {
968
+ story: `
969
+ ### hideDetails
970
+ Contrôle l'affichage de la zone de messages sous le champ.
971
+
972
+ | Valeur | Comportement |
973
+ |--------|-------------|
974
+ | \`'auto'\` (défaut) | Zone affichée uniquement si un message est présent |
975
+ | \`false\` | Zone toujours affichée (espace réservé même sans message) |
976
+ | \`true\` | Zone toujours masquée |
977
+ `,
978
+ },
979
+ },
980
+ sourceCode: [
981
+ {
982
+ name: 'Template',
983
+ code: `
984
+ <template>
985
+ <SyForm @submit="onSubmit">
986
+ <p>hide-details="auto" (défaut)</p>
987
+ <SyCheckBoxGroup v-model="selected" label="Option" :options="options" required hide-details="auto" />
988
+
989
+ <p>:hide-details="false" (espace toujours réservé)</p>
990
+ <SyCheckBoxGroup v-model="selected" label="Option" :options="options" required :hide-details="false" />
991
+
992
+ <p>:hide-details="true" (messages jamais affichés)</p>
993
+ <SyCheckBoxGroup v-model="selected" label="Option" :options="options" required :hide-details="true" />
994
+
995
+ <VBtn type="submit" color="primary" class="mt-4">Valider</VBtn>
996
+ </SyForm>
997
+ </template>`,
998
+ },
999
+ {
1000
+ name: 'Script',
1001
+ code: `<script setup lang="ts">
1002
+ import { ref } from 'vue'
1003
+ import { SyCheckBoxGroup, SyForm } from '@cnamts/synapse'
1004
+ import { VBtn } from 'vuetify/components'
1005
+
1006
+ const selected = ref<string | null>(null)
1007
+ const options = [
1008
+ { label: 'Option A', value: 'a' },
1009
+ { label: 'Option B', value: 'b' },
818
1010
  ]
1011
+ const onSubmit = (event: { isValid: boolean }) => {
1012
+ if (event.isValid) alert('Formulaire valide !')
1013
+ }
819
1014
  </script>`,
820
1015
  },
821
1016
  ],
822
1017
  },
823
1018
 
824
- render: args => ({
825
- components: { SyCheckBoxGroup },
1019
+ render: () => ({
1020
+ components: { SyCheckBoxGroup, SyForm, VBtn },
826
1021
  setup() {
827
- const selected = ref<string | null>('A')
1022
+ const selected = ref<string | null>(null)
828
1023
  const options = [
829
- { label: 'Option A', value: 'A' },
830
- { label: 'Option B', value: 'B' },
831
- ]
832
- const warningRules = [
833
- {
834
- type: 'custom',
835
- options: {
836
- validate: (value: string | null) => {
837
- if (value !== 'A') {
838
- return 'Vous devez sélectionner l’option A'
839
- }
840
- return true
841
- },
842
- },
843
- },
844
- ]
845
- const successRules = [
846
- {
847
- type: 'custom',
848
- options: {
849
- validate: (value: string | null) => value === 'A',
850
- successMessage: 'Option A sélectionnée',
851
- },
852
- },
1024
+ { label: 'Option A', value: 'a' },
1025
+ { label: 'Option B', value: 'b' },
853
1026
  ]
854
- return { args, selected, options, warningRules, successRules }
1027
+ const onSubmit = (event: { isValid: boolean }) => {
1028
+ if (event.isValid) alert('Formulaire valide !')
1029
+ }
1030
+ return { selected, options, onSubmit }
855
1031
  },
856
1032
  template: `
857
- <SyCheckBoxGroup
858
- v-model="selected"
859
- label="Options"
860
- :options="options"
861
- :custom-warning-rules="warningRules"
862
- :custom-success-rules="successRules"
863
- :is-validate-on-blur="false"
864
- />
1033
+ <SyForm @submit="onSubmit">
1034
+ <p class="mb-1 text-body-2">hide-details="auto" (défaut)</p>
1035
+ <SyCheckBoxGroup v-model="selected" label="Choisissez une option" :options="options" required hide-details="auto" />
1036
+
1037
+ <p class="mt-4 mb-1 text-body-2">:hide-details="false" (espace toujours réservé)</p>
1038
+ <SyCheckBoxGroup v-model="selected" label="Choisissez une option" :options="options" required :hide-details="false" />
1039
+
1040
+ <p class="mt-4 mb-1 text-body-2">:hide-details="true" (messages jamais affichés)</p>
1041
+ <SyCheckBoxGroup v-model="selected" label="Choisissez une option" :options="options" required :hide-details="true" />
1042
+
1043
+ <VBtn type="submit" class="mt-6" color="primary">Valider</VBtn>
1044
+ </SyForm>
865
1045
  `,
866
1046
  }),
867
1047
  }