@cnamts/synapse 0.0.5-alpha → 0.0.6-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 (222) hide show
  1. package/dist/design-system-v3.d.ts +481 -411
  2. package/dist/design-system-v3.js +2950 -2202
  3. package/dist/design-system-v3.umd.cjs +6 -6
  4. package/dist/style.css +1 -1
  5. package/package.json +17 -17
  6. package/src/assets/settings.scss +3 -0
  7. package/src/assets/tokens.scss +16 -16
  8. package/src/components/BackBtn/AccessibiliteItems.ts +0 -30
  9. package/src/components/BackBtn/BackBtn.mdx +1 -1
  10. package/src/components/BackBtn/BackBtn.stories.ts +8 -8
  11. package/src/components/BackBtn/BackBtn.vue +0 -1
  12. package/src/components/BackToTopBtn/AccessibiliteItems.ts +0 -30
  13. package/src/components/BackToTopBtn/BackToTopBtn.mdx +1 -1
  14. package/src/components/CollapsibleList/Accessibilite.stories.ts +4 -0
  15. package/src/components/CollapsibleList/AccessibiliteItems.ts +55 -62
  16. package/src/components/CollapsibleList/CollapsibleList.stories.ts +1 -1
  17. package/src/components/CookieBanner/Accessibilite.stories.ts +219 -0
  18. package/src/components/CookieBanner/AccessibiliteItems.ts +356 -0
  19. package/src/components/CookieBanner/CookieBanner.mdx +219 -0
  20. package/src/components/CookieBanner/CookieBanner.stories.ts +678 -0
  21. package/src/components/CookieBanner/CookieBanner.vue +225 -0
  22. package/src/components/CookieBanner/config.ts +38 -0
  23. package/src/components/CookieBanner/locales.ts +12 -0
  24. package/src/components/CookieBanner/tests/CookieBanner.spec.ts +129 -0
  25. package/src/components/CookieBanner/tests/__snapshots__/CookieBanner.spec.ts.snap +197 -0
  26. package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +123 -0
  27. package/src/components/CookiesSelection/CookiesInformation/locales.ts +21 -0
  28. package/src/components/CookiesSelection/CookiesInformation/tests/CookiesInformation.spec.ts +121 -0
  29. package/src/components/CookiesSelection/CookiesSelection.vue +127 -0
  30. package/src/components/CookiesSelection/CookiesTable/CookiesTable.vue +47 -0
  31. package/src/components/CookiesSelection/CookiesTable/headers.ts +14 -0
  32. package/src/components/CookiesSelection/CookiesTable/tests/CookiesTable.spec.ts +30 -0
  33. package/src/components/CookiesSelection/CookiesTable/tests/__snapshots__/CookiesTable.spec.ts.snap +3 -0
  34. package/src/components/CookiesSelection/locales.ts +10 -0
  35. package/src/components/CookiesSelection/tests/CookiesSelection.spec.ts +184 -0
  36. package/src/components/CookiesSelection/tests/__snapshots__/CookiesSelection.spec.ts.snap +192 -0
  37. package/src/components/CookiesSelection/types.ts +15 -0
  38. package/src/components/CopyBtn/AccessibiliteItems.ts +0 -30
  39. package/src/components/CopyBtn/CopyBtn.mdx +1 -1
  40. package/src/components/CopyBtn/CopyBtn.stories.ts +4 -4
  41. package/src/components/CopyBtn/CopyBtn.vue +0 -1
  42. package/src/components/Customs/SyBtnSelect/Accessibilite.mdx +14 -0
  43. package/src/components/Customs/SyBtnSelect/Accessibilite.stories.ts +193 -0
  44. package/src/components/Customs/SyBtnSelect/AccessibiliteItems.ts +139 -0
  45. package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +3 -2
  46. package/src/components/Customs/SyBtnSelect/SyBtnSelect.stories.ts +63 -7
  47. package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +21 -13
  48. package/src/components/Customs/SyBtnSelect/constants/ExpertiseLevelEnum.ts +4 -0
  49. package/src/components/Customs/SyInputSelect/Accessibilite.mdx +14 -0
  50. package/src/components/Customs/SyInputSelect/Accessibilite.stories.ts +166 -0
  51. package/src/components/Customs/SyInputSelect/AccessibiliteItems.ts +96 -0
  52. package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +3 -2
  53. package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +5 -58
  54. package/src/components/Customs/SyInputSelect/SyInputSelect.vue +36 -4
  55. package/src/components/Customs/SyInputSelect/constants/ExpertiseLevelEnum.ts +4 -0
  56. package/src/components/Customs/SySelect/Accessibilite.mdx +14 -0
  57. package/src/components/Customs/SySelect/Accessibilite.stories.ts +217 -0
  58. package/src/components/Customs/SySelect/AccessibiliteItems.ts +173 -0
  59. package/src/components/Customs/SySelect/SySelect.mdx +3 -2
  60. package/src/components/Customs/SySelect/SySelect.stories.ts +4 -58
  61. package/src/components/Customs/SySelect/SySelect.vue +35 -8
  62. package/src/components/Customs/SySelect/constants/ExpertiseLevelEnum.ts +4 -0
  63. package/src/components/Customs/SyTextField/Accessibilite.mdx +14 -0
  64. package/src/components/Customs/SyTextField/Accessibilite.stories.ts +224 -0
  65. package/src/components/Customs/SyTextField/AccessibiliteItems.ts +198 -0
  66. package/src/components/Customs/SyTextField/SyTextField.mdx +1 -1
  67. package/src/components/Customs/SyTextField/SyTextField.stories.ts +118 -7
  68. package/src/components/Customs/SyTextField/SyTextField.vue +27 -7
  69. package/src/components/Customs/SyTextField/constants/ExpertiseLevelEnum.ts +4 -0
  70. package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +2 -1
  71. package/src/components/DataList/Accessibilite.mdx +14 -0
  72. package/src/components/DataList/Accessibilite.stories.ts +166 -0
  73. package/src/components/DataList/AccessibiliteItems.ts +47 -0
  74. package/src/components/DataList/DataList.mdx +1 -1
  75. package/src/components/DataList/DataList.stories.ts +10 -10
  76. package/src/components/DataList/constants/ExpertiseLevelEnum.ts +4 -0
  77. package/src/components/DataListGroup/Accessibilite.mdx +14 -0
  78. package/src/components/DataListGroup/Accessibilite.stories.ts +225 -0
  79. package/src/components/DataListGroup/AccessibiliteItems.ts +79 -0
  80. package/src/components/DataListGroup/DataListGroup.mdx +1 -1
  81. package/src/components/DataListGroup/DataListGroup.stories.ts +7 -7
  82. package/src/components/DataListGroup/constants/ExpertiseLevelEnum.ts +4 -0
  83. package/src/components/DialogBox/Accessibilite.mdx +14 -0
  84. package/src/components/DialogBox/Accessibilite.stories.ts +189 -0
  85. package/src/components/DialogBox/AccessibiliteItems.ts +167 -0
  86. package/src/components/DialogBox/constants/ExpertiseLevelEnum.ts +4 -0
  87. package/src/components/DownloadBtn/AccessibiliteItems.ts +1 -31
  88. package/src/components/DownloadBtn/DownloadBtn.mdx +3 -3
  89. package/src/components/DownloadBtn/DownloadBtn.stories.ts +6 -6
  90. package/src/components/ErrorPage/Accessibilite.mdx +14 -0
  91. package/src/components/ErrorPage/Accessibilite.stories.ts +189 -0
  92. package/src/components/ErrorPage/AccessibiliteItems.ts +205 -0
  93. package/src/components/ErrorPage/constants/ExpertiseLevelEnum.ts +4 -0
  94. package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +4 -4
  95. package/src/components/FooterBar/Accessibilite.mdx +14 -0
  96. package/src/components/FooterBar/Accessibilite.stories.ts +223 -0
  97. package/src/components/FooterBar/AccessibiliteItems.ts +257 -0
  98. package/src/components/FooterBar/FooterBar.mdx +2 -2
  99. package/src/components/FooterBar/FooterBar.stories.ts +14 -14
  100. package/src/components/FooterBar/FooterBar.vue +80 -73
  101. package/src/components/FooterBar/constants/ExpertiseLevelEnum.ts +4 -0
  102. package/src/components/FooterBar/tests/__snapshots__/FooterBar.spec.ts.snap +22 -20
  103. package/src/components/FranceConnectBtn/AccessibiliteItems.ts +0 -30
  104. package/src/components/FranceConnectBtn/FranceConnectBtn.mdx +1 -1
  105. package/src/components/FranceConnectBtn/FranceConnectBtn.stories.ts +3 -3
  106. package/src/components/HeaderBar/Accessibilite.mdx +14 -0
  107. package/src/components/HeaderBar/Accessibilite.stories.ts +223 -0
  108. package/src/components/HeaderBar/AccessibiliteItems.ts +194 -0
  109. package/src/components/HeaderBar/HeaderBar.vue +1 -9
  110. package/src/components/HeaderBar/HeaderBurgerMenu/Accessibilite.mdx +14 -0
  111. package/src/components/HeaderBar/HeaderBurgerMenu/Accessibilite.stories.ts +223 -0
  112. package/src/components/HeaderBar/HeaderBurgerMenu/AccessibiliteItems.ts +174 -0
  113. package/src/components/HeaderBar/HeaderBurgerMenu/constants/ExpertiseLevelEnum.ts +4 -0
  114. package/src/components/HeaderBar/constants/ExpertiseLevelEnum.ts +4 -0
  115. package/src/components/HeaderBar/tests/__snapshots__/HeaderBar.spec.ts.snap +1 -1
  116. package/src/components/HeaderLoading/Accessibilite.mdx +14 -0
  117. package/src/components/HeaderLoading/Accessibilite.stories.ts +167 -0
  118. package/src/components/HeaderLoading/AccessibiliteItems.ts +29 -0
  119. package/src/components/HeaderLoading/HeaderLoading.mdx +1 -1
  120. package/src/components/HeaderLoading/HeaderLoading.stories.ts +1 -1
  121. package/src/components/HeaderLoading/constants/ExpertiseLevelEnum.ts +4 -0
  122. package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +35 -33
  123. package/src/components/HeaderToolbar/Accessibilite.mdx +14 -0
  124. package/src/components/HeaderToolbar/Accessibilite.stories.ts +203 -0
  125. package/src/components/HeaderToolbar/AccessibiliteItems.ts +200 -0
  126. package/src/components/HeaderToolbar/HeaderToolbar.mdx +1 -1
  127. package/src/components/HeaderToolbar/HeaderToolbar.stories.ts +2 -2
  128. package/src/components/HeaderToolbar/HeaderToolbar.vue +1 -0
  129. package/src/components/HeaderToolbar/constants/ExpertiseLevelEnum.ts +4 -0
  130. package/src/components/LangBtn/Accessibilite.stories.ts +3 -1
  131. package/src/components/LangBtn/AccessibiliteItems.ts +0 -31
  132. package/src/components/LangBtn/LangBtn.mdx +1 -1
  133. package/src/components/LangBtn/LangBtn.stories.ts +4 -4
  134. package/src/components/LangBtn/LangBtn.vue +3 -2
  135. package/src/components/Logo/Accessibilite.mdx +14 -0
  136. package/src/components/Logo/Accessibilite.stories.ts +223 -0
  137. package/src/components/Logo/AccessibiliteItems.ts +155 -0
  138. package/src/components/Logo/Logo.mdx +1 -1
  139. package/src/components/Logo/Logo.stories.ts +8 -8
  140. package/src/components/Logo/constants/ExpertiseLevelEnum.ts +4 -0
  141. package/src/components/LogoBrandSection/Accessibilite.mdx +14 -0
  142. package/src/components/LogoBrandSection/Accessibilite.stories.ts +223 -0
  143. package/src/components/LogoBrandSection/AccessibiliteItems.ts +194 -0
  144. package/src/components/LogoBrandSection/constants/ExpertiseLevelEnum.ts +4 -0
  145. package/src/components/MaintenancePage/Accessibilite.mdx +14 -0
  146. package/src/components/MaintenancePage/Accessibilite.stories.ts +189 -0
  147. package/src/components/MaintenancePage/AccessibiliteItems.ts +173 -0
  148. package/src/components/MaintenancePage/constants/ExpertiseLevelEnum.ts +4 -0
  149. package/src/components/NirField/Accessibilite.mdx +14 -0
  150. package/src/components/NirField/Accessibilite.stories.ts +214 -0
  151. package/src/components/NirField/AccessibiliteItems.ts +243 -0
  152. package/src/components/NirField/NirField.mdx +216 -0
  153. package/src/components/NirField/NirField.stories.ts +359 -0
  154. package/src/components/NirField/NirField.vue +450 -0
  155. package/src/components/NirField/config.ts +16 -0
  156. package/src/components/NirField/constants/ExpertiseLevelEnum.ts +4 -0
  157. package/src/components/NirField/locales.ts +12 -0
  158. package/src/components/NirField/nirValidation.ts +42 -0
  159. package/src/components/NirField/tests/NirField.spec.ts +119 -0
  160. package/src/components/NotFoundPage/Accessibilite.mdx +14 -0
  161. package/src/components/NotFoundPage/Accessibilite.stories.ts +190 -0
  162. package/src/components/NotFoundPage/AccessibiliteItems.ts +205 -0
  163. package/src/components/NotFoundPage/constants/ExpertiseLevelEnum.ts +4 -0
  164. package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +4 -4
  165. package/src/components/NotificationBar/AccessibiliteItems.ts +0 -30
  166. package/src/components/NotificationBar/NotificationBar.mdx +1 -1
  167. package/src/components/PageContainer/PageContainer.mdx +1 -1
  168. package/src/components/PageContainer/PageContainer.stories.ts +4 -4
  169. package/src/components/PageContainer/PageContainer.vue +16 -15
  170. package/src/components/PageContainer/tests/PageContainer.spec.ts +1 -1
  171. package/src/components/PageContainer/tests/__snapshots__/PageContainer.spec.ts.snap +2 -2
  172. package/src/components/PhoneField/Accessibilite.mdx +14 -0
  173. package/src/components/PhoneField/Accessibilite.stories.ts +216 -0
  174. package/src/components/PhoneField/AccessibiliteItems.ts +238 -0
  175. package/src/components/PhoneField/PhoneField.mdx +1 -1
  176. package/src/components/PhoneField/PhoneField.stories.ts +2 -2
  177. package/src/components/PhoneField/PhoneField.vue +0 -1
  178. package/src/components/PhoneField/constants/ExpertiseLevelEnum.ts +4 -0
  179. package/src/components/SkipLink/Accessibilite.stories.ts +1 -1
  180. package/src/components/SkipLink/SkipLink.stories.ts +2 -2
  181. package/src/components/SocialMediaLinks/Accessibilite.mdx +14 -0
  182. package/src/components/SocialMediaLinks/Accessibilite.stories.ts +170 -0
  183. package/src/components/SocialMediaLinks/AccessibiliteItems.ts +160 -0
  184. package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +1 -1
  185. package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +1 -1
  186. package/src/components/SocialMediaLinks/constants/ExpertiseLevelEnum.ts +4 -0
  187. package/src/components/SubHeader/Accessibilite.mdx +14 -0
  188. package/src/components/SubHeader/Accessibilite.stories.ts +166 -0
  189. package/src/components/SubHeader/AccessibiliteItems.ts +146 -0
  190. package/src/components/SubHeader/SubHeader.mdx +1 -1
  191. package/src/components/SubHeader/SubHeader.stories.ts +11 -11
  192. package/src/components/SubHeader/constants/ExpertiseLevelEnum.ts +4 -0
  193. package/src/components/SyAlert/Accessibilite.mdx +14 -0
  194. package/src/components/{Alert → SyAlert}/Accessibilite.stories.ts +1 -1
  195. package/src/components/{Alert → SyAlert}/AccessibiliteItems.ts +2 -32
  196. package/src/components/{Alert/Alert.mdx → SyAlert/SyAlert.mdx} +9 -9
  197. package/src/components/{Alert/Alert.stories.ts → SyAlert/SyAlert.stories.ts} +22 -22
  198. package/src/components/SyAlert/constants/ExpertiseLevelEnum.ts +4 -0
  199. package/src/components/{Alert/tests/Alert.spec.ts → SyAlert/tests/SyAlert.spec.ts} +5 -5
  200. package/src/components/{Alert/tests/__snapshots__/Alert.spec.ts.snap → SyAlert/tests/__snapshots__/SyAlert.spec.ts.snap} +2 -2
  201. package/src/components/UserMenuBtn/Accessibilite.mdx +14 -0
  202. package/src/components/UserMenuBtn/Accessibilite.stories.ts +189 -0
  203. package/src/components/UserMenuBtn/AccessibiliteItems.ts +155 -0
  204. package/src/components/UserMenuBtn/UserMenuBtn.mdx +17 -17
  205. package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +121 -19
  206. package/src/components/UserMenuBtn/UserMenuBtn.vue +25 -29
  207. package/src/components/UserMenuBtn/config.ts +1 -1
  208. package/src/components/UserMenuBtn/constants/ExpertiseLevelEnum.ts +4 -0
  209. package/src/components/index.ts +10 -4
  210. package/src/composables/rules/tests/useFieldValidation.spec.ts +60 -58
  211. package/src/composables/rules/useFieldValidation.ts +65 -28
  212. package/src/main.ts +1 -0
  213. package/src/stories/GuideDuDev/CommentUtiliserLesRules.mdx +67 -79
  214. package/src/stories/GuideDuDev/components.stories.ts +5 -5
  215. package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
  216. package/src/stories/Guidelines/Vuetify/Vuetify.mdx +11 -0
  217. package/src/stories/Guidelines/Vuetify/Vuetify.stories.ts +138 -0
  218. package/src/stories/Guidelines/Vuetify/VuetifyItems.ts +350 -0
  219. /package/src/components/{Alert → CookieBanner}/Accessibilite.mdx +0 -0
  220. /package/src/components/{Alert → CookieBanner}/constants/ExpertiseLevelEnum.ts +0 -0
  221. /package/src/components/{Alert/Alert.vue → SyAlert/SyAlert.vue} +0 -0
  222. /package/src/components/{Alert → SyAlert}/locales.ts +0 -0
