@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,71 +1,38 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onMounted, ref, watch } from 'vue'
2
+ import { computed, ref } from 'vue'
3
3
  import { VMessages } from 'vuetify/components'
4
- import { useValidation, type ValidationRule } from '@/composables/validation/useValidation'
4
+ import { validationPropsDefaults } from '@/composables/unifyValidation/useValidation'
5
5
  import { useValidatable } from '@/composables/validation/useValidatable'
6
+ import { useSyCheckBoxGroupValidation } from './composables/useSyCheckBoxGroupValidation'
6
7
  import SyCheckbox from '@/components/Customs/SyCheckbox/SyCheckbox.vue'
7
8
  import { locales } from './locales'
8
- import type { Option } from './types'
9
+ import type { SyCheckBoxGroupProps } from './types'
9
10
 
10
11
  const props = withDefaults(
11
- defineProps<{
12
- ariaLabel?: string
13
- ariaLabelledby?: string
14
- color?: string
15
- customRules?: ValidationRule[]
16
- customSuccessRules?: ValidationRule[]
17
- customWarningRules?: ValidationRule[]
18
- density?: 'default' | 'comfortable' | 'compact'
19
- disabled?: boolean
20
- disableErrorHandling?: boolean
21
- displayAsterisk?: boolean
22
- errorMessages?: string[] | null
23
- hideDetails?: boolean | 'auto'
24
- id?: string
25
- isValidateOnBlur?: boolean
26
- label?: string
27
- modelValue?: (string | number) | (string | number)[] | null
28
- multiple?: boolean
29
- name?: string
30
- options?: Option[]
31
- readonly?: boolean
32
- required?: boolean
33
- showSuccessMessages?: boolean
34
- successMessages?: string[] | null
35
- title?: string
36
- warningMessages?: string[] | null
37
- }>(),
12
+ defineProps<SyCheckBoxGroupProps>(),
38
13
  {
39
14
  ariaLabel: undefined,
40
15
  ariaLabelledby: undefined,
41
16
  color: 'primary',
42
- customRules: () => [],
43
- customSuccessRules: () => [],
44
- customWarningRules: () => [],
45
17
  density: 'default',
46
- disabled: false,
47
- disableErrorHandling: false,
48
18
  displayAsterisk: false,
49
- errorMessages: null,
19
+ helpText: '',
50
20
  hideDetails: 'auto',
51
21
  id: undefined,
52
- isValidateOnBlur: false,
53
22
  label: undefined,
54
23
  modelValue: null,
55
24
  multiple: false,
56
25
  name: undefined,
57
26
  options: () => [],
58
- readonly: false,
59
- required: false,
60
- showSuccessMessages: false,
61
- successMessages: null,
62
27
  title: undefined,
63
- warningMessages: null,
28
+ ...validationPropsDefaults,
29
+ isValidateOnBlur: false,
64
30
  },
65
31
  )
66
32
 
67
33
  const emit = defineEmits(['update:modelValue', 'change'])
68
34
 
35
+ const focused = ref(false)
69
36
  const isMultiple = computed(() => props.multiple)
70
37
 
71
38
  const model = computed({
@@ -78,31 +45,26 @@
78
45
  },
79
46
  })
80
47
 
81
- const generatedLabel = computed(() => (props.label || '') + (props.displayAsterisk ? '*' : ''))
82
-
83
- const isSubmitted = ref(false)
48
+ const generatedLabel = computed(() => (props.label || '') + (props.displayAsterisk ? ' *' : ''))
84
49
 
85
- const validation = useValidation({
86
- showSuccessMessages: props.showSuccessMessages,
87
- fieldIdentifier: props.label,
88
- disableErrorHandling: props.disableErrorHandling,
89
- })
90
-
91
- watch(() => props.errorMessages, value => (validation.errors.value = value || []), { immediate: true })
92
- watch(() => props.warningMessages, value => (validation.warnings.value = value || []), { immediate: true })
93
- watch(() => props.successMessages, value => (validation.successes.value = value || []), { immediate: true })
94
-
95
- const defaultRules = computed<ValidationRule[]>(() =>
96
- props.required
97
- ? [{
98
- type: 'required',
99
- options: {
100
- message: `Le champ ${props.label || 'ce champ'} est requis.`,
101
- fieldIdentifier: props.label,
102
- },
103
- }]
104
- : [],
105
- )
50
+ // Utilisation du composable de validation unifié
51
+ const {
52
+ validate,
53
+ validateOnSubmit,
54
+ clearValidation,
55
+ errors,
56
+ warnings,
57
+ successes,
58
+ hasError,
59
+ hasWarning,
60
+ hasSuccess,
61
+ defaultRules,
62
+ } = useSyCheckBoxGroupValidation(props, model, focused)
63
+
64
+ const reset = () => {
65
+ clearValidation()
66
+ model.value = props.multiple ? [] : null
67
+ }
106
68
 
