@cnamts/synapse 0.0.7-alpha → 0.0.9-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design-system-v3.d.ts +785 -372
- package/dist/design-system-v3.js +4993 -3357
- package/dist/design-system-v3.umd.cjs +1 -10
- package/dist/style.css +1 -1
- package/package.json +10 -2
- package/src/assets/settings.scss +2 -2
- package/src/assets/tokens.scss +107 -112
- package/src/components/BackBtn/BackBtn.vue +4 -4
- package/src/components/BackToTopBtn/BackToTopBtn.vue +1 -0
- package/src/components/CollapsibleList/CollapsibleList.mdx +1 -1
- package/src/components/CollapsibleList/CollapsibleList.vue +43 -44
- package/src/components/ContextualMenu/Accessibilite.mdx +14 -0
- package/src/components/ContextualMenu/Accessibilite.stories.ts +191 -0
- package/src/components/ContextualMenu/AccessibiliteItems.ts +89 -0
- package/src/components/ContextualMenu/ContextualMenu.mdx +118 -0
- package/src/components/ContextualMenu/ContextualMenu.stories.ts +430 -0
- package/src/components/ContextualMenu/ContextualMenu.vue +101 -0
- package/src/components/ContextualMenu/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/ContextualMenu/tests/ContextualMenu.spec.ts +115 -0
- package/src/components/ContextualMenu/tests/__snapshots__/ContextualMenu.spec.ts.snap +10 -0
- package/src/components/ContextualMenu/types.ts +5 -0
- package/src/components/CookieBanner/CookieBanner.stories.ts +1 -2
- package/src/components/CookieBanner/CookieBanner.vue +13 -10
- package/src/components/CookieBanner/tests/__snapshots__/CookieBanner.spec.ts.snap +17 -15
- package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +6 -1
- package/src/components/CookiesSelection/CookiesInformation/locales.ts +1 -0
- package/src/components/CookiesSelection/CookiesTable/CookiesTable.vue +1 -0
- package/src/components/CookiesSelection/tests/__snapshots__/CookiesSelection.spec.ts.snap +17 -15
- package/src/components/CopyBtn/CopyBtn.vue +7 -7
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +26 -26
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +24 -24
- package/src/components/Customs/SySelect/SySelect.stories.ts +7 -7
- package/src/components/Customs/SySelect/SySelect.vue +36 -30
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +2 -2
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +187 -2
- package/src/components/Customs/SyTextField/SyTextField.vue +185 -16
- package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +2 -4
- package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +18 -16
- package/src/components/Customs/SyTextField/types.d.ts +2 -2
- package/src/components/DataList/DataList.stories.ts +3 -2
- package/src/components/DataList/DataList.vue +1 -1
- package/src/components/DataListGroup/DataListGroup.stories.ts +3 -2
- package/src/components/DataListItem/DataListItem.vue +12 -12
- package/src/components/DatePicker/DatePicker.mdx +191 -0
- package/src/components/DatePicker/DatePicker.stories.ts +787 -0
- package/src/components/DatePicker/DatePicker.vue +560 -0
- package/src/components/DatePicker/DateTextInput.vue +409 -0
- package/src/components/DatePicker/tests/DatePicker.spec.ts +266 -0
- package/src/components/DialogBox/DialogBox.mdx +28 -2
- package/src/components/DialogBox/DialogBox.stories.ts +2 -2
- package/src/components/DialogBox/DialogBox.vue +3 -2
- package/src/components/DownloadBtn/DownloadBtn.vue +2 -1
- package/src/components/ExternalLinks/Accessibilite.mdx +14 -0
- package/src/components/ExternalLinks/Accessibilite.stories.ts +191 -0
- package/src/components/ExternalLinks/AccessibiliteItems.ts +197 -0
- package/src/components/ExternalLinks/ExternalLinks.mdx +86 -0
- package/src/components/ExternalLinks/ExternalLinks.stories.ts +553 -0
- package/src/components/ExternalLinks/ExternalLinks.vue +200 -0
- package/src/components/ExternalLinks/config.ts +34 -0
- package/src/components/ExternalLinks/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/ExternalLinks/locales.ts +4 -0
- package/src/components/ExternalLinks/tests/ExternalLinks.spec.ts +154 -0
- package/src/components/ExternalLinks/tests/__snapshots__/ExternalLinks.spec.ts.snap +159 -0
- package/src/components/FileUpload/FileUpload.mdx +165 -0
- package/src/components/FileUpload/FileUpload.stories.ts +429 -0
- package/src/components/FileUpload/FileUpload.vue +195 -0
- package/src/components/FileUpload/FileUploadContent.vue +109 -0
- package/src/components/FileUpload/locales.ts +10 -0
- package/src/components/FileUpload/tests/FileUpload.spec.ts +332 -0
- package/src/components/FileUpload/tests/__snapshots__/FileUpload.spec.ts.snap +7 -0
- package/src/components/FileUpload/useFileDrop.ts +23 -0
- package/src/components/FileUpload/validateFiles.ts +39 -0
- package/src/components/FooterBar/FooterBar.vue +105 -80
- package/src/components/FranceConnectBtn/FranceConnectBtn.vue +14 -13
- package/src/components/HeaderBar/HeaderBar.vue +3 -3
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.vue +11 -7
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.vue +5 -5
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.vue +2 -2
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.vue +10 -8
- package/src/components/HeaderBar/HeaderLogo/HeaderLogo.vue +2 -2
- package/src/components/HeaderBar/HeaderLogo/logos/Logo-mobile.vue +2 -1
- package/src/components/HeaderBar/HeaderLogo/logos/Logo.vue +2 -1
- package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +10 -10
- package/src/components/HeaderBar/consts.scss +1 -1
- package/src/components/HeaderLoading/HeaderLoading.vue +12 -11
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.vue +2 -1
- package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +9 -9
- package/src/components/HeaderToolbar/HeaderToolbar.vue +215 -202
- package/src/components/LangBtn/LangBtn.vue +8 -6
- package/src/components/LogoBrandSection/LogoBrandSection.stories.ts +2 -2
- package/src/components/NirField/NirField.stories.ts +8 -8
- package/src/components/NirField/NirField.vue +46 -48
- package/src/components/NotFoundPage/NotFoundPage.stories.ts +33 -2
- package/src/components/NotFoundPage/NotFoundPage.vue +17 -0
- package/src/components/NotificationBar/NotificationBar.mdx +5 -5
- package/src/components/NotificationBar/NotificationBar.stories.ts +410 -314
- package/src/components/NotificationBar/NotificationBar.vue +43 -41
- package/src/components/PageContainer/PageContainer.vue +4 -4
- package/src/components/PasswordField/Accessibilite.mdx +14 -0
- package/src/components/PasswordField/Accessibilite.stories.ts +191 -0
- package/src/components/PasswordField/AccessibiliteItems.ts +184 -0
- package/src/components/PasswordField/PasswordField.mdx +70 -0
- package/src/components/PasswordField/PasswordField.stories.ts +213 -0
- package/src/components/PasswordField/PasswordField.vue +189 -0
- package/src/components/PasswordField/config.ts +11 -0
- package/src/components/PasswordField/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/PasswordField/locales.ts +4 -0
- package/src/components/PasswordField/tests/PasswordField.spec.ts +96 -0
- package/src/components/PhoneField/PhoneField.mdx +0 -2
- package/src/components/PhoneField/PhoneField.stories.ts +10 -50
- package/src/components/PhoneField/PhoneField.vue +77 -93
- package/src/components/PhoneField/tests/PhoneField.spec.ts +0 -15
- package/src/components/RangeField/RangeField.mdx +54 -0
- package/src/components/RangeField/RangeField.stories.ts +189 -0
- package/src/components/RangeField/RangeField.vue +157 -0
- package/src/components/RangeField/RangeSlider/RangeSlider.vue +387 -0
- package/src/components/RangeField/RangeSlider/Tooltip/Tooltip.vue +64 -0
- package/src/components/RangeField/RangeSlider/tests/__snapshots__/rangeSlider.spec.ts.snap +27 -0
- package/src/components/RangeField/RangeSlider/tests/rangeSlider.spec.ts +100 -0
- package/src/components/RangeField/RangeSlider/tests/useDoubleSlider.spec.ts +246 -0
- package/src/components/RangeField/RangeSlider/tests/useMouseSlide.spec.ts +204 -0
- package/src/components/RangeField/RangeSlider/tests/useThumb.spec.ts +22 -0
- package/src/components/RangeField/RangeSlider/tests/useThumbKeyboard.spec.ts +233 -0
- package/src/components/RangeField/RangeSlider/tests/useTooltipsNudge.spec.ts +150 -0
- package/src/components/RangeField/RangeSlider/tests/useTrack.spec.ts +314 -0
- package/src/components/RangeField/RangeSlider/tests/vAnimateClick.spec.ts +32 -0
- package/src/components/RangeField/RangeSlider/types.ts +15 -0
- package/src/components/RangeField/RangeSlider/useMouseSlide.ts +109 -0
- package/src/components/RangeField/RangeSlider/useRangeSlider.ts +126 -0
- package/src/components/RangeField/RangeSlider/useThumb.ts +18 -0
- package/src/components/RangeField/RangeSlider/useThumbKeyboard.ts +84 -0
- package/src/components/RangeField/RangeSlider/useTooltipsNudge.ts +92 -0
- package/src/components/RangeField/RangeSlider/useTrack.ts +116 -0
- package/src/components/RangeField/RangeSlider/vAnimateClick.ts +19 -0
- package/src/components/RangeField/config.ts +7 -0
- package/src/components/RangeField/locales.ts +4 -0
- package/src/components/RangeField/tests/RangeField.spec.ts +224 -0
- package/src/components/RangeField/tests/__snapshots__/RangeField.spec.ts.snap +379 -0
- package/src/components/RatingPicker/EmotionPicker/EmotionPicker.vue +205 -0
- package/src/components/RatingPicker/EmotionPicker/locales.ts +3 -0
- package/src/components/RatingPicker/EmotionPicker/tests/EmotionPicker.spec.ts +104 -0
- package/src/components/RatingPicker/EmotionPicker/tests/__snapshots__/EmotionPicker.spec.ts.snap +66 -0
- package/src/components/RatingPicker/NumberPicker/NumberPicker.vue +159 -0
- package/src/components/RatingPicker/NumberPicker/locales.ts +4 -0
- package/src/components/RatingPicker/NumberPicker/tests/NumberPicker.spec.ts +73 -0
- package/src/components/RatingPicker/NumberPicker/tests/__snapshots__/NumberPicker.spec.ts.snap +105 -0
- package/src/components/RatingPicker/Rating.ts +45 -0
- package/src/components/RatingPicker/RatingPicker.mdx +56 -0
- package/src/components/RatingPicker/RatingPicker.stories.ts +515 -0
- package/src/components/RatingPicker/RatingPicker.vue +122 -0
- package/src/components/RatingPicker/StarsPicker/StarsPicker.vue +116 -0
- package/src/components/RatingPicker/StarsPicker/tests/StarsPicker.spec.ts +95 -0
- package/src/components/RatingPicker/StarsPicker/tests/__snapshots__/StarsPicker.spec.ts.snap +36 -0
- package/src/components/RatingPicker/locales.ts +3 -0
- package/src/components/RatingPicker/tests/Rating.spec.ts +104 -0
- package/src/components/RatingPicker/tests/RatingPicker.spec.ts +187 -0
- package/src/components/RatingPicker/tests/__snapshots__/RatingPicker.spec.ts.snap +108 -0
- package/src/components/SearchListField/SearchListField.mdx +74 -0
- package/src/components/SearchListField/SearchListField.stories.ts +126 -0
- package/src/components/SearchListField/SearchListField.vue +194 -0
- package/src/components/SearchListField/locales.ts +5 -0
- package/src/components/SearchListField/tests/SearchListField.spec.ts +323 -0
- package/src/components/SearchListField/types.d.ts +4 -0
- package/src/components/SelectBtnField/SelectBtnField.mdx +50 -0
- package/src/components/SelectBtnField/SelectBtnField.stories.ts +763 -0
- package/src/components/SelectBtnField/SelectBtnField.vue +283 -0
- package/src/components/SelectBtnField/config.ts +11 -0
- package/src/components/SelectBtnField/tests/SelectBtnField.spec.ts +327 -0
- package/src/components/SelectBtnField/tests/__snapshots__/SelectBtnField.spec.ts.snap +125 -0
- package/src/components/SelectBtnField/types.d.ts +11 -0
- package/src/components/SkipLink/SkipLink.vue +10 -10
- package/src/components/SocialMediaLinks/SocialMediaLinks.vue +28 -26
- package/src/components/SubHeader/SubHeader.vue +32 -31
- package/src/components/SyAlert/SyAlert.vue +12 -12
- package/src/components/UserMenuBtn/UserMenuBtn.vue +1 -1
- package/src/components/UserMenuBtn/config.ts +1 -1
- package/src/components/index.ts +17 -7
- package/src/composables/rules/useFieldValidation.ts +172 -44
- package/src/designTokens/index.ts +6 -4
- package/src/designTokens/{bootstrapColors.md → paColors.md} +1 -1
- package/src/designTokens/tokens/cnam/cnamLightTheme.ts +2 -0
- package/src/designTokens/tokens/pa/paColors.ts +171 -0
- package/src/designTokens/tokens/pa/paContextual.ts +58 -0
- package/src/designTokens/tokens/pa/paDarkTheme.ts +5 -0
- package/src/designTokens/tokens/pa/paLightTheme.ts +123 -0
- package/src/designTokens/tokens/pa/paSemantic.ts +87 -0
- package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +52 -2
- package/src/stories/GuideDuDev/CreerUneIssue.mdx +64 -0
- package/src/stories/GuideDuDev/{CommentUtiliserLesRules.mdx → UtiliserLesRules.mdx} +2 -2
- package/src/stories/GuideDuDev/components.stories.ts +9 -7
- package/src/stories/Guidelines/Vuetify/Vuetify.stories.ts +163 -88
- package/src/stories/Guidelines/Vuetify/VuetifyItems.ts +250 -23
- package/src/temp/TestDTComponent.vue +5 -6
- package/src/utils/calcHumanFileSize/index.ts +12 -0
- package/src/utils/calcHumanFileSize/tests/calcHumanFileSize.spec.ts +21 -0
- package/src/designTokens/tokens/bootstrap/bootstrapColors.ts +0 -158
- package/src/designTokens/tokens/bootstrap/bootstrapLightTheme.ts +0 -22
- package/src/stories/GuideDuDev/CommentContribuer.mdx +0 -22
|
@@ -47,8 +47,6 @@ export const Default: Story = {
|
|
|
47
47
|
<PhoneField
|
|
48
48
|
v-model="modelValue"
|
|
49
49
|
:required="required"
|
|
50
|
-
:outlined="outlined"
|
|
51
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
52
50
|
:withCountryCode="withCountryCode"
|
|
53
51
|
:countryCodeRequired="countryCodeRequired"
|
|
54
52
|
:displayFormat="displayFormat"
|
|
@@ -63,12 +61,10 @@ export const Default: Story = {
|
|
|
63
61
|
name: 'Script',
|
|
64
62
|
code: `
|
|
65
63
|
<script setup lang="ts">
|
|
66
|
-
import PhoneField from '@cnamts/
|
|
64
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
67
65
|
|
|
68
66
|
const modelValue = ref('')
|
|
69
67
|
const required = ref(true)
|
|
70
|
-
const outlined = ref(true)
|
|
71
|
-
const outlinedIndicatif = ref(true)
|
|
72
68
|
const withCountryCode = ref(true)
|
|
73
69
|
const countryCodeRequired = ref(true)
|
|
74
70
|
const displayFormat = ref('code')
|
|
@@ -129,8 +125,6 @@ export const Required: Story = {
|
|
|
129
125
|
<PhoneField
|
|
130
126
|
v-model="modelValue"
|
|
131
127
|
:required="required"
|
|
132
|
-
:outlined="outlined"
|
|
133
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
134
128
|
:withCountryCode="withCountryCode"
|
|
135
129
|
:countryCodeRequired="countryCodeRequired"
|
|
136
130
|
:displayFormat="displayFormat"
|
|
@@ -145,12 +139,10 @@ export const Required: Story = {
|
|
|
145
139
|
name: 'Script',
|
|
146
140
|
code: `
|
|
147
141
|
<script setup lang="ts">
|
|
148
|
-
import PhoneField from '@cnamts/
|
|
142
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
149
143
|
|
|
150
144
|
const modelValue = ref('')
|
|
151
145
|
const required = ref(true)
|
|
152
|
-
const outlined = ref(true)
|
|
153
|
-
const outlinedIndicatif = ref(true)
|
|
154
146
|
const withCountryCode = ref(true)
|
|
155
147
|
const countryCodeRequired = ref(true)
|
|
156
148
|
const displayFormat = ref('code')
|
|
@@ -210,8 +202,6 @@ export const CustomIndicatifs: Story = {
|
|
|
210
202
|
<PhoneField
|
|
211
203
|
v-model="modelValue"
|
|
212
204
|
:required="required"
|
|
213
|
-
:outlined="outlined"
|
|
214
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
215
205
|
:withCountryCode="withCountryCode"
|
|
216
206
|
:countryCodeRequired="countryCodeRequired"
|
|
217
207
|
:displayFormat="displayFormat"
|
|
@@ -226,12 +216,10 @@ export const CustomIndicatifs: Story = {
|
|
|
226
216
|
name: 'Script',
|
|
227
217
|
code: `
|
|
228
218
|
<script setup lang="ts">
|
|
229
|
-
import PhoneField from '@cnamts/
|
|
219
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
230
220
|
|
|
231
221
|
const modelValue = ref('')
|
|
232
222
|
const required = ref(true)
|
|
233
|
-
const outlined = ref(true)
|
|
234
|
-
const outlinedIndicatif = ref(true)
|
|
235
223
|
const withCountryCode = ref(true)
|
|
236
224
|
const countryCodeRequired = ref(true)
|
|
237
225
|
const displayFormat = ref('code')
|
|
@@ -301,8 +289,6 @@ export const NotValidatedOnBlur: Story = {
|
|
|
301
289
|
<PhoneField
|
|
302
290
|
v-model="modelValue"
|
|
303
291
|
:required="required"
|
|
304
|
-
:outlined="outlined"
|
|
305
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
306
292
|
:withCountryCode="withCountryCode"
|
|
307
293
|
:countryCodeRequired="countryCodeRequired"
|
|
308
294
|
:displayFormat="displayFormat"
|
|
@@ -317,12 +303,10 @@ export const NotValidatedOnBlur: Story = {
|
|
|
317
303
|
name: 'Script',
|
|
318
304
|
code: `
|
|
319
305
|
<script setup lang="ts">
|
|
320
|
-
import PhoneField from '@cnamts/
|
|
306
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
321
307
|
|
|
322
308
|
const modelValue = ref('')
|
|
323
309
|
const required = ref(true)
|
|
324
|
-
const outlined = ref(true)
|
|
325
|
-
const outlinedIndicatif = ref(true)
|
|
326
310
|
const withCountryCode = ref(true)
|
|
327
311
|
const countryCodeRequired = ref(true)
|
|
328
312
|
const displayFormat = ref('code')
|
|
@@ -382,8 +366,6 @@ export const DisplayFormatCode: Story = {
|
|
|
382
366
|
<PhoneField
|
|
383
367
|
v-model="modelValue"
|
|
384
368
|
:required="required"
|
|
385
|
-
:outlined="outlined"
|
|
386
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
387
369
|
:withCountryCode="withCountryCode"
|
|
388
370
|
:countryCodeRequired="countryCodeRequired"
|
|
389
371
|
:displayFormat="displayFormat"
|
|
@@ -398,12 +380,10 @@ export const DisplayFormatCode: Story = {
|
|
|
398
380
|
name: 'Script',
|
|
399
381
|
code: `
|
|
400
382
|
<script setup lang="ts">
|
|
401
|
-
import PhoneField from '@cnamts/
|
|
383
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
402
384
|
|
|
403
385
|
const modelValue = ref('')
|
|
404
386
|
const required = ref(true)
|
|
405
|
-
const outlined = ref(true)
|
|
406
|
-
const outlinedIndicatif = ref(true)
|
|
407
387
|
const withCountryCode = ref(true)
|
|
408
388
|
const countryCodeRequired = ref(true)
|
|
409
389
|
const displayFormat = ref('code')
|
|
@@ -463,8 +443,6 @@ export const DisplayFormatCodeAbbreviation: Story = {
|
|
|
463
443
|
<PhoneField
|
|
464
444
|
v-model="modelValue"
|
|
465
445
|
:required="required"
|
|
466
|
-
:outlined="outlined"
|
|
467
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
468
446
|
:withCountryCode="withCountryCode"
|
|
469
447
|
:countryCodeRequired="countryCodeRequired"
|
|
470
448
|
:displayFormat="displayFormat"
|
|
@@ -479,12 +457,10 @@ export const DisplayFormatCodeAbbreviation: Story = {
|
|
|
479
457
|
name: 'Script',
|
|
480
458
|
code: `
|
|
481
459
|
<script setup lang="ts">
|
|
482
|
-
import PhoneField from '@cnamts/
|
|
460
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
483
461
|
|
|
484
462
|
const modelValue = ref('')
|
|
485
463
|
const required = ref(true)
|
|
486
|
-
const outlined = ref(true)
|
|
487
|
-
const outlinedIndicatif = ref(true)
|
|
488
464
|
const withCountryCode = ref(true)
|
|
489
465
|
const countryCodeRequired = ref(true)
|
|
490
466
|
const displayFormat = ref('code-abbreviation')
|
|
@@ -544,8 +520,6 @@ export const DisplayFormatCodeCountry: Story = {
|
|
|
544
520
|
<PhoneField
|
|
545
521
|
v-model="modelValue"
|
|
546
522
|
:required="required"
|
|
547
|
-
:outlined="outlined"
|
|
548
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
549
523
|
:withCountryCode="withCountryCode"
|
|
550
524
|
:countryCodeRequired="countryCodeRequired"
|
|
551
525
|
:displayFormat="displayFormat"
|
|
@@ -560,12 +534,10 @@ export const DisplayFormatCodeCountry: Story = {
|
|
|
560
534
|
name: 'Script',
|
|
561
535
|
code: `
|
|
562
536
|
<script setup lang="ts">
|
|
563
|
-
import PhoneField from '@cnamts/
|
|
537
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
564
538
|
|
|
565
539
|
const modelValue = ref('')
|
|
566
540
|
const required = ref(true)
|
|
567
|
-
const outlined = ref(true)
|
|
568
|
-
const outlinedIndicatif = ref(true)
|
|
569
541
|
const withCountryCode = ref(true)
|
|
570
542
|
const countryCodeRequired = ref(true)
|
|
571
543
|
const displayFormat = ref('code-country')
|
|
@@ -625,8 +597,6 @@ export const DisplayFormatCountry: Story = {
|
|
|
625
597
|
<PhoneField
|
|
626
598
|
v-model="modelValue"
|
|
627
599
|
:required="required"
|
|
628
|
-
:outlined="outlined"
|
|
629
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
630
600
|
:withCountryCode="withCountryCode"
|
|
631
601
|
:countryCodeRequired="countryCodeRequired"
|
|
632
602
|
:displayFormat="displayFormat"
|
|
@@ -641,12 +611,10 @@ export const DisplayFormatCountry: Story = {
|
|
|
641
611
|
name: 'Script',
|
|
642
612
|
code: `
|
|
643
613
|
<script setup lang="ts">
|
|
644
|
-
import PhoneField from '@cnamts/
|
|
614
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
645
615
|
|
|
646
616
|
const modelValue = ref('')
|
|
647
617
|
const required = ref(true)
|
|
648
|
-
const outlined = ref(true)
|
|
649
|
-
const outlinedIndicatif = ref(true)
|
|
650
618
|
const withCountryCode = ref(true)
|
|
651
619
|
const countryCodeRequired = ref(true)
|
|
652
620
|
const displayFormat = ref('country')
|
|
@@ -706,8 +674,6 @@ export const DisplayFormatAbbreviation: Story = {
|
|
|
706
674
|
<PhoneField
|
|
707
675
|
v-model="modelValue"
|
|
708
676
|
:required="required"
|
|
709
|
-
:outlined="outlined"
|
|
710
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
711
677
|
:withCountryCode="withCountryCode"
|
|
712
678
|
:countryCodeRequired="countryCodeRequired"
|
|
713
679
|
:displayFormat="displayFormat"
|
|
@@ -722,12 +688,10 @@ export const DisplayFormatAbbreviation: Story = {
|
|
|
722
688
|
name: 'Script',
|
|
723
689
|
code: `
|
|
724
690
|
<script setup lang="ts">
|
|
725
|
-
import PhoneField from '@cnamts/
|
|
691
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
726
692
|
|
|
727
693
|
const modelValue = ref('')
|
|
728
694
|
const required = ref(true)
|
|
729
|
-
const outlined = ref(true)
|
|
730
|
-
const outlinedIndicatif = ref(true)
|
|
731
695
|
const withCountryCode = ref(true)
|
|
732
696
|
const countryCodeRequired = ref(true)
|
|
733
697
|
const displayFormat = ref('abbreviation')
|
|
@@ -791,8 +755,6 @@ export const DisplayModels: Story = {
|
|
|
791
755
|
v-model="modelValue"
|
|
792
756
|
v-model:selectedDialCode="selectedDialCode"
|
|
793
757
|
:required="required"
|
|
794
|
-
:outlined="outlined"
|
|
795
|
-
:outlinedIndicatif="outlinedIndicatif"
|
|
796
758
|
:withCountryCode="withCountryCode"
|
|
797
759
|
:countryCodeRequired="countryCodeRequired"
|
|
798
760
|
:displayFormat="displayFormat"
|
|
@@ -807,13 +769,11 @@ export const DisplayModels: Story = {
|
|
|
807
769
|
name: 'Script',
|
|
808
770
|
code: `
|
|
809
771
|
<script setup lang="ts">
|
|
810
|
-
import PhoneField from '@cnamts/
|
|
772
|
+
import { PhoneField } from '@cnamts/synapse'
|
|
811
773
|
|
|
812
774
|
const modelValue = ref('')
|
|
813
775
|
const selectedDialCode = ref('')
|
|
814
776
|
const required = ref(true)
|
|
815
|
-
const outlined = ref(true)
|
|
816
|
-
const outlinedIndicatif = ref(true)
|
|
817
777
|
const withCountryCode = ref(true)
|
|
818
778
|
const countryCodeRequired = ref(true)
|
|
819
779
|
const displayFormat = ref('code-country')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { computed, ref, watch
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
3
|
import type { PropType } from 'vue'
|
|
4
4
|
import { required as RequiredRule } from '@/utils/rules/required'
|
|
5
5
|
import { exactLength } from '@/utils/rules/exactLength'
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
25
25
|
dialCodeModel: { type: [String, Object] as PropType<string | Record<string, any>>, default: '' },
|
|
26
26
|
required: { type: Boolean, default: false },
|
|
27
|
-
outlined: { type: Boolean, default:
|
|
28
|
-
outlinedIndicatif: { type: Boolean, default:
|
|
27
|
+
outlined: { type: Boolean, default: true },
|
|
28
|
+
outlinedIndicatif: { type: Boolean, default: true },
|
|
29
29
|
withCountryCode: { type: Boolean, default: false },
|
|
30
30
|
countryCodeRequired: { type: Boolean, default: false },
|
|
31
31
|
displayFormat: { type: String as PropType<DisplayFormat>, default: 'code' },
|
|
@@ -44,6 +44,34 @@
|
|
|
44
44
|
const hasError = ref(false)
|
|
45
45
|
const onBlur = ref(false)
|
|
46
46
|
|
|
47
|
+
function formatPhoneNumber(value: string): string {
|
|
48
|
+
if (!value) return ''
|
|
49
|
+
const cleaned = value.replace(/\D/g, '')
|
|
50
|
+
return cleaned.replace(/(.{2})/g, '$1 ').trim()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const computedValue = computed(() => formatPhoneNumber(phoneNumber.value))
|
|
54
|
+
|
|
55
|
+
watch(() => props.modelValue, (newVal) => {
|
|
56
|
+
phoneNumber.value = (newVal || '').replace(/\s/g, '')
|
|
57
|
+
}, { immediate: true })
|
|
58
|
+
|
|
59
|
+
watch(dialCode, (newVal) => {
|
|
60
|
+
emit('update:selectedDialCode', newVal)
|
|
61
|
+
if (typeof newVal === 'object' && newVal !== null) {
|
|
62
|
+
counter.value = newVal.phoneLength || 10
|
|
63
|
+
phoneMask.value = newVal.mask || '#'.repeat(newVal.phoneLength || 10).replace(/(.{2})/g, '$1 ').trim()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
function handlePhoneInput(event: Event) {
|
|
68
|
+
const input = (event.target as HTMLInputElement).value
|
|
69
|
+
const cleanedInput = input.replace(/\D/g, '')
|
|
70
|
+
phoneNumber.value = cleanedInput
|
|
71
|
+
emit('update:modelValue', cleanedInput)
|
|
72
|
+
emit('change', cleanedInput)
|
|
73
|
+
}
|
|
74
|
+
|
|
47
75
|
const mergedDialCodes = computed(() =>
|
|
48
76
|
props.useCustomIndicatifsOnly ? props.customIndicatifs : [...indicatifs, ...props.customIndicatifs],
|
|
49
77
|
)
|
|
@@ -66,28 +94,13 @@
|
|
|
66
94
|
return format[props.displayFormat] || ind.code
|
|
67
95
|
}
|
|
68
96
|
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
function applyPhoneMask(phone: string): string {
|
|
75
|
-
phone = phone.replace(/\D/g, '')
|
|
76
|
-
if (currentDialCode.value?.mask) {
|
|
77
|
-
const regex = new RegExp(currentDialCode.value.mask.replace(/#/g, '\\d'))
|
|
78
|
-
return phone.replace(regex, currentDialCode.value.mask).trim()
|
|
97
|
+
const validationRules = computed(() => {
|
|
98
|
+
const rules = [exactLength(counter.value, true)]
|
|
99
|
+
if (props.required) {
|
|
100
|
+
rules.unshift(RequiredRule)
|
|
79
101
|
}
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function handlePhoneInput(event: Event) {
|
|
84
|
-
const input = (event.target as HTMLInputElement).value.replace(/\s|\D/g, '')
|
|
85
|
-
phoneNumber.value = input.startsWith(String(dialCode.value) || '')
|
|
86
|
-
? input.slice(String(dialCode.value || '').length)
|
|
87
|
-
: input
|
|
88
|
-
emit('update:modelValue', phoneNumber.value)
|
|
89
|
-
emit('change', phoneNumber.value)
|
|
90
|
-
}
|
|
102
|
+
return rules
|
|
103
|
+
})
|
|
91
104
|
|
|
92
105
|
function validateInputOnBlur() {
|
|
93
106
|
if (!props.isValidatedOnBlur) return
|
|
@@ -100,34 +113,6 @@
|
|
|
100
113
|
onBlur.value = true
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
const validationRules = computed(() => {
|
|
104
|
-
const rules = [exactLength(counter.value, true)]
|
|
105
|
-
if (props.required) {
|
|
106
|
-
rules.unshift(RequiredRule)
|
|
107
|
-
}
|
|
108
|
-
return rules
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const computedValue = computed(() =>
|
|
112
|
-
phoneNumber.value ? applyPhoneMask(phoneNumber.value) : '',
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
watch(() => props.modelValue, (newVal) => {
|
|
116
|
-
phoneNumber.value = newVal || ''
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
watch(dialCode, (newVal) => {
|
|
120
|
-
emit('update:selectedDialCode', newVal)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
124
|
-
watch(dialCode, (selectedPhoneCode: any) => {
|
|
125
|
-
if (selectedPhoneCode) {
|
|
126
|
-
counter.value = selectedPhoneCode?.phoneLength || 10
|
|
127
|
-
phoneMask.value = selectedPhoneCode?.mask || '## ## ## ## ##'
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
116
|
defineExpose({
|
|
132
117
|
computedValue,
|
|
133
118
|
dialCode,
|
|
@@ -137,7 +122,6 @@
|
|
|
137
122
|
phoneNumber,
|
|
138
123
|
mergedDialCodes,
|
|
139
124
|
})
|
|
140
|
-
|
|
141
125
|
</script>
|
|
142
126
|
|
|
143
127
|
<template>
|
|
@@ -146,26 +130,26 @@
|
|
|
146
130
|
v-if="props.withCountryCode"
|
|
147
131
|
v-model="dialCode"
|
|
148
132
|
:items="dialCodeOptions"
|
|
149
|
-
text-key="displayText"
|
|
150
|
-
value-key="code"
|
|
151
133
|
:label="locales.indicatifLabel"
|
|
134
|
+
:outlined="outlinedIndicatif"
|
|
152
135
|
:required="props.countryCodeRequired"
|
|
153
136
|
class="custom-select"
|
|
154
|
-
|
|
137
|
+
text-key="displayText"
|
|
138
|
+
value-key="code"
|
|
155
139
|
/>
|
|
156
140
|
<SyTextField
|
|
141
|
+
v-model="phoneNumber"
|
|
157
142
|
v-maska="phoneMask"
|
|
158
|
-
:model-value="computedValue"
|
|
159
|
-
:rules="validationRules"
|
|
160
|
-
:required="props.required"
|
|
161
143
|
:counter="counter"
|
|
162
144
|
:counter-value="(value: string) => value.replace(/\s/g, '').length"
|
|
163
145
|
:label="locales.label"
|
|
146
|
+
:required="props.required"
|
|
147
|
+
:rules="validationRules"
|
|
164
148
|
:variant="outlined ? 'outlined' : 'underlined'"
|
|
149
|
+
class="phone-field"
|
|
165
150
|
color="primary"
|
|
166
|
-
class="phoneField"
|
|
167
|
-
@input="handlePhoneInput"
|
|
168
151
|
@blur="validateInputOnBlur"
|
|
152
|
+
@input="handlePhoneInput"
|
|
169
153
|
>
|
|
170
154
|
<template #append-inner>
|
|
171
155
|
<VIcon
|
|
@@ -184,46 +168,46 @@
|
|
|
184
168
|
|
|
185
169
|
<style scoped>
|
|
186
170
|
.phone-field-container {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
align-items: flex-start;
|
|
174
|
+
width: 100%;
|
|
191
175
|
}
|
|
192
176
|
|
|
193
|
-
.
|
|
194
|
-
|
|
177
|
+
.phone-field {
|
|
178
|
+
width: 100%;
|
|
195
179
|
}
|
|
196
180
|
|
|
197
181
|
.custom-select {
|
|
198
|
-
|
|
182
|
+
width: 30%;
|
|
199
183
|
}
|
|
200
184
|
|
|
201
|
-
@media (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
185
|
+
@media (width >= 600px) {
|
|
186
|
+
.phone-field-container {
|
|
187
|
+
flex-direction: row;
|
|
188
|
+
align-items: center;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.custom-select {
|
|
192
|
+
margin-right: 1rem;
|
|
193
|
+
margin-bottom: 0;
|
|
194
|
+
min-width: 144px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.phone-field {
|
|
198
|
+
min-width: 350px;
|
|
199
|
+
}
|
|
216
200
|
}
|
|
217
201
|
|
|
218
202
|
:deep(.v-list) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
203
|
+
position: absolute;
|
|
204
|
+
left: inherit !important;
|
|
205
|
+
background-color: white;
|
|
206
|
+
max-height: 300px;
|
|
207
|
+
padding: 0;
|
|
208
|
+
box-shadow: 0 2px 5px rgb(0 0 0 / 12%), 0 2px 10px rgb(0 0 0 / 8%);
|
|
209
|
+
border-radius: 4px;
|
|
210
|
+
overflow-y: auto;
|
|
211
|
+
z-index: 2;
|
|
228
212
|
}
|
|
229
213
|
</style>
|
|
@@ -96,21 +96,6 @@ describe('PhoneField', () => {
|
|
|
96
96
|
expect(wrapper.vm.hasError).toBe(false)
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
it('updates phoneNumber when modelValue prop changes', async () => {
|
|
100
|
-
const wrapper = mount(PhoneField, {
|
|
101
|
-
global: {
|
|
102
|
-
plugins: [vuetify],
|
|
103
|
-
},
|
|
104
|
-
props: {
|
|
105
|
-
modelValue: '1234567890',
|
|
106
|
-
},
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
await wrapper.setProps({ modelValue: '0987654321' })
|
|
110
|
-
|
|
111
|
-
expect(wrapper.vm.phoneNumber).toBe('0987654321')
|
|
112
|
-
})
|
|
113
|
-
|
|
114
99
|
it('uses only custom indicatifs when useCustomIndicatifsOnly is true', () => {
|
|
115
100
|
const customIndicatifs = [{ code: '+99', abbreviation: 'XX', country: 'Testland', phoneLength: 10 }]
|
|
116
101
|
const wrapper = mount(PhoneField, {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {Controls, Canvas, Meta, Source} from '@storybook/blocks';
|
|
2
|
+
import * as RangeFieldStories from './RangeField.stories.ts';
|
|
3
|
+
|
|
4
|
+
<Meta of={RangeFieldStories} />
|
|
5
|
+
|
|
6
|
+
# RangeField
|
|
7
|
+
|
|
8
|
+
Le composant RangeField est utilisé pour permettre à l'utilisateur de sélectionner un interval.
|
|
9
|
+
|
|
10
|
+
<Canvas of={RangeFieldStories.Default} />
|
|
11
|
+
|
|
12
|
+
# Api
|
|
13
|
+
|
|
14
|
+
<Controls of={RangeFieldStories.Default} />
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Personnalisation des limites
|
|
18
|
+
|
|
19
|
+
Vous pouvez personnaliser les limites de l'intervalle en utilisant les props `min` et `max`.
|
|
20
|
+
|
|
21
|
+
<Canvas
|
|
22
|
+
of={RangeFieldStories.OtherRange}
|
|
23
|
+
source={{
|
|
24
|
+
language: 'html',
|
|
25
|
+
format: 'dedent',
|
|
26
|
+
code: `
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { ref } from 'vue'
|
|
29
|
+
import { RangeField } from '@cnamts/synapse'
|
|
30
|
+
|
|
31
|
+
const range = ref([0, 100])
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<RangeField
|
|
36
|
+
v-model="range"
|
|
37
|
+
min="-50"
|
|
38
|
+
max="50"
|
|
39
|
+
/>
|
|
40
|
+
</template>
|
|
41
|
+
`
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Personnalisation des composants Vuetify
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Vous pouvez personnaliser les composants Vuetify `VTextField` utilisés dans le composant RangeField en utilisant la props `vuetifyOptions`.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
<Canvas
|
|
53
|
+
of={RangeFieldStories.Customization}
|
|
54
|
+
/>
|