@@ -1,60 +1,55 @@
1
1
  <script lang="ts" setup>
2
- import { defineProps, defineEmits, withDefaults, computed } from 'vue'
2
+ import { computed } from 'vue'
3
3
  import SyBtnSelect from '../Customs/SyBtnSelect/SyBtnSelect.vue'
4
4
  import { useDisplay } from 'vuetify'
5
5
  import { mdiAccount, mdiLoginVariant } from '@mdi/js'
6
6
  import useCustomizableOptions, { type CustomizableOptions } from '@/composables/useCustomizableOptions'
7
7
  import { defaultOptions } from './config'
8
8
 
9
+ type MenuItem = { text: string, value: string, link?: string }
10
+
9
11
  const props = withDefaults(defineProps<CustomizableOptions & {
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
11
- modelValue: string | Record<string, any> | null | undefined
12
- menuItems?: { text: string, value: string }[]
12
+ menuItems?: MenuItem[]
13
13
  additionalInformation?: string
14
14
  fullName?: string
15
15
  hideLogoutBtn?: boolean
16
- logoutIcon?: string
17
16
  isMobileView?: boolean
18
17
  hideUserIcon?: boolean
19
18
  }>(), {
20
- modelValue: null,
21
19
  menuItems: () => [],
22
20
  additionalInformation: 'Information supplémentaire',
23
21
  fullName: 'Prénom Nom',
24
22
  hideLogoutBtn: false,
25
- logoutIcon: 'mdiLoginVariant',
26
23
  isMobileView: false,
27
24
  hideUserIcon: false,
28
25
  })
