@cnamts/synapse 0.0.11-alpha → 0.0.13-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 (315) hide show
  1. package/dist/design-system-v3.js +5394 -3813
  2. package/dist/design-system-v3.umd.cjs +1 -1
  3. package/dist/src/components/Amelipro/types/types.d.ts +38 -0
  4. package/dist/src/components/CookieBanner/CookieBanner.d.ts +1 -1
  5. package/dist/src/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
  6. package/dist/src/components/Customs/SyTextField/SyTextField.d.ts +31 -23
  7. package/dist/src/components/Customs/SyTextField/types.d.ts +1 -0
  8. package/dist/src/components/DatePicker/DatePicker.d.ts +105 -102
  9. package/dist/src/components/DatePicker/DateTextInput.d.ts +82 -74
  10. package/dist/src/components/ErrorPage/ErrorPage.d.ts +1 -1
  11. package/dist/src/components/FileList/FileList.d.ts +1 -0
  12. package/dist/src/components/FileList/UploadItem/UploadItem.d.ts +1 -1
  13. package/dist/src/components/FilterInline/AccessibiliteItems.d.ts +30 -0
  14. package/dist/src/components/FilterInline/constants/ExpertiseLevelEnum.d.ts +4 -0
  15. package/dist/src/components/FilterSideBar/AccessibiliteItems.d.ts +29 -0
  16. package/dist/src/components/FilterSideBar/FilterSideBar.d.ts +31 -0
  17. package/dist/src/components/FilterSideBar/constants/ExpertiseLevelEnum.d.ts +4 -0
  18. package/dist/src/components/FilterSideBar/locales.d.ts +7 -0
  19. package/dist/src/components/LangBtn/LangBtn.d.ts +2 -2
  20. package/dist/src/components/NirField/NirField.d.ts +952 -0
  21. package/dist/src/components/NotificationBar/NotificationBar.d.ts +6 -6
  22. package/dist/src/components/PasswordField/PasswordField.d.ts +42 -8
  23. package/dist/src/components/PeriodField/PeriodField.d.ts +259 -235
  24. package/dist/src/components/PhoneField/PhoneField.d.ts +33 -3
  25. package/dist/src/components/RatingPicker/EmotionPicker/EmotionPicker.d.ts +1 -1
  26. package/dist/src/components/RatingPicker/NumberPicker/NumberPicker.d.ts +1 -1
  27. package/dist/src/components/RatingPicker/StarsPicker/StarsPicker.d.ts +1 -1
  28. package/dist/src/components/UploadWorkflow/AccessibiliteItems.d.ts +29 -0
  29. package/dist/src/components/UploadWorkflow/config.d.ts +29 -0
  30. package/dist/src/components/UploadWorkflow/constants/ExpertiseLevelEnum.d.ts +4 -0
  31. package/dist/src/components/UploadWorkflow/locales.d.ts +7 -0
  32. package/dist/src/components/UploadWorkflow/types.d.ts +19 -0
  33. package/dist/src/components/UploadWorkflow/useFileList.d.ts +10 -0
  34. package/dist/src/components/UploadWorkflow/useFileUploadJourney.d.ts +9 -0
  35. package/dist/src/components/Usages/Usages.d.ts +10 -0
  36. package/dist/src/components/index.d.ts +5 -0
  37. package/dist/src/composables/date/tests/useDateFormat.spec.d.ts +1 -0
  38. package/dist/src/composables/date/tests/useDateInitialization.spec.d.ts +1 -0
  39. package/dist/src/composables/date/tests/useDatePickerAccessibility.spec.d.ts +1 -0
  40. package/dist/src/composables/date/useDateFormat.d.ts +26 -0
  41. package/dist/src/composables/date/useDateInitialization.d.ts +18 -0
  42. package/dist/src/composables/date/useDatePickerAccessibility.d.ts +8 -0
  43. package/dist/src/composables/rules/useFieldValidation.d.ts +1 -0
  44. package/dist/src/composables/useFilterable/useFilterable.d.ts +1 -1
  45. package/dist/src/composables/validation/tests/useValidation.spec.d.ts +1 -0
  46. package/dist/src/composables/validation/useValidation.d.ts +40 -0
  47. package/dist/src/designTokens/index.d.ts +3 -1
  48. package/dist/src/main.d.ts +1 -0
  49. package/dist/src/utils/formatDate/index.d.ts +3 -0
  50. package/dist/src/utils/formatDate/tests/formatDate.spec.d.ts +1 -0
  51. package/dist/src/utils/functions/validation/isDateAfter/index.d.ts +2 -0
  52. package/dist/src/utils/functions/validation/isDateAfter/tests/isDateAfter.spec.d.ts +1 -0
  53. package/dist/src/utils/functions/validation/isDateBefore/index.d.ts +2 -0
  54. package/dist/src/utils/functions/validation/isDateBefore/tests/isDateBefore.spec.d.ts +1 -0
  55. package/dist/src/utils/functions/validation/isDateInRange/index.d.ts +3 -0
  56. package/dist/src/utils/functions/validation/isDateInRange/tests/isDateInRange.spec.d.ts +1 -0
  57. package/dist/src/utils/functions/validation/isDateValid/index.d.ts +9 -0
  58. package/dist/src/utils/functions/validation/isDateValid/tests/isDateValid.spec.d.ts +1 -0
  59. package/dist/src/utils/functions/validation/isEmailValid/tests/isEmailValid.spec.d.ts +1 -0
  60. package/dist/src/utils/functions/validation/isWeekend/index.d.ts +3 -0
  61. package/dist/src/utils/functions/validation/isWeekend/tests/isWeekend.spec.d.ts +1 -0
  62. package/dist/src/utils/parseDate/index.d.ts +3 -0
  63. package/dist/src/utils/parseDate/tests/parseDate.spec.d.ts +1 -0
  64. package/dist/src/utils/rules/doMatchPattern/index.d.ts +3 -0
  65. package/dist/src/utils/rules/doMatchPattern/tests/matchPattern.spec.d.ts +1 -0
  66. package/dist/src/utils/rules/index.d.ts +11 -0
  67. package/dist/src/utils/rules/isDateValid/index.d.ts +4 -0
  68. package/dist/src/utils/rules/isDateValid/tests/isDateValid.spec.d.ts +1 -0
  69. package/dist/src/utils/rules/isExactLength/index.d.ts +3 -0
  70. package/dist/src/utils/rules/isExactLength/locales.d.ts +2 -0
  71. package/dist/src/utils/rules/isExactLength/tests/exactLength.spec.d.ts +1 -0
  72. package/dist/src/utils/rules/isMaxLength/index.d.ts +3 -0
  73. package/dist/src/utils/rules/isMaxLength/locales.d.ts +2 -0
  74. package/dist/src/utils/rules/isMaxLength/tests/isMaxLength.spec.d.ts +1 -0
  75. package/dist/src/utils/rules/isMinLength/index.d.ts +3 -0
  76. package/dist/src/utils/rules/isMinLength/locales.d.ts +2 -0
  77. package/dist/src/utils/rules/isMinLength/tests/isMinLength.spec.d.ts +1 -0
  78. package/dist/src/utils/rules/isNotAfterDate/index.d.ts +3 -0
  79. package/dist/src/utils/rules/isNotAfterDate/tests/isNotAfterDate.spec.d.ts +1 -0
  80. package/dist/src/utils/rules/isNotAfterToday/index.d.ts +4 -0
  81. package/dist/src/utils/rules/isNotAfterToday/locales.d.ts +2 -0
  82. package/dist/src/utils/rules/isNotAfterToday/tests/isNotAfterToday.spec.d.ts +1 -0
  83. package/dist/src/utils/rules/isNotBeforeDate/index.d.ts +3 -0
  84. package/dist/src/utils/rules/isNotBeforeDate/locales.d.ts +2 -0
  85. package/dist/src/utils/rules/isNotBeforeDate/tests/IsNotBeforeDate.spec.d.ts +1 -0
  86. package/dist/src/utils/rules/isNotBeforeToday/index.d.ts +4 -0
  87. package/dist/src/utils/rules/isNotBeforeToday/locales.d.ts +2 -0
  88. package/dist/src/utils/rules/isNotBeforeToday/tests/notBeforeToday.spec.d.ts +1 -0
  89. package/dist/src/utils/rules/isRequired/index.d.ts +4 -0
  90. package/dist/src/utils/rules/isRequired/locales.d.ts +2 -0
  91. package/dist/src/utils/rules/isRequired/tests/isRequred.spec.d.ts +1 -0
  92. package/dist/src/utils/rules/isValidEmail/index.d.ts +4 -0
  93. package/dist/src/utils/rules/isValidEmail/locales.d.ts +2 -0
  94. package/dist/src/utils/rules/isValidEmail/tests/isValidEmail.spec.d.ts +1 -0
  95. package/dist/src/vuetifyConfig.d.ts +81 -0
  96. package/dist/style.css +1 -1
  97. package/package.json +3 -1
  98. package/src/assets/_elevations.scss +89 -0
  99. package/src/assets/_fonts.scss +6 -0
  100. package/src/assets/_radius.scss +92 -0
  101. package/src/assets/_spacers.scss +149 -0
  102. package/src/assets/settings.scss +15 -3
  103. package/src/assets/tokens.scss +32 -29
  104. package/src/components/Amelipro/types/types.ts +40 -0
  105. package/src/components/ChipList/ChipList.stories.ts +26 -27
  106. package/src/components/ChipList/ChipList.vue +5 -1
  107. package/src/components/ChipList/config.ts +1 -0
  108. package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +2 -2
  109. package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +1 -1
  110. package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +1 -1
  111. package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +65 -0
  112. package/src/components/Customs/SyInputSelect/SyInputSelect.vue +13 -3
  113. package/src/components/Customs/SySelect/SySelect.mdx +1 -1
  114. package/src/components/Customs/SySelect/SySelect.stories.ts +88 -5
  115. package/src/components/Customs/SySelect/SySelect.vue +55 -14
  116. package/src/components/Customs/SySelect/tests/SySelect.spec.ts +135 -2
  117. package/src/components/Customs/SyTextField/SyTextField.mdx +2 -2
  118. package/src/components/Customs/SyTextField/SyTextField.stories.ts +809 -79
  119. package/src/components/Customs/SyTextField/SyTextField.vue +135 -104
  120. package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +190 -38
  121. package/src/components/Customs/SyTextField/types.d.ts +1 -0
  122. package/src/components/DatePicker/DatePicker.stories.ts +177 -5
  123. package/src/components/DatePicker/DatePicker.vue +302 -233
  124. package/src/components/DatePicker/DateTextInput.vue +101 -246
  125. package/src/components/DatePicker/tests/DatePicker.spec.ts +123 -60
  126. package/src/components/DatePicker/tests/DateTextInput.spec.ts +202 -6
  127. package/src/components/FileList/Accessibilite.stories.ts +1 -1
  128. package/src/components/FileList/AccessibiliteItems.ts +22 -0
  129. package/src/components/FileList/FileList.vue +2 -1
  130. package/src/components/FileList/UploadItem/UploadItem.vue +10 -0
  131. package/src/components/FileUpload/FileUpload.stories.ts +93 -7
  132. package/src/components/FileUpload/FileUpload.vue +1 -0
  133. package/src/components/FileUpload/tests/FileUpload.spec.ts +4 -4
  134. package/src/components/FilterInline/Accessibilite.mdx +14 -0
  135. package/src/components/FilterInline/Accessibilite.stories.ts +216 -0
  136. package/src/components/FilterInline/AccessibiliteItems.ts +132 -0
  137. package/src/components/FilterInline/FilterInline.mdx +180 -34
  138. package/src/components/FilterInline/FilterInline.stories.ts +363 -6
  139. package/src/components/FilterInline/constants/ExpertiseLevelEnum.ts +4 -0
  140. package/src/components/FilterSideBar/Accessibilite.mdx +14 -0
  141. package/src/components/FilterSideBar/Accessibilite.stories.ts +216 -0
  142. package/src/components/FilterSideBar/AccessibiliteItems.ts +153 -0
  143. package/src/components/FilterSideBar/FilterSideBar.mdx +237 -0
  144. package/src/components/FilterSideBar/FilterSideBar.stories.ts +798 -0
  145. package/src/components/FilterSideBar/FilterSideBar.vue +193 -0
  146. package/src/components/FilterSideBar/constants/ExpertiseLevelEnum.ts +4 -0
  147. package/src/components/FilterSideBar/locales.ts +8 -0
  148. package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +305 -0
  149. package/src/components/FilterSideBar/tests/__snapshots__/FilterSideBar.spec.ts.snap +39 -0
  150. package/src/components/HeaderBar/Usages.mdx +1 -1
  151. package/src/components/NirField/NirField.stories.ts +738 -29
  152. package/src/components/NirField/NirField.vue +401 -359
  153. package/src/components/NirField/examples//342/200/257dataset/342/200/257.md +12 -0
  154. package/src/components/NirField/tests/NirField.spec.ts +88 -52
  155. package/src/components/NirField/tests/config.spec.ts +65 -0
  156. package/src/components/NotificationBar/Accessibilite.stories.ts +4 -0
  157. package/src/components/NotificationBar/NotificationBar.mdx +2 -2
  158. package/src/components/NotificationBar/NotificationBar.stories.ts +66 -13
  159. package/src/components/NotificationBar/NotificationBar.vue +42 -114
  160. package/src/components/NotificationBar/tests/NotificationBar.spec.ts +28 -33
  161. package/src/components/NotificationBar/tests/__snapshots__/NotificationBar.spec.ts.snap +1 -1
  162. package/src/components/PaginatedTable/PaginatedTable.vue +6 -10
  163. package/src/components/PaginatedTable/tests/__snapshots__/PaginatedTable.spec.ts.snap +4 -4
  164. package/src/components/PasswordField/PasswordField.mdx +129 -47
  165. package/src/components/PasswordField/PasswordField.stories.ts +1111 -120
  166. package/src/components/PasswordField/PasswordField.vue +212 -99
  167. package/src/components/PasswordField/tests/PasswordField.spec.ts +138 -9
  168. package/src/components/PeriodField/PeriodField.stories.ts +214 -118
  169. package/src/components/PeriodField/PeriodField.vue +238 -190
  170. package/src/components/PeriodField/tests/PeriodField.spec.ts +146 -0
  171. package/src/components/PhoneField/PhoneField.stories.ts +170 -0
  172. package/src/components/PhoneField/PhoneField.vue +76 -17
  173. package/src/components/PhoneField/indicatifs.ts +1 -1
  174. package/src/components/PhoneField/tests/PhoneField.spec.ts +40 -0
  175. package/src/components/RatingPicker/RatingPicker.stories.ts +7 -7
  176. package/src/components/SearchListField/SearchListField.stories.ts +1 -1
  177. package/src/components/UploadWorkflow/Accessibilite.mdx +14 -0
  178. package/src/components/UploadWorkflow/Accessibilite.stories.ts +216 -0
  179. package/src/components/UploadWorkflow/AccessibiliteItems.ts +192 -0
  180. package/src/components/UploadWorkflow/UploadWorkflow.mdx +75 -0
  181. package/src/components/UploadWorkflow/UploadWorkflow.stories.ts +943 -0
  182. package/src/components/UploadWorkflow/UploadWorkflow.vue +230 -0
  183. package/src/components/UploadWorkflow/config.ts +29 -0
  184. package/src/components/UploadWorkflow/constants/ExpertiseLevelEnum.ts +4 -0
  185. package/src/components/UploadWorkflow/locales.ts +8 -0
  186. package/src/components/UploadWorkflow/tests/UploadWorkflow.spec.ts +257 -0
  187. package/src/components/UploadWorkflow/tests/__snapshots__/UploadWorkflow.spec.ts.snap +54 -0
  188. package/src/components/UploadWorkflow/types.ts +21 -0
  189. package/src/components/UploadWorkflow/useFileList.ts +84 -0
  190. package/src/components/UploadWorkflow/useFileUploadJourney.ts +18 -0
  191. package/src/components/Usages/tests/Usages.spec.ts +183 -0
  192. package/src/components/index.ts +5 -0
  193. package/src/composables/date/tests/useDateFormat.spec.ts +67 -0
  194. package/src/composables/date/tests/useDateInitialization.spec.ts +89 -0
  195. package/src/composables/date/tests/useDatePickerAccessibility.spec.ts +102 -0
  196. package/src/composables/date/useDateFormat.ts +94 -0
  197. package/src/composables/date/useDateInitialization.ts +92 -0
  198. package/src/composables/date/useDatePickerAccessibility.ts +78 -0
  199. package/src/composables/rules/tests/useFieldValidation.spec.ts +385 -4
  200. package/src/composables/rules/useFieldValidation.ts +5 -2
  201. package/src/composables/useFilterable/useFilterable.ts +5 -4
  202. package/src/composables/validation/tests/useValidation.spec.ts +154 -0
  203. package/src/composables/validation/useValidation.ts +180 -0
  204. package/src/designTokens/index.ts +4 -0
  205. package/src/main.ts +1 -0
  206. package/src/stories/Accessibilite/Aculturation/AuditDesignSystem.mdx +28 -0
  207. package/src/stories/Accessibilite/Aculturation/SensibilisationAccessibilite.mdx +2 -2
  208. package/src/stories/Accessibilite/Audit/RGAA.mdx +6 -6
  209. package/src/stories/Accessibilite/Introduction.mdx +2 -1
  210. package/src/stories/Accessibilite/KitDePreAudit/Echantillonnage.mdx +1 -1
  211. package/src/stories/Accessibilite/KitDePreAudit/Introduction.mdx +1 -1
  212. package/src/stories/Accessibilite/KitDePreAudit/Outils/Introduction.mdx +8 -11
  213. package/src/stories/Accessibilite/KitDePreAudit/Outils/LecteursDEcran.mdx +77 -0
  214. package/src/stories/Accessibilite/KitDePreAudit/Outils/Tanaguru.mdx +9 -3
  215. package/src/stories/Accessibilite/KitDePreAudit/Preaudit.mdx +2 -2
  216. package/src/stories/Demarrer/Accueil.mdx +1 -1
  217. package/src/stories/Demarrer/Introduction.stories.ts +3 -3
  218. package/src/stories/Demarrer/Releases.mdx +8 -0
  219. package/src/stories/Demarrer/Releases.stories.ts +66 -0
  220. package/src/stories/DesignTokens/Conteneurs.stories.ts +3 -3
  221. package/src/stories/DesignTokens/ThemePA.mdx +4 -30
  222. package/src/stories/GuideDuDev/LesBreackingChanges.mdx +36 -0
  223. package/src/stories/GuideDuDev/UtiliserLesRules.mdx +321 -78
  224. package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
  225. package/src/utils/formatDate/index.ts +6 -0
  226. package/src/utils/formatDate/tests/formatDate.spec.ts +18 -0
  227. package/src/utils/functions/validation/isDateAfter/index.ts +9 -0
  228. package/src/utils/functions/validation/isDateAfter/tests/isDateAfter.spec.ts +18 -0
  229. package/src/utils/functions/validation/isDateBefore/index.ts +9 -0
  230. package/src/utils/functions/validation/isDateBefore/tests/isDateBefore.spec.ts +23 -0
  231. package/src/utils/functions/validation/isDateInRange/index.ts +22 -0
  232. package/src/utils/functions/validation/isDateInRange/tests/isDateInRange.spec.ts +28 -0
  233. package/src/utils/functions/validation/isDateValid/index.ts +67 -0
  234. package/src/utils/functions/validation/isDateValid/tests/isDateValid.spec.ts +46 -0
  235. package/src/utils/functions/validation/isEmailValid/index.ts +9 -0
  236. package/src/utils/functions/validation/isWeekend/index.ts +10 -0
  237. package/src/utils/functions/validation/isWeekend/tests/isWeekend.spec.ts +16 -0
  238. package/src/utils/parseDate/index.ts +29 -0
  239. package/src/utils/parseDate/tests/parseDate.spec.ts +52 -0
  240. package/src/utils/rules/Rules.mdx +16 -0
  241. package/src/utils/rules/doMatchPattern/DoMachPattern.mdx +66 -0
  242. package/src/utils/rules/doMatchPattern/DoMatchPattern.stories.ts +106 -0
  243. package/src/utils/rules/doMatchPattern/index.ts +28 -0
  244. package/src/utils/rules/doMatchPattern/locales.ts +5 -0
  245. package/src/utils/rules/doMatchPattern/tests/matchPattern.spec.ts +38 -0
  246. package/src/utils/rules/index.ts +11 -0
  247. package/src/utils/rules/isDateValid/IsDateValid.mdx +87 -0
  248. package/src/utils/rules/isDateValid/IsDateValid.stories.ts +113 -0
  249. package/src/utils/rules/isDateValid/index.ts +32 -0
  250. package/src/utils/rules/isDateValid/locales.ts +10 -0
  251. package/src/utils/rules/isDateValid/tests/isDateValid.spec.ts +27 -0
  252. package/src/utils/rules/isExactLength/IsExactLenght.mdx +68 -0
  253. package/src/utils/rules/isExactLength/IsExactLength.stories.ts +151 -0
  254. package/src/utils/rules/{exactLength → isExactLength}/index.ts +2 -4
  255. package/src/utils/rules/isExactLength/tests/exactLength.spec.ts +48 -0
  256. package/src/utils/rules/isMaxLength/IsMaxLength.mdx +68 -0
  257. package/src/utils/rules/isMaxLength/IsMaxLength.stories.ts +152 -0
  258. package/src/utils/rules/isMaxLength/index.ts +30 -0
  259. package/src/utils/rules/isMaxLength/locales.ts +6 -0
  260. package/src/utils/rules/isMaxLength/tests/isMaxLength.spec.ts +42 -0
  261. package/src/utils/rules/isMinLength/IsMinLength.mdx +68 -0
  262. package/src/utils/rules/isMinLength/IsMinLength.stories.ts +152 -0
  263. package/src/utils/rules/isMinLength/index.ts +30 -0
  264. package/src/utils/rules/isMinLength/locales.ts +6 -0
  265. package/src/utils/rules/isMinLength/tests/isMinLength.spec.ts +42 -0
  266. package/src/utils/rules/isNotAfterDate/IsNotAfterDate.mdx +68 -0
  267. package/src/utils/rules/isNotAfterDate/IsNotAfterDate.stories.ts +109 -0
  268. package/src/utils/rules/isNotAfterDate/index.ts +25 -0
  269. package/src/utils/rules/isNotAfterDate/locales.ts +6 -0
  270. package/src/utils/rules/isNotAfterDate/tests/isNotAfterDate.spec.ts +25 -0
  271. package/src/utils/rules/isNotAfterToday/IsNotAfterToday.mdx +83 -0
  272. package/src/utils/rules/isNotAfterToday/IsNotAfterToday.stories.ts +110 -0
  273. package/src/utils/rules/isNotAfterToday/index.ts +28 -0
  274. package/src/utils/rules/isNotAfterToday/locales.ts +5 -0
  275. package/src/utils/rules/isNotAfterToday/tests/isNotAfterToday.spec.ts +30 -0
  276. package/src/utils/rules/isNotBeforeDate/IsNotBeforeDate.mdx +68 -0
  277. package/src/utils/rules/isNotBeforeDate/IsNotBeforeDate.stories.ts +114 -0
  278. package/src/utils/rules/isNotBeforeDate/index.ts +25 -0
  279. package/src/utils/rules/isNotBeforeDate/locales.ts +6 -0
  280. package/src/utils/rules/isNotBeforeDate/tests/IsNotBeforeDate.spec.ts +25 -0
  281. package/src/utils/rules/isNotBeforeToday/IsNotBeforeToday.mdx +83 -0
  282. package/src/utils/rules/isNotBeforeToday/IsNotBeforeToday.stories.ts +110 -0
  283. package/src/utils/rules/isNotBeforeToday/index.ts +28 -0
  284. package/src/utils/rules/isNotBeforeToday/locales.ts +5 -0
  285. package/src/utils/rules/isNotBeforeToday/tests/notBeforeToday.spec.ts +36 -0
  286. package/src/utils/rules/isRequired/IsRequired.mdx +81 -0
  287. package/src/utils/rules/isRequired/IsRequired.stories.ts +101 -0
  288. package/src/utils/rules/{required → isRequired}/index.ts +3 -3
  289. package/src/utils/rules/{required/tests/index.spec.ts → isRequired/tests/isRequred.spec.ts} +9 -9
  290. package/src/utils/rules/isValidEmail/IsValidEmail.mdx +81 -0
  291. package/src/utils/rules/isValidEmail/IsValidEmail.stories.ts +101 -0
  292. package/src/utils/rules/{email → isValidEmail}/index.ts +3 -5
  293. package/src/utils/rules/{email/tests/email.spec.ts → isValidEmail/tests/isValidEmail.spec.ts} +5 -5
  294. package/src/vuetifyConfig.ts +61 -0
  295. package/dist/src/utils/rules/email/index.d.ts +0 -4
  296. package/dist/src/utils/rules/exactLength/index.d.ts +0 -4
  297. package/dist/src/utils/rules/required/index.d.ts +0 -4
  298. package/dist/src/utils/rules/required/ruleMessageHelper.d.ts +0 -3
  299. package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +0 -58
  300. package/src/composables/useFilterable/__snapshots__/useFilterable.spec.ts.snap +0 -3
  301. package/src/utils/functions/isEmailValid/index.ts +0 -8
  302. package/src/utils/rules/required/ruleMessageHelper.ts +0 -14
  303. package/src/utils/rules/required/tests/rulesMessageHelper.spec.ts +0 -22
  304. /package/dist/src/{utils/functions/isEmailValid/tests/isEmailValid.spec.d.ts → components/FilterSideBar/tests/FilterSideBar.spec.d.ts} +0 -0
  305. /package/dist/src/{utils/rules/email/tests/email.spec.d.ts → components/NirField/tests/config.spec.d.ts} +0 -0
  306. /package/dist/src/{utils/rules/required/tests/index.spec.d.ts → components/UploadWorkflow/tests/UploadWorkflow.spec.d.ts} +0 -0
  307. /package/dist/src/{utils/rules/required/tests/rulesMessageHelper.spec.d.ts → components/Usages/tests/Usages.spec.d.ts} +0 -0
  308. /package/dist/src/utils/functions/{isEmailValid → validation/isEmailValid}/index.d.ts +0 -0
  309. /package/dist/src/utils/rules/{exactLength → doMatchPattern}/locales.d.ts +0 -0
  310. /package/dist/src/utils/rules/{email → isDateValid}/locales.d.ts +0 -0
  311. /package/dist/src/utils/rules/{required → isNotAfterDate}/locales.d.ts +0 -0
  312. /package/src/utils/functions/{isEmailValid → validation/isEmailValid}/tests/isEmailValid.spec.ts +0 -0
  313. /package/src/utils/rules/{exactLength → isExactLength}/locales.ts +0 -0
  314. /package/src/utils/rules/{required → isRequired}/locales.ts +0 -0
  315. /package/src/utils/rules/{email → isValidEmail}/locales.ts +0 -0
