@cnamts/synapse 0.0.14-alpha → 0.0.15-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.
Files changed (86) hide show
  1. package/dist/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -2
  2. package/dist/components/Customs/SySelect/SySelect.d.ts +24 -12
  3. package/dist/components/Customs/SySelect/locales.d.ts +3 -0
  4. package/dist/components/Customs/SyTextField/SyTextField.d.ts +2 -2
  5. package/dist/components/DatePicker/DatePicker.d.ts +732 -16
  6. package/dist/components/DatePicker/DateTextInput.d.ts +8 -8
  7. package/dist/components/DialogBox/config.d.ts +1 -1
  8. package/dist/components/DownloadBtn/DownloadBtn.d.ts +2 -0
  9. package/dist/components/LangBtn/LangBtn.d.ts +467 -1
  10. package/dist/components/LangBtn/config.d.ts +1 -3
  11. package/dist/components/NirField/NirField.d.ts +13 -13
  12. package/dist/components/PasswordField/PasswordField.d.ts +2 -2
  13. package/dist/components/PeriodField/PeriodField.d.ts +1462 -30
  14. package/dist/components/PhoneField/PhoneField.d.ts +3 -3
  15. package/dist/components/SelectBtnField/SelectBtnField.d.ts +1 -1
  16. package/dist/components/SkipLink/SkipLink.d.ts +3 -2
  17. package/dist/components/UserMenuBtn/UserMenuBtn.d.ts +2 -0
  18. package/dist/components/index.d.ts +1 -0
  19. package/dist/design-system-v3.js +3038 -2936
  20. package/dist/design-system-v3.umd.cjs +1 -1
  21. package/dist/style.css +1 -1
  22. package/dist/vuetifyConfig.d.ts +1 -0
  23. package/package.json +1 -1
  24. package/src/components/BackBtn/Accessibilite.stories.ts +4 -0
  25. package/src/components/BackBtn/BackBtn.vue +2 -1
  26. package/src/components/BackToTopBtn/Accessibilite.stories.ts +4 -0
  27. package/src/components/BackToTopBtn/BackToTopBtn.stories.ts +78 -21
  28. package/src/components/BackToTopBtn/BackToTopBtn.vue +15 -0
  29. package/src/components/BackToTopBtn/config.ts +2 -2
  30. package/src/components/BackToTopBtn/tests/__snapshots__/BackToTopBtn.spec.ts.snap +4 -4
  31. package/src/components/CopyBtn/Accessibilite.stories.ts +4 -0
  32. package/src/components/Customs/SyBtnSelect/SyBtnSelect.stories.ts +2 -2
  33. package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +0 -1
  34. package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +3 -3
  35. package/src/components/Customs/SyInputSelect/SyInputSelect.vue +4 -4
  36. package/src/components/Customs/SySelect/SySelect.stories.ts +4 -0
  37. package/src/components/Customs/SySelect/SySelect.vue +75 -10
  38. package/src/components/Customs/SySelect/locales.ts +3 -0
  39. package/src/components/Customs/SySelect/tests/SySelect.spec.ts +24 -2
  40. package/src/components/Customs/SyTextField/SyTextField.stories.ts +1 -1
  41. package/src/components/Customs/SyTextField/SyTextField.vue +3 -3
  42. package/src/components/DatePicker/DatePicker.vue +82 -57
  43. package/src/components/DatePicker/DatePickerValidation.mdx +338 -0
  44. package/src/components/DatePicker/DatePickerValidation.stories.ts +22 -0
  45. package/src/components/DatePicker/DatePickerValidationExamples.vue +535 -0
  46. package/src/components/DatePicker/DateTextInput.vue +3 -3
  47. package/src/components/DatePicker/tests/DateTextInput.spec.ts +2 -2
  48. package/src/components/DialogBox/DialogBox.stories.ts +5 -2
  49. package/src/components/DialogBox/DialogBox.vue +1 -1
  50. package/src/components/DialogBox/config.ts +1 -1
  51. package/src/components/DownloadBtn/Accessibilite.stories.ts +4 -0
  52. package/src/components/DownloadBtn/DownloadBtn.stories.ts +17 -8
  53. package/src/components/DownloadBtn/DownloadBtn.vue +13 -6
  54. package/src/components/DownloadBtn/tests/__snapshots__/DownloadBtn.spec.ts.snap +0 -2
  55. package/src/components/FranceConnectBtn/Accessibilite.stories.ts +4 -0
  56. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.vue +3 -0
  57. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.vue +3 -0
  58. package/src/components/HeaderBar/HeaderBurgerMenu/menu.scss +19 -0
  59. package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +12 -2
  60. package/src/components/LangBtn/Accessibilite.stories.ts +4 -0
  61. package/src/components/LangBtn/LangBtn.stories.ts +1 -4
  62. package/src/components/LangBtn/LangBtn.vue +68 -9
  63. package/src/components/LangBtn/config.ts +0 -1
  64. package/src/components/LangBtn/tests/LangBtn.spec.ts +30 -2
  65. package/src/components/PageContainer/Accessibilite.stories.ts +36 -23
  66. package/src/components/PaginatedTable/PaginatedTable.stories.ts +144 -18
  67. package/src/components/PasswordField/PasswordField.stories.ts +6 -6
  68. package/src/components/PasswordField/PasswordField.vue +3 -3
  69. package/src/components/PeriodField/PeriodField.vue +4 -4
  70. package/src/components/PhoneField/PhoneField.stories.ts +216 -24
  71. package/src/components/PhoneField/PhoneField.vue +32 -2
  72. package/src/components/PhoneField/tests/PhoneField.spec.ts +161 -14
  73. package/src/components/RatingPicker/NumberPicker/NumberPicker.vue +2 -1
  74. package/src/components/RatingPicker/RatingPicker.stories.ts +1 -1
  75. package/src/components/SkipLink/Accessibilite.stories.ts +8 -0
  76. package/src/components/SkipLink/SkipLink.vue +11 -9
  77. package/src/components/SkipLink/tests/__snapshots__/skipLink.spec.ts.snap +7 -4
  78. package/src/components/SkipLink/tests/skipLink.spec.ts +120 -6
  79. package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +56 -0
  80. package/src/components/UserMenuBtn/UserMenuBtn.vue +4 -2
  81. package/src/components/UserMenuBtn/tests/UserMenuBtn.spec.ts +41 -0
  82. package/src/components/index.ts +1 -0
  83. package/src/composables/rules/useFieldValidation.ts +26 -3
  84. package/src/stories/Accessibilite/KitDePreAudit/Echantillonnage.mdx +1 -1
  85. package/src/stories/GuideDuDev/LesBreackingChanges.mdx +31 -2
  86. package/src/components/LangBtn/tests/Config.spec.ts +0 -24
