@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
@@ -0,0 +1,717 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import { ref, watch, onMounted } from 'vue'
3
+ import { VBtn, VForm } from 'vuetify/components'
4
+ import { fn } from '@storybook/test'
5
+ import LunarCalendar from '../LunarCalendar.vue'
6
+ import SyForm from '../../Customs/SyForm/SyForm.vue'
7
+ import { getValidationDocumentation } from '@/composables/unifyValidation/documentationValidationProps'
8
+
9
+ const meta = {
10
+ title: 'Composants/Formulaires/LunarCalendar/Validation',
11
+ component: LunarCalendar,
12
+ decorators: [
13
+ () => ({
14
+ template: '<div style="padding: 20px;"><story/></div>',
15
+ }),
16
+ ],
17
+ parameters: {
18
+ layout: 'fullscreen',
19
+ docs: {
20
+ description: {
21
+ component: `Exemples de validation pour le composant LunarCalendar`,
22
+ },
23
+ },
24
+ },
25
+ argTypes: {
26
+ ...getValidationDocumentation('date'),
27
+ modelValue: {
28
+ control: 'text',
29
+ description: 'La valeur du calendrier lunaire au format DD/MM/YYYY',
30
+ },
31
+ label: {
32
+ control: 'text',
33
+ description: 'Libellé du champ',
34
+ },
35
+ },
36
+ args: {
37
+ 'modelValue': '',
38
+ 'label': 'Date de naissance',
39
+ 'required': false,
40
+ 'errorMessages': null,
41
+ 'warningMessages': null,
42
+ 'successMessages': null,
43
+ 'readonly': false,
44
+ 'disabled': false,
45
+ 'customRules': [],
46
+ 'customWarningRules': [],
47
+ 'customSuccessRules': [],
48
+ 'isValidateOnBlur': true,
49
+ 'onUpdate:modelValue': fn(),
50
+ },
51
+ } as Meta<typeof LunarCalendar>
52
+
53
+ export default meta
54
+
55
+ type Story = StoryObj<typeof meta>
56
+
57
+ export const WithError: Story = {
58
+ parameters: {
59
+ a11y: {
60
+ disable: true,
61
+ },
62
+ sourceCode: [
63
+ {
64
+ name: 'Template',
65
+ code: `
66
+ <template>
67
+ <LunarCalendar
68
+ label="Date de naissance"
69
+ v-model="dateValue"
70
+ :min-year="1400"
71
+ :max-year="1500"
72
+ />
73
+ </template>
74
+
75
+ <script setup lang="ts">
76
+ import { ref } from 'vue'
77
+
78
+ const dateValue = ref('16/08/1550')
79
+ </script>
80
+ `,
81
+ },
82
+ ],
83
+ },
84
+ args: {
85
+ modelValue: '16/08/1550',
86
+ minYear: 1400,
87
+ maxYear: 1500,
88
+ },
89
+ render: args => ({
90
+ components: { LunarCalendar },
91
+ setup() {
92
+ const value = ref(args.modelValue)
93
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
94
+ watch(() => args.modelValue, (newValue) => {
95
+ value.value = newValue
96
+ })
97
+ onMounted(() => {
98
+ fieldRef.value?.validateOnSubmit()
99
+ })
100
+ return { args, value, fieldRef }
101
+ },
102
+ template: `
103
+ <div class="pa-4">
104
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" />
105
+ </div>
106
+ `,
107
+ }),
108
+ }
109
+
110
+ export const WithWarning: Story = {
111
+ parameters: {
112
+ a11y: {
113
+ disable: true,
114
+ },
115
+ sourceCode: [
116
+ {
117
+ name: 'Template',
118
+ code: `
119
+ <template>
120
+ <LunarCalendar
121
+ label="Date de naissance"
122
+ v-model="dateValue"
123
+ :custom-warning-rules="customWarningRules"
124
+ />
125
+ </template>
126
+
127
+ <script setup lang="ts">
128
+ import { ref } from 'vue'
129
+
130
+ const dateValue = ref('01/01/1900')
131
+
132
+ const customWarningRules = [
133
+ {
134
+ type: 'custom',
135
+ options: {
136
+ validate: (value: string) => {
137
+ const year = Number(value.split('/')[2])
138
+ return isNaN(year) || year >= 1912
139
+ },
140
+ warningMessage: 'Cette date est antérieure à 1912.',
141
+ },
142
+ },
143
+ ]
144
+ </script>
145
+ `,
146
+ },
147
+ ],
148
+ },
149
+ args: {
150
+ modelValue: '01/01/1900',
151
+ customWarningRules: [
152
+ {
153
+ type: 'custom',
154
+ options: {
155
+ validate: (value: string) => {
156
+ const year = Number(value.split('/')[2])
157
+ return isNaN(year) || year >= 1912
158
+ },
159
+ warningMessage: 'Cette date est antérieure à 1912.',
160
+ },
161
+ },
162
+ ],
163
+ },
164
+ render: args => ({
165
+ components: { LunarCalendar },
166
+ setup() {
167
+ const value = ref(args.modelValue)
168
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
169
+ watch(() => args.modelValue, (newValue) => {
170
+ value.value = newValue
171
+ })
172
+ onMounted(() => {
173
+ fieldRef.value?.validateOnSubmit()
174
+ })
175
+ return { args, value, fieldRef }
176
+ },
177
+ template: `
178
+ <div class="pa-4">
179
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" />
180
+ </div>
181
+ `,
182
+ }),
183
+ }
184
+
185
+ export const WithSuccess: Story = {
186
+ parameters: {
187
+ a11y: {
188
+ disable: true,
189
+ },
190
+ sourceCode: [
191
+ {
192
+ name: 'Template',
193
+ code: `
194
+ <template>
195
+ <LunarCalendar
196
+ label="Date de naissance"
197
+ v-model="dateValue"
198
+ show-success-messages
199
+ :custom-success-rules="customSuccessRules"
200
+ />
201
+ </template>
202
+
203
+ <script setup lang="ts">
204
+ import { ref } from 'vue'
205
+
206
+ const dateValue = ref('15/08/1450')
207
+
208
+ const customSuccessRules = [
209
+ {
210
+ type: 'custom',
211
+ options: {
212
+ validate: (value: string) => /^\\d{2}\\/\\d{2}\\/\\d{4}$/.test(value),
213
+ successMessage: 'Date lunaire valide.',
214
+ },
215
+ },
216
+ ]
217
+ </script>
218
+ `,
219
+ },
220
+ ],
221
+ },
222
+ args: {
223
+ modelValue: '15/08/1450',
224
+ showSuccessMessages: true,
225
+ customSuccessRules: [
226
+ {
227
+ type: 'custom',
228
+ options: {
229
+ validate: (value: string) => /^\d{2}\/\d{2}\/\d{4}$/.test(value),
230
+ successMessage: 'Date lunaire valide.',
231
+ },
232
+ },
233
+ ],
234
+ },
235
+ render: args => ({
236
+ components: { LunarCalendar },
237
+ setup() {
238
+ const value = ref(args.modelValue)
239
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
240
+ watch(() => args.modelValue, (newValue) => {
241
+ value.value = newValue
242
+ })
243
+ onMounted(() => {
244
+ fieldRef.value?.validateOnSubmit()
245
+ })
246
+ return { args, value, fieldRef }
247
+ },
248
+ template: `
249
+ <div class="pa-4">
250
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" show-success-messages />
251
+ </div>
252
+ `,
253
+ }),
254
+ }
255
+
256
+ export const ExternalMessages: Story = {
257
+ parameters: {
258
+ sourceCode: [
259
+ {
260
+ name: 'Template',
261
+ code: `
262
+ <template>
263
+ <LunarCalendar
264
+ label="Date de naissance"
265
+ v-model="dateValue"
266
+ show-success-messages
267
+ :error-messages="errorMessages"
268
+ :warning-messages="warningMessages"
269
+ :success-messages="successMessages"
270
+ />
271
+ <div class="mt-4 d-flex flex-wrap ga-2">
272
+ <VBtn color="error" @click="setError">Simuler une erreur</VBtn>
273
+ <VBtn color="warning" @click="setWarning">Simuler un avertissement</VBtn>
274
+ <VBtn color="success" @click="setSuccess">Simuler un succès</VBtn>
275
+ <VBtn color="black" @click="reset">Réinitialiser</VBtn>
276
+ </div>
277
+ </template>
278
+
279
+ <script setup lang="ts">
280
+ import { ref } from 'vue'
281
+
282
+ const dateValue = ref('15/08/1450')
283
+ const errorMessages = ref<string[] | null>(null)
284
+ const warningMessages = ref<string[] | null>(null)
285
+ const successMessages = ref<string[] | null>(null)
286
+
287
+ function setError() {
288
+ errorMessages.value = ['Date non reconnue dans le calendrier lunaire.']
289
+ warningMessages.value = null
290
+ successMessages.value = null
291
+ }
292
+ function setWarning() {
293
+ errorMessages.value = null
294
+ warningMessages.value = ['Cette date correspond à une période incertaine.']
295
+ successMessages.value = null
296
+ }
297
+ function setSuccess() {
298
+ errorMessages.value = null
299
+ warningMessages.value = null
300
+ successMessages.value = ['Date lunaire validée par le serveur.']
301
+ }
302
+ function reset() {
303
+ errorMessages.value = null
304
+ warningMessages.value = null
305
+ successMessages.value = null
306
+ }
307
+ </script>
308
+ `,
309
+ },
310
+ ],
311
+ },
312
+ args: {
313
+ modelValue: '15/08/1450',
314
+ showSuccessMessages: true,
315
+ },
316
+ render: args => ({
317
+ components: { LunarCalendar, VBtn },
318
+ setup() {
319
+ const value = ref(args.modelValue)
320
+ watch(() => args.modelValue, (newValue) => {
321
+ value.value = newValue
322
+ })
323
+ const errorMessages = ref<string[] | null>(null)
324
+ const warningMessages = ref<string[] | null>(null)
325
+ const successMessages = ref<string[] | null>(null)
326
+
327
+ function setError() {
328
+ errorMessages.value = ['Date non reconnue dans le calendrier lunaire.']
329
+ warningMessages.value = null
330
+ successMessages.value = null
331
+ }
332
+ function setWarning() {
333
+ errorMessages.value = null
334
+ warningMessages.value = ['Cette date correspond à une période incertaine.']
335
+ successMessages.value = null
336
+ }
337
+ function setSuccess() {
338
+ errorMessages.value = null
339
+ warningMessages.value = null
340
+ successMessages.value = ['Date lunaire validée par le serveur.']
341
+ }
342
+ function reset() {
343
+ errorMessages.value = null
344
+ warningMessages.value = null
345
+ successMessages.value = null
346
+ }
347
+
348
+ return { args, value, errorMessages, warningMessages, successMessages, setError, setWarning, setSuccess, reset }
349
+ },
350
+ template: `
351
+ <div class="pa-4">
352
+ <LunarCalendar
353
+ v-bind="args"
354
+ v-model="value"
355
+ show-success-messages
356
+ :error-messages="errorMessages"
357
+ :warning-messages="warningMessages"
358
+ :success-messages="successMessages"
359
+ />
360
+ <div class="mt-4 d-flex flex-wrap ga-2">
361
+ <VBtn color="error" @click="setError">Simuler une erreur</VBtn>
362
+ <VBtn color="warning" @click="setWarning">Simuler un avertissement</VBtn>
363
+ <VBtn color="success" @click="setSuccess">Simuler un succès</VBtn>
364
+ <VBtn color="black" @click="reset">Réinitialiser</VBtn>
365
+ </div>
366
+ </div>
367
+ `,
368
+ }),
369
+ }
370
+
371
+ export const WithYearConstraints: Story = {
372
+ parameters: {
373
+ sourceCode: [
374
+ {
375
+ name: 'Template',
376
+ code: `
377
+ <template>
378
+ <LunarCalendar
379
+ label="Date de naissance"
380
+ v-model="dateValue"
381
+ :min-year="1400"
382
+ :max-year="1500"
383
+ />
384
+ </template>
385
+
386
+ <script setup lang="ts">
387
+ import { ref } from 'vue'
388
+
389
+ const dateValue = ref('16/08/1550')
390
+ </script>
391
+ `,
392
+ },
393
+ ],
394
+ },
395
+ args: {
396
+ modelValue: '16/08/1550',
397
+ minYear: 1400,
398
+ maxYear: 1500,
399
+ },
400
+ render: args => ({
401
+ components: { LunarCalendar },
402
+ setup() {
403
+ const value = ref(args.modelValue)
404
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
405
+ watch(() => args.modelValue, (newValue) => {
406
+ value.value = newValue
407
+ })
408
+ onMounted(() => {
409
+ fieldRef.value?.validateOnSubmit()
410
+ })
411
+ return { args, value, fieldRef }
412
+ },
413
+ template: `
414
+ <div class="pa-4">
415
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" />
416
+ </div>
417
+ `,
418
+ }),
419
+ }
420
+
421
+ export const WithMinYearOnly: Story = {
422
+ parameters: {
423
+ sourceCode: [
424
+ {
425
+ name: 'Template',
426
+ code: `
427
+ <template>
428
+ <LunarCalendar
429
+ label="Date de naissance"
430
+ v-model="dateValue"
431
+ :min-year="1420"
432
+ />
433
+ </template>
434
+
435
+ <script setup lang="ts">
436
+ import { ref } from 'vue'
437
+
438
+ const dateValue = ref('12/12/1445')
439
+ </script>
440
+ `,
441
+ },
442
+ ],
443
+ },
444
+ args: {
445
+ modelValue: '12/12/1445',
446
+ minYear: 1420,
447
+ },
448
+ render: args => ({
449
+ components: { LunarCalendar },
450
+ setup() {
451
+ const value = ref(args.modelValue)
452
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
453
+ watch(() => args.modelValue, (newValue) => {
454
+ value.value = newValue
455
+ })
456
+ onMounted(() => {
457
+ fieldRef.value?.validateOnSubmit()
458
+ })
459
+ return { args, value, fieldRef }
460
+ },
461
+ template: `
462
+ <div class="pa-4">
463
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" />
464
+ </div>
465
+ `,
466
+ }),
467
+ }
468
+
469
+ export const WithMaxYearOnly: Story = {
470
+ parameters: {
471
+ sourceCode: [
472
+ {
473
+ name: 'Template',
474
+ code: `
475
+ <template>
476
+ <LunarCalendar
477
+ label="Date de naissance"
478
+ v-model="dateValue"
479
+ :max-year="1450"
480
+ />
481
+ </template>
482
+
483
+ <script setup lang="ts">
484
+ import { ref } from 'vue'
485
+
486
+ const dateValue = ref('12/12/1445')
487
+ </script>
488
+ `,
489
+ },
490
+ ],
491
+ },
492
+ args: {
493
+ modelValue: '12/12/1445',
494
+ maxYear: 1450,
495
+ },
496
+ render: args => ({
497
+ components: { LunarCalendar },
498
+ setup() {
499
+ const value = ref(args.modelValue)
500
+ const fieldRef = ref<{ validateOnSubmit: () => Promise<boolean> } | null>(null)
501
+ watch(() => args.modelValue, (newValue) => {
502
+ value.value = newValue
503
+ })
504
+ onMounted(() => {
505
+ fieldRef.value?.validateOnSubmit()
506
+ })
507
+ return { args, value, fieldRef }
508
+ },
509
+ template: `
510
+ <div class="pa-4">
511
+ <LunarCalendar ref="fieldRef" v-bind="args" v-model="value" />
512
+ </div>
513
+ `,
514
+ }),
515
+ }
516
+
517
+ export const SyFormValidation: Story = {
518
+ parameters: {
519
+ sourceCode: [
520
+ {
521
+ name: 'Template',
522
+ code: `<template>
523
+ <SyForm @submit="handleSubmit">
524
+ <LunarCalendar
525
+ v-model="value"
526
+ label="Date de naissance"
527
+ :custom-rules="customRules"
528
+ required
529
+ />
530
+ <div class="mt-4">
531
+ <VBtn type="submit" color="primary">Valider</VBtn>
532
+ </div>
533
+ </SyForm>
534
+ </template>`,
535
+ },
536
+ {
537
+ name: 'Script',
538
+ code: `<script setup lang="ts">
539
+ import { ref } from 'vue'
540
+ import { LunarCalendar, SyForm } from '@cnamts/synapse'
541
+
542
+ const value = ref('')
543
+
544
+ const customRules = [
545
+ {
546
+ type: 'custom',
547
+ options: {
548
+ validate: (value: string) => {
549
+ if (!value || !/^\\d{2}\\/\\d{2}\\/\\d{4}$/.test(value)) {
550
+ return false
551
+ }
552
+ return true
553
+ },
554
+ message: 'La date doit être au format JJ/MM/AAAA.',
555
+ fieldIdentifier: 'date',
556
+ },
557
+ },
558
+ ]
559
+
560
+ function handleSubmit(e) {
561
+ const isValid = e.isValid
562
+ alert(isValid ? 'Date valide !' : 'Veuillez corriger les erreurs.')
563
+ }
564
+ </script>`,
565
+ },
566
+ ],
567
+ },
568
+ args: {
569
+ modelValue: '',
570
+ required: true,
571
+ },
572
+ render: args => ({
573
+ components: { LunarCalendar, VBtn, SyForm },
574
+ setup() {
575
+ const value = ref(args.modelValue)
576
+ watch(() => args.modelValue, (newValue) => {
577
+ value.value = newValue
578
+ })
579
+
580
+ const customRules = [
581
+ {
582
+ type: 'custom',
583
+ options: {
584
+ validate: (value: string) => {
585
+ if (!value || !/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
586
+ return false
587
+ }
588
+ return true
589
+ },
590
+ message: 'La date doit être au format JJ/MM/AAAA.',
591
+ fieldIdentifier: 'date',
592
+ },
593
+ },
594
+ ]
595
+
596
+ function handleSubmit(e: { isValid: boolean }) {
597
+ const isValid = e.isValid
598
+ alert(isValid ? 'Date valide !' : 'Veuillez corriger les erreurs.')
599
+ }
600
+
601
+ return { args, value, customRules, handleSubmit }
602
+ },
603
+ template: `
604
+ <div>
605
+ <SyForm @submit="handleSubmit">
606
+ <LunarCalendar
607
+ v-bind="args"
608
+ v-model="value"
609
+ label="Date de naissance"
610
+ :custom-rules="customRules"
611
+ required
612
+ />
613
+ <div class="mt-4">
614
+ <VBtn type="submit" color="primary">Valider</VBtn>
615
+ </div>
616
+ </SyForm>
617
+ </div>
618
+ `,
619
+ }),
620
+ }
621
+
622
+ export const VFormValidation: Story = {
623
+ parameters: {
624
+ sourceCode: [
625
+ {
626
+ name: 'Template',
627
+ code: `<template>
628
+ <VForm @submit.prevent="handleSubmit">
629
+ <LunarCalendar
630
+ ref="lunarRef"
631
+ v-model="value"
632
+ label="Date de naissance"
633
+ :custom-rules="[
634
+ {
635
+ type: 'custom',
636
+ options: {
637
+ validate: (value) => !!value && /^\\d{2}\\/\\d{2}\\/\\d{4}$/.test(value),
638
+ message: 'La date doit être au format JJ/MM/AAAA.',
639
+ fieldIdentifier: 'date',
640
+ },
641
+ },
642
+ ]"
643
+ required
644
+ />
645
+ <VBtn type="submit" color="primary" class="mt-4">Valider</VBtn>
646
+ </VForm>
647
+ </template>`,
648
+ },
649
+ {
650
+ name: 'Script',
651
+ code: `<script setup lang="ts">
652
+ import { ref } from 'vue'
653
+ import { LunarCalendar } from '@cnamts/synapse'
654
+ import { VBtn, VForm } from 'vuetify/components'
655
+
656
+ const value = ref('')
657
+ const lunarRef = ref()
658
+
659
+ async function handleSubmit() {
660
+ if (lunarRef.value) {
661
+ const result = await lunarRef.value.validateOnSubmit()
662
+ alert(result ? 'Date valide !' : 'Veuillez corriger les erreurs.')
663
+ }
664
+ }
665
+ </script>`,
666
+ },
667
+ ],
668
+ },
669
+ args: {
670
+ modelValue: '',
671
+ required: true,
672
+ },
673
+ render: args => ({
674
+ components: { LunarCalendar, VBtn, VForm },
675
+ setup() {
676
+ const value = ref(args.modelValue)
677
+ watch(() => args.modelValue, (newValue) => {
678
+ value.value = newValue
679
+ })
680
+ const lunarRef = ref()
681
+
682
+ async function handleSubmit() {
683
+ if (lunarRef.value) {
684
+ const result = await lunarRef.value.validateOnSubmit()
685
+ alert(result ? 'Date valide !' : 'Veuillez corriger les erreurs.')
686
+ }
687
+ }
688
+
689
+ return { args, value, lunarRef, handleSubmit }
690
+ },
691
+ template: `
692
+ <div>
693
+ <p>Il faut privilégier l'utilisation de <code>SyForm</code> pour bénéficier de l'intégration native.</p>
694
+ <VForm @submit.prevent="handleSubmit">
695
+ <LunarCalendar
696
+ v-bind="args"
697
+ ref="lunarRef"
698
+ v-model="value"
699
+ label="Date de naissance"
700
+ :custom-rules="[
701
+ {
702
+ type: 'custom',
703
+ options: {
704
+ validate: (value) => !!value && /^\\d{2}\\/\\d{2}\\/\\d{4}$/.test(value),
705
+ message: 'La date doit être au format JJ/MM/AAAA.',
706
+ fieldIdentifier: 'date',
707
+ },
708
+ },
709
+ ]"
710
+ required
711
+ />
712
+ <VBtn type="submit" color="primary" class="mt-4">Valider</VBtn>
713
+ </VForm>
714
+ </div>
715
+ `,
716
+ }),
717
+ }
@@ -72,7 +72,7 @@ describe('LunarCalendar – accessibility (axe)', () => {
72
72
  const wrapper = mount(LunarCalendar, {
73
73
  props: {
74
74
  label: 'Date de naissance lunaire',
75
- successMessages: 'Date valide',
75
+ successMessages: ['Date valide'],
76
76
  },
77
77
  modelValue: '15/08/2023',
78
78
  })