@@ -1,4 +1,6 @@
1
1
  import type { StoryObj, Meta } from '@storybook/vue3'
2
+ import { ref } from 'vue'
3
+ import { VBtn } from 'vuetify/components'
2
4
  import NirField from './NirField.vue'
3
5
 
4
6
  const meta: Meta<typeof NirField> = {
@@ -19,6 +21,7 @@ const meta: Meta<typeof NirField> = {
19
21
  table: {
20
22
  type: {
21
23
  summary: 'string',
24
+ detail: 'ex: 1840275123456 74',
22
25
  },
23
26
  },
24
27
  },
@@ -51,6 +54,20 @@ const meta: Meta<typeof NirField> = {
51
54
  },
52
55
  },
53
56
  },
57
+ nirTooltipPosition: {
58
+ description: 'Position de l\'infobulle pour le champ NIR, si le `nirTooltip` est renseigné',
59
+ control: 'select',
60
+ options: ['prepend', 'append'],
61
+ default: 'append',
62
+ table: {
63
+ type: {
64
+ summary: 'string',
65
+ },
66
+ defaultValue: {
67
+ summary: 'append',
68
+ },
69
+ },
70
+ },
54
71
  keyTooltip: {
55
72
  description: 'Infobulle pour le champ clé.',
56
73
  control: 'text',
@@ -60,24 +77,44 @@ const meta: Meta<typeof NirField> = {
60
77
  },
61
78
  },
