@cnamts/synapse 0.0.4-alpha → 0.0.6-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.d.ts +1277 -499
- package/dist/design-system-v3.js +4193 -1573
- package/dist/design-system-v3.umd.cjs +8 -8
- package/dist/style.css +1 -1
- package/package.json +18 -17
- package/src/assets/settings.scss +3 -0
- package/src/assets/tokens.scss +16 -17
- package/src/components/BackBtn/Accessibilite.mdx +14 -0
- package/src/components/BackBtn/Accessibilite.stories.ts +166 -0
- package/src/components/BackBtn/AccessibiliteItems.ts +102 -0
- package/src/components/BackBtn/BackBtn.mdx +1 -1
- package/src/components/BackBtn/BackBtn.stories.ts +8 -8
- package/src/components/BackBtn/BackBtn.vue +0 -1
- package/src/components/BackBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/BackToTopBtn/Accessibilite.mdx +14 -0
- package/src/components/BackToTopBtn/Accessibilite.stories.ts +166 -0
- package/src/components/BackToTopBtn/AccessibiliteItems.ts +52 -0
- package/src/components/BackToTopBtn/BackToTopBtn.mdx +1 -1
- package/src/components/BackToTopBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/CollapsibleList/Accessibilite.mdx +14 -0
- package/src/components/CollapsibleList/Accessibilite.stories.ts +170 -0
- package/src/components/CollapsibleList/AccessibiliteItems.ts +122 -0
- package/src/components/CollapsibleList/CollapsibleList.stories.ts +1 -1
- package/src/components/CollapsibleList/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/CookieBanner/Accessibilite.mdx +14 -0
- package/src/components/CookieBanner/Accessibilite.stories.ts +219 -0
- package/src/components/CookieBanner/AccessibiliteItems.ts +356 -0
- package/src/components/CookieBanner/CookieBanner.mdx +219 -0
- package/src/components/CookieBanner/CookieBanner.stories.ts +678 -0
- package/src/components/CookieBanner/CookieBanner.vue +225 -0
- package/src/components/CookieBanner/config.ts +38 -0
- package/src/components/CookieBanner/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/CookieBanner/locales.ts +12 -0
- package/src/components/CookieBanner/tests/CookieBanner.spec.ts +129 -0
- package/src/components/CookieBanner/tests/__snapshots__/CookieBanner.spec.ts.snap +197 -0
- package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +123 -0
- package/src/components/CookiesSelection/CookiesInformation/locales.ts +21 -0
- package/src/components/CookiesSelection/CookiesInformation/tests/CookiesInformation.spec.ts +121 -0
- package/src/components/CookiesSelection/CookiesSelection.vue +127 -0
- package/src/components/CookiesSelection/CookiesTable/CookiesTable.vue +47 -0
- package/src/components/CookiesSelection/CookiesTable/headers.ts +14 -0
- package/src/components/CookiesSelection/CookiesTable/tests/CookiesTable.spec.ts +30 -0
- package/src/components/CookiesSelection/CookiesTable/tests/__snapshots__/CookiesTable.spec.ts.snap +3 -0
- package/src/components/CookiesSelection/locales.ts +10 -0
- package/src/components/CookiesSelection/tests/CookiesSelection.spec.ts +184 -0
- package/src/components/CookiesSelection/tests/__snapshots__/CookiesSelection.spec.ts.snap +192 -0
- package/src/components/CookiesSelection/types.ts +15 -0
- package/src/components/CopyBtn/Accessibilite.mdx +14 -0
- package/src/components/CopyBtn/Accessibilite.stories.ts +166 -0
- package/src/components/CopyBtn/AccessibiliteItems.ts +105 -0
- package/src/components/CopyBtn/CopyBtn.mdx +1 -1
- package/src/components/CopyBtn/CopyBtn.stories.ts +4 -4
- package/src/components/CopyBtn/CopyBtn.vue +0 -1
- package/src/components/CopyBtn/config.ts +2 -0
- package/src/components/CopyBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/SyBtnSelect/Accessibilite.mdx +14 -0
- package/src/components/Customs/SyBtnSelect/Accessibilite.stories.ts +193 -0
- package/src/components/Customs/SyBtnSelect/AccessibiliteItems.ts +139 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +45 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.stories.ts +662 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +254 -0
- package/src/components/Customs/SyBtnSelect/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/SyBtnSelect/tests/SyBtnSelect.spec.ts +168 -0
- package/src/components/Customs/SyInputSelect/Accessibilite.mdx +14 -0
- package/src/components/Customs/SyInputSelect/Accessibilite.stories.ts +166 -0
- package/src/components/Customs/SyInputSelect/AccessibiliteItems.ts +96 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +41 -0
- package/src/components/Customs/{CustomInputSelect/CustomInputSelect.stories.ts → SyInputSelect/SyInputSelect.stories.ts} +30 -83
- package/src/components/Customs/{CustomInputSelect/CustomInputSelect.vue → SyInputSelect/SyInputSelect.vue} +46 -6
- package/src/components/Customs/SyInputSelect/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/SyInputSelect/tests/SyInputSelect.spec.ts +140 -0
- package/src/components/Customs/SySelect/Accessibilite.mdx +14 -0
- package/src/components/Customs/SySelect/Accessibilite.stories.ts +217 -0
- package/src/components/Customs/SySelect/AccessibiliteItems.ts +173 -0
- package/src/components/Customs/{CustomSelect/CustomSelect.mdx → SySelect/SySelect.mdx} +9 -8
- package/src/components/Customs/{CustomSelect/CustomSelect.stories.ts → SySelect/SySelect.stories.ts} +25 -79
- package/src/components/Customs/{CustomSelect/CustomSelect.vue → SySelect/SySelect.vue} +44 -13
- package/src/components/Customs/SySelect/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/{CustomInputSelect/tests/CustomInputSelect.spec.ts → SySelect/tests/SySelect.spec.ts} +48 -71
- package/src/components/Customs/SyTextField/Accessibilite.mdx +14 -0
- package/src/components/Customs/SyTextField/Accessibilite.stories.ts +224 -0
- package/src/components/Customs/SyTextField/AccessibiliteItems.ts +198 -0
- package/src/components/Customs/SyTextField/SyTextField.mdx +44 -0
- package/src/components/Customs/{CustomTextField/CustomTextField.stories.ts → SyTextField/SyTextField.stories.ts} +145 -34
- package/src/components/Customs/{CustomTextField/CustomTextField.vue → SyTextField/SyTextField.vue} +27 -7
- package/src/components/Customs/SyTextField/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/{CustomTextField/tests/CustomTextField.spec.ts → SyTextField/tests/SyTextField.spec.ts} +3 -3
- package/src/components/Customs/{CustomTextField/tests/__snapshots__/CustomTextField.spec.ts.snap → SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap} +5 -6
- package/src/components/DataList/Accessibilite.mdx +14 -0
- package/src/components/DataList/Accessibilite.stories.ts +166 -0
- package/src/components/DataList/AccessibiliteItems.ts +47 -0
- package/src/components/DataList/DataList.mdx +1 -1
- package/src/components/DataList/DataList.stories.ts +10 -10
- package/src/components/DataList/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/DataListGroup/Accessibilite.mdx +14 -0
- package/src/components/DataListGroup/Accessibilite.stories.ts +225 -0
- package/src/components/DataListGroup/AccessibiliteItems.ts +79 -0
- package/src/components/DataListGroup/DataListGroup.mdx +1 -1
- package/src/components/DataListGroup/DataListGroup.stories.ts +7 -7
- package/src/components/DataListGroup/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/DialogBox/Accessibilite.mdx +14 -0
- package/src/components/DialogBox/Accessibilite.stories.ts +189 -0
- package/src/components/DialogBox/AccessibiliteItems.ts +167 -0
- package/src/components/DialogBox/DialogBox.mdx +14 -0
- package/src/components/DialogBox/DialogBox.stories.ts +798 -0
- package/src/components/DialogBox/DialogBox.vue +181 -0
- package/src/components/DialogBox/config.ts +25 -0
- package/src/components/DialogBox/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/DialogBox/locales.ts +5 -0
- package/src/components/DialogBox/tests/DialogBox.spec.ts +329 -0
- package/src/components/DialogBox/tests/__snapshots__/DialogBox.spec.ts.snap +46 -0
- package/src/components/DownloadBtn/AccessibiliteItems.ts +1 -31
- package/src/components/DownloadBtn/DownloadBtn.mdx +3 -3
- package/src/components/DownloadBtn/DownloadBtn.stories.ts +6 -6
- package/src/components/ErrorPage/Accessibilite.mdx +14 -0
- package/src/components/ErrorPage/Accessibilite.stories.ts +189 -0
- package/src/components/ErrorPage/AccessibiliteItems.ts +205 -0
- package/src/components/ErrorPage/ErrorPage.mdx +21 -0
- package/src/components/ErrorPage/ErrorPage.stories.ts +133 -0
- package/src/components/ErrorPage/ErrorPage.vue +93 -0
- package/src/components/ErrorPage/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/ErrorPage/locales.ts +5 -0
- package/src/components/ErrorPage/tests/ErrorPage.spec.ts +40 -0
- package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +78 -0
- package/src/components/FooterBar/Accessibilite.mdx +14 -0
- package/src/components/FooterBar/Accessibilite.stories.ts +223 -0
- package/src/components/FooterBar/AccessibiliteItems.ts +257 -0
- package/src/components/FooterBar/FooterBar.mdx +2 -2
- package/src/components/FooterBar/FooterBar.stories.ts +556 -8
- package/src/components/FooterBar/FooterBar.vue +80 -73
- package/src/components/FooterBar/config.ts +2 -3
- package/src/components/FooterBar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/FooterBar/tests/FooterBar.spec.ts +1 -1
- package/src/components/FooterBar/tests/FooterBarConfig.spec.ts +1 -1
- package/src/components/FooterBar/tests/__snapshots__/FooterBar.spec.ts.snap +24 -22
- package/src/components/FranceConnectBtn/Accessibilite.mdx +14 -0
- package/src/components/FranceConnectBtn/Accessibilite.stories.ts +194 -0
- package/src/components/FranceConnectBtn/AccessibiliteItems.ts +169 -0
- package/src/components/FranceConnectBtn/FranceConnectBtn.mdx +1 -1
- package/src/components/FranceConnectBtn/FranceConnectBtn.stories.ts +3 -3
- package/src/components/FranceConnectBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderBar/Accessibilite.mdx +14 -0
- package/src/components/HeaderBar/Accessibilite.stories.ts +223 -0
- package/src/components/HeaderBar/AccessibiliteItems.ts +194 -0
- package/src/components/HeaderBar/HeaderBar.stories.ts +60 -2
- package/src/components/HeaderBar/HeaderBar.vue +1 -9
- package/src/components/HeaderBar/HeaderBurgerMenu/Accessibilite.mdx +14 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/Accessibilite.stories.ts +223 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/AccessibiliteItems.ts +174 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderBar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderBar/tests/__snapshots__/HeaderBar.spec.ts.snap +1 -1
- package/src/components/HeaderLoading/Accessibilite.mdx +14 -0
- package/src/components/HeaderLoading/Accessibilite.stories.ts +167 -0
- package/src/components/HeaderLoading/AccessibiliteItems.ts +29 -0
- package/src/components/HeaderLoading/HeaderLoading.mdx +1 -1
- package/src/components/HeaderLoading/HeaderLoading.stories.ts +1 -1
- package/src/components/HeaderLoading/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.mdx +6 -6
- package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +35 -33
- package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.spec.ts +1 -1
- package/src/components/HeaderToolbar/Accessibilite.mdx +14 -0
- package/src/components/HeaderToolbar/Accessibilite.stories.ts +203 -0
- package/src/components/HeaderToolbar/AccessibiliteItems.ts +200 -0
- package/src/components/HeaderToolbar/HeaderToolbar.mdx +1 -1
- package/src/components/HeaderToolbar/HeaderToolbar.stories.ts +2 -2
- package/src/components/HeaderToolbar/HeaderToolbar.vue +3 -2
- package/src/components/HeaderToolbar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderToolbar/tests/HeaderToolbar.spec.ts +36 -2
- package/src/components/LangBtn/Accessibilite.mdx +14 -0
- package/src/components/LangBtn/Accessibilite.stories.ts +168 -0
- package/src/components/LangBtn/AccessibiliteItems.ts +101 -0
- package/src/components/LangBtn/LangBtn.mdx +1 -1
- package/src/components/LangBtn/LangBtn.stories.ts +4 -4
- package/src/components/LangBtn/LangBtn.vue +3 -2
- package/src/components/LangBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/LangBtn/tests/LangBtn.spec.ts +1 -1
- package/src/components/LangBtn/tests/__snapshots__/LangBtn.spec.ts.snap +1 -1
- package/src/components/Logo/Accessibilite.mdx +14 -0
- package/src/components/Logo/Accessibilite.stories.ts +223 -0
- package/src/components/Logo/AccessibiliteItems.ts +155 -0
- package/src/components/Logo/Logo.mdx +1 -1
- package/src/components/Logo/Logo.stories.ts +8 -8
- package/src/components/Logo/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/LogoBrandSection/Accessibilite.mdx +14 -0
- package/src/components/LogoBrandSection/Accessibilite.stories.ts +223 -0
- package/src/components/LogoBrandSection/AccessibiliteItems.ts +194 -0
- package/src/components/LogoBrandSection/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/MaintenancePage/Accessibilite.mdx +14 -0
- package/src/components/MaintenancePage/Accessibilite.stories.ts +189 -0
- package/src/components/MaintenancePage/AccessibiliteItems.ts +173 -0
- package/src/components/MaintenancePage/MaintenancePage.mdx +11 -0
- package/src/components/MaintenancePage/MaintenancePage.stories.ts +41 -0
- package/src/components/MaintenancePage/MaintenancePage.vue +25 -0
- package/src/components/MaintenancePage/assets/maintenance.svg +1 -0
- package/src/components/MaintenancePage/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/MaintenancePage/index.ts +3 -0
- package/src/components/MaintenancePage/locales.ts +5 -0
- package/src/components/MaintenancePage/tests/MaintenancePage.spec.ts +12 -0
- package/src/components/MaintenancePage/tests/__snapshots__/MaintenancePage.spec.ts.snap +3 -0
- package/src/components/NirField/Accessibilite.mdx +14 -0
- package/src/components/NirField/Accessibilite.stories.ts +214 -0
- package/src/components/NirField/AccessibiliteItems.ts +243 -0
- package/src/components/NirField/NirField.mdx +216 -0
- package/src/components/NirField/NirField.stories.ts +359 -0
- package/src/components/NirField/NirField.vue +450 -0
- package/src/components/NirField/config.ts +16 -0
- package/src/components/NirField/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/NirField/locales.ts +12 -0
- package/src/components/NirField/nirValidation.ts +42 -0
- package/src/components/NirField/tests/NirField.spec.ts +119 -0
- package/src/components/NotFoundPage/Accessibilite.mdx +14 -0
- package/src/components/NotFoundPage/Accessibilite.stories.ts +190 -0
- package/src/components/NotFoundPage/AccessibiliteItems.ts +205 -0
- package/src/components/NotFoundPage/NotFoundPage.mdx +19 -0
- package/src/components/NotFoundPage/NotFoundPage.stories.ts +76 -0
- package/src/components/NotFoundPage/NotFoundPage.vue +52 -0
- package/src/components/NotFoundPage/assets/not-found.svg +1 -0
- package/src/components/NotFoundPage/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/NotFoundPage/locales.ts +6 -0
- package/src/components/NotFoundPage/tests/NotFoundPage.spec.ts +38 -0
- package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +76 -0
- package/src/components/NotificationBar/Accessibilite.mdx +14 -0
- package/src/components/NotificationBar/Accessibilite.stories.ts +166 -0
- package/src/components/NotificationBar/AccessibiliteItems.ts +144 -0
- package/src/components/NotificationBar/NotificationBar.mdx +1 -1
- package/src/components/NotificationBar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/NotificationBar/options.ts +1 -0
- package/src/components/PageContainer/Accessibilite.mdx +14 -0
- package/src/components/PageContainer/Accessibilite.stories.ts +166 -0
- package/src/components/PageContainer/AccessibiliteItems.ts +52 -0
- package/src/components/PageContainer/PageContainer.mdx +1 -1
- package/src/components/PageContainer/PageContainer.stories.ts +4 -4
- package/src/components/PageContainer/PageContainer.vue +16 -15
- package/src/components/PageContainer/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/PageContainer/tests/PageContainer.spec.ts +1 -1
- package/src/components/PageContainer/tests/__snapshots__/PageContainer.spec.ts.snap +2 -2
- package/src/components/PhoneField/Accessibilite.mdx +14 -0
- package/src/components/PhoneField/Accessibilite.stories.ts +216 -0
- package/src/components/PhoneField/AccessibiliteItems.ts +238 -0
- package/src/components/PhoneField/PhoneField.mdx +1 -1
- package/src/components/PhoneField/PhoneField.stories.ts +2 -2
- package/src/components/PhoneField/PhoneField.vue +5 -6
- package/src/components/PhoneField/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/PhoneField/tests/PhoneField.spec.ts +3 -3
- package/src/components/SkipLink/Accessibilite.mdx +14 -0
- package/src/components/SkipLink/Accessibilite.stories.ts +167 -0
- package/src/components/SkipLink/AccessibiliteItems.ts +77 -0
- package/src/components/SkipLink/SkipLink.stories.ts +2 -2
- package/src/components/SkipLink/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/SocialMediaLinks/Accessibilite.mdx +14 -0
- package/src/components/SocialMediaLinks/Accessibilite.stories.ts +170 -0
- package/src/components/SocialMediaLinks/AccessibiliteItems.ts +160 -0
- package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +18 -14
- package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +3 -2
- package/src/components/SocialMediaLinks/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/SocialMediaLinks/tests/SocialMediaLinks.spec.ts +1 -1
- package/src/components/SocialMediaLinks/tests/__snapshots__/SocialMediaLinks.spec.ts.snap +2 -2
- package/src/components/SubHeader/Accessibilite.mdx +14 -0
- package/src/components/SubHeader/Accessibilite.stories.ts +166 -0
- package/src/components/SubHeader/AccessibiliteItems.ts +146 -0
- package/src/components/SubHeader/SubHeader.mdx +1 -1
- package/src/components/SubHeader/SubHeader.stories.ts +11 -11
- package/src/components/SubHeader/SubHeader.vue +1 -1
- package/src/components/SubHeader/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/SyAlert/Accessibilite.mdx +14 -0
- package/src/components/SyAlert/Accessibilite.stories.ts +166 -0
- package/src/components/SyAlert/AccessibiliteItems.ts +122 -0
- package/src/components/{Alert/Alert.mdx → SyAlert/SyAlert.mdx} +9 -9
- package/src/components/{Alert/Alert.stories.ts → SyAlert/SyAlert.stories.ts} +22 -22
- package/src/components/SyAlert/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/{Alert/tests/Alert.spec.ts → SyAlert/tests/SyAlert.spec.ts} +5 -5
- package/src/components/{Alert/tests/__snapshots__/Alert.spec.ts.snap → SyAlert/tests/__snapshots__/SyAlert.spec.ts.snap} +2 -2
- package/src/components/UserMenuBtn/Accessibilite.mdx +14 -0
- package/src/components/UserMenuBtn/Accessibilite.stories.ts +189 -0
- package/src/components/UserMenuBtn/AccessibiliteItems.ts +155 -0
- package/src/components/UserMenuBtn/UserMenuBtn.mdx +35 -0
- package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +540 -0
- package/src/components/UserMenuBtn/UserMenuBtn.vue +101 -0
- package/src/components/UserMenuBtn/config.ts +24 -0
- package/src/components/UserMenuBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/UserMenuBtn/tests/UserMenuBtn.spec.ts +125 -0
- package/src/components/index.ts +19 -4
- package/src/composables/index.ts +8 -0
- package/src/composables/rules/tests/useFieldValidation.spec.ts +84 -0
- package/src/composables/rules/useFieldValidation.ts +90 -0
- package/src/designTokens/index.ts +2 -0
- package/src/designTokens/tokens/cnam/cnamDarkTheme.ts +5 -0
- package/src/designTokens/tokens/cnam/cnamLightTheme.ts +1 -0
- package/src/main.ts +3 -0
- package/src/stories/Fondamentaux/Arrondis.mdx +24 -0
- package/src/stories/{Guidelines → Fondamentaux}/Colors.mdx +1 -1
- package/src/stories/Fondamentaux/Conteneurs.mdx +7 -0
- package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +7 -0
- package/src/stories/Fondamentaux/Elevations.mdx +14 -0
- package/src/stories/Fondamentaux/Espacements.mdx +29 -0
- package/src/stories/{Guidelines → Fondamentaux}/Introduction.mdx +1 -1
- package/src/stories/Fondamentaux/StylesTypographiques.mdx +33 -0
- package/src/stories/Fondamentaux/Typographie.mdx +58 -0
- package/src/stories/GuideDuDev/CommentUtiliserLesRules.mdx +120 -0
- package/src/stories/GuideDuDev/components.stories.ts +5 -5
- package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
- package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.stories.ts +1 -1
- package/src/stories/{Fondamentaux → Guidelines}/EcoConception/Econception.stories.ts +2 -2
- package/src/stories/Guidelines/Vuetify/Vuetify.mdx +11 -0
- package/src/stories/Guidelines/Vuetify/Vuetify.stories.ts +138 -0
- package/src/stories/Guidelines/Vuetify/VuetifyItems.ts +350 -0
- package/src/components/Customs/CustomInputSelect/CustomInputSelect.mdx +0 -40
- package/src/components/Customs/CustomSelect/tests/CustomSelect.spec.ts +0 -236
- package/src/components/Customs/CustomTextField/CustomTextField.mdx +0 -44
- package/src/stories/Guidelines/CustomisationEtThemes.mdx +0 -3
- package/src/stories/Guidelines/Typo.mdx +0 -53
- /package/src/components/Customs/{CustomInputSelect → SyInputSelect}/config.ts +0 -0
- /package/src/components/Customs/{CustomTextField → SyTextField}/types.d.ts +0 -0
- /package/src/components/{Alert/Alert.vue → SyAlert/SyAlert.vue} +0 -0
- /package/src/components/{Alert → SyAlert}/locales.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.mdx +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/AccessibiliteItems.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/ExpertiseLevelEnum.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/RGAALevelEnum.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/EcoConception.mdx +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/ecoDesignItems.ts +0 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, watch, computed, nextTick } from 'vue'
|
|
3
|
+
import { useFieldValidation } from '@/composables/rules/useFieldValidation'
|
|
4
|
+
import { vMaska } from 'maska/vue'
|
|
5
|
+
import { checkNIR, isNIRKeyValid } from './nirValidation'
|
|
6
|
+
import useCustomizableOptions, { type CustomizableOptions } from '@/composables/useCustomizableOptions'
|
|
7
|
+
import SyTextField from '../Customs/SyTextField/SyTextField.vue'
|
|
8
|
+
import { mdiInformationOutline } from '@mdi/js'
|
|
9
|
+
import { locales } from './locales'
|
|
10
|
+
import defaultOptions from './config'
|
|
11
|
+
|
|
12
|
+
type Rule = (value: string) => { error?: string, success?: string }
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<CustomizableOptions & {
|
|
15
|
+
modelValue?: string | undefined
|
|
16
|
+
outlined?: boolean
|
|
17
|
+
required?: boolean
|
|
18
|
+
nirTooltip?: string
|
|
19
|
+
keyTooltip?: string
|
|
20
|
+
numberLabel?: string
|
|
21
|
+
keyLabel?: string
|
|
22
|
+
displayKey?: boolean
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
24
|
+
customNumberRules?: any
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
26
|
+
customKeyRules?: any
|
|
27
|
+
}>(), {
|
|
28
|
+
modelValue: undefined,
|
|
29
|
+
outlined: true,
|
|
30
|
+
required: false,
|
|
31
|
+
nirTooltip: undefined,
|
|
32
|
+
keyTooltip: undefined,
|
|
33
|
+
numberLabel: 'Numéro de sécurité sociale',
|
|
34
|
+
keyLabel: 'Clé',
|
|
35
|
+
displayKey: true,
|
|
36
|
+
customNumberRules: [],
|
|
37
|
+
customKeyRules: [],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits(['update:modelValue'])
|
|
41
|
+
const options = useCustomizableOptions(defaultOptions, props)
|
|
42
|
+
const infoIcon = mdiInformationOutline
|
|
43
|
+
|
|
44
|
+
// Champs
|
|
45
|
+
const numberValue = ref('')
|
|
46
|
+
const keyValue = ref('')
|
|
47
|
+
const keyDeleted = ref(false)
|
|
48
|
+
|
|
49
|
+
// Refs pour les champs
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
51
|
+
const keyField = ref<any | null>(null)
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
53
|
+
const numberField = ref<any | null>(null)
|
|
54
|
+
|
|
55
|
+
const unmaskedNumberValue = computed(() => numberValue.value.replace(/\s/g, ''))
|
|
56
|
+
|
|
57
|
+
watch(() => props.modelValue, async (value) => {
|
|
58
|
+
numberValue.value = value?.slice(0, 13) ?? ''
|
|
59
|
+
keyValue.value = value?.slice(13, 15) ?? ''
|
|
60
|
+
}, { immediate: true })
|
|
61
|
+
|
|
62
|
+
// Etats d’erreur/succès
|
|
63
|
+
const errors = ref<string[]>([])
|
|
64
|
+
const successes = ref<string[]>([])
|
|
65
|
+
|
|
66
|
+
// Flags de validation
|
|
67
|
+
const isValidating = ref(false)
|
|
68
|
+
|
|
69
|
+
// Masques
|
|
70
|
+
const numberMask = {
|
|
71
|
+
mask: '# ## ## #C ### ###',
|
|
72
|
+
preProcess: (value: string) => value.toUpperCase(),
|
|
73
|
+
tokens: {
|
|
74
|
+
C: {
|
|
75
|
+
pattern: /[0-9AB]/,
|
|
76
|
+
transform: (char: string) => char.toUpperCase(),
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
const keyMask = { mask: '##' }
|
|
81
|
+
|
|
82
|
+
// Règles de validation par défaut
|
|
83
|
+
const { generateRules } = useFieldValidation()
|
|
84
|
+
|
|
85
|
+
const defaultNumberRules = [
|
|
86
|
+
{
|
|
87
|
+
type: 'exactLength',
|
|
88
|
+
options: { length: 13, message: locales.errorLengthNumber(13), ignoreSpace: true, fieldIdentifier: 'numéro' },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'custom',
|
|
92
|
+
options: {
|
|
93
|
+
validate: checkNIR,
|
|
94
|
+
message: 'Le numéro de sécurité sociale est invalide.',
|
|
95
|
+
successMessage: 'Le numéro de sécurité sociale est valide.',
|
|
96
|
+
fieldIdentifier: 'numéro',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
...(props.required
|
|
100
|
+
? [{
|
|
101
|
+
type: 'required',
|
|
102
|
+
options: { message: 'Le numéro de sécurité sociale est requis.', fieldIdentifier: 'numéro' },
|
|
103
|
+
}]
|
|
104
|
+
: []),
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
const defaultKeyRules = [
|
|
108
|
+
{
|
|
109
|
+
type: 'exactLength',
|
|
110
|
+
options: { length: 2, message: locales.errorLengthKey(2), ignoreSpace: true, fieldIdentifier: 'clé' },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'custom',
|
|
114
|
+
options: {
|
|
115
|
+
validate: () => isNIRKeyValid(`${numberValue.value}${keyValue.value}`),
|
|
116
|
+
message: 'La clé du numéro de sécurité sociale est invalide.',
|
|
117
|
+
successMessage: 'Le champ clé est valide.',
|
|
118
|
+
fieldIdentifier: 'clé',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
...(props.required
|
|
122
|
+
? [{
|
|
123
|
+
type: 'required',
|
|
124
|
+
options: { message: 'La clé est requise.', fieldIdentifier: 'clé' },
|
|
125
|
+
}]
|
|
126
|
+
: []),
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
// Computed pour statut des champs
|
|
130
|
+
const fieldIdentifierNumber = defaultNumberRules[0]?.options?.fieldIdentifier
|
|
131
|
+
const fieldIdentifierKey = defaultKeyRules[0]?.options?.fieldIdentifier
|
|
132
|
+
|
|
133
|
+
const hasNumberErrors = computed(() => errors.value.some(error => error.includes(fieldIdentifierNumber)))
|
|
134
|
+
const hasKeyErrors = computed(() => errors.value.some(error => error.includes(fieldIdentifierKey)))
|
|
135
|
+
const hasNumberSuccess = computed(() => successes.value.some(success => success.includes(fieldIdentifierNumber)))
|
|
136
|
+
const hasKeySuccess = computed(() => successes.value.some(success => success.includes(fieldIdentifierKey)))
|
|
137
|
+
|
|
138
|
+
// Génération des règles finales
|
|
139
|
+
const numberRules = props.customNumberRules?.length
|
|
140
|
+
? generateRules(props.customNumberRules)
|
|
141
|
+
: generateRules(defaultNumberRules)
|
|
142
|
+
|
|
143
|
+
const keyRules = props.displayKey
|
|
144
|
+
? (props.customKeyRules?.length
|
|
145
|
+
? generateRules(props.customKeyRules)
|
|
146
|
+
: generateRules(defaultKeyRules))
|
|
147
|
+
: []
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Valide une liste de règles sur une valeur et met à jour les tableaux d'erreurs et de succès.
|
|
151
|
+
* @param value Valeur du champ à valider
|
|
152
|
+
* @param rules Ensemble de règles
|
|
153
|
+
*/
|
|
154
|
+
function validateFieldSet(value: string, rules: Rule[]) {
|
|
155
|
+
rules.forEach((rule) => {
|
|
156
|
+
const { error, success } = rule(value)
|
|
157
|
+
if (error) errors.value.push(error)
|
|
158
|
+
if (success && success !== 'Le champ est valide.') successes.value.push(success)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Valide les champs numéro et clé (si activée).
|
|
164
|
+
* @param onBlur Si true, la validation est lancée suite à un blur, sinon validation continue
|
|
165
|
+
*/
|
|
166
|
+
function validateFields(onBlur = false) {
|
|
167
|
+
errors.value = []
|
|
168
|
+
successes.value = []
|
|
169
|
+
|
|
170
|
+
const shouldValidateNumber = onBlur || isValidating.value || numberValue.value.length === 18
|
|
171
|
+
const shouldValidateKey = props.displayKey && (onBlur || isValidating.value || keyValue.value.length === 2)
|
|
172
|
+
|
|
173
|
+
if (shouldValidateNumber) {
|
|
174
|
+
validateFieldSet(numberValue.value, numberRules)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (shouldValidateKey) {
|
|
178
|
+
validateFieldSet(keyValue.value, keyRules)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Unicité des succès
|
|
182
|
+
successes.value = Array.from(new Set(successes.value))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Compteurs
|
|
186
|
+
const numberCounter = computed(() => {
|
|
187
|
+
const length = numberValue.value.replace(/\s/g, '').length
|
|
188
|
+
return `${Math.min(length, 13)}/13`
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
const keyCounter = computed(() => {
|
|
192
|
+
const length = keyValue.value.replace(/\s/g, '').length
|
|
193
|
+
return `${Math.min(length, 2)}/2`
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
watch([unmaskedNumberValue, keyValue], () => {
|
|
197
|
+
validateFields()
|
|
198
|
+
if (unmaskedNumberValue.value + keyValue.value !== props.modelValue) {
|
|
199
|
+
emit('update:modelValue', `${unmaskedNumberValue.value}${keyValue.value}`)
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
watch(keyValue, (newValue, oldValue) => {
|
|
204
|
+
keyDeleted.value = !!(!newValue && oldValue)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
watch(numberValue, () => {
|
|
208
|
+
if (unmaskedNumberValue.value.length < 13) {
|
|
209
|
+
keyDeleted.value = false
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
// Déplacement du focus sur la clé quand le numéro est rempli
|
|
214
|
+
const focusElement = computed(() => {
|
|
215
|
+
if (props.displayKey && numberValue.value.length === 18) {
|
|
216
|
+
if (!keyDeleted.value) {
|
|
217
|
+
return keyField.value?.$el?.querySelector('input')
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return numberField.value?.$el?.querySelector('input')
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return null
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
watch(focusElement, (newEl) => {
|
|
227
|
+
nextTick(() => {
|
|
228
|
+
newEl?.focus()
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
function validateOnSubmit() {
|
|
233
|
+
isValidating.value = true
|
|
234
|
+
validateFields()
|
|
235
|
+
return errors.value.length === 0
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
defineExpose({
|
|
239
|
+
validateOnSubmit,
|
|
240
|
+
})
|
|
241
|
+
</script>
|
|
242
|
+
<template>
|
|
243
|
+
<div class="d-flex align-start">
|
|
244
|
+
<v-input
|
|
245
|
+
ref="vInput"
|
|
246
|
+
:class="{
|
|
247
|
+
'v-messages__message--success': successes.length > 0,
|
|
248
|
+
'v-messages__message--error': errors.length > 0
|
|
249
|
+
}"
|
|
250
|
+
:error-messages="errors"
|
|
251
|
+
:label="numberLabel"
|
|
252
|
+
:max-errors="3"
|
|
253
|
+
:messages="successes"
|
|
254
|
+
:model-value="[numberValue, keyValue]"
|
|
255
|
+
class="vd-nir-field__fields-wrapper multi-line"
|
|
256
|
+
validate-on="blur lazy"
|
|
257
|
+
>
|
|
258
|
+
<VTooltip v-if="nirTooltip">
|
|
259
|
+
<template #activator="{ props: iconProps }">
|
|
260
|
+
<VIcon
|
|
261
|
+
class="vd-tooltip-icon mt-4 mr-4"
|
|
262
|
+
v-bind="{ ...iconProps, ...options.tooltip }"
|
|
263
|
+
>
|
|
264
|
+
{{ infoIcon }}
|
|
265
|
+
</VIcon>
|
|
266
|
+
</template>
|
|
267
|
+
<slot name="nirTooltip">
|
|
268
|
+
{{ nirTooltip }}
|
|
269
|
+
</slot>
|
|
270
|
+
</VTooltip>
|
|
271
|
+
<SyTextField
|
|
272
|
+
ref="numberField"
|
|
273
|
+
v-model="numberValue"
|
|
274
|
+
v-maska="numberMask"
|
|
275
|
+
:append-inner-icon="hasNumberErrors ? 'error' : (hasNumberSuccess ? 'success' : undefined)"
|
|
276
|
+
:aria-errormessage="hasNumberErrors ? 'number-field-errors' : undefined"
|
|
277
|
+
:aria-invalid="hasNumberErrors"
|
|
278
|
+
:aria-required="required"
|
|
279
|
+
:color="hasNumberErrors ? 'error' : 'primary'"
|
|
280
|
+
:error="hasNumberErrors"
|
|
281
|
+
:hint="locales.numberHint"
|
|
282
|
+
:label="numberLabel"
|
|
283
|
+
:variant="outlined ? 'outlined' : 'underlined'"
|
|
284
|
+
class="vd-number-field"
|
|
285
|
+
title="nirField"
|
|
286
|
+
@blur="validateFields(true)"
|
|
287
|
+
>
|
|
288
|
+
<template #details>
|
|
289
|
+
<span class="custom-counter">
|
|
290
|
+
{{ numberCounter }}
|
|
291
|
+
</span>
|
|
292
|
+
</template>
|
|
293
|
+
</SyTextField>
|
|
294
|
+
|
|
295
|
+
<template v-if="displayKey">
|
|
296
|
+
<SyTextField
|
|
297
|
+
ref="keyField"
|
|
298
|
+
v-model="keyValue"
|
|
299
|
+
v-maska="keyMask"
|
|
300
|
+
:append-inner-icon="hasKeyErrors ? 'error' : (hasKeySuccess ? 'success' : undefined)"
|
|
301
|
+
:aria-errormessage="hasKeyErrors ? 'key-field-errors' : undefined"
|
|
302
|
+
:aria-invalid="hasKeyErrors"
|
|
303
|
+
:aria-required="required"
|
|
304
|
+
:color="hasKeyErrors ? 'error' : 'primary'"
|
|
305
|
+
:error="hasKeyErrors"
|
|
306
|
+
:hint="locales.keyHint"
|
|
307
|
+
:label="keyLabel"
|
|
308
|
+
:variant="outlined ? 'outlined' : 'underlined'"
|
|
309
|
+
class="vd-key-field"
|
|
310
|
+
title="nirKeyField"
|
|
311
|
+
@blur="validateFields(true)"
|
|
312
|
+
>
|
|
313
|
+
<template #details>
|
|
314
|
+
<span class="custom-counter">
|
|
315
|
+
{{ keyCounter }}
|
|
316
|
+
</span>
|
|
317
|
+
</template>
|
|
318
|
+
</SyTextField>
|
|
319
|
+
|
|
320
|
+
<VTooltip v-if="keyTooltip">
|
|
321
|
+
<template #activator="{ props: iconProps }">
|
|
322
|
+
<VIcon
|
|
323
|
+
class="vd-tooltip-icon mt-4 ml-4"
|
|
324
|
+
v-bind="{ ...iconProps, ...options.icon }"
|
|
325
|
+
>
|
|
326
|
+
{{ infoIcon }}
|
|
327
|
+
</VIcon>
|
|
328
|
+
</template>
|
|
329
|
+
<slot name="keyTooltip">
|
|
330
|
+
{{ keyTooltip }}
|
|
331
|
+
</slot>
|
|
332
|
+
</VTooltip>
|
|
333
|
+
</template>
|
|
334
|
+
</v-input>
|
|
335
|
+
</div>
|
|
336
|
+
</template>
|
|
337
|
+
|
|
338
|
+
<style lang="scss" scoped>
|
|
339
|
+
@use '@/assets/tokens.scss';
|
|
340
|
+
|
|
341
|
+
.v-messages__message--success {
|
|
342
|
+
color: tokens.$colors-border-success !important;
|
|
343
|
+
|
|
344
|
+
.v-field--active & {
|
|
345
|
+
color: tokens.$colors-border-success !important;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.v-messages__message--error {
|
|
350
|
+
color: tokens.$colors-border-error;
|
|
351
|
+
|
|
352
|
+
.v-field--active & {
|
|
353
|
+
color: tokens.$colors-border-error;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
:deep(.v-field.v-field--active .v-label.v-field-label--floating) {
|
|
358
|
+
opacity: 1;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.multi-line {
|
|
362
|
+
white-space: pre-line !important;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.vd-number-field {
|
|
366
|
+
max-width: 296px;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.vd-key-field {
|
|
370
|
+
width: 104px;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.custom-counter {
|
|
374
|
+
color: rgba(0, 0, 0, 0.54);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.vd-nir-field :deep(.v-input__append-inner),
|
|
378
|
+
.vd-tooltip-icon {
|
|
379
|
+
flex: none;
|
|
380
|
+
color: rgba(0, 0, 0, 0.54);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
:deep(.v-overlay__content) {
|
|
384
|
+
background: rgba(84, 88, 89, 0.95) !important;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.vd-key-field {
|
|
388
|
+
flex: none;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.vd-nir-field--outlined :deep(.v-messages.error--text) {
|
|
392
|
+
padding: 6px;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.vd-nir-field {
|
|
396
|
+
container-name: nirFieldwrapper;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
:deep(.v-input__append) {
|
|
400
|
+
margin-inline-start: 0 !important;
|
|
401
|
+
}
|
|
402
|
+
:deep(.vd-number-field > .v-input__prepend) {
|
|
403
|
+
margin-right: 0 !important;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
:deep(.vd-key-field > .v-input__prepend) {
|
|
407
|
+
@media screen and (max-width: 360px) {
|
|
408
|
+
margin-inline-end: 0 !important;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
:deep(.v-text-field .v-input__details) {
|
|
413
|
+
padding-inline-start: 0 !important;
|
|
414
|
+
padding-inline-end: 0 !important;
|
|
415
|
+
flex: none !important;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
:deep(.v-text-field .v-input__details .v-messages) {
|
|
419
|
+
color: rgba(0, 0, 0, 1) !important;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@mixin responsive-nir-wrapper {
|
|
423
|
+
.vd-nir-field__fields-wrapper :deep(> .v-input__control) {
|
|
424
|
+
justify-content: start;
|
|
425
|
+
flex-wrap: wrap;
|
|
426
|
+
gap: 4px;
|
|
427
|
+
margin-bottom: 4px;
|
|
428
|
+
|
|
429
|
+
.vd-number-field {
|
|
430
|
+
flex: 100% 0 0;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
@container nirFieldwrapper (max-width: 300px) {
|
|
436
|
+
@include responsive-nir-wrapper;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
@media screen and (max-width: 360px) {
|
|
440
|
+
@include responsive-nir-wrapper;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.v-text-field .v-input__append-inner {
|
|
444
|
+
padding-left: 0 !important;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
:deep(.v-text-field > .v-input__control > .v-input__slot > .v-text-field__slot) {
|
|
448
|
+
width: min-content !important;
|
|
449
|
+
}
|
|
450
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const locales = {
|
|
2
|
+
errorRequiredNumber: 'Le numéro de sécurité sociale est requis.',
|
|
3
|
+
errorLengthNumber: (length: number) => `Le numéro de sécurité sociale doit contenir ${length} caractères.`,
|
|
4
|
+
errorInvalidFormat: 'Le format du numéro de sécurité sociale est invalide.',
|
|
5
|
+
errorRequiredKey: 'La clé du numéro de sécurité sociale est requise.',
|
|
6
|
+
errorLengthKey: (length: number) => `La clé du numéro de sécurité sociale doit contenir ${length} caractères.`,
|
|
7
|
+
errorInvalidKey: 'La clé du numéro de sécurité sociale est invalide.',
|
|
8
|
+
numberLabel: 'Numéro de sécurité sociale',
|
|
9
|
+
numberHint: '13 caractères',
|
|
10
|
+
keyLabel: 'Clé',
|
|
11
|
+
keyHint: '2 chiffres',
|
|
12
|
+
} as const
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const NUMBER_LENGTH = 13
|
|
2
|
+
export const KEY_LENGTH = 2
|
|
3
|
+
|
|
4
|
+
export function checkNIR(nir: string): boolean {
|
|
5
|
+
nir = nir.replace(/\s+/g, '').toUpperCase()
|
|
6
|
+
|
|
7
|
+
const nirRegex = new RegExp(
|
|
8
|
+
'^'
|
|
9
|
+
+ '(?<sexe>[1-4]|7|8)'
|
|
10
|
+
+ '(?<anneeNaissance>\\d{2})'
|
|
11
|
+
+ '(?<moisNaissance>0[1-9]|1[0-2]|2[0-9]|3[0-9]|4[0-2])'
|
|
12
|
+
+ '(?<departementNaissance>\\d{2}|2A|2B|96|97\\d|98\\d)'
|
|
13
|
+
+ '(?<communeNaissance>\\d{3})'
|
|
14
|
+
+ '(?<rangInscription>\\d{3})'
|
|
15
|
+
+ '(?<cle>[0-9]{2})?'
|
|
16
|
+
+ '$',
|
|
17
|
+
'i',
|
|
18
|
+
)
|
|
19
|
+
return nirRegex.test(nir)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function computeNIRKey(nir: string): string {
|
|
23
|
+
nir = nir.replace(/\s+/g, '').toUpperCase()
|
|
24
|
+
|
|
25
|
+
let nirNumberPart = nir.substring(0, 13)
|
|
26
|
+
|
|
27
|
+
nirNumberPart = nirNumberPart.replace('2A', '19').replace('2B', '18')
|
|
28
|
+
|
|
29
|
+
const nirNumber = BigInt(nirNumberPart)
|
|
30
|
+
|
|
31
|
+
const key = 97n - (nirNumber % 97n)
|
|
32
|
+
|
|
33
|
+
return key.toString().padStart(2, '0')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isNIRKeyValid(nir: string): boolean {
|
|
37
|
+
nir = nir.replace(/\s+/g, '').toUpperCase()
|
|
38
|
+
|
|
39
|
+
const providedKey = nir.substring(13, 15)
|
|
40
|
+
const computedKey = computeNIRKey(nir)
|
|
41
|
+
return providedKey === computedKey
|
|
42
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils'
|
|
2
|
+
import NirField from '../NirField.vue'
|
|
3
|
+
import { describe, it, expect, beforeEach } from 'vitest'
|
|
4
|
+
import { createVuetify } from 'vuetify'
|
|
5
|
+
|
|
6
|
+
const vuetify = createVuetify()
|
|
7
|
+
|
|
8
|
+
describe('NirField.vue', () => {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
10
|
+
let wrapper: any
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
wrapper = mount(NirField, {
|
|
14
|
+
global: {
|
|
15
|
+
plugins: [vuetify],
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
modelValue: '',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('renders correctly', () => {
|
|
25
|
+
expect(wrapper.exists()).toBe(true)
|
|
26
|
+
expect(wrapper.find('.vd-number-field').exists()).toBe(true)
|
|
27
|
+
expect(wrapper.find('.vd-key-field').exists()).toBe(true)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('displays error message for invalid NIR length', async () => {
|
|
31
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
32
|
+
await numberField.setValue('123') // Invalid length
|
|
33
|
+
await numberField.trigger('blur')
|
|
34
|
+
expect(wrapper.find('.v-messages__message').text()).toContain('Le numéro de sécurité sociale doit contenir 13 caractères.')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('validates the NIR field successfully', async () => {
|
|
38
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
39
|
+
await numberField.setValue('2940375120005') // Valid NIR length
|
|
40
|
+
expect(wrapper.find('.v-messages__message--success').exists()).toBe(true)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('displays error message for invalid key length', async () => {
|
|
44
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
45
|
+
await numberField.setValue('2940375120005') // Valid NIR length
|
|
46
|
+
const keyField = wrapper.find('.vd-key-field input')
|
|
47
|
+
await keyField.setValue('1') // Invalid length
|
|
48
|
+
await keyField.trigger('blur')
|
|
49
|
+
expect(wrapper.find('.v-messages__message').text()).toContain('La clé du numéro de sécurité sociale doit contenir 2 caractères.')
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('validates the key field successfully', async () => {
|
|
53
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
54
|
+
const keyField = wrapper.find('.vd-key-field input')
|
|
55
|
+
await numberField.setValue('2940375120005')
|
|
56
|
+
await keyField.setValue('91')
|
|
57
|
+
expect(wrapper.find('.v-messages__message--success').exists()).toBe(true)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('hides the key field when displayKey is false', async () => {
|
|
61
|
+
await wrapper.setProps({ displayKey: false })
|
|
62
|
+
expect(wrapper.find('.vd-key-field').exists()).toBe(false)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('calls validateOnSubmit and returns true if no errors', async () => {
|
|
66
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
67
|
+
const keyField = wrapper.find('.vd-key-field input')
|
|
68
|
+
|
|
69
|
+
await numberField.setValue('2940375120005')
|
|
70
|
+
await keyField.setValue('91')
|
|
71
|
+
|
|
72
|
+
await wrapper.vm.$nextTick()
|
|
73
|
+
|
|
74
|
+
wrapper.vm.validateFields()
|
|
75
|
+
|
|
76
|
+
const isValid = wrapper.vm.validateOnSubmit()
|
|
77
|
+
|
|
78
|
+
expect(isValid).toBe(true)
|
|
79
|
+
expect(wrapper.vm.errors.length).toBe(0)
|
|
80
|
+
})
|
|
81
|
+
it('applies custom key rules when provided', async () => {
|
|
82
|
+
const customKeyRules = [
|
|
83
|
+
{
|
|
84
|
+
type: 'custom',
|
|
85
|
+
options: {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
87
|
+
validate: (value: any) => value === '91',
|
|
88
|
+
message: 'Custom key validation failed.',
|
|
89
|
+
successMessage: 'Custom key validation passed.',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
wrapper = mount(NirField, {
|
|
95
|
+
global: {
|
|
96
|
+
plugins: [vuetify],
|
|
97
|
+
},
|
|
98
|
+
props: {
|
|
99
|
+
modelValue: '',
|
|
100
|
+
required: true,
|
|
101
|
+
customKeyRules,
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
const numberField = wrapper.find('.vd-number-field input')
|
|
105
|
+
const keyField = wrapper.find('.vd-key-field input')
|
|
106
|
+
await numberField.setValue('2940375120005')
|
|
107
|
+
await keyField.setValue('91')
|
|
108
|
+
|
|
109
|
+
await wrapper.vm.$nextTick()
|
|
110
|
+
|
|
111
|
+
expect(wrapper.vm.errors.length).toBe(0)
|
|
112
|
+
expect(wrapper.vm.successes).toContain('Custom key validation passed.')
|
|
113
|
+
|
|
114
|
+
await keyField.setValue('11')
|
|
115
|
+
await wrapper.vm.$nextTick()
|
|
116
|
+
|
|
117
|
+
expect(wrapper.vm.errors).toContain('Custom key validation failed.')
|
|
118
|
+
})
|
|
119
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import * as AccessStories from './Accessibilite.stories.ts';
|
|
3
|
+
|
|
4
|
+
<Meta of={AccessStories} />
|
|
5
|
+
|
|
6
|
+
Accessibilité
|
|
7
|
+
=============
|
|
8
|
+
<Story of={AccessStories.Legende} />
|
|
9
|
+
<br />
|
|
10
|
+
|
|
11
|
+
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
<Story of={AccessStories.AccessibilitePanel} />
|
|
14
|
+
<br />
|