@cnamts/synapse 0.0.11-alpha → 0.0.12-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.
- package/dist/design-system-v3.js +3878 -3189
- package/dist/design-system-v3.umd.cjs +1 -1
- package/dist/src/components/Amelipro/types/languages.d.ts +6 -0
- package/dist/src/components/Amelipro/types/types.d.ts +65 -0
- package/dist/src/components/CookieBanner/CookieBanner.d.ts +1 -1
- package/dist/src/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
- package/dist/src/components/Customs/SyTextField/SyTextField.d.ts +29 -23
- package/dist/src/components/Customs/SyTextField/types.d.ts +1 -0
- package/dist/src/components/DatePicker/DatePicker.d.ts +70 -59
- package/dist/src/components/DatePicker/DateTextInput.d.ts +67 -56
- package/dist/src/components/ErrorPage/ErrorPage.d.ts +1 -1
- package/dist/src/components/FileList/FileList.d.ts +1 -0
- package/dist/src/components/FileList/UploadItem/UploadItem.d.ts +1 -1
- package/dist/src/components/FilterSideBar/FilterSideBar.d.ts +31 -0
- package/dist/src/components/FilterSideBar/locales.d.ts +7 -0
- package/dist/src/components/FilterSideBar/tests/FilterSideBar.spec.d.ts +1 -0
- package/dist/src/components/LangBtn/LangBtn.d.ts +2 -2
- package/dist/src/components/NirField/NirField.d.ts +940 -0
- package/dist/src/components/NotificationBar/NotificationBar.d.ts +1 -1
- package/dist/src/components/PasswordField/PasswordField.d.ts +40 -8
- package/dist/src/components/PeriodField/PeriodField.d.ts +142 -120
- package/dist/src/components/PhoneField/PhoneField.d.ts +11 -2
- package/dist/src/components/RatingPicker/EmotionPicker/EmotionPicker.d.ts +1 -1
- package/dist/src/components/RatingPicker/NumberPicker/NumberPicker.d.ts +1 -1
- package/dist/src/components/RatingPicker/StarsPicker/StarsPicker.d.ts +1 -1
- package/dist/src/components/UploadWorkflow/config.d.ts +29 -0
- package/dist/src/components/UploadWorkflow/locales.d.ts +7 -0
- package/dist/src/components/UploadWorkflow/tests/UploadWorkflow.spec.d.ts +1 -0
- package/dist/src/components/UploadWorkflow/types.d.ts +19 -0
- package/dist/src/components/UploadWorkflow/useFileList.d.ts +10 -0
- package/dist/src/components/UploadWorkflow/useFileUploadJourney.d.ts +9 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/composables/rules/useFieldValidation.d.ts +1 -0
- package/dist/src/composables/validation/tests/useValidation.spec.d.ts +1 -0
- package/dist/src/composables/validation/useValidation.d.ts +39 -0
- package/dist/src/designTokens/index.d.ts +3 -1
- package/dist/src/vuetifyConfig.d.ts +81 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/assets/_elevations.scss +89 -0
- package/src/assets/_fonts.scss +6 -0
- package/src/assets/_radius.scss +86 -0
- package/src/assets/_spacers.scss +149 -0
- package/src/assets/settings.scss +7 -3
- package/src/assets/tokens.scss +32 -29
- package/src/components/Amelipro/types/languages.d.ts +6 -0
- package/src/components/Amelipro/types/types.d.ts +65 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +65 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +13 -3
- package/src/components/Customs/SySelect/SySelect.stories.ts +88 -5
- package/src/components/Customs/SySelect/SySelect.vue +36 -10
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +135 -2
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +576 -85
- package/src/components/Customs/SyTextField/SyTextField.vue +132 -104
- package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +190 -38
- package/src/components/Customs/SyTextField/types.d.ts +1 -0
- package/src/components/DatePicker/DatePicker.vue +405 -137
- package/src/components/DatePicker/DateTextInput.vue +15 -0
- package/src/components/DatePicker/tests/DatePicker.spec.ts +8 -15
- package/src/components/FileList/FileList.vue +2 -1
- package/src/components/FileList/UploadItem/UploadItem.vue +10 -0
- package/src/components/FileUpload/FileUpload.stories.ts +84 -0
- package/src/components/FileUpload/FileUpload.vue +1 -0
- package/src/components/FileUpload/tests/FileUpload.spec.ts +4 -4
- package/src/components/FilterInline/FilterInline.mdx +180 -34
- package/src/components/FilterInline/FilterInline.stories.ts +363 -6
- package/src/components/FilterSideBar/FilterSideBar.mdx +237 -0
- package/src/components/FilterSideBar/FilterSideBar.stories.ts +798 -0
- package/src/components/FilterSideBar/FilterSideBar.vue +193 -0
- package/src/components/FilterSideBar/locales.ts +8 -0
- package/src/components/FilterSideBar/tests/FilterSideBar.spec.ts +305 -0
- package/src/components/FilterSideBar/tests/__snapshots__/FilterSideBar.spec.ts.snap +39 -0
- package/src/components/HeaderBar/Usages.mdx +1 -1
- package/src/components/NirField/NirField.stories.ts +573 -29
- package/src/components/NirField/NirField.vue +397 -359
- package/src/components/NirField/tests/NirField.spec.ts +88 -52
- package/src/components/NirField/tests//342/200/257dataset/342/200/257.md +12 -0
- package/src/components/NotificationBar/Accessibilite.stories.ts +4 -0
- package/src/components/NotificationBar/NotificationBar.stories.ts +18 -13
- package/src/components/PasswordField/PasswordField.mdx +129 -47
- package/src/components/PasswordField/PasswordField.stories.ts +924 -120
- package/src/components/PasswordField/PasswordField.vue +209 -99
- package/src/components/PasswordField/tests/PasswordField.spec.ts +138 -9
- package/src/components/PeriodField/PeriodField.vue +55 -54
- package/src/components/PhoneField/PhoneField.stories.ts +69 -0
- package/src/components/PhoneField/PhoneField.vue +3 -0
- package/src/components/PhoneField/indicatifs.ts +1 -1
- package/src/components/UploadWorkflow/UploadWorkflow.mdx +75 -0
- package/src/components/UploadWorkflow/UploadWorkflow.stories.ts +943 -0
- package/src/components/UploadWorkflow/UploadWorkflow.vue +230 -0
- package/src/components/UploadWorkflow/config.ts +29 -0
- package/src/components/UploadWorkflow/locales.ts +8 -0
- package/src/components/UploadWorkflow/tests/UploadWorkflow.spec.ts +257 -0
- package/src/components/UploadWorkflow/tests/__snapshots__/UploadWorkflow.spec.ts.snap +54 -0
- package/src/components/UploadWorkflow/types.ts +21 -0
- package/src/components/UploadWorkflow/useFileList.ts +84 -0
- package/src/components/UploadWorkflow/useFileUploadJourney.ts +18 -0
- package/src/components/index.ts +2 -0
- package/src/composables/rules/useFieldValidation.ts +5 -2
- package/src/composables/validation/tests/useValidation.spec.ts +154 -0
- package/src/composables/validation/useValidation.ts +165 -0
- package/src/designTokens/index.ts +4 -0
- package/src/stories/Demarrer/Accueil.mdx +1 -1
- package/src/stories/DesignTokens/ThemePA.mdx +4 -30
- package/src/stories/GuideDuDev/UtiliserLesRules.mdx +319 -76
- package/src/stories/GuideDuDev/moduleDeNotification.mdx +1 -1
- package/src/vuetifyConfig.ts +61 -0
- package/src/composables/useFilterable/__snapshots__/useFilterable.spec.ts.snap +0 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { computed, ref, type Ref } from 'vue'
|
|
2
|
+
import type { UploadItem } from './types'
|
|
3
|
+
|
|
4
|
+
export default function useFileUploadJourney(
|
|
5
|
+
fileListItems: Ref<UploadItem[]>,
|
|
6
|
+
) {
|
|
7
|
+
const selectItems = computed(() => fileListItems.value.map(item => ({
|
|
8
|
+
value: item.id,
|
|
9
|
+
text: item.title,
|
|
10
|
+
})))
|
|
11
|
+
|
|
12
|
+
const selectedItem = ref<string>()
|
|
13
|
+
|
|
14
|
+
return ({
|
|
15
|
+
selectItems,
|
|
16
|
+
selectedItem,
|
|
17
|
+
})
|
|
18
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { default as FileList } from './FileList/FileList.vue'
|
|
|
27
27
|
export { default as FilePreview } from './FilePreview/FilePreview.vue'
|
|
28
28
|
export { default as FileUpload } from './FileUpload/FileUpload.vue'
|
|
29
29
|
export { default as FilterInline } from './FilterInline/FilterInline.vue'
|
|
30
|
+
export { default as FilterSideBar } from './FilterSideBar/FilterSideBar.vue'
|
|
30
31
|
export { default as FooterBar } from './FooterBar/FooterBar.vue'
|
|
31
32
|
export { default as FranceConnectBtn } from './FranceConnectBtn/FranceConnectBtn.vue'
|
|
32
33
|
export { default as HeaderBar } from './HeaderBar/HeaderBar.vue'
|
|
@@ -60,4 +61,5 @@ export { default as SkipLink } from './SkipLink/SkipLink.vue'
|
|
|
60
61
|
export { default as SocialMediaLinks } from './SocialMediaLinks/SocialMediaLinks.vue'
|
|
61
62
|
export { default as SubHeader } from './SubHeader/SubHeader.vue'
|
|
62
63
|
export { default as SyAlert } from './SyAlert/SyAlert.vue'
|
|
64
|
+
export { default as UploadWorkflow } from './UploadWorkflow/UploadWorkflow.vue'
|
|
63
65
|
export { default as UserMenuBtn } from './UserMenuBtn/UserMenuBtn.vue'
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Regular expressions
|
|
2
|
+
export const EMAIL_REGEXP = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
|
|
3
|
+
|
|
1
4
|
export type ValidationResult = {
|
|
2
5
|
success?: string
|
|
3
6
|
error?: string
|
|
@@ -100,7 +103,7 @@ export function useFieldValidation() {
|
|
|
100
103
|
|
|
101
104
|
const baseMessages = {
|
|
102
105
|
success: options.successMessage || 'Le champ est valide.',
|
|
103
|
-
error: options.message || `Validation
|
|
106
|
+
error: options.message || `Validation pour ${identifier}.`,
|
|
104
107
|
warning: options.warningMessage || `Attention : ${identifier} peut contenir une erreur.`,
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -154,7 +157,7 @@ export function useFieldValidation() {
|
|
|
154
157
|
|
|
155
158
|
case 'email':
|
|
156
159
|
return createValidationResult(
|
|
157
|
-
typeof value === 'string' &&
|
|
160
|
+
typeof value === 'string' && EMAIL_REGEXP.test(value),
|
|
158
161
|
options.message || options.warningMessage || `${identifier} doit être un email valide.`,
|
|
159
162
|
)
|
|
160
163
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { useValidation } from '../useValidation'
|
|
3
|
+
|
|
4
|
+
describe('useValidation', () => {
|
|
5
|
+
it('should initialize with empty validation state', () => {
|
|
6
|
+
const validation = useValidation()
|
|
7
|
+
|
|
8
|
+
expect(validation.errors.value).toEqual([])
|
|
9
|
+
expect(validation.warnings.value).toEqual([])
|
|
10
|
+
expect(validation.successes.value).toEqual([])
|
|
11
|
+
expect(validation.hasError.value).toBe(false)
|
|
12
|
+
expect(validation.hasWarning.value).toBe(false)
|
|
13
|
+
expect(validation.hasSuccess.value).toBe(false)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should handle basic validation rules', () => {
|
|
17
|
+
const validation = useValidation()
|
|
18
|
+
const rules = [{
|
|
19
|
+
type: 'required',
|
|
20
|
+
options: {
|
|
21
|
+
message: 'Ce champ est requis',
|
|
22
|
+
successMessage: 'Champ valide',
|
|
23
|
+
},
|
|
24
|
+
}]
|
|
25
|
+
|
|
26
|
+
// Test avec une valeur vide
|
|
27
|
+
const emptyResult = validation.validateField('', rules)
|
|
28
|
+
expect(emptyResult.hasError).toBe(true)
|
|
29
|
+
expect(emptyResult.state.errors).toContain('Ce champ est requis')
|
|
30
|
+
|
|
31
|
+
// Test avec une valeur valide
|
|
32
|
+
const validResult = validation.validateField('test', rules)
|
|
33
|
+
expect(validResult.hasSuccess).toBe(true)
|
|
34
|
+
expect(validResult.state.successes).toContain('Champ valide')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should handle warning rules', () => {
|
|
38
|
+
const validation = useValidation()
|
|
39
|
+
const warningRules = [{
|
|
40
|
+
type: 'custom',
|
|
41
|
+
options: {
|
|
42
|
+
validate: (value: string) => value.length >= 8,
|
|
43
|
+
warningMessage: 'Le champ devrait contenir au moins 8 caractères',
|
|
44
|
+
isWarning: true,
|
|
45
|
+
},
|
|
46
|
+
}]
|
|
47
|
+
|
|
48
|
+
// Test avec une valeur courte
|
|
49
|
+
const shortResult = validation.validateField('test', [], warningRules)
|
|
50
|
+
expect(shortResult.hasWarning).toBe(true)
|
|
51
|
+
expect(shortResult.state.warnings[0]).toContain('8 caractères')
|
|
52
|
+
|
|
53
|
+
// Test avec une valeur valide
|
|
54
|
+
const validResult = validation.validateField('test_long', [], warningRules)
|
|
55
|
+
expect(validResult.hasWarning).toBe(false)
|
|
56
|
+
expect(validResult.state.warnings).toEqual([])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('should handle multiple validation rules', () => {
|
|
60
|
+
const validation = useValidation()
|
|
61
|
+
const rules = [
|
|
62
|
+
{
|
|
63
|
+
type: 'required',
|
|
64
|
+
options: {
|
|
65
|
+
message: 'Ce champ est requis',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'minLength',
|
|
70
|
+
options: {
|
|
71
|
+
length: 3,
|
|
72
|
+
message: 'Minimum 3 caractères requis',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
// Test avec une valeur vide
|
|
78
|
+
const emptyResult = validation.validateField('', rules)
|
|
79
|
+
expect(emptyResult.hasError).toBe(true)
|
|
80
|
+
expect(emptyResult.state.errors).toContain('Ce champ est requis')
|
|
81
|
+
|
|
82
|
+
// Test avec une valeur trop courte
|
|
83
|
+
const shortResult = validation.validateField('ab', rules)
|
|
84
|
+
expect(shortResult.hasError).toBe(true)
|
|
85
|
+
expect(shortResult.state.errors).toContain('Minimum 3 caractères requis')
|
|
86
|
+
|
|
87
|
+
// Test avec une valeur valide
|
|
88
|
+
const validResult = validation.validateField('abc', rules)
|
|
89
|
+
expect(validResult.hasError).toBe(false)
|
|
90
|
+
expect(validResult.hasSuccess).toBe(true)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('should respect showSuccessMessages option', () => {
|
|
94
|
+
const validation = useValidation({ showSuccessMessages: false })
|
|
95
|
+
const rules = [{
|
|
96
|
+
type: 'required',
|
|
97
|
+
options: {
|
|
98
|
+
message: 'Ce champ est requis',
|
|
99
|
+
successMessage: 'Champ valide',
|
|
100
|
+
},
|
|
101
|
+
}]
|
|
102
|
+
|
|
103
|
+
const result = validation.validateField('test', rules)
|
|
104
|
+
expect(result.hasSuccess).toBe(false)
|
|
105
|
+
expect(result.state.successes).toEqual([])
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('should use fieldIdentifier in messages', () => {
|
|
109
|
+
const validation = useValidation({ fieldIdentifier: 'Email' })
|
|
110
|
+
const rules = [{
|
|
111
|
+
type: 'required',
|
|
112
|
+
options: {
|
|
113
|
+
message: 'Le champ Email est requis',
|
|
114
|
+
},
|
|
115
|
+
}]
|
|
116
|
+
|
|
117
|
+
const result = validation.validateField('', rules)
|
|
118
|
+
expect(result.state.errors[0]).toContain('Email')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should clear validation state', () => {
|
|
122
|
+
const validation = useValidation()
|
|
123
|
+
const rules = [{
|
|
124
|
+
type: 'required',
|
|
125
|
+
options: {
|
|
126
|
+
message: 'Ce champ est requis',
|
|
127
|
+
},
|
|
128
|
+
}]
|
|
129
|
+
|
|
130
|
+
validation.validateField('', rules)
|
|
131
|
+
expect(validation.hasError.value).toBe(true)
|
|
132
|
+
|
|
133
|
+
validation.clearValidation()
|
|
134
|
+
expect(validation.errors.value).toEqual([])
|
|
135
|
+
expect(validation.warnings.value).toEqual([])
|
|
136
|
+
expect(validation.successes.value).toEqual([])
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should validate on submit', async () => {
|
|
140
|
+
const validation = useValidation()
|
|
141
|
+
const rules = [{
|
|
142
|
+
type: 'required',
|
|
143
|
+
options: {
|
|
144
|
+
message: 'Ce champ est requis',
|
|
145
|
+
},
|
|
146
|
+
}]
|
|
147
|
+
|
|
148
|
+
validation.validateField('', rules)
|
|
149
|
+
expect(await validation.validateOnSubmit()).toBe(false)
|
|
150
|
+
|
|
151
|
+
validation.validateField('test', rules)
|
|
152
|
+
expect(await validation.validateOnSubmit()).toBe(true)
|
|
153
|
+
})
|
|
154
|
+
})
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ref, computed } from 'vue'
|
|
2
|
+
import { useFieldValidation, type RuleOptions } from '../rules/useFieldValidation'
|
|
3
|
+
|
|
4
|
+
export type ValidationRule = {
|
|
5
|
+
type: string
|
|
6
|
+
options: RuleOptions
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ValidationOptions {
|
|
10
|
+
showSuccessMessages?: boolean
|
|
11
|
+
fieldIdentifier?: string
|
|
12
|
+
customRules?: ValidationRule[]
|
|
13
|
+
warningRules?: ValidationRule[]
|
|
14
|
+
successRules?: ValidationRule[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ValidationState {
|
|
18
|
+
errors: string[]
|
|
19
|
+
warnings: string[]
|
|
20
|
+
successes: string[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ValidationResult {
|
|
24
|
+
hasError: boolean
|
|
25
|
+
hasWarning: boolean
|
|
26
|
+
hasSuccess: boolean
|
|
27
|
+
state: ValidationState
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Composable pour gérer la validation des champs de formulaire
|
|
32
|
+
* @param options Options de configuration de la validation
|
|
33
|
+
* @returns Un objet contenant les états et méthodes de validation
|
|
34
|
+
*/
|
|
35
|
+
export function useValidation(options: ValidationOptions = { showSuccessMessages: true }) {
|
|
36
|
+
const errors = ref<string[]>([])
|
|
37
|
+
const warnings = ref<string[]>([])
|
|
38
|
+
const successes = ref<string[]>([])
|
|
39
|
+
|
|
40
|
+
const { generateRules } = useFieldValidation()
|
|
41
|
+
|
|
42
|
+
const hasError = computed(() => errors.value.length > 0)
|
|
43
|
+
const hasWarning = computed(() => warnings.value.length > 0)
|
|
44
|
+
const hasSuccess = computed(() =>
|
|
45
|
+
successes.value.length > 0 && !hasError.value && !hasWarning.value,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const clearValidation = () => {
|
|
49
|
+
errors.value = []
|
|
50
|
+
warnings.value = []
|
|
51
|
+
successes.value = []
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const validateField = (
|
|
55
|
+
value: unknown,
|
|
56
|
+
rules: ValidationRule[] = [],
|
|
57
|
+
warningRules: ValidationRule[] = [],
|
|
58
|
+
successRules: ValidationRule[] = [],
|
|
59
|
+
): ValidationResult => {
|
|
60
|
+
clearValidation()
|
|
61
|
+
|
|
62
|
+
// Validation des règles normales
|
|
63
|
+
const normalRules = rules.map(rule => ({
|
|
64
|
+
type: rule.type,
|
|
65
|
+
options: {
|
|
66
|
+
...rule.options,
|
|
67
|
+
fieldIdentifier: options.fieldIdentifier || rule.options.fieldIdentifier,
|
|
68
|
+
},
|
|
69
|
+
}))
|
|
70
|
+
|
|
71
|
+
const validationRules = generateRules(normalRules)
|
|
72
|
+
let hasValidationError = false
|
|
73
|
+
validationRules.forEach((validationRule) => {
|
|
74
|
+
const result = validationRule(value)
|
|
75
|
+
if (result.error) {
|
|
76
|
+
errors.value.push(result.error)
|
|
77
|
+
hasValidationError = true
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// Si pas d'erreur, ajouter le message de succès ou un message par défaut
|
|
82
|
+
if (!hasValidationError && value && options.showSuccessMessages !== false) {
|
|
83
|
+
const customSuccessMessage = rules.find(rule => rule.options.successMessage)?.options.successMessage
|
|
84
|
+
if (customSuccessMessage) {
|
|
85
|
+
successes.value.push(customSuccessMessage)
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const defaultMessage = options.fieldIdentifier ? `Le champ ${options.fieldIdentifier} est valide.` : 'Champ valide'
|
|
89
|
+
successes.value.push(defaultMessage)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Validation des règles d'avertissement
|
|
94
|
+
if (!hasValidationError) {
|
|
95
|
+
const warningValidationRules = generateRules(
|
|
96
|
+
warningRules.map(rule => ({
|
|
97
|
+
type: rule.type,
|
|
98
|
+
options: {
|
|
99
|
+
...rule.options,
|
|
100
|
+
isWarning: true,
|
|
101
|
+
fieldIdentifier: options.fieldIdentifier || rule.options.fieldIdentifier,
|
|
102
|
+
},
|
|
103
|
+
})),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
warningValidationRules.forEach((validationRule) => {
|
|
107
|
+
const result = validationRule(value)
|
|
108
|
+
if (result.warning) {
|
|
109
|
+
warnings.value.push(result.warning)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Validation des règles de succès
|
|
115
|
+
if (!hasValidationError && !hasWarning.value) {
|
|
116
|
+
const successValidationRules = generateRules(
|
|
117
|
+
successRules.map(rule => ({
|
|
118
|
+
type: rule.type,
|
|
119
|
+
options: {
|
|
120
|
+
...rule.options,
|
|
121
|
+
isSuccess: true,
|
|
122
|
+
fieldIdentifier: options.fieldIdentifier || rule.options.fieldIdentifier,
|
|
123
|
+
},
|
|
124
|
+
})),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
successValidationRules.forEach((validationRule) => {
|
|
128
|
+
const result = validationRule(value)
|
|
129
|
+
if (result.success && options.showSuccessMessages !== false) {
|
|
130
|
+
successes.value.push(result.success)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
hasError: hasError.value,
|
|
137
|
+
hasWarning: hasWarning.value,
|
|
138
|
+
hasSuccess: hasSuccess.value,
|
|
139
|
+
state: {
|
|
140
|
+
errors: errors.value,
|
|
141
|
+
warnings: warnings.value,
|
|
142
|
+
successes: successes.value,
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const validateOnSubmit = async (): Promise<boolean> => {
|
|
148
|
+
return !hasError.value
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
// États
|
|
153
|
+
errors,
|
|
154
|
+
warnings,
|
|
155
|
+
successes,
|
|
156
|
+
hasError,
|
|
157
|
+
hasWarning,
|
|
158
|
+
hasSuccess,
|
|
159
|
+
|
|
160
|
+
// Méthodes
|
|
161
|
+
validateField,
|
|
162
|
+
validateOnSubmit,
|
|
163
|
+
clearValidation,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -4,6 +4,8 @@ import { cnamColorsTokens } from './tokens/cnam/cnamColors'
|
|
|
4
4
|
import { cnamLightTheme } from './tokens/cnam/cnamLightTheme'
|
|
5
5
|
import { cnamDarkTheme } from './tokens/cnam/cnamDarkTheme'
|
|
6
6
|
import { paColorsTokens } from './tokens/pa/paColors'
|
|
7
|
+
import { paSemanticTokens } from './tokens/pa/paSemantic'
|
|
8
|
+
import { paContextualTokens } from './tokens/pa/paContextual'
|
|
7
9
|
import { paLightTheme } from './tokens/pa/paLightTheme'
|
|
8
10
|
import { paDarkTheme } from './tokens/pa/paDarkTheme'
|
|
9
11
|
|
|
@@ -14,6 +16,8 @@ export {
|
|
|
14
16
|
cnamLightTheme,
|
|
15
17
|
cnamDarkTheme,
|
|
16
18
|
paColorsTokens,
|
|
19
|
+
paSemanticTokens,
|
|
20
|
+
paContextualTokens,
|
|
17
21
|
paLightTheme,
|
|
18
22
|
paDarkTheme,
|
|
19
23
|
}
|
|
@@ -4,7 +4,7 @@ import { css } from '@emotion/css';
|
|
|
4
4
|
|
|
5
5
|
<Meta of={AccueilStories} />
|
|
6
6
|
|
|
7
|
-
<div
|
|
7
|
+
<div className={css`position: relative; padding: 4rem; margin: -4rem -4rem 1rem !important;`}>
|
|
8
8
|
<Story of={AccueilStories.Header} />
|
|
9
9
|
</div>
|
|
10
10
|
|
|
@@ -4,44 +4,18 @@ import {Meta, Source} from '@storybook/addon-docs/blocks';
|
|
|
4
4
|
|
|
5
5
|
# Thème Portail Agent
|
|
6
6
|
|
|
7
|
-
Pour des raisons techniques, la documentation ne permet pas encore l'affichage des composants aux couleurs du Portail Agent.<br/>
|
|
8
|
-
Cependant, il est possible de changer le thème du Design System pour qu'il corresponde aux couleurs du PA.
|
|
9
|
-
#
|
|
10
|
-
|
|
11
7
|
## Étapes pour changer le thème du Design System aux couleurs Portail Agent
|
|
12
8
|
|
|
13
9
|
### 1. Modification du fichier nuxt.config.ts
|
|
14
10
|
|
|
15
11
|
1. Ouvrez le fichier nuxt.config.ts dans votre éditeur de code.
|
|
16
|
-
2. Remplacer
|
|
17
|
-
|
|
18
|
-
<Source dark code={`
|
|
19
|
-
import {paLightTheme} from '@cnamts/synapse/designTokens/tokens/pa/paLightTheme'
|
|
20
|
-
import {paDarkTheme} from '@cnamts/synapse/designTokens/tokens/pa/paDarkTheme'
|
|
21
|
-
`}
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
3. Localisez la configuration de base de Vuetify (ligne 31 dans le fichier `nuxt.config.ts`).
|
|
25
|
-
4. Mettez à jour le thème en configurant les couleurs selon la charte PA si nécessaire :
|
|
12
|
+
2. Remplacer la valeur du thème par défaut`defaultTheme` par le thème PA : `pa`.
|
|
26
13
|
|
|
27
14
|
<Source dark code={`
|
|
28
15
|
theme: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
colors: {
|
|
33
|
-
...paLightTheme,
|
|
34
|
-
// ...customLightTheme
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
dark: {
|
|
38
|
-
colors: {
|
|
39
|
-
...paDarkTheme,
|
|
40
|
-
//...customDarkTheme,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
16
|
+
defaultTheme: 'pa',
|
|
17
|
+
...
|
|
18
|
+
}
|
|
45
19
|
`}
|
|
46
20
|
/>
|
|
47
21
|
|