@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
@@ -3,11 +3,14 @@
3
3
  import SyTextField from '@/components/Customs/SyTextField/SyTextField.vue'
4
4
  import DateTextInput from './DateTextInput.vue'
5
5
  import { VDatePicker } from 'vuetify/components'
6
- import { useFieldValidation } from '@/composables/rules/useFieldValidation'
7
- import type { RuleOptions } from '@/composables/rules/useFieldValidation'
6
+ import { useValidation } from '@/composables/validation/useValidation'
7
+ import { useDateFormat } from '@/composables/date/useDateFormat'
8
+ import { useDateInitialization, type DateValue, type DateInput } from '@/composables/date/useDateInitialization'
9
+ import { useDatePickerAccessibility } from '@/composables/date/useDatePickerAccessibility'
8
10
 
9
- type DateValue = string | [string, string] | null
10
- type DateInput = string | string[] | null | object
11
+ const { parseDate, formatDate } = useDateFormat()
12
+ const { initializeSelectedDates } = useDateInitialization()
13
+ const { updateAccessibility } = useDatePickerAccessibility()
11
14
 
12
15
  const props = withDefaults(defineProps<{
13
16
  modelValue?: DateInput
@@ -21,14 +24,18 @@
21
24
  displayIcon?: boolean
22
25
  displayAppendIcon?: boolean
23
26
  displayPrependIcon?: boolean
24
- customRules?: { type: string, options: RuleOptions }[]
25
- customWarningRules?: { type: string, options: RuleOptions }[]
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- mock Axios headers
28
+ customRules?: { type: string, options: any }[]
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- mock Axios headers
30
+ customWarningRules?: { type: string, options: any }[]
26
31
  isDisabled?: boolean
27
32
  noIcon?: boolean
28
33
  noCalendar?: boolean
29
34
  isOutlined?: boolean
30
35
  isReadOnly?: boolean
31
36
  width?: string
37
+ disableErrorHandling?: boolean
38
+ showSuccessMessages?: boolean
32
39
  }>(), {
33
40
  modelValue: undefined,
34
41
  placeholder: 'Sélectionner une date',
@@ -49,6 +56,8 @@
49
56
  isOutlined: true,
50
57
  isReadOnly: false,
51
58
  width: '100%',
59
+ disableErrorHandling: false,
60
+ showSuccessMessages: true,
52
61
  })
53
62
 
54
63
  const emit = defineEmits<{
@@ -58,94 +67,126 @@
58
67
  (e: 'blur'): void
59
68
  }>()
60
69
 