29
26
 
30
- const emit = defineEmits(['update:modelValue', 'logout'])
27
+ const modelValue = defineModel<MenuItem | null>({
28
+ default: null,
29
+ })
30
+
31
+ defineEmits(['logout'])
32
+
31
33
  const { smAndDown } = useDisplay()
32
34
 
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
34
- const options = useCustomizableOptions(defaultOptions, props) as any
35
+ const options = useCustomizableOptions(defaultOptions, props)
35
36
 
36
37
  const isMobileView = computed(() => {
37
38
  return props.isMobileView || smAndDown.value
38
39
  })
39
-
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
41
- function updateModelValue(value: any) {
42
- emit('update:modelValue', value)
43
- }
44
40
  </script>
45
41
 
46
42
  <template>
47
43
  <SyBtnSelect
48
- :is-mobile-view="isMobileView"
44
+ v-model="modelValue"
45
+ :hide-icon="hideUserIcon"
49
46
  :icon-only="isMobileView"
47
+ :is-mobile-view="isMobileView"
50
48
  :menu-items="menuItems"
51
- :model-value="props.modelValue ?? undefined"
52
49
  :options="options"
53
50
  :primary-info="fullName"
54
51
  :secondary-info="additionalInformation"
55
- :hide-icon="hideUserIcon"
56
52
  class="user-menu-btn"
