@cnamts/synapse 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/{AutocompleteFilter-DXd4szWO.js → AutocompleteFilter-CGF33skz.js} +1 -1
  2. package/dist/{DateFilter-BD59Kgwf.js → DateFilter-D7-MsKtx.js} +1 -1
  3. package/dist/{NumberFilter-BSMZE7uw.js → NumberFilter-bjQPPfsj.js} +1 -1
  4. package/dist/{PeriodFilter-keUdSSk0.js → PeriodFilter-B3wJpK8-.js} +1 -1
  5. package/dist/{SelectFilter-Dhvvwazl.js → SelectFilter-BN6DbKAV.js} +1 -1
  6. package/dist/{TextFilter-CU8FpXz0.js → TextFilter-BffP0J2f.js} +1 -1
  7. package/dist/{apLightTheme2026-DbS7BPUf.js → apLightTheme2026-C4ygwMHC.js} +11 -11
  8. package/dist/components/Amelipro/AmeliproAutoCompleteField/AmeliproAutoCompleteField.d.ts +6 -6
  9. package/dist/components/Amelipro/AmeliproSelect/AmeliproSelect.d.ts +6 -6
  10. package/dist/components/Amelipro/AmeliproTabs/AmeliproTabs.d.ts +6 -6
  11. package/dist/components/Captcha/Captcha.d.ts +27 -16
  12. package/dist/components/Captcha/CaptchaForm.d.ts +29 -3
  13. package/dist/components/Captcha/types.d.ts +14 -0
  14. package/dist/components/Captcha/useCaptchaValidation.d.ts +37 -0
  15. package/dist/components/Customs/Selects/SelectBtnField/SelectBtnField.d.ts +33 -13
  16. package/dist/components/Customs/Selects/SelectBtnField/composables/useSelectBtnFieldValidation.d.ts +23 -0
  17. package/dist/components/Customs/Selects/SyAutocomplete/composables/useSyAutocompleteValidation.d.ts +2 -2
  18. package/dist/components/Customs/Selects/SySelect/composables/useSySelectValidation.d.ts +2 -2
  19. package/dist/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.d.ts +17 -48
  20. package/dist/components/Customs/SyCheckBoxGroup/composables/useSyCheckBoxGroupValidation.d.ts +29 -0
  21. package/dist/components/Customs/SyCheckBoxGroup/types.d.ts +46 -0
  22. package/dist/components/Customs/SyCheckbox/SyCheckbox.d.ts +16 -51
  23. package/dist/components/Customs/SyCheckbox/composables/useSyCheckboxValidation.d.ts +27 -0
  24. package/dist/components/Customs/SyCheckbox/types.d.ts +49 -0
  25. package/dist/components/Customs/SyTextField/FieldState.d.ts +5 -0
  26. package/dist/components/Customs/SyTextField/useSyTextFieldValidation.d.ts +3 -3
  27. package/dist/components/DialogBox/DialogBox.d.ts +2 -0
  28. package/dist/components/DialogBox/locales.d.ts +1 -0
  29. package/dist/components/FilterSideBar/FilterSideBar.d.ts +4 -0
  30. package/dist/components/LunarCalendar/LunarCalendar.d.ts +43 -14
  31. package/dist/components/LunarCalendar/types.d.ts +35 -0
  32. package/dist/components/LunarCalendar/useLunarCalendarValidation.d.ts +11 -12
  33. package/dist/components/MonthPicker/MonthPicker.d.ts +72 -1747
  34. package/dist/components/MonthPicker/MonthPickerText/MonthPickerInput.d.ts +21 -1733
  35. package/dist/components/MonthPicker/MonthPickerText/useTextField.d.ts +5 -0
  36. package/dist/components/MonthPicker/locales.d.ts +1 -0
  37. package/dist/components/MonthPicker/types.d.ts +11 -0
  38. package/dist/components/MonthPicker/useMonthPickerValidation.d.ts +37 -24
  39. package/dist/components/NirField/NirField.d.ts +6 -4
  40. package/dist/components/NirField/useNirValidation.d.ts +7 -5
  41. package/dist/components/PageContainer/PageContainer.d.ts +8 -0
  42. package/dist/components/PasswordField/PasswordField.d.ts +2 -2
  43. package/dist/components/PasswordField/usePasswordFieldValidation.d.ts +2 -2
  44. package/dist/components/PhoneField/PhoneField.d.ts +960 -1938
  45. package/dist/components/PhoneField/indicatifs.d.ts +715 -8
  46. package/dist/components/PhoneField/locales.d.ts +7 -0
  47. package/dist/components/PhoneField/types.d.ts +29 -0
  48. package/dist/components/PhoneField/usePhoneFieldValidation.d.ts +45 -0
  49. package/dist/components/PhoneField/usePhoneIndicatifs.d.ts +947 -0
  50. package/dist/components/SyTextArea/composables/useSyTextAreaValidation.d.ts +2 -2
  51. package/dist/composables/unifyValidation/documentationValidationProps.d.ts +1 -1
  52. package/dist/composables/unifyValidation/useValidation.d.ts +4 -5
  53. package/dist/design-system-v3.js +2 -2
  54. package/dist/designTokens/tokens/amelipro/apLightTheme.d.ts +10 -10
  55. package/dist/designTokens/tokens/baseTokens.d.ts +18 -18
  56. package/dist/designTokens/tokens/cnam/cnamLightTheme.d.ts +10 -10
  57. package/dist/designTokens/tokens/pa/paLightTheme.d.ts +10 -10
  58. package/dist/designTokens/tokens/semanticTokens.d.ts +14 -14
  59. package/dist/{main-D8ryUoS5.js → main-C4wAktOs.js} +13718 -12991
  60. package/dist/synapse.css +1 -1
  61. package/dist/vuetifyConfig.js +1 -1
  62. package/package.json +7 -7
  63. package/src/assets/compat/_legacy-tokens.scss +91 -0
  64. package/src/assets/overrides/_utilities.scss +23 -0
  65. package/src/components/Accordion/Accordion.stories.ts +121 -1
  66. package/src/components/BackBtn/BackBtn.mdx +1 -1
  67. package/src/components/BackToTopBtn/BackToTopBtn.mdx +0 -1
  68. package/src/components/Captcha/Captcha.stories.ts +134 -31
  69. package/src/components/Captcha/Captcha.vue +95 -28
  70. package/src/components/Captcha/CaptchaForm.vue +51 -22
  71. package/src/components/Captcha/tests/Captcha.focus.spec.ts +214 -0
  72. package/src/components/Captcha/tests/Captcha.spec.ts +233 -24
  73. package/src/components/Captcha/tests/CaptchaForm.spec.ts +82 -0
  74. package/src/components/Captcha/tests/__snapshots__/Captcha.spec.ts.snap +16 -42
  75. package/src/components/Captcha/types.ts +15 -0
  76. package/src/components/Captcha/useCaptchaValidation.ts +87 -0
  77. package/src/components/Captcha/validation/validation.stories.ts +1194 -0
  78. package/src/components/ChipList/ChipList.mdx +0 -1
  79. package/src/components/CollapsibleList/CollapsibleList.mdx +0 -1
  80. package/src/components/CookieBanner/CookieBanner.mdx +0 -1
  81. package/src/components/CopyBtn/CopyBtn.mdx +0 -1
  82. package/src/components/Customs/Selects/SelectBtnField/SelectBtnField.stories.ts +123 -439
  83. package/src/components/Customs/Selects/SelectBtnField/SelectBtnField.vue +147 -41
  84. package/src/components/Customs/Selects/SelectBtnField/Validation/Validation.stories.ts +600 -0
  85. package/src/components/Customs/Selects/SelectBtnField/composables/useSelectBtnFieldValidation.ts +87 -0
  86. package/src/components/Customs/Selects/SelectBtnField/tests/SelectBtnField.spec.ts +402 -33
  87. package/src/components/Customs/Selects/SelectBtnField/tests/__snapshots__/SelectBtnField.spec.ts.snap +52 -38
  88. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.stories.ts +342 -162
  89. package/src/components/Customs/SyCheckBoxGroup/SyCheckBoxGroup.vue +77 -129
  90. package/src/components/Customs/SyCheckBoxGroup/Validation/Validation.stories.ts +1008 -0
  91. package/src/components/Customs/SyCheckBoxGroup/composables/useSyCheckBoxGroupValidation.ts +107 -0
  92. package/src/components/Customs/SyCheckBoxGroup/tests/SyCheckBoxGroup.spec.ts +180 -7
  93. package/src/components/Customs/SyCheckBoxGroup/types.ts +49 -0
  94. package/src/components/Customs/SyCheckbox/SyCheckbox.stories.ts +41 -161
  95. package/src/components/Customs/SyCheckbox/SyCheckbox.vue +71 -148
  96. package/src/components/Customs/SyCheckbox/Validation/Validation.stories.ts +654 -0
  97. package/src/components/Customs/SyCheckbox/composables/useSyCheckboxValidation.ts +105 -0
  98. package/src/components/Customs/SyCheckbox/tests/SyCheckbox.spec.ts +106 -0
  99. package/src/components/Customs/SyCheckbox/tests/useSyCheckboxValidation.spec.ts +98 -0
  100. package/src/components/Customs/SyCheckbox/types.ts +51 -0
  101. package/src/components/Customs/SyTextField/FieldState.vue +50 -0
  102. package/src/components/Customs/SyTextField/SyTextField.vue +12 -9
  103. package/src/components/Customs/SyTextField/useSyTextFieldValidation.ts +2 -11
  104. package/src/components/DataList/DataList.mdx +0 -1
  105. package/src/components/DataListGroup/DataListGroup.mdx +0 -1
  106. package/src/components/DiacriticPicker/DiacriticPicker.mdx +0 -1
  107. package/src/components/DialogBox/DialogBox.mdx +0 -1
  108. package/src/components/DialogBox/DialogBox.stories.ts +399 -4
  109. package/src/components/DialogBox/DialogBox.vue +20 -0
  110. package/src/components/DialogBox/locales.ts +1 -0
  111. package/src/components/DialogBox/tests/DialogBox.spec.ts +73 -0
  112. package/src/components/DialogBox/tests/DialogBox.visual.cy.ts +24 -0
  113. package/src/components/ErrorPage/ErrorPage.mdx +1 -1
  114. package/src/components/ExternalLinks/ExternalLinks.mdx +0 -1
  115. package/src/components/FileList/FileList.mdx +0 -1
  116. package/src/components/FilterInline/FilterInline.mdx +0 -1
  117. package/src/components/FilterSideBar/FilterSideBar.mdx +8 -1
  118. package/src/components/FilterSideBar/FilterSideBar.stories.ts +133 -1
  119. package/src/components/FilterSideBar/FilterSideBar.vue +19 -2
  120. package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +55 -0
  121. package/src/components/FooterBar/FooterBar.mdx +0 -1
  122. package/src/components/FranceConnectBtn/FranceConnectBtn.mdx +0 -1
  123. package/src/components/HeaderBar/HeaderBar.mdx +0 -1
  124. package/src/components/HeaderLoading/HeaderLoading.mdx +0 -1
  125. package/src/components/LangBtn/LangBtn.mdx +0 -1
  126. package/src/components/Logo/Logo.mdx +1 -1
  127. package/src/components/LunarCalendar/LunarCalendar.mdx +6 -9
  128. package/src/components/LunarCalendar/LunarCalendar.stories.ts +243 -46
  129. package/src/components/LunarCalendar/LunarCalendar.vue +61 -26
  130. package/src/components/LunarCalendar/Validation/Validation.stories.ts +717 -0
  131. package/src/components/LunarCalendar/tests/LunarCalendar.a11y.spec.ts +1 -1
  132. package/src/components/LunarCalendar/tests/LunarCalendar.spec.ts +197 -6
  133. package/src/components/LunarCalendar/tests/useLunarCalendarValidation.spec.ts +287 -0
  134. package/src/components/LunarCalendar/types.ts +39 -0
  135. package/src/components/LunarCalendar/useLunarCalendarValidation.ts +115 -39
  136. package/src/components/MonthPicker/MonthPicker.stories.ts +38 -281
  137. package/src/components/MonthPicker/MonthPicker.vue +66 -17
  138. package/src/components/MonthPicker/MonthPickerText/MonthPickerInput.vue +44 -20
  139. package/src/components/MonthPicker/MonthPickerText/useTextField.ts +5 -0
  140. package/src/components/MonthPicker/Validation/Validation.stories.ts +1117 -0
  141. package/src/components/MonthPicker/locales.ts +1 -0
  142. package/src/components/MonthPicker/tests/MonthPicker.spec.ts +353 -2
  143. package/src/components/MonthPicker/tests/__snapshots__/MonthPicker.spec.ts.snap +12 -8
  144. package/src/components/MonthPicker/types.ts +16 -0
  145. package/src/components/MonthPicker/useMonthPickerValidation.ts +64 -27
  146. package/src/components/NirField/NirField.mdx +120 -66
  147. package/src/components/NirField/NirField.stories.ts +216 -0
  148. package/src/components/NirField/useNirValidation.ts +16 -17
  149. package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +263 -245
  150. package/src/components/NotificationBar/NotificationBar.mdx +0 -1
  151. package/src/components/PageContainer/PageContainer.mdx +0 -1
  152. package/src/components/PageContainer/PageContainer.stories.ts +170 -2
  153. package/src/components/PageContainer/PageContainer.vue +63 -8
  154. package/src/components/PageContainer/tests/__snapshots__/PageContainer.spec.ts.snap +19 -11
  155. package/src/components/PaginatedTable/PaginatedTable.mdx +0 -1
  156. package/src/components/PeriodField/PeriodField.mdx +0 -1
  157. package/src/components/PhoneField/PhoneField.mdx +2 -3
  158. package/src/components/PhoneField/PhoneField.stories.ts +227 -410
  159. package/src/components/PhoneField/PhoneField.vue +204 -438
  160. package/src/components/PhoneField/indicatifs.ts +1 -1
  161. package/src/components/PhoneField/locales.ts +7 -0
  162. package/src/components/PhoneField/tests/PhoneField.a11y.spec.ts +0 -1
  163. package/src/components/PhoneField/tests/PhoneField.spec.ts +517 -220
  164. package/src/components/PhoneField/types.ts +30 -0
  165. package/src/components/PhoneField/usePhoneFieldValidation.ts +119 -0
  166. package/src/components/PhoneField/usePhoneIndicatifs.ts +89 -0
  167. package/src/components/PhoneField/validation/validation.stories.ts +717 -0
  168. package/src/components/RangeField/RangeField.mdx +0 -1
  169. package/src/components/RatingPicker/RatingPicker.mdx +0 -1
  170. package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +0 -1
  171. package/src/components/StatusPage/StatusPage.vue +1 -0
  172. package/src/components/StatusPage/tests/__snapshots__/StatusPage.spec.ts.snap +248 -230
  173. package/src/components/SubHeader/SubHeader.mdx +5 -6
  174. package/src/components/Tables/common/tests/SyTableFilter.spec.ts +11 -12
  175. package/src/components/UploadWorkflow/UploadWorkflow.mdx +0 -1
  176. package/src/components/UserMenuBtn/UserMenuBtn.mdx +0 -1
  177. package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +177 -0
  178. package/src/composables/unifyValidation/documentationValidationProps.ts +1 -1
  179. package/src/composables/unifyValidation/tests/useValidation.spec.ts +13 -1
  180. package/src/composables/unifyValidation/useValidation.ts +37 -33
  181. package/src/composantsVuetify/VCard/VCard.mdx +4 -0
  182. package/src/composantsVuetify/VCard/v-card.stories.ts +93 -1
  183. package/src/composantsVuetify/VCarousel/VCarousel.mdx +74 -0
  184. package/src/composantsVuetify/VCarousel/v-carousel.stories.ts +531 -0
  185. package/src/composantsVuetify/VNavigationDrawer/VNavgationDrawer.mdx +53 -0
  186. package/src/composantsVuetify/VNavigationDrawer/v-navigation-drawer.stories.ts +310 -0
  187. package/src/composantsVuetify/VSlideGroup/VSlideGroup.mdx +105 -0
  188. package/src/composantsVuetify/VSlideGroup/v-slide-group.stories.ts +463 -0
  189. package/src/designTokens/tokens/baseColors.ts +1 -1
  190. package/src/designTokens/tokens/baseTokens.ts +18 -18
  191. package/src/stories/Components/Components.stories.ts +34 -1
  192. package/src/stories/Demarrer/Releases.stories.ts +16 -2
  193. package/src/stories/DesignTokens/Arrondis.mdx +1 -1
  194. package/src/stories/DesignTokens/Correspondances.mdx +219 -0
  195. package/src/stories/DesignTokens/UtiliserLesTokens.mdx +235 -0
  196. package/src/stories/DesignTokens/colors.stories.ts +569 -569
  197. package/src/stories/GuideDuDev/Amelipro.stories.ts +335 -267
  198. package/dist/components/LunarCalendar/useLunarCalendarRules.d.ts +0 -5
  199. package/dist/components/PhoneField/tests/types.d.ts +0 -18
  200. package/src/components/LunarCalendar/tests/useLunarCalendarRules.spec.ts +0 -184
  201. package/src/components/LunarCalendar/useLunarCalendarRules.ts +0 -96
  202. package/src/components/PhoneField/tests/types.d.ts +0 -19