107
69
  function isOptionChecked(value: string | number): boolean {
108
70
  if (isMultiple.value) {
@@ -125,58 +87,8 @@
125
87
  model.value = model.value === value ? null : value
126
88
  }
127
89
 
128
- function getValidationValue(): (string | number) | (string | number)[] | null {
129
- if (isMultiple.value) {
130
- return Array.isArray(model.value) ? model.value : []
131
- }
132
- return model.value as (string | number) | null
133
- }
134
-
135
- const validateField = async (value: (string | number) | (string | number)[] | null) => {
136
- if (props.readonly) {
137
- validation.clearValidation()
138
- return true
139
- }
140
-
141
- if (!props.required && (value === null || (Array.isArray(value) && value.length === 0))) {
142
- validation.clearValidation()
143
- return true
144
- }
145
-
146
- const result = await validation.validateField(
147
- value,
148
- [...defaultRules.value, ...props.customRules],
149
- props.customWarningRules,
150
- props.customSuccessRules,
151
- )
152
- return !result.hasError
153
- }
154
-
155
- const validateOnSubmit = async () => {
156
- isSubmitted.value = true
157
- return await validateField(getValidationValue())
158
- }
159
-
160
- const checkErrorOnBlur = () => {
161
- validateField(getValidationValue())
162
- }
163
-
164
- watch(model, async (newValue) => {
165
- if (!props.isValidateOnBlur || isSubmitted.value) {
166
- await validateField(newValue as (string | number) | (string | number)[] | null)
167
- }
168
- })
169
-
170
- const hasError = computed(() => validation.hasError.value)
171
- const hasWarning = computed(() => validation.hasWarning.value)
172
- const hasSuccess = computed(() => validation.hasSuccess.value)
173
-
174
90
  const checkboxColor = computed(() => (hasError.value ? 'error' : props.color))
175
91
 
176
- const errors = computed(() => validation.errors.value)
177
- const warnings = computed(() => validation.warnings.value)
178
- const displaySuccesses = computed(() => validation.displaySuccesses.value)
179
-
180
92
  const labelId = computed(() => (props.id ? `${props.id}-label` : undefined))
181
93
  const computedAriaLabelledby = computed(() => {
182
94
  if (props.label && labelId.value) {
@@ -185,6 +97,13 @@
185
97
  return props.ariaLabelledby
186
98
  })
187
99
 
100
+ const hasMessages = computed(() =>
101
+ errors.value.length > 0 || warnings.value.length > 0 || successes.value.length > 0,
102
+ )
103
+
104
+ const showHelpTextAsMessage = computed(() => !!props.helpText && !hasMessages.value)
105
+ const showHelpTextBelow = computed(() => !!props.helpText && hasMessages.value && props.hideDetails !== true)
106
+
188
107
  const messagesRef = ref<InstanceType<typeof VMessages> | null>(null)
189
108
  const vMessagesId = computed(() => messagesRef.value?.$el.id)
190
109
 
@@ -204,18 +123,21 @@
204
123
  return ids.length > 0 ? ids.join(' ') : undefined
205
124
  })
206
125
 
207
- onMounted(() => {
208
- if (!props.isValidateOnBlur && !props.required) {
209
- validateField(getValidationValue())
210
- }
211
- })
212
-
213
- useValidatable(validateOnSubmit)
126
+ // Intégration avec le système de validation du formulaire
127
+ useValidatable(validateOnSubmit, clearValidation, reset)
214
128
 
215
129
  defineExpose({
216
- validation,
217
130
  validateOnSubmit,
218
- checkErrorOnBlur,
131
+ clearValidation,
132
+ reset,
133
+ defaultRules,
134
+ checkErrorOnBlur: () => {
135
+ focused.value = false
136
+ if (props.isValidateOnBlur) {
137
+ return validate()
138
+ }
139
+ return Promise.resolve(true)
140
+ },
219
141
  })
220
142
  </script>
221
143
 
@@ -257,19 +179,35 @@
257
179
  :hide-details="props.hideDetails"
258
180
  :density="props.density"
259
181
  @update:model-value="() => toggleOption(opt.value)"
260
- @blur="checkErrorOnBlur"
182
+ @focus="focused = true"
183
+ @blur="focused = false"
261
184
  />
262
185
  </div>
263
186
 
264
187
  <div
265
- v-if="props.hideDetails !== true && (hasError || hasWarning || (hasSuccess && props.showSuccessMessages))"
188
+ v-if="props.hideDetails !== true && (hasError || hasWarning || (hasSuccess && props.showSuccessMessages) || showHelpTextAsMessage)"
266
189
  class="v-input__details sy-checkbox-group__messages"
267
190
  >
268
191
  <VMessages
192
+ v-if="hasError || hasWarning || (hasSuccess && props.showSuccessMessages)"
269
193
  ref="messagesRef"
270
- :active="hasError || hasWarning || (hasSuccess && displaySuccesses.length > 0)"
271
- :messages="hasError ? errors : (hasWarning ? warnings : (hasSuccess ? displaySuccesses : []))"
194
+ :active="hasError || hasWarning || (hasSuccess && successes.length > 0)"
195
+ :messages="hasError ? errors : (hasWarning ? warnings : (hasSuccess && props.showSuccessMessages ? successes : []))"
272
196
  />
197
+ <div
198
+ v-if="showHelpTextAsMessage"
199
+ class="help-text-below"
200
+ :class="{ 'text-disabled': props.disabled }"
201
+ >
202
+ {{ props.helpText }}
203
+ </div>
204
+ </div>
205
+ <div
206
+ v-if="showHelpTextBelow"
207
+ class="help-text-below px-1 mt-1"
208
+ :class="{ 'text-disabled': props.disabled }"
209
+ >
210
+ {{ props.helpText }}
273
211
  </div>
274
212
 
275
213
  <span
@@ -293,6 +231,16 @@
293
231
  font-weight: 500;
294
232
  }
295
233
 
234
+ .help-text-below {
235
+ color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
236
+ font-size: var(--v-fontSize-liensEtLibelles);
237
+ line-height: 1.2;
238
+ }
239
+
240
+ .help-text-below.text-disabled {
241
+ color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity));
242
+ }
243
+
296
244
  :deep(.v-messages) {
297
245
  opacity: 1;
298
246
  }