57
- @update:model-value="updateModelValue"
58
53
  >
59
54
  <template #append-icon>
60
55
  <VIcon
@@ -88,18 +83,19 @@
88
83
  </SyBtnSelect>
89
84
  </template>
90
85
 
91
- <style scoped>
86
+ <style scoped lang="scss">
92
87
  @use '@/assets/tokens.scss';
88
+
93
89
  .vd-user-icon {
94
- width: 40px;
95
- height: 40px;
96
- background: tokens.$grey-lighten-90;
97
- border-radius: 50%;
90
+ width: 40px;
91
+ height: 40px;
92
+ background: tokens.$grey-lighten-90;
93
+ border-radius: 50%;
98
94
 
99
- svg,
100
- .v-icon__svg {
101
- width: 24px;
102
- height: 24px;
103
- }
95
+ svg,
96
+ .v-icon__svg {
97
+ width: 24px;
98
+ height: 24px;
99
+ }
104
100
  }
105
101
  </style>
@@ -21,4 +21,4 @@ export const defaultOptions = {
21
21
  color: 'primary',
22
22
  class: 'mr-4',
23
23
  },
24
- }
24
+ } as const
@@ -0,0 +1,4 @@
1
+ export enum ExpertiseLevelEnum {
2
+ DEV = 'dev',
3
+ DESIGN = 'design',
4
+ }
@@ -1,12 +1,12 @@
1
- export { default as Alert } from './Alert/Alert.vue'
1
+ export { default as SyAlert } from './SyAlert/SyAlert.vue'
2
2
  export { default as BackBtn } from './BackBtn/BackBtn.vue'
3
3
  export { default as BackToTopBtn } from './BackToTopBtn/BackToTopBtn.vue'
4
4
  export { default as CollapsibleList } from './CollapsibleList/CollapsibleList.vue'
5
5
  export { default as CopyBtn } from './CopyBtn/CopyBtn.vue'
6
6
  export { default as SyBtnSelect } from './Customs/SyBtnSelect/SyBtnSelect.vue'
7
- export { default as SyInputSelect } from '@/components/Customs/SyInputSelect/SyInputSelect.vue'
8
- export { default as SySelect } from '@/components/Customs/SySelect/SySelect.vue'
9
- export { default as SyTextField } from '@/components/Customs/SyTextField/SyTextField.vue'
7
+ export { default as SyInputSelect } from './Customs/SyInputSelect/SyInputSelect.vue'
8
+ export { default as SySelect } from './Customs/SySelect/SySelect.vue'
9
+ export { default as SyTextField } from './Customs/SyTextField/SyTextField.vue'
10
10
  export { default as DataList } from './DataList/DataList.vue'
11
11
  export { default as DataListGroup } from './DataListGroup/DataListGroup.vue'