61
- // Fonction pour parser les dates selon le format spécifié
62
- const parseDate = (dateString: string, format: string = props.format): Date | null => {
63
- if (!dateString) return null
70
+ const selectedDates = ref<Date | Date[] | null>(
71
+ initializeSelectedDates(props.modelValue as DateInput | null, props.format, props.dateFormatReturn),
72
+ )
64
73
 
65
- // Créer un mapping des positions des éléments de date selon le format
66
- const separator = format.includes('/') ? '/' : format.includes('-') ? '-' : '.'
67
- const parts = format.split(separator)
68
- const dateParts = dateString.split(separator)
74
+ const isDatePickerVisible = ref(false)
75
+ const validation = useValidation({
76
+ showSuccessMessages: props.showSuccessMessages,
77
+ fieldIdentifier: 'Date',
78
+ customRules: props.customRules,
79
+ warningRules: props.customWarningRules,
80
+ disableErrorHandling: props.disableErrorHandling,
81
+ })
82
+ const { errors, warnings, successes, validateField, clearValidation } = validation
69
83
 
70
- if (parts.length !== dateParts.length) return null
84
+ const errorMessages = errors
85
+ const warningMessages = warnings
86
+ const successMessages = successes
87
+ const displayFormattedDate = ref('')
71
88
 
72
- let day = '', month = '', year = ''
89
+ const textInputValue = ref<string>('')
73
90
 
74
- // Extraire les valeurs selon leur position dans le format
75
- parts.forEach((part, index) => {
76
- const value = dateParts[index]
77
- if (part.includes('DD')) day = value
78
- else if (part.includes('MM')) month = value
79
- else if (part.includes('YYYY')) year = value
80
- else if (part.includes('YY')) year = '20' + value // Assumons que nous sommes au 21ème siècle
81
- })
91
+ // Variable pour éviter les mises à jour récursives
92
+ const isUpdatingFromInternal = ref(false)
82
93
 
83
- // Vérifier que nous avons toutes les parties nécessaires
84
- if (!day || !month || !year) return null
94
+ // Déclaration de la fonction validateDates avant son utilisation
95
+ const validateDates = (forceValidation = false) => {
96
+ if (props.noCalendar) {
97
+ // En mode no-calendar, on délègue la validation au DateTextInput
98
+ return
99
+ }
85
100
 
86
- const date = new Date(`${year}-${month}-${day}`)
87
- return isNaN(date.getTime()) ? null : date
88
- }
101
+ // Réinitialiser la validation
102
+ clearValidation()
89
103
 
90
- function initializeSelectedDates(
91
- modelValue: DateInput | null,
92
- ): Date | Date[] | null {
93
- if (!modelValue) return null
94
-
95
- if (Array.isArray(modelValue)) {
96
- if (modelValue.length >= 2) {
97
- const dates = [parseDate(modelValue[0]), parseDate(modelValue[1])]
98
- // Vérifie si l'une des dates est invalide
99
- if (dates.some(date => date === null)) {
100
- return []
101
- }
102
- // Vérifie si la première date est après la seconde
103
- if (dates[0] && dates[1] && dates[0] > dates[1]) {
104
- return []
105
- }
106
- // Filtrer les dates nulles et convertir en tableau de Date
107
- return dates.filter((date): date is Date => date !== null)
108
- }
109
- if (modelValue.length === 1) {
110
- const date = parseDate(modelValue[0])
111
- return date === null ? [] : [date]
104
+ // Si la gestion des erreurs est désactivée, on effectue la validation interne
105
+ // mais on n'ajoute pas les messages d'erreur
106
+ const shouldDisplayErrors = !props.disableErrorHandling
107
+
108
+ // Vérifier si le champ est requis et vide
109
+ if ((forceValidation || !isUpdatingFromInternal.value) && props.required && (!selectedDates.value || (Array.isArray(selectedDates.value) && selectedDates.value.length === 0))) {
110
+ if (shouldDisplayErrors) {
111
+ errors.value.push('La date est requise.')
112
112
  }
113
- return []
113
+ return
114
114
  }
115
115
 
116
- // Si modelValue est un objet, on le convertit en chaîne
117
- if (typeof modelValue === 'object') {
118
- return null
119
- }
116
+ if (!selectedDates.value) return
117
+
118
+ // Préparer les dates à valider
119
+ const datesToValidate = Array.isArray(selectedDates.value)
120
+ ? selectedDates.value
121
+ : [selectedDates.value]
122
+
123
+ // Valider chaque date
124
+ if (shouldDisplayErrors) {
125
+ datesToValidate.forEach((date) => {
126
+ validateField(
127
+ date,
128
+ props.customRules,
129
+ props.customWarningRules,
130
+ )
131
+ })
120
132
 
121
- const date = parseDate(modelValue)
122
- return date === null ? null : date
133
+ // Dédoublonner les messages (au cas où plusieurs dates auraient les mêmes messages)
134
+ errors.value = [...new Set(errors.value)]
135
+ warnings.value = [...new Set(warnings.value)]
136
+ successes.value = [...new Set(successes.value)]
137
+ }
123
138
  }
124
139
 
125
- // Utilisation de la fonction pour initialiser `selectedDates`
126
- const selectedDates = ref<Date | Date[] | null>(
127
- initializeSelectedDates(props.modelValue as DateInput | null),
128
- )
129
-
130
- const isDatePickerVisible = ref(false)
131
- const errorMessages = ref<string[]>([])
132
- const successMessages = ref<string[]>([])
133
- const warningMessages = ref<string[]>([])
134
- const displayFormattedDate = ref('')
140
+ // Fonction centralisée pour mettre à jour le modèle
141
+ const updateModel = (value: DateValue) => {
142
+ // Éviter les mises à jour inutiles
143
+ if (JSON.stringify(value) === JSON.stringify(props.modelValue)) return
135
144
 
136
- const textInputValue = ref<string>('')
145
+ try {
146
+ isUpdatingFromInternal.value = true
147
+ emit('update:modelValue', value)
148
+ }
149
+ finally {
150
+ // S'assurer que le flag est toujours réinitialisé
151
+ setTimeout(() => {
152
+ isUpdatingFromInternal.value = false
153
+ }, 0)
154
+ }
155
+ }
137
156
 
157
+ // Watcher pour mettre à jour le modèle lorsque les dates sélectionnées changent
138
158
  watch(selectedDates, (newValue) => {
159
+ // Valider les dates
139
160
  validateDates()
140
- if (props.displayRange) {
141
- if (Array.isArray(newValue) && newValue.length >= 2) {
142
- isDatePickerVisible.value = false
143
- emit('closed')
161
+
162
+ // Mettre à jour le modèle si nécessaire
163
+ if (newValue !== null) {
164
+ updateModel(formattedDate.value)
165
+
166
+ // Mettre à jour textInputValue pour le DateTextInput
167
+ try {
168
+ isUpdatingFromInternal.value = true
169
+ if (Array.isArray(newValue)) {
170
+ // Pour les plages de dates, utiliser la première date
171
+ if (newValue.length > 0) {
172
+ textInputValue.value = formatDate(newValue[0], props.format)
173
+ }
174
+ }
175
+ else {
176
+ // Pour une date unique
177
+ textInputValue.value = formatDate(newValue, props.format)
178
+ }
179
+ }
180
+ finally {
181
+ setTimeout(() => {
182
+ isUpdatingFromInternal.value = false
183
+ }, 0)
144
184
  }
145
185
  }
146
186
  else {
147
- isDatePickerVisible.value = false
148
- emit('closed')
187
+ updateModel(null)
188
+ // Réinitialiser textInputValue
189
+ textInputValue.value = ''
149
190
  }
150
191
  })
151
192
 
@@ -160,16 +201,6 @@
160
201
  'min-width': '100%',
161
202
  }))
162
203
 
163
- // Formate une date unique au format spécifié
164
- const formatDate = (date: Date, format: string): string => {
165
- if (!date) return ''
166
- const day = date.getDate().toString().padStart(2, '0')
167
- const month = (date.getMonth() + 1).toString().padStart(2, '0')
168
- const year = date.getFullYear().toString()
169
- const shortYear = year.slice(-2)
170
- return format.replace('YYYY', year).replace('YY', shortYear).replace('MM', month).replace('DD', day)
171
- }
172
-
173
204
  // Date(s) formatée(s) en chaîne de caractères pour la valeur de retour
174
205
  const formattedDate = computed<DateValue>(() => {
175
206
  if (!selectedDates.value) return ''
@@ -208,6 +239,9 @@
208
239
  }, { immediate: true })
209
240
 
210
241
  watch(textInputValue, (newValue) => {
242
+ // Éviter les mises à jour récursives
243
+ if (isUpdatingFromInternal.value) return
244
+
211
245
  // Parse la date avec le format d'affichage
212
246
  const date = parseDate(newValue, props.format)
213
247
  if (date) {
@@ -215,12 +249,50 @@
215
249
  const formattedValue = props.dateFormatReturn
216
250
  ? formatDate(date, props.dateFormatReturn)
217
251
  : formatDate(date, props.format)
218
- emit('update:modelValue', formattedValue)
252
+ updateModel(formattedValue)
253
+
254
+ // Mettre à jour selectedDates sans déclencher de watchers supplémentaires
255
+ try {
256
+ isUpdatingFromInternal.value = true
257
+ selectedDates.value = date
258
+ // Mettre à jour l'affichage formaté
259
+ displayFormattedDate.value = formatDate(date, props.format)
260
+ }
261
+ finally {
262
+ setTimeout(() => {
263
+ isUpdatingFromInternal.value = false
264
+ }, 0)
265
+ }
266
+ }
267
+ else if (newValue) {
268
+ // Même si la date n'est pas valide, conserver la valeur saisie
269
+ // pour éviter que la date ne disparaisse
270
+ updateModel(newValue)
271
+ // Mettre à jour l'affichage formaté pour qu'il corresponde à ce qui est saisi
272
+ try {
273
+ isUpdatingFromInternal.value = true
274
+ displayFormattedDate.value = newValue
275
+ }
276
+ finally {
277
+ setTimeout(() => {
278
+ isUpdatingFromInternal.value = false
279
+ }, 0)
280
+ }
219
281
  }
220
282
  else {
221
- emit('update:modelValue', newValue || null)
283
+ updateModel(null)
284
+ // Réinitialiser l'affichage formaté
285
+ try {
286
+ isUpdatingFromInternal.value = true
287
+ displayFormattedDate.value = ''
288
+ selectedDates.value = null
289
+ }
290
+ finally {
291
+ setTimeout(() => {
292
+ isUpdatingFromInternal.value = false
293
+ }, 0)
294
+ }
222
295
  }
223
- updateSelectedDates(newValue)
224
296
  })
225
297
 
226
298
  // Date(s) formatée(s) en chaîne de caractères pour l'affichage
@@ -240,16 +312,6 @@
240
312
  return formatDate(selectedDates.value, props.format)
241
313
  })
