@cnamts/synapse 0.0.4-alpha → 0.0.5-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.d.ts +932 -224
- package/dist/design-system-v3.js +3374 -1502
- package/dist/design-system-v3.umd.cjs +6 -6
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/assets/tokens.scss +0 -1
- package/src/components/Alert/Accessibilite.mdx +14 -0
- package/src/components/Alert/Accessibilite.stories.ts +166 -0
- package/src/components/Alert/AccessibiliteItems.ts +152 -0
- package/src/components/Alert/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/BackBtn/Accessibilite.mdx +14 -0
- package/src/components/BackBtn/Accessibilite.stories.ts +166 -0
- package/src/components/BackBtn/AccessibiliteItems.ts +132 -0
- package/src/components/BackBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/BackToTopBtn/Accessibilite.mdx +14 -0
- package/src/components/BackToTopBtn/Accessibilite.stories.ts +166 -0
- package/src/components/BackToTopBtn/AccessibiliteItems.ts +82 -0
- package/src/components/BackToTopBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/CollapsibleList/Accessibilite.mdx +14 -0
- package/src/components/CollapsibleList/Accessibilite.stories.ts +166 -0
- package/src/components/CollapsibleList/AccessibiliteItems.ts +129 -0
- package/src/components/CollapsibleList/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/CopyBtn/Accessibilite.mdx +14 -0
- package/src/components/CopyBtn/Accessibilite.stories.ts +166 -0
- package/src/components/CopyBtn/AccessibiliteItems.ts +135 -0
- package/src/components/CopyBtn/config.ts +2 -0
- package/src/components/CopyBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +44 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.stories.ts +606 -0
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +246 -0
- package/src/components/Customs/SyBtnSelect/tests/SyBtnSelect.spec.ts +168 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +40 -0
- package/src/components/Customs/{CustomInputSelect/CustomInputSelect.stories.ts → SyInputSelect/SyInputSelect.stories.ts} +29 -29
- package/src/components/Customs/{CustomInputSelect/CustomInputSelect.vue → SyInputSelect/SyInputSelect.vue} +10 -2
- package/src/components/Customs/SyInputSelect/tests/SyInputSelect.spec.ts +140 -0
- package/src/components/Customs/{CustomSelect/CustomSelect.mdx → SySelect/SySelect.mdx} +8 -8
- package/src/components/Customs/{CustomSelect/CustomSelect.stories.ts → SySelect/SySelect.stories.ts} +25 -25
- package/src/components/Customs/{CustomSelect/CustomSelect.vue → SySelect/SySelect.vue} +9 -5
- package/src/components/Customs/{CustomInputSelect/tests/CustomInputSelect.spec.ts → SySelect/tests/SySelect.spec.ts} +48 -71
- package/src/components/Customs/SyTextField/SyTextField.mdx +44 -0
- package/src/components/Customs/{CustomTextField/CustomTextField.stories.ts → SyTextField/SyTextField.stories.ts} +34 -34
- package/src/components/Customs/{CustomTextField/tests/CustomTextField.spec.ts → SyTextField/tests/SyTextField.spec.ts} +3 -3
- package/src/components/Customs/{CustomTextField/tests/__snapshots__/CustomTextField.spec.ts.snap → SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap} +3 -5
- package/src/components/DialogBox/DialogBox.mdx +14 -0
- package/src/components/DialogBox/DialogBox.stories.ts +798 -0
- package/src/components/DialogBox/DialogBox.vue +181 -0
- package/src/components/DialogBox/config.ts +25 -0
- package/src/components/DialogBox/locales.ts +5 -0
- package/src/components/DialogBox/tests/DialogBox.spec.ts +329 -0
- package/src/components/DialogBox/tests/__snapshots__/DialogBox.spec.ts.snap +46 -0
- package/src/components/ErrorPage/ErrorPage.mdx +21 -0
- package/src/components/ErrorPage/ErrorPage.stories.ts +133 -0
- package/src/components/ErrorPage/ErrorPage.vue +93 -0
- package/src/components/ErrorPage/locales.ts +5 -0
- package/src/components/ErrorPage/tests/ErrorPage.spec.ts +40 -0
- package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +78 -0
- package/src/components/FooterBar/FooterBar.stories.ts +556 -8
- package/src/components/FooterBar/config.ts +2 -3
- package/src/components/FooterBar/tests/FooterBar.spec.ts +1 -1
- package/src/components/FooterBar/tests/FooterBarConfig.spec.ts +1 -1
- package/src/components/FooterBar/tests/__snapshots__/FooterBar.spec.ts.snap +2 -2
- package/src/components/FranceConnectBtn/Accessibilite.mdx +14 -0
- package/src/components/FranceConnectBtn/Accessibilite.stories.ts +194 -0
- package/src/components/FranceConnectBtn/AccessibiliteItems.ts +199 -0
- package/src/components/FranceConnectBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/HeaderBar/HeaderBar.stories.ts +60 -2
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.mdx +6 -6
- package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.spec.ts +1 -1
- package/src/components/HeaderToolbar/HeaderToolbar.vue +2 -2
- package/src/components/HeaderToolbar/tests/HeaderToolbar.spec.ts +36 -2
- package/src/components/LangBtn/Accessibilite.mdx +14 -0
- package/src/components/LangBtn/Accessibilite.stories.ts +166 -0
- package/src/components/LangBtn/AccessibiliteItems.ts +132 -0
- package/src/components/LangBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/LangBtn/tests/LangBtn.spec.ts +1 -1
- package/src/components/LangBtn/tests/__snapshots__/LangBtn.spec.ts.snap +1 -1
- package/src/components/MaintenancePage/MaintenancePage.mdx +11 -0
- package/src/components/MaintenancePage/MaintenancePage.stories.ts +41 -0
- package/src/components/MaintenancePage/MaintenancePage.vue +25 -0
- package/src/components/MaintenancePage/assets/maintenance.svg +1 -0
- package/src/components/MaintenancePage/index.ts +3 -0
- package/src/components/MaintenancePage/locales.ts +5 -0
- package/src/components/MaintenancePage/tests/MaintenancePage.spec.ts +12 -0
- package/src/components/MaintenancePage/tests/__snapshots__/MaintenancePage.spec.ts.snap +3 -0
- package/src/components/NotFoundPage/NotFoundPage.mdx +19 -0
- package/src/components/NotFoundPage/NotFoundPage.stories.ts +76 -0
- package/src/components/NotFoundPage/NotFoundPage.vue +52 -0
- package/src/components/NotFoundPage/assets/not-found.svg +1 -0
- package/src/components/NotFoundPage/locales.ts +6 -0
- package/src/components/NotFoundPage/tests/NotFoundPage.spec.ts +38 -0
- package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +76 -0
- package/src/components/NotificationBar/Accessibilite.mdx +14 -0
- package/src/components/NotificationBar/Accessibilite.stories.ts +166 -0
- package/src/components/NotificationBar/AccessibiliteItems.ts +174 -0
- package/src/components/NotificationBar/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/NotificationBar/options.ts +1 -0
- package/src/components/PageContainer/Accessibilite.mdx +14 -0
- package/src/components/PageContainer/Accessibilite.stories.ts +166 -0
- package/src/components/PageContainer/AccessibiliteItems.ts +52 -0
- package/src/components/PageContainer/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/PhoneField/PhoneField.vue +5 -5
- package/src/components/PhoneField/tests/PhoneField.spec.ts +3 -3
- package/src/components/SkipLink/Accessibilite.mdx +14 -0
- package/src/components/SkipLink/Accessibilite.stories.ts +167 -0
- package/src/components/SkipLink/AccessibiliteItems.ts +77 -0
- package/src/components/SkipLink/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +17 -13
- package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +2 -1
- package/src/components/SocialMediaLinks/tests/SocialMediaLinks.spec.ts +1 -1
- package/src/components/SocialMediaLinks/tests/__snapshots__/SocialMediaLinks.spec.ts.snap +2 -2
- package/src/components/SubHeader/SubHeader.vue +1 -1
- package/src/components/UserMenuBtn/UserMenuBtn.mdx +35 -0
- package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +438 -0
- package/src/components/UserMenuBtn/UserMenuBtn.vue +105 -0
- package/src/components/UserMenuBtn/config.ts +24 -0
- package/src/components/UserMenuBtn/tests/UserMenuBtn.spec.ts +125 -0
- package/src/components/index.ts +12 -3
- package/src/composables/index.ts +8 -0
- package/src/composables/rules/tests/useFieldValidation.spec.ts +82 -0
- package/src/composables/rules/useFieldValidation.ts +53 -0
- package/src/designTokens/index.ts +2 -0
- package/src/designTokens/tokens/cnam/cnamDarkTheme.ts +5 -0
- package/src/designTokens/tokens/cnam/cnamLightTheme.ts +1 -0
- package/src/main.ts +2 -0
- package/src/stories/Fondamentaux/Arrondis.mdx +24 -0
- package/src/stories/{Guidelines → Fondamentaux}/Colors.mdx +1 -1
- package/src/stories/Fondamentaux/Conteneurs.mdx +7 -0
- package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +7 -0
- package/src/stories/Fondamentaux/Elevations.mdx +14 -0
- package/src/stories/Fondamentaux/Espacements.mdx +29 -0
- package/src/stories/{Guidelines → Fondamentaux}/Introduction.mdx +1 -1
- package/src/stories/Fondamentaux/StylesTypographiques.mdx +33 -0
- package/src/stories/Fondamentaux/Typographie.mdx +58 -0
- package/src/stories/GuideDuDev/CommentUtiliserLesRules.mdx +132 -0
- package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.stories.ts +1 -1
- package/src/stories/{Fondamentaux → Guidelines}/EcoConception/Econception.stories.ts +2 -2
- package/src/components/Customs/CustomInputSelect/CustomInputSelect.mdx +0 -40
- package/src/components/Customs/CustomSelect/tests/CustomSelect.spec.ts +0 -236
- package/src/components/Customs/CustomTextField/CustomTextField.mdx +0 -44
- package/src/stories/Guidelines/CustomisationEtThemes.mdx +0 -3
- package/src/stories/Guidelines/Typo.mdx +0 -53
- /package/src/components/Customs/{CustomInputSelect → SyInputSelect}/config.ts +0 -0
- /package/src/components/Customs/{CustomTextField/CustomTextField.vue → SyTextField/SyTextField.vue} +0 -0
- /package/src/components/Customs/{CustomTextField → SyTextField}/types.d.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.mdx +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/AccessibiliteItems.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/ExpertiseLevelEnum.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/RGAALevelEnum.ts +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/EcoConception.mdx +0 -0
- /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/ecoDesignItems.ts +0 -0
package/src/components/index.ts
CHANGED
|
@@ -3,12 +3,16 @@ 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
|
-
export { default as
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
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'
|
|
9
10
|
export { default as DataList } from './DataList/DataList.vue'
|
|
10
11
|
export { default as DataListGroup } from './DataListGroup/DataListGroup.vue'
|
|
12
|
+
export { default as DataListItem } from './DataListItem/DataListItem.vue'
|
|
13
|
+
export { default as DialogBox } from './DialogBox/DialogBox.vue'
|
|
11
14
|
export { default as DownloadBtn } from './DownloadBtn/DownloadBtn.vue'
|
|
15
|
+
export { default as ErrorPage } from './ErrorPage/ErrorPage.vue'
|
|
12
16
|
export { default as FooterBar } from './FooterBar/FooterBar.vue'
|
|
13
17
|
export { default as FranceConnectBtn } from './FranceConnectBtn/FranceConnectBtn.vue'
|
|
14
18
|
export { default as HeaderBar } from './HeaderBar/HeaderBar.vue'
|
|
@@ -20,12 +24,17 @@ export { default as HeaderLogo } from './HeaderBar/HeaderLogo/HeaderLogo.vue'
|
|
|
20
24
|
export { default as HeaderMenuBtn } from './HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue'
|
|
21
25
|
export { default as HeaderLoading } from './HeaderLoading/HeaderLoading.vue'
|
|
22
26
|
export { default as HeaderNavigationBar } from './HeaderNavigationBar/HeaderNavigationBar.vue'
|
|
27
|
+
export { default as HeaderToolbar } from './HeaderToolbar/HeaderToolbar.vue'
|
|
23
28
|
export { default as LangBtn } from './LangBtn/LangBtn.vue'
|
|
24
29
|
export { default as Logo } from './Logo/Logo.vue'
|
|
25
30
|
export { default as LogoBrandSection } from './LogoBrandSection/LogoBrandSection.vue'
|
|
31
|
+
export { default as MaintenancePage } from './MaintenancePage/MaintenancePage.vue'
|
|
32
|
+
export { default as NotFoundPage } from './NotFoundPage/NotFoundPage.vue'
|
|
26
33
|
export { default as NotificationBar } from './NotificationBar/NotificationBar.vue'
|
|
27
34
|
export * from './NotificationBar/types'
|
|
28
35
|
export { default as PageContainer } from './PageContainer/PageContainer.vue'
|
|
36
|
+
export { default as PhoneField } from './PhoneField/PhoneField.vue'
|
|
29
37
|
export { default as SkipLink } from './SkipLink/SkipLink.vue'
|
|
30
38
|
export { default as SocialMediaLinks } from './SocialMediaLinks/SocialMediaLinks.vue'
|
|
31
39
|
export { default as SubHeader } from './SubHeader/SubHeader.vue'
|
|
40
|
+
export { default as UserMenuBtn } from './UserMenuBtn/UserMenuBtn.vue'
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useFieldValidation } from '../useFieldValidation'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('useFieldValidation', () => {
|
|
5
|
+
const { generateRules } = useFieldValidation()
|
|
6
|
+
|
|
7
|
+
describe('createRule', () => {
|
|
8
|
+
it('should validate required rule', () => {
|
|
9
|
+
const rules = generateRules([{ type: 'required', options: { fieldName: 'Nom' } }])
|
|
10
|
+
const requiredRule = rules[0]
|
|
11
|
+
|
|
12
|
+
expect(requiredRule('')).toBe('Vous devez renseigner Nom.')
|
|
13
|
+
expect(requiredRule('Test')).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should validate min rule', () => {
|
|
17
|
+
const rules = generateRules([{ type: 'min', options: { value: 5 } }])
|
|
18
|
+
const minRule = rules[0]
|
|
19
|
+
|
|
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
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should validate minLength rule', () => {
|
|
26
|
+
const rules = generateRules([{ type: 'minLength', options: { length: 3 } }])
|
|
27
|
+
const minLengthRule = rules[0]
|
|
28
|
+
|
|
29
|
+
expect(minLengthRule('ab')).toBe('Ce champ doit avoir au moins 3 caractères.')
|
|
30
|
+
expect(minLengthRule('abc')).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should validate max rule', () => {
|
|
34
|
+
const rules = generateRules([{ type: 'max', options: { value: 10 } }])
|
|
35
|
+
const maxRule = rules[0]
|
|
36
|
+
|
|
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
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should validate maxLength rule', () => {
|
|
43
|
+
const rules = generateRules([{ type: 'maxLength', options: { length: 5 } }])
|
|
44
|
+
const maxLengthRule = rules[0]
|
|
45
|
+
|
|
46
|
+
expect(maxLengthRule('abcdef')).toBe('Ce champ ne doit pas dépasser 5 caractères.')
|
|
47
|
+
expect(maxLengthRule('abc')).toBe(true)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should validate exactLength rule', () => {
|
|
51
|
+
const rules = generateRules([{ type: 'exactLength', options: { length: 4 } }])
|
|
52
|
+
const exactLengthRule = rules[0]
|
|
53
|
+
|
|
54
|
+
expect(exactLengthRule('abc')).toBe('Ce champ doit avoir exactement 4 caractères.')
|
|
55
|
+
expect(exactLengthRule('abcd')).toBe(true)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should validate email rule', () => {
|
|
59
|
+
const rules = generateRules([{ type: 'email' }])
|
|
60
|
+
const emailRule = rules[0]
|
|
61
|
+
|
|
62
|
+
expect(emailRule('invalid-email')).toBe('Veuillez entrer un email valide.')
|
|
63
|
+
expect(emailRule('test@example.com')).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should validate matchPattern rule', () => {
|
|
67
|
+
const rules = generateRules([{ type: 'matchPattern', options: { pattern: /^[a-z]+$/ } }])
|
|
68
|
+
const matchPatternRule = rules[0]
|
|
69
|
+
|
|
70
|
+
expect(matchPatternRule('123')).toBe('Format invalide.')
|
|
71
|
+
expect(matchPatternRule('abc')).toBe(true)
|
|
72
|
+
})
|
|
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]
|
|
77
|
+
|
|
78
|
+
expect(minLengthRule('a b')).toBe('Ce champ doit avoir au moins 3 caractères.')
|
|
79
|
+
expect(minLengthRule('ab c')).toBe(true)
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type RuleOptions = {
|
|
2
|
+
fieldName?: string
|
|
3
|
+
message?: string
|
|
4
|
+
length?: number
|
|
5
|
+
value?: number
|
|
6
|
+
pattern?: RegExp
|
|
7
|
+
ignoreSpace?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
11
|
+
type ValidationRule = (value: any) => string | boolean
|
|
12
|
+
|
|
13
|
+
export function useFieldValidation() {
|
|
14
|
+
const createRule = (type: string, options: RuleOptions = {}): ValidationRule => {
|
|
15
|
+
const getValueLength = (value: string) => {
|
|
16
|
+
return options.ignoreSpace ? value.replace(/\s/g, '').length : value.length
|
|
17
|
+
}
|
|
18
|
+
|
|
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.`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const generateRules = (fieldRules: Array<{ type: string, options?: RuleOptions }>) => {
|
|
49
|
+
return fieldRules.map(rule => createRule(rule.type, rule.options))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return { generateRules }
|
|
53
|
+
}
|
|
@@ -2,6 +2,7 @@ import { cnamSemanticTokens } from './tokens/cnam/cnamSemantic'
|
|
|
2
2
|
import { cnamContextualTokens } from './tokens/cnam/cnamContextual'
|
|
3
3
|
import { cnamColorsTokens } from './tokens/cnam/cnamColors'
|
|
4
4
|
import { cnamLightTheme } from './tokens/cnam/cnamLightTheme'
|
|
5
|
+
import { cnamDarkTheme } from './tokens/cnam/cnamDarkTheme'
|
|
5
6
|
import { bootstrapColorsTokens } from './tokens/bootstrap/bootstrapColors'
|
|
6
7
|
import { bootstrapLightTheme } from './tokens/bootstrap/bootstrapLightTheme'
|
|
7
8
|
|
|
@@ -10,6 +11,7 @@ export {
|
|
|
10
11
|
cnamSemanticTokens,
|
|
11
12
|
cnamContextualTokens,
|
|
12
13
|
cnamLightTheme,
|
|
14
|
+
cnamDarkTheme,
|
|
13
15
|
bootstrapColorsTokens,
|
|
14
16
|
bootstrapLightTheme,
|
|
15
17
|
}
|
|
@@ -7,6 +7,7 @@ export const cnamLightTheme = {
|
|
|
7
7
|
accent: cnamColorsTokens.cyan.base,
|
|
8
8
|
error: cnamColorsTokens.orange.darken20,
|
|
9
9
|
info: cnamColorsTokens.blue.base,
|
|
10
|
+
avatar: cnamColorsTokens.cyan.darken20,
|
|
10
11
|
success: cnamColorsTokens.turquoise.darken60,
|
|
11
12
|
warning: cnamColorsTokens.yellow.darken60,
|
|
12
13
|
risquePro: cnamColorsTokens.brick.base,
|
package/src/main.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Fondamentaux/Arrondis" />
|
|
4
|
+
|
|
5
|
+
# Arrondis
|
|
6
|
+
|
|
7
|
+
Les angles des éléments permettent de créer du contraste entre les formes et de suggérer l’utilisation des composants
|
|
8
|
+
|
|
9
|
+
Il existe 4 radius disponibles :
|
|
10
|
+
|
|
11
|
+
- <b>rounded-0 : 0px</b><br/>
|
|
12
|
+
Dès lors que l’on ne souhaite pas utiliser de radius
|
|
13
|
+
|
|
14
|
+
- <b>rounded : 4px</b><br/>
|
|
15
|
+
Ce radius peut être utilisé sur des éléments interactifs tels que les boutons, les inputs, les alerts,
|
|
16
|
+
|
|
17
|
+
- <b>rounded-lg : 8px</b><br/>
|
|
18
|
+
Ce radius peut être utilisé sur des blocs de structure (cards, tableaux...)
|
|
19
|
+
|
|
20
|
+
- <b>rounded-pill : 96px</b><br/>
|
|
21
|
+
Ce radius peut être utilisé sur des éléments (intéractifs ou non) présentant de la donnée, comme des tags, des filtres, des status...
|
|
22
|
+
|
|
23
|
+
<br />
|
|
24
|
+
<img alt="Radius" src={'/radius.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
@@ -2,7 +2,7 @@ import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs';
|
|
|
2
2
|
import { cnamLightTheme } from "@/designTokens/tokens/cnam/cnamLightTheme.ts";
|
|
3
3
|
import { cnamColorsTokens } from '@/designTokens/tokens/cnam/cnamColors.ts'
|
|
4
4
|
|
|
5
|
-
<Meta title="
|
|
5
|
+
<Meta title="Fondamentaux/Couleurs" />
|
|
6
6
|
|
|
7
7
|
# Couleurs
|
|
8
8
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Fondamentaux/Elévations" />
|
|
4
|
+
|
|
5
|
+
# Elévations
|
|
6
|
+
|
|
7
|
+
<b>Les plateformes de l’Assurance Maladie n’utilisent pas d’élévations à but esthétiques.</b><br/>
|
|
8
|
+
L’élévation est à utiliser pour représenter des interactions avec superposition, comme un élément fixe se positionnant au-dessus d’un élément scrollable, un bouton flottant...
|
|
9
|
+
|
|
10
|
+
<b>Le style d’élévation est issu de la librairie Vuetify.</b><br/>
|
|
11
|
+
Pour des raisons de cohérence et d’esthétique, des 24 élévations différentes, nous avons retenue la <b>02</b> qui sera la seule et unique utilisée sur les plateformes.
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
<img alt="Elevation" src={'/elevation.jpg'} style={{marginLeft: '-5px'}} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Fondamentaux/Espacements" />
|
|
4
|
+
|
|
5
|
+
# Espacements
|
|
6
|
+
|
|
7
|
+
Le design système de la CNAM est basé sur des multiples de 4 pour définir la taille des éléments, placer des espacements et disposer des composants.<br/>
|
|
8
|
+
Ce système d’espacement permet de garantir une homogénéité, cohérence et consistance des interfaces conçues. Cela dans le but d'améliorer l’UX et de faciliter la conception et le développement.
|
|
9
|
+
|
|
10
|
+
Chaque partie de l'interface utilisateur doit être intentionnellement conçue, y compris l'espace vide entre les éléments. Les espacements permettent de :
|
|
11
|
+
|
|
12
|
+
- <b>Créer des relations</b>
|
|
13
|
+
Utilisez des espacements faibles entre plusieurs composants pour signaler qu’ils sont liés, ou font partie d’un même groupe (exemple : champs de formulaire) ;
|
|
14
|
+
Utilisez des espacements importants pour mettre en évidence un élément indépendant du reste de la page (exemple : call to action).
|
|
15
|
+
|
|
16
|
+
- <b>Créer des hiérarchies</b>
|
|
17
|
+
Augmentez les espacements autour d’un composant clé de votre page permet d’améliorer sa visibilité.
|
|
18
|
+
|
|
19
|
+
## Les espacements verticaux
|
|
20
|
+
<br />
|
|
21
|
+
<img alt="Les espacements verticaux" src={'/espacements-verticaux.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
22
|
+
|
|
23
|
+
## Les espacements horizontaux
|
|
24
|
+
<br />
|
|
25
|
+
<img alt="Les espacements horizontaux" src={'/espacements-horizontaux.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
26
|
+
|
|
27
|
+
## Mise en situation
|
|
28
|
+
<br />
|
|
29
|
+
<img alt="Mise en situation" src={'/espacements-situation.jpg'} style={{ border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Fondamentaux/Styles typographiques" />
|
|
4
|
+
|
|
5
|
+
# Styles typographiques
|
|
6
|
+
|
|
7
|
+
## Styles de titres
|
|
8
|
+
|
|
9
|
+
Les titres sont utilisés pour créer une hiérarchie visuelle dans la page, et permettent de trouver facilement une information.
|
|
10
|
+
|
|
11
|
+
<img alt="Styles de titres" src={'/font-titres.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Styles de titres alternatifs
|
|
15
|
+
|
|
16
|
+
Pour donner une plus grande liberté éditoriale et graphique, sans nuire à la hiérarchie de l’information et au référencement nous vous proposons plusieurs niveaux de titres alternatifs (display). Vous pourrez les utiliser pour les mise en avant, les bannières, etc..
|
|
17
|
+
Les titres alternatifs peuvent être associés selon votre besoin à un h1, un h2, un h3 ou un h4.
|
|
18
|
+
|
|
19
|
+
<img alt="Styles de titres alternatifs" src={'/font-titres-alt.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Corps de texte
|
|
23
|
+
|
|
24
|
+
Les styles de texte sont là pour vous aider à concevoir vos interfaces efficacement et assurer l’homogénéité entre les différents sites.
|
|
25
|
+
|
|
26
|
+
<img alt="Corps de texte" src={'/font-corps.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Liens et libellés
|
|
30
|
+
|
|
31
|
+
<br />
|
|
32
|
+
|
|
33
|
+
<img alt="Liens et libellés" src={'/font-liens.jpg'} style={{ padding: '10px', border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Meta, Typeset } from '@storybook/addon-docs';
|
|
2
|
+
|
|
3
|
+
<Meta title="Fondamentaux/Typographie" />
|
|
4
|
+
|
|
5
|
+
export const typography = {
|
|
6
|
+
type: {
|
|
7
|
+
primary: 'Arial',
|
|
8
|
+
},
|
|
9
|
+
weight: {
|
|
10
|
+
regular: '400',
|
|
11
|
+
bold: '700',
|
|
12
|
+
extrabold: '800',
|
|
13
|
+
black: '900',
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
s1: 12,
|
|
17
|
+
s2: 14,
|
|
18
|
+
s3: 16,
|
|
19
|
+
m1: 18,
|
|
20
|
+
m2: 20,
|
|
21
|
+
m3: 24,
|
|
22
|
+
l1: 28,
|
|
23
|
+
l2: 30,
|
|
24
|
+
l3: 32,
|
|
25
|
+
l4:40,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const SampleText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
|
|
30
|
+
|
|
31
|
+
# Typographie
|
|
32
|
+
|
|
33
|
+
<img alt="Arial" src={'/font-arial.jpg'} style={{ border: '1px solid rgba(0, 0, 0, 0.05)', boxShadow: 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' }} />
|
|
34
|
+
|
|
35
|
+
**Weights:** 400(regular), 700(bold), 900(black)
|
|
36
|
+
|
|
37
|
+
<Typeset
|
|
38
|
+
fontSizes={[
|
|
39
|
+
Number(typography.size.s1),
|
|
40
|
+
Number(typography.size.s2),
|
|
41
|
+
Number(typography.size.s3),
|
|
42
|
+
Number(typography.size.m1),
|
|
43
|
+
Number(typography.size.m2),
|
|
44
|
+
Number(typography.size.m3),
|
|
45
|
+
Number(typography.size.l1),
|
|
46
|
+
Number(typography.size.l2),
|
|
47
|
+
Number(typography.size.l3),
|
|
48
|
+
Number(typography.size.l4),
|
|
49
|
+
]}
|
|
50
|
+
fontWeight={typography.weight.regular}
|
|
51
|
+
sampleText={SampleText}
|
|
52
|
+
fontFamily={typography.type.primary}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
**Interlignage:** 2 ratio de line-height :
|
|
56
|
+
|
|
57
|
+
- 130% quand le `font-size` est supérieur à 18px
|
|
58
|
+
- 150% quand le `font-size` est inférieur ou égal à 18px
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {Meta, Source} from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Guide Du Dev/Comment utiliser les rules"/>
|
|
4
|
+
|
|
5
|
+
# Comment utiliser les règles de validation
|
|
6
|
+
|
|
7
|
+
Ce guide décrit comment utiliser le composable `useFieldValidation` pour créer des règles de validation flexibles et personnalisées dans votre projet Vue.js.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
Le composable `useFieldValidation` vous permet de définir des règles de validation dynamiques pour différents champs dans vos formulaires. Ce composable est conçu pour être flexible, réutilisable et facilement intégrable avec des bibliothèques comme Vuetify.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Structure du composable
|
|
18
|
+
|
|
19
|
+
### Type `RuleOptions`
|
|
20
|
+
|
|
21
|
+
<Source dark code={`
|
|
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
|
|
29
|
+
};
|
|
30
|
+
`} />
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Exemple d'intégration
|
|
35
|
+
|
|
36
|
+
### Script Vue.js
|
|
37
|
+
|
|
38
|
+
<Source dark code={`
|
|
39
|
+
<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
|
+
]),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const validateField = (field: string) => {
|
|
66
|
+
return rules[field].every((rule) => rule(field));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleSubmit = () => {
|
|
70
|
+
if (validateField('firstName') && validateField('email') && validateField('age')) {
|
|
71
|
+
alert('Formulaire valide.');
|
|
72
|
+
} else {
|
|
73
|
+
alert('Merci de vérifier les champs.');
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
</script>
|
|
77
|
+
`} />
|
|
78
|
+
---
|
|
79
|
+
|
|
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
|
+
---
|
|
109
|
+
|
|
110
|
+
## Fonctionnalités supportées
|
|
111
|
+
|
|
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`)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Bonnes pratiques
|
|
123
|
+
|
|
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.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Conclusion
|
|
131
|
+
|
|
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.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { VExpansionPanels, VExpansionPanel } from 'vuetify/components'
|
|
2
2
|
import type { StoryObj } from '@storybook/vue3'
|
|
3
|
-
import { ecoDesignItems } from '@/stories/
|
|
3
|
+
import { ecoDesignItems } from '@/stories/Guidelines/EcoConception/ecoDesignItems'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: '
|
|
6
|
+
title: 'Guidelines/Éco-conception',
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const EcoPanel: StoryObj = {
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls, Story, Source } from '@storybook/blocks';
|
|
2
|
-
import * as CustomInputSelectStories from "./CustomInputSelect.stories.ts";
|
|
3
|
-
|
|
4
|
-
<Meta of={CustomInputSelectStories} />
|
|
5
|
-
|
|
6
|
-
# CustomInputSelect
|
|
7
|
-
|
|
8
|
-
Le composant `CustomInputSelect` est utilisé pour proposer une alternative au `v-select` de Vuetify qui ne respecte pas les règles RGAA.
|
|
9
|
-
|
|
10
|
-
<Canvas of={CustomInputSelectStories.Default} />
|
|
11
|
-
|
|
12
|
-
<Story of={CustomInputSelectStories.Info} />
|
|
13
|
-
|
|
14
|
-
# API
|
|
15
|
-
|
|
16
|
-
<Controls of={CustomInputSelectStories.Default} />
|
|
17
|
-
|
|
18
|
-
# Exemple d'utilisation
|
|
19
|
-
|
|
20
|
-
<Source dark code={`
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import CustomInputSelect from '@cnamts/synapse'
|
|
23
|
-
|
|
24
|
-
const items = [
|
|
25
|
-
{ text: 'Option 1', value: '1' },
|
|
26
|
-
{ text: 'Option 2', value: '2' },
|
|
27
|
-
],
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<template>
|
|
31
|
-
<main>
|
|
32
|
-
<div class="mt-12 ml-12">
|
|
33
|
-
<CustomInputSelect
|
|
34
|
-
v-model="value"
|
|
35
|
-
:items="items"
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
</main>
|
|
39
|
-
</template>
|
|
40
|
-
`} />
|