12
12
  export { default as DataListItem } from './DataListItem/DataListItem.vue'
@@ -30,6 +30,8 @@ export { default as Logo } from './Logo/Logo.vue'
30
30
  export { default as LogoBrandSection } from './LogoBrandSection/LogoBrandSection.vue'
31
31
  export { default as MaintenancePage } from './MaintenancePage/MaintenancePage.vue'
32
32
  export { default as NotFoundPage } from './NotFoundPage/NotFoundPage.vue'
33
+ export { default as NirField } from './NirField/NirField.vue'
34
+ export * from './NirField/nirValidation'
33
35
  export { default as NotificationBar } from './NotificationBar/NotificationBar.vue'
34
36
  export * from './NotificationBar/types'
35
37
  export { default as PageContainer } from './PageContainer/PageContainer.vue'
@@ -38,3 +40,7 @@ export { default as SkipLink } from './SkipLink/SkipLink.vue'
38
40
  export { default as SocialMediaLinks } from './SocialMediaLinks/SocialMediaLinks.vue'
39
41
  export { default as SubHeader } from './SubHeader/SubHeader.vue'
40
42
  export { default as UserMenuBtn } from './UserMenuBtn/UserMenuBtn.vue'
43
+ export { default as CookieBanner } from './CookieBanner/CookieBanner.vue'
44
+ export { default as CookiesSelection } from './CookiesSelection/CookiesSelection.vue'
45
+ export { default as CookiesInformation } from './CookiesSelection/CookiesInformation/CookiesInformation.vue'
46
+ export { default as CookiesTable } from './CookiesSelection/CookiesTable/CookiesTable.vue'
@@ -1,82 +1,84 @@
1
- import { useFieldValidation } from '../useFieldValidation'
2
1
  import { describe, it, expect } from 'vitest'
2
+ import { useFieldValidation } from '../useFieldValidation'
3
3
 