62
79
  },
80
+ keyTooltipPosition: {
81
+ description: 'Position de l\'infobulle pour le champ clé, si le `keyTooltip` est renseigné',
82
+ control: 'select',
83
+ options: ['prepend', 'append'],
84
+ default: 'append',
85
+ table: {
86
+ type: {
87
+ summary: 'string',
88
+ },
89
+ defaultValue: {
90
+ summary: 'append',
91
+ },
92
+ },
93
+ },
63
94
  numberLabel: {
64
- description: 'Étiquette pour le champ numéro.',
95
+ description: 'Label pour le champ numéro.',
65
96
  control: 'text',
66
97
  default: 'Numéro de sécurité sociale',
67
98
  table: {
68
99
  type: {
69
100
  summary: 'string',
70
101
  },
102
+ defaultValue: {
103
+ summary: 'Numéro de sécurité sociale',
104
+ },
71
105
  },
72
106
  },
73
107
  keyLabel: {
74
- description: 'Étiquette pour le champ clé.',
108
+ description: 'Label pour le champ clé.',
75
109
  control: 'text',
76
110
  default: 'Clé',
77
111
  table: {
78
112
  type: {
79
113
  summary: 'string',
80
114
  },
115
+ defaultValue: {
116
+ summary: 'Clé',
117
+ },
81
118
  },
82
119
  },
