@cnamts/synapse 1.0.6 → 1.0.8
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-BlOpwEVq.js → DateFilter-DkqG0pmr.js} +1 -1
- package/dist/{NumberFilter-BPUXE4wY.js → NumberFilter-Ck7AwD39.js} +1 -1
- package/dist/{PeriodFilter-B2yx329_.js → PeriodFilter-LRI6YpgU.js} +1 -1
- package/dist/{SelectFilter-CedKn1oV.js → SelectFilter-DPc70Jk7.js} +1 -1
- package/dist/{TextFilter-DkhJjRtR.js → TextFilter-DRQL7uD8.js} +1 -1
- package/dist/components/Amelipro/AmeliproAccordionGroup/AmeliproAccordionGroup.d.ts +116 -0
- package/dist/components/Amelipro/AmeliproAccordionGroup/types.d.ts +4 -0
- package/dist/components/Amelipro/AmeliproAccordionList/AmeliproAccordionList.d.ts +220 -0
- package/dist/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResult.d.ts +68 -0
- package/dist/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResultTemplate/AmeliproAccordionResultTemplate.d.ts +70 -0
- package/dist/components/Amelipro/AmeliproAccordionResultList/AmeliproAccordionResultList.d.ts +204 -0
- package/dist/components/Amelipro/AmeliproAutoCompleteField/AmeliproAutoCompleteField.d.ts +26 -26
- package/dist/components/Amelipro/AmeliproBadge/AmeliproBadge.d.ts +59 -0
- package/dist/components/Amelipro/AmeliproBtn/AmeliproBtn.d.ts +3 -3
- package/dist/components/Amelipro/AmeliproCaptcha/AmeliproCaptcha.d.ts +1 -1
- package/dist/components/Amelipro/AmeliproCarousel/AmeliproCarousel.d.ts +214 -0
- package/dist/components/Amelipro/AmeliproCarousel/AmeliproCarouselItem/AmeliproCarouselItem.d.ts +70 -0
- package/dist/components/Amelipro/AmeliproCarousel/types.d.ts +7 -0
- package/dist/components/Amelipro/AmeliproClickableTile/AmeliproClickableTile.d.ts +125 -0
- package/dist/components/Amelipro/AmeliproIconBtn/AmeliproIconBtn.d.ts +1 -1
- package/dist/components/Amelipro/AmeliproIllustratedDataTile/AmeliproIllustratedDataTile.d.ts +2 -2
- package/dist/components/Amelipro/AmeliproResultList/AmeliproResultList.d.ts +164 -0
- package/dist/components/Amelipro/AmeliproSelect/AmeliproSelect.d.ts +27 -27
- package/dist/components/Amelipro/AmeliproStateTile/AmeliproStateTile.d.ts +1 -1
- package/dist/components/Amelipro/AmeliproTable/AmeliproTable.d.ts +1 -1
- package/dist/components/Amelipro/AmeliproTabs/AmeliproTabs.d.ts +32 -32
- package/dist/components/Amelipro/AmeliproTextArea/AmeliproTextArea.d.ts +6 -6
- package/dist/components/Amelipro/AmeliproTextField/AmeliproTextField.d.ts +7 -7
- package/dist/components/Amelipro/AmeliproTileBtn/AmeliproTileBtn.d.ts +1 -1
- package/dist/components/Amelipro/AmeliproTooltips/AmeliproTooltips.d.ts +2 -2
- package/dist/components/ChipList/ChipList.d.ts +4 -0
- package/dist/components/ChipList/locales.d.ts +4 -2
- package/dist/components/CookiesSelection/CookiesInformation/CookiesInformation.d.ts +8 -8
- package/dist/components/Customs/Selects/SySelect/SySelect.d.ts +329 -1296
- package/dist/components/Customs/Selects/SySelect/composables/useSySelectKeyboard.d.ts +0 -1
- package/dist/components/Customs/SyCheckbox/SyCheckbox.d.ts +2 -0
- package/dist/components/Customs/SyTabs/SyTabs.d.ts +71 -0
- package/dist/components/Customs/SyTabs/config.d.ts +17 -0
- package/dist/components/Customs/SyTabs/types.d.ts +11 -0
- package/dist/components/Customs/SyTextField/SyTextField.d.ts +9 -9
- package/dist/components/DataList/DataList.d.ts +1 -1
- package/dist/components/DatePicker/CalendarMode/DatePicker.d.ts +4811 -240
- package/dist/components/DatePicker/ComplexDatePicker/ComplexDatePicker.d.ts +52 -33
- package/dist/components/DatePicker/DateTextInput/DateTextInput.d.ts +23 -10
- package/dist/components/DatePicker/composables/useDateInputEditing.d.ts +1 -0
- package/dist/components/DatePicker/composables/useTodayButton.d.ts +1 -0
- package/dist/components/DialogBox/DialogBox.d.ts +219 -0
- package/dist/components/HeaderLoading/HeaderLoading.d.ts +27 -0
- package/dist/components/HeaderNavigationBar/HeaderNavigationBar.d.ts +110 -3
- package/dist/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.d.ts +19 -1
- package/dist/components/LangBtn/LangBtn.d.ts +2 -2
- package/dist/components/NirField/NirField.d.ts +18 -18
- package/dist/components/PeriodField/PeriodField.d.ts +10766 -1620
- package/dist/components/PhoneField/PhoneField.d.ts +1866 -2
- package/dist/components/PhoneField/indicatifs.d.ts +1 -0
- package/dist/components/PhoneField/locales.d.ts +1 -0
- package/dist/components/RangeField/RangeField.d.ts +1 -1
- package/dist/components/RangeField/RangeSlider/RangeSlider.d.ts +1 -1
- package/dist/components/SubHeader/SubHeader.d.ts +8 -0
- package/dist/components/SubHeader/locales.d.ts +1 -0
- package/dist/components/SyTextArea/SyTextArea.d.ts +6 -6
- package/dist/components/Tables/SyServerTable/SyServerTable.d.ts +5 -4
- package/dist/components/Tables/SyTable/SyTable.d.ts +5 -4
- package/dist/components/Tables/common/SyTablePagination.d.ts +333 -1296
- package/dist/components/Tables/common/organizeColumns/OrganizeColumns.d.ts +2 -2
- package/dist/components/Tables/common/types.d.ts +2 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/design-system-v3.js +173 -164
- package/dist/design-system-v3.umd.cjs +286 -263
- package/dist/{main-BXPFSAB4.js → main-DXMoMtj5.js} +13176 -11457
- package/dist/services/NotificationService.d.ts +1 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/assets/amelipro/icons.ts +38 -11
- package/src/components/Amelipro/AmeliproAccordionGroup/AmeliproAccordionGroup.mdx +20 -0
- package/src/components/Amelipro/AmeliproAccordionGroup/AmeliproAccordionGroup.stories.ts +135 -0
- package/src/components/Amelipro/AmeliproAccordionGroup/AmeliproAccordionGroup.vue +107 -0
- package/src/components/Amelipro/AmeliproAccordionGroup/__tests__/AmeliproAccordionGroup.spec.ts +37 -0
- package/src/components/Amelipro/AmeliproAccordionGroup/__tests__/__snapshots__/AmeliproAccordionGroup.spec.ts.snap +513 -0
- package/src/components/Amelipro/AmeliproAccordionGroup/types.d.ts +4 -0
- package/src/components/Amelipro/AmeliproAccordionList/AmeliproAccordionList.mdx +16 -0
- package/src/components/Amelipro/AmeliproAccordionList/AmeliproAccordionList.stories.ts +300 -0
- package/src/components/Amelipro/AmeliproAccordionList/AmeliproAccordionList.vue +288 -0
- package/src/components/Amelipro/AmeliproAccordionList/__tests__/AmeliproAccordionList.spec.ts +38 -0
- package/src/components/Amelipro/AmeliproAccordionList/__tests__/__snapshots__/AmeliproAccordionList.spec.ts.snap +1712 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResult.mdx +19 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResult.stories.ts +68 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResult.vue +66 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResultTemplate/AmeliproAccordionResultTemplate.vue +145 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResultTemplate/__tests__/AmeliproAccordionResultTemplate.spec.ts +24 -0
- package/src/components/Amelipro/AmeliproAccordionResult/AmeliproAccordionResultTemplate/__tests__/__snapshots__/AmeliproAccordionResultTemplate.spec.ts.snap +127 -0
- package/src/components/Amelipro/AmeliproAccordionResult/__tests__/AmeliproAccordionResult.spec.ts +24 -0
- package/src/components/Amelipro/AmeliproAccordionResult/__tests__/__snapshots__/AmeliproAccordionResult.spec.ts.snap +123 -0
- package/src/components/Amelipro/AmeliproAccordionResultList/AmeliproAccordionResultList.mdx +20 -0
- package/src/components/Amelipro/AmeliproAccordionResultList/AmeliproAccordionResultList.stories.ts +273 -0
- package/src/components/Amelipro/AmeliproAccordionResultList/AmeliproAccordionResultList.vue +275 -0
- package/src/components/Amelipro/AmeliproAccordionResultList/__tests__/AmeliproAccordionResultList.spec.ts +38 -0
- package/src/components/Amelipro/AmeliproAccordionResultList/__tests__/__snapshots__/AmeliproAccordionResultList.spec.ts.snap +1593 -0
- package/src/components/Amelipro/AmeliproBadge/AmeliproBadge.mdx +15 -0
- package/src/components/Amelipro/AmeliproBadge/AmeliproBadge.stories.ts +54 -0
- package/src/components/Amelipro/AmeliproBadge/AmeliproBadge.vue +76 -0
- package/src/components/Amelipro/AmeliproBadge/__tests__/AmeliproBadge.spec.ts +20 -0
- package/src/components/Amelipro/AmeliproBadge/__tests__/__snapshots__/AmeliproBadge.spec.ts.snap +19 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarousel.mdx +15 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarousel.stories.ts +191 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarousel.vue +263 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarouselItem/AmeliproCarouselItem.vue +93 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarouselItem/__tests__/AmeliproCarouselItem.spec.ts +24 -0
- package/src/components/Amelipro/AmeliproCarousel/AmeliproCarouselItem/__tests__/__snapshots__/AmeliproCarouselItem.spec.ts.snap +43 -0
- package/src/components/Amelipro/AmeliproCarousel/__tests__/AmeliproCarousel.spec.ts +40 -0
- package/src/components/Amelipro/AmeliproCarousel/__tests__/__snapshots__/AmeliproCarousel.spec.ts.snap +342 -0
- package/src/components/Amelipro/AmeliproCarousel/types.d.ts +8 -0
- package/src/components/Amelipro/AmeliproClickableTile/AmeliproClickableTile.mdx +18 -0
- package/src/components/Amelipro/AmeliproClickableTile/AmeliproClickableTile.stories.ts +67 -0
- package/src/components/Amelipro/AmeliproClickableTile/AmeliproClickableTile.vue +233 -0
- package/src/components/Amelipro/AmeliproClickableTile/tests/AmeliproClickableTile.spec.ts +21 -0
- package/src/components/Amelipro/AmeliproClickableTile/tests/__snapshots__/AmeliproClickableTile.spec.ts.snap +140 -0
- package/src/components/Amelipro/AmeliproHeader/AmeliproHeader.vue +7 -1
- package/src/components/Amelipro/AmeliproHeader/tests/__snapshots__/AmeliproHeader.spec.ts.snap +5 -4
- package/src/components/Amelipro/AmeliproIcon/iconList.ts +6 -0
- package/src/components/Amelipro/AmeliproPageLayout/tests/__snapshots__/AmeliproPageLayout.spec.ts.snap +5 -4
- package/src/components/Amelipro/AmeliproResultList/AmeliproResultList.mdx +15 -0
- package/src/components/Amelipro/AmeliproResultList/AmeliproResultList.stories.ts +264 -0
- package/src/components/Amelipro/AmeliproResultList/AmeliproResultList.vue +231 -0
- package/src/components/Amelipro/AmeliproResultList/__tests__/AmeliproResultList.spec.ts +37 -0
- package/src/components/Amelipro/AmeliproResultList/__tests__/__snapshots__/AmeliproResultList.spec.ts.snap +434 -0
- package/src/components/Amelipro/AmeliproTable/AmeliproTable.vue +6 -5
- package/src/components/Amelipro/AmeliproTable/__tests__/__snapshots__/AmeliproTable.spec.ts.snap +23 -26
- package/src/components/Amelipro/AmeliproTileBtn/AmeliproTileBtn.stories.ts +2 -2
- package/src/components/ChipList/Accessibilite.stories.ts +4 -0
- package/src/components/ChipList/ChipList.vue +185 -42
- package/src/components/ChipList/locales.ts +4 -2
- package/src/components/ChipList/tests/chipList.spec.ts +7 -4
- package/src/components/Customs/Selects/SelectOverview.mdx +34 -66
- package/src/components/Customs/Selects/SyBtnSelect/SyBtnSelect.stories.ts +10 -10
- package/src/components/Customs/Selects/SyInputSelect/SyInputSelect.mdx +3 -0
- package/src/components/Customs/Selects/SyInputSelect/SyInputSelect.stories.ts +14 -0
- package/src/components/Customs/Selects/SySelect/SySelect.stories.ts +14 -6
- package/src/components/Customs/Selects/SySelect/SySelect.vue +268 -205
- package/src/components/Customs/Selects/SySelect/composables/tests/useSySelectKeyboard.spec.ts +0 -10
- package/src/components/Customs/Selects/SySelect/composables/useSySelectKeyboard.ts +0 -5
- package/src/components/Customs/Selects/SySelect/tests/SySelect.spec.ts +184 -25
- package/src/components/Customs/SyCheckbox/SyCheckbox.mdx +3 -1
- package/src/components/Customs/SyCheckbox/SyCheckbox.stories.ts +165 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.vue +28 -9
- package/src/components/Customs/SyTabs/Accessibilite.mdx +309 -0
- package/src/components/Customs/SyTabs/SyTabs.mdx +117 -0
- package/src/components/Customs/SyTabs/SyTabs.stories.ts +354 -0
- package/src/components/Customs/SyTabs/SyTabs.vue +413 -0
- package/src/components/Customs/SyTabs/config.ts +17 -0
- package/src/components/Customs/SyTabs/tests/SyTabs.spec.ts +425 -0
- package/src/components/Customs/SyTabs/types.ts +12 -0
- package/src/components/Customs/SyTextField/SyTextField.mdx +3 -0
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +142 -1
- package/src/components/Customs/SyTextField/SyTextField.vue +19 -16
- package/src/components/DataList/DataList.vue +47 -49
- package/src/components/DataListGroup/DataListGroup.vue +1 -1
- package/src/components/DataListItem/DataListItem.vue +67 -63
- package/src/components/DataListItem/tests/DataListItem.spec.ts +2 -2
- package/src/components/DatePicker/CalendarMode/DatePicker.stories.ts +3 -3
- package/src/components/DatePicker/CalendarMode/DatePicker.vue +49 -13
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.vue +412 -649
- package/src/components/DatePicker/DatePickerValidationExample/CalendarMode.stories.ts +215 -0
- package/src/components/DatePicker/DatePickerValidationExample/ComplexDatePicker.stories.ts +218 -0
- package/src/components/DatePicker/DatePickerValidationExample/DatePickerValidation.mdx +2 -0
- package/src/components/DatePicker/DatePickerValidationExample/DatePickerValidation.stories.ts +1 -1
- package/src/components/DatePicker/DatePickerValidationExample/DateTextInput.stories.ts +218 -0
- package/src/components/DatePicker/DatePickerValidationExample/MultiMode.stories.ts +281 -0
- package/src/components/DatePicker/DateTextInput/DateTextInput.events.spec.ts +17 -4
- package/src/components/DatePicker/DateTextInput/DateTextInput.range.spec.ts +111 -18
- package/src/components/DatePicker/DateTextInput/DateTextInput.spec.ts +238 -6
- package/src/components/DatePicker/DateTextInput/DateTextInput.vue +716 -757
- package/src/components/DatePicker/composables/tests/useDateInputEditing.spec.ts +4 -4
- package/src/components/DatePicker/composables/tests/useDisplayedDateString.spec.ts +17 -10
- package/src/components/DatePicker/composables/useDateInputEditing.ts +52 -22
- package/src/components/DatePicker/composables/useDisplayedDateString.ts +18 -4
- package/src/components/DatePicker/composables/useTodayButton.ts +13 -1
- package/src/components/DatePicker/utils/dateFormattingUtils.ts +79 -14
- package/src/components/DialogBox/DialogBox.stories.ts +12 -0
- package/src/components/DialogBox/DialogBox.vue +16 -11
- package/src/components/DialogBox/tests/DialogBox.spec.ts +22 -0
- package/src/components/HeaderLoading/Accessibilite.mdx +429 -8
- package/src/components/HeaderLoading/Accessibilite.stories.ts +4 -0
- package/src/components/HeaderLoading/HeaderLoading.vue +59 -0
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.mdx +17 -2
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.stories.ts +91 -2
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.vue +37 -1
- package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +284 -21
- package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.spec.ts +2 -2
- package/src/components/NirField/NirField.mdx +3 -0
- package/src/components/NirField/NirField.vue +10 -1
- package/src/components/NirField/tests/NirField.spec.ts +81 -0
- package/src/components/NotificationBar/NotificationBar.stories.ts +128 -2
- package/src/components/NotificationBar/NotificationBar.vue +16 -1
- package/src/components/NotificationBar/tests/NotificationBar.spec.ts +65 -0
- package/src/components/PasswordField/PasswordField.mdx +3 -0
- package/src/components/PeriodField/PeriodField.mdx +2 -0
- package/src/components/PeriodField/PeriodField.stories.ts +195 -0
- package/src/components/PhoneField/Accessibilite.stories.ts +4 -0
- package/src/components/PhoneField/PhoneField.mdx +3 -1
- package/src/components/PhoneField/PhoneField.stories.ts +285 -1
- package/src/components/PhoneField/PhoneField.vue +228 -95
- package/src/components/PhoneField/indicatifs.ts +102 -102
- package/src/components/PhoneField/locales.ts +1 -0
- package/src/components/PhoneField/tests/PhoneField.spec.ts +419 -2
- package/src/components/SkipLink/SkipLink.vue +3 -31
- package/src/components/SkipLink/tests/skipLink.spec.ts +0 -21
- package/src/components/SubHeader/Accessibilite.stories.ts +8 -0
- package/src/components/SubHeader/SubHeader.mdx +1 -0
- package/src/components/SubHeader/SubHeader.stories.ts +179 -60
- package/src/components/SubHeader/SubHeader.vue +45 -15
- package/src/components/SubHeader/locales.ts +1 -0
- package/src/components/SyAlert/SyAlert.vue +6 -0
- package/src/components/Tables/SyServerTable/SyServerTable.mdx +3 -10
- package/src/components/Tables/SyServerTable/SyServerTable.stories.ts +242 -0
- package/src/components/Tables/SyServerTable/SyServerTable.vue +29 -10
- package/src/components/Tables/SyTable/SyTable.mdx +3 -10
- package/src/components/Tables/SyTable/SyTable.stories.ts +242 -0
- package/src/components/Tables/SyTable/SyTable.vue +2 -0
- package/src/components/Tables/common/SyTablePagination.vue +13 -6
- package/src/components/Tables/common/filters/tests/SelectFilter.spec.ts +6 -1
- package/src/components/Tables/common/tests/SyTablePagination.spec.ts +157 -0
- package/src/components/Tables/common/types.ts +2 -0
- package/src/components/index.ts +9 -0
- package/src/composables/useFilterable/useFilterable.ts +10 -0
- package/src/designTokens/tokens/amelipro/apColors.ts +1 -1
- package/src/designTokens/tokens/cnam/cnamSemantic.ts +3 -3
- package/src/services/NotificationService.ts +9 -0
- package/src/stories/Components/Components.stories.ts +1 -1
- package/src/stories/GuideDuDev/FormValidationGuide.mdx +342 -0
- package/src/stories/Templates/Templates.stories.ts +1 -1
- package/src/utils/functions/ameliproColors/ameliproColors.ts +1 -1
- package/dist/components/DataList/locales.d.ts +0 -3
- package/src/components/DataList/locales.ts +0 -3
- package/src/components/PhoneField/tests/PhoneField.additional.spec.ts +0 -266
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, ref, watch } from 'vue'
|
|
2
|
+
import { computed, ref, watch, nextTick } from 'vue'
|
|
3
3
|
import type { PropType } from 'vue'
|
|
4
4
|
import { mdiPhone } from '@mdi/js'
|
|
5
5
|
import { indicatifs } from './indicatifs'
|
|
6
|
-
import {
|
|
6
|
+
import { Mask } from 'maska'
|
|
7
7
|
import { locales } from './locales'
|
|
8
8
|
import SySelect from '@/components/Customs/Selects/SySelect/SySelect.vue'
|
|
9
9
|
import SyTextField from '@/components/Customs/SyTextField/SyTextField.vue'
|
|
10
|
+
import SyIcon from '@/components/Customs/SyIcon/SyIcon.vue'
|
|
10
11
|
import { useValidation, type ValidationRule } from '@/composables/validation/useValidation'
|
|
11
12
|
import {
|
|
12
13
|
mdiAlertOutline,
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
code: string
|
|
20
21
|
abbreviation: string
|
|
21
22
|
country: string
|
|
23
|
+
countryFr?: string
|
|
22
24
|
mask?: string
|
|
23
25
|
phoneLength: number
|
|
24
26
|
}
|
|
@@ -41,6 +43,9 @@
|
|
|
41
43
|
bgColor: { type: String, default: 'white' },
|
|
42
44
|
readonly: { type: Boolean, default: false },
|
|
43
45
|
disabled: { type: Boolean, default: false },
|
|
46
|
+
helpText: { type: String, default: '' },
|
|
47
|
+
autocompleteCountryCode: { type: String, default: 'tel-country-code' },
|
|
48
|
+
autocompletePhone: { type: String, default: 'tel-national' },
|
|
44
49
|
})
|
|
45
50
|
|
|
46
51
|
const emit = defineEmits(['update:modelValue', 'update:selectedDialCode', 'change'])
|
|
@@ -61,7 +66,14 @@
|
|
|
61
66
|
const computedValue = computed(() => formatPhoneNumber(phoneNumber.value))
|
|
62
67
|
|
|
63
68
|
watch(() => props.modelValue, (newVal) => {
|
|
64
|
-
|
|
69
|
+
if (newVal) {
|
|
70
|
+
// Apply mask to incoming value to ensure consistent formatting
|
|
71
|
+
const mask = new Mask({ mask: phoneMask.value })
|
|
72
|
+
phoneNumber.value = mask.masked(newVal)
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
phoneNumber.value = ''
|
|
76
|
+
}
|
|
65
77
|
}, { immediate: true })
|
|
66
78
|
|
|
67
79
|
watch(dialCode, (newVal) => {
|
|
@@ -69,15 +81,63 @@
|
|
|
69
81
|
if (typeof newVal === 'object' && newVal !== null) {
|
|
70
82
|
counter.value = newVal.phoneLength || 10
|
|
71
83
|
phoneMask.value = newVal.mask || '#'.repeat(newVal.phoneLength || 10).replace(/(.{2})/g, '$1 ').trim()
|
|
84
|
+
const mask = new Mask({ mask: phoneMask.value })
|
|
85
|
+
const maskedValue = mask.masked(phoneNumber.value)
|
|
86
|
+
emit('update:modelValue', maskedValue)
|
|
72
87
|
}
|
|
73
88
|
})
|
|
74
89
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Calcule la position ajustée du curseur en tenant compte des espaces ajoutés par le masque
|
|
92
|
+
* @param cursorPosition - Position originale du curseur
|
|
93
|
+
* @param originalValue - Valeur avant application du masque
|
|
94
|
+
* @param maskedValue - Valeur après application du masque
|
|
95
|
+
* @returns Position ajustée du curseur
|
|
96
|
+
*/
|
|
97
|
+
const calculateAdjustedPosition = (cursorPosition: number, originalValue: string, maskedValue: string): number => {
|
|
98
|
+
// Compte combien de caractères non-espace se trouvent avant la position du curseur dans la valeur originale
|
|
99
|
+
const digitsBeforeCursor = originalValue.substring(0, cursorPosition).replace(/\s/g, '').length
|
|
100
|
+
|
|
101
|
+
// Parcours la valeur masquée pour trouver la position qui contient le même nombre de caractères non-espace
|
|
102
|
+
let newPosition = 0
|
|
103
|
+
let digitCount = 0
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < maskedValue.length; i++) {
|
|
106
|
+
if (maskedValue[i] !== ' ') {
|
|
107
|
+
digitCount++
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (digitCount > digitsBeforeCursor) {
|
|
111
|
+
break
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
newPosition = i + 1
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return newPosition
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const handlePhoneInput = (event: Event) => {
|
|
121
|
+
const inputElement = event.target as HTMLInputElement
|
|
122
|
+
const input = inputElement.value
|
|
123
|
+
|
|
124
|
+
// Sauvegarder la position du curseur
|
|
125
|
+
const cursorPosition = inputElement.selectionStart || 0
|
|
126
|
+
|
|
127
|
+
// Appliquer le masque
|
|
128
|
+
const mask = new Mask({ mask: phoneMask.value })
|
|
129
|
+
const maskedValue = mask.masked(input)
|
|
130
|
+
|
|
131
|
+
// Mettre à jour la valeur
|
|
132
|
+
phoneNumber.value = maskedValue
|
|
133
|
+
emit('update:modelValue', maskedValue)
|
|
134
|
+
emit('change', maskedValue)
|
|
135
|
+
|
|
136
|
+
// Restaurer la position du curseur sur le prochain cycle de rendu
|
|
137
|
+
nextTick(() => {
|
|
138
|
+
const adjustedPosition = calculateAdjustedPosition(cursorPosition, input, maskedValue)
|
|
139
|
+
inputElement.setSelectionRange(adjustedPosition, adjustedPosition)
|
|
140
|
+
})
|
|
81
141
|
}
|
|
82
142
|
|
|
83
143
|
const mergedDialCodes = computed(() =>
|
|
@@ -88,6 +148,7 @@
|
|
|
88
148
|
mergedDialCodes.value.map(ind => ({
|
|
89
149
|
...ind,
|
|
90
150
|
displayText: generateDisplayText(ind),
|
|
151
|
+
plainDisplayText: generatePlainDisplayText(ind),
|
|
91
152
|
})),
|
|
92
153
|
)
|
|
93
154
|
|
|
@@ -127,11 +188,24 @@
|
|
|
127
188
|
}, { immediate: true })
|
|
128
189
|
|
|
129
190
|
function generateDisplayText(ind: Indicatif): string {
|
|
191
|
+
const countryName = ind.countryFr || ind.country
|
|
192
|
+
const format = {
|
|
193
|
+
'code': ind.code,
|
|
194
|
+
'code-abbreviation': `${ind.code} (<abbr title="${countryName}">${ind.abbreviation}</abbr>)`,
|
|
195
|
+
'code-country': `${ind.code} ${countryName}`,
|
|
196
|
+
'country': countryName,
|
|
197
|
+
'abbreviation': `<abbr title="${countryName}">${ind.abbreviation}</abbr>`,
|
|
198
|
+
}
|
|
199
|
+
return format[props.displayFormat] || ind.code
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function generatePlainDisplayText(ind: Indicatif): string {
|
|
203
|
+
const countryName = ind.countryFr || ind.country
|
|
130
204
|
const format = {
|
|
131
205
|
'code': ind.code,
|
|
132
206
|
'code-abbreviation': `${ind.code} (${ind.abbreviation})`,
|
|
133
|
-
'code-country': `${ind.code} ${
|
|
134
|
-
'country':
|
|
207
|
+
'code-country': `${ind.code} ${countryName}`,
|
|
208
|
+
'country': countryName,
|
|
135
209
|
'abbreviation': ind.abbreviation,
|
|
136
210
|
}
|
|
137
211
|
return format[props.displayFormat] || ind.code
|
|
@@ -142,22 +216,24 @@
|
|
|
142
216
|
type: 'exactLength',
|
|
143
217
|
options: {
|
|
144
218
|
length: counter.value,
|
|
145
|
-
ignoreSpace: true,
|
|
219
|
+
ignoreSpace: true,
|
|
146
220
|
message: `Le numéro de téléphone doit contenir ${counter.value} chiffres.`,
|
|
147
221
|
fieldIdentifier: locales.label,
|
|
148
222
|
},
|
|
149
|
-
}]
|
|
223
|
+
}] as ValidationRule[]
|
|
224
|
+
|
|
150
225
|
if (props.required) {
|
|
151
226
|
rules.unshift({
|
|
152
227
|
type: 'required',
|
|
153
228
|
options: {
|
|
154
229
|
length: counter.value,
|
|
155
|
-
ignoreSpace: true,
|
|
230
|
+
ignoreSpace: true,
|
|
156
231
|
message: `Le champ ${locales.label} est requis.`,
|
|
157
232
|
fieldIdentifier: locales.label,
|
|
158
233
|
},
|
|
159
234
|
})
|
|
160
235
|
}
|
|
236
|
+
|
|
161
237
|
return rules
|
|
162
238
|
})
|
|
163
239
|
|
|
@@ -186,6 +262,11 @@
|
|
|
186
262
|
const warnings = computed(() => validation.warnings.value)
|
|
187
263
|
const successes = computed(() => validation.successes.value)
|
|
188
264
|
|
|
265
|
+
const showHelpTextBelow = computed(() => {
|
|
266
|
+
// Display help text below by default if it exists
|
|
267
|
+
return props.helpText && props.helpText.trim() !== ''
|
|
268
|
+
})
|
|
269
|
+
|
|
189
270
|
function validateInputOnBlur() {
|
|
190
271
|
if (!props.isValidatedOnBlur || shouldDisableErrorHandling.value) return
|
|
191
272
|
|
|
@@ -243,85 +324,131 @@
|
|
|
243
324
|
</script>
|
|
244
325
|
|
|
245
326
|
<template>
|
|
246
|
-
<
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
<
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
327
|
+
<fieldset class="phone-field-fieldset">
|
|
328
|
+
<legend class="phone-field-legend">
|
|
329
|
+
{{ locales.label }}
|
|
330
|
+
</legend>
|
|
331
|
+
<div class="phone-field-container">
|
|
332
|
+
<SySelect
|
|
333
|
+
v-if="withCountryCode"
|
|
334
|
+
v-model="dialCode"
|
|
335
|
+
:items="dialCodeOptions"
|
|
336
|
+
:label="locales.indicatifLabel"
|
|
337
|
+
:outlined="outlinedIndicatif"
|
|
338
|
+
:required="countryCodeRequired"
|
|
339
|
+
:aria-required="countryCodeRequired"
|
|
340
|
+
:error="hasError"
|
|
341
|
+
:error-messages="errors[1]"
|
|
342
|
+
:display-asterisk="displayAsterisk"
|
|
343
|
+
:disable-error-handling="shouldDisableErrorHandling"
|
|
344
|
+
:return-object="true"
|
|
345
|
+
:bg-color="bgColor"
|
|
346
|
+
:readonly="readonly"
|
|
347
|
+
:disabled="disabled"
|
|
348
|
+
:allow-html="displayFormat === 'code-abbreviation' || displayFormat === 'abbreviation'"
|
|
349
|
+
:autocomplete="autocompleteCountryCode"
|
|
350
|
+
width="30%"
|
|
351
|
+
class="custom-select mr-4"
|
|
352
|
+
text-key="displayText"
|
|
353
|
+
plain-text-key="plainDisplayText"
|
|
354
|
+
value-key="code"
|
|
355
|
+
/>
|
|
356
|
+
<SyTextField
|
|
357
|
+
ref="phoneField"
|
|
358
|
+
:model-value="phoneNumber"
|
|
359
|
+
:counter="counter"
|
|
360
|
+
:counter-value="(value: string) => value.replace(/\s/g, '').length"
|
|
361
|
+
:label="withCountryCode ? locales.phoneNumberWithoutCountryLabel : locales.label"
|
|
362
|
+
:required="required"
|
|
363
|
+
:aria-required="required"
|
|
364
|
+
:error="hasError"
|
|
365
|
+
:error-messages="errors"
|
|
366
|
+
:warning-messages="warnings"
|
|
367
|
+
:success-messages="successes"
|
|
368
|
+
:variant="outlined ? 'outlined' : 'underlined'"
|
|
369
|
+
:display-asterisk="displayAsterisk"
|
|
370
|
+
:readonly="readonly"
|
|
371
|
+
:bg-color="bgColor"
|
|
372
|
+
:disabled="disabled"
|
|
373
|
+
:autocomplete="autocompletePhone"
|
|
374
|
+
:class="{
|
|
375
|
+
'phone-field': true,
|
|
376
|
+
'error-field': hasError,
|
|
377
|
+
'warning-field': hasWarning,
|
|
378
|
+
'success-field': hasSuccess
|
|
379
|
+
}"
|
|
380
|
+
width="70%"
|
|
381
|
+
color="primary"
|
|
382
|
+
type="tel"
|
|
383
|
+
@blur="validateInputOnBlur"
|
|
384
|
+
@input="handlePhoneInput"
|
|
385
|
+
>
|
|
386
|
+
<template #append-inner>
|
|
387
|
+
<div class="d-flex align-center">
|
|
388
|
+
<SyIcon
|
|
389
|
+
v-if="hasError && !shouldDisableErrorHandling"
|
|
390
|
+
color="error"
|
|
391
|
+
:icon="mdiInformation"
|
|
392
|
+
decorative
|
|
393
|
+
/>
|
|
394
|
+
<SyIcon
|
|
395
|
+
v-else-if="hasWarning && !shouldDisableErrorHandling"
|
|
396
|
+
color="warning"
|
|
397
|
+
:icon="mdiAlertOutline"
|
|
398
|
+
decorative
|
|
399
|
+
/>
|
|
400
|
+
<SyIcon
|
|
401
|
+
v-else-if="hasSuccess && !shouldDisableErrorHandling"
|
|
402
|
+
color="success"
|
|
403
|
+
:icon="mdiCheck"
|
|
404
|
+
decorative
|
|
405
|
+
/>
|
|
406
|
+
<SyIcon
|
|
407
|
+
class="ml-2"
|
|
408
|
+
:color="iconColor"
|
|
409
|
+
:icon="mdiPhone"
|
|
410
|
+
decorative
|
|
411
|
+
/>
|
|
412
|
+
</div>
|
|
413
|
+
</template>
|
|
414
|
+
</SyTextField>
|
|
415
|
+
</div>
|
|
416
|
+
</fieldset>
|
|
417
|
+
|
|
418
|
+
<div
|
|
419
|
+
v-if="showHelpTextBelow"
|
|
420
|
+
class="help-text-below px-4 mt-1"
|
|
421
|
+
:class="{ 'text-disabled': disabled }"
|
|
422
|
+
>
|
|
423
|
+
{{ helpText }}
|
|
321
424
|
</div>
|
|
322
425
|
</template>
|
|
323
426
|
|
|
324
|
-
<style scoped>
|
|
427
|
+
<style lang="scss" scoped>
|
|
428
|
+
@use '@/assets/tokens';
|
|
429
|
+
|
|
430
|
+
.phone-field-fieldset {
|
|
431
|
+
border: 1px solid #b9b9b9;
|
|
432
|
+
border-radius: 4px;
|
|
433
|
+
padding: 25px;
|
|
434
|
+
margin: 0;
|
|
435
|
+
display: flex;
|
|
436
|
+
flex-direction: column;
|
|
437
|
+
box-sizing: border-box;
|
|
438
|
+
min-width: 0;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.phone-field-legend {
|
|
442
|
+
padding: 0 8px;
|
|
443
|
+
font-weight: 500;
|
|
444
|
+
color: #666;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.required-asterisk {
|
|
448
|
+
color: #d32f2f;
|
|
449
|
+
margin-left: 4px;
|
|
450
|
+
}
|
|
451
|
+
|
|
325
452
|
.phone-field-container {
|
|
326
453
|
display: flex;
|
|
327
454
|
flex-direction: column;
|
|
@@ -333,10 +460,6 @@
|
|
|
333
460
|
width: 100%;
|
|
334
461
|
}
|
|
335
462
|
|
|
336
|
-
.custom-select {
|
|
337
|
-
width: 30%;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
463
|
@media (width >= 600px) {
|
|
341
464
|
.phone-field-container {
|
|
342
465
|
flex-direction: row;
|
|
@@ -344,7 +467,6 @@
|
|
|
344
467
|
}
|
|
345
468
|
|
|
346
469
|
.custom-select {
|
|
347
|
-
margin-right: 1rem;
|
|
348
470
|
margin-bottom: 0;
|
|
349
471
|
min-width: 144px;
|
|
350
472
|
}
|
|
@@ -365,4 +487,15 @@
|
|
|
365
487
|
overflow-y: auto;
|
|
366
488
|
z-index: 2;
|
|
367
489
|
}
|
|
490
|
+
|
|
491
|
+
.help-text-below {
|
|
492
|
+
font-size: 0.75rem;
|
|
493
|
+
line-height: 1.25rem;
|
|
494
|
+
color: rgb(var(--v-theme-on-surface));
|
|
495
|
+
opacity: 0.6;
|
|
496
|
+
|
|
497
|
+
&.text-disabled {
|
|
498
|
+
opacity: 0.38;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
368
501
|
</style>
|