@@ -1,64 +1,27 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref, watch, onMounted, onUpdated, nextTick } from 'vue'
2
+ import { computed, ref, watch, onMounted, onUpdated, nextTick, type Ref } from 'vue'
3
3
  import type { VCheckbox } from 'vuetify/components'
4
- import { useValidation, type ValidationRule } from '@/composables/validation/useValidation'
4
+ import SyIcon from '@/components/Customs/SyIcon/SyIcon.vue'
5
+ import { mdiCheckboxBlankOutline, mdiCheckboxMarked, mdiMinusBox } from '@mdi/js'
6
+ import { validationPropsDefaults } from '@/composables/unifyValidation/useValidation'
5
7
  import { useValidatable } from '@/composables/validation/useValidatable'
8
+ import { useSyCheckboxValidation } from './composables/useSyCheckboxValidation'
6
9
  import { cnamSemanticTokens } from '@/designTokens/tokens/cnam/cnamSemantic'
10
+ import type { SyCheckboxProps } from './types'
7
11
 
8
12
  const props = withDefaults(
9
- defineProps<{
10
- modelValue?: boolean | null
11
- indeterminate?: boolean
12
- label?: string
13
- ariaLabel?: string
14
- ariaLabelledby?: string
15
- title?: string
16
- color?: string
17
- disabled?: boolean
18
- readonly?: boolean
19
- required?: boolean
20
- hideDetails?: boolean | 'auto'
21
- density?: 'default' | 'comfortable' | 'compact'
22
- errorMessages?: string[] | null
23
- warningMessages?: string[] | null
24
- successMessages?: string[] | null
25
- customRules?: ValidationRule[]
26
- customWarningRules?: ValidationRule[]
27
- customSuccessRules?: ValidationRule[]
28
- showSuccessMessages?: boolean
29
- isValidateOnBlur?: boolean
30
- disableErrorHandling?: boolean
31
- id?: string
32
- name?: string
33
- value?: unknown
34
- trueValue?: unknown
35
- falseValue?: unknown
36
- controlsIds?: string[]
37
- displayAsterisk?: boolean
38
- decorative?: boolean
39
- }>(),
13
+ defineProps<SyCheckboxProps>(),
40
14
  {
41
15
  modelValue: false,
42
16
  indeterminate: false,
43
17
  label: undefined,
18
+ helpText: '',
44
19
  ariaLabel: undefined,
45
20
  ariaLabelledby: undefined,
46
21
  title: undefined,
47
22
  color: 'primary',
48
- disabled: false,
49
- readonly: false,
50
- required: false,
51
23
  hideDetails: 'auto',
52
24
  density: 'default',
53
- errorMessages: null,
54
- warningMessages: null,
55
- successMessages: null,
56
- customRules: () => [],
57
- customWarningRules: () => [],
58
- customSuccessRules: () => [],
59
- showSuccessMessages: false,
60
- isValidateOnBlur: false,
61
- disableErrorHandling: false,
62
25
  id: undefined,
63
26
  name: undefined,
64
27
  value: undefined,
@@ -67,17 +30,17 @@
67
30
  controlsIds: () => [],
68
31
  displayAsterisk: false,
69
32
  decorative: false,
33
+ ...validationPropsDefaults,
34
+ isValidateOnBlur: false,
70
35
  },
71
36
  )