83
120
  displayKey: {
@@ -118,6 +155,177 @@ const meta: Meta<typeof NirField> = {
118
155
  },
119
156
  },
120
157
  },
158
+ bgColor: {
159
+ description: 'Définit la couleur de fond du champ.',
160
+ control: 'color',
161
+ default: undefined,
162
+ table: {
163
+ type: {
164
+ summary: 'string',
165
+ },
166
+ },
167
+ },
168
+ isDisabled: {
169
+ description: 'Indique si le champ est désactivé.',
170
+ control: 'boolean',
171
+ default: false,
172
+ table: {
173
+ type: {
174
+ summary: 'boolean',
175
+ },
176
+ },
177
+ },
178
+ width: {
179
+ description: 'Définit la largeur du champ NIR. Accepte toute valeur CSS valide (%, px, rem, etc.). Le champ numéro occupera 80% de cette largeur et le champ clé 20%.',
180
+ control: 'text',
181
+ default: '100%',
182
+ table: {
183
+ type: {
184
+ summary: 'string',
185
+ },
186
+ defaultValue: {
187
+ summary: '100%',
188
+ },
189
+ },
190
+ },
191
+ // Propriétés natives de Vuetify
192
+ density: {
193
+ description: 'Contrôle la densité du champ.',
194
+ control: 'select',
195
+ options: ['default', 'comfortable', 'compact'],
196
+ default: 'default',
197
+ table: {
198
+ type: {
199
+ summary: 'string',
200
+ },
201
+ defaultValue: {
202
+ summary: 'default',
203
+ },
204
+ },
205
+ },
206
+ hideDetails: {
207
+ description: 'Masque les détails du champ (messages d\'erreur, compteur, etc.).',
208
+ control: 'boolean',
209
+ default: false,
210
+ table: {
211
+ type: {
212
+ summary: 'boolean | "auto"',
213
+ },
214
+ defaultValue: {
215
+ summary: 'false',
216
+ },
217
+ },
218
+ },
219
+ hideSpinButtons: {
220
+ description: 'Masque les boutons de spin pour les champs numériques.',
221
+ control: 'boolean',
222
+ default: false,
223
+ table: {
224
+ type: {
225
+ summary: 'boolean',
226
+ },
227
+ defaultValue: {
228
+ summary: 'false',
229
+ },
230
+ },
231
+ },
232
+ placeholder: {
233
+ description: 'Texte à afficher lorsque le champ est vide.',
234
+ control: 'text',
235
+ table: {
236
+ type: {
237
+ summary: 'string',
238
+ },
239
+ },
240
+ },
241
+ readonly: {
242
+ description: 'Rend le champ en lecture seule.',
243
+ control: 'boolean',
244
+ default: false,
245
+ table: {
246
+ type: {
247
+ summary: 'boolean',
248
+ },
249
+ defaultValue: {
250
+ summary: 'false',
251
+ },
252
+ },
253
+ },
254
+ variant: {
255
+ description: 'Style du champ.',
256
+ control: 'select',
257
+ options: ['filled', 'outlined', 'plain', 'underlined', 'solo'],
258
+ default: 'outlined',
259
+ table: {
260
+ type: {
261
+ summary: 'string',
262
+ },
263
+ defaultValue: {
264
+ summary: 'outlined',
265
+ },
266
+ },
267
+ },
268
+ clearable: {
269
+ description: 'Permet d\'afficher un bouton pour effacer le contenu.',
270
+ control: 'boolean',
271
+ default: false,
272
+ table: {
273
+ type: {
274
+ summary: 'boolean',
275
+ },
276
+ defaultValue: {
277
+ summary: 'false',
278
+ },
279
+ },
280
+ },
281
+ counter: {
282
+ description: 'Affiche un compteur de caractères.',
283
+ control: 'boolean',
284
+ default: false,
285
+ table: {
286
+ type: {
287
+ summary: 'boolean | number | string',
288
+ },
289
+ defaultValue: {
290
+ summary: 'false',
291
+ },
292
+ },
293
+ },
294
+ hint: {
295
+ description: 'Texte d\'aide affiché sous le champ.',
296
+ control: 'text',
297
+ table: {
298
+ type: {
299
+ summary: 'string',
300
+ },
301
+ },
302
+ },
303
+ persistentHint: {
304
+ description: 'Affiche toujours l\'indice, même lorsque le champ n\'est pas en focus.',
305
+ control: 'boolean',
306
+ default: false,
307
+ table: {
308
+ type: {
309
+ summary: 'boolean',
310
+ },
311
+ defaultValue: {
312
+ summary: 'false',
313
+ },
314
+ },
315
+ },
316
+ persistentPlaceholder: {
317
+ description: 'Affiche toujours le placeholder, même lorsque le champ est en focus.',
318
+ control: 'boolean',
319
+ default: false,
320
+ table: {
321
+ type: {
322
+ summary: 'boolean',
323
+ },
324
+ defaultValue: {
325
+ summary: 'false',
326
+ },
327
+ },
328
+ },
121
329
  },