4
4
  describe('useFieldValidation', () => {
5
5
  const { generateRules } = useFieldValidation()
6
6
 
7
- describe('createRule', () => {
8
- it('should validate required rule', () => {
9
- const rules = generateRules([{ type: 'required', options: { fieldName: 'Nom' } }])
10
- const requiredRule = rules[0]
7
+ it('should validate required rule', () => {
8
+ const rules = generateRules([{ type: 'required', options: { message: 'This field is required.' } }])
9
+ const rule = rules[0]
11
10
 
12
- expect(requiredRule('')).toBe('Vous devez renseigner Nom.')
13
- expect(requiredRule('Test')).toBe(true)
14
- })
11
+ expect(rule('')).toEqual({ error: 'This field is required.' })
12
+ expect(rule('value')).toEqual({ success: 'Le champ est valide.' })
13
+ })
15
14
 
16
- it('should validate min rule', () => {
17
- const rules = generateRules([{ type: 'min', options: { value: 5 } }])
18
- const minRule = rules[0]
15
+ it('should validate min rule', () => {
16
+ const rules = generateRules([{ type: 'min', options: { value: 5, message: 'Value must be at least 5.' } }])
17
+ const rule = rules[0]
19
18
 
20
- expect(minRule(3)).toBe('La valeur doit être supérieure ou égale à 5.')
21
- expect(minRule(5)).toBe(true)
22
- expect(minRule(10)).toBe(true)
23
- })
19
+ expect(rule(3)).toEqual({ error: 'Value must be at least 5.' })
20
+ expect(rule(5)).toEqual({ success: 'Le champ est valide.' })
21
+ })
24
22
 
25
- it('should validate minLength rule', () => {
26
- const rules = generateRules([{ type: 'minLength', options: { length: 3 } }])
27
- const minLengthRule = rules[0]
23
+ it('should validate max rule', () => {
24
+ const rules = generateRules([{ type: 'max', options: { value: 10, message: 'Value must be at most 10.' } }])
25
+ const rule = rules[0]
28
26
 
29
- expect(minLengthRule('ab')).toBe('Ce champ doit avoir au moins 3 caractères.')
30
- expect(minLengthRule('abc')).toBe(true)
31
- })
27
+ expect(rule(15)).toEqual({ error: 'Value must be at most 10.' })
28
+ expect(rule(10)).toEqual({ success: 'Le champ est valide.' })
29
+ })
32
30
 
33
- it('should validate max rule', () => {
34
- const rules = generateRules([{ type: 'max', options: { value: 10 } }])
35
- const maxRule = rules[0]
31
+ it('should validate minLength rule', () => {
32
+ const rules = generateRules([{ type: 'minLength', options: { length: 5, message: 'Minimum length is 5.' } }])
33
+ const rule = rules[0]
36
34
 
37
- expect(maxRule(15)).toBe('La valeur doit être inférieure ou égale à 10.')
38
- expect(maxRule(10)).toBe(true)
39
- expect(maxRule(5)).toBe(true)
40
- })
35
+ expect(rule('1234')).toEqual({ error: 'Minimum length is 5.' })
36
+ expect(rule('12345')).toEqual({ success: 'Le champ est valide.' })
37
+ })
41
38
 
42
- it('should validate maxLength rule', () => {
43
- const rules = generateRules([{ type: 'maxLength', options: { length: 5 } }])
44
- const maxLengthRule = rules[0]
39
+ it('should validate maxLength rule', () => {
40
+ const rules = generateRules([{ type: 'maxLength', options: { length: 5, message: 'Maximum length is 5.' } }])
41
+ const rule = rules[0]
45
42
 
46
- expect(maxLengthRule('abcdef')).toBe('Ce champ ne doit pas dépasser 5 caractères.')
47
- expect(maxLengthRule('abc')).toBe(true)
48
- })
43
+ expect(rule('123456')).toEqual({ error: 'Maximum length is 5.' })
44
+ expect(rule('12345')).toEqual({ success: 'Le champ est valide.' })
45
+ })
49
46
 
50
- it('should validate exactLength rule', () => {
51
- const rules = generateRules([{ type: 'exactLength', options: { length: 4 } }])
52
- const exactLengthRule = rules[0]
47
+ it('should validate exactLength rule', () => {
48
+ const rules = generateRules([{ type: 'exactLength', options: { length: 5, message: 'Length must be exactly 5.' } }])
49
+ const rule = rules[0]
53
50
 
54
- expect(exactLengthRule('abc')).toBe('Ce champ doit avoir exactement 4 caractères.')
55
- expect(exactLengthRule('abcd')).toBe(true)
56
- })
51
+ expect(rule('1234')).toEqual({ error: 'Length must be exactly 5.' })
52
+ expect(rule('12345')).toEqual({ success: 'Le champ est valide.' })
53
+ })
57
54
 
58
- it('should validate email rule', () => {
59
- const rules = generateRules([{ type: 'email' }])
60
- const emailRule = rules[0]
55
+ it('should validate email rule', () => {
56
+ const rules = generateRules([{ type: 'email', options: { message: 'Invalid email address.' } }])
57
+ const rule = rules[0]
61
58
 
62
- expect(emailRule('invalid-email')).toBe('Veuillez entrer un email valide.')
63
- expect(emailRule('test@example.com')).toBe(true)
64
- })
59
+ expect(rule('invalid-email')).toEqual({ error: 'Invalid email address.' })
60
+ expect(rule('test@example.com')).toEqual({ success: 'Le champ est valide.' })
61
+ })
65
62
 
66
- it('should validate matchPattern rule', () => {
67
- const rules = generateRules([{ type: 'matchPattern', options: { pattern: /^[a-z]+$/ } }])
68
- const matchPatternRule = rules[0]
63
+ it('should validate matchPattern rule', () => {
64
+ const rules = generateRules([{
65
+ type: 'matchPattern',
66
+ options: { pattern: /^[a-z]+$/, message: 'Invalid format.' },
67
+ }])
68
+ const rule = rules[0]
69
69
 
70
- expect(matchPatternRule('123')).toBe('Format invalide.')
71
- expect(matchPatternRule('abc')).toBe(true)
72
- })
70
+ expect(rule('123')).toEqual({ error: 'Invalid format.' })
71
+ expect(rule('abc')).toEqual({ success: 'Le champ est valide.' })
72
+ })
73
73
 
74
- it('should handle ignoreSpace option in length rules', () => {
75
- const rules = generateRules([{ type: 'minLength', options: { length: 3, ignoreSpace: true } }])
76
- const minLengthRule = rules[0]
74
+ it('should validate custom rule', () => {
75
+ const rules = generateRules([{
76
+ type: 'custom',
77
+ options: { validate: value => value === 'valid', message: 'Custom validation failed.' },
78
+ }])
79
+ const rule = rules[0]
77
80
 
78
- expect(minLengthRule('a b')).toBe('Ce champ doit avoir au moins 3 caractères.')
79
- expect(minLengthRule('ab c')).toBe(true)
80
- })
81
+ expect(rule('invalid')).toEqual({ error: 'Custom validation failed.' })
82
+ expect(rule('valid')).toEqual({ success: 'Le champ est valide.' })
81
83
  })
82
84
  })
@@ -1,50 +1,87 @@
1
1
  type RuleOptions = {
2
2
  fieldName?: string
3
3
  message?: string
4
+ successMessage?: string
4
5
  length?: number
5
6
  value?: number
6
7
  pattern?: RegExp
7
8
  ignoreSpace?: boolean
9
+ fieldIdentifier?: string
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
11
+ validate?: (value: any) => boolean | string
8
12
  }
9
13
 
14
+ type ValidationResult = {
15
+ success?: string
16
+ error?: string
17
+ }
10
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
11
- type ValidationRule = (value: any) => string | boolean
19
+ type ValidationRule = (value: any) => ValidationResult
12
20
 
13
21
  export function useFieldValidation() {
14
22
  const createRule = (type: string, options: RuleOptions = {}): ValidationRule => {
15
23
  const getValueLength = (value: string) => {
16
24
  return options.ignoreSpace ? value.replace(/\s/g, '').length : value.length
17
25
  }
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
27
+ return (value: any) => {
28
+ if (type !== 'required' && typeof value === 'string' && value.trim() === '') {
29
+ return {}
30
+ }
31
+ switch (type) {
32
+ case 'required':
33
+ return typeof value === 'string' && value.trim()
34
+ ? { success: options.successMessage || 'Le champ est valide.' }
35
+ : { error: options.message || `Vous devez renseigner ${options.fieldName || 'ce champ'}.` }
36
+
37
+ case 'min':
38
+ return typeof value === 'number' && value >= (options.value ?? 0)
39
+ ? { success: options.successMessage || 'Le champ est valide.' }
40
+ : { error: options.message || `La valeur doit être supérieure ou égale à ${options.value}.` }
41
+
42
+ case 'minLength':
43
+ return typeof value === 'string' && getValueLength(value) >= (options.length ?? 0)
44
+ ? { success: options.successMessage || 'Le champ est valide.' }
45
+ : { error: options.message || `Ce champ doit avoir au moins ${options.length} caractères.` }
46
+
47
+ case 'max':
48
+ return typeof value === 'number' && value <= (options.value ?? Infinity)
49
+ ? { success: options.successMessage || 'Le champ est valide.' }
50
+ : { error: options.message || `La valeur doit être inférieure ou égale à ${options.value}.` }
51
+
52
+ case 'maxLength':
53
+ return typeof value === 'string' && getValueLength(value) <= (options.length ?? Infinity)
54
+ ? { success: options.successMessage || 'Le champ est valide.' }
55
+ : { error: options.message || `Ce champ ne doit pas dépasser ${options.length} caractères.` }
18
56
 
19
- switch (type) {
20
- case 'required':
21
- return (value: string) =>
22
- !!value || options.message || `Vous devez renseigner ${options.fieldName || 'ce champ'}.`
23
- case 'min':
24
- return (value: number) =>
25
- value >= (options.value ?? 0) || options.message || `La valeur doit être supérieure ou égale à ${options.value}.`
26
- case 'minLength':
27
- return (value: string) =>
28
- getValueLength(value) >= (options.length ?? 0) || options.message || `Ce champ doit avoir au moins ${options.length} caractères.`
29
- case 'max':
30
- return (value: number) =>
31
- value <= (options.value ?? Infinity) || options.message || `La valeur doit être inférieure ou égale à ${options.value}.`
32
- case 'maxLength':
33
- return (value: string) =>
34
- getValueLength(value) <= (options.length ?? Infinity) || options.message || `Ce champ ne doit pas dépasser ${options.length} caractères.`
35
- case 'exactLength':
36
- return (value: string) =>
37
- getValueLength(value) === (options.length ?? 0) || options.message || `Ce champ doit avoir exactement ${options.length} caractères.`
38
- case 'email':
39
- return (value: string) =>
40
- /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) || options.message || `Veuillez entrer un email valide.`
41
- case 'matchPattern':
42
- return (value: string) =>
43
- options.pattern ? options.pattern.test(value) || options.message || `Format invalide.` : `Format invalide.`
44
- default:
45
- return () => `La règle spécifiée n'existe pas.`
57
+ case 'exactLength':
58
+ return typeof value === 'string' && getValueLength(value) === (options.length ?? 0)
59
+ ? { success: options.successMessage || 'Le champ est valide.' }
60
+ : { error: options.message || `Ce champ doit avoir exactement ${options.length} caractères.` }
61
+
62
+ case 'email':
63
+ return typeof value === 'string' && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
64
+ ? { success: options.successMessage || 'Le champ est valide.' }
65
+ : { error: options.message || `Veuillez entrer un email valide.` }
66
+
67
+ case 'matchPattern':
68
+ return typeof value === 'string' && options.pattern?.test(value)
69
+ ? { success: options.successMessage || 'Le champ est valide.' }
70
+ : { error: options.message || `Format invalide.` }
71
+
72
+ case 'custom': {
73
+ const result = options.validate?.(value)
74
+ return result === true
75
+ ? { success: options.successMessage || 'Le champ est valide.' }
76
+ : { error: typeof result === 'string' ? result : options.message || `Validation échouée.` }
77
+ }
78
+
79
+ default:
80
+ return { error: `La règle spécifiée n'existe pas.` }
81
+ }
46
82
  }
47
83
  }
84
+
48
85
  const generateRules = (fieldRules: Array<{ type: string, options?: RuleOptions }>) => {
49
86
  return fieldRules.map(rule => createRule(rule.type, rule.options))
50
87
  }
package/src/main.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import '../src/assets/tokens.scss'
2
+ import '../src/assets/settings.scss'
2
3
 
3
4
  export * from './components'
4
5
  export * from './services'
@@ -18,16 +18,29 @@ Le composable `useFieldValidation` vous permet de définir des règles de valida
18
18
 
19
19
  ### Type `RuleOptions`
20
20
 
21
- <Source dark code={`
21
+ <Source dark code={`
22
22
  type RuleOptions = {
23
- fieldName?: string; // Nom du champ utilisé dans les messages d'erreur
24
- message?: string; // Message personnalisé pour la règle
25
- length?: number; // Longueur minimale ou maximale
26
- value?: number; // Valeur minimale ou maximale
27
- pattern?: RegExp; // Motif à valider
28
- ignoreSpace?: boolean; // Ignorer les espaces lors de la validation de longueur
23
+ fieldName?: string; // Nom du champ utilisé dans les messages d'erreur
24
+ message?: string; // Message personnalisé pour la règle
25
+ successMessage?: string; // Message personnalisé de validation réussie
26
+ length?: number; // Longueur minimale ou maximale
27
+ value?: number; // Valeur minimale ou maximale
28
+ pattern?: RegExp; // Motif à valider
29
+ ignoreSpace?: boolean; // Ignorer les espaces lors de la validation de longueur
30
+ validate?: (value: any) => boolean | string; // Validation personnalisée
29
31
  };
30
- `} />
32
+ `}
33
+ />
34
+
35
+ ### Type `ValidationResult`
36
+
37
+ <Source dark code={`
38
+ type ValidationResult = {
39
+ success?: string; // Message de validation réussie
40
+ error?: string; // Message d'erreur
41
+ };
42
+ `}
43
+ />
31
44
 
32
45
  ---
33
46
 
@@ -35,98 +48,73 @@ ignoreSpace?: boolean; // Ignorer les espaces lors de la validation de longueur
35
48
 
36
49
  ### Script Vue.js
37
50
 
38
- <Source dark code={`
51
+ <Source dark code={`
39
52
  <script lang="ts" setup>
40
- import {ref} from 'vue';
41
- import {useFieldValidation} from '@cnamts/synapse';
42
-
43
- const {generateRules} = useFieldValidation();
44
-
45
- const firstName = ref('');
46
- const email = ref('');
47
- const age = ref('');
48
-
49
- const rules = {
50
- firstName: generateRules([
51
- {type: 'required', options: {message: 'Ce champ est requis.'}},
52
- {type: 'minLength', options: {length: 3, ignoreSpace: true}},
53
- {type: 'maxLength', options: {length: 20}},
54
- ]),
55
- email: generateRules([
56
- {type: 'required', options: {fieldName: 'Email'}},
57
- {type: 'email'},
58
- ]),
59
- age: generateRules([
60
- {type: 'min', options: {value: 18}},
61
- {type: 'max', options: {value: 99}},
62
- ]),
53
+ import { ref } from 'vue';
54
+ import { useFieldValidation } from '@cnamts/synapse';
55
+
56
+ const { generateRules } = useFieldValidation();
57
+
58
+ const firstName = ref('');
59
+ const email = ref('');
60
+ const age = ref('');
61
+
62
+ const rules = {
63
+ firstName: generateRules([
64
+ { type: 'required', options: { message: 'Ce champ est requis.' } },
65
+ { type: 'minLength', options: { length: 3, ignoreSpace: true } },
66
+ { type: 'maxLength', options: { length: 20 } },
67
+ ]),
68
+ email: generateRules([
69
+ { type: 'required', options: { fieldName: 'Email' } },
70
+ { type: 'email' },
71
+ ]),
72
+ age: generateRules([
73
+ { type: 'min', options: { value: 18 } },
74
+ { type: 'max', options: { value: 99 } },
75
+ ]),
63
76
  };
64
77
 
65
- const validateField = (field: string) => {
66
- return rules[field].every((rule) => rule(field));
78
+ const validateField = (field: string) => {
79
+ return rules[field].every((rule) => rule(field));
67
80
  };
68
81
 
69
- const handleSubmit = () => {
70
- if (validateField('firstName') && validateField('email') && validateField('age')) {
82
+ const handleSubmit = () => {
83
+ if (validateField('firstName') && validateField('email') && validateField('age')) {
71
84
  alert('Formulaire valide.');
72
- } else {
85
+ } else {
73
86
  alert('Merci de vérifier les champs.');
74
- }
87
+ }
75
88
  };
76
89
  </script>
77
- `} />
78
- ---
90
+ `}
91
+ />
92
+
93
+ Vous pouvez retrouver un exemple complet sur le [NirField](/docs/composants-formulaires-nirfield--docs).
79
94
 
80
- ### Template Vue.js
81
-
82
- <Source dark code={`
83
- <template>
84
- <v-form
85
- @submit.prevent="handleSubmit">
86
- <v-text-field
87
- v-model="firstName"
88
- :rules="rules.firstName"
89
- label="Prénom"
90
- @blur="validateField('firstName')"
91
- />
92
- <v-text-field
93
- v-model="email"
94
- :rules="rules.email"
95
- label="Email"
96
- @blur="validateField('email')"
97
- />
98
- <v-text-field
99
- v-model="age"
100
- :rules="rules.age"
101
- label="Âge"
102
- @blur="validateField('age')"
103
- />
104
- <v-btn block class="mt-2" type="submit">Soumettre</v-btn>
105
- </v-form>
106
- </template>
107
- `} />
108
95
  ---
109
96
 
110
97
  ## Fonctionnalités supportées
111
98
 
112
- - **Validation requise** (`required`)
113
- - **Longueur minimale** (`minLength`)
114
- - **Longueur maximale** (`maxLength`)
115
- - **Valeur minimale** (`min`)
116
- - **Valeur maximale** (`max`)
117
- - **Validation par motif** (`matchPattern`)
118
- - **Validation d'email** (`email`)
99
+ - **Validation requise** (`required`) : Assurez-vous qu'un champ est rempli.
100
+ - **Longueur minimale** (`minLength`) : Validez un champ avec un nombre minimal de caractères.
101
+ - **Longueur maximale** (`maxLength`) : Limitez un champ à un nombre maximal de caractères.
102
+ - **Valeur minimale** (`min`) : Assurez-vous que la valeur est au moins égale à une valeur définie.
103
+ - **Valeur maximale** (`max`) : Assurez-vous que la valeur ne dépasse pas une valeur définie.
104
+ - **Validation par motif** (`matchPattern`) : Validez un champ à l'aide d'une expression régulière.
105
+ - **Validation d'email** (`email`) : Assurez-vous que la valeur est une adresse email valide.
106
+ - **Validation personnalisée** (`custom`) : Implémentez des règles spécifiques via une fonction.
119
107
 
120
108
  ---
121
109
 
122
110
  ## Bonnes pratiques
123
111
 
124
- - Toujours tester les messages d'erreur personnalisés pour garantir une bonne expérience utilisateur.
125
- - Centraliser la logique de validation pour une meilleure maintenance.
126
- - Documenter les règles complexes pour aider votre équipe à comprendre leur fonctionnement.
112
+ - **Centralisation** : Centralisez la logique de validation pour garantir une maintenance facile.
113
+ - **Accessibilité** : Vérifiez que les messages d'erreur sont clairs et concis pour tous les utilisateurs.
127
114
 
128
115
  ---
129
116
 
130
117
  ## Conclusion
131
118
 
132
- Avec `useFieldValidation`, vous disposez d'un moyen simple et flexible pour gérer vos validations de formulaires dans Vue.js. Combinez-le avec des bibliothèques comme Vuetify pour une expérience utilisateur optimisée.
119
+ Avec `useFieldValidation`, vous disposez d'un outil pour gérer les validations de vos formulaires dans Vue.js. Ce composable est idéal pour créer des validations personnalisées et intégrer des champs avec des bibliothèques comme Vuetify.
120
+
@@ -1,21 +1,21 @@
1
- import Alert from '../../components/Alert/Alert.vue'
1
+ import SyAlert from '@/components/SyAlert/SyAlert.vue'
2
2
 
3
3
  export default {
4
4
  title: 'Guide Du Dev/Rapport de bug',
5
- component: Alert,
5
+ component: SyAlert,
6
6
  }
7
7
  export const Info = {
8
8
  render: () => {
9
9
  return {
10
- components: { Alert },
10
+ components: { SyAlert },
11
11
  setup() {
12
12
  return { }
13
13
  },
14
14
  template: `
15
- <Alert type="info" variant="tonal" :closable="false">
15
+ <SyAlert type="info" variant="tonal" :closable="false">
16
16
  <template #default>Lorsque vous créez une reproduction minimale, supprimez tous les éléments, propriétés, variables, données et autres qui ne sont pas nécessaires pour reproduire le bug. Cela facilitera le traitement du rapport et le temps qu’il faudra pour identifier puis résoudre le bug.
17
17
  </template>
18
- </Alert>
18
+ </SyAlert>
19
19
  `,
20
20
  }
21
21
  },
@@ -122,7 +122,7 @@ Utilisation dans un composant Vue
122
122
  <Source dark code={`
123
123
  <script setup lang="ts">
124
124
  import { VBtn } from 'vuetify/components'
125
- import NotificationBar from '@cnamts/synapse'
125
+ import { NotificationBar } from '@cnamts/synapse'
126
126
  import { useNotificationService } from '@cnamts/synapse/src/services/NotificationService'
127
127
  import type { Notification } from '@cnamts/synapse/src/components/NotificationBar/types'
128
128