72
37
 
73
38
  const emit = defineEmits(['update:modelValue', 'update:indeterminate', 'change'])
74
39
 
75
- import SyIcon from '@/components/Customs/SyIcon/SyIcon.vue'
76
- import { mdiCheckboxBlankOutline, mdiCheckboxMarked, mdiMinusBox } from '@mdi/js'
77
-
78
40
  const checkboxRef = ref<VCheckbox | null>(null)
79
41
 
80
42
  const internalIndeterminate = ref(props.indeterminate)
43
+ const focused = ref(false)
81
44
 
82
45
  const generatedLabel = computed(() => {
83
46
  return (props.label || '') + (props.displayAsterisk ? '*' : '')
@@ -101,110 +64,44 @@
101
64
  internalIndeterminate.value = val
102
65
  })
103
66
 
104
- // Initialisation du composable de validation
105
- // Variable pour suivre si le formulaire a été soumis
106
- const isSubmitted = ref(false)
107
-
108
- const validation = useValidation({
109
- showSuccessMessages: props.showSuccessMessages,
110
- fieldIdentifier: props.label,
111
- disableErrorHandling: props.disableErrorHandling,
112
- })
113
-
114
- // Synchronisation des messages externes
115
- watch(() => props.errorMessages, (newVal) => {
116
- validation.errors.value = newVal || []
117
- }, { immediate: true })
118
-
119
- watch(() => props.warningMessages, (newVal) => {
120
- validation.warnings.value = newVal || []
121
- }, { immediate: true })
122
-
123
- watch(() => props.successMessages, (newVal) => {
124
- validation.successes.value = newVal || []
125
- }, { immediate: true })
126
-
127
- // Construction des règles de validation
128
- const defaultRules = computed<ValidationRule[]>(() => props.required
129
- ? [{
130
- type: 'required',
131
- options: {
132
- message: `Le champ ${props.label || 'ce champ'} est requis.`,
133
- fieldIdentifier: props.label,
134
- },
135
- }]
136
- : [],
67
+ // Validation via le composable unifié dédié
68
+ const {
69
+ validate,
70
+ validateOnSubmit,
71
+ clearValidation,
72
+ errors,
73
+ warnings,
74
+ successes,
75
+ hasError,
76
+ hasWarning,
77
+ hasSuccess,
78
+ } = useSyCheckboxValidation(props, model as Ref<boolean | null>, focused)
79
+
80
+ // Texte d'aide affiché sous la case, tant qu'aucun message de validation n'est présent
81
+ const showHelpText = computed(() =>
82
+ !!props.helpText
83
+ && props.hideDetails !== true
84
+ && !hasError.value
85
+ && !hasWarning.value
86
+ && !(hasSuccess.value && props.showSuccessMessages),
137
87
  )
138
88
 
139
- const validateField = async (value: boolean | null) => {
140
- // Si en lecture seule ou si la valeur est null et non requise, pas de validation
141
- if (props.readonly) {
142
- validation.clearValidation()
143
- return true
144
- }
145
-
146
- if (value === null && !props.required) {
147
- validation.clearValidation()
148
- return true
149
- }
150
-
151
- // Pour les règles personnalisées qui vérifient si la case est cochée
152
- // Si la valeur est true, on peut déjà savoir que la validation va réussir
153
- if (value === true && props.customRules.every(rule =>
154
- rule.type === 'custom',
155
- )) {
156
- validation.clearValidation()
157
- return true
89
+ // Réinitialisation (appelée par SyForm via useValidatable)
90
+ const reset = () => {
91
+ clearValidation()
92
+ if (internalIndeterminate.value) {
93
+ internalIndeterminate.value = false
94
+ emit('update:indeterminate', false)
158
95
  }
159
-
160
- // Validation standard
161
- const result = await validation.validateField(
162
- value,
163
- [...defaultRules.value, ...props.customRules],
164
- props.customWarningRules,
165
- )
166
-
167
- return !result.hasError
168
- }
169
-
170
- const validateOnSubmit = () => {
171
- isSubmitted.value = true
172
- return validateField(model.value)
96
+ model.value = false
173
97
  }
174
98
 
99
+ // Validation au blur (en mode eager, c'est sans effet de bord)
175
100
  const checkErrorOnBlur = () => {
176
- validateField(model.value)
101
+ focused.value = false
102
+ return validate()
177
103
  }
178
104
 
179
- watch(model, async (newValue) => {
180
- if (!props.isValidateOnBlur) {
181
- // Si le formulaire a été soumis et que la valeur change, on valide à nouveau
182
- if (isSubmitted.value) {
183
- const isValid = await validateField(newValue)
184
- if (isValid) {
185
- // La validation a réussi, effacer les erreurs
186
- validation.clearValidation()
187
- }
188
- }
189
- else {
190
- // Comportement normal (hors soumission)
191
- const isValid = await validateField(newValue)
192
- // Si la validation réussit, s'assurer que les erreurs sont effacées
193
- if (isValid && validation.hasError.value) {
194
- validation.clearValidation()
195
- }
196
- }
197
- }
198
- })
199
-
200
- const hasError = computed(() => validation.hasError.value)
201
- const hasWarning = computed(() => validation.hasWarning.value)
202
- const hasSuccess = computed(() => validation.hasSuccess.value)
203
-
204
- const errors = computed(() => validation.errors.value)
205
- const warnings = computed(() => validation.warnings.value)
206
- const displaySuccesses = computed(() => validation.displaySuccesses.value)
207
-
208
105
  const ariaChecked = computed(() => {
209
106
  if (internalIndeterminate.value) return 'mixed'
210
107
  return model.value ? 'true' : 'false'
@@ -269,8 +166,8 @@
269
166
  removeAriaAttributes()
270
167
  })
271
168
 
272
- // Intégration avec le système de validation du formulaire
273
- useValidatable(validateOnSubmit)
169
+ // Intégration avec le système de validation du formulaire (auto-enregistrement SyForm)
170
+ useValidatable(validateOnSubmit, clearValidation, reset)
274
171
 
275
172
  const toggleMixed = () => {
276
173
  if (!props.readonly && !props.disabled) {
@@ -303,8 +200,9 @@
303
200
  }
304
201
 
305
202
  defineExpose({
306
- validation,
307
203
  validateOnSubmit,
204
+ clearValidation,
205
+ reset,
308
206
  checkErrorOnBlur,
309
207
  toggleMixed,
310
208
  })
@@ -358,13 +256,14 @@
358
256
  :density="props.density"
359
257
  :error="hasError"
360
258
  :error-messages="errors"
361
- :messages="hasError ? errors : (hasWarning ? warnings : (hasSuccess ? displaySuccesses : []))"
259
+ :messages="hasError ? errors : (hasWarning ? warnings : (hasSuccess && props.showSuccessMessages ? successes : []))"
362
260
  :indeterminate="internalIndeterminate"
363
261
  :true-value="props.trueValue"
364
262
  :false-value="props.falseValue"
365
263
  :aria-checked="ariaChecked"
366
264
  :aria-describedby="messageId"
367
265
  @click="toggleMixed"
266
+ @focus="focused = true"
368
267
  @blur="checkErrorOnBlur"
369
268
  >
370
269
  <template
@@ -380,10 +279,34 @@
380
279
  <slot />
381
280
  </template>
382
281
  </VCheckbox>
282
+
283
+ <div
284
+ v-if="showHelpText"
285
+ class="help-text-below"
286
+ :class="{ 'text-disabled': props.disabled }"
287
+ >
288
+ {{ props.helpText }}
289
+ </div>
383
290
  </div>
384
291
  </template>
385
292
 
386
293
  <style scoped>
294
+ .help-text-below {
295
+ color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
296
+ font-size: var(--v-fontSize-liensEtLibelles);
297
+ line-height: 1.2;
298
+ }
299
+
300
+ .help-text-below.text-disabled {
301
+ color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity));
302
+ }
303
+
304
+ .error-field :deep(.v-messages),
305
+ .warning-field :deep(.v-messages),
306
+ .success-field :deep(.v-messages) {
307
+ opacity: 1 !important;
308
+ }
309
+
387
310
  .success-field :deep(.v-messages__message) {
388
311
  color: rgb(var(--v-theme-onSuccessVariant)) !important;
389
312
  }