122
330
  } satisfies Meta<typeof NirField>
123
331
 
@@ -171,32 +379,73 @@ export const Required: Story = {
171
379
  required: true,
172
380
  },
173
381
  parameters: {
174
- ...Default.parameters,
382
+ docs: {
383
+ description: {
384
+ story: `
385
+ ### Champs requis sans astérisque
386
+
387
+ Cette story montre des champs requis sans astérisque.
388
+ Pour afficher l'astérisque sur des champs requis, il faut activer la prop \`displayAsterisk\`.`,
389
+ },
390
+ },
175
391
  sourceCode: [
176
392
  {
177
393
  name: 'Template',
178
- code: `
179
- <template>
180
- <NirField
181
- v-model="value"
182
- :required="true"
183
- numberLabel="Numéro de sécurité sociale"
184
- keyLabel="Clé"
185
- :displayKey="true"
186
- />
187
- </template>
188
- `,
394
+ code: `<template>
395
+ <NirField
396
+ v-model="value"
397
+ required
398
+ />
399
+ </template>`,
189
400
  },
190
401
  {
191
402
  name: 'Script',
192
- code: `
193
- <script setup lang="ts">
194
- import NirField from '@cnamts/synapse'
195
- import { ref } from 'vue'
196
-
197
- const value = ref('')
198
- </script>
199
- `,
403
+ code: `<script setup lang="ts">
404
+ import { NirField } from '@cnamts/synapse'
405
+ import { ref } from 'vue'
406
+
407
+ const value = ref('')
408
+ </script>`,
409
+ },
410
+ ],
411
+ },
412
+ }
413
+
414
+ export const RequiredWithAsterisk: Story = {
415
+ args: {
416
+ ...Default.args,
417
+ displayAsterisk: true,
418
+ required: true,
419
+ },
420
+ parameters: {
421
+ docs: {
422
+ description: {
423
+ story: `
424
+ ### Champs non requis avec astérisque
425
+
426
+ Cette story montre que des champs non requis ne peuvent pas avoir d'astérisque.
427
+ Même si \`displayAsterisk\` est à \`true\`, l'astérisque ne s'affichera pas car les champs ne sont pas requis.`,
428
+ },
429
+ },
430
+ sourceCode: [
431
+ {
432
+ name: 'Template',
433
+ code: `<template>
434
+ <NirField
435
+ v-model="value"
436
+ display-asterisk
437
+ required
438
+ />
439
+ </template>`,
440
+ },
441
+ {
442
+ name: 'Script',
443
+ code: `<script setup lang="ts">
444
+ import { NirField } from '@cnamts/synapse'
445
+ import { ref } from 'vue'
446
+
447
+ const value = ref('')
448
+ </script>`,
200
449
  },
201
450
  ],
202
451
  },
@@ -276,6 +525,89 @@ export const WithSuccessMessages: Story = {
276
525
  },
277
526
  }
