@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.
- package/dist/design-system-v3.js +5394 -3813
- package/dist/design-system-v3.umd.cjs +1 -1
- package/dist/src/components/Amelipro/types/types.d.ts +38 -0
- package/dist/src/components/CookieBanner/CookieBanner.d.ts +1 -1
- package/dist/src/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
- package/dist/src/components/Customs/SyTextField/SyTextField.d.ts +31 -23
- package/dist/src/components/Customs/SyTextField/types.d.ts +1 -0
- package/dist/src/components/DatePicker/DatePicker.d.ts +105 -102
- package/dist/src/components/DatePicker/DateTextInput.d.ts +82 -74
- package/dist/src/components/ErrorPage/ErrorPage.d.ts +1 -1
- package/dist/src/components/FileList/FileList.d.ts +1 -0
- package/dist/src/components/FileList/UploadItem/UploadItem.d.ts +1 -1
- package/dist/src/components/FilterInline/AccessibiliteItems.d.ts +30 -0
- package/dist/src/components/FilterInline/constants/ExpertiseLevelEnum.d.ts +4 -0
- package/dist/src/components/FilterSideBar/AccessibiliteItems.d.ts +29 -0
- package/dist/src/components/FilterSideBar/FilterSideBar.d.ts +31 -0
- package/dist/src/components/FilterSideBar/constants/ExpertiseLevelEnum.d.ts +4 -0
- package/dist/src/components/FilterSideBar/locales.d.ts +7 -0
- package/dist/src/components/LangBtn/LangBtn.d.ts +2 -2
- package/dist/src/components/NirField/NirField.d.ts +952 -0
- package/dist/src/components/NotificationBar/NotificationBar.d.ts +6 -6
- package/dist/src/components/PasswordField/PasswordField.d.ts +42 -8
- package/dist/src/components/PeriodField/PeriodField.d.ts +259 -235
- package/dist/src/components/PhoneField/PhoneField.d.ts +33 -3
- package/dist/src/components/RatingPicker/EmotionPicker/EmotionPicker.d.ts +1 -1
- package/dist/src/components/RatingPicker/NumberPicker/NumberPicker.d.ts +1 -1
- package/dist/src/components/RatingPicker/StarsPicker/StarsPicker.d.ts +1 -1
- package/dist/src/components/UploadWorkflow/AccessibiliteItems.d.ts +29 -0
- package/dist/src/components/UploadWorkflow/config.d.ts +29 -0
- package/dist/src/components/UploadWorkflow/constants/ExpertiseLevelEnum.d.ts +4 -0
- package/dist/src/components/UploadWorkflow/locales.d.ts +7 -0
- package/dist/src/components/UploadWorkflow/types.d.ts +19 -0
- package/dist/src/components/UploadWorkflow/useFileList.d.ts +10 -0
- package/dist/src/components/UploadWorkflow/useFileUploadJourney.d.ts +9 -0
- package/dist/src/components/Usages/Usages.d.ts +10 -0
- package/dist/src/components/index.d.ts +5 -0
- package/dist/src/composables/date/tests/useDateFormat.spec.d.ts +1 -0
- package/dist/src/composables/date/tests/useDateInitialization.spec.d.ts +1 -0
- package/dist/src/composables/date/tests/useDatePickerAccessibility.spec.d.ts +1 -0
- package/dist/src/composables/date/useDateFormat.d.ts +26 -0
- package/dist/src/composables/date/useDateInitialization.d.ts +18 -0
- package/dist/src/composables/date/useDatePickerAccessibility.d.ts +8 -0
- package/dist/src/composables/rules/useFieldValidation.d.ts +1 -0
- package/dist/src/composables/useFilterable/useFilterable.d.ts +1 -1
- package/dist/src/composables/validation/tests/useValidation.spec.d.ts +1 -0
- package/dist/src/composables/validation/useValidation.d.ts +40 -0
- package/dist/src/designTokens/index.d.ts +3 -1
- package/dist/src/main.d.ts +1 -0
- package/dist/src/utils/formatDate/index.d.ts +3 -0
- package/dist/src/utils/formatDate/tests/formatDate.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isDateAfter/index.d.ts +2 -0
- package/dist/src/utils/functions/validation/isDateAfter/tests/isDateAfter.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isDateBefore/index.d.ts +2 -0
- package/dist/src/utils/functions/validation/isDateBefore/tests/isDateBefore.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isDateInRange/index.d.ts +3 -0
- package/dist/src/utils/functions/validation/isDateInRange/tests/isDateInRange.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isDateValid/index.d.ts +9 -0
- package/dist/src/utils/functions/validation/isDateValid/tests/isDateValid.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isEmailValid/tests/isEmailValid.spec.d.ts +1 -0
- package/dist/src/utils/functions/validation/isWeekend/index.d.ts +3 -0
- package/dist/src/utils/functions/validation/isWeekend/tests/isWeekend.spec.d.ts +1 -0
- package/dist/src/utils/parseDate/index.d.ts +3 -0
- package/dist/src/utils/parseDate/tests/parseDate.spec.d.ts +1 -0
- package/dist/src/utils/rules/doMatchPattern/index.d.ts +3 -0
- package/dist/src/utils/rules/doMatchPattern/tests/matchPattern.spec.d.ts +1 -0
- package/dist/src/utils/rules/index.d.ts +11 -0
- package/dist/src/utils/rules/isDateValid/index.d.ts +4 -0
- package/dist/src/utils/rules/isDateValid/tests/isDateValid.spec.d.ts +1 -0
- package/dist/src/utils/rules/isExactLength/index.d.ts +3 -0
- package/dist/src/utils/rules/isExactLength/locales.d.ts +2 -0
- package/dist/src/utils/rules/isExactLength/tests/exactLength.spec.d.ts +1 -0
- package/dist/src/utils/rules/isMaxLength/index.d.ts +3 -0
- package/dist/src/utils/rules/isMaxLength/locales.d.ts +2 -0
- package/dist/src/utils/rules/isMaxLength/tests/isMaxLength.spec.d.ts +1 -0
- package/dist/src/utils/rules/isMinLength/index.d.ts +3 -0
- package/dist/src/utils/rules/isMinLength/locales.d.ts +2 -0
- package/dist/src/utils/rules/isMinLength/tests/isMinLength.spec.d.ts +1 -0
- package/dist/src/utils/rules/isNotAfterDate/index.d.ts +3 -0
- package/dist/src/utils/rules/isNotAfterDate/tests/isNotAfterDate.spec.d.ts +1 -0
- package/dist/src/utils/rules/isNotAfterToday/index.d.ts +4 -0
- package/dist/src/utils/rules/isNotAfterToday/locales.d.ts +2 -0
- package/dist/src/utils/rules/isNotAfterToday/tests/isNotAfterToday.spec.d.ts +1 -0
- package/dist/src/utils/rules/isNotBeforeDate/index.d.ts +3 -0
- package/dist/src/utils/rules/isNotBeforeDate/locales.d.ts +2 -0
- package/dist/src/utils/rules/isNotBeforeDate/tests/IsNotBeforeDate.spec.d.ts +1 -0
- package/dist/src/utils/rules/isNotBeforeToday/index.d.ts +4 -0
- package/dist/src/utils/rules/isNotBeforeToday/locales.d.ts +2 -0
- package/dist/src/utils/rules/isNotBeforeToday/tests/notBeforeToday.spec.d.ts +1 -0
- package/dist/src/utils/rules/isRequired/index.d.ts +4 -0
- package/dist/src/utils/rules/isRequired/locales.d.ts +2 -0
- package/dist/src/utils/rules/isRequired/tests/isRequred.spec.d.ts +1 -0
- package/dist/src/utils/rules/isValidEmail/index.d.ts +4 -0
- package/dist/src/utils/rules/isValidEmail/locales.d.ts +2 -0
- package/dist/src/utils/rules/isValidEmail/tests/isValidEmail.spec.d.ts +1 -0
- package/dist/src/vuetifyConfig.d.ts +81 -0
- package/dist/style.css +1 -1
- package/package.json +3 -1
- package/src/assets/_elevations.scss +89 -0
- package/src/assets/_fonts.scss +6 -0
- package/src/assets/_radius.scss +92 -0
- package/src/assets/_spacers.scss +149 -0
- package/src/assets/settings.scss +15 -3
- package/src/assets/tokens.scss +32 -29
- package/src/components/Amelipro/types/types.ts +40 -0
- package/src/components/ChipList/ChipList.stories.ts +26 -27
- package/src/components/ChipList/ChipList.vue +5 -1
- package/src/components/ChipList/config.ts +1 -0
- package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +2 -2
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +1 -1
- package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +1 -1
- package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +65 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +13 -3
- package/src/components/Customs/SySelect/SySelect.mdx +1 -1
- package/src/components/Customs/SySelect/SySelect.stories.ts +88 -5
- package/src/components/Customs/SySelect/SySelect.vue +55 -14
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +135 -2
- package/src/components/Customs/SyTextField/SyTextField.mdx +2 -2
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +809 -79
- package/src/components/Customs/SyTextField/SyTextField.vue +135 -104
- package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +190 -38
- package/src/components/Customs/SyTextField/types.d.ts +1 -0
- package/src/components/DatePicker/DatePicker.stories.ts +177 -5
- package/src/components/DatePicker/DatePicker.vue +302 -233
- package/src/components/DatePicker/DateTextInput.vue +101 -246
- package/src/components/DatePicker/tests/DatePicker.spec.ts +123 -60
- package/src/components/DatePicker/tests/DateTextInput.spec.ts +202 -6
- package/src/components/FileList/Accessibilite.stories.ts +1 -1
- package/src/components/FileList/AccessibiliteItems.ts +22 -0
- package/src/components/FileList/FileList.vue +2 -1
- package/src/components/FileList/UploadItem/UploadItem.vue +10 -0
- package/src/components/FileUpload/FileUpload.stories.ts +93 -7
- package/src/components/FileUpload/FileUpload.vue +1 -0
- package/src/components/FileUpload/tests/FileUpload.spec.ts +4 -4
- package/src/components/FilterInline/Accessibilite.mdx +14 -0
- package/src/components/FilterInline/Accessibilite.stories.ts +216 -0
- package/src/components/FilterInline/AccessibiliteItems.ts +132 -0
- package/src/components/FilterInline/FilterInline.mdx +180 -34
- package/src/components/FilterInline/FilterInline.stories.ts +363 -6
- package/src/components/FilterInline/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/FilterSideBar/Accessibilite.mdx +14 -0
- package/src/components/FilterSideBar/Accessibilite.stories.ts +216 -0
- package/src/components/FilterSideBar/AccessibiliteItems.ts +153 -0
- package/src/components/FilterSideBar/FilterSideBar.mdx +237 -0
- package/src/components/FilterSideBar/FilterSideBar.stories.ts +798 -0
- package/src/components/FilterSideBar/FilterSideBar.vue +193 -0
- package/src/components/FilterSideBar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/FilterSideBar/locales.ts +8 -0
- package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +305 -0
- package/src/components/FilterSideBar/tests/__snapshots__/FilterSideBar.spec.ts.snap +39 -0
- package/src/components/HeaderBar/Usages.mdx +1 -1
- package/src/components/NirField/NirField.stories.ts +738 -29
- package/src/components/NirField/NirField.vue +401 -359
- package/src/components/NirField/examples//342/200/257dataset/342/200/257.md +12 -0
- package/src/components/NirField/tests/NirField.spec.ts +88 -52
- package/src/components/NirField/tests/config.spec.ts +65 -0
- package/src/components/NotificationBar/Accessibilite.stories.ts +4 -0
- package/src/components/NotificationBar/NotificationBar.mdx +2 -2
- package/src/components/NotificationBar/NotificationBar.stories.ts +66 -13
- package/src/components/NotificationBar/NotificationBar.vue +42 -114
- package/src/components/NotificationBar/tests/NotificationBar.spec.ts +28 -33
- package/src/components/NotificationBar/tests/__snapshots__/NotificationBar.spec.ts.snap +1 -1
- package/src/components/PaginatedTable/PaginatedTable.vue +6 -10
- package/src/components/PaginatedTable/tests/__snapshots__/PaginatedTable.spec.ts.snap +4 -4
- package/src/components/PasswordField/PasswordField.mdx +129 -47
- package/src/components/PasswordField/PasswordField.stories.ts +1111 -120
- package/src/components/PasswordField/PasswordField.vue +212 -99
- package/src/components/PasswordField/tests/PasswordField.spec.ts +138 -9
- package/src/components/PeriodField/PeriodField.stories.ts +214 -118
- package/src/components/PeriodField/PeriodField.vue +238 -190
- package/src/components/PeriodField/tests/PeriodField.spec.ts +146 -0
- package/src/components/PhoneField/PhoneField.stories.ts +170 -0
- package/src/components/PhoneField/PhoneField.vue +76 -17
- package/src/components/PhoneField/indicatifs.ts +1 -1
- package/src/components/PhoneField/tests/PhoneField.spec.ts +40 -0
- package/src/components/RatingPicker/RatingPicker.stories.ts +7 -7
- package/src/components/SearchListField/SearchListField.stories.ts +1 -1
- package/src/components/UploadWorkflow/Accessibilite.mdx +14 -0
- package/src/components/UploadWorkflow/Accessibilite.stories.ts +216 -0
- package/src/components/UploadWorkflow/AccessibiliteItems.ts +192 -0
- package/src/components/UploadWorkflow/UploadWorkflow.mdx +75 -0
- package/src/components/UploadWorkflow/UploadWorkflow.stories.ts +943 -0
- package/src/components/UploadWorkflow/UploadWorkflow.vue +230 -0
- package/src/components/UploadWorkflow/config.ts +29 -0
- package/src/components/UploadWorkflow/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/UploadWorkflow/locales.ts +8 -0
- package/src/components/UploadWorkflow/tests/UploadWorkflow.spec.ts +257 -0
- package/src/components/UploadWorkflow/tests/__snapshots__/UploadWorkflow.spec.ts.snap +54 -0
- package/src/components/UploadWorkflow/types.ts +21 -0
- package/src/components/UploadWorkflow/useFileList.ts +84 -0
- package/src/components/UploadWorkflow/useFileUploadJourney.ts +18 -0
- package/src/components/Usages/tests/Usages.spec.ts +183 -0
- package/src/components/index.ts +5 -0
- package/src/composables/date/tests/useDateFormat.spec.ts +67 -0
- package/src/composables/date/tests/useDateInitialization.spec.ts +89 -0
- package/src/composables/date/tests/useDatePickerAccessibility.spec.ts +102 -0
- package/src/composables/date/useDateFormat.ts +94 -0
- package/src/composables/date/useDateInitialization.ts +92 -0
- package/src/composables/date/useDatePickerAccessibility.ts +78 -0
- package/src/composables/rules/tests/useFieldValidation.spec.ts +385 -4
- package/src/composables/rules/useFieldValidation.ts +5 -2
- package/src/composables/useFilterable/useFilterable.ts +5 -4
- package/src/composables/validation/tests/useValidation.spec.ts +154 -0
- package/src/composables/validation/useValidation.ts +180 -0
- package/src/designTokens/index.ts +4 -0
- package/src/main.ts +1 -0
- package/src/stories/Accessibilite/Aculturation/AuditDesignSystem.mdx +28 -0
- package/src/stories/Accessibilite/Aculturation/SensibilisationAccessibilite.mdx +2 -2
- package/src/stories/Accessibilite/Audit/RGAA.mdx +6 -6
- package/src/stories/Accessibilite/Introduction.mdx +2 -1
- package/src/stories/Accessibilite/KitDePreAudit/Echantillonnage.mdx +1 -1
- package/src/stories/Accessibilite/KitDePreAudit/Introduction.mdx +1 -1
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Introduction.mdx +8 -11
- package/src/stories/Accessibilite/KitDePreAudit/Outils/LecteursDEcran.mdx +77 -0
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Tanaguru.mdx +9 -3
- package/src/stories/Accessibilite/KitDePreAudit/Preaudit.mdx +2 -2
- package/src/stories/Demarrer/Accueil.mdx +1 -1
- package/src/stories/Demarrer/Introduction.stories.ts +3 -3
- package/src/stories/Demarrer/Releases.mdx +8 -0
- package/src/stories/Demarrer/Releases.stories.ts +66 -0
- package/src/stories/DesignTokens/Conteneurs.stories.ts +3 -3
- package/src/stories/DesignTokens/ThemePA.mdx +4 -30
- package/src/stories/GuideDuDev/LesBreackingChanges.mdx +36 -0
- package/src/stories/GuideDuDev/UtiliserLesRules.mdx +321 -78
- package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
- package/src/utils/formatDate/index.ts +6 -0
- package/src/utils/formatDate/tests/formatDate.spec.ts +18 -0
- package/src/utils/functions/validation/isDateAfter/index.ts +9 -0
- package/src/utils/functions/validation/isDateAfter/tests/isDateAfter.spec.ts +18 -0
- package/src/utils/functions/validation/isDateBefore/index.ts +9 -0
- package/src/utils/functions/validation/isDateBefore/tests/isDateBefore.spec.ts +23 -0
- package/src/utils/functions/validation/isDateInRange/index.ts +22 -0
- package/src/utils/functions/validation/isDateInRange/tests/isDateInRange.spec.ts +28 -0
- package/src/utils/functions/validation/isDateValid/index.ts +67 -0
- package/src/utils/functions/validation/isDateValid/tests/isDateValid.spec.ts +46 -0
- package/src/utils/functions/validation/isEmailValid/index.ts +9 -0
- package/src/utils/functions/validation/isWeekend/index.ts +10 -0
- package/src/utils/functions/validation/isWeekend/tests/isWeekend.spec.ts +16 -0
- package/src/utils/parseDate/index.ts +29 -0
- package/src/utils/parseDate/tests/parseDate.spec.ts +52 -0
- package/src/utils/rules/Rules.mdx +16 -0
- package/src/utils/rules/doMatchPattern/DoMachPattern.mdx +66 -0
- package/src/utils/rules/doMatchPattern/DoMatchPattern.stories.ts +106 -0
- package/src/utils/rules/doMatchPattern/index.ts +28 -0
- package/src/utils/rules/doMatchPattern/locales.ts +5 -0
- package/src/utils/rules/doMatchPattern/tests/matchPattern.spec.ts +38 -0
- package/src/utils/rules/index.ts +11 -0
- package/src/utils/rules/isDateValid/IsDateValid.mdx +87 -0
- package/src/utils/rules/isDateValid/IsDateValid.stories.ts +113 -0
- package/src/utils/rules/isDateValid/index.ts +32 -0
- package/src/utils/rules/isDateValid/locales.ts +10 -0
- package/src/utils/rules/isDateValid/tests/isDateValid.spec.ts +27 -0
- package/src/utils/rules/isExactLength/IsExactLenght.mdx +68 -0
- package/src/utils/rules/isExactLength/IsExactLength.stories.ts +151 -0
- package/src/utils/rules/{exactLength → isExactLength}/index.ts +2 -4
- package/src/utils/rules/isExactLength/tests/exactLength.spec.ts +48 -0
- package/src/utils/rules/isMaxLength/IsMaxLength.mdx +68 -0
- package/src/utils/rules/isMaxLength/IsMaxLength.stories.ts +152 -0
- package/src/utils/rules/isMaxLength/index.ts +30 -0
- package/src/utils/rules/isMaxLength/locales.ts +6 -0
- package/src/utils/rules/isMaxLength/tests/isMaxLength.spec.ts +42 -0
- package/src/utils/rules/isMinLength/IsMinLength.mdx +68 -0
- package/src/utils/rules/isMinLength/IsMinLength.stories.ts +152 -0
- package/src/utils/rules/isMinLength/index.ts +30 -0
- package/src/utils/rules/isMinLength/locales.ts +6 -0
- package/src/utils/rules/isMinLength/tests/isMinLength.spec.ts +42 -0
- package/src/utils/rules/isNotAfterDate/IsNotAfterDate.mdx +68 -0
- package/src/utils/rules/isNotAfterDate/IsNotAfterDate.stories.ts +109 -0
- package/src/utils/rules/isNotAfterDate/index.ts +25 -0
- package/src/utils/rules/isNotAfterDate/locales.ts +6 -0
- package/src/utils/rules/isNotAfterDate/tests/isNotAfterDate.spec.ts +25 -0
- package/src/utils/rules/isNotAfterToday/IsNotAfterToday.mdx +83 -0
- package/src/utils/rules/isNotAfterToday/IsNotAfterToday.stories.ts +110 -0
- package/src/utils/rules/isNotAfterToday/index.ts +28 -0
- package/src/utils/rules/isNotAfterToday/locales.ts +5 -0
- package/src/utils/rules/isNotAfterToday/tests/isNotAfterToday.spec.ts +30 -0
- package/src/utils/rules/isNotBeforeDate/IsNotBeforeDate.mdx +68 -0
- package/src/utils/rules/isNotBeforeDate/IsNotBeforeDate.stories.ts +114 -0
- package/src/utils/rules/isNotBeforeDate/index.ts +25 -0
- package/src/utils/rules/isNotBeforeDate/locales.ts +6 -0
- package/src/utils/rules/isNotBeforeDate/tests/IsNotBeforeDate.spec.ts +25 -0
- package/src/utils/rules/isNotBeforeToday/IsNotBeforeToday.mdx +83 -0
- package/src/utils/rules/isNotBeforeToday/IsNotBeforeToday.stories.ts +110 -0
- package/src/utils/rules/isNotBeforeToday/index.ts +28 -0
- package/src/utils/rules/isNotBeforeToday/locales.ts +5 -0
- package/src/utils/rules/isNotBeforeToday/tests/notBeforeToday.spec.ts +36 -0
- package/src/utils/rules/isRequired/IsRequired.mdx +81 -0
- package/src/utils/rules/isRequired/IsRequired.stories.ts +101 -0
- package/src/utils/rules/{required → isRequired}/index.ts +3 -3
- package/src/utils/rules/{required/tests/index.spec.ts → isRequired/tests/isRequred.spec.ts} +9 -9
- package/src/utils/rules/isValidEmail/IsValidEmail.mdx +81 -0
- package/src/utils/rules/isValidEmail/IsValidEmail.stories.ts +101 -0
- package/src/utils/rules/{email → isValidEmail}/index.ts +3 -5
- package/src/utils/rules/{email/tests/email.spec.ts → isValidEmail/tests/isValidEmail.spec.ts} +5 -5
- package/src/vuetifyConfig.ts +61 -0
- package/dist/src/utils/rules/email/index.d.ts +0 -4
- package/dist/src/utils/rules/exactLength/index.d.ts +0 -4
- package/dist/src/utils/rules/required/index.d.ts +0 -4
- package/dist/src/utils/rules/required/ruleMessageHelper.d.ts +0 -3
- package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +0 -58
- package/src/composables/useFilterable/__snapshots__/useFilterable.spec.ts.snap +0 -3
- package/src/utils/functions/isEmailValid/index.ts +0 -8
- package/src/utils/rules/required/ruleMessageHelper.ts +0 -14
- package/src/utils/rules/required/tests/rulesMessageHelper.spec.ts +0 -22
- /package/dist/src/{utils/functions/isEmailValid/tests/isEmailValid.spec.d.ts → components/FilterSideBar/tests/FilterSideBar.spec.d.ts} +0 -0
- /package/dist/src/{utils/rules/email/tests/email.spec.d.ts → components/NirField/tests/config.spec.d.ts} +0 -0
- /package/dist/src/{utils/rules/required/tests/index.spec.d.ts → components/UploadWorkflow/tests/UploadWorkflow.spec.d.ts} +0 -0
- /package/dist/src/{utils/rules/required/tests/rulesMessageHelper.spec.d.ts → components/Usages/tests/Usages.spec.d.ts} +0 -0
- /package/dist/src/utils/functions/{isEmailValid → validation/isEmailValid}/index.d.ts +0 -0
- /package/dist/src/utils/rules/{exactLength → doMatchPattern}/locales.d.ts +0 -0
- /package/dist/src/utils/rules/{email → isDateValid}/locales.d.ts +0 -0
- /package/dist/src/utils/rules/{required → isNotAfterDate}/locales.d.ts +0 -0
- /package/src/utils/functions/{isEmailValid → validation/isEmailValid}/tests/isEmailValid.spec.ts +0 -0
- /package/src/utils/rules/{exactLength → isExactLength}/locales.ts +0 -0
- /package/src/utils/rules/{required → isRequired}/locales.ts +0 -0
- /package/src/utils/rules/{email → isValidEmail}/locales.ts +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isDateValid } from '../index'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('isDateValid', () => {
|
|
5
|
+
it('returns an error when the date is not valid', () => {
|
|
6
|
+
const date = '99/99/9999'
|
|
7
|
+
|
|
8
|
+
expect(typeof isDateValid(date)).toBe('string')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns an error when the format is invalid', () => {
|
|
12
|
+
const date = '2020-04-16'
|
|
13
|
+
|
|
14
|
+
expect(typeof isDateValid(date)).toBe('string')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('returns an error when the day does not match the month', () => {
|
|
18
|
+
const date = '31/11/2019' // Only 30 days in November
|
|
19
|
+
|
|
20
|
+
expect(typeof isDateValid(date)).toBe('string')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('returns an error when it is february (not leap year) and the day does not match the month', () => {
|
|
24
|
+
const date = '29/02/2019' // Not a leap year, only 28 days
|
|
25
|
+
|
|
26
|
+
expect(typeof isDateValid(date)).toBe('string')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('returns an error when it is february (leap year) and the day does not match the month', () => {
|
|
30
|
+
const date = '30/02/2020' // Leap year, 29 days
|
|
31
|
+
|
|
32
|
+
expect(typeof isDateValid(date)).toBe('string')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('returns true when it is february and the date is valid', () => {
|
|
36
|
+
const date = '15/02/2019'
|
|
37
|
+
|
|
38
|
+
expect(isDateValid(date)).toBe(true)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('returns true when the date is valid', () => {
|
|
42
|
+
const date = '14/09/2019'
|
|
43
|
+
|
|
44
|
+
expect(isDateValid(date)).toBe(true)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** From https://emailregex.com/ */
|
|
2
|
+
export const EMAIL_REGEXP
|
|
3
|
+
// eslint-disable-next-line no-control-regex
|
|
4
|
+
= /^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/
|
|
5
|
+
|
|
6
|
+
/** Check if an email is valid */
|
|
7
|
+
export function isEmailValid(email: string): boolean {
|
|
8
|
+
return Boolean(EMAIL_REGEXP.exec(email))
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
|
|
3
|
+
export const WEEKEND_DAYS = ['Saturday', 'Sunday']
|
|
4
|
+
|
|
5
|
+
/** Check if a date is Saturday or Sunday */
|
|
6
|
+
export function isWeekend(date: string): boolean {
|
|
7
|
+
const day = dayjs(date).format('dddd')
|
|
8
|
+
|
|
9
|
+
return WEEKEND_DAYS.includes(day)
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isWeekend } from '../'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('isWeekend', () => {
|
|
5
|
+
it('returns true if the day is in a weekend', () => {
|
|
6
|
+
const date = '2019-10-26' // Saturday
|
|
7
|
+
|
|
8
|
+
expect(isWeekend(date)).toBe(true)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns false if the day is not in a weekend', () => {
|
|
12
|
+
const date = '2019-10-21' // Monday
|
|
13
|
+
|
|
14
|
+
expect(isWeekend(date)).toBe(false)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
|
|
3
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
|
4
|
+
|
|
5
|
+
dayjs.extend(customParseFormat)
|
|
6
|
+
|
|
7
|
+
/** Parse a date with dayjs */
|
|
8
|
+
export function parseDate(value: string, format = 'DD/MM/YYYY'): dayjs.Dayjs {
|
|
9
|
+
// Currently dayjs doesn't work well with timezone offsets and parsing
|
|
10
|
+
// To fix this, we set the hour based on timezone offset
|
|
11
|
+
// so we don't go back or forward multiple hours
|
|
12
|
+
|
|
13
|
+
/** Timezone offset in minutes */
|
|
14
|
+
const timezoneOffset = (new Date()).getTimezoneOffset()
|
|
15
|
+
|
|
16
|
+
let offset = '00'
|
|
17
|
+
|
|
18
|
+
if (timezoneOffset > 0) {
|
|
19
|
+
offset = '14'
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
offset = '04'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const dateWithTime = `${value} ${offset}:00:00`
|
|
26
|
+
const formatWithTime = `${format} HH:mm:ss`
|
|
27
|
+
|
|
28
|
+
return dayjs(dateWithTime, formatWithTime, true)
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { parseDate } from '../index'
|
|
5
|
+
|
|
6
|
+
const RESULT_DATE_FORMAT = 'YYYY-MM-DD'
|
|
7
|
+
|
|
8
|
+
describe('parseDate', () => {
|
|
9
|
+
it('returns a working dayjs instance', () => {
|
|
10
|
+
const date = dayjs().format('DD/MM/YYYY')
|
|
11
|
+
const parsedDate = dayjs().format(RESULT_DATE_FORMAT)
|
|
12
|
+
|
|
13
|
+
expect(parseDate(date).format(RESULT_DATE_FORMAT)).toBe(parsedDate)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('returns a working dayjs instance with custom date format', () => {
|
|
17
|
+
const DATE_FORMAT = 'DD MM YYYY'
|
|
18
|
+
|
|
19
|
+
const date = dayjs().format(DATE_FORMAT)
|
|
20
|
+
const parsedDate = dayjs().format(RESULT_DATE_FORMAT)
|
|
21
|
+
|
|
22
|
+
expect(parseDate(date, DATE_FORMAT).format(RESULT_DATE_FORMAT)).toBe(
|
|
23
|
+
parsedDate,
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('returns a working dayjs instance with a positive timezone offset', () => {
|
|
28
|
+
const date = dayjs().format('DD/MM/YYYY')
|
|
29
|
+
const parsedDate = dayjs().format(RESULT_DATE_FORMAT)
|
|
30
|
+
|
|
31
|
+
// Mock getTimezoneOffset
|
|
32
|
+
const originalGetTimezoneOffset = Date.prototype.getTimezoneOffset
|
|
33
|
+
Date.prototype.getTimezoneOffset = () => 160
|
|
34
|
+
|
|
35
|
+
expect(parseDate(date).format(RESULT_DATE_FORMAT)).toBe(parsedDate)
|
|
36
|
+
|
|
37
|
+
Date.prototype.getTimezoneOffset = originalGetTimezoneOffset
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('returns a working dayjs instance with a neutral timezone offset', () => {
|
|
41
|
+
const date = dayjs().format('DD/MM/YYYY')
|
|
42
|
+
const parsedDate = dayjs().format(RESULT_DATE_FORMAT)
|
|
43
|
+
|
|
44
|
+
// Mock getTimezoneOffset
|
|
45
|
+
const originalGetTimezoneOffset = Date.prototype.getTimezoneOffset
|
|
46
|
+
Date.prototype.getTimezoneOffset = () => 0
|
|
47
|
+
|
|
48
|
+
expect(parseDate(date).format(RESULT_DATE_FORMAT)).toBe(parsedDate)
|
|
49
|
+
|
|
50
|
+
Date.prototype.getTimezoneOffset = originalGetTimezoneOffset
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Guide Du Dev/Règles De Validation/Les règles de validation" />
|
|
4
|
+
|
|
5
|
+
# Les règles de validation
|
|
6
|
+
|
|
7
|
+
Les règles de validation permettent de vérifier la validité des données saisies dans un formulaire. Elles peuvent être utilisées en combinaison d'autres règles de `synapse` ou de personnalisées.
|
|
8
|
+
|
|
9
|
+
Pour plus d'informations sur les règles de validation, consultez la [documentation de `Vuetify`](https://vuetifyjs.com/en/components/forms/#rules).
|
|
10
|
+
|
|
11
|
+
## Détails d'utilisation
|
|
12
|
+
|
|
13
|
+
Les règles de validation sont des fonctions qui prennent en paramètre la valeur du champ de formulaire à valider. Elles retournent un `boolean` ou une `string` en fonction de la validité de la valeur.
|
|
14
|
+
|
|
15
|
+
Ce package fournie des fonctions d'ordre supérieur pour faciliter la création de règles de validation personnalisées. le nom de ces fonctions se termine par `Fn`.
|
|
16
|
+
Elles prennent en paramètre des données de configuration et retournent une fonction de validation. Cette fonction de validation peut être utilisée comme règle d'un champ de formulaire.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Meta, Canvas, Source } from '@storybook/blocks';
|
|
2
|
+
import * as DoMatchPatternStories from './DoMatchPattern.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={DoMatchPatternStories} />
|
|
5
|
+
|
|
6
|
+
# Règle de validation `doMatchPattern`
|
|
7
|
+
|
|
8
|
+
La règle de validation `doMatchPattern` permet de vérifier qu'une chaîne de caractères correspond à un motif donné.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
Pour utiliser cette règle de validation, vous devez importer la fonction d'ordre supérieur `doMatchPatternFn` depuis le package `@cnamts/synapse`.
|
|
13
|
+
|
|
14
|
+
<Source dark code={`
|
|
15
|
+
import { doMatchPatternFn } from '@cnamts/synapse';
|
|
16
|
+
`} />
|
|
17
|
+
|
|
18
|
+
Vous devez ensuite faire appel à cette fonction en lui passant en paramètre le motif que vous souhaitez vérifier.
|
|
19
|
+
|
|
20
|
+
<Source dark code={`
|
|
21
|
+
const isEmail = doMatchPatternFn(/^[\w-]+@([\w-]+\.)+[\w-]+$/);
|
|
22
|
+
`} />
|
|
23
|
+
|
|
24
|
+
Vous pouvez ensuite utiliser la fonction retournée comme règle d'un champs de formulaire.
|
|
25
|
+
|
|
26
|
+
<Source dark code={`
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { doMatchPatternFn } from '@cnamts/synapse';
|
|
29
|
+
import { VTextField } from 'vuetify/components';
|
|
30
|
+
|
|
31
|
+
const isEmail = doMatchPatternFn(/^[\w-]+@([\w-]+\.)+[\w-]+$/);
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<VTextField
|
|
36
|
+
:rules="[isEmail]"
|
|
37
|
+
label="Email"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
40
|
+
`} />
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
<Source dark code={`
|
|
45
|
+
doMatchPatternFn(
|
|
46
|
+
pattern: RegExp,
|
|
47
|
+
errorMessages?: {
|
|
48
|
+
default: string;
|
|
49
|
+
}
|
|
50
|
+
): (value: string) => true | string;
|
|
51
|
+
`} />
|
|
52
|
+
|
|
53
|
+
### Arguments
|
|
54
|
+
|
|
55
|
+
- `pattern` : expression régulière à utiliser pour vérifier la chaîne de caractères.
|
|
56
|
+
- `errorMessages` : objet optionnel permettant de personnaliser les messages d'erreur. Les clés disponibles sont :
|
|
57
|
+
- `default` : message d'erreur par défaut.
|
|
58
|
+
|
|
59
|
+
### Valeurs de retour
|
|
60
|
+
|
|
61
|
+
Retourne une fonction pouvant être utilisée comme règle de validation pour un champs de formulaire Vuetify.
|
|
62
|
+
|
|
63
|
+
## Exemples
|
|
64
|
+
|
|
65
|
+
<Canvas of={DoMatchPatternStories.Default} />
|
|
66
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/vue3'
|
|
2
|
+
import { VTextField } from 'vuetify/components'
|
|
3
|
+
import { doMatchPatternFn } from './index'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Guide du dev/Règles De Validation/doMatchPattern',
|
|
7
|
+
component: doMatchPatternFn,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Default: StoryObj<unknown> = {
|
|
11
|
+
render: () => {
|
|
12
|
+
return {
|
|
13
|
+
components: { VTextField },
|
|
14
|
+
setup() {
|
|
15
|
+
const matchTwoDigits = doMatchPatternFn(/^[0-9]{2}$/)
|
|
16
|
+
return { matchTwoDigits }
|
|
17
|
+
},
|
|
18
|
+
template: `
|
|
19
|
+
<VTextField
|
|
20
|
+
:rules="[matchTwoDigits]"
|
|
21
|
+
label="Deux chiffres"
|
|
22
|
+
variant="outlined"
|
|
23
|
+
/>
|
|
24
|
+
`,
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
parameters: {
|
|
28
|
+
sourceCode: [
|
|
29
|
+
{
|
|
30
|
+
name: 'Script',
|
|
31
|
+
code: `
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import { VTextField } from 'vuetify/components'
|
|
34
|
+
import { doMatchPatternFn } from '@cnamts/synapse'
|
|
35
|
+
|
|
36
|
+
const matchTwoDigits = doMatchPatternFn(/^[0-9]{2}$/)
|
|
37
|
+
</script>
|
|
38
|
+
`,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'Template',
|
|
42
|
+
code: `
|
|
43
|
+
<template>
|
|
44
|
+
<VTextField
|
|
45
|
+
:rules="[matchTwoDigits]"
|
|
46
|
+
label="Deux chiffres"
|
|
47
|
+
variant="outlined"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const CustomMessage: StoryObj<unknown> = {
|
|
57
|
+
render: () => {
|
|
58
|
+
return {
|
|
59
|
+
components: { VTextField },
|
|
60
|
+
setup() {
|
|
61
|
+
const twoDigits = doMatchPatternFn(
|
|
62
|
+
/^[0-9]{2}$/,
|
|
63
|
+
{ default: 'Veuillez saisir deux chiffres.' },
|
|
64
|
+
)
|
|
65
|
+
return { twoDigits }
|
|
66
|
+
},
|
|
67
|
+
template: `
|
|
68
|
+
<VTextField
|
|
69
|
+
:rules="[twoDigits]"
|
|
70
|
+
label="Deux chiffres"
|
|
71
|
+
variant="outlined"
|
|
72
|
+
/>
|
|
73
|
+
`,
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
parameters: {
|
|
77
|
+
sourceCode: [
|
|
78
|
+
{
|
|
79
|
+
name: 'Script',
|
|
80
|
+
code: `
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import { VTextField } from 'vuetify/components'
|
|
83
|
+
import { doMatchPatternFn } from '@cnamts/synapse'
|
|
84
|
+
|
|
85
|
+
const twoDigits = doMatchPatternFn(
|
|
86
|
+
/^[0-9]{2}$/,
|
|
87
|
+
{ default: 'Veuillez saisir deux chiffres.' },
|
|
88
|
+
)
|
|
89
|
+
</script>
|
|
90
|
+
`,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Template',
|
|
94
|
+
code: `
|
|
95
|
+
<template>
|
|
96
|
+
<VTextField
|
|
97
|
+
:rules="[twoDigits]"
|
|
98
|
+
label="Deux chiffres"
|
|
99
|
+
variant="outlined"
|
|
100
|
+
/>
|
|
101
|
+
</template>
|
|
102
|
+
`,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ruleMessage } from '@/utils/ruleMessage'
|
|
2
|
+
import type {
|
|
3
|
+
ValidationRule,
|
|
4
|
+
ValidationResult,
|
|
5
|
+
ErrorMessages,
|
|
6
|
+
Value,
|
|
7
|
+
} from '../types'
|
|
8
|
+
|
|
9
|
+
import { defaultErrorMessages } from './locales'
|
|
10
|
+
|
|
11
|
+
/** Check that the value match the specified pattern */
|
|
12
|
+
export function doMatchPatternFn(
|
|
13
|
+
pattern: RegExp,
|
|
14
|
+
errorMessages: ErrorMessages<number> = defaultErrorMessages,
|
|
15
|
+
): ValidationRule {
|
|
16
|
+
return (value: Value): ValidationResult => {
|
|
17
|
+
if (!value) {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const matches = value.match(pattern)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
(matches && matches.length > 0)
|
|
25
|
+
|| ruleMessage(errorMessages, 'default')
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { doMatchPatternFn } from '..'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('doMatchPatternFn', () => {
|
|
5
|
+
it('should return true if the value is empty', () => {
|
|
6
|
+
const rule = doMatchPatternFn(/^[A-Z]+$/)
|
|
7
|
+
|
|
8
|
+
expect(rule('')).toBe(true)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('should return true if the value matches the pattern', () => {
|
|
12
|
+
const rule = doMatchPatternFn(/^[A-Z]+$/)
|
|
13
|
+
|
|
14
|
+
expect(rule('ABC')).toBe(true)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should return an error if the value does not match the pattern', () => {
|
|
18
|
+
const rule = doMatchPatternFn(/^[A-Z]+$/)
|
|
19
|
+
|
|
20
|
+
expect(typeof rule('abc')).toBe('string')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should return a custom error message if the validation fails', () => {
|
|
24
|
+
const rule = doMatchPatternFn(/^[A-Z]+$/, {
|
|
25
|
+
default: 'test',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
expect(rule('abc')).toBe('test')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should not return a custom error message if the validation fails', () => {
|
|
32
|
+
const rule = doMatchPatternFn(/^[A-Z]+$/, {
|
|
33
|
+
default: 'test',
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
expect(rule('ABC')).toBe(true)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './doMatchPattern/index'
|
|
2
|
+
export * from './isDateValid/index'
|
|
3
|
+
export * from './isExactLength/index'
|
|
4
|
+
export * from './isMaxLength/index'
|
|
5
|
+
export * from './isMinLength/index'
|
|
6
|
+
export * from './isNotAfterDate/index'
|
|
7
|
+
export * from './isNotBeforeDate/index'
|
|
8
|
+
export * from './isNotBeforeToday/index'
|
|
9
|
+
export * from './isNotAfterToday/index'
|
|
10
|
+
export * from './isRequired/index'
|
|
11
|
+
export * from './isValidEmail/index'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Meta, Canvas, Source } from '@storybook/blocks';
|
|
2
|
+
import * as IsDateValidStories from './IsDateValid.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={IsDateValidStories} />
|
|
5
|
+
|
|
6
|
+
# Règle de validation `isDateValid`
|
|
7
|
+
|
|
8
|
+
La règle de validation `isDateValid` permet de vérifier si une chaîne de caractères est une date au format *DD/MM/YYYY*.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
Pour utiliser cette règle de validation, vous devez importer la fonction d'ordre supérieur `isDateValidFn` depuis le package `@cnamts/synapse`.
|
|
13
|
+
|
|
14
|
+
<Source dark code={`
|
|
15
|
+
import { isDateValidFn } from '@cnamts/synapse';
|
|
16
|
+
`} />
|
|
17
|
+
|
|
18
|
+
Vous devez ensuite faire appel à cette fonction pour obtenir la règle de validation.
|
|
19
|
+
|
|
20
|
+
<Source dark code={`
|
|
21
|
+
const isDateValid = isDateValidFn(/* options */);
|
|
22
|
+
`} />
|
|
23
|
+
|
|
24
|
+
Vous pouvez ensuite utiliser la fonction retournée comme règle d'un champs de formulaire.
|
|
25
|
+
|
|
26
|
+
<Source dark code={`
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { isDateValidFn } from '@cnamts/synapse';
|
|
29
|
+
import { VTextField } from 'vuetify/components';
|
|
30
|
+
|
|
31
|
+
const dateValid = isDateValidFn(/* options */);
|
|
32
|
+
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<VTextField
|
|
37
|
+
:rules="[dateValid]"
|
|
38
|
+
label="Date"
|
|
39
|
+
/>
|
|
40
|
+
</template>
|
|
41
|
+
`} />
|
|
42
|
+
|
|
43
|
+
Si vous n'utilisez cette règle sans options, vous pouvez faire appel à la fonction `isDateValid`.
|
|
44
|
+
|
|
45
|
+
<Source dark code={`
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { isDateValid } from '@cnamts/synapse';
|
|
48
|
+
import { VTextField } from 'vuetify/components';
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<VTextField
|
|
53
|
+
:rules="[isDateValid]"
|
|
54
|
+
label="Date"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
`} />
|
|
59
|
+
|
|
60
|
+
## API
|
|
61
|
+
|
|
62
|
+
<Source dark code={`
|
|
63
|
+
isDateValidFn(
|
|
64
|
+
errorMessages?: {
|
|
65
|
+
default: string;
|
|
66
|
+
wrongFormat: string;
|
|
67
|
+
monthNotMatch: string;
|
|
68
|
+
notALeapYear: string;
|
|
69
|
+
}
|
|
70
|
+
): (value: string) => true | string;
|
|
71
|
+
`} />
|
|
72
|
+
|
|
73
|
+
### Arguments
|
|
74
|
+
|
|
75
|
+
- `errorMessages` : objet optionnel permettant de personnaliser les messages d'erreur. Les clés disponibles sont :
|
|
76
|
+
- `default` : message d'erreur par défaut.
|
|
77
|
+
- `wrongFormat` : message d'erreur si le format de la date n'est pas respecté.
|
|
78
|
+
- `monthNotMatch` : message d'erreur si le mois n'est pas valide.
|
|
79
|
+
- `notALeapYear` : message d'erreur si l'année n'est pas bissextile.
|
|
80
|
+
|
|
81
|
+
### Valeurs de retour
|
|
82
|
+
|
|
83
|
+
Retourne une fonction pouvant être utilisée comme règle de validation pour un champs de formulaire Vuetify.
|
|
84
|
+
|
|
85
|
+
## Exemples
|
|
86
|
+
|
|
87
|
+
<Canvas of={IsDateValidStories.Default} />.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/vue3'
|
|
2
|
+
import { VTextField } from 'vuetify/components'
|
|
3
|
+
import { isDateValid, isDateValidFn } from './index'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Guide du dev/Règles De Validation/isDateValid',
|
|
8
|
+
component: isDateValid,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Default: StoryObj<unknown> = {
|
|
12
|
+
render: () => {
|
|
13
|
+
return {
|
|
14
|
+
components: { VTextField },
|
|
15
|
+
setup() {
|
|
16
|
+
const date = ref('31/11/1993')
|
|
17
|
+
return { date, isDateValid }
|
|
18
|
+
},
|
|
19
|
+
template: `
|
|
20
|
+
<VTextField
|
|
21
|
+
v-model="date"
|
|
22
|
+
:rules="[isDateValid]"
|
|
23
|
+
label="Date valide"
|
|
24
|
+
validate-on="eager blur"
|
|
25
|
+
variant="outlined"
|
|
26
|
+
/>
|
|
27
|
+
`,
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
parameters: {
|
|
31
|
+
sourceCode: [
|
|
32
|
+
{
|
|
33
|
+
name: 'Script',
|
|
34
|
+
code: `
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { VTextField } from 'vuetify/components'
|
|
37
|
+
import { isDateValid } from '@cnamts/synapse'
|
|
38
|
+
</script>
|
|
39
|
+
`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Template',
|
|
43
|
+
code: `
|
|
44
|
+
<template>
|
|
45
|
+
<VTextField
|
|
46
|
+
:rules="[isDateValid]"
|
|
47
|
+
label="Date valide"
|
|
48
|
+
variant="outlined"
|
|
49
|
+
/>
|
|
50
|
+
</template>
|
|
51
|
+
`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const CustomMessage: StoryObj<unknown> = {
|
|
58
|
+
render: () => {
|
|
59
|
+
return {
|
|
60
|
+
components: { VTextField },
|
|
61
|
+
setup() {
|
|
62
|
+
const dateValid = isDateValidFn({
|
|
63
|
+
default: 'The date you entered is invalid',
|
|
64
|
+
wrongFormat: 'The format you entered is invalid',
|
|
65
|
+
monthNotMatch: 'The day you entered exceeds the number of days in the corresponding month',
|
|
66
|
+
notALeapYear: 'The day you entered is invalid because the corresponding year is not a leap year',
|
|
67
|
+
})
|
|
68
|
+
return { dateValid }
|
|
69
|
+
},
|
|
70
|
+
template: `
|
|
71
|
+
<VTextField
|
|
72
|
+
:rules="[dateValid]"
|
|
73
|
+
label="Date"
|
|
74
|
+
validate-on="blur"
|
|
75
|
+
variant="outlined"
|
|
76
|
+
/>
|
|
77
|
+
`,
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
parameters: {
|
|
81
|
+
sourceCode: [
|
|
82
|
+
{
|
|
83
|
+
name: 'Script',
|
|
84
|
+
code: `
|
|
85
|
+
<script setup lang="ts">
|
|
86
|
+
import { VTextField } from 'vuetify/components'
|
|
87
|
+
import { isDateValidFn } from '@cnamts/synapse'
|
|
88
|
+
|
|
89
|
+
const isDateValidCustom = isDateValid({
|
|
90
|
+
default: 'The date you entered is invalid',
|
|
91
|
+
wrongFormat: 'The format you entered is invalid',
|
|
92
|
+
monthNotMatch: 'The day you entered exceeds the number of days in the corresponding month',
|
|
93
|
+
notALeapYear: 'The day you entered is invalid because the corresponding year is not a leap year',
|
|
94
|
+
})
|
|
95
|
+
</script>
|
|
96
|
+
`,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'Template',
|
|
100
|
+
code: `
|
|
101
|
+
<template>
|
|
102
|
+
<VTextField
|
|
103
|
+
:rules="[isDateValidCustom]"
|
|
104
|
+
label="Date"
|
|
105
|
+
validate-on="blur"
|
|
106
|
+
variant="outlined"
|
|
107
|
+
/>
|
|
108
|
+
</template>
|
|
109
|
+
`,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ruleMessage } from '@/utils/ruleMessage'
|
|
2
|
+
import type {
|
|
3
|
+
ValidationRule,
|
|
4
|
+
ValidationResult,
|
|
5
|
+
ErrorMessages,
|
|
6
|
+
Value,
|
|
7
|
+
} from '../types'
|
|
8
|
+
|
|
9
|
+
import { defaultErrorMessages } from './locales'
|
|
10
|
+
|
|
11
|
+
import { isDateValid as checkIfDateValid } from '@/utils/functions/validation/isDateValid'
|
|
12
|
+
|
|
13
|
+
/** Check that the value is a valid date (DD/MM/YYYY format) */
|
|
14
|
+
export function isDateValidFn(
|
|
15
|
+
errorMessages: ErrorMessages = defaultErrorMessages,
|
|
16
|
+
): ValidationRule {
|
|
17
|
+
return (value: Value): ValidationResult => {
|
|
18
|
+
if (!value) {
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const validationResult = checkIfDateValid(value)
|
|
23
|
+
const errorMessage
|
|
24
|
+
= typeof validationResult === 'string'
|
|
25
|
+
? ruleMessage(errorMessages, validationResult)
|
|
26
|
+
: true
|
|
27
|
+
|
|
28
|
+
return errorMessage || ruleMessage(errorMessages, 'default')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const isDateValid = isDateValidFn()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ErrorMessages } from '../types'
|
|
2
|
+
|
|
3
|
+
export const defaultErrorMessages: ErrorMessages = {
|
|
4
|
+
default: 'La date saisie n’est pas valide.',
|
|
5
|
+
wrongFormat: 'Le format de la date n’est pas valide.',
|
|
6
|
+
monthNotMatch:
|
|
7
|
+
'Le jour saisi dépasse le nombre de jours dans le mois correspondant.',
|
|
8
|
+
notALeapYear:
|
|
9
|
+
'Le jour saisi est invalide car l’année correspondante n’est pas une année bissextile.',
|
|
10
|
+
}
|