242
314
 
243
- // const validateDateValue = (value: DateValue): DateValue => {
244
- // if (Array.isArray(value)) {
245
- // if (value.length >= 2) {
246
- // return [value[0], value[1]] as [string, string]
247
- // }
248
- // return value[0] || ''
249
- // }
250
- // return value
251
- // }
252
-
253
315
  watch(displayFormattedDateComputed, (newValue) => {
254
316
  if (!props.noCalendar && newValue) {
255
317
  displayFormattedDate.value = newValue
@@ -259,7 +321,7 @@
259
321
  const updateSelectedDates = (input: DateValue) => {
260
322
  if (Array.isArray(input)) {
261
323
  const dates = input
262
- .map(date => (date ? parseDate(date) : null))
324
+ .map(date => (date ? parseDate(date, props.format) : null))
263
325
  .filter((date): date is Date => date !== null)
264
326
 
265
327
  if (dates.length === 0) {
@@ -271,7 +333,7 @@
271
333
  return
272
334
  }
273
335
 
274
- const date = input ? parseDate(input) : null
336
+ const date = input ? parseDate(input, props.format) : null
275
337
  selectedDates.value = date === null ? null : date
276
338
  }
277
339
 
@@ -284,8 +346,6 @@
284
346
 
285
347
  // Si on clique dans le conteneur du DatePicker, on ne fait rien
286
348
  if (container) return
287
-
288
- isDatePickerVisible.value = false
289
349
  emit('closed')
290
350
  // Déclencher la validation à la fermeture
291
351
  validateDates()
@@ -301,17 +361,14 @@
301
361
 
302
362
  onMounted(() => {
303
363
  document.addEventListener('click', handleClickOutside)
304
- if (props.modelValue) {
305
- validateDates()
306
- }
307
- if (selectedDates.value !== null) {
308
- validateDates()
309
- // Force format application on mount
310
- emit('update:modelValue', formattedDate.value)
311
- }
364
+
365
+ // Initialiser l'affichage formaté
312
366
  if (displayFormattedDateComputed.value) {
313
367
  displayFormattedDate.value = displayFormattedDateComputed.value
314
368
  }
369
+
370
+ // Valider les dates au montage
371
+ validateDates()
315
372
  })
316
373
 
317
374
  onBeforeUnmount(() => {
@@ -324,117 +381,62 @@
324
381
  if (props.noCalendar) {
325
382
  return dateTextInputRef.value?.validateOnSubmit()
326
383
  }
327
- validateDates()
328
- return errorMessages.value.length === 0
384
+ // Forcer la validation pour ignorer les conditions de validation interactive
385
+ validateDates(true)
386
+ // Retourner directement un booléen pour maintenir la compatibilité avec les tests existants
387
+ return errors.value.length === 0
329
388
  }
330
389
 
331
- defineExpose({
332
- validateOnSubmit,
333
- isDatePickerVisible,
334
- selectedDates,
335
- errorMessages,
336
- handleClickOutside,
337
- initializeSelectedDates,
338
- })
390
+ const showDatePicker = () => {
391
+ if (props.isDisabled || props.isReadOnly) return
339
392
 
340
- // les btns du date picker ne sont pas accessibles, on les rend accessibles
341
- watch(isDatePickerVisible, async (newValue) => {
342
- if (newValue) {
343
- await nextTick()
344
- const arrowDown = document.querySelector('.v-btn.v-btn--icon.v-theme--light.v-btn--density-comfortable.v-btn--size-default.v-btn--variant-text.v-date-picker-controls__mode-btn')
345
- const arrowLeftButtons = document.querySelectorAll('.v-btn.v-btn--icon.v-theme--light.v-btn--density-default.v-btn--size-default.v-btn--variant-text')
346
-
347
- if (arrowDown) {
348
- arrowDown.setAttribute('aria-label', 'Fleche vers le bas')
349
- }
350
-
351
- arrowLeftButtons.forEach((button, index) => {
352
- if (index === 0) {
353
- button.setAttribute('aria-label', 'Fleche vers la gauche')
354
- }
355
- else if (index === 1) {
356
- button.setAttribute('aria-label', 'Fleche vers la droite')
357
- }
358
- })
359
- }
360
- })
361
-
362
- const handlePrependIconClick = () => {
363
393
  isDatePickerVisible.value = true
364
- }
365
394
 
366
- const handleAppendIconClick = () => {
367
- isDatePickerVisible.value = true
395
+ // Mettre à jour l'accessibilité après l'ouverture du DatePicker
396
+ nextTick(() => {
397
+ updateAccessibility()
398
+ })
368
399
  }
369
400
 
370
- type Rule = { type: string, options: RuleOptions }
371
-
372
- const customRules = ref<Rule[]>(props.customRules || [])
373
- const customWarningRules = ref<Rule[]>(props.customWarningRules || [])
401
+ const openDatePicker = () => {
402
+ showDatePicker()
403
+ }
374
404
 
375
- const { generateRules } = useFieldValidation()
376
- const validationRules = generateRules(customRules.value)
377
- const warningValidationRules = generateRules(customWarningRules.value)
405
+ type ViewMode = 'month' | 'year' | 'months' | undefined
378
406
 
379
- const validateDates = () => {
380
- errorMessages.value = []
381
- successMessages.value = []
382
- warningMessages.value = []
407
+ // Variable pour suivre le mode d'affichage actuel du DatePicker
408
+ const currentViewMode = ref<ViewMode>(props.isBirthDate ? 'year' : 'month')
383
409
 
384
- if (props.noCalendar) {
385
- // En mode no-calendar, on délègue la validation au DateTextInput
386
- return
387
- }
410
+ // Fonction pour gérer le changement de mode d'affichage
411
+ const handleViewModeUpdate = (newMode: ViewMode) => {
412
+ currentViewMode.value = newMode
413
+ }
388
414
 
389
- const addMessages = (dates, rules) => {
390
- dates.forEach((date) => {
391
- rules.forEach((rule) => {
392
- const result = rule(date)
393
- if (result?.error) {
394
- errorMessages.value.push(result.error)
395
- errorMessages.value = [...new Set(errorMessages.value)]
396
- }
397
- else if (result?.warning) {
398
- warningMessages.value.push(result.warning)
399
- warningMessages.value = [...new Set(warningMessages.value)]
400
- }
401
- else if (result?.success) {
402
- successMessages.value.push(result.success)
403
- successMessages.value = [...new Set(successMessages.value)]
404
- }
405
- })
406
- })
415
+ // Fonction pour gérer la sélection de l'année quand isBirthDate est true
416
+ const handleYearUpdate = () => {
417
+ if (props.isBirthDate) {
418
+ // Après la sélection de l'année, passer automatiquement à la sélection du mois
419
+ currentViewMode.value = 'months'
407
420
  }
421
+ }
408
422
 
409
- const handleValidation = (dates) => {
410
- if (Array.isArray(dates) && dates.length > 1) {
411
- // Pour une plage, on ne vérifie que le premier et le dernier jour
412
- const [firstDate, ...rest] = dates
413
- const lastDate = rest[rest.length - 1]
414
- const datesToValidate = [firstDate, lastDate]
415
-
416
- // Validation des règles
417
- addMessages(datesToValidate, validationRules)
418
- addMessages(datesToValidate, warningValidationRules)
419
- }
420
- else {
421
- // Pour une date unique, on valide normalement
422
- const datesToValidate = Array.isArray(dates) ? dates : [dates]
423
- addMessages(datesToValidate, validationRules)
424
- addMessages(datesToValidate, warningValidationRules)
425
- }
423
+ // Fonction pour gérer la sélection du mois quand isBirthDate est true
424
+ const handleMonthUpdate = () => {
425
+ if (props.isBirthDate) {
426
+ // Après la sélection du mois, passer automatiquement à la sélection du jour
427
+ currentViewMode.value = undefined
426
428
  }
429
+ }
427
430
 
428
- if (props.required && (!selectedDates.value || (Array.isArray(selectedDates.value) && selectedDates.value.length === 0))) {
429
- errorMessages.value.push('La date est requise.')
431
+ watch(isDatePickerVisible, (isVisible) => {
432
+ if (!isVisible && props.isBirthDate) {
433
+ // Réinitialiser le mode d'affichage au type birthdate
434
+ currentViewMode.value = 'year'
430
435
  }
431
- else if (selectedDates.value) {
432
- handleValidation(Array.isArray(selectedDates.value) ? selectedDates.value : [selectedDates.value])
433
- }
434
- }
436
+ })
435
437
 
436
438
  const getIcon = () => {
437
- if (props.noCalendar) {
439
+ if (props.noCalendar || props.disableErrorHandling) {
438
440
  return
439
441
  }
440
442
  switch (true) {
@@ -449,17 +451,65 @@
449
451
  }
450
452
  }
451
453
 
452
- // Watch sur modelValue pour gérer les changements externes
453
- watch(() => props.modelValue, (newValue) => {
454
+ const syncFromModelValue = (newValue: DateInput | undefined) => {
454
455
  if (!newValue || newValue === '') {
455
456
  selectedDates.value = null
456
457
  textInputValue.value = ''
457
458
  displayFormattedDate.value = ''
459
+ validateDates()
460
+ return
458
461
  }
459
- else {
460
- selectedDates.value = initializeSelectedDates(newValue)
462
+
463
+ selectedDates.value = initializeSelectedDates(newValue, props.format, props.dateFormatReturn)
464
+
465
+ if (selectedDates.value) {
466
+ const firstDate = Array.isArray(selectedDates.value)
467
+ ? selectedDates.value[0]
468
+ : selectedDates.value
469
+
470
+ textInputValue.value = formatDate(firstDate, props.format)
471
+ displayFormattedDate.value = displayFormattedDateComputed.value || ''
472
+ }
473
+
474
+ validateDates()
475
+ }
476
+
477
+ watch(() => props.modelValue, (newValue) => {
478
+ if (isUpdatingFromInternal.value) {
479
+ if (props.displayRange) {
480
+ if (Array.isArray(newValue) && newValue.length >= 2) {
481
+ isDatePickerVisible.value = false
482
+ emit('closed')
483
+ }
484
+ }
485
+ else {
486
+ isDatePickerVisible.value = false
487
+ emit('closed')
488
+ }
489
+ return
490
+ }
491
+
492
+ try {
493
+ isUpdatingFromInternal.value = true
494
+ syncFromModelValue(newValue)
495
+ }
496
+ finally {
497
+ setTimeout(() => {
498
+ isUpdatingFromInternal.value = false
499
+ }, 0)
461
500
  }
462
501
  }, { immediate: true })
502
+
503
+ defineExpose({
504
+ validateOnSubmit,
505
+ isDatePickerVisible,
506
+ selectedDates,
507
+ errorMessages,
508
+ handleClickOutside,
509
+ initializeSelectedDates,
510
+ updateAccessibility,
511
+ openDatePicker,
512
+ })
463
513
  </script>
464
514
 
465
515
  <template>
@@ -486,6 +536,8 @@
486
536
  :display-append-icon="props.displayAppendIcon"
487
537
  :display-prepend-icon="props.displayPrependIcon"
488
538
  :no-icon="props.noIcon"
539
+ :disable-error-handling="props.disableErrorHandling"
540
+ :show-success-messages="props.showSuccessMessages"
489
541
  title="Date text input"
490
542
  @focus="emit('focus')"
491
543
  @blur="emit('blur')"
@@ -499,7 +551,7 @@
499
551
  :class="[getMessageClasses(), 'label-hidden-on-focus']"
500
552
  :error-messages="errorMessages"
501
553
  :warning-messages="warningMessages"
502
- :success-messages="successMessages"
554
+ :success-messages="props.showSuccessMessages ? successMessages : []"
503
555
  :is-disabled="props.isDisabled"
504
556
  :is-read-only="true"
505
557
  :label="props.placeholder"
@@ -507,37 +559,54 @@
507
559
  :prepend-icon="displayIcon && !displayAppendIcon ? 'calendar' : undefined"
508
560
  :variant-style="props.isOutlined ? 'outlined' : 'underlined'"
509
561
  color="primary"
562
+ :show-success-messages="props.showSuccessMessages"
510
563
  is-clearable
511
564
  title="Date Picker"
512
- @focus="isDatePickerVisible = true"
565
+ @focus="openDatePicker"
513
566
  @update:model-value="updateSelectedDates"
514
- @prepend-icon-click="handlePrependIconClick"
515
- @append-icon-click="handleAppendIconClick"
567
+ @prepend-icon-click="openDatePicker"
568
+ @append-icon-click="openDatePicker"
516
569
  />
517
570
  </template>
518
- <transition name="fade">
519
- <v-locale-provider locale="fr">
520
- <VDatePicker
521
- v-if="isDatePickerVisible && !props.noCalendar"
522
- v-model="selectedDates"
523
- :first-day-of-week="1"
524
- :multiple="props.displayRange ? 'range' : false"
525
- :show-adjacent-months="true"
526
- :show-week="props.showWeekNumber"
527
- :view-mode="props.isBirthDate ? 'year' : 'month'"
528
- color="primary"
529
- >
530
- <template #title>
531
- Sélectionnez une date
532
- </template>
533
- <template #header>
534
- <h3 class="mx-auto my-auto ml-5 mb-4">
535
- {{ todayInString }}
536
- </h3>
537
- </template>
538
- </VDatePicker>
539
- </v-locale-provider>
540
- </transition>
571
+ <div>
572
+ <VMenu
573
+ v-if="!props.noCalendar"
574
+ v-model="isDatePickerVisible"
575
+ activator="parent"
576
+ :min-width="0"
577
+ location="bottom"
578
+ :close-on-content-click="false"
579
+ :open-on-click="false"
580
+ transition="fade-transition"
581
+ attach="body"
582
+ :offset="[-20, 5]"
583
+ >
584
+ <transition name="fade">
585
+ <VDatePicker
586
+ v-if="isDatePickerVisible && !props.noCalendar"
587
+ v-model="selectedDates"
588
+ color="primary"
589
+ :first-day-of-week="1"
590
+ :multiple="props.displayRange ? 'range' : false"
591
+ :show-adjacent-months="true"
592
+ :show-week="props.showWeekNumber"
593
+ :view-mode="currentViewMode"
594
+ @update:view-mode="handleViewModeUpdate"
595
+ @update:year="handleYearUpdate"
596
+ @update:month="handleMonthUpdate"
597
+ >
598
+ <template #title>
599
+ Sélectionnez une date
600
+ </template>
601
+ <template #header>
602
+ <h3 class="mx-auto my-auto ml-5 mb-4">
603
+ {{ todayInString }}
604
+ </h3>
605
+ </template>
606
+ </VDatePicker>
607
+ </transition>
608
+ </VMenu>
609
+ </div>
541
610
  </div>
542
611
  </template>
543
612