278
527
 
528
+ export const WithoutSuccessMessages: Story = {
529
+ parameters: {
530
+ docs: {
531
+ description: {
532
+ story: `
533
+ ### Messages de succès
534
+
535
+ Cette story illustre l'utilisation de la propriété \`showSuccessMessages\` qui permet de contrôler
536
+ l'affichage des messages de succès lors de la validation. Par défaut, cette propriété est à \`true\`.
537
+
538
+ Cela peut être utile pour réduire la verbosité de l'interface lorsque les messages de succès
539
+ ne sont pas nécessaires dans certains contextes.
540
+ `,
541
+ },
542
+ },
543
+ sourceCode: [
544
+ {
545
+ name: 'Template',
546
+ code: `<template>
547
+ <!-- Champ avec messages de succès (par défaut) -->
548
+ <NirField
549
+ v-model="value"
550
+ label="NIR avec messages de succès"
551
+ required
552
+ />
553
+
554
+ <!-- Champ sans messages de succès -->
555
+ <NirField
556
+ v-model="value"
557
+ label="NIR sans messages de succès"
558
+ required
559
+ :showSuccessMessages="false"
560
+ />
561
+ </template>`,
562
+ },
563
+ ],
564
+ },
565
+ render: () => ({
566
+ components: { NirField },
567
+ setup() {
568
+ const value1 = ref('184027512345674')
569
+ const value2 = ref('184027512345674')
570
+
571
+ return { value1, value2 }
572
+ },
573
+ template: `
574
+ <div>
575
+ <div>
576
+ <div>
577
+ <p class="text-subtitle-2 mb-2">Avec messages de succès</p>
578
+ <NirField
579
+ v-model="value1"
580
+ label="NIR avec messages de succès"
581
+ required
582
+ showSuccessMessages
583
+ />
584
+ </div>
585
+
586
+ <div>
587
+ <p class="text-subtitle-2 mb-2">Sans messages de succès</p>
588
+ <NirField
589
+ v-model="value2"
590
+ label="NIR sans messages de succès"
591
+ required
592
+ :showSuccessMessages="false"
593
+ />
594
+ </div>
595
+ </div>
596
+
597
+ <div class="mt-4 text-body-2">
598
+ <p>Observations :</p>
599
+ <ul>
600
+ <li>Les deux champs ont la même valeur valide</li>
601
+ <li>Le premier champ affiche un message de succès et un indicateur visuel vert au blur</li>
602
+ <li>Le second champ n'affiche pas de message de succès, au blur</li>
603
+ <li>Essayez de modifier les valeurs pour voir le comportement avec des données invalides puis valides</li>
604
+ </ul>
605
+ </div>
606
+ </div>
607
+ `,
608
+ }),
609
+ }
610
+
279
611
  export const CustomRules: Story = {
280
612
  args: {
281
613
  ...Default.args,
@@ -335,13 +667,22 @@ export const CustomRules: Story = {
335
667
  },
336
668
  }
337
669
 
338
- export const WithNumberTooltip: Story = {
670
+ export const WithNirTooltip: Story = {
339
671
  args: {
340
672
  ...Default.args,
341
- nirTooltip: 'Ceci est un tooltip pour le champs numéro de sécurité sociale',
673
+ nirTooltip: 'Ceci est un tooltip pour le champs numéro de sécurité sociale si le champs `nirTooltip` est saisi',
674
+ nirTooltipPosition: 'prepend',
342
675
  },
343
676
  parameters: {
344
- ...Default.parameters,
677
+ docs: {
678
+ description: {
679
+ story: `
680
+ ### Tooltip sur le champ NIR
681
+
682
+ Cette story montre l'affichage d'une infobulle sur le champ du numéro de sécurité sociale.
683
+ L'infobulle est positionnée avant le champ et s'affiche au survol de l'icône d'information.`,
684
+ },
685
+ },
345
686
  sourceCode: [
346
687
  {
347
688
  name: 'Template',
@@ -353,7 +694,8 @@ export const WithNumberTooltip: Story = {
353
694
  numberLabel="Numéro de sécurité sociale"
354
695
  keyLabel="Clé"
355
696
  :displayKey="true"
356
- nirTooltip="Ceci est un tooltip pour le champs numéro de sécurité sociale"
697
+ :nirTooltip="'Ceci est un tooltip pour le champs numéro de sécurité sociale'"
698
+ nirTooltipPosition="prepend"
357
699
  />
358
700
  </template>
359
701
  `,
@@ -377,9 +719,18 @@ export const WithKeyTooltip: Story = {
377
719
  args: {
378
720
  ...Default.args,
379
721
  keyTooltip: 'Ceci est un tooltip pour la clef du numéro de sécurité sociale',
722
+ keyTooltipPosition: 'append',
380
723
  },
381
724
  parameters: {
382
- ...Default.parameters,
725
+ docs: {
726
+ description: {
727
+ story: `
728
+ ### Tooltip sur le champ clé
729
+
730
+ Cette story montre l'affichage d'une infobulle sur le champ de la clé.
731
+ L'infobulle est positionnée après le champ et s'affiche au survol de l'icône d'information.`,
732
+ },
733
+ },
383
734
  sourceCode: [
384
735
  {
385
736
  name: 'Template',
@@ -391,7 +742,185 @@ export const WithKeyTooltip: Story = {
391
742
  numberLabel="Numéro de sécurité sociale"
392
743
  keyLabel="Clé"
393
744
  :displayKey="true"
394
- keyTooltip="Ceci est un tooltip pour la clef du numéro de sécurité sociale"
745
+ :keyTooltip="'Ceci est un tooltip pour la clef du numéro de sécurité sociale'"
746
+ keyTooltipPosition="append"
747
+ />
748
+ </template>
749
+ `,
750
+ },
751
+ {
752
+ name: 'Script',
753
+ code: `
754
+ <script setup lang="ts">
755
+ import NirField from '@cnamts/synapse'
756
+ import { ref } from 'vue'
757
+
758
+ const value = ref('')
759
+ </script>
760
+ `,
761
+ },
762
+ ],
763
+ },
764
+ }
765
+
766
+ export const WithWarnings: Story = {
767
+ args: {
768
+ ...Default.args,
769
+ showSuccessMessages: false,
770
+ customNumberWarningRules: [
771
+ {
772
+ type: 'custom',
773
+ options: {
774
+ message: 'Attention : ce NIR commence par 1 (homme)',
775
+ warningMessage: 'Attention : ce NIR commence par 1 (homme)',
776
+ validate: (value: string) => {
777
+ if (!value) return false
778
+ // On retourne true si la règle n'est PAS respectée (= warning)
779
+ return !value.startsWith('1')
780
+ },
781
+ isWarning: true,
782
+ },
783
+ },
784
+ {
785
+ type: 'custom',
786
+ options: {
787
+ message: 'Attention : ce NIR commence par 2 (femme)',
788
+ warningMessage: 'Attention : ce NIR commence par 2 (femme)',
789
+ validate: (value: string) => {
790
+ if (!value) return false
791
+ // On retourne true si la règle n'est PAS respectée (= warning)
792
+ return !value.startsWith('2')
793
+ },
794
+ isWarning: true,
795
+ },
796
+ },
797
+ ],
798
+ customKeyRules: [
799
+ {
800
+ type: 'custom',
801
+ options: {
802
+ message: 'La clé doit être comprise entre 01 et 97',
803
+ validate: (value: string) => {
804
+ if (!value) return true
805
+ const numValue = parseInt(value)
806
+ return numValue >= 1 && numValue <= 97
807
+ },
808
+ },
809
+ },
810
+ ],
811
+ customKeyWarningRules: [
812
+ {
813
+ type: 'custom',
814
+ options: {
815
+ message: 'Attention : la clé est supérieure à 50',
816
+ warningMessage: 'Attention : la clé est supérieure à 50',
817
+ validate: (value: string) => {
818
+ if (!value) return false
819
+ const numValue = parseInt(value)
820
+ // On retourne true si la règle n'est PAS respectée (= warning)
821
+ return !(numValue > 50)
822
+ },
823
+ isWarning: true,
824
+ },
825
+ },
826
+ ],
827
+ },
828
+ parameters: {
829
+ ...Default.parameters,
830
+ docs: {
831
+ description: {
832
+ story: `
833
+ ## Exemple d'utilisation des warnings
834
+
835
+ Le NirField peut afficher des warnings pour guider l'utilisateur sans bloquer la validation.
836
+
837
+ ### Warnings sur le NIR
838
+ - Un warning s'affiche si le NIR commence par 1 (homme)
839
+ - Un warning s'affiche si le NIR commence par 2 (femme)
840
+
841
+ ### Warnings sur la clé
842
+ - Un warning s'affiche si la clé est supérieure à 50
843
+ - Une erreur s'affiche si la clé n'est pas entre 01 et 97
844
+
845
+ ### Exemples de NIR valides avec warnings :
846
+ - \`1234567891011\` (warning : homme)
847
+ - \`2234567891011\` (warning : femme)
848
+ - Clé \`51\` (warning : clé > 50)
849
+
850
+ Les warnings sont affichés en jaune avec une icône d'avertissement mais ne bloquent pas la validation.
851
+ Les erreurs sont affichées en rouge et bloquent la validation.
852
+ `,
853
+ },
854
+ },
855
+ sourceCode: [
856
+ {
857
+ name: 'Template',
858
+ code: `
859
+ <template>
860
+ <NirField
861
+ v-model="value"
862
+ :required="false"
863
+ :show-success-messages="true"
864
+ numberLabel="Numéro de sécurité sociale"
865
+ keyLabel="Clé"
866
+ :display-key="true"
867
+ :customNumberWarningRules="[
868
+ {
869
+ type: 'custom',
870
+ options: {
871
+ message: 'Attention : ce NIR commence par 1 (homme)',
872
+ warningMessage: 'Attention : ce NIR commence par 1 (homme)',
873
+ validate: (value) => {
874
+ if (!value) return false
875
+ // On retourne true si la règle n'est PAS respectée (= warning)
876
+ return !value.startsWith('1')
877
+ },
878
+ isWarning: true,
879
+ },
880
+ },
881
+ {
882
+ type: 'custom',
883
+ options: {
884
+ message: 'Attention : ce NIR commence par 2 (femme)',
885
+ warningMessage: 'Attention : ce NIR commence par 2 (femme)',
886
+ validate: (value) => {
887
+ if (!value) return false
888
+ // On retourne true si la règle n'est PAS respectée (= warning)
889
+ return !value.startsWith('2')
890
+ },
891
+ isWarning: true,
892
+ },
893
+ },
894
+ ]"
895
+ :customKeyRules="[
896
+ {
897
+ type: 'custom',
898
+ options: {
899
+ message: 'La clé doit être comprise entre 01 et 97',
900
+ validate: (value) => {
901
+ if (!value) return true
902
+ const numValue = parseInt(value)
903
+ return numValue >= 1 && numValue <= 97
904
+ },
905
+ },
906
+ },
907
+ ]"
908
+ :customKeyWarningRules="[
909
+ {
910
+ type: 'custom',
911
+ options: {
912
+ message: 'Attention : la clé est supérieure à 50',
913
+ warningMessage: 'Attention : la clé est supérieure à 50',
914
+ validate: (value) => {
915
+ if (!value) return false
916
+ const numValue = parseInt(value)
917
+ // On retourne true si la règle n'est PAS respectée (= warning)
918
+ return !(numValue > 50)
919
+ },
920
+ isWarning: true,
921
+ },
922
+ },
923
+ ]"
395
924
  />
396
925
  </template>
397
926
  `,
@@ -400,7 +929,7 @@ export const WithKeyTooltip: Story = {
400
929
  name: 'Script',
401
930
  code: `
402
931
  <script setup lang="ts">
403
- import NirField from '@cnamts/synapse'
932
+ import { NirField } from '@cnamts/synapse'
404
933
  import { ref } from 'vue'
405
934
 
406
935
  const value = ref('')
@@ -410,3 +939,183 @@ export const WithKeyTooltip: Story = {
410
939
  ],
411
940
  },
412
941
  }
942
+
943
+ export const FormValidation: Story = {
944
+ parameters: {
945
+ docs: {
946
+ description: {
947
+ story: `
948
+ ### Validation de formulaire
949
+
950
+ Cette story montre l'utilisation du NirField dans un formulaire avec validation. Le formulaire :
951
+ - Requiert un NIR valide (13 chiffres)
952
+ - Requiert une clé valide (2 chiffres)
953
+ - Affiche des messages de succès quand les champs sont valides
954
+ - Affiche des messages d'erreur quand les champs sont invalides
955
+ `,
956
+ },
957
+ },
958
+ sourceCode: [
959
+ {
960
+ name: 'Template',
961
+ code: `<form @submit.prevent="onSubmit">
962
+ <NirField
963
+ v-model="value"
964
+ label="Numéro de sécurité sociale"
965
+ required
966
+ showSuccessMessages
967
+ ref="nirField"
968
+ />
969
+ <v-btn
970
+ type="submit"
971
+ color="primary"
972
+ class="mt-4"
973
+ >
974
+ Valider
975
+ </v-btn>
976
+ </form>`,
977
+ },
978
+ {
979
+ name: 'Script',
980
+ code: `<script setup lang="ts">
981
+ import { ref } from 'vue'
982
+ import { NirField } from '@cnamts/synapse'
983
+
984
+ const value = ref('')
985
+ const nirField = ref()
986
+
987
+ const onSubmit = async () => {
988
+ const isValid = await nirField.value?.validateOnSubmit()
989
+
990
+ if (isValid) {
991
+ alert('Formulaire soumis avec succès !')
992
+ }
993
+ else {
994
+ alert('Formulaire non soumis !')
995
+ }
996
+ }
997
+ </script>`,
998
+ },
999
+ ],
1000
+ },
1001
+ render: args => ({
1002
+ components: { NirField, VBtn },
1003
+ setup() {
1004
+ const value = ref('')
1005
+ const nirField = ref()
1006
+
1007
+ const onSubmit = async () => {
1008
+ const isValid = await nirField.value?.validateOnSubmit()
1009
+
1010
+ if (isValid) {
1011
+ alert('Formulaire soumis avec succès !')
1012
+ }
1013
+ else {
1014
+ alert('Formulaire non soumis !')
1015
+ }
1016
+ }
1017
+
1018
+ return { args, value, nirField, onSubmit }
1019
+ },
1020
+ template: `
1021
+ <form @submit.prevent="onSubmit">
1022
+ <NirField
1023
+ v-model="value"
1024
+ v-bind="args"
1025
+ label="Numéro de sécurité sociale"
1026
+ required
1027
+ showSuccessMessages
1028
+ ref="nirField"
1029
+ />
1030
+ <v-btn
1031
+ type="submit"
1032
+ color="primary"
1033
+ class="mt-4"
1034
+ >
1035
+ Valider
1036
+ </v-btn>
1037
+ </form>
1038
+ `,
1039
+ }),
1040
+ }
1041
+
1042
+ export const DisableErrorHandling: Story = {
1043
+ parameters: {
1044
+ docs: {
1045
+ description: {
1046
+ story: `
1047
+ ### Désactivation de la gestion des erreurs
1048
+
1049
+ Cette story illustre l'utilisation de la propriété \`disableErrorHandling\` qui permet de désactiver complètement
1050
+ la gestion et l'affichage des erreurs dans un champ, même si des règles de validation sont définies.
1051
+
1052
+ Cela peut être utile dans des cas particuliers où vous souhaitez définir des règles de validation
1053
+ mais gérer leur affichage différemment, ou utiliser la validation uniquement au niveau du formulaire parent.
1054
+ `,
1055
+ },
1056
+ },
1057
+ sourceCode: [
1058
+ {
1059
+ name: 'Template',
1060
+ code: `<template>
1061
+ <!-- Champ avec validation normale -->
1062
+ <NirField
1063
+ v-model="value"
1064
+ label="NIR avec validation"
1065
+ required
1066
+ />
1067
+
1068
+ <!-- Champ avec gestion d'erreurs désactivée -->
1069
+ <NirField
1070
+ v-model="value"
1071
+ label="NIR sans gestion d'erreurs"
1072
+ required
1073
+ disableErrorHandling
1074
+ />
1075
+ </template>`,
1076
+ },
1077
+ ],
1078
+ },
1079
+ render: () => ({
1080
+ components: { NirField },
1081
+ setup() {
1082
+ const value1 = ref('')
1083
+ const value2 = ref('')
1084
+
1085
+ return { value1, value2 }
1086
+ },
1087
+ template: `
1088
+ <div>
1089
+ <div>
1090
+ <div>
1091
+ <p class="text-subtitle-2 mb-2">Validation normale</p>
1092
+ <NirField
1093
+ v-model="value1"
1094
+ label="NIR avec validation"
1095
+ required
1096
+ />
1097
+ </div>
1098
+
1099
+ <div>
1100
+ <p class="text-subtitle-2 mb-2">Sans gestion d'erreurs</p>
1101
+ <NirField
1102
+ v-model="value2"
1103
+ label="NIR sans gestion d'erreurs"
1104
+ required
1105
+ disableErrorHandling
1106
+ />
1107
+ </div>
1108
+ </div>
1109
+
1110
+ <div class="mt-4 text-body-2">
1111
+ <p>Instructions :</p>
1112
+ <ol>
1113
+ <li class="ml-4">Cliquez dans un champ puis en dehors pour déclencher la validation</li>
1114
+ <li class="ml-4">Essayez de saisir des valeurs invalides (moins de 13 chiffres)</li>
1115
+ <li class="ml-4">Notez que le premier champ affiche des erreurs, mais pas le second</li>
1116
+ </ol>
1117
+ </div>
1118
+ </div>
1119
+ `,
1120
+ }),
1121
+ }