@cnamts/synapse 0.0.7-alpha → 0.0.9-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 (198) hide show
  1. package/dist/design-system-v3.d.ts +785 -372
  2. package/dist/design-system-v3.js +4993 -3357
  3. package/dist/design-system-v3.umd.cjs +1 -10
  4. package/dist/style.css +1 -1
  5. package/package.json +10 -2
  6. package/src/assets/settings.scss +2 -2
  7. package/src/assets/tokens.scss +107 -112
  8. package/src/components/BackBtn/BackBtn.vue +4 -4
  9. package/src/components/BackToTopBtn/BackToTopBtn.vue +1 -0
  10. package/src/components/CollapsibleList/CollapsibleList.mdx +1 -1
  11. package/src/components/CollapsibleList/CollapsibleList.vue +43 -44
  12. package/src/components/ContextualMenu/Accessibilite.mdx +14 -0
  13. package/src/components/ContextualMenu/Accessibilite.stories.ts +191 -0
  14. package/src/components/ContextualMenu/AccessibiliteItems.ts +89 -0
  15. package/src/components/ContextualMenu/ContextualMenu.mdx +118 -0
  16. package/src/components/ContextualMenu/ContextualMenu.stories.ts +430 -0
  17. package/src/components/ContextualMenu/ContextualMenu.vue +101 -0
  18. package/src/components/ContextualMenu/constants/ExpertiseLevelEnum.ts +4 -0
  19. package/src/components/ContextualMenu/tests/ContextualMenu.spec.ts +115 -0
  20. package/src/components/ContextualMenu/tests/__snapshots__/ContextualMenu.spec.ts.snap +10 -0
  21. package/src/components/ContextualMenu/types.ts +5 -0
  22. package/src/components/CookieBanner/CookieBanner.stories.ts +1 -2
  23. package/src/components/CookieBanner/CookieBanner.vue +13 -10
  24. package/src/components/CookieBanner/tests/__snapshots__/CookieBanner.spec.ts.snap +17 -15
  25. package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +6 -1
  26. package/src/components/CookiesSelection/CookiesInformation/locales.ts +1 -0
  27. package/src/components/CookiesSelection/CookiesTable/CookiesTable.vue +1 -0
  28. package/src/components/CookiesSelection/tests/__snapshots__/CookiesSelection.spec.ts.snap +17 -15
  29. package/src/components/CopyBtn/CopyBtn.vue +7 -7
  30. package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +26 -26
  31. package/src/components/Customs/SyInputSelect/SyInputSelect.vue +24 -24
  32. package/src/components/Customs/SySelect/SySelect.stories.ts +7 -7
  33. package/src/components/Customs/SySelect/SySelect.vue +36 -30
  34. package/src/components/Customs/SySelect/tests/SySelect.spec.ts +2 -2
  35. package/src/components/Customs/SyTextField/SyTextField.stories.ts +187 -2
  36. package/src/components/Customs/SyTextField/SyTextField.vue +185 -16
  37. package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +2 -4
  38. package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +18 -16
  39. package/src/components/Customs/SyTextField/types.d.ts +2 -2
  40. package/src/components/DataList/DataList.stories.ts +3 -2
  41. package/src/components/DataList/DataList.vue +1 -1
  42. package/src/components/DataListGroup/DataListGroup.stories.ts +3 -2
  43. package/src/components/DataListItem/DataListItem.vue +12 -12
  44. package/src/components/DatePicker/DatePicker.mdx +191 -0
  45. package/src/components/DatePicker/DatePicker.stories.ts +787 -0
  46. package/src/components/DatePicker/DatePicker.vue +560 -0
  47. package/src/components/DatePicker/DateTextInput.vue +409 -0
  48. package/src/components/DatePicker/tests/DatePicker.spec.ts +266 -0
  49. package/src/components/DialogBox/DialogBox.mdx +28 -2
  50. package/src/components/DialogBox/DialogBox.stories.ts +2 -2
  51. package/src/components/DialogBox/DialogBox.vue +3 -2
  52. package/src/components/DownloadBtn/DownloadBtn.vue +2 -1
  53. package/src/components/ExternalLinks/Accessibilite.mdx +14 -0
  54. package/src/components/ExternalLinks/Accessibilite.stories.ts +191 -0
  55. package/src/components/ExternalLinks/AccessibiliteItems.ts +197 -0
  56. package/src/components/ExternalLinks/ExternalLinks.mdx +86 -0
  57. package/src/components/ExternalLinks/ExternalLinks.stories.ts +553 -0
  58. package/src/components/ExternalLinks/ExternalLinks.vue +200 -0
  59. package/src/components/ExternalLinks/config.ts +34 -0
  60. package/src/components/ExternalLinks/constants/ExpertiseLevelEnum.ts +4 -0
  61. package/src/components/ExternalLinks/locales.ts +4 -0
  62. package/src/components/ExternalLinks/tests/ExternalLinks.spec.ts +154 -0
  63. package/src/components/ExternalLinks/tests/__snapshots__/ExternalLinks.spec.ts.snap +159 -0
  64. package/src/components/FileUpload/FileUpload.mdx +165 -0
  65. package/src/components/FileUpload/FileUpload.stories.ts +429 -0
  66. package/src/components/FileUpload/FileUpload.vue +195 -0
  67. package/src/components/FileUpload/FileUploadContent.vue +109 -0
  68. package/src/components/FileUpload/locales.ts +10 -0
  69. package/src/components/FileUpload/tests/FileUpload.spec.ts +332 -0
  70. package/src/components/FileUpload/tests/__snapshots__/FileUpload.spec.ts.snap +7 -0
  71. package/src/components/FileUpload/useFileDrop.ts +23 -0
  72. package/src/components/FileUpload/validateFiles.ts +39 -0
  73. package/src/components/FooterBar/FooterBar.vue +105 -80
  74. package/src/components/FranceConnectBtn/FranceConnectBtn.vue +14 -13
  75. package/src/components/HeaderBar/HeaderBar.vue +3 -3
  76. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.vue +11 -7
  77. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.vue +5 -5
  78. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.vue +2 -2
  79. package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.vue +10 -8
  80. package/src/components/HeaderBar/HeaderLogo/HeaderLogo.vue +2 -2
  81. package/src/components/HeaderBar/HeaderLogo/logos/Logo-mobile.vue +2 -1
  82. package/src/components/HeaderBar/HeaderLogo/logos/Logo.vue +2 -1
  83. package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +10 -10
  84. package/src/components/HeaderBar/consts.scss +1 -1
  85. package/src/components/HeaderLoading/HeaderLoading.vue +12 -11
  86. package/src/components/HeaderNavigationBar/HeaderNavigationBar.vue +2 -1
  87. package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +9 -9
  88. package/src/components/HeaderToolbar/HeaderToolbar.vue +215 -202
  89. package/src/components/LangBtn/LangBtn.vue +8 -6
  90. package/src/components/LogoBrandSection/LogoBrandSection.stories.ts +2 -2
  91. package/src/components/NirField/NirField.stories.ts +8 -8
  92. package/src/components/NirField/NirField.vue +46 -48
  93. package/src/components/NotFoundPage/NotFoundPage.stories.ts +33 -2
  94. package/src/components/NotFoundPage/NotFoundPage.vue +17 -0
  95. package/src/components/NotificationBar/NotificationBar.mdx +5 -5
  96. package/src/components/NotificationBar/NotificationBar.stories.ts +410 -314
  97. package/src/components/NotificationBar/NotificationBar.vue +43 -41
  98. package/src/components/PageContainer/PageContainer.vue +4 -4
  99. package/src/components/PasswordField/Accessibilite.mdx +14 -0
  100. package/src/components/PasswordField/Accessibilite.stories.ts +191 -0
  101. package/src/components/PasswordField/AccessibiliteItems.ts +184 -0
  102. package/src/components/PasswordField/PasswordField.mdx +70 -0
  103. package/src/components/PasswordField/PasswordField.stories.ts +213 -0
  104. package/src/components/PasswordField/PasswordField.vue +189 -0
  105. package/src/components/PasswordField/config.ts +11 -0
  106. package/src/components/PasswordField/constants/ExpertiseLevelEnum.ts +4 -0
  107. package/src/components/PasswordField/locales.ts +4 -0
  108. package/src/components/PasswordField/tests/PasswordField.spec.ts +96 -0
  109. package/src/components/PhoneField/PhoneField.mdx +0 -2
  110. package/src/components/PhoneField/PhoneField.stories.ts +10 -50
  111. package/src/components/PhoneField/PhoneField.vue +77 -93
  112. package/src/components/PhoneField/tests/PhoneField.spec.ts +0 -15
  113. package/src/components/RangeField/RangeField.mdx +54 -0
  114. package/src/components/RangeField/RangeField.stories.ts +189 -0
  115. package/src/components/RangeField/RangeField.vue +157 -0
  116. package/src/components/RangeField/RangeSlider/RangeSlider.vue +387 -0
  117. package/src/components/RangeField/RangeSlider/Tooltip/Tooltip.vue +64 -0
  118. package/src/components/RangeField/RangeSlider/tests/__snapshots__/rangeSlider.spec.ts.snap +27 -0
  119. package/src/components/RangeField/RangeSlider/tests/rangeSlider.spec.ts +100 -0
  120. package/src/components/RangeField/RangeSlider/tests/useDoubleSlider.spec.ts +246 -0
  121. package/src/components/RangeField/RangeSlider/tests/useMouseSlide.spec.ts +204 -0
  122. package/src/components/RangeField/RangeSlider/tests/useThumb.spec.ts +22 -0
  123. package/src/components/RangeField/RangeSlider/tests/useThumbKeyboard.spec.ts +233 -0
  124. package/src/components/RangeField/RangeSlider/tests/useTooltipsNudge.spec.ts +150 -0
  125. package/src/components/RangeField/RangeSlider/tests/useTrack.spec.ts +314 -0
  126. package/src/components/RangeField/RangeSlider/tests/vAnimateClick.spec.ts +32 -0
  127. package/src/components/RangeField/RangeSlider/types.ts +15 -0
  128. package/src/components/RangeField/RangeSlider/useMouseSlide.ts +109 -0
  129. package/src/components/RangeField/RangeSlider/useRangeSlider.ts +126 -0
  130. package/src/components/RangeField/RangeSlider/useThumb.ts +18 -0
  131. package/src/components/RangeField/RangeSlider/useThumbKeyboard.ts +84 -0
  132. package/src/components/RangeField/RangeSlider/useTooltipsNudge.ts +92 -0
  133. package/src/components/RangeField/RangeSlider/useTrack.ts +116 -0
  134. package/src/components/RangeField/RangeSlider/vAnimateClick.ts +19 -0
  135. package/src/components/RangeField/config.ts +7 -0
  136. package/src/components/RangeField/locales.ts +4 -0
  137. package/src/components/RangeField/tests/RangeField.spec.ts +224 -0
  138. package/src/components/RangeField/tests/__snapshots__/RangeField.spec.ts.snap +379 -0
  139. package/src/components/RatingPicker/EmotionPicker/EmotionPicker.vue +205 -0
  140. package/src/components/RatingPicker/EmotionPicker/locales.ts +3 -0
  141. package/src/components/RatingPicker/EmotionPicker/tests/EmotionPicker.spec.ts +104 -0
  142. package/src/components/RatingPicker/EmotionPicker/tests/__snapshots__/EmotionPicker.spec.ts.snap +66 -0
  143. package/src/components/RatingPicker/NumberPicker/NumberPicker.vue +159 -0
  144. package/src/components/RatingPicker/NumberPicker/locales.ts +4 -0
  145. package/src/components/RatingPicker/NumberPicker/tests/NumberPicker.spec.ts +73 -0
  146. package/src/components/RatingPicker/NumberPicker/tests/__snapshots__/NumberPicker.spec.ts.snap +105 -0
  147. package/src/components/RatingPicker/Rating.ts +45 -0
  148. package/src/components/RatingPicker/RatingPicker.mdx +56 -0
  149. package/src/components/RatingPicker/RatingPicker.stories.ts +515 -0
  150. package/src/components/RatingPicker/RatingPicker.vue +122 -0
  151. package/src/components/RatingPicker/StarsPicker/StarsPicker.vue +116 -0
  152. package/src/components/RatingPicker/StarsPicker/tests/StarsPicker.spec.ts +95 -0
  153. package/src/components/RatingPicker/StarsPicker/tests/__snapshots__/StarsPicker.spec.ts.snap +36 -0
  154. package/src/components/RatingPicker/locales.ts +3 -0
  155. package/src/components/RatingPicker/tests/Rating.spec.ts +104 -0
  156. package/src/components/RatingPicker/tests/RatingPicker.spec.ts +187 -0
  157. package/src/components/RatingPicker/tests/__snapshots__/RatingPicker.spec.ts.snap +108 -0
  158. package/src/components/SearchListField/SearchListField.mdx +74 -0
  159. package/src/components/SearchListField/SearchListField.stories.ts +126 -0
  160. package/src/components/SearchListField/SearchListField.vue +194 -0
  161. package/src/components/SearchListField/locales.ts +5 -0
  162. package/src/components/SearchListField/tests/SearchListField.spec.ts +323 -0
  163. package/src/components/SearchListField/types.d.ts +4 -0
  164. package/src/components/SelectBtnField/SelectBtnField.mdx +50 -0
  165. package/src/components/SelectBtnField/SelectBtnField.stories.ts +763 -0
  166. package/src/components/SelectBtnField/SelectBtnField.vue +283 -0
  167. package/src/components/SelectBtnField/config.ts +11 -0
  168. package/src/components/SelectBtnField/tests/SelectBtnField.spec.ts +327 -0
  169. package/src/components/SelectBtnField/tests/__snapshots__/SelectBtnField.spec.ts.snap +125 -0
  170. package/src/components/SelectBtnField/types.d.ts +11 -0
  171. package/src/components/SkipLink/SkipLink.vue +10 -10
  172. package/src/components/SocialMediaLinks/SocialMediaLinks.vue +28 -26
  173. package/src/components/SubHeader/SubHeader.vue +32 -31
  174. package/src/components/SyAlert/SyAlert.vue +12 -12
  175. package/src/components/UserMenuBtn/UserMenuBtn.vue +1 -1
  176. package/src/components/UserMenuBtn/config.ts +1 -1
  177. package/src/components/index.ts +17 -7
  178. package/src/composables/rules/useFieldValidation.ts +172 -44
  179. package/src/designTokens/index.ts +6 -4
  180. package/src/designTokens/{bootstrapColors.md → paColors.md} +1 -1
  181. package/src/designTokens/tokens/cnam/cnamLightTheme.ts +2 -0
  182. package/src/designTokens/tokens/pa/paColors.ts +171 -0
  183. package/src/designTokens/tokens/pa/paContextual.ts +58 -0
  184. package/src/designTokens/tokens/pa/paDarkTheme.ts +5 -0
  185. package/src/designTokens/tokens/pa/paLightTheme.ts +123 -0
  186. package/src/designTokens/tokens/pa/paSemantic.ts +87 -0
  187. package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +52 -2
  188. package/src/stories/GuideDuDev/CreerUneIssue.mdx +64 -0
  189. package/src/stories/GuideDuDev/{CommentUtiliserLesRules.mdx → UtiliserLesRules.mdx} +2 -2
  190. package/src/stories/GuideDuDev/components.stories.ts +9 -7
  191. package/src/stories/Guidelines/Vuetify/Vuetify.stories.ts +163 -88
  192. package/src/stories/Guidelines/Vuetify/VuetifyItems.ts +250 -23
  193. package/src/temp/TestDTComponent.vue +5 -6
  194. package/src/utils/calcHumanFileSize/index.ts +12 -0
  195. package/src/utils/calcHumanFileSize/tests/calcHumanFileSize.spec.ts +21 -0
  196. package/src/designTokens/tokens/bootstrap/bootstrapColors.ts +0 -158
  197. package/src/designTokens/tokens/bootstrap/bootstrapLightTheme.ts +0 -22
  198. package/src/stories/GuideDuDev/CommentContribuer.mdx +0 -22