@@ -1,5 +1,6 @@
1
1
  import type { StoryObj, Meta } from '@storybook/vue3'
2
2
  import PhoneField from './PhoneField.vue'
3
+ import { indicatifs } from './indicatifs'
3
4
 
4
5
  const meta = {
5
6
  title: 'Composants/Formulaires/PhoneField',
@@ -91,7 +92,7 @@ export const Default: Story = {
91
92
  useCustomIndicatifsOnly: false,
92
93
  isValidatedOnBlur: true,
93
94
  bgColor: undefined,
94
- readOnly: false,
95
+ readonly: false,
95
96
  disabled: false,
96
97
  },
97
98
  render: (args) => {
@@ -114,7 +115,7 @@ export const Default: Story = {
114
115
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
115
116
  :isValidatedOnBlur="args.isValidatedOnBlur"
116
117
  :bg-color="args.bgColor"
117
- :readOnly="args.readOnly"
118
+ :readonly="args.readonly"
118
119
  :disabled="args.disabled"
119
120
  />
120
121
  </div>
@@ -175,7 +176,7 @@ export const Required: Story = {
175
176
  useCustomIndicatifsOnly: false,
176
177
  isValidatedOnBlur: true,
177
178
  bgColor: undefined,
178
- readOnly: false,
179
+ readonly: false,
179
180
  disabled: false,
180
181
  },
181
182
  render: (args) => {
@@ -198,7 +199,7 @@ export const Required: Story = {
198
199
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
199
200
  :isValidatedOnBlur="args.isValidatedOnBlur"
200
201
  :bg-color="args.bgColor"
201
- :readOnly="args.readOnly"
202
+ :readonly="args.readonly"
202
203
  :disabled="args.disabled"
203
204
  />
204
205
  </div>
@@ -269,7 +270,7 @@ const phoneNumber = ref('')
269
270
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
270
271
  :isValidatedOnBlur="args.isValidatedOnBlur"
271
272
  :display-asterisk="args.displayAsterisk"
272
- :readOnly="args.readOnly"
273
+ :readonly="args.readonly"
273
274
  :disabled="args.disabled"
274
275
  :bg-color="args.bgColor"
275
276
  />
@@ -340,7 +341,7 @@ export const CustomIndicatifs: Story = {
340
341
  useCustomIndicatifsOnly: true,
341
342
  isValidatedOnBlur: true,
342
343
  bgColor: undefined,
343
- readOnly: false,
344
+ readonly: false,
344
345
  disabled: false,
345
346
  },
346
347
  render: (args) => {
@@ -362,7 +363,7 @@ export const CustomIndicatifs: Story = {
362
363
  :customIndicatifs="args.customIndicatifs"
363
364
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
364
365
  :isValidatedOnBlur="args.isValidatedOnBlur"
365
- :readOnly="args.readOnly"
366
+ :readonly="args.readonly"
366
367
  :disabled="args.disabled"
367
368
  :bg-color="args.bgColor"
368
369
  />
@@ -422,7 +423,7 @@ export const NotValidatedOnBlur: Story = {
422
423
  customIndicatifs: [],
423
424
  useCustomIndicatifsOnly: false,
424
425
  isValidatedOnBlur: false,
425
- readOnly: false,
426
+ readonly: false,
426
427
  disabled: false,
427
428
  bgColor: undefined,
428
429
  },
@@ -445,7 +446,7 @@ export const NotValidatedOnBlur: Story = {
445
446
  :customIndicatifs="args.customIndicatifs"
446
447
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
447
448
  :isValidatedOnBlur="args.isValidatedOnBlur"
448
- :readOnly="args.readOnly"
449
+ :readonly="args.readonly"
449
450
  :disabled="args.disabled"
450
451
  :bg-color="args.bgColor"
451
452
  />
@@ -505,7 +506,7 @@ export const DisplayFormatCode: Story = {
505
506
  customIndicatifs: [],
506
507
  useCustomIndicatifsOnly: false,
507
508
  isValidatedOnBlur: false,
508
- readOnly: false,
509
+ readonly: false,
509
510
  disabled: false,
510
511
  bgColor: undefined,
511
512
  },
@@ -528,7 +529,7 @@ export const DisplayFormatCode: Story = {
528
529
  :customIndicatifs="args.customIndicatifs"
529
530
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
530
531
  :isValidatedOnBlur="args.isValidatedOnBlur"
531
- :readOnly="args.readOnly"
532
+ :readonly="args.readonly"
532
533
  :disabled="args.disabled"
533
534
  :bg-color="args.bgColor"
534
535
  />
@@ -588,7 +589,7 @@ export const DisplayFormatCodeAbbreviation: Story = {
588
589
  customIndicatifs: [],
589
590
  useCustomIndicatifsOnly: false,
590
591
  isValidatedOnBlur: false,
591
- readOnly: false,
592
+ readonly: false,
592
593
  disabled: false,
593
594
  bgColor: undefined,
594
595
  },
@@ -611,7 +612,7 @@ export const DisplayFormatCodeAbbreviation: Story = {
611
612
  :customIndicatifs="args.customIndicatifs"
612
613
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
613
614
  :isValidatedOnBlur="args.isValidatedOnBlur"
614
- :readOnly="args.readOnly"
615
+ :readonly="args.readonly"
615
616
  :disabled="args.disabled"
616
617
  :bg-color="args.bgColor"
617
618
  />
@@ -671,7 +672,7 @@ export const DisplayFormatCodeCountry: Story = {
671
672
  customIndicatifs: [],
672
673
  useCustomIndicatifsOnly: false,
673
674
  isValidatedOnBlur: false,
674
- readOnly: false,
675
+ readonly: false,
675
676
  disabled: false,
676
677
  bgColor: undefined,
677
678
  },
@@ -694,7 +695,7 @@ export const DisplayFormatCodeCountry: Story = {
694
695
  :customIndicatifs="args.customIndicatifs"
695
696
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
696
697
  :isValidatedOnBlur="args.isValidatedOnBlur"
697
- :readOnly="args.readOnly"
698
+ :readonly="args.readonly"
698
699
  :disabled="args.disabled"
699
700
  :bg-color="args.bgColor"
700
701
  />
@@ -754,7 +755,7 @@ export const DisplayFormatCountry: Story = {
754
755
  customIndicatifs: [],
755
756
  useCustomIndicatifsOnly: false,
756
757
  isValidatedOnBlur: false,
757
- readOnly: false,
758
+ readonly: false,
758
759
  disabled: false,
759
760
  bgColor: undefined,
760
761
  },
@@ -777,7 +778,7 @@ export const DisplayFormatCountry: Story = {
777
778
  :customIndicatifs="args.customIndicatifs"
778
779
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
779
780
  :isValidatedOnBlur="args.isValidatedOnBlur"
780
- :readOnly="args.readOnly"
781
+ :readonly="args.readonly"
781
782
  :disabled="args.disabled"
782
783
  :bg-color="args.bgColor"
783
784
  />
@@ -837,7 +838,7 @@ export const DisplayFormatAbbreviation: Story = {
837
838
  customIndicatifs: [],
838
839
  useCustomIndicatifsOnly: false,
839
840
  isValidatedOnBlur: false,
840
- readOnly: false,
841
+ readonly: false,
841
842
  disabled: false,
842
843
  bgColor: undefined,
843
844
  },
@@ -860,7 +861,7 @@ export const DisplayFormatAbbreviation: Story = {
860
861
  :customIndicatifs="args.customIndicatifs"
861
862
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
862
863
  :isValidatedOnBlur="args.isValidatedOnBlur"
863
- :readOnly="args.readOnly"
864
+ :readonly="args.readonly"
864
865
  :disabled="args.disabled"
865
866
  :bg-color="args.bgColor"
866
867
  />
@@ -870,6 +871,197 @@ export const DisplayFormatAbbreviation: Story = {
870
871
  },
871
872
  }
872
873
 
874
+ export const DefaultDialCode: Story = {
875
+ parameters: {
876
+ sourceCode: [
877
+ {
878
+ name: 'Template',
879
+ code: `
880
+ <template>
881
+ <PhoneField
882
+ v-model="modelValue"
883
+ :dial-code-model="dialCodeModel"
884
+ :required="required"
885
+ :withCountryCode="withCountryCode"
886
+ :countryCodeRequired="countryCodeRequired"
887
+ :displayFormat="displayFormat"
888
+ :customIndicatifs="customIndicatifs"
889
+ :useCustomIndicatifsOnly="useCustomIndicatifsOnly"
890
+ :isValidatedOnBlur="isValidatedOnBlur"
891
+ />
892
+ </template>
893
+ `,
894
+ },
895
+ {
896
+ name: 'Script',
897
+ code: `
898
+ <script setup lang="ts">
899
+ import { ref } from 'vue'
900
+ import { PhoneField } from '@cnamts/synapse'
901
+
902
+ const modelValue = ref('')
903
+
904
+ // Indicatifs personnalisés
905
+ const customIndicatifs = [
906
+ { code: '+3433', country: 'Exemple', abbreviation: 'EX', phoneLength: 10, mask: '## ## ## ## ##' },
907
+ { code: '+34', country: 'Espagne', abbreviation: 'ES', phoneLength: 9, mask: '### ### ###' },
908
+ { code: '+41', country: 'Suisse', abbreviation: 'CH', phoneLength: 9, mask: '### ### ###' },
909
+ ]
910
+
911
+ // Pré-sélection de l'indicatif Exemple
912
+ const dialCodeModel = ref(customIndicatifs.find(ind => ind.country === 'Exemple'))
913
+
914
+ const required = ref(true)
915
+ const withCountryCode = ref(true)
916
+ const countryCodeRequired = ref(true)
917
+ const displayFormat = ref('code-country')
918
+ const useCustomIndicatifsOnly = ref(true)
919
+ const isValidatedOnBlur = ref(true)
920
+ </script>
921
+ `,
922
+ },
923
+ ],
924
+ },
925
+ args: {
926
+ modelValue: '',
927
+ dialCodeModel: { code: '+3433', country: 'Exemple', abbreviation: 'EX', phoneLength: 10, mask: '## ## ## ## ##' },
928
+ required: true,
929
+ outlined: true,
930
+ outlinedIndicatif: true,
931
+ withCountryCode: true,
932
+ countryCodeRequired: true,
933
+ displayFormat: 'code-country',
934
+ customIndicatifs: [
935
+ { code: '+3433', country: 'Exemple', abbreviation: 'EX', phoneLength: 10, mask: '## ## ## ## ##' },
936
+ { code: '+34', country: 'Espagne', abbreviation: 'ES', phoneLength: 9, mask: '### ### ###' },
937
+ { code: '+41', country: 'Suisse', abbreviation: 'CH', phoneLength: 9, mask: '### ### ###' },
938
+ ],
939
+ useCustomIndicatifsOnly: true,
940
+ isValidatedOnBlur: true,
941
+ bgColor: undefined,
942
+ readonly: false,
943
+ disabled: false,
944
+ },
945
+ render: (args) => {
946
+ return {
947
+ components: { PhoneField },
948
+ setup() {
949
+ return { args }
950
+ },
951
+ template: `
952
+ <div class="pa-4">
953
+ <h3>PhoneField avec indicatif pré-rempli</h3>
954
+ <p>Cette story montre comment pré-remplir l'indicatif téléphonique avec des indicatifs personnalisés.</p>
955
+ <PhoneField
956
+ v-model="args.modelValue"
957
+ :dial-code-model="args.dialCodeModel"
958
+ :required="args.required"
959
+ :outlined="args.outlined"
960
+ :outlinedIndicatif="args.outlinedIndicatif"
961
+ :withCountryCode="args.withCountryCode"
962
+ :countryCodeRequired="args.countryCodeRequired"
963
+ :displayFormat="args.displayFormat"
964
+ :customIndicatifs="args.customIndicatifs"
965
+ :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
966
+ :isValidatedOnBlur="args.isValidatedOnBlur"
967
+ :readonly="args.readonly"
968
+ :disabled="args.disabled"
969
+ :bg-color="args.bgColor"
970
+ />
971
+ </div>
972
+ `,
973
+ }
974
+ },
975
+ }
976
+
977
+ export const DefaultDialCodeStandard: Story = {
978
+ parameters: {
979
+ sourceCode: [
980
+ {
981
+ name: 'Template',
982
+ code: `
983
+ <template>
984
+ <PhoneField
985
+ v-model="phone"
986
+ :dial-code-model="dialCodeModel"
987
+ :with-country-code="true"
988
+ :country-code-required="true"
989
+ display-format="code-country"
990
+ />
991
+ </template>
992
+ `,
993
+ },
994
+ {
995
+ name: 'Script',
996
+ code: `
997
+ <script setup lang="ts">
998
+ import { ref } from 'vue'
999
+ import { PhoneField, indicatifs } from '@cnamts/synapse'
1000
+
1001
+ // Modèle pour le numéro de téléphone
1002
+ const phone = ref('')
1003
+
1004
+ // Recherche de l'indicatif France dans les indicatifs standards
1005
+ const franceIndicatif = indicatifs.find(ind => ind.country === 'France')
1006
+
1007
+ // Pré-remplissage avec l'indicatif France
1008
+ const dialCodeModel = ref(franceIndicatif)
1009
+ </script>
1010
+ `,
1011
+ },
1012
+ ],
1013
+ },
1014
+ args: {
1015
+ modelValue: '',
1016
+ dialCodeModel: indicatifs.find(ind => ind.country === 'France'),
1017
+ required: false,
1018
+ outlined: true,
1019
+ outlinedIndicatif: true,
1020
+ withCountryCode: true,
1021
+ countryCodeRequired: true,
1022
+ displayFormat: 'code-country',
1023
+ customIndicatifs: [],
1024
+ useCustomIndicatifsOnly: false,
1025
+ isValidatedOnBlur: true,
1026
+ bgColor: undefined,
1027
+ readonly: false,
1028
+ disabled: false,
1029
+ },
1030
+ render: (args) => {
1031
+ return {
1032
+ components: { PhoneField },
1033
+ setup() {
1034
+ return { args }
1035
+ },
1036
+ template: `
1037
+ <div class="pa-4">
1038
+ <h3>PhoneField avec indicatif standard pré-rempli</h3>
1039
+ <p>Cette story montre comment pré-remplir l'indicatif téléphonique avec les indicatifs standards.</p>
1040
+ <div class="mb-4">
1041
+ <strong>Indicatif sélectionné :</strong> {{ args.dialCodeModel ? args.dialCodeModel.code + ' ' + args.dialCodeModel.country : 'Aucun' }}
1042
+ </div>
1043
+ <PhoneField
1044
+ v-model="args.modelValue"
1045
+ :dial-code-model="args.dialCodeModel"
1046
+ :required="args.required"
1047
+ :outlined="args.outlined"
1048
+ :outlinedIndicatif="args.outlinedIndicatif"
1049
+ :withCountryCode="args.withCountryCode"
1050
+ :countryCodeRequired="args.countryCodeRequired"
1051
+ :displayFormat="args.displayFormat"
1052
+ :customIndicatifs="args.customIndicatifs"
1053
+ :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
1054
+ :isValidatedOnBlur="args.isValidatedOnBlur"
1055
+ :readonly="args.readonly"
1056
+ :disabled="args.disabled"
1057
+ :bg-color="args.bgColor"
1058
+ />
1059
+ </div>
1060
+ `,
1061
+ }
1062
+ },
1063
+ }
1064
+
873
1065
  export const DisplayModels: Story = {
874
1066
  parameters: {
875
1067
  sourceCode: [
@@ -926,7 +1118,7 @@ export const DisplayModels: Story = {
926
1118
  customIndicatifs: [],
927
1119
  useCustomIndicatifsOnly: false,
928
1120
  isValidatedOnBlur: false,
929
- readOnly: false,
1121
+ readonly: false,
930
1122
  bgColor: undefined,
931
1123
  },
932
1124
  render: (args) => {
@@ -952,7 +1144,7 @@ export const DisplayModels: Story = {
952
1144
  :customIndicatifs="args.customIndicatifs"
953
1145
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
954
1146
  :isValidatedOnBlur="args.isValidatedOnBlur"
955
- :readOnly="args.readOnly"
1147
+ :readonly="args.readonly"
956
1148
  :disabled="args.disabled"
957
1149
  :bg-color="args.bgColor"
958
1150
  />
@@ -1015,7 +1207,7 @@ export const DisabledErrorHandling: Story = {
1015
1207
  useCustomIndicatifsOnly: false,
1016
1208
  isValidatedOnBlur: true,
1017
1209
  disableErrorHandling: true,
1018
- readOnly: false,
1210
+ readonly: false,
1019
1211
  disabled: false,
1020
1212
  bgColor: undefined,
1021
1213
  },
@@ -1041,7 +1233,7 @@ export const DisabledErrorHandling: Story = {
1041
1233
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
1042
1234
  :isValidatedOnBlur="args.isValidatedOnBlur"
1043
1235
  :disableErrorHandling="args.disableErrorHandling"
1044
- :readOnly="args.readOnly"
1236
+ :readonly="args.readonly"
1045
1237
  :disabled="args.disabled"
1046
1238
  :bg-color="args.bgColor"
1047
1239
  />
@@ -1060,7 +1252,7 @@ export const DisabledErrorHandling: Story = {
1060
1252
  :useCustomIndicatifsOnly="args.useCustomIndicatifsOnly"
1061
1253
  :isValidatedOnBlur="args.isValidatedOnBlur"
1062
1254
  :disableErrorHandling="false"
1063
- :readOnly="args.readOnly"
1255
+ :readonly="args.readonly"
1064
1256
  :disabled="args.disabled"
1065
1257
  :bg-color="args.bgColor"
1066
1258
  />
@@ -34,7 +34,7 @@
34
34
  displayAsterisk: { type: Boolean, default: false },
35
35
  disableErrorHandling: { type: Boolean, default: false },
36
36
  bgColor: { type: String, default: undefined },
37
- readOnly: { type: Boolean, default: false },
37
+ readonly: { type: Boolean, default: false },
38
38
  disabled: { type: Boolean, default: false },
39
39
  })
40
40
 
@@ -86,6 +86,35 @@
86
86
  })),
87
87
  )
88
88
 
89
+ // Watcher pour initialiser dialCode à partir de props.dialCodeModel
90
+ // Placé après la définition de dialCodeOptions pour éviter l'erreur d'accès avant initialisation
91
+ watch(() => props.dialCodeModel, (newVal) => {
92
+ if (!newVal) {
93
+ dialCode.value = ''
94
+ return
95
+ }
96
+
97
+ // Si c'est un objet, on cherche l'indicatif correspondant dans la liste des options
98
+ if (typeof newVal === 'object') {
99
+ // On cherche l'indicatif avec le même code
100
+ const matchingOption = dialCodeOptions.value.find((opt) => {
101
+ return opt.code === newVal.code
102
+ })
103
+
104
+ if (matchingOption) {
105
+ // On utilise directement l'objet de la liste pour éviter les problèmes de référence
106
+ dialCode.value = matchingOption
107
+ }
108
+ else {
109
+ dialCode.value = newVal
110
+ }
111
+ }
112
+ else {
113
+ // Si c'est une chaîne ou autre chose, on l'utilise directement
114
+ dialCode.value = newVal
115
+ }
116
+ }, { immediate: true })
117
+
89
118
  function generateDisplayText(ind: Indicatif): string {
90
119
  const format = {
91
120
  'code': ind.code,
@@ -190,7 +219,7 @@
190
219
  :disable-error-handling="props.disableErrorHandling"
191
220
  :return-object="true"
192
221
  :bg-color="props.bgColor"
193
- :read-only="props.readOnly"
222
+ :readonly="props.readonly"
194
223
  :disabled="props.disabled"
195
224
  class="custom-select"
196
225
  text-key="displayText"
@@ -209,6 +238,7 @@
209
238
  :success-messages="successes"
210
239
  :variant="outlined ? 'outlined' : 'underlined'"
211
240
  :display-asterisk="props.displayAsterisk"
241
+ :readonly="props.readonly"
212
242
  :bg-color="props.bgColor"
213
243
  :disabled="props.disabled"
214
244
  :class="{
@@ -163,42 +163,189 @@ describe('PhoneField', () => {
163
163
  })
164
164
 
165
165
  it('passes dialCode object to SyTextField when dialCode is set', async () => {
166
+ const dialCodeModelValue = { code: '+33', abbreviation: 'FR', country: 'France', phoneLength: 10, mask: '## ## ## ## ##' }
167
+
166
168
  const wrapper = mount(PhoneField, {
167
169
  global: {
168
170
  plugins: [vuetify],
169
171
  },
170
172
  props: {
171
173
  withCountryCode: true,
172
- dialCodeModel: { code: '+33', abbreviation: 'FR', country: 'France', phoneLength: 10, mask: '## ## ## ## ##' },
174
+ dialCodeModel: dialCodeModelValue,
173
175
  },
174
176
  })
175
177
 
176
- // Vérifier que le dialCode est bien un objet
178
+ await wrapper.vm.$nextTick()
179
+
180
+ expect(wrapper.vm.dialCode).toBeDefined()
177
181
  expect(typeof wrapper.vm.dialCode).toBe('object')
178
182
 
179
- // Trouver le composant SyTextField
180
- const textField = wrapper.findComponent({ name: 'SyTextField' })
181
- expect(textField.exists()).toBe(true)
183
+ type Indicatif = {
184
+ code: string
185
+ country: string
186
+ abbreviation: string
187
+ phoneLength: number
188
+ mask: string
189
+ displayText?: string
190
+ }
191
+ const dialCode = wrapper.vm.dialCode as Indicatif
192
+
193
+ expect(dialCode.code).toBe('+33')
194
+ expect(dialCode.country).toBe('France')
195
+ expect(dialCode.phoneLength).toBe(10)
196
+ expect(dialCode.abbreviation).toBe('FR')
197
+ expect(dialCode.mask).toBe('## ## ## ## ##')
198
+
199
+ expect(dialCode).toHaveProperty('displayText')
200
+ expect(typeof dialCode.displayText).toBe('string')
182
201
 
183
- // Vérifier que les propriétés du SyTextField sont correctement définies en fonction du dialCode
184
202
  expect(wrapper.vm.phoneMask).toBe('## ## ## ## ##')
185
203
  expect(wrapper.vm.counter).toBe(10)
186
204
 
187
- // Vérifier que le SyTextField reçoit les bonnes propriétés
205
+ const textField = wrapper.findComponent({ name: 'SyTextField' })
206
+ expect(textField.exists()).toBe(true)
188
207
  expect(textField.props('counter')).toBe(10)
189
208
 
190
- // Vérifier que le SySelect est présent et reçoit l'objet dialCode
191
209
  const select = wrapper.findComponent({ name: 'SySelect' })
192
210
  expect(select.exists()).toBe(true)
193
211
  expect(select.props('returnObject')).toBe(true)
194
212
 
195
- // Vérifier que l'objet dialCode est correctement passé au SySelect via v-model
196
- expect(wrapper.vm.dialCode).toEqual({
197
- code: '+33',
198
- abbreviation: 'FR',
199
- country: 'France',
213
+ expect(select.props('modelValue')).toEqual(wrapper.vm.dialCode)
214
+ })
215
+
216
+ // Test du watcher pour dialCodeModel
217
+ it('updates dialCode when dialCodeModel changes after mount', async () => {
218
+ const wrapper = mount(PhoneField, {
219
+ global: {
220
+ plugins: [vuetify],
221
+ },
222
+ props: {
223
+ withCountryCode: true,
224
+ // Pas de dialCodeModel initial
225
+ },
226
+ })
227
+
228
+ // Vérifier que dialCode est initialisé avec une chaîne vide
229
+ // Dans le composant: const dialCode = ref<string | Record<string, any>>(props.dialCodeModel || '')
230
+ expect(wrapper.vm.dialCode).toBe('')
231
+
232
+ // Définir un dialCodeModel après le montage
233
+ await wrapper.setProps({
234
+ dialCodeModel: { code: '+1', country: 'USA', abbreviation: 'US', phoneLength: 10, mask: '###-###-####' },
235
+ })
236
+
237
+ // Attendre que le watcher s'exécute
238
+ await wrapper.vm.$nextTick()
239
+
240
+ // Vérifier que dialCode a été mis à jour
241
+ expect(wrapper.vm.dialCode).toBeDefined()
242
+ expect(typeof wrapper.vm.dialCode).toBe('object')
243
+
244
+ // Utiliser une assertion de type pour indiquer à TypeScript que dialCode est un objet
245
+ type Indicatif = {
246
+ code: string
247
+ country: string
248
+ abbreviation: string
249
+ phoneLength: number
250
+ mask: string
251
+ displayText?: string
252
+ }
253
+ const dialCode = wrapper.vm.dialCode as Indicatif
254
+
255
+ expect(dialCode.code).toBe('+1')
256
+ expect(dialCode.country).toBe('USA/Canada')
257
+ expect(wrapper.vm.phoneMask).toBe('### ### ####')
258
+ expect(wrapper.vm.counter).toBe(10)
259
+ })
260
+
261
+ // Test pour les objets sans displayText
262
+ it('handles dialCodeModel objects without displayText property', async () => {
263
+ // Objet indicatif sans propriété displayText
264
+ const indicatifSansDisplayText = {
265
+ code: '+44',
266
+ country: 'United Kingdom',
267
+ abbreviation: 'GB',
200
268
  phoneLength: 10,
201
- mask: '## ## ## ## ##',
269
+ mask: '#### ### ####',
270
+ }
271
+
272
+ const wrapper = mount(PhoneField, {
273
+ global: {
274
+ plugins: [vuetify],
275
+ },
276
+ props: {
277
+ withCountryCode: true,
278
+ dialCodeModel: indicatifSansDisplayText,
279
+ },
280
+ })
281
+
282
+ await wrapper.vm.$nextTick()
283
+
284
+ // Vérifier que dialCode a été correctement initialisé
285
+ expect(wrapper.vm.dialCode).toBeDefined()
286
+
287
+ // Utiliser une assertion de type pour indiquer à TypeScript que dialCode est un objet
288
+ type Indicatif = {
289
+ code: string
290
+ country: string
291
+ abbreviation: string
292
+ phoneLength: number
293
+ mask: string
294
+ displayText?: string
295
+ }
296
+ const dialCode = wrapper.vm.dialCode as Indicatif
297
+
298
+ expect(dialCode.code).toBe('+44')
299
+ expect(dialCode.country).toBe('United Kingdom')
300
+
301
+ // Vérifier que la propriété displayText a été ajoutée
302
+ expect(dialCode).toHaveProperty('displayText')
303
+ expect(typeof dialCode.displayText).toBe('string')
304
+ // Le format exact dépend de la fonction generateDisplayText, mais on peut vérifier qu'il contient le code
305
+ expect(dialCode.displayText).toContain('+44')
306
+ })
307
+
308
+ // Test avec les indicatifs standards importés
309
+ it('works correctly with standard indicatifs imported from indicatifs.ts', async () => {
310
+ // Importer les indicatifs standards
311
+ const { indicatifs } = await import('../indicatifs')
312
+
313
+ // Trouver l'indicatif pour la France
314
+ const franceIndicatif = indicatifs.find(ind => ind.country === 'France')
315
+ expect(franceIndicatif).toBeDefined()
316
+
317
+ const wrapper = mount(PhoneField, {
318
+ global: {
319
+ plugins: [vuetify],
320
+ },
321
+ props: {
322
+ withCountryCode: true,
323
+ dialCodeModel: franceIndicatif,
324
+ },
202
325
  })
326
+
327
+ await wrapper.vm.$nextTick()
328
+
329
+ // Vérifier que l'indicatif a été correctement appliqué
330
+ expect(wrapper.vm.dialCode).toBeDefined()
331
+
332
+ // Utiliser une assertion de type pour indiquer à TypeScript que dialCode est un objet
333
+ type Indicatif = {
334
+ code: string
335
+ country: string
336
+ abbreviation: string
337
+ phoneLength: number
338
+ mask: string
339
+ displayText?: string
340
+ }
341
+ const dialCode = wrapper.vm.dialCode as Indicatif
342
+
343
+ expect(dialCode.code).toBe('+33')
344
+ expect(dialCode.country).toBe('France')
345
+
346
+ // Vérifier que le SySelect affiche la bonne valeur
347
+ const select = wrapper.findComponent({ name: 'SySelect' })
348
+ expect(select.exists()).toBe(true)
349
+ expect(select.props('modelValue')).toEqual(wrapper.vm.dialCode)
203
350
  })
204
351
  })
@@ -3,12 +3,13 @@
3
3
  import { RatingEnum, useRating } from '../Rating'
4
4
  import { locales } from './locales'
5
5
  import type { PropType } from 'vue'
6
+ import type { ItemType } from '@/components/Customs/SySelect/SySelect.vue'
6
7
 
7
8
  import SySelect from '@/components/Customs/SySelect/SySelect.vue'
8
9
 
9
10
  import { useDisplay } from 'vuetify'
10
11
 
11
- interface SelectItem {
12
+ interface SelectItem extends ItemType {
12
13
  text: string
13
14
  value: number
14
15
  }