@cnamts/synapse 1.0.0 → 1.0.2
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/README.md +1 -1
- package/dist/DateFilter-YWOTbfeL.js +98 -0
- package/dist/NumberFilter-DMmMgALM.js +121 -0
- package/dist/PeriodFilter-Bok5BHcn.js +112 -0
- package/dist/SelectFilter-BKud2WhN.js +136 -0
- package/dist/TextFilter-DvMf2thH.js +114 -0
- package/dist/{components/BackBtn → common}/constants/ExpertiseLevelEnum.d.ts +3 -0
- package/dist/components/Accordion/Accordion.d.ts +2 -1
- package/dist/components/Accordion/composables/useAccordionGroupCommunication.d.ts +5 -0
- package/dist/components/Accordion/composables/useAccordionKeyboardNavigation.d.ts +12 -0
- package/dist/components/Accordion/composables/useAccordionState.d.ts +13 -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/SyCheckbox/SyCheckbox.d.ts +85 -0
- package/dist/components/Customs/SyInputSelect/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
- package/dist/components/Customs/SySelect/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SySelect/SySelect.d.ts +33 -13
- package/dist/components/Customs/SyTextField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Customs/SyTextField/SyTextField.d.ts +2 -2
- 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 +4295 -0
- package/dist/components/DatePicker/{DatePicker.d.ts → DatePicker/DatePicker.d.ts} +158 -104
- package/dist/components/DatePicker/{DateTextInput.d.ts → DateTextInput/DateTextInput.d.ts} +35 -27
- package/dist/components/DatePicker/composables/index.d.ts +17 -0
- package/dist/components/DatePicker/composables/useAsteriskDisplay.d.ts +14 -0
- package/dist/components/DatePicker/composables/useDateAutoClamp.d.ts +16 -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 +19 -0
- package/dist/components/DatePicker/composables/useIconState.d.ts +17 -0
- package/dist/components/DatePicker/composables/useInputBlurHandler.d.ts +31 -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 +12 -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/NirField/NirField.d.ts +7 -3
- package/dist/components/NirField/nirValidation.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/PasswordField/PasswordField.d.ts +2 -0
- package/dist/components/PeriodField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PeriodField/PeriodField.d.ts +219 -41
- package/dist/components/PhoneField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/PhoneField/PhoneField.d.ts +2 -2
- package/dist/components/RangeField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/RangeField/RangeField.d.ts +2 -0
- package/dist/components/RatingPicker/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SearchListField/AccessibiliteItems.d.ts +1 -1
- package/dist/components/SearchListField/SearchListField.d.ts +9 -0
- 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/SyTextArea/SyTextArea.d.ts +2 -0
- package/dist/components/TableToolbar/AccessibiliteItems.d.ts +1 -1
- package/dist/components/Tables/SyServerTable/SyServerTable.d.ts +652 -0
- package/dist/components/Tables/SyTable/SyTable.d.ts +671 -0
- package/dist/components/Tables/common/SyTableFilter.d.ts +126 -0
- package/dist/components/Tables/common/SyTablePagination.d.ts +1636 -0
- package/dist/components/Tables/common/TableHeader.d.ts +15 -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/filters/getFilterComponent.d.ts +1 -0
- package/dist/components/Tables/common/filters/locales.d.ts +4 -0
- package/dist/components/Tables/common/filters/logics/date.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/number.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/period.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/select.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/text.d.ts +1 -0
- package/dist/components/Tables/common/formatters.d.ts +17 -0
- package/dist/components/Tables/common/locales.d.ts +28 -0
- package/dist/components/Tables/common/organizeColumns/OrganizeColumns.d.ts +267 -0
- package/dist/components/Tables/common/organizeColumns/sortHeaders.d.ts +2 -0
- package/dist/components/Tables/common/tableAccessibilityUtils.d.ts +8 -0
- package/dist/components/Tables/common/tableFilterUtils.d.ts +3 -0
- package/dist/components/Tables/common/tableStorageUtils.d.ts +69 -0
- package/dist/components/Tables/common/tableUtils.d.ts +79 -0
- package/dist/components/Tables/common/types.d.ts +91 -0
- package/dist/components/Tables/common/usePagination.d.ts +22 -0
- package/dist/components/Tables/common/useTableCheckbox.d.ts +20 -0
- package/dist/components/Tables/common/useTableFilter.d.ts +9 -0
- package/dist/components/Tables/common/useTableHeaders.d.ts +76 -0
- package/dist/components/Tables/common/useTableItems.d.ts +24 -0
- package/dist/components/Tables/common/useTableOptions.d.ts +18 -0
- package/dist/components/Tables/index.d.ts +2 -0
- package/dist/components/ToolbarContainer/ToolbarContainer.d.ts +11 -0
- package/dist/components/UploadWorkflow/AccessibiliteItems.d.ts +1 -1
- package/dist/components/UserMenuBtn/AccessibiliteItems.d.ts +1 -1
- package/dist/components/UserMenuBtn/UserMenuBtn.d.ts +9 -2
- package/dist/components/index.d.ts +9 -5
- package/dist/design-system-v3.js +102 -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-Cx8qG7YR.js +16344 -0
- package/dist/stories/Accessibilite/Vuetify/VuetifyItems.d.ts +14 -2
- package/dist/stories/DesignTokens/StylesTypographiques.stories.new.d.ts +8 -0
- package/dist/stories/DesignTokens/TypographyDisplay.d.ts +28 -0
- package/dist/stories/DesignTokens/vue-shims.d.ts +6 -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/common/imgs/accessibility-svgrepo-com.svg +4 -0
- package/src/components/Accordion/Accessibilite/AccessibilityGuide.mdx +249 -0
- package/src/components/Accordion/Accordion.vue +48 -76
- package/src/components/Accordion/composables/__tests__/useAccordionGroupCommunication.spec.ts +146 -0
- package/src/components/Accordion/composables/__tests__/useAccordionKeyboardNavigation.spec.ts +209 -0
- package/src/components/Accordion/composables/__tests__/useAccordionState.spec.ts +144 -0
- package/src/components/Accordion/composables/useAccordionGroupCommunication.ts +52 -0
- package/src/components/Accordion/composables/useAccordionKeyboardNavigation.ts +111 -0
- package/src/components/Accordion/composables/useAccordionState.ts +59 -0
- package/src/components/Accordion/tests/__snapshots__/accordion.spec.ts.snap +3 -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/SyCheckbox/Accessibilite.mdx +303 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.mdx +50 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.stories.ts +630 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.vue +326 -0
- package/src/components/Customs/SyCheckbox/tests/SyCheckbox.spec.ts +201 -0
- package/src/components/Customs/SyInputSelect/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +1 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +8 -1
- package/src/components/Customs/SySelect/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SySelect/SySelect.stories.ts +160 -0
- package/src/components/Customs/SySelect/SySelect.vue +292 -39
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +234 -2
- package/src/components/Customs/SyTextField/AccessibiliteItems.ts +1 -1
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +3 -2
- package/src/components/Customs/SyTextField/SyTextField.vue +19 -8
- 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 +1307 -0
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.vue +769 -204
- package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.events.spec.ts +161 -0
- package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.spec.ts +943 -0
- package/src/components/DatePicker/DatePicker/DatePicker.mdx +176 -0
- package/src/components/DatePicker/{DatePicker.stories.ts → DatePicker/DatePicker.stories.ts} +356 -519
- package/src/components/DatePicker/{DatePicker.vue → DatePicker/DatePicker.vue} +435 -89
- package/src/components/DatePicker/DatePicker/tests/DatePicker.events.spec.ts +189 -0
- package/src/components/DatePicker/{tests → DatePicker/tests}/DatePicker.spec.ts +0 -14
- 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 +320 -0
- package/src/components/DatePicker/DateTextInput/DateTextInput.events.spec.ts +148 -0
- package/src/components/DatePicker/DateTextInput/DateTextInput.range.spec.ts +278 -0
- package/src/components/DatePicker/{tests → DateTextInput}/DateTextInput.spec.ts +10 -7
- package/src/components/DatePicker/DateTextInput/DateTextInput.vue +1111 -0
- package/src/components/DatePicker/DateTextInput/NoCalendar.mdx +64 -0
- package/src/components/DatePicker/DateTextInput/NoCalendar.stories.ts +782 -0
- package/src/components/DatePicker/composables/index.ts +24 -0
- package/src/components/DatePicker/composables/tests/useDateAutoClamp.spec.ts +190 -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 +456 -0
- package/src/components/DatePicker/composables/tests/useManualDateValidation.spec.ts +233 -0
- package/src/components/DatePicker/composables/tests/useMonthButtonCustomization.spec.ts +125 -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/useAsteriskDisplay.ts +31 -0
- package/src/components/DatePicker/composables/useDateAutoClamp.ts +136 -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 +378 -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 +70 -0
- package/src/components/DatePicker/composables/useIconState.ts +53 -0
- package/src/components/DatePicker/composables/useInputBlurHandler.ts +165 -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 +187 -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/DiacriticPicker/DiacriticPicker.stories.ts +10 -0
- package/src/components/DialogBox/AccessibiliteItems.ts +1 -1
- package/src/components/DownloadBtn/AccessibiliteItems.ts +1 -1
- package/src/components/ErrorPage/Accessibilite.stories.ts +8 -0
- package/src/components/ErrorPage/AccessibiliteItems.ts +1 -1
- package/src/components/ErrorPage/ErrorPage.vue +12 -6
- package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +4 -4
- 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/NirField/NirField.mdx +22 -9
- package/src/components/NirField/NirField.stories.ts +26 -2
- package/src/components/NirField/NirField.vue +209 -22
- package/src/components/NirField/nirValidation.ts +17 -3
- package/src/components/NirField/tests/NirField.spec.ts +2 -2
- package/src/components/NotFoundPage/Accessibilite.stories.ts +8 -0
- package/src/components/NotFoundPage/AccessibiliteItems.ts +1 -1
- package/src/components/NotFoundPage/NotFoundPage.vue +2 -1
- package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +8 -6
- 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.mdx +2 -0
- 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/PasswordField/PasswordField.stories.ts +4 -0
- package/src/components/PasswordField/PasswordField.vue +3 -0
- package/src/components/PeriodField/AccessibiliteItems.ts +1 -1
- package/src/components/PeriodField/PeriodField.vue +15 -1
- package/src/components/PhoneField/AccessibiliteItems.ts +1 -1
- package/src/components/PhoneField/PhoneField.stories.ts +15 -15
- package/src/components/PhoneField/PhoneField.vue +1 -1
- package/src/components/RangeField/AccessibiliteItems.ts +1 -1
- package/src/components/RangeField/RangeField.stories.ts +9 -0
- package/src/components/RangeField/RangeField.vue +4 -0
- package/src/components/RangeField/tests/__snapshots__/RangeField.spec.ts.snap +12 -0
- package/src/components/RatingPicker/AccessibiliteItems.ts +1 -1
- package/src/components/SearchListField/AccessibiliteItems.ts +1 -1
- package/src/components/SearchListField/SearchListField.vue +5 -0
- 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/SyTextArea/SyTextArea.vue +3 -0
- package/src/components/SyTextArea/tests/SyTextArea.spec.ts +0 -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 +700 -0
- package/src/components/Tables/SyServerTable/SyServerTable.mdx +170 -0
- package/src/components/Tables/SyServerTable/SyServerTable.stories.ts +4354 -0
- package/src/components/Tables/SyServerTable/SyServerTable.vue +391 -0
- package/src/components/Tables/SyServerTable/tests/SyServerTable.spec.ts +702 -0
- package/src/components/Tables/SyTable/FilterRules.stories.ts +418 -0
- package/src/components/Tables/SyTable/SyTable.mdx +139 -0
- package/src/components/Tables/SyTable/SyTable.stories.ts +2754 -0
- package/src/components/Tables/SyTable/SyTable.vue +397 -0
- package/src/components/Tables/SyTable/tests/SyTable.spec.ts +707 -0
- package/src/components/Tables/common/SyTableFilter.vue +289 -0
- package/src/components/Tables/common/SyTablePagination.vue +375 -0
- package/src/components/Tables/common/TableHeader.vue +205 -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 +235 -0
- package/src/components/Tables/common/filters/TextFilter.vue +191 -0
- package/src/components/Tables/common/filters/getFilterComponent.ts +54 -0
- package/src/components/Tables/common/filters/locales.ts +4 -0
- package/src/components/Tables/common/filters/logics/date.ts +12 -0
- package/src/components/Tables/common/filters/logics/number.ts +48 -0
- package/src/components/Tables/common/filters/logics/period.ts +25 -0
- package/src/components/Tables/common/filters/logics/select.ts +27 -0
- package/src/components/Tables/common/filters/logics/tests/TextFilterLogic.spec.ts +177 -0
- package/src/components/Tables/common/filters/logics/text.ts +62 -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 +31 -0
- package/src/components/Tables/common/organizeColumns/OrganizeColumns.vue +269 -0
- package/src/components/Tables/common/organizeColumns/sortHeaders.ts +9 -0
- package/src/components/Tables/common/tableAccessibilityUtils.ts +61 -0
- package/src/components/Tables/common/tableFilterUtils.ts +75 -0
- package/src/components/Tables/common/tableStorageUtils.ts +127 -0
- package/src/components/Tables/common/tableStyles.scss +80 -0
- package/src/components/Tables/common/tableUtils.ts +102 -0
- package/src/components/Tables/common/tests/SyTableFilter.spec.ts +312 -0
- package/src/components/Tables/common/tests/SyTablePagination.spec.ts +170 -0
- package/src/components/Tables/common/tests/filterByRange.spec.ts +215 -0
- package/src/components/Tables/common/tests/resize.spec.ts +161 -0
- package/src/components/Tables/common/tests/tableFilterUtils.spec.ts +92 -0
- package/src/components/Tables/common/tests/tableUtils.spec.ts +228 -0
- package/src/components/Tables/common/types.ts +92 -0
- package/src/components/Tables/common/usePagination.ts +83 -0
- package/src/components/Tables/common/useTableCheckbox.ts +58 -0
- package/src/components/Tables/common/useTableFilter.ts +19 -0
- package/src/components/Tables/common/useTableHeaders.ts +88 -0
- package/src/components/Tables/common/useTableItems.ts +87 -0
- package/src/components/Tables/common/useTableOptions.ts +93 -0
- package/src/components/Tables/index.ts +3 -0
- package/src/components/ToolbarContainer/ToolbarContainer.mdx +16 -0
- package/src/components/ToolbarContainer/ToolbarContainer.stories.ts +675 -0
- package/src/components/ToolbarContainer/ToolbarContainer.vue +128 -0
- package/src/components/ToolbarContainer/tests/ToolbarContainer.spec.ts +156 -0
- package/src/components/UploadWorkflow/AccessibiliteItems.ts +1 -1
- package/src/components/UserMenuBtn/AccessibiliteItems.ts +1 -1
- package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +74 -0
- package/src/components/UserMenuBtn/UserMenuBtn.vue +19 -17
- package/src/components/index.ts +9 -5
- 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/Accessibilite/Aculturation/AuditDesignSystem.mdx +293 -20
- package/src/stories/Accessibilite/Aculturation/SensibilisationAccessibilite.mdx +448 -54
- package/src/stories/Accessibilite/Audit/RGAA.mdx +231 -23
- package/src/stories/Accessibilite/Avancement/Avancement.mdx +591 -7
- package/src/stories/Accessibilite/Avancement/Avancement.stories.ts +139 -38
- package/src/stories/Accessibilite/Introduction.mdx +258 -18
- package/src/stories/Accessibilite/KitDePreAudit/Echantillonnage.mdx +221 -31
- package/src/stories/Accessibilite/KitDePreAudit/Introduction.mdx +204 -22
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Introduction.mdx +537 -24
- package/src/stories/Accessibilite/KitDePreAudit/Outils/LecteursDEcran.mdx +577 -70
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Tanaguru.mdx +382 -31
- package/src/stories/Accessibilite/KitDePreAudit/Preaudit.mdx +419 -81
- package/src/stories/Accessibilite/Vuetify/Vuetify.mdx +132 -6
- package/src/stories/Accessibilite/Vuetify/Vuetify.stories.ts +370 -146
- package/src/stories/Accessibilite/Vuetify/VuetifyItems.ts +35 -57
- package/src/stories/Demarrer/Accueil.stories.ts +32 -8
- package/src/stories/DesignTokens/StylesTypographiques.mdx +10 -9
- package/src/stories/DesignTokens/StylesTypographiques.stories.new.ts +397 -0
- package/src/stories/DesignTokens/StylesTypographiques.stories.ts +397 -0
- package/src/stories/DesignTokens/TypographyDisplay.vue +155 -0
- package/src/stories/DesignTokens/vue-shims.d.ts +6 -0
- package/src/stories/GuideDuDev/LesBreackingChanges.mdx +0 -2
- package/src/stories/GuideDuDev/MigrationDepuisBridge.mdx +1 -1
- package/src/stories/GuideDuDev/MigrationDepuisVue2.mdx +1 -1
- package/src/stories/GuideDuDev/PortailAgent.mdx +10 -0
- package/src/stories/GuideDuDev/PortailAgent.stories.ts +506 -0
- package/src/stories/GuideDuDev/Theme.mdx +41 -0
- 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/PaginatedTable/tests/__snapshots__/PaginatedTable.spec.ts.snap +0 -886
- 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/stories/DesignTokens/ThemePA.mdx +0 -35
- /package/src/components/DatePicker/{examples → playground}/DatePickerHolidayRule.vue +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { type Ref, type ComponentPublicInstance } from 'vue'
|
|
2
|
+
import type { DateObjectValue } from '../types'
|
|
3
|
+
import { useDateInputEditing } from './useDateInputEditing'
|
|
4
|
+
|
|
5
|
+
export interface InputHandlerOptions {
|
|
6
|
+
// Configuration
|
|
7
|
+
format: string
|
|
8
|
+
displayRange: boolean
|
|
9
|
+
dateFormatReturn?: string
|
|
10
|
+
disableErrorHandling?: boolean
|
|
11
|
+
|
|
12
|
+
// Fonctions externes
|
|
13
|
+
parseDate: (dateStr: string, format: string) => Date | null
|
|
14
|
+
formatDate: (date: Date, format: string) => string
|
|
15
|
+
generateDateRange: (startDate: Date, endDate: Date) => Date[]
|
|
16
|
+
isDateComplete: (value: string) => boolean
|
|
17
|
+
|
|
18
|
+
// Références réactives
|
|
19
|
+
displayFormattedDate: Ref<string>
|
|
20
|
+
selectedDates: Ref<DateObjectValue>
|
|
21
|
+
isFormatting: Ref<boolean>
|
|
22
|
+
isManualInputActive: Ref<boolean>
|
|
23
|
+
isUpdatingFromInternal: Ref<boolean>
|
|
24
|
+
|
|
25
|
+
// Fonctions de validation
|
|
26
|
+
clearValidation: () => void
|
|
27
|
+
validateField: (value: unknown, rules?: unknown[], warningRules?: unknown[]) => unknown
|
|
28
|
+
|
|
29
|
+
// Fonctions d'émission
|
|
30
|
+
updateModel: (value: unknown) => void
|
|
31
|
+
emitInput: (value: string) => void
|
|
32
|
+
|
|
33
|
+
// Référence à l'élément input
|
|
34
|
+
inputRef: Ref<ComponentPublicInstance | null>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useInputHandler(options: InputHandlerOptions) {
|
|
38
|
+
const {
|
|
39
|
+
format,
|
|
40
|
+
displayRange,
|
|
41
|
+
dateFormatReturn,
|
|
42
|
+
disableErrorHandling,
|
|
43
|
+
parseDate,
|
|
44
|
+
formatDate,
|
|
45
|
+
generateDateRange,
|
|
46
|
+
isDateComplete,
|
|
47
|
+
displayFormattedDate,
|
|
48
|
+
selectedDates,
|
|
49
|
+
isFormatting,
|
|
50
|
+
isManualInputActive,
|
|
51
|
+
isUpdatingFromInternal,
|
|
52
|
+
clearValidation,
|
|
53
|
+
validateField,
|
|
54
|
+
updateModel,
|
|
55
|
+
emitInput,
|
|
56
|
+
inputRef,
|
|
57
|
+
} = options
|
|
58
|
+
|
|
59
|
+
// Nous n'utilisons pas directement useDateRangeInput car nous avons implémenté
|
|
60
|
+
// des fonctions spécifiques pour gérer les cas particuliers de la saisie en mode plage
|
|
61
|
+
|
|
62
|
+
// Utiliser le composable useDateInputEditing pour le formatage
|
|
63
|
+
const dateInputEditing = useDateInputEditing({
|
|
64
|
+
format,
|
|
65
|
+
updateDisplayValue: (value) => {
|
|
66
|
+
displayFormattedDate.value = value
|
|
67
|
+
emitInput(value)
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Met à jour la position du curseur dans l'élément input
|
|
73
|
+
*/
|
|
74
|
+
const updateCursorPosition = (inputElement: HTMLInputElement | null, position: number) => {
|
|
75
|
+
if (!inputElement) return
|
|
76
|
+
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
if (inputElement) {
|
|
79
|
+
const safePos = Math.min(position, inputElement.value.length)
|
|
80
|
+
inputElement.setSelectionRange(safePos, safePos)
|
|
81
|
+
inputElement.focus()
|
|
82
|
+
}
|
|
83
|
+
}, 0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Gère le cas spécial où la première date vient d'être complétée
|
|
88
|
+
* et nous devons passer à la saisie de la seconde date
|
|
89
|
+
*/
|
|
90
|
+
const handleFirstDateCompletion = (value: string): boolean => {
|
|
91
|
+
// Ne traiter que si nous sommes en mode plage
|
|
92
|
+
if (!displayRange) {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const previousValue = displayFormattedDate.value
|
|
97
|
+
|
|
98
|
+
// Vérifier si la valeur contient déjà un séparateur de plage
|
|
99
|
+
if (previousValue.includes(' - ') || value.includes(' - ')) {
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Vérifier si la date est complète
|
|
104
|
+
if (!isDateComplete(value)) {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let date: Date | null = null
|
|
109
|
+
|
|
110
|
+
if (value.charAt(value.length - 1) === '_') {
|
|
111
|
+
date = parseDate(value.substring(0, value.length - 1), format)
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
date = parseDate(value, format)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (date) {
|
|
118
|
+
// Formater la date pour s'assurer qu'elle est correctement formatée
|
|
119
|
+
const formattedDate = formatDate(date, format)
|
|
120
|
+
|
|
121
|
+
// Ajouter le séparateur de plage
|
|
122
|
+
const newValue = `${formattedDate} - `
|
|
123
|
+
displayFormattedDate.value = newValue
|
|
124
|
+
emitInput(newValue)
|
|
125
|
+
|
|
126
|
+
// Mettre à jour les dates sélectionnées (première date remplie, seconde vide)
|
|
127
|
+
selectedDates.value = [date, null]
|
|
128
|
+
|
|
129
|
+
// Mettre à jour la position du curseur après le séparateur
|
|
130
|
+
const inputElement = inputRef.value?.$el?.querySelector('input')
|
|
131
|
+
|
|
132
|
+
// Positionner le curseur après le séparateur ' - '
|
|
133
|
+
const cursorPosition = formattedDate.length + 3 // longueur de la date formatée + longueur du séparateur
|
|
134
|
+
|
|
135
|
+
// Utiliser setTimeout pour s'assurer que le positionnement du curseur se fait après le rendu
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
updateCursorPosition(inputElement, cursorPosition)
|
|
138
|
+
}, 0)
|
|
139
|
+
|
|
140
|
+
return true
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Gère le cas spécial où nous commençons à saisir la seconde date
|
|
148
|
+
*/
|
|
149
|
+
const handleStartingSecondDate = (value: string): boolean => {
|
|
150
|
+
const previousValue = displayFormattedDate.value
|
|
151
|
+
|
|
152
|
+
// Vérifier si la valeur précédente contient déjà un séparateur de plage
|
|
153
|
+
if (previousValue.includes(' - ')) {
|
|
154
|
+
// Si la valeur précédente se termine par le séparateur, c'est qu'on commence à saisir la seconde date
|
|
155
|
+
if (previousValue.endsWith(' - ') && value.length > previousValue.length) {
|
|
156
|
+
// La nouvelle valeur doit commencer par la première partie + séparateur
|
|
157
|
+
const firstPart = previousValue.substring(0, previousValue.length - 3) // Enlever ' - '
|
|
158
|
+
const secondPart = value.substring(previousValue.length)
|
|
159
|
+
|
|
160
|
+
// Formater la seconde partie avec le composable useDateInputEditing
|
|
161
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(secondPart, secondPart.length)
|
|
162
|
+
const newValue = `${firstPart} - ${formatted}`
|
|
163
|
+
displayFormattedDate.value = newValue
|
|
164
|
+
emitInput(newValue)
|
|
165
|
+
|
|
166
|
+
// Mettre à jour les dates sélectionnées
|
|
167
|
+
if (displayRange) {
|
|
168
|
+
// Récupérer la première date
|
|
169
|
+
const firstDate = parseDate(firstPart, format)
|
|
170
|
+
// Essayer de parser la seconde date (peut être incomplète)
|
|
171
|
+
const secondDate = parseDate(secondPart, format)
|
|
172
|
+
// Mettre à jour les dates sélectionnées
|
|
173
|
+
selectedDates.value = [firstDate, secondDate]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Mettre à jour la position du curseur après le séparateur et la seconde partie formatée
|
|
177
|
+
const inputElement = inputRef.value?.$el?.querySelector('input')
|
|
178
|
+
// Calculer la position du curseur : longueur de la première partie + longueur du séparateur + nouvelle position du curseur dans la seconde partie
|
|
179
|
+
const cursorPosition = firstPart.length + 3 + newPos
|
|
180
|
+
updateCursorPosition(inputElement, cursorPosition)
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Si nous avons déjà une partie de la seconde date, continuer à éditer cette partie
|
|
185
|
+
const parts = previousValue.split(' - ')
|
|
186
|
+
if (parts.length === 2 && parts[1].length > 0) {
|
|
187
|
+
// Vérifier si la nouvelle valeur contient la première partie et le séparateur
|
|
188
|
+
if (value.startsWith(parts[0] + ' - ')) {
|
|
189
|
+
// Extraire la nouvelle seconde partie
|
|
190
|
+
const secondPart = value.substring((parts[0] + ' - ').length)
|
|
191
|
+
|
|
192
|
+
// Formater la seconde partie avec le composable useDateInputEditing
|
|
193
|
+
const secondPartCursorPos = value.length - (parts[0].length + 3)
|
|
194
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(secondPart, secondPartCursorPos)
|
|
195
|
+
|
|
196
|
+
// Créer la nouvelle valeur formatée
|
|
197
|
+
const newValue = `${parts[0]} - ${formatted}`
|
|
198
|
+
displayFormattedDate.value = newValue
|
|
199
|
+
emitInput(newValue)
|
|
200
|
+
|
|
201
|
+
// Mettre à jour les dates sélectionnées
|
|
202
|
+
if (displayRange) {
|
|
203
|
+
// Récupérer la première date
|
|
204
|
+
const firstDate = parseDate(parts[0], format)
|
|
205
|
+
// Essayer de parser la seconde date (peut être incomplète)
|
|
206
|
+
const secondDate = parseDate(secondPart, format)
|
|
207
|
+
// Mettre à jour les dates sélectionnées
|
|
208
|
+
selectedDates.value = [firstDate, secondDate]
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Mettre à jour la position du curseur après le séparateur et la seconde partie formatée
|
|
212
|
+
const inputElement = inputRef.value?.$el?.querySelector('input')
|
|
213
|
+
// Calculer la position du curseur : longueur de la première partie + longueur du séparateur + nouvelle position du curseur dans la seconde partie
|
|
214
|
+
const cursorPosition = parts[0].length + 3 + newPos
|
|
215
|
+
updateCursorPosition(inputElement, cursorPosition)
|
|
216
|
+
return true
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return false
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Formate une plage de dates pendant la saisie
|
|
225
|
+
*/
|
|
226
|
+
const formatRangeInput = (value: string, cursorPos: number): { formattedInput: string, newCursorPos: number } => {
|
|
227
|
+
let formattedInput = value
|
|
228
|
+
let newCursorPos = cursorPos
|
|
229
|
+
|
|
230
|
+
// Si la valeur contient déjà un séparateur de plage
|
|
231
|
+
if (value.includes(' - ')) {
|
|
232
|
+
const parts = value.split(' - ')
|
|
233
|
+
if (parts.length === 2) {
|
|
234
|
+
// Déterminer quelle partie est en cours d'édition
|
|
235
|
+
const firstPartLength = parts[0].length
|
|
236
|
+
const separatorLength = 3 // ' - '
|
|
237
|
+
|
|
238
|
+
if (cursorPos <= firstPartLength) {
|
|
239
|
+
// Édition de la première partie
|
|
240
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(parts[0], cursorPos)
|
|
241
|
+
formattedInput = `${formatted} - ${parts[1]}`
|
|
242
|
+
newCursorPos = newPos
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
// Édition de la seconde partie
|
|
246
|
+
const secondPartCursorPos = cursorPos - (firstPartLength + separatorLength)
|
|
247
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(parts[1], secondPartCursorPos)
|
|
248
|
+
formattedInput = `${parts[0]} - ${formatted}`
|
|
249
|
+
newCursorPos = newPos + (firstPartLength + separatorLength)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// Pas de séparateur, formater normalement
|
|
255
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(value, cursorPos)
|
|
256
|
+
formattedInput = formatted
|
|
257
|
+
newCursorPos = newPos
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return { formattedInput, newCursorPos }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Met à jour les dates sélectionnées à partir d'une valeur formatée
|
|
265
|
+
*/
|
|
266
|
+
const updateSelectedDatesFromFormattedValue = (formattedInput: string) => {
|
|
267
|
+
if (displayRange && formattedInput.includes(' - ')) {
|
|
268
|
+
const parts = formattedInput.split(' - ')
|
|
269
|
+
if (parts.length === 2) {
|
|
270
|
+
const firstDate = parseDate(parts[0], format)
|
|
271
|
+
const secondDate = parseDate(parts[1], format)
|
|
272
|
+
selectedDates.value = [firstDate, secondDate]
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
const date = parseDate(formattedInput, format)
|
|
277
|
+
if (displayRange) {
|
|
278
|
+
selectedDates.value = date ? [date, null] : null
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
selectedDates.value = date
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Met à jour le modèle à partir des dates sélectionnées
|
|
288
|
+
*/
|
|
289
|
+
const updateModelFromSelectedDates = () => {
|
|
290
|
+
try {
|
|
291
|
+
isUpdatingFromInternal.value = true
|
|
292
|
+
|
|
293
|
+
const currentDates = Array.isArray(selectedDates.value)
|
|
294
|
+
? selectedDates.value
|
|
295
|
+
: (selectedDates.value ? [selectedDates.value] : [])
|
|
296
|
+
|
|
297
|
+
if (displayRange && currentDates.length >= 2 && currentDates[0] && currentDates[1]) {
|
|
298
|
+
// Générer toutes les dates entre les deux dates
|
|
299
|
+
const allDates = generateDateRange(currentDates[0], currentDates[1])
|
|
300
|
+
selectedDates.value = allDates
|
|
301
|
+
|
|
302
|
+
// Formater les dates pour le modèle
|
|
303
|
+
const returnFormat = dateFormatReturn || format
|
|
304
|
+
const modelValue = [
|
|
305
|
+
formatDate(currentDates[0], returnFormat),
|
|
306
|
+
formatDate(currentDates[1], returnFormat),
|
|
307
|
+
] as [string, string]
|
|
308
|
+
|
|
309
|
+
updateModel(modelValue)
|
|
310
|
+
|
|
311
|
+
// Valider les règles personnalisées si la saisie est complète
|
|
312
|
+
if (!disableErrorHandling && displayFormattedDate.value && isDateComplete(displayFormattedDate.value)) {
|
|
313
|
+
validateField(currentDates[0])
|
|
314
|
+
validateField(currentDates[1])
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else if (currentDates.length > 0 && currentDates[0]) {
|
|
318
|
+
const returnFormat = dateFormatReturn || format
|
|
319
|
+
const modelValue = formatDate(currentDates[0], returnFormat)
|
|
320
|
+
updateModel(modelValue)
|
|
321
|
+
|
|
322
|
+
// Valider les règles personnalisées si la saisie est complète
|
|
323
|
+
if (!disableErrorHandling && displayFormattedDate.value && isDateComplete(displayFormattedDate.value)) {
|
|
324
|
+
validateField(currentDates[0])
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
updateModel(null)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
isUpdatingFromInternal.value = false
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Gère l'entrée utilisateur en mode plage de dates
|
|
338
|
+
*/
|
|
339
|
+
const handleRangeInput = (event: Event) => {
|
|
340
|
+
const input = event.target as HTMLInputElement
|
|
341
|
+
const cursorPos = input.selectionStart || 0
|
|
342
|
+
const value = input.value
|
|
343
|
+
|
|
344
|
+
// Cas spéciaux pour la gestion des plages
|
|
345
|
+
if (handleFirstDateCompletion(value)) return
|
|
346
|
+
if (handleStartingSecondDate(value)) return
|
|
347
|
+
|
|
348
|
+
// Traitement normal pour les autres cas
|
|
349
|
+
const { formattedInput, newCursorPos } = formatRangeInput(value, cursorPos)
|
|
350
|
+
|
|
351
|
+
// Mettre à jour la valeur affichée
|
|
352
|
+
displayFormattedDate.value = formattedInput
|
|
353
|
+
emitInput(formattedInput)
|
|
354
|
+
|
|
355
|
+
// Mettre à jour les dates sélectionnées
|
|
356
|
+
updateSelectedDatesFromFormattedValue(formattedInput)
|
|
357
|
+
|
|
358
|
+
// Mettre à jour la position du curseur
|
|
359
|
+
const inputElement = inputRef.value?.$el?.querySelector('input')
|
|
360
|
+
updateCursorPosition(inputElement, newCursorPos)
|
|
361
|
+
|
|
362
|
+
// Réinitialiser les messages d'erreur
|
|
363
|
+
clearValidation()
|
|
364
|
+
|
|
365
|
+
// Mettre à jour le modèle en fonction des dates sélectionnées
|
|
366
|
+
const currentDates = Array.isArray(selectedDates.value)
|
|
367
|
+
? selectedDates.value
|
|
368
|
+
: (selectedDates.value ? [selectedDates.value] : [])
|
|
369
|
+
|
|
370
|
+
if (displayRange && currentDates.length >= 2 && currentDates[0] && currentDates[1]) {
|
|
371
|
+
updateModelFromSelectedDates()
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Gère l'entrée utilisateur en mode date simple
|
|
377
|
+
*/
|
|
378
|
+
const handleSingleDateInput = (event: Event) => {
|
|
379
|
+
const input = event.target as HTMLInputElement
|
|
380
|
+
const cursorPos = input.selectionStart || 0
|
|
381
|
+
const value = input.value
|
|
382
|
+
|
|
383
|
+
// Utiliser le composable useDateInputEditing pour formater la date
|
|
384
|
+
const { formatted, cursorPos: newPos } = dateInputEditing.formatDateInput(value, cursorPos)
|
|
385
|
+
|
|
386
|
+
// Mettre à jour la valeur affichée
|
|
387
|
+
displayFormattedDate.value = formatted
|
|
388
|
+
emitInput(formatted)
|
|
389
|
+
|
|
390
|
+
// Mettre à jour les dates sélectionnées
|
|
391
|
+
const date = parseDate(formatted, format)
|
|
392
|
+
selectedDates.value = date
|
|
393
|
+
|
|
394
|
+
// Mettre à jour la position du curseur
|
|
395
|
+
const inputElement = inputRef.value?.$el?.querySelector('input')
|
|
396
|
+
updateCursorPosition(inputElement, newPos)
|
|
397
|
+
|
|
398
|
+
// Réinitialiser les messages d'erreur
|
|
399
|
+
clearValidation()
|
|
400
|
+
|
|
401
|
+
// Mettre à jour le modèle si la date est complète
|
|
402
|
+
if (date && isDateComplete(formatted)) {
|
|
403
|
+
updateModelFromSelectedDates()
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Fonction principale pour gérer l'entrée utilisateur
|
|
409
|
+
*/
|
|
410
|
+
const handleInput = (event: Event) => {
|
|
411
|
+
if (isFormatting.value) return
|
|
412
|
+
if (!isManualInputActive.value) return
|
|
413
|
+
|
|
414
|
+
try {
|
|
415
|
+
isFormatting.value = true
|
|
416
|
+
|
|
417
|
+
if (displayRange) {
|
|
418
|
+
handleRangeInput(event)
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
handleSingleDateInput(event)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
finally {
|
|
425
|
+
isFormatting.value = false
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return {
|
|
430
|
+
handleInput,
|
|
431
|
+
updateModelFromSelectedDates,
|
|
432
|
+
updateCursorPosition,
|
|
433
|
+
formatRangeInput,
|
|
434
|
+
updateSelectedDatesFromFormattedValue,
|
|
435
|
+
}
|
|
436
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type Ref } from 'vue'
|
|
2
|
+
import { type ValidationResult } from '@/composables/validation/useValidation'
|
|
3
|
+
import { DATE_PICKER_MESSAGES } from '../constants/messages'
|
|
4
|
+
import { formatDate } from '@/utils/formatDate'
|
|
5
|
+
import dayjs from 'dayjs'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Composable pour la validation manuelle des dates saisies
|
|
9
|
+
*
|
|
10
|
+
* @param options - Options de configuration
|
|
11
|
+
* @returns Fonction pour valider la saisie manuelle de date
|
|
12
|
+
*/
|
|
13
|
+
export const useManualDateValidation = (options: {
|
|
14
|
+
// Propriétés de configuration
|
|
15
|
+
format: string
|
|
16
|
+
required?: boolean
|
|
17
|
+
disableErrorHandling?: boolean
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Règles personnalisées
|
|
19
|
+
customRules?: { type: string, options: any }[]
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Règles d'avertissement personnalisées
|
|
21
|
+
customWarningRules?: { type: string, options: any }[]
|
|
22
|
+
|
|
23
|
+
// Références réactives
|
|
24
|
+
hasInteracted: Ref<boolean>
|
|
25
|
+
errors: Ref<string[]>
|
|
26
|
+
|
|
27
|
+
// Fonctions de validation
|
|
28
|
+
clearValidation: () => void
|
|
29
|
+
validateDateFormat: (dateStr: string) => { isValid: boolean, message: string }
|
|
30
|
+
isDateComplete: (value: string) => boolean
|
|
31
|
+
parseDate: (dateStr: string, format: string) => Date | null
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Règles personnalisées
|
|
33
|
+
validateField: (value: any, rules?: any[], warningRules?: any[]) => ValidationResult
|
|
34
|
+
}) => {
|
|
35
|
+
const {
|
|
36
|
+
format,
|
|
37
|
+
required = false,
|
|
38
|
+
disableErrorHandling = false,
|
|
39
|
+
customRules = [],
|
|
40
|
+
customWarningRules = [],
|
|
41
|
+
hasInteracted,
|
|
42
|
+
errors,
|
|
43
|
+
clearValidation,
|
|
44
|
+
validateDateFormat,
|
|
45
|
+
isDateComplete,
|
|
46
|
+
parseDate,
|
|
47
|
+
validateField,
|
|
48
|
+
} = options
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Valide une saisie manuelle de date
|
|
52
|
+
*
|
|
53
|
+
* @param value - Chaîne de date à valider
|
|
54
|
+
* @returns Booléen indiquant si la saisie est valide
|
|
55
|
+
*/
|
|
56
|
+
const validateManualInput = (value: string): boolean => {
|
|
57
|
+
// Réinitialiser la validation
|
|
58
|
+
clearValidation()
|
|
59
|
+
|
|
60
|
+
// Vérifier si le champ est requis et vide
|
|
61
|
+
if (!value && required && hasInteracted.value) {
|
|
62
|
+
if (!disableErrorHandling) {
|
|
63
|
+
errors.value.push(DATE_PICKER_MESSAGES.ERROR_REQUIRED)
|
|
64
|
+
}
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Si le champ est vide et non requis, c'est valide
|
|
69
|
+
if (!value && !required) {
|
|
70
|
+
return true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Vérifier si la saisie est complète avant de valider le format
|
|
74
|
+
if (!isDateComplete(value)) {
|
|
75
|
+
// La saisie n'est pas complète, ne pas afficher d'erreur
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Valider le format de la date
|
|
80
|
+
const formatValidation = validateDateFormat(value)
|
|
81
|
+
if (!formatValidation.isValid) {
|
|
82
|
+
if (!disableErrorHandling && formatValidation.message) {
|
|
83
|
+
errors.value.push(formatValidation.message)
|
|
84
|
+
}
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Si le format est valide, vérifier si la date peut être parsée
|
|
89
|
+
const date = parseDate(value, format)
|
|
90
|
+
if (!date) {
|
|
91
|
+
// La date n'a pas pu être parsée
|
|
92
|
+
if (!disableErrorHandling) {
|
|
93
|
+
errors.value.push(`Format de date invalide (${format})`)
|
|
94
|
+
}
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Valider les règles personnalisées
|
|
99
|
+
if (!disableErrorHandling) {
|
|
100
|
+
// Pour maintenir la compatibilité avec les tests existants, nous devons appeler validateField
|
|
101
|
+
// avec tous les paramètres comme avant, mais nous devons aussi gérer correctement
|
|
102
|
+
// les règles personnalisées qui utilisent includes() sur des chaînes
|
|
103
|
+
|
|
104
|
+
// Pré-traitement des règles personnalisées pour éviter l'erreur "value.includes is not a function"
|
|
105
|
+
const safeCustomRules = customRules.map((rule) => {
|
|
106
|
+
if (rule.type === 'custom' && rule.options && rule.options.validate) {
|
|
107
|
+
// Créer une copie de la règle pour ne pas modifier l'original
|
|
108
|
+
const safeCopy = { ...rule }
|
|
109
|
+
const originalValidate = rule.options.validate
|
|
110
|
+
|
|
111
|
+
// Remplacer la fonction validate par une version sécurisée
|
|
112
|
+
safeCopy.options = { ...rule.options }
|
|
113
|
+
safeCopy.options.validate = (val: string | Date | null | undefined) => {
|
|
114
|
+
// Si la valeur est une Date mais que la fonction originale attend une chaîne
|
|
115
|
+
// (détecté par la présence de includes dans le code source)
|
|
116
|
+
if (val instanceof Date && originalValidate.toString().includes('.includes')) {
|
|
117
|
+
// Convertir la date en chaîne au format spécifié
|
|
118
|
+
return originalValidate(format ? formatDate(dayjs(val), format) : val.toISOString())
|
|
119
|
+
}
|
|
120
|
+
return originalValidate(val)
|
|
121
|
+
}
|
|
122
|
+
return safeCopy
|
|
123
|
+
}
|
|
124
|
+
return rule
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
// Faire de même pour les règles d'avertissement
|
|
128
|
+
const safeWarningRules = customWarningRules.map((rule) => {
|
|
129
|
+
if (rule.type === 'custom' && rule.options && rule.options.validate) {
|
|
130
|
+
const safeCopy = { ...rule }
|
|
131
|
+
const originalValidate = rule.options.validate
|
|
132
|
+
|
|
133
|
+
safeCopy.options = { ...rule.options }
|
|
134
|
+
safeCopy.options.validate = (val: string | Date | null | undefined) => {
|
|
135
|
+
if (val instanceof Date && originalValidate.toString().includes('.includes')) {
|
|
136
|
+
return originalValidate(format ? formatDate(dayjs(val), format) : val.toISOString())
|
|
137
|
+
}
|
|
138
|
+
return originalValidate(val)
|
|
139
|
+
}
|
|
140
|
+
return safeCopy
|
|
141
|
+
}
|
|
142
|
+
return rule
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
// Appeler validateField comme avant pour maintenir la compatibilité avec les tests
|
|
146
|
+
const result = validateField(
|
|
147
|
+
date,
|
|
148
|
+
safeCustomRules,
|
|
149
|
+
safeWarningRules,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
return !result.hasError
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return errors.value.length === 0
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
validateManualInput,
|
|
160
|
+
}
|
|
161
|
+
}
|