@@ -1,88 +1,216 @@
1
- type RuleOptions = {
2
- fieldName?: string
1
+ export type ValidationResult = {
2
+ success?: string
3
+ error?: string
4
+ warning?: string
5
+ }
6
+
7
+ export type RuleOptions = {
3
8
  message?: string
4
9
  successMessage?: string
10
+ warningMessage?: string
11
+ fieldName?: string
12
+ fieldIdentifier?: string
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
14
+ value?: any
5
15
  length?: number
6
- value?: number
7
16
  pattern?: RegExp
8
17
  ignoreSpace?: boolean
9
- fieldIdentifier?: string
18
+ isWarning?: boolean // Si true, la règle génère un warning au lieu d'une erreur
10
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
11
20
  validate?: (value: any) => boolean | string
21
+ date?: string | Date // Date de référence pour les règles notBeforeDate et notAfterDate
12
22
  }
13
23
 
14
- type ValidationResult = {
15
- success?: string
16
- error?: string
17
- }
18
24
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
19
- type ValidationRule = (value: any) => ValidationResult
25
+ export type ValidationRule = (value: any) => ValidationResult
20
26
 
21
27
  export function useFieldValidation() {
28
+ const getValueLength = (value: string, ignoreSpace?: boolean): number => {
29
+ return ignoreSpace ? value.replace(/\s/g, '').length : value.length
30
+ }
31
+
22
32
  const createRule = (type: string, options: RuleOptions = {}): ValidationRule => {
23
- const getValueLength = (value: string) => {
24
- return options.ignoreSpace ? value.replace(/\s/g, '').length : value.length
25
- }
26
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
27
- return (value: any) => {
34
+ return (value: any): ValidationResult => {
35
+ // Gestion des champs vides non obligatoires
28
36
  if (type !== 'required' && typeof value === 'string' && value.trim() === '') {
29
37
  return {}
30
38
  }
39
+
40
+ // Identifier de champ pour personnaliser les messages
41
+ const identifier = options.fieldIdentifier
42
+ ? `${options.fieldIdentifier}`
43
+ : options.fieldName || 'ce champ'
44
+
45
+ const baseMessages = {
46
+ success: options.successMessage || 'Le champ est valide.',
47
+ error: options.message || `Validation échouée pour ${identifier}.`,
48
+ warning: options.warningMessage || `Attention : ${identifier} peut contenir une erreur.`,
49
+ }
50
+
51
+ const createValidationResult = (isValid: boolean, message?: string): ValidationResult => {
52
+ if (isValid) {
53
+ return { success: baseMessages.success }
54
+ }
55
+ return options.isWarning
56
+ ? { warning: message || baseMessages.warning }
57
+ : { error: message || baseMessages.error }
58
+ }
59
+
31
60
  switch (type) {
32
61
  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'}.` }
62
+ return createValidationResult(
63
+ typeof value === 'string' && value.trim() !== '',
64
+ options.message || `Vous devez renseigner ${identifier}.`,
65
+ )
36
66
 
37
67
  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.` }
68
+ return createValidationResult(
69
+ typeof value === 'number' && value >= (options.value ?? 0),
70
+ options.message || `La valeur de ${identifier} doit être supérieure ou égale à ${options.value}.`,
71
+ )
46
72
 
47
73
  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}.` }
74
+ return createValidationResult(
75
+ typeof value === 'number' && value <= (options.value ?? Infinity),
76
+ options.message || `La valeur de ${identifier} doit être inférieure ou égale à ${options.value}.`,
77
+ )
78
+
79
+ case 'minLength':
80
+ return createValidationResult(
81
+ typeof value === 'string' && getValueLength(value, options.ignoreSpace) >= (options.length ?? 0),
82
+ options.message || `${identifier} doit contenir au moins ${options.length} caractères.`,
83
+ )
51
84
 
52
85
  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.` }
86
+ return createValidationResult(
87
+ typeof value === 'string' && getValueLength(value, options.ignoreSpace) <= (options.length ?? Infinity),
88
+ options.message || `${identifier} ne doit pas dépasser ${options.length} caractères.`,
89
+ )
56
90
 
57
91
  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.` }
92
+ return createValidationResult(
93
+ typeof value === 'string' && getValueLength(value, options.ignoreSpace) === (options.length ?? 0),
94
+ options.message || `${identifier} doit contenir exactement ${options.length} caractères.`,
95
+ )
61
96
 
62
97
  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.` }
98
+ return createValidationResult(
99
+ typeof value === 'string' && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value),
100
+ options.message || `${identifier} doit être un email valide.`,
101
+ )
66
102
 
67
103
  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.` }
104
+ return createValidationResult(
105
+ typeof value === 'string' && !!options.pattern && options.pattern.test(value),
106
+ options.message || `Le format de ${identifier} est invalide.`,
107
+ )
108
+
109
+ case 'notWeekend': {
110
+ const dateValue = new Date(value)
111
+ return createValidationResult(
112
+ !(dateValue.getDay() === 0 || dateValue.getDay() === 6),
113
+ options.message || `${identifier} ne peut pas être un jour de weekend.`,
114
+ )
115
+ }
116
+
117
+ case 'notBeforeToday': {
118
+ const dateValue = new Date(value)
119
+ return createValidationResult(
120
+ dateValue >= new Date(),
121
+ options.message || `${identifier} ne peut pas être antérieur à aujourd'hui.`,
122
+ )
123
+ }
124
+
125
+ case 'notAfterToday': {
126
+ const dateValue = new Date(value)
127
+ return createValidationResult(
128
+ dateValue <= new Date(),
129
+ options.message || `${identifier} ne peut pas être postérieur à aujourd'hui.`,
130
+ )
131
+ }
132
+
133
+ case 'notBeforeDate': {
134
+ if (!options.date) {
135
+ return { error: 'Configuration de la règle invalide' }
136
+ }
137
+
138
+ const dateValue = new Date(value)
139
+
140
+ // Check if options.date is a string and in DD/MM/YYYY format
141
+ if (typeof options.date !== 'string') {
142
+ throw new Error('Date reference must be a string in DD/MM/YYYY format')
143
+ }
144
+
145
+ // Convert reference date from DD/MM/YYYY format to YYYY-MM-DD
146
+ const [day, month, year] = options.date.split('/')
147
+ const referenceDate = new Date(`${year}-${month}-${day}`)
148
+
149
+ return createValidationResult(
150
+ dateValue >= referenceDate,
151
+ options.message || `${identifier} ne peut pas être avant le ${options.date}.`,
152
+ )
153
+ }
154
+
155
+ case 'notAfterDate': {
156
+ if (!options.date) {
157
+ return { error: 'Configuration de la règle invalide' }
158
+ }
159
+
160
+ const dateValue = new Date(value)
161
+
162
+ // Check if options.date is a string and in DD/MM/YYYY format
163
+ if (typeof options.date !== 'string') {
164
+ throw new Error('Date reference must be a string in DD/MM/YYYY format')
165
+ }
166
+
167
+ // Convert reference date from DD/MM/YYYY format to YYYY-MM-DD
168
+ const [day, month, year] = options.date.split('/')
169
+ const referenceDate = new Date(`${year}-${month}-${day}`)
170
+
171
+ return createValidationResult(
172
+ dateValue <= referenceDate,
173
+ options.message || `${identifier} ne peut pas être après le ${options.date}.`,
174
+ )
175
+ }
176
+
177
+ case 'dateExact': {
178
+ if (!options.date) {
179
+ return { error: 'Configuration de la règle invalide' }
180
+ }
181
+
182
+ const dateValue = new Date(value)
183
+
184
+ if (typeof options.date !== 'string') {
185
+ throw new Error('Date reference must be a string in DD/MM/YYYY format')
186
+ }
187
+
188
+ const [day, month, year] = options.date.split('/')
189
+ const referenceDate = new Date(`${year}-${month}-${day}`)
190
+
191
+ return createValidationResult(
192
+ dateValue.getTime() === referenceDate.getTime(),
193
+ options.message || `${identifier} doit être exactement le ${options.date}.`,
194
+ )
195
+ }
71
196
 
72
197
  case 'custom': {
73
198
  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.` }
199
+ if (result === true) {
200
+ return { success: baseMessages.success }
201
+ }
202
+ return options.isWarning
203
+ ? { warning: typeof result === 'string' ? result : baseMessages.warning }
204
+ : { error: typeof result === 'string' ? result : baseMessages.error }
77
205
  }
78
206
 
79
207
  default:
80
- return { error: `La règle spécifiée n'existe pas.` }
208
+ return { error: `La règle spécifiée pour ${identifier} n'existe pas.` }
81
209
  }
82
210
  }
83
211
  }
84
212
 
85
- const generateRules = (fieldRules: Array<{ type: string, options?: RuleOptions }>) => {
213
+ const generateRules = (fieldRules: Array<{ type: string, options?: RuleOptions }>): ValidationRule[] => {
86
214
  return fieldRules.map(rule => createRule(rule.type, rule.options))
87
215
  }
88
216
 
@@ -3,8 +3,9 @@ import { cnamContextualTokens } from './tokens/cnam/cnamContextual'
3
3
  import { cnamColorsTokens } from './tokens/cnam/cnamColors'
4
4
  import { cnamLightTheme } from './tokens/cnam/cnamLightTheme'
5
5
  import { cnamDarkTheme } from './tokens/cnam/cnamDarkTheme'
6
- import { bootstrapColorsTokens } from './tokens/bootstrap/bootstrapColors'
7
- import { bootstrapLightTheme } from './tokens/bootstrap/bootstrapLightTheme'
6
+ import { paColorsTokens } from './tokens/pa/paColors'
7
+ import { paLightTheme } from './tokens/pa/paLightTheme'
8
+ import { paDarkTheme } from './tokens/pa/paDarkTheme'
8
9
 
9
10
  export {
10
11
  cnamColorsTokens,
@@ -12,6 +13,7 @@ export {
12
13
  cnamContextualTokens,
13
14
  cnamLightTheme,
14
15
  cnamDarkTheme,
15
- bootstrapColorsTokens,
16
- bootstrapLightTheme,
16
+ paColorsTokens,
17
+ paLightTheme,
18
+ paDarkTheme,
17
19
  }
@@ -1,4 +1,4 @@
1
- # Color Bootstrap Cnam Light
1
+ # Color Palette Portail Agent Light
2
2
 
3
3
  ## Primary
4
4
 
@@ -11,6 +11,8 @@ export const cnamLightTheme = {
11
11
  success: cnamColorsTokens.turquoise.darken60,
12
12
  warning: cnamColorsTokens.yellow.darken60,
13
13
  risquePro: cnamColorsTokens.brick.base,
14
+ light: cnamColorsTokens.grey.lighten60,
15
+ dark: cnamColorsTokens.grey.darken80,
14
16
  onBackground: cnamSemanticTokens.colors.background.surface,
15
17
  onSurfaceAlt: cnamSemanticTokens.colors.background.surfaceAlt,
16
18
  onSurface: cnamSemanticTokens.colors.background.surface,
@@ -0,0 +1,171 @@
1
+ export const paColorsTokens = {
2
+ orange: {
3
+ darken80: '#2d100b',
4
+ darken60: '#5a2017',
5
+ darken40: '#862f22',
6
+ darken20: '#b33f2e',
7
+ base: '#e04f39',
8
+ lighten20: '#e67261',
9
+ lighten40: '#ec9588',
10
+ lighten60: '#f3b9b0',
11
+ lighten80: '#f9dcd7',
12
+ lighten90: '#fcedeb',
13
+ lighten97: '#fefaf9',
14
+ },
15
+ yellow: {
16
+ darken80: '#302407',
17
+ darken60: '#60480e',
18
+ darken40: '#906b15',
19
+ darken20: '#c08f1c',
20
+ base: '#f0b323',
21
+ lighten20: '#f3c24f',
22
+ lighten40: '#f6d17b',
23
+ lighten60: '#f9e1a7',
24
+ lighten80: '#fcf0d3',
25
+ lighten90: '#fdf7e9',
26
+ lighten97: '#fffdf8',
27
+ },
28
+ green: {
29
+ darken80: '#112717',
30
+ darken60: '#224e2d',
31
+ darken40: '#347444',
32
+ darken20: '#459b5a',
33
+ base: '#56c271',
34
+ lighten20: '#78ce8d',
35
+ lighten40: '#9adaaa',
36
+ lighten60: '#bbe7c6',
37
+ lighten80: '#ddf3e3',
38
+ lighten90: '#eef9f1',
39
+ lighten97: '#fafdfb',
40
+ },
41
+ turquoise: {
42
+ darken80: '#00221c',
43
+ darken60: '#004439',
44
+ darken40: '#006755',
45
+ darken20: '#008972',
46
+ base: '#00ab8e',
47
+ lighten20: '#33bca5',
48
+ lighten40: '#66cdbb',
49
+ lighten60: '#99ddd2',
50
+ lighten80: '#cceee8',
51
+ lighten90: '#e5f7f4',
52
+ lighten97: '#f7fcfc',
53
+ },
54
+ blue: {
55
+ darken80: '#020d1f',
56
+ darken60: '#051a3e',
57
+ darken40: '#07275c',
58
+ darken20: '#0a347b',
59
+ base: '#0c419a',
60
+ lighten20: '#3d67ae',
61
+ lighten40: '#6d8dc2',
62
+ lighten60: '#9eb3d7',
63
+ lighten80: '#ced9eb',
64
+ lighten90: '#e7ecf5',
65
+ lighten97: '#f8f9fc',
66
+ },
67
+ cyan: {
68
+ darken80: '#00212d',
69
+ darken60: '#004259',
70
+ darken40: '#006386',
71
+ darken20: '#0084b2',
72
+ base: '#00a5df',
73
+ lighten20: '#33b7e5',
74
+ lighten40: '#66c9ec',
75
+ lighten60: '#99dbf2',
76
+ lighten80: '#ccedf9',
77
+ lighten90: '#e5f6fc',
78
+ lighten97: '#f7fcfe',
79
+ },
80
+ frostedBlue: {
81
+ darken80: '#142327',
82
+ darken60: '#28464d',
83
+ darken40: '#3d6874',
84
+ darken20: '#518b9a',
85
+ base: '#65aec1',
86
+ lighten20: '#84becd',
87
+ lighten40: '#a3ceda',
88
+ lighten60: '#c1dfe6',
89
+ lighten80: '#e0eff3',
90
+ lighten90: '#f0f7f9',
91
+ lighten97: '#fafdfd',
92
+ },
93
+ parma: {
94
+ darken80: '#171c26',
95
+ darken60: '#2f384d',
96
+ darken40: '#465473',
97
+ darken20: '#5e709a',
98
+ base: '#758cc0',
99
+ lighten20: '#91a3cd',
100
+ lighten40: '#acbad9',
101
+ lighten60: '#c8d1e6',
102
+ lighten80: '#e3e8f2',
103
+ lighten90: '#f1f3f9',
104
+ lighten97: '#fbfcfd',
105
+ },
106
+ mauve: {
107
+ darken80: '#201224',
108
+ darken60: '#402449',
109
+ darken40: '#60376d',
110
+ darken20: '#804992',
111
+ base: '#a05bb6',
112
+ lighten20: '#b37cc5',
113
+ lighten40: '#c69dd3',
114
+ lighten60: '#d9bde2',
115
+ lighten80: '#ecdef0',
116
+ lighten90: '#f5eff8',
117
+ lighten97: '#fcfafd',
118
+ },
119
+ pink: {
120
+ darken80: '#2d051a',
121
+ darken60: '#5a0a34',
122
+ darken40: '#87104d',
123
+ darken20: '#b41567',
124
+ base: '#e11a81',
125
+ lighten20: '#e7489a',
126
+ lighten40: '#ed76b3',
127
+ lighten60: '#f3a3cd',
128
+ lighten80: '#f9d1e6',
129
+ lighten90: '#fce8f2',
130
+ lighten97: '#fef8fb',
131
+ },
132
+ brick: {
133
+ darken80: '#291112',
134
+ darken60: '#522224',
135
+ darken40: '#7b3237',
136
+ darken20: '#a44349',
137
+ base: '#cd545b',
138
+ lighten20: '#d7767c',
139
+ lighten40: '#e1989d',
140
+ lighten60: '#ebbbbd',
141
+ lighten80: '#f5ddde',
142
+ lighten90: '#faeeef',
143
+ lighten97: '#fdfafa',
144
+ },
145
+ grey: {
146
+ darken80: '#111212',
147
+ darken60: '#222324',
148
+ darken40: '#323535',
149
+ darken20: '#434647',
150
+ base: '#545859',
151
+ lighten20: '#76797a',
152
+ lighten40: '#989b9b',
153
+ lighten60: '#bbbcbd',
154
+ lighten80: '#dddede',
155
+ lighten90: '#eeeeee',
156
+ lighten97: '#fafafa',
157
+ },
158
+ white: {
159
+ 20: 'rgba(255, 255, 255, 0.2000)',
160
+ 38: 'rgba(255, 255, 255, 0.3800)',
161
+ 40: 'rgba(255, 255, 255, 0.4000)',
162
+ 70: 'rgba(255, 255, 255, 0.7000)',
163
+ 8: 'rgba(255, 255, 255, 0.0800)',
164
+ 0: 'rgba(255, 255, 255, 0.0000)',
165
+ base: '#ffffff',
166
+ },
167
+ transparentBlue: {
168
+ transparentBlue18: '#a6d4eb',
169
+ transparentBlue8: '#ebf0f7',
170
+ },
171
+ }
@@ -0,0 +1,58 @@
1
+ export const paContextualTokens = {
2
+ colors: {
3
+ background: '#ffffff',
4
+ border: '#dddddd',
5
+ text: '#333333',
6
+ icon: '#666666',
7
+ overlay: 'rgba(0, 0, 0, 0.5)',
8
+ interactive: '#007bff',
9
+ },
10
+ gap: {
11
+ 0: '0',
12
+ 1: '4px',
13
+ 2: '8px',
14
+ 3: '122px',
15
+ 4: '16px',
16
+ 5: '20px',
17
+ 6: '24px',
18
+ 7: '28px',
19
+ 8: '32px',
20
+ 9: '36px',
21
+ 10: '40px',
22
+ 11: '44px',
23
+ 12: '48px',
24
+ 13: '52px',
25
+ 14: '56px',
26
+ 15: '60px',
27
+ 16: '64px',
28
+ },
29
+ iconSize: {
30
+ xsmall: '8px',
31
+ small: '16px',
32
+ default: '24px',
33
+ large: '32px',
34
+ },
35
+ radius: {
36
+ rounded0: '0',
37
+ rounded: '4px',
38
+ roundedLg: '8px',
39
+ roundedPill: '64px',
40
+ },
41
+ padding: {
42
+ 0: '0',
43
+ 2: '8px',
44
+ 3: '12px',
45
+ 4: '16px',
46
+ 6: '24px',
47
+ 8: '32px',
48
+ 10: '40px',
49
+ 14: '56px',
50
+ 16: '64px',
51
+ },
52
+ fontSize: {
53
+ titres: '24px',
54
+ titresAlternatifs: '20px',
55
+ corpsDeTexte: '16px',
56
+ liensEtLibelles: '14px',
57
+ },
58
+ }
@@ -0,0 +1,5 @@
1
+ import { paColorsTokens } from '../pa/paColors'
2
+
3
+ export const paDarkTheme = {
4
+ backgroundSurface: paColorsTokens.parma.darken60,
5
+ }
@@ -0,0 +1,123 @@
1
+ import { paColorsTokens } from './paColors'
2
+ import { paSemanticTokens } from '../pa/paSemantic'
3
+
4
+ export const paLightTheme = {
5
+ primary: '#0062ac',
6
+ secondary: '#ac1c81',
7
+ accent: '#6f42c1',
8
+ error: '#B6052A',
9
+ info: '#0062AC',
10
+ success: '#73A839',
11
+ warning: '#FD7E14',
12
+ blue: '#007bff',
13
+ blueBase: '#007bff',
14
+ indigo: '#6610f2',
15
+ indigoBase: '#6610f2',
16
+ purple: '#6f42c1',
17
+ purpleBase: '#6f42c1',
18
+ pink: '#e83e8c',
19
+ pinkBase: '#e83e8c',
20
+ red: '#dc3545',
21
+ redBase: '#dc3545',
22
+ orange: '#fd7e14',
23
+ orangeBase: '#fd7e14',
24
+ yellow: '#ffc107',
25
+ yellowBase: '#ffc107',
26
+ green: '#28a745',
27
+ greenBase: '#28a745',
28
+ teal: '#20c997',
29
+ tealBase: '#20c997',
30
+ cyan: '#17a2b8',
31
+ cyanBase: '#17a2b8',
32
+ gray: '#8a8b8b',
33
+ grayBase: '#8a8b8b',
34
+ grayDark: '#343434',
35
+ grayDarkBase: '#343434',
36
+ risquePro: paColorsTokens.brick.base,
37
+ light: '#f4f5f1',
38
+ dark: '#343434',
39
+ default: '#b7cbd6',
40
+ brand: '#4a3f59',
41
+ brandSecondary: '#ac1c81',
42
+ brandMuted: '#b7cbd6',
43
+ brandMutedLite: '#E7F3F9',
44
+ hilitePrimary: '#0062ac',
45
+ hiliteSecondary: '#e6bebf',
46
+ onBackground: paSemanticTokens.colors.background.surface,
47
+ onSurfaceAlt: paSemanticTokens.colors.background.surfaceAlt,
48
+ onSurface: paSemanticTokens.colors.background.surface,
49
+ onWarning: paSemanticTokens.colors.background.warning,
50
+ overlayFullpage: paSemanticTokens.colors.overlay.fullpage,
51
+ overlayOnDark: paSemanticTokens.colors.overlay.onDark,
52
+ overlayOnLight: paSemanticTokens.colors.overlay.onLight,
53
+ interactiveDefault: paSemanticTokens.colors.interactive.default,
54
+ interactiveHover: paSemanticTokens.colors.interactive.hover,
55
+ interactivePressed: paSemanticTokens.colors.interactive.pressed,
56
+ interactiveFocus: paSemanticTokens.colors.interactive.focus,
57
+ interactiveDisabled: paSemanticTokens.colors.interactive.disabled,
58
+ interactiveHoverOnSelected: paSemanticTokens.colors.interactive.hoverOnSelected,
59
+ backgroundMain: paSemanticTokens.colors.background.main,
60
+ backgroundSurface: paSemanticTokens.colors.background.surface,
61
+ backgroundSurfaceAlt: paSemanticTokens.colors.background.surfaceAlt,
62
+ backgroungMainAlt: paSemanticTokens.colors.background.mainAlt,
63
+ backgroungRaised: paSemanticTokens.colors.background.raised,
64
+ backgroundAccent: paSemanticTokens.colors.background.accent,
65
+ backgroungAccentContrasted: paSemanticTokens.colors.background.accentContrasted,
66
+ backgroundAccentAlt: paSemanticTokens.colors.background.accentAlt,
67
+ backgroundInfo: paSemanticTokens.colors.background.info,
68
+ backgroundInfoSubdued: paSemanticTokens.colors.background.infoSubdued,
69
+ backgroundInfoContrasted: paSemanticTokens.colors.background.infoContrasted,
70
+ backgroundSuccess: paSemanticTokens.colors.background.success,
71
+ backgroundSuccessSubdued: paSemanticTokens.colors.background.successSubdued,
72
+ backgroundSuccessContrasted: paSemanticTokens.colors.background.successContrasted,
73
+ backgroundWarning: paSemanticTokens.colors.background.warning,
74
+ backgroundWarningSubdued: paSemanticTokens.colors.background.warningSubdued,
75
+ backgroundWarningContrasted: paSemanticTokens.colors.background.warningContrasted,
76
+ backgroundError: paSemanticTokens.colors.background.error,
77
+ backgroundErrorSubdued: paSemanticTokens.colors.background.errorSubdued,
78
+ backgroundErrorContrasted: paSemanticTokens.colors.background.errorContrasted,
79
+ backgroundDisabled: paSemanticTokens.colors.background.disabled,
80
+ backgroundDisabledOnDark: paSemanticTokens.colors.background.disabledOnDark,
81
+ backgroundAssure: paSemanticTokens.colors.background.assure,
82
+ backgroundProfessionnel: paSemanticTokens.colors.background.professionnel,
83
+ backgroundEntreprise: paSemanticTokens.colors.background.entreprise,
84
+ borderDarker: paSemanticTokens.colors.border.darker,
85
+ borderBase: paSemanticTokens.colors.border.base,
86
+ borderSubdued: paSemanticTokens.colors.border.subdued,
87
+ borderAccent: paSemanticTokens.colors.border.accent,
88
+ borderAccentContrasted: paSemanticTokens.colors.border.accentContrasted,
89
+ borderAccentOnDark: paSemanticTokens.colors.border.accentOnDark,
90
+ borderInfo: paSemanticTokens.colors.border.info,
91
+ borderSuccess: paSemanticTokens.colors.border.success,
92
+ borderWarning: paSemanticTokens.colors.border.warning,
93
+ borderError: paSemanticTokens.colors.border.error,
94
+ borderOnDark: paSemanticTokens.colors.border.onDark,
95
+ borderDisabled: paSemanticTokens.colors.border.disabled,
96
+ borderDisabledOnDark: paSemanticTokens.colors.border.disabledOnDark,
97
+ textBase: paSemanticTokens.colors.text.base,
98
+ textAccent: paSemanticTokens.colors.text.accent,
99
+ textAccentContrasted: paSemanticTokens.colors.text.accentContrasted,
100
+ textSubdued: paSemanticTokens.colors.text.subdued,
101
+ textInfo: paSemanticTokens.colors.text.info,
102
+ textSuccess: paSemanticTokens.colors.text.success,
103
+ textWarning: paSemanticTokens.colors.text.warning,
104
+ textError: paSemanticTokens.colors.text.error,
105
+ textDisabled: paSemanticTokens.colors.text.disabled,
106
+ textOnDark: paSemanticTokens.colors.text.onDark,
107
+ textSubduedOnDark: paSemanticTokens.colors.text.subduedOnDark,
108
+ textDisabledOnDark: paSemanticTokens.colors.text.disabledOnDark,
109
+ iconBase: paSemanticTokens.colors.icon.base,
110
+ iconSubdued: paSemanticTokens.colors.icon.subdued,
111
+ iconSubduedOnDark: paSemanticTokens.colors.icon.subduedOnDark,
112
+ iconAccent: paSemanticTokens.colors.icon.accent,
113
+ iconAccentContrasted: paSemanticTokens.colors.icon.accentContrasted,
114
+ iconInfo: paSemanticTokens.colors.icon.info,
115
+ iconSuccess: paSemanticTokens.colors.icon.success,
116
+ iconWarning: paSemanticTokens.colors.icon.warning,
117
+ iconError: paSemanticTokens.colors.icon.error,
118
+ iconOnDark: paSemanticTokens.colors.icon.onDark,
119
+ iconDisabled: paSemanticTokens.colors.icon.disabled,
120
+ iconDisabledOnDark: paSemanticTokens.colors.icon.disabledOnDark,
121
+ transparentBlue18: paColorsTokens.blue.base,
122
+ transparentBlue8: paColorsTokens.transparentBlue.transparentBlue8,
123
+ }