@cnamts/synapse 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DateFilter-BmRuzQ9Z.js +98 -0
- package/dist/NumberFilter-CnIPDHqx.js +121 -0
- package/dist/PeriodFilter-CZwZ8CnQ.js +112 -0
- package/dist/SelectFilter-Cj-GW2Cc.js +97 -0
- package/dist/TextFilter-DTxZHJwX.js +114 -0
- package/dist/{components/BackBtn → common}/constants/ExpertiseLevelEnum.d.ts +3 -0
- package/dist/components/BackBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/BackToTopBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/ChipList/AccessibiliteItems.d.ts +1 -1
- package/dist/components/CollapsibleList/AccessibiliteItems.d.ts +1 -1
- package/dist/components/ContextualMenu/AccessibiliteItems.d.ts +1 -1
- package/dist/components/CookieBanner/AccessibiliteItems.d.ts +1 -1
- package/dist/components/CopyBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SyBtnSelect/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SyInputSelect/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SySelect/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SyTextField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/DataList/AccessibiliteItems.d.ts +1 -1
- package/dist/components/DataListGroup/AccessibiliteItems.d.ts +1 -1
- package/dist/components/DatePicker/AccessibiliteItems.d.ts +1 -1
- package/dist/components/DatePicker/ComplexDatePicker/ComplexDatePicker.d.ts +4162 -0
- package/dist/components/DatePicker/{DatePicker.d.ts → DatePicker/DatePicker.d.ts} +142 -102
- package/dist/components/DatePicker/{DateTextInput.d.ts → DateTextInput/DateTextInput.d.ts} +32 -26
- package/dist/components/DatePicker/composables/index.d.ts +15 -0
- package/dist/components/DatePicker/composables/useDateFormatValidation.d.ts +25 -0
- package/dist/components/DatePicker/composables/useDateInputEditing.d.ts +33 -0
- package/dist/components/DatePicker/composables/useDatePickerViewMode.d.ts +16 -0
- package/dist/components/DatePicker/composables/useDatePickerVisibility.d.ts +27 -0
- package/dist/components/DatePicker/composables/useDateRangeInput.d.ts +29 -0
- package/dist/components/DatePicker/composables/useDateRangeValidation.d.ts +11 -0
- package/dist/components/DatePicker/composables/useDateSelection.d.ts +10 -0
- package/dist/components/DatePicker/composables/useDateValidation.d.ts +35 -0
- package/dist/components/DatePicker/composables/useDisplayedDateString.d.ts +16 -0
- package/dist/components/DatePicker/composables/useIconState.d.ts +17 -0
- package/dist/components/DatePicker/composables/useInputBlurHandler.d.ts +30 -0
- package/dist/components/DatePicker/composables/useInputHandler.d.ts +32 -0
- package/dist/components/DatePicker/composables/useManualDateValidation.d.ts +33 -0
- package/dist/components/DatePicker/composables/useMonthButtonCustomization.d.ts +9 -0
- package/dist/components/DatePicker/composables/useTodayButton.d.ts +16 -0
- package/dist/components/DatePicker/composables/useWeekendDays.d.ts +11 -0
- package/dist/components/DatePicker/constants/messages.d.ts +29 -0
- package/dist/components/DatePicker/types.d.ts +13 -0
- package/dist/components/DialogBox/AccessibiliteItems.d.ts +1 -1
- package/dist/components/DownloadBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/ErrorPage/AccessibiliteItems.d.ts +1 -1
- package/dist/components/ExternalLinks/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FileList/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FilePreview/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FileUpload/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FilterInline/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FilterSideBar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FilterSideBar/FilterSideBar.d.ts +395 -1
- package/dist/components/FooterBar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/FranceConnectBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/HeaderBar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/HeaderBar/HeaderBurgerMenu/AccessibiliteItems.d.ts +1 -1
- package/dist/components/HeaderLoading/AccessibiliteItems.d.ts +1 -1
- package/dist/components/HeaderToolbar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/LangBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Logo/AccessibiliteItems.d.ts +1 -1
- package/dist/components/LogoBrandSection/AccessibiliteItems.d.ts +1 -1
- package/dist/components/MaintenancePage/AccessibiliteItems.d.ts +1 -1
- package/dist/components/NirField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/NotFoundPage/AccessibiliteItems.d.ts +1 -1
- package/dist/components/NotificationBar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PageContainer/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PaginatedTable/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PasswordField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PeriodField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PeriodField/PeriodField.d.ts +171 -37
- package/dist/components/PhoneField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/RangeField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/RatingPicker/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SearchListField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SelectBtnField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SkipLink/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SocialMediaLinks/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SubHeader/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SyAlert/AccessibiliteItems.d.ts +1 -1
- package/dist/components/TableToolbar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Tables/SyServerTable/SyServerTable.d.ts +647 -0
- package/dist/components/Tables/SyTable/SyTable.d.ts +666 -0
- package/dist/components/Tables/common/SyTableFilter.d.ts +126 -0
- package/dist/components/Tables/common/TableHeader.d.ts +33 -0
- package/dist/components/Tables/common/constants/StateEnum.d.ts +6 -0
- package/dist/components/Tables/common/filters/DateFilter.d.ts +121 -0
- package/dist/components/Tables/common/filters/NumberFilter.d.ts +132 -0
- package/dist/components/Tables/common/filters/PeriodFilter.d.ts +135 -0
- package/dist/components/Tables/common/filters/SelectFilter.d.ts +120 -0
- package/dist/components/Tables/common/filters/TextFilter.d.ts +132 -0
- package/dist/components/Tables/common/formatters.d.ts +17 -0
- package/dist/components/Tables/common/locales.d.ts +7 -0
- package/dist/components/Tables/common/tableAccessibilityUtils.d.ts +8 -0
- package/dist/components/Tables/common/tableFilterUtils.d.ts +2 -0
- package/dist/components/Tables/common/tableStorageUtils.d.ts +29 -0
- package/dist/components/Tables/common/tableUtils.d.ts +42 -0
- package/dist/components/Tables/common/types.d.ts +80 -0
- package/dist/components/Tables/common/useTableFilter.d.ts +9 -0
- package/dist/components/Tables/index.d.ts +2 -0
- package/dist/components/UploadWorkflow/AccessibiliteItems.d.ts +1 -1
- package/dist/components/UserMenuBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/design-system-v3.js +100 -11944
- package/dist/design-system-v3.umd.cjs +22 -4
- package/dist/designTokens/index.d.ts +3 -1
- package/dist/designTokens/tokens/cnam/cnamFonts.d.ts +140 -0
- package/dist/designTokens/tokens/pa/paFonts.d.ts +140 -0
- package/dist/designTokens/utils/createFontVariables.d.ts +39 -0
- package/dist/designTokens/utils/index.d.ts +2 -1
- package/dist/main-WDqeoGM-.js +14788 -0
- package/dist/style.css +1 -1
- package/dist/utils/rules/isRequired/index.d.ts +1 -1
- package/dist/vite-env.d.ts +12 -0
- package/package.json +3 -3
- package/src/assets/_spacers.scss +37 -1
- package/src/assets/_typography.scss +158 -0
- package/src/assets/settings.scss +7 -0
- package/src/common/constants/ExpertiseLevelEnum.ts +7 -0
- package/src/components/BackBtn/AccessibiliteItems.ts +1 -1
- package/src/components/BackToTopBtn/AccessibiliteItems.ts +1 -1
- package/src/components/ChipList/AccessibiliteItems.ts +1 -1
- package/src/components/CollapsibleList/AccessibiliteItems.ts +1 -1
- package/src/components/ContextualMenu/AccessibiliteItems.ts +1 -1
- package/src/components/CookieBanner/AccessibiliteItems.ts +1 -1
- package/src/components/CopyBtn/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SyBtnSelect/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SyInputSelect/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SySelect/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SySelect/SySelect.vue +3 -9
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +4 -2
- package/src/components/Customs/SyTextField/AccessibiliteItems.ts +1 -1
- package/src/components/DataList/AccessibiliteItems.ts +1 -1
- package/src/components/DataListGroup/AccessibiliteItems.ts +1 -1
- package/src/components/DatePicker/AccessibiliteItems.ts +1 -1
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.mdx +212 -0
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.stories.ts +1097 -0
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.vue +497 -180
- package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.spec.ts +941 -0
- package/src/components/DatePicker/DatePicker/DatePicker.mdx +176 -0
- package/src/components/DatePicker/{tests → DatePicker}/DatePicker.spec.ts +1 -1
- package/src/components/DatePicker/{DatePicker.stories.ts → DatePicker/DatePicker.stories.ts} +115 -400
- package/src/components/DatePicker/{DatePicker.vue → DatePicker/DatePicker.vue} +302 -84
- package/src/components/DatePicker/DatePickerOverview.mdx +227 -0
- package/src/components/DatePicker/{DatePickerValidation.mdx → DatePickerValidationExample/DatePickerValidation.mdx} +3 -3
- package/src/components/DatePicker/{DatePickerValidation.stories.ts → DatePickerValidationExample/DatePickerValidation.stories.ts} +2 -2
- package/src/components/DatePicker/DateTextInput/DateRange.stories.ts +310 -0
- package/src/components/DatePicker/DateTextInput/DateTextInput.range.spec.ts +278 -0
- package/src/components/DatePicker/{tests → DateTextInput}/DateTextInput.spec.ts +8 -7
- package/src/components/DatePicker/DateTextInput/DateTextInput.vue +916 -0
- package/src/components/DatePicker/DateTextInput/NoCalendar.mdx +64 -0
- package/src/components/DatePicker/DateTextInput/NoCalendar.stories.ts +572 -0
- package/src/components/DatePicker/composables/index.ts +22 -0
- package/src/components/DatePicker/composables/tests/useDateFormatValidation.spec.ts +165 -0
- package/src/components/DatePicker/composables/tests/useDateInputEditing.spec.ts +359 -0
- package/src/components/DatePicker/composables/tests/useDatePickerViewMode.spec.ts +160 -0
- package/src/components/DatePicker/composables/tests/useDatePickerVisibility.spec.ts +339 -0
- package/src/components/DatePicker/composables/tests/useDateRangeInput.spec.ts +277 -0
- package/src/components/DatePicker/composables/tests/useDateRangeValidation.spec.ts +107 -0
- package/src/components/DatePicker/composables/tests/useDateSelection.spec.ts +171 -0
- package/src/components/DatePicker/composables/tests/useDateValidation.spec.ts +245 -0
- package/src/components/DatePicker/composables/tests/useDisplayedDateString.spec.ts +98 -0
- package/src/components/DatePicker/composables/tests/useIconState.spec.ts +130 -0
- package/src/components/DatePicker/composables/tests/useInputBlurHandler.spec.ts +278 -0
- package/src/components/DatePicker/composables/tests/useManualDateValidation.spec.ts +233 -0
- package/src/components/DatePicker/composables/tests/useMonthButtonCustomization.spec.ts +100 -0
- package/src/components/DatePicker/composables/tests/useTodayButton.spec.ts +97 -0
- package/src/components/DatePicker/composables/tests/useWeekendDays.spec.ts +28 -0
- package/src/components/DatePicker/composables/useDateFormatValidation.ts +95 -0
- package/src/components/DatePicker/composables/useDateInputEditing.ts +326 -0
- package/src/components/DatePicker/composables/useDatePickerViewMode.ts +61 -0
- package/src/components/DatePicker/composables/useDatePickerVisibility.ts +146 -0
- package/src/components/DatePicker/composables/useDateRangeInput.ts +375 -0
- package/src/components/DatePicker/composables/useDateRangeValidation.ts +48 -0
- package/src/components/DatePicker/composables/useDateSelection.ts +121 -0
- package/src/components/DatePicker/composables/useDateValidation.ts +225 -0
- package/src/components/DatePicker/composables/useDisplayedDateString.ts +58 -0
- package/src/components/DatePicker/composables/useIconState.ts +53 -0
- package/src/components/DatePicker/composables/useInputBlurHandler.ts +101 -0
- package/src/components/DatePicker/composables/useInputHandler.ts +436 -0
- package/src/components/DatePicker/composables/useManualDateValidation.ts +161 -0
- package/src/components/DatePicker/composables/useMonthButtonCustomization.ts +89 -0
- package/src/components/DatePicker/composables/useTodayButton.ts +43 -0
- package/src/components/DatePicker/composables/useWeekendDays.ts +21 -0
- package/src/components/DatePicker/constants/messages.ts +50 -0
- package/src/components/DatePicker/docExamples/DatePickerBidirectionalValidation.vue +4 -4
- package/src/components/DatePicker/docExamples/DatePickerValidationExamples.vue +1 -1
- package/src/components/DatePicker/playground/ComplexDatePickerPlayground.vue +172 -0
- package/src/components/DatePicker/types.ts +15 -0
- package/src/components/DialogBox/AccessibiliteItems.ts +1 -1
- package/src/components/DownloadBtn/AccessibiliteItems.ts +1 -1
- package/src/components/ErrorPage/AccessibiliteItems.ts +1 -1
- package/src/components/ExternalLinks/AccessibiliteItems.ts +1 -1
- package/src/components/FileList/AccessibiliteItems.ts +1 -1
- package/src/components/FilePreview/AccessibiliteItems.ts +1 -1
- package/src/components/FileUpload/AccessibiliteItems.ts +1 -1
- package/src/components/FilterInline/AccessibiliteItems.ts +1 -1
- package/src/components/FilterSideBar/AccessibiliteItems.ts +1 -1
- package/src/components/FilterSideBar/FilterSideBar.vue +108 -90
- package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +27 -0
- package/src/components/FilterSideBar/tests/__snapshots__/FilterSideBar.spec.ts.snap +114 -109
- package/src/components/FooterBar/AccessibiliteItems.ts +1 -1
- package/src/components/FooterBar/FooterBar.vue +2 -1
- package/src/components/FranceConnectBtn/AccessibiliteItems.ts +1 -1
- package/src/components/HeaderBar/AccessibiliteItems.ts +1 -1
- package/src/components/HeaderBar/HeaderBurgerMenu/AccessibiliteItems.ts +1 -1
- package/src/components/HeaderLoading/AccessibiliteItems.ts +1 -1
- package/src/components/HeaderToolbar/AccessibiliteItems.ts +1 -1
- package/src/components/LangBtn/AccessibiliteItems.ts +1 -1
- package/src/components/Logo/Accessibilite.stories.ts +4 -0
- package/src/components/Logo/AccessibiliteItems.ts +1 -1
- package/src/components/LogoBrandSection/AccessibiliteItems.ts +1 -1
- package/src/components/MaintenancePage/AccessibiliteItems.ts +1 -1
- package/src/components/NirField/AccessibiliteItems.ts +1 -1
- package/src/components/NotFoundPage/AccessibiliteItems.ts +1 -1
- package/src/components/NotificationBar/AccessibiliteItems.ts +1 -1
- package/src/components/PageContainer/AccessibiliteItems.ts +1 -1
- package/src/components/PaginatedTable/AccessibiliteItems.ts +1 -1
- package/src/components/PaginatedTable/PaginatedTable.stories.ts +19 -0
- package/src/components/PaginatedTable/PaginatedTable.vue +51 -13
- package/src/components/PaginatedTable/tests/PaginatedTable.spec.ts +0 -2
- package/src/components/PasswordField/AccessibiliteItems.ts +1 -1
- package/src/components/PeriodField/AccessibiliteItems.ts +1 -1
- package/src/components/PeriodField/PeriodField.vue +13 -1
- package/src/components/PhoneField/AccessibiliteItems.ts +1 -1
- package/src/components/RangeField/AccessibiliteItems.ts +1 -1
- package/src/components/RatingPicker/AccessibiliteItems.ts +1 -1
- package/src/components/SearchListField/AccessibiliteItems.ts +1 -1
- package/src/components/SelectBtnField/AccessibiliteItems.ts +1 -1
- package/src/components/SkipLink/AccessibiliteItems.ts +1 -1
- package/src/components/SocialMediaLinks/AccessibiliteItems.ts +1 -1
- package/src/components/SubHeader/AccessibiliteItems.ts +1 -1
- package/src/components/SyAlert/AccessibiliteItems.ts +1 -1
- package/src/components/TableToolbar/AccessibiliteItems.ts +1 -1
- package/src/components/TableToolbar/TableToolbar.stories.ts +110 -56
- package/src/components/Tables/SyServerTable/FilterRules.stories.ts +83 -0
- package/src/components/Tables/SyServerTable/SyServerTable.mdx +160 -0
- package/src/components/Tables/SyServerTable/SyServerTable.stories.ts +2887 -0
- package/src/components/Tables/SyServerTable/SyServerTable.vue +302 -0
- package/src/components/Tables/SyServerTable/tests/SyServerTable.spec.ts +450 -0
- package/src/components/Tables/SyServerTable/tests/__snapshots__/SyServerTable.spec.ts.snap +521 -0
- package/src/components/Tables/SyTable/FilterRules.stories.ts +235 -0
- package/src/components/Tables/SyTable/SyTable.mdx +129 -0
- package/src/components/Tables/SyTable/SyTable.stories.ts +1966 -0
- package/src/components/Tables/SyTable/SyTable.vue +317 -0
- package/src/components/Tables/SyTable/tests/SyTable.spec.ts +345 -0
- package/src/components/Tables/SyTable/tests/__snapshots__/SyTable.spec.ts.snap +521 -0
- package/src/components/Tables/common/SyTableFilter.vue +342 -0
- package/src/components/Tables/common/TableHeader.vue +221 -0
- package/src/components/Tables/common/constants/StateEnum.ts +6 -0
- package/src/components/Tables/common/filters/DateFilter.vue +140 -0
- package/src/components/Tables/common/filters/NumberFilter.vue +234 -0
- package/src/components/Tables/common/filters/PeriodFilter.vue +147 -0
- package/src/components/Tables/common/filters/SelectFilter.vue +126 -0
- package/src/components/Tables/common/filters/TextFilter.vue +191 -0
- package/src/components/Tables/common/filters/tests/DateFilter.spec.ts +187 -0
- package/src/components/Tables/common/filters/tests/NumberFilter.spec.ts +280 -0
- package/src/components/Tables/common/filters/tests/PeriodFilter.spec.ts +192 -0
- package/src/components/Tables/common/filters/tests/SelectFilter.spec.ts +219 -0
- package/src/components/Tables/common/filters/tests/TextFilter.spec.ts +260 -0
- package/src/components/Tables/common/formatters.ts +72 -0
- package/src/components/Tables/common/locales.ts +7 -0
- package/src/components/Tables/common/tableAccessibilityUtils.ts +61 -0
- package/src/components/Tables/common/tableFilterUtils.ts +327 -0
- package/src/components/Tables/common/tableStorageUtils.ts +102 -0
- package/src/components/Tables/common/tableStyles.scss +54 -0
- package/src/components/Tables/common/tableUtils.ts +115 -0
- package/src/components/Tables/common/tests/SyTableFilter.spec.ts +312 -0
- package/src/components/Tables/common/tests/resize.spec.ts +161 -0
- package/src/components/Tables/common/tests/tableFilterUtils.spec.ts +106 -0
- package/src/components/Tables/common/tests/tableUtils.spec.ts +272 -0
- package/src/components/Tables/common/types.ts +81 -0
- package/src/components/Tables/common/useTableFilter.ts +19 -0
- package/src/components/Tables/index.ts +3 -0
- package/src/components/UploadWorkflow/AccessibiliteItems.ts +1 -1
- package/src/components/UserMenuBtn/AccessibiliteItems.ts +1 -1
- package/src/components/index.ts +3 -1
- package/src/composables/date/useDateFormatDayjs.ts +8 -3
- package/src/composables/date/useDateInitializationDayjs.ts +28 -36
- package/src/composables/rules/useFieldValidation.ts +1 -2
- package/src/designTokens/index.ts +4 -0
- package/src/designTokens/tokens/cnam/cnamFonts.ts +140 -0
- package/src/designTokens/tokens/pa/paFonts.ts +140 -0
- package/src/designTokens/utils/createFontVariables.ts +143 -0
- package/src/designTokens/utils/index.ts +2 -1
- package/src/stories/Demarrer/Accueil.stories.ts +12 -3
- package/src/utils/rules/isHolidayDay/IsHolidayDay.stories.ts +1 -1
- package/src/utils/rules/isRequired/index.ts +2 -1
- package/src/vite-env.d.ts +12 -0
- package/src/vuetifyConfig.ts +10 -3
- package/dist/components/BackToTopBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/ChipList/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/CollapsibleList/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/ContextualMenu/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/CookieBanner/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/CopyBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/Customs/SyBtnSelect/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/Customs/SyInputSelect/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/Customs/SySelect/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/Customs/SyTextField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/DataList/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/DataListGroup/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/DatePicker/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/DialogBox/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/DownloadBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/ErrorPage/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/ExternalLinks/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FileList/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FilePreview/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FileUpload/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FilterInline/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FilterSideBar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FooterBar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/FranceConnectBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/HeaderBar/HeaderBurgerMenu/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/HeaderBar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/HeaderLoading/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/HeaderToolbar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/LangBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/Logo/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/LogoBrandSection/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/MaintenancePage/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/NirField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/NotFoundPage/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/NotificationBar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/PageContainer/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/PaginatedTable/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/PasswordField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/PeriodField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/PhoneField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/RangeField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/RatingPicker/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SearchListField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SelectBtnField/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SkipLink/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SocialMediaLinks/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SubHeader/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/SyAlert/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/TableToolbar/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/UploadWorkflow/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/dist/components/UserMenuBtn/constants/ExpertiseLevelEnum.d.ts +0 -4
- package/src/components/BackBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/BackToTopBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/ChipList/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/CollapsibleList/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/ContextualMenu/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/CookieBanner/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/CopyBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/Customs/SyBtnSelect/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/Customs/SyInputSelect/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/Customs/SySelect/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/Customs/SyTextField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/DataList/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/DataListGroup/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/DatePicker/DatePicker.mdx +0 -222
- package/src/components/DatePicker/DateTextInput.vue +0 -504
- package/src/components/DatePicker/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/DialogBox/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/DownloadBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/ErrorPage/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/ExternalLinks/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FileList/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FilePreview/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FileUpload/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FilterInline/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FilterSideBar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FooterBar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/FranceConnectBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/HeaderBar/HeaderBurgerMenu/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/HeaderBar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/HeaderLoading/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/HeaderToolbar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/LangBtn/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/Logo/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/LogoBrandSection/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/MaintenancePage/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/NirField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/NotFoundPage/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/NotificationBar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/PageContainer/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/PaginatedTable/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/PasswordField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/PeriodField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/PhoneField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/RangeField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/RatingPicker/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SearchListField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SelectBtnField/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SkipLink/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SocialMediaLinks/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SubHeader/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/SyAlert/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/TableToolbar/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/UploadWorkflow/constants/ExpertiseLevelEnum.ts +0 -4
- package/src/components/UserMenuBtn/constants/ExpertiseLevelEnum.ts +0 -4
- /package/src/components/DatePicker/{examples → playground}/DatePickerHolidayRule.vue +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ref, watch, type Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type ViewMode = 'month' | 'year' | 'months' | undefined
|
|
4
|
+
|
|
5
|
+
export interface ViewModeReturn {
|
|
6
|
+
currentViewMode: Ref<ViewMode>
|
|
7
|
+
handleViewModeUpdate: (newMode: ViewMode) => void
|
|
8
|
+
handleYearUpdate: () => void
|
|
9
|
+
handleMonthUpdate: () => void
|
|
10
|
+
resetViewMode: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Composable pour gérer le mode d'affichage du DatePicker (année, mois, jour)
|
|
15
|
+
* Utilisé pour contrôler le comportement du DatePicker, notamment pour les dates de naissance
|
|
16
|
+
*
|
|
17
|
+
* @param isBirthDateGetter - Une fonction qui retourne la valeur actuelle de isBirthDate
|
|
18
|
+
*/
|
|
19
|
+
export function useDatePickerViewMode(isBirthDateGetter: () => boolean): ViewModeReturn {
|
|
20
|
+
// Variable pour suivre le mode d'affichage actuel du DatePicker
|
|
21
|
+
const currentViewMode = ref<ViewMode>(isBirthDateGetter() ? 'year' : 'month')
|
|
22
|
+
|
|
23
|
+
// Mettre à jour le mode d'affichage quand isBirthDate change
|
|
24
|
+
watch(isBirthDateGetter, (newValue) => {
|
|
25
|
+
currentViewMode.value = newValue ? 'year' : 'month'
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Fonction pour gérer le changement de mode d'affichage
|
|
29
|
+
const handleViewModeUpdate = (newMode: ViewMode) => {
|
|
30
|
+
currentViewMode.value = newMode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Fonction pour gérer la sélection de l'année quand isBirthDate est true
|
|
34
|
+
const handleYearUpdate = () => {
|
|
35
|
+
if (isBirthDateGetter()) {
|
|
36
|
+
// Après la sélection de l'année, passer automatiquement à la sélection du mois
|
|
37
|
+
currentViewMode.value = 'months'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Fonction pour gérer la sélection du mois quand isBirthDate est true
|
|
42
|
+
const handleMonthUpdate = () => {
|
|
43
|
+
if (isBirthDateGetter()) {
|
|
44
|
+
// Après la sélection du mois, passer automatiquement à la sélection du jour
|
|
45
|
+
currentViewMode.value = undefined
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Fonction pour réinitialiser le mode d'affichage (utile lors de la fermeture du DatePicker)
|
|
50
|
+
const resetViewMode = () => {
|
|
51
|
+
currentViewMode.value = isBirthDateGetter() ? 'year' : 'month'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
currentViewMode,
|
|
56
|
+
handleViewModeUpdate,
|
|
57
|
+
handleYearUpdate,
|
|
58
|
+
handleMonthUpdate,
|
|
59
|
+
resetViewMode,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type Ref, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Composable pour gérer la visibilité et les interactions avec le DatePicker
|
|
5
|
+
*
|
|
6
|
+
* @param options - Options de configuration
|
|
7
|
+
* @returns Fonctions pour gérer la visibilité du DatePicker
|
|
8
|
+
*/
|
|
9
|
+
export const useDatePickerVisibility = (options: {
|
|
10
|
+
// Propriétés de configuration
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
readonly?: boolean
|
|
13
|
+
textFieldActivator?: boolean
|
|
14
|
+
|
|
15
|
+
// Références réactives
|
|
16
|
+
isDatePickerVisible: Ref<boolean>
|
|
17
|
+
isManualInputActive: Ref<boolean>
|
|
18
|
+
hasInteracted: Ref<boolean>
|
|
19
|
+
|
|
20
|
+
// Fonctions
|
|
21
|
+
updateAccessibility: () => void
|
|
22
|
+
validateDates: () => void
|
|
23
|
+
|
|
24
|
+
// Émetteurs d'événements
|
|
25
|
+
emitClosed: () => void
|
|
26
|
+
emitFocus: () => void
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
disabled = false,
|
|
30
|
+
readonly = false,
|
|
31
|
+
textFieldActivator = false,
|
|
32
|
+
isDatePickerVisible,
|
|
33
|
+
isManualInputActive,
|
|
34
|
+
hasInteracted,
|
|
35
|
+
updateAccessibility,
|
|
36
|
+
validateDates,
|
|
37
|
+
emitClosed,
|
|
38
|
+
emitFocus,
|
|
39
|
+
} = options
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Bascule l'affichage du DatePicker
|
|
43
|
+
*/
|
|
44
|
+
const toggleDatePicker = () => {
|
|
45
|
+
if (disabled || readonly) return
|
|
46
|
+
|
|
47
|
+
isDatePickerVisible.value = !isDatePickerVisible.value
|
|
48
|
+
|
|
49
|
+
if (isDatePickerVisible.value) {
|
|
50
|
+
// Mettre à jour l'accessibilité après l'ouverture du DatePicker
|
|
51
|
+
nextTick(() => {
|
|
52
|
+
updateAccessibility()
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
emitClosed()
|
|
57
|
+
validateDates()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Ouvre le DatePicker s'il n'est pas déjà visible
|
|
63
|
+
*/
|
|
64
|
+
const openDatePicker = () => {
|
|
65
|
+
if (!isDatePickerVisible.value) {
|
|
66
|
+
toggleDatePicker()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ouvre le DatePicker lors d'un clic sur le champ de texte
|
|
72
|
+
*/
|
|
73
|
+
const openDatePickerOnClick = () => {
|
|
74
|
+
if (textFieldActivator) {
|
|
75
|
+
openDatePicker()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Gère le focus sur le champ de texte
|
|
81
|
+
*/
|
|
82
|
+
const openDatePickerOnFocus = () => {
|
|
83
|
+
// Only open the DatePicker if textFieldActivator is true
|
|
84
|
+
if (textFieldActivator) {
|
|
85
|
+
openDatePicker()
|
|
86
|
+
}
|
|
87
|
+
// Always emit the focus event
|
|
88
|
+
emitFocus()
|
|
89
|
+
isManualInputActive.value = true
|
|
90
|
+
hasInteracted.value = true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gère le clic sur l'icône du DatePicker
|
|
95
|
+
*/
|
|
96
|
+
const openDatePickerOnIconClick = () => {
|
|
97
|
+
toggleDatePicker()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Gère les clics en dehors du DatePicker pour le fermer
|
|
102
|
+
*/
|
|
103
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
104
|
+
if (!isDatePickerVisible.value) return
|
|
105
|
+
|
|
106
|
+
const target = event.target as HTMLElement
|
|
107
|
+
const container = target.closest('.date-picker-container')
|
|
108
|
+
|
|
109
|
+
// Si on clique dans le conteneur du DatePicker, on ne fait rien
|
|
110
|
+
if (container) return
|
|
111
|
+
emitClosed()
|
|
112
|
+
// Déclencher la validation à la fermeture
|
|
113
|
+
validateDates()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Gestion des événements de clic en dehors du DatePicker
|
|
117
|
+
onMounted(() => {
|
|
118
|
+
document.addEventListener('click', handleClickOutside)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
onBeforeUnmount(() => {
|
|
122
|
+
document.removeEventListener('click', handleClickOutside)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Gère l'ouverture du DatePicker lors de l'appui sur Entrée ou Espace
|
|
127
|
+
*/
|
|
128
|
+
const handleKeyboardNavigation = (event: KeyboardEvent) => {
|
|
129
|
+
if ((event.key === 'Enter' || event.key === ' ') && !disabled && !readonly) {
|
|
130
|
+
event.preventDefault() // Empêcher le comportement par défaut
|
|
131
|
+
openDatePicker()
|
|
132
|
+
return true
|
|
133
|
+
}
|
|
134
|
+
return false
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
toggleDatePicker,
|
|
139
|
+
openDatePicker,
|
|
140
|
+
openDatePickerOnClick,
|
|
141
|
+
openDatePickerOnFocus,
|
|
142
|
+
openDatePickerOnIconClick,
|
|
143
|
+
handleClickOutside,
|
|
144
|
+
handleKeyboardNavigation,
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { ref, computed } from 'vue'
|
|
2
|
+
import dayjs from 'dayjs'
|
|
3
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
|
4
|
+
|
|
5
|
+
// Initialiser les plugins dayjs
|
|
6
|
+
dayjs.extend(customParseFormat)
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Composable pour gérer la saisie manuelle des plages de dates
|
|
10
|
+
* Permet de saisir et formater correctement une plage de dates au format "date1 - date2"
|
|
11
|
+
*/
|
|
12
|
+
export function useDateRangeInput(
|
|
13
|
+
format: string,
|
|
14
|
+
isRangeMode: boolean,
|
|
15
|
+
parseDate: (dateStr: string, format: string) => Date | null,
|
|
16
|
+
formatDate: (date: Date, format: string) => string,
|
|
17
|
+
) {
|
|
18
|
+
// État pour suivre si nous sommes en train de saisir la première ou la deuxième date
|
|
19
|
+
const isEditingSecondDate = ref(false)
|
|
20
|
+
// Stockage temporaire pour la première date saisie
|
|
21
|
+
const firstDate = ref<Date | null>(null)
|
|
22
|
+
// Stockage temporaire pour la deuxième date saisie
|
|
23
|
+
const secondDate = ref<Date | null>(null)
|
|
24
|
+
// Séparateur de plage
|
|
25
|
+
const rangeSeparator = ' - '
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Vérifie si une chaîne de caractères contient un séparateur de plage
|
|
29
|
+
*/
|
|
30
|
+
const hasRangeSeparator = (value: string): boolean => {
|
|
31
|
+
return value.includes(rangeSeparator)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Extrait les deux parties d'une plage de dates
|
|
36
|
+
*/
|
|
37
|
+
const extractRangeParts = (value: string): [string, string] => {
|
|
38
|
+
const parts = value.split(rangeSeparator)
|
|
39
|
+
return [
|
|
40
|
+
parts[0]?.trim() || '',
|
|
41
|
+
parts[1]?.trim() || '',
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Formate une plage de dates pour l'affichage
|
|
47
|
+
*/
|
|
48
|
+
const formatRangeForDisplay = (startDate: Date | null, endDate: Date | null): string => {
|
|
49
|
+
if (!startDate) return ''
|
|
50
|
+
if (!endDate) return `${formatDate(startDate, format)}${rangeSeparator}`
|
|
51
|
+
return `${formatDate(startDate, format)}${rangeSeparator}${formatDate(endDate, format)}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Analyse une chaîne de caractères pour en extraire une plage de dates
|
|
56
|
+
* Retourne un tableau contenant les dates de début et de fin
|
|
57
|
+
*/
|
|
58
|
+
const parseRangeInput = (value: string): [Date | null, Date | null] => {
|
|
59
|
+
if (!value) return [null, null]
|
|
60
|
+
|
|
61
|
+
// Si la valeur contient un séparateur de plage
|
|
62
|
+
if (hasRangeSeparator(value)) {
|
|
63
|
+
const [startStr, endStr] = extractRangeParts(value)
|
|
64
|
+
const startDate = parseDate(startStr, format)
|
|
65
|
+
const endDate = parseDate(endStr, format)
|
|
66
|
+
return [startDate, endDate]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Si la valeur ne contient pas de séparateur, c'est une seule date
|
|
70
|
+
const singleDate = parseDate(value, format)
|
|
71
|
+
return [singleDate, null]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Gère la saisie manuelle d'une plage de dates
|
|
76
|
+
* @param inputValue Valeur actuelle du champ de saisie
|
|
77
|
+
* @param newValue Nouvelle valeur saisie
|
|
78
|
+
* @param cursorPosition Position actuelle du curseur (optionnel)
|
|
79
|
+
* @returns Objet contenant les informations sur la plage de dates
|
|
80
|
+
*/
|
|
81
|
+
const handleRangeInput = (inputValue: string, newValue: string, cursorPosition?: number): {
|
|
82
|
+
formattedValue: string
|
|
83
|
+
dates: [Date | null, Date | null]
|
|
84
|
+
isComplete: boolean
|
|
85
|
+
justCompletedFirstDate?: boolean
|
|
86
|
+
cursorPosition?: number
|
|
87
|
+
} => {
|
|
88
|
+
// Si le mode plage n'est pas activé, traiter comme une date unique
|
|
89
|
+
if (!isRangeMode) {
|
|
90
|
+
const date = parseDate(newValue, format)
|
|
91
|
+
return {
|
|
92
|
+
formattedValue: date ? formatDate(date, format) : newValue,
|
|
93
|
+
dates: [date, null],
|
|
94
|
+
isComplete: !!date,
|
|
95
|
+
cursorPosition: cursorPosition,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Cas spécial : si la valeur précédente se terminait par un séparateur et que la nouvelle valeur
|
|
100
|
+
// contient du texte après le séparateur, c'est qu'on commence à saisir la seconde date
|
|
101
|
+
if (inputValue && inputValue.endsWith(rangeSeparator)
|
|
102
|
+
&& newValue.startsWith(inputValue)
|
|
103
|
+
&& newValue.length > inputValue.length) {
|
|
104
|
+
// On est en train de saisir la seconde date pour la première fois
|
|
105
|
+
isEditingSecondDate.value = true
|
|
106
|
+
|
|
107
|
+
// Extraire la première date et le nouveau caractère saisi
|
|
108
|
+
const firstPart = inputValue.substring(0, inputValue.length - rangeSeparator.length)
|
|
109
|
+
const firstDateObj = parseDate(firstPart, format)
|
|
110
|
+
firstDate.value = firstDateObj
|
|
111
|
+
|
|
112
|
+
// Extraire le caractère nouvellement saisi (après le séparateur)
|
|
113
|
+
const secondPart = newValue.substring(inputValue.length)
|
|
114
|
+
secondDate.value = parseDate(secondPart, format)
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
formattedValue: `${firstPart}${rangeSeparator}${secondPart}`,
|
|
118
|
+
dates: [firstDateObj, secondDate.value],
|
|
119
|
+
isComplete: false,
|
|
120
|
+
cursorPosition: newValue.length,
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Si la valeur contient déjà un séparateur de plage
|
|
125
|
+
if (hasRangeSeparator(newValue)) {
|
|
126
|
+
const [startStr, endStr] = extractRangeParts(newValue)
|
|
127
|
+
const startDate = parseDate(startStr, format)
|
|
128
|
+
const endDate = parseDate(endStr, format)
|
|
129
|
+
|
|
130
|
+
// Mettre à jour les dates temporaires
|
|
131
|
+
firstDate.value = startDate
|
|
132
|
+
secondDate.value = endDate
|
|
133
|
+
|
|
134
|
+
// Déterminer si nous sommes en train d'éditer la deuxième date
|
|
135
|
+
isEditingSecondDate.value = !!startDate && startStr.length >= format.length
|
|
136
|
+
|
|
137
|
+
// Formater correctement la valeur
|
|
138
|
+
const formattedStart = startDate ? formatDate(startDate, format) : startStr
|
|
139
|
+
const formattedValue = `${formattedStart}${rangeSeparator}${endStr}`
|
|
140
|
+
|
|
141
|
+
// Calculer la nouvelle position du curseur en fonction de la position actuelle
|
|
142
|
+
let newCursorPosition = cursorPosition
|
|
143
|
+
|
|
144
|
+
// Si la position du curseur est dans la première partie de la date
|
|
145
|
+
if (cursorPosition !== undefined) {
|
|
146
|
+
const separatorPos = inputValue.indexOf(rangeSeparator)
|
|
147
|
+
if (separatorPos !== -1 && cursorPosition <= separatorPos) {
|
|
148
|
+
// Ajuster la position si la première partie a été formatée
|
|
149
|
+
if (startStr !== formattedStart) {
|
|
150
|
+
// Conserver la position relative dans la première partie
|
|
151
|
+
const relativePos = Math.min(cursorPosition, startStr.length)
|
|
152
|
+
newCursorPosition = Math.min(relativePos, formattedStart.length)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (separatorPos !== -1) {
|
|
156
|
+
// Le curseur est dans la seconde partie
|
|
157
|
+
// Conserver la position relative après le séparateur
|
|
158
|
+
const posAfterSeparator = cursorPosition - (separatorPos + rangeSeparator.length)
|
|
159
|
+
newCursorPosition = formattedStart.length + rangeSeparator.length + Math.min(posAfterSeparator, endStr.length)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
formattedValue,
|
|
165
|
+
dates: [startDate, endDate],
|
|
166
|
+
isComplete: !!startDate && !!endDate,
|
|
167
|
+
cursorPosition: newCursorPosition,
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Si nous sommes déjà en train d'éditer la deuxième date
|
|
172
|
+
// (ce cas ne devrait pas arriver souvent car la valeur devrait contenir un séparateur)
|
|
173
|
+
if (isEditingSecondDate.value && firstDate.value) {
|
|
174
|
+
// Formater la valeur pour afficher la première date + séparateur + nouvelle valeur
|
|
175
|
+
const formattedValue = `${formatDate(firstDate.value, format)}${rangeSeparator}${newValue}`
|
|
176
|
+
const secondDateParsed = parseDate(newValue, format)
|
|
177
|
+
secondDate.value = secondDateParsed
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
formattedValue,
|
|
181
|
+
dates: [firstDate.value, secondDateParsed],
|
|
182
|
+
isComplete: !!firstDate.value && !!secondDateParsed,
|
|
183
|
+
cursorPosition: cursorPosition !== undefined ? formatDate(firstDate.value, format).length + rangeSeparator.length + Math.min(cursorPosition, newValue.length) : undefined,
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Si nous éditons la première date
|
|
188
|
+
const date = parseDate(newValue, format)
|
|
189
|
+
firstDate.value = date
|
|
190
|
+
|
|
191
|
+
// Si la première date est complète, passer à la saisie de la deuxième date
|
|
192
|
+
if (date && newValue.length >= format.length) {
|
|
193
|
+
isEditingSecondDate.value = true
|
|
194
|
+
const formattedDate = formatDate(date, format)
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
formattedValue: `${formattedDate}${rangeSeparator}`,
|
|
198
|
+
dates: [date, null],
|
|
199
|
+
isComplete: false,
|
|
200
|
+
justCompletedFirstDate: true,
|
|
201
|
+
cursorPosition: formattedDate.length + rangeSeparator.length,
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
formattedValue: newValue,
|
|
207
|
+
dates: [date, null],
|
|
208
|
+
isComplete: false,
|
|
209
|
+
cursorPosition: cursorPosition,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Initialise l'état du composable avec des valeurs existantes
|
|
215
|
+
*/
|
|
216
|
+
const initializeWithDates = (startDate: Date | null, endDate: Date | null) => {
|
|
217
|
+
firstDate.value = startDate
|
|
218
|
+
secondDate.value = endDate
|
|
219
|
+
isEditingSecondDate.value = !!startDate && !!endDate
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Réinitialise l'état du composable
|
|
224
|
+
*/
|
|
225
|
+
const resetState = () => {
|
|
226
|
+
firstDate.value = null
|
|
227
|
+
secondDate.value = null
|
|
228
|
+
isEditingSecondDate.value = false
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Vérifie si une plage de dates est valide (la date de début est antérieure à la date de fin)
|
|
233
|
+
*/
|
|
234
|
+
const isValidRange = (startDate: Date | null, endDate: Date | null): boolean => {
|
|
235
|
+
if (!startDate || !endDate) return true
|
|
236
|
+
return startDate.getTime() <= endDate.getTime()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Vérifie si la plage actuelle est valide
|
|
241
|
+
*/
|
|
242
|
+
const currentRangeIsValid = computed(() => {
|
|
243
|
+
return isValidRange(firstDate.value, secondDate.value)
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Gère l'événement keydown pour filtrer les caractères non numériques
|
|
248
|
+
*
|
|
249
|
+
* @param event - Événement keydown
|
|
250
|
+
*/
|
|
251
|
+
const handleKeydown = (event: KeyboardEvent & { target: HTMLInputElement }): void => {
|
|
252
|
+
// Bloquer la saisie de caractères non numériques
|
|
253
|
+
// Autoriser uniquement : chiffres, touches de navigation, touches de modification et touches de contrôle
|
|
254
|
+
if (
|
|
255
|
+
// Si la touche n'est pas un chiffre
|
|
256
|
+
!/^\d$/.test(event.key)
|
|
257
|
+
// Et n'est pas une touche spéciale autorisée
|
|
258
|
+
&& ![
|
|
259
|
+
'Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown',
|
|
260
|
+
'Home', 'End', 'Tab', 'Escape', 'Enter',
|
|
261
|
+
'Control', 'Alt', 'Shift', 'Meta',
|
|
262
|
+
].includes(event.key)
|
|
263
|
+
// Et n'est pas une combinaison de touches (Ctrl+A, Ctrl+C, Ctrl+V, etc.)
|
|
264
|
+
&& !(event.ctrlKey || event.metaKey)
|
|
265
|
+
) {
|
|
266
|
+
// Empêcher la saisie de caractères non numériques
|
|
267
|
+
event.preventDefault()
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Gérer les touches spéciales pour le mode plage
|
|
272
|
+
if (isRangeMode) {
|
|
273
|
+
// Gérer la suppression des séparateurs de plage
|
|
274
|
+
if (event.key === 'Backspace') {
|
|
275
|
+
const input = event.target
|
|
276
|
+
if (!input.selectionStart || input.selectionStart !== input.selectionEnd) {
|
|
277
|
+
return
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const cursorPos = input.selectionStart
|
|
281
|
+
|
|
282
|
+
// Si on est juste après un séparateur de plage
|
|
283
|
+
if (cursorPos >= rangeSeparator.length
|
|
284
|
+
&& input.value.substring(cursorPos - rangeSeparator.length, cursorPos) === rangeSeparator) {
|
|
285
|
+
// Empêcher le comportement par défaut
|
|
286
|
+
event.preventDefault()
|
|
287
|
+
|
|
288
|
+
// Supprimer le séparateur complet
|
|
289
|
+
const newValue = input.value.substring(0, cursorPos - rangeSeparator.length)
|
|
290
|
+
+ input.value.substring(cursorPos)
|
|
291
|
+
|
|
292
|
+
// Mettre à jour la valeur (via l'événement input)
|
|
293
|
+
const inputEvent = new InputEvent('input', { bubbles: true, cancelable: true, data: newValue })
|
|
294
|
+
Object.defineProperty(inputEvent, 'target', { value: input, enumerable: true })
|
|
295
|
+
input.value = newValue
|
|
296
|
+
input.dispatchEvent(inputEvent)
|
|
297
|
+
|
|
298
|
+
// Positionner le curseur
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
const newCursorPos = cursorPos - rangeSeparator.length
|
|
301
|
+
input.setSelectionRange(newCursorPos, newCursorPos)
|
|
302
|
+
}, 0)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Gère l'événement paste pour filtrer les caractères non numériques
|
|
310
|
+
*
|
|
311
|
+
* @param event - Événement paste
|
|
312
|
+
*/
|
|
313
|
+
const handlePaste = (event: ClipboardEvent): void => {
|
|
314
|
+
// Récupérer le contenu du presse-papiers
|
|
315
|
+
const clipboardData = event.clipboardData
|
|
316
|
+
if (!clipboardData) return
|
|
317
|
+
|
|
318
|
+
// Extraire le texte
|
|
319
|
+
const pastedText = clipboardData.getData('text')
|
|
320
|
+
|
|
321
|
+
// Filtrer pour ne garder que les chiffres
|
|
322
|
+
const cleanedText = pastedText.replace(/[^0-9]/g, '')
|
|
323
|
+
|
|
324
|
+
// Si le texte collé ne contient pas de chiffres, annuler l'opération
|
|
325
|
+
if (cleanedText.length === 0) {
|
|
326
|
+
event.preventDefault()
|
|
327
|
+
return
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Si le texte a été modifié (des caractères non numériques ont été supprimés)
|
|
331
|
+
if (cleanedText !== pastedText) {
|
|
332
|
+
event.preventDefault()
|
|
333
|
+
|
|
334
|
+
// Insérer manuellement le texte nettoyé
|
|
335
|
+
const input = event.target as HTMLInputElement
|
|
336
|
+
if (!input) return
|
|
337
|
+
|
|
338
|
+
const start = input.selectionStart || 0
|
|
339
|
+
const end = input.selectionEnd || 0
|
|
340
|
+
|
|
341
|
+
// Construire la nouvelle valeur
|
|
342
|
+
const newValue = input.value.substring(0, start) + cleanedText + input.value.substring(end)
|
|
343
|
+
|
|
344
|
+
// Mettre à jour la valeur (via l'événement input)
|
|
345
|
+
const inputEvent = new InputEvent('input', { bubbles: true, cancelable: true, data: newValue })
|
|
346
|
+
Object.defineProperty(inputEvent, 'target', { value: input, enumerable: true })
|
|
347
|
+
input.value = newValue
|
|
348
|
+
input.dispatchEvent(inputEvent)
|
|
349
|
+
|
|
350
|
+
// Positionner le curseur après le texte collé
|
|
351
|
+
setTimeout(() => {
|
|
352
|
+
const newCursorPos = start + cleanedText.length
|
|
353
|
+
input.setSelectionRange(newCursorPos, newCursorPos)
|
|
354
|
+
}, 0)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
isEditingSecondDate,
|
|
360
|
+
firstDate,
|
|
361
|
+
secondDate,
|
|
362
|
+
rangeSeparator,
|
|
363
|
+
hasRangeSeparator,
|
|
364
|
+
extractRangeParts,
|
|
365
|
+
formatRangeForDisplay,
|
|
366
|
+
parseRangeInput,
|
|
367
|
+
handleRangeInput,
|
|
368
|
+
initializeWithDates,
|
|
369
|
+
resetState,
|
|
370
|
+
isValidRange,
|
|
371
|
+
currentRangeIsValid,
|
|
372
|
+
handleKeydown,
|
|
373
|
+
handlePaste,
|
|
374
|
+
}
|
|
375
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { computed, type Ref } from 'vue'
|
|
2
|
+
import type { DateObjectValue } from '../types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Composable pour gérer la validation des plages de dates
|
|
6
|
+
* Permet de vérifier si une plage de dates est valide (date de début avant date de fin)
|
|
7
|
+
*/
|
|
8
|
+
export function useDateRangeValidation(
|
|
9
|
+
selectedDates: Ref<DateObjectValue>,
|
|
10
|
+
displayRange: boolean,
|
|
11
|
+
) {
|
|
12
|
+
/**
|
|
13
|
+
* Vérifie si une plage de dates est valide (date de début avant date de fin)
|
|
14
|
+
*/
|
|
15
|
+
const isRangeValid = (startDate: Date | null, endDate: Date | null): boolean => {
|
|
16
|
+
if (!startDate || !endDate) return true // Si une des dates est manquante, considérer comme valide
|
|
17
|
+
return startDate.getTime() <= endDate.getTime()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Variable réactive pour suivre la validité de la plage de dates actuelle
|
|
22
|
+
*/
|
|
23
|
+
const currentRangeIsValid = computed(() => {
|
|
24
|
+
if (!displayRange || !selectedDates.value) return true
|
|
25
|
+
if (!Array.isArray(selectedDates.value)) return true
|
|
26
|
+
if (selectedDates.value.length < 2) return true
|
|
27
|
+
|
|
28
|
+
const [startDate, endDate] = selectedDates.value.length >= 2
|
|
29
|
+
? [selectedDates.value[0], selectedDates.value[selectedDates.value.length - 1]]
|
|
30
|
+
: [null, null]
|
|
31
|
+
|
|
32
|
+
return isRangeValid(startDate, endDate)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Fonction pour obtenir un message d'erreur si la plage n'est pas valide
|
|
37
|
+
*/
|
|
38
|
+
const getRangeValidationError = computed((): string => {
|
|
39
|
+
if (currentRangeIsValid.value) return ''
|
|
40
|
+
return 'La date de fin doit être postérieure ou égale à la date de début'
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
isRangeValid,
|
|
45
|
+
currentRangeIsValid,
|
|
46
|
+
getRangeValidationError,
|
|
47
|
+
}
|
|
48
|
+
}
|