@cnamts/synapse 0.0.3-alpha → 0.0.4-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 +712 -27
- package/dist/design-system-v3.js +2715 -1485
- package/dist/design-system-v3.umd.cjs +10 -1
- package/dist/style.css +1 -1
- package/package.json +5 -2
- package/src/components/Alert/Alert.mdx +1 -1
- package/src/components/Alert/Alert.stories.ts +91 -1
- package/src/components/BackBtn/BackBtn.mdx +1 -1
- package/src/components/BackBtn/BackBtn.stories.ts +84 -1
- package/src/components/BackToTopBtn/BackToTopBtn.mdx +3 -3
- package/src/components/BackToTopBtn/BackToTopBtn.stories.ts +172 -11
- package/src/components/CollapsibleList/CollapsibleList.mdx +2 -2
- package/src/components/CollapsibleList/CollapsibleList.stories.ts +37 -1
- package/src/components/CopyBtn/CopyBtn.mdx +1 -1
- package/src/components/CopyBtn/CopyBtn.stories.ts +120 -1
- package/src/components/CopyBtn/CopyBtn.vue +1 -1
- package/src/components/Customs/CustomInputSelect/CustomInputSelect.mdx +6 -8
- package/src/components/Customs/CustomInputSelect/CustomInputSelect.stories.ts +270 -4
- package/src/components/Customs/CustomInputSelect/CustomInputSelect.vue +80 -53
- package/src/components/Customs/CustomInputSelect/config.ts +10 -0
- package/src/components/Customs/CustomSelect/CustomSelect.mdx +3 -3
- package/src/components/Customs/CustomSelect/CustomSelect.stories.ts +158 -2
- package/src/components/Customs/CustomSelect/CustomSelect.vue +25 -6
- package/src/components/Customs/CustomTextField/CustomTextField.mdx +44 -0
- package/src/components/Customs/CustomTextField/CustomTextField.stories.ts +403 -0
- package/src/components/Customs/CustomTextField/CustomTextField.vue +110 -0
- package/src/components/Customs/CustomTextField/tests/CustomTextField.spec.ts +93 -0
- package/src/components/Customs/CustomTextField/tests/__snapshots__/CustomTextField.spec.ts.snap +59 -0
- package/src/components/Customs/CustomTextField/types.d.ts +3 -0
- package/src/components/DataList/DataList.mdx +77 -0
- package/src/components/DataList/DataList.stories.ts +960 -0
- package/src/components/DataList/DataList.vue +140 -0
- package/src/components/DataList/DataListLoading/DataListLoading.vue +56 -0
- package/src/components/DataList/DataListLoading/tests/DataListLoading.spec.ts +23 -0
- package/src/components/DataList/locales.ts +3 -0
- package/src/components/DataList/tests/DataList.spec.ts +194 -0
- package/src/components/DataList/types.d.ts +23 -0
- package/src/components/DataListGroup/DataListGroup.mdx +77 -0
- package/src/components/DataListGroup/DataListGroup.stories.ts +987 -0
- package/src/components/DataListGroup/DataListGroup.vue +59 -0
- package/src/components/DataListGroup/tests/DataListGroup.spec.ts +54 -0
- package/src/components/DataListGroup/tests/data/dataListGroupItems.ts +41 -0
- package/src/components/DataListGroup/types.d.ts +15 -0
- package/src/components/DataListItem/DataListItem.vue +135 -0
- package/src/components/DataListItem/config.ts +17 -0
- package/src/components/DataListItem/locales.ts +3 -0
- package/src/components/DataListItem/tests/DataListItem.spec.ts +156 -0
- package/src/components/DataListItem/types.d.ts +23 -0
- package/src/components/DownloadBtn/Accessibilite.mdx +14 -0
- package/src/components/DownloadBtn/Accessibilite.stories.ts +166 -0
- package/src/components/DownloadBtn/AccessibiliteItems.ts +129 -0
- package/src/components/DownloadBtn/DownloadBtn.mdx +5 -6
- package/src/components/DownloadBtn/DownloadBtn.stories.ts +207 -2
- package/src/components/DownloadBtn/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/FooterBar/FooterBar.mdx +2 -2
- package/src/components/FooterBar/FooterBar.stories.ts +1 -1
- package/src/components/FranceConnectBtn/FranceConnectBtn.mdx +1 -1
- package/src/components/FranceConnectBtn/FranceConnectBtn.stories.ts +58 -1
- package/src/components/HeaderBar/HeaderBar.mdx +164 -45
- package/src/components/HeaderBar/HeaderBar.stories.ts +559 -15
- package/src/components/HeaderBar/HeaderBar.vue +60 -22
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.mdx +433 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.stories.ts +1089 -0
- package/src/components/HeaderBar/{HeaderComplexMenu/HeaderComplexMenu.vue → HeaderBurgerMenu/HeaderBurgerMenu.vue} +74 -45
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.mdx +38 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.stories.ts +89 -0
- package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderMenuItem/tests/__snapshots__/HeaderMenuItem.spec.ts.snap +1 -1
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.mdx +17 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.stories.ts +121 -0
- package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderMenuSection/HeaderMenuSection.vue +2 -2
- package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderMenuSection/tests/HeaderMenuSection.spec.ts +1 -3
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.mdx +43 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.stories.ts +261 -0
- package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderSubMenu/HeaderSubMenu.vue +17 -3
- package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderSubMenu/tests/HeaderSubMenu.spec.ts +1 -1
- package/src/components/HeaderBar/HeaderBurgerMenu/tests/HeaderBurgerMenu.spec.ts +180 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/tests/__snapshots__/HeaderBurgerMenu.spec.ts.snap +13 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/tests/__snapshots__/HeaderComplexMenu.spec.ts.snap +13 -0
- package/src/components/HeaderBar/HeaderLogo/HeaderLogo.vue +62 -25
- package/src/components/HeaderBar/HeaderLogo/tests/HeaderLogo.spec.ts +49 -1
- package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +19 -23
- package/src/components/HeaderBar/HeaderMenuBtn/tests/HeaderMenuBtn.spec.ts +70 -0
- package/src/components/HeaderBar/Usages.mdx +85 -0
- package/src/components/HeaderBar/consts.scss +0 -1
- package/src/components/HeaderBar/tests/HeaderBar.spec.ts +8 -2
- package/src/components/HeaderBar/tests/__snapshots__/HeaderBar.spec.ts.snap +5 -10
- package/src/components/HeaderLoading/HeaderLoading.mdx +28 -0
- package/src/components/HeaderLoading/HeaderLoading.stories.ts +62 -0
- package/src/components/HeaderLoading/HeaderLoading.vue +45 -0
- package/src/components/HeaderLoading/tests/HeaderLoading.spec.ts +22 -0
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.mdx +128 -0
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.stories.ts +784 -0
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.vue +194 -0
- package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +74 -0
- package/src/components/HeaderNavigationBar/HorizontalNavbar/config.ts +18 -0
- package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.spec.ts +127 -0
- package/src/components/HeaderNavigationBar/types.ts +7 -0
- package/src/components/HeaderToolbar/HeaderToolbar.mdx +31 -0
- package/src/components/HeaderToolbar/HeaderToolbar.stories.ts +343 -0
- package/src/components/HeaderToolbar/HeaderToolbar.vue +487 -0
- package/src/components/HeaderToolbar/tests/HeaderToolbar.spec.ts +196 -0
- package/src/components/HeaderToolbar/types.d.ts +20 -0
- package/src/components/LangBtn/LangBtn.mdx +1 -1
- package/src/components/LangBtn/LangBtn.stories.ts +125 -8
- package/src/components/Logo/Logo.mdx +2 -2
- package/src/components/Logo/Logo.stories.ts +147 -1
- package/src/components/LogoBrandSection/LogoBrandSection.mdx +14 -0
- package/src/components/LogoBrandSection/LogoBrandSection.stories.ts +158 -0
- package/src/components/LogoBrandSection/LogoBrandSection.vue +312 -0
- package/src/components/LogoBrandSection/assets/ameli-pro.svg +1 -0
- package/src/components/LogoBrandSection/assets/ameli.svg +1 -0
- package/src/components/LogoBrandSection/assets/cnam.svg +1 -0
- package/src/components/LogoBrandSection/assets/compte-ameli.svg +1 -0
- package/src/components/LogoBrandSection/dividerDimensionsMapping.ts +14 -0
- package/src/components/LogoBrandSection/locales.ts +14 -0
- package/src/components/LogoBrandSection/secondaryLogoMapping.ts +24 -0
- package/src/components/LogoBrandSection/tests/LogoBrandSection.spec.ts +365 -0
- package/src/components/LogoBrandSection/tests/__snapshots__/LogoBrandSection.spec.ts.snap +14 -0
- package/src/components/LogoBrandSection/types.ts +8 -0
- package/src/components/NotificationBar/NotificationBar.mdx +6 -6
- package/src/components/NotificationBar/NotificationBar.stories.ts +1 -1
- package/src/components/NotificationBar/NotificationBar.vue +2 -2
- package/src/components/NotificationBar/tests/NotificationBar.spec.ts +1 -1
- package/src/components/PageContainer/PageContainer.mdx +1 -1
- package/src/components/PageContainer/PageContainer.stories.ts +86 -1
- package/src/components/PhoneField/PhoneField.mdx +49 -0
- package/src/components/PhoneField/PhoneField.stories.ts +869 -0
- package/src/components/PhoneField/PhoneField.vue +230 -0
- package/src/components/PhoneField/indicatifs.ts +104 -0
- package/src/components/PhoneField/locales.ts +4 -0
- package/src/components/PhoneField/tests/PhoneField.spec.ts +179 -0
- package/src/components/SkipLink/SkipLink.stories.ts +50 -1
- package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +28 -1
- package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +37 -1
- package/src/components/SubHeader/SubHeader.mdx +31 -0
- package/src/components/SubHeader/SubHeader.stories.ts +1032 -0
- package/src/components/SubHeader/SubHeader.vue +185 -0
- package/src/components/SubHeader/config.ts +12 -0
- package/src/components/SubHeader/locales.ts +3 -0
- package/src/components/SubHeader/tests/SubHeader.spec.ts +144 -0
- package/src/components/index.ts +24 -7
- package/src/composables/widthable/index.ts +29 -0
- package/src/composables/widthable/tests/widthable.spec.ts +52 -0
- package/src/designTokens/tokens/cnam/cnamLightTheme.ts +2 -2
- package/src/main.ts +1 -0
- package/src/modules.d.ts +4 -0
- package/src/services/index.ts +1 -0
- package/src/stories/Demarrer/Accueil.mdx +10 -0
- package/src/stories/Demarrer/Accueil.stories.ts +76 -0
- package/src/stories/Demarrer/PolitiqueDeConfidentialite.mdx +9 -0
- package/src/stories/Demarrer/PolitiqueDeConfidentialite.stories.ts +20 -0
- package/src/stories/Fondamentaux/Accessibilite/Accessibilite.mdx +1 -2
- package/src/stories/Fondamentaux/Accessibilite/Accessibilite.stories.ts +1 -1
- package/src/stories/Fondamentaux/EcoConception/Econception.stories.ts +1 -1
- package/src/stories/GuideDuDev/moduleDeNotification.mdx +52 -48
- package/src/stories/GuideDuDev/vuetifyOptions.mdx +31 -28
- package/src/stories/Guidelines/CustomisationEtThemes.mdx +1 -1
- package/src/utils/functions/throttleDisplayFn/tests/throttleDisplayFn.spec.ts +47 -0
- package/src/utils/functions/throttleDisplayFn/throttleDisplayFn.ts +26 -0
- package/src/utils/rules/exactLength/index.ts +33 -0
- package/src/utils/rules/exactLength/locales.ts +6 -0
- package/src/utils/rules/required/index.ts +25 -0
- package/src/utils/rules/required/locales.ts +5 -0
- package/src/utils/rules/required/ruleMessageHelper.ts +14 -0
- package/src/utils/rules/required/tests/index.spec.ts +47 -0
- package/src/utils/rules/required/tests/rulesMessageHelper.spec.ts +22 -0
- package/src/utils/rules/types.d.ts +15 -0
- package/src/components/Beta/beta.mdx +0 -5
- package/src/components/Deprecated/deprecated.mdx +0 -5
- package/src/components/HeaderBar/HeaderComplexMenu/HeaderComplexMenu.stories.ts +0 -272
- package/src/components/HeaderBar/HeaderComplexMenu/HeaderMenuItem/HeaderMenuItem.stories.ts +0 -49
- package/src/components/HeaderBar/HeaderComplexMenu/HeaderMenuSection/HeaderMenuSection.stories.ts +0 -56
- package/src/components/HeaderBar/HeaderComplexMenu/HeaderSubMenu/HeaderSubMenu.stories.ts +0 -137
- package/src/components/HeaderBar/HeaderComplexMenu/tests/HeaderComplexMenu.spec.ts +0 -129
- package/src/components/HeaderBar/HeaderComplexMenu/tests/__snapshots__/HeaderComplexMenu.spec.ts.snap +0 -18
- package/src/stories/Home/Accueil.mdx +0 -7
- package/src/stories/Home/PolitiqueDeConfidentialite.mdx +0 -4
- package/src/stories/Home/synapse.webp +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderMenuItem/HeaderMenuItem.vue +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/HeaderMenuItem/tests/HeaderMenuItem.spec.ts +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/conts.ts +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/locals.ts +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/tests/useHandleSubMenus.spec.ts +0 -0
- /package/src/components/HeaderBar/{HeaderComplexMenu → HeaderBurgerMenu}/useHandleSubMenus.ts +0 -0
- /package/src/components/Logo/{types.d.ts → types.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta } from '@storybook/addon-docs/blocks';
|
|
1
|
+
import { Meta, Source } from '@storybook/addon-docs/blocks';
|
|
2
2
|
|
|
3
3
|
<Meta title="Guide Du Dev/Services/useNotificationService" />
|
|
4
4
|
# useNotificationService
|
|
@@ -7,78 +7,82 @@ import { Meta } from '@storybook/addon-docs/blocks';
|
|
|
7
7
|
|
|
8
8
|
## Importation et utilisation
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
import { useNotificationService } from '
|
|
10
|
+
<Source dark code={`
|
|
11
|
+
import { useNotificationService } from '@cnamts/synapse/src/services/useNotificationService'
|
|
12
12
|
|
|
13
13
|
const { notificationQueue, addNotification, removeNotification, clearQueue } = useNotificationService()
|
|
14
|
-
|
|
14
|
+
`} />
|
|
15
15
|
|
|
16
|
-
Propriétés et
|
|
16
|
+
## Propriétés et méthodes :
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
<Source dark code={`
|
|
19
19
|
notificationQueue: Ref<Notification[]>
|
|
20
|
-
|
|
20
|
+
`} />
|
|
21
21
|
|
|
22
22
|
Une référence réactive à la file d'attente des notifications. Elle contient un tableau d'objets de type Notification.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
<Source dark code={`
|
|
25
|
+
addNotification(notification: Notification): void
|
|
26
|
+
`} />
|
|
25
27
|
|
|
26
28
|
Ajoute une nouvelle notification à la file d'attente, à condition qu'une notification avec le même id ne soit pas déjà présente.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
<Source dark code={`
|
|
29
31
|
addNotification({
|
|
30
32
|
id: 'notif-1',
|
|
31
33
|
message: 'Notification 1',
|
|
32
34
|
type: 'info',
|
|
33
35
|
duration: 5000
|
|
34
36
|
})
|
|
35
|
-
|
|
37
|
+
`} />
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
<Source dark code={`
|
|
38
40
|
removeNotification(id: string): void
|
|
39
|
-
|
|
41
|
+
`} />
|
|
40
42
|
Supprime une notification de la file d'attente en fonction de son id.
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
<Source dark code={`
|
|
43
45
|
removeNotification('notif-1')
|
|
44
|
-
|
|
46
|
+
`} />
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
<Source dark code={`
|
|
47
49
|
clearQueue(): void
|
|
48
|
-
|
|
50
|
+
`} />
|
|
49
51
|
|
|
50
52
|
Efface toutes les notifications de la file d'attente.
|
|
51
53
|
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
<Source dark code={`
|
|
54
56
|
clearQueue()
|
|
55
|
-
|
|
57
|
+
`} />
|
|
56
58
|
|
|
57
|
-
Typage de Notification
|
|
59
|
+
## Typage de Notification
|
|
58
60
|
|
|
59
61
|
Le type Notification est défini comme suit :
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
<Source dark code={`
|
|
63
64
|
type Notification = {
|
|
64
65
|
id: string
|
|
65
66
|
message: string
|
|
66
67
|
type: 'success' | 'error' | 'info' | 'warning'
|
|
67
68
|
duration?: number
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
`} />
|
|
71
|
+
|
|
70
72
|
Propriétés de Notification
|
|
71
|
-
|
|
73
|
+
|
|
74
|
+
<Source dark code={`
|
|
72
75
|
id: string — Identifiant unique de la notification.
|
|
73
76
|
message: string — Le texte à afficher dans la notification.
|
|
74
77
|
type: 'success' | 'error' | 'info' | 'warning' — Le type de la notification, qui peut influencer son apparence.
|
|
75
78
|
duration?: number — Durée pendant laquelle la notification sera visible (en millisecondes).
|
|
76
|
-
|
|
77
|
-
Exemples d'utilisation
|
|
78
|
-
Ajouter une notification
|
|
79
|
+
`} />
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
## Exemples d'utilisation
|
|
81
82
|
|
|
83
|
+
Ajouter une notification
|
|
84
|
+
|
|
85
|
+
<Source dark code={`
|
|
82
86
|
const { addNotification } = useNotificationService()
|
|
83
87
|
|
|
84
88
|
addNotification({
|
|
@@ -87,39 +91,40 @@ addNotification({
|
|
|
87
91
|
type: 'success',
|
|
88
92
|
duration: 3000
|
|
89
93
|
})
|
|
90
|
-
|
|
94
|
+
`} />
|
|
95
|
+
|
|
91
96
|
Supprimer une notification
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
<Source dark code={`
|
|
94
99
|
const { removeNotification } = useNotificationService()
|
|
95
100
|
|
|
96
101
|
removeNotification('notif-2')
|
|
97
|
-
|
|
98
|
-
Effacer la file d'attente de notifications
|
|
102
|
+
`} />
|
|
99
103
|
|
|
100
|
-
|
|
104
|
+
Effacer la file d'attente de notifications
|
|
101
105
|
|
|
106
|
+
<Source dark code={`
|
|
102
107
|
const { clearQueue } = useNotificationService()
|
|
103
108
|
|
|
104
109
|
clearQueue()
|
|
105
|
-
|
|
110
|
+
`} />
|
|
106
111
|
|
|
107
112
|
Accéder à la file d'attente
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
<Source dark code={`
|
|
110
115
|
const { notificationQueue } = useNotificationService()
|
|
111
116
|
|
|
112
117
|
console.log(notificationQueue.value) // Affiche toutes les notifications présentes dans la file d'attente
|
|
113
|
-
|
|
118
|
+
`} />
|
|
119
|
+
|
|
114
120
|
Utilisation dans un composant Vue
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
<script setup lang="ts">
|
|
122
|
+
<Source dark code={`
|
|
118
123
|
<script setup lang="ts">
|
|
119
124
|
import { VBtn } from 'vuetify/components'
|
|
120
|
-
import NotificationBar from '
|
|
121
|
-
import { useNotificationService } from '
|
|
122
|
-
import type { Notification } from '
|
|
125
|
+
import NotificationBar from '@cnamts/synapse'
|
|
126
|
+
import { useNotificationService } from '@cnamts/synapse/src/services/NotificationService'
|
|
127
|
+
import type { Notification } from '@cnamts/synapse/src/components/NotificationBar/types'
|
|
123
128
|
|
|
124
129
|
const { addNotification } = useNotificationService()
|
|
125
130
|
|
|
@@ -171,12 +176,11 @@ Utilisation dans un composant Vue
|
|
|
171
176
|
</template>
|
|
172
177
|
|
|
173
178
|
<style scoped>
|
|
174
|
-
.button-group {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
179
|
+
.button-group {
|
|
180
|
+
display: flex;
|
|
181
|
+
flex-direction: column;
|
|
182
|
+
gap: 16px;
|
|
183
|
+
margin-top: 20px;
|
|
184
|
+
}
|
|
180
185
|
</style>
|
|
181
|
-
|
|
182
|
-
```
|
|
186
|
+
`} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta } from '@storybook/addon-docs/blocks';
|
|
1
|
+
import { Meta, Source } from '@storybook/addon-docs/blocks';
|
|
2
2
|
|
|
3
3
|
<Meta title="Guide Du Dev/VuetifyOptions" />
|
|
4
4
|
|
|
@@ -13,60 +13,63 @@ Utilisation de vuetifyOptions
|
|
|
13
13
|
Certains composants du design system acceptent une prop vuetifyOptions qui vous permet de personnaliser le comportement et le style du composant basé sur Vuetify.
|
|
14
14
|
Vous trouverez des exemples de configurations directement dans la documentation de chaque composant que nous proposons pour mieux comprendre comment les personnaliser.
|
|
15
15
|
|
|
16
|
-
Exemple d'utilisation dans un composant
|
|
16
|
+
## Exemple d'utilisation dans un composant Vuetify:
|
|
17
17
|
|
|
18
18
|
Prenons l'exemple d'un bouton (VBtn).
|
|
19
19
|
|
|
20
20
|
Voici un exemple d'utilisation du composant :
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
<Source dark code={`
|
|
24
23
|
<MyButton
|
|
25
|
-
:title="'Cliquez ici'"
|
|
26
|
-
:vuetifyOptions="{ btn: { color: 'secondary', icon: true } }"
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
:title="'Cliquez ici'"
|
|
25
|
+
:vuetifyOptions="{ btn: { color: 'secondary', icon: true } }"
|
|
26
|
+
/>
|
|
27
|
+
`} />
|
|
28
|
+
|
|
29
29
|
Dans cet exemple :
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
Vous pouvez passer un objet vuetifyOptions pour personnaliser les propriétés du composant Vuetify sous-jacent (ici, VBtn).
|
|
31
|
+
> Le texte du bouton est défini via la prop title.
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
> Vous pouvez passer un objet vuetifyOptions pour personnaliser les propriétés du composant Vuetify sous-jacent (ici, VBtn).
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
<b>Explication</b>
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
> Propriétés de Vuetify : Vous pouvez configurer n'importe quelle option reconnue par Vuetify. Par exemple, pour un bouton (VBtn), vous pourriez ajuster sa couleur, son icône, son style (outlined, elevation, etc.).
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
> Fusion des options : Le design system gère la fusion des options par défaut et celles que vous fournissez dans vuetifyOptions. Si vous ne définissez pas une option spécifique, la valeur par défaut sera utilisée.
|
|
40
|
+
|
|
41
|
+
<b>Exemple détaillé</b>
|
|
41
42
|
|
|
42
43
|
Voici un exemple plus complet :
|
|
43
|
-
```
|
|
44
|
-
vue
|
|
45
44
|
|
|
45
|
+
<Source dark code={`
|
|
46
46
|
<MyButton
|
|
47
|
-
:title="'Valider'"
|
|
48
|
-
:vuetifyOptions="{ btn: { color: 'primary', outlined: false, icon: true } }"
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
:title="'Valider'"
|
|
48
|
+
:vuetifyOptions="{ btn: { color: 'primary', outlined: false, icon: true } }"
|
|
49
|
+
/>
|
|
50
|
+
`} />
|
|
51
|
+
|
|
51
52
|
Dans cet exemple :
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
Il n'aura pas de contour (outlined: false).
|
|
55
|
-
Une icône sera affichée sur le bouton (icon: true).
|
|
54
|
+
> Le bouton sera bleu (color: 'primary').
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
> Il n'aura pas de contour (outlined: false).
|
|
57
|
+
|
|
58
|
+
> Une icône sera affichée sur le bouton (icon: true).
|
|
59
|
+
|
|
60
|
+
## Options par défaut
|
|
58
61
|
|
|
59
62
|
Chaque composant du design system dispose d'options par défaut qui lui assurent un style et un comportement cohérents. Cependant, si vous souhaitez personnaliser ces options, vous pouvez utiliser la prop vuetifyOptions pour adapter ces composants à vos besoins spécifiques sans compromettre la structure de base du design system.
|
|
60
63
|
Exemple de bouton par défaut
|
|
61
64
|
|
|
62
65
|
Sans fournir de vuetifyOptions, le bouton pourrait ressembler à ceci :
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
<Source dark code={`
|
|
66
68
|
<MyButton :title="'Par défaut'" />
|
|
67
|
-
|
|
69
|
+
`} />
|
|
70
|
+
|
|
68
71
|
Ce bouton utilisera les options par défaut définies dans le design system, telles que la couleur, le style de bordure ou les icônes.
|
|
69
72
|
|
|
70
|
-
Conclusion
|
|
73
|
+
## Conclusion
|
|
71
74
|
|
|
72
75
|
L'intégration des vuetifyOptions dans les composants de ce design system vous offre une grande flexibilité pour personnaliser les composants en fonction de vos besoins spécifiques. Grâce à ce mécanisme, vous pouvez ajuster des propriétés telles que la couleur, les icônes et d'autres configurations Vuetify tout en vous appuyant sur des valeurs par défaut bien définies. Vous n'avez pas à vous soucier de la gestion interne des options : il vous suffit de passer les options personnalisées via la prop vuetifyOptions, et le composant s'adaptera automatiquement.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import throttleDisplayFn from '../throttleDisplayFn'
|
|
3
|
+
|
|
4
|
+
describe('throttleDisplayFn', () => {
|
|
5
|
+
vi.stubGlobal('requestAnimationFrame', (fn: () => void) => fn())
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
vi.useFakeTimers()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
vi.restoreAllMocks()
|
|
13
|
+
vi.clearAllTimers()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should call the function immediately if delay has passed', () => {
|
|
17
|
+
const mockFn = vi.fn()
|
|
18
|
+
const delay = 100
|
|
19
|
+
const throttledFn = throttleDisplayFn(mockFn, delay)
|
|
20
|
+
|
|
21
|
+
throttledFn()
|
|
22
|
+
expect(mockFn).toHaveBeenCalledTimes(1)
|
|
23
|
+
|
|
24
|
+
vi.spyOn(performance, 'now').mockReturnValue(performance.now() + delay + 1)
|
|
25
|
+
throttledFn()
|
|
26
|
+
expect(mockFn).toHaveBeenCalledTimes(2)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should call the function after the delay if called multiple times within the delay', () => {
|
|
30
|
+
const mockFn = vi.fn()
|
|
31
|
+
const delay = 100
|
|
32
|
+
const throttledFn = throttleDisplayFn(mockFn, delay)
|
|
33
|
+
|
|
34
|
+
throttledFn()
|
|
35
|
+
expect(mockFn).toHaveBeenCalledTimes(1)
|
|
36
|
+
|
|
37
|
+
throttledFn()
|
|
38
|
+
throttledFn()
|
|
39
|
+
|
|
40
|
+
expect(mockFn).toHaveBeenCalledTimes(1)
|
|
41
|
+
|
|
42
|
+
// Advance timers to trigger the setTimeout
|
|
43
|
+
vi.advanceTimersByTime(delay)
|
|
44
|
+
|
|
45
|
+
expect(mockFn).toHaveBeenCalledTimes(2)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a throttled version of the provided function that will only be called once every `delay` milliseconds.
|
|
3
|
+
*/
|
|
4
|
+
export default function throttleDisplayFn<
|
|
5
|
+
F extends (...args: unknown[]) => void,
|
|
6
|
+
>(fn: F, delay: number) {
|
|
7
|
+
let timeout: number | null = null
|
|
8
|
+
let lastCalled = 0
|
|
9
|
+
|
|
10
|
+
return function (...args: Parameters<F>) {
|
|
11
|
+
if (timeout !== null) {
|
|
12
|
+
window.clearTimeout(timeout)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (performance.now() - lastCalled >= delay) {
|
|
16
|
+
window.requestAnimationFrame(() => fn(...args))
|
|
17
|
+
lastCalled = performance.now()
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
timeout = window.setTimeout(() => {
|
|
21
|
+
fn(...args)
|
|
22
|
+
lastCalled = performance.now()
|
|
23
|
+
}, delay)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ruleMessage } from '../required/ruleMessageHelper'
|
|
2
|
+
import type {
|
|
3
|
+
ValidationRule,
|
|
4
|
+
ValidationResult,
|
|
5
|
+
ErrorMessages,
|
|
6
|
+
Value,
|
|
7
|
+
} from '../types'
|
|
8
|
+
|
|
9
|
+
import { defaultErrorMessages } from './locales'
|
|
10
|
+
|
|
11
|
+
/** Check that the value does not exceeds the specified length */
|
|
12
|
+
export function exactLengthFn(
|
|
13
|
+
lengthValue: number,
|
|
14
|
+
ignoreSpaces = false,
|
|
15
|
+
errorMessages: ErrorMessages<number> = defaultErrorMessages,
|
|
16
|
+
): ValidationRule {
|
|
17
|
+
return (value: Value): ValidationResult => {
|
|
18
|
+
if (!value) {
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (ignoreSpaces) {
|
|
23
|
+
value = value.replace(/\s/g, '')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
value.length === lengthValue
|
|
28
|
+
|| ruleMessage(errorMessages, 'default', [lengthValue])
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const exactLength = exactLengthFn
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ruleMessage } from './ruleMessageHelper'
|
|
2
|
+
import type { ValidationRule, ValidationResult, ErrorMessages } from '../types'
|
|
3
|
+
|
|
4
|
+
import { defaultErrorMessages } from './locales'
|
|
5
|
+
|
|
6
|
+
export type Value = string | string[] | null
|
|
7
|
+
|
|
8
|
+
export function requiredFn(
|
|
9
|
+
errorMessages: ErrorMessages = defaultErrorMessages,
|
|
10
|
+
): ValidationRule<Value> {
|
|
11
|
+
return (value: Value): ValidationResult => {
|
|
12
|
+
let valid: boolean
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
valid = value.length !== 0
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
valid = Boolean(typeof value === 'string' ? value.trim() : value)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return valid || ruleMessage(errorMessages, 'default')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const required = requiredFn()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ErrorMessages, GenericFnOpt } from '../types'
|
|
2
|
+
|
|
3
|
+
/** Get the value of an error message */
|
|
4
|
+
export function ruleMessage<T>(
|
|
5
|
+
errorMessages: ErrorMessages<T>,
|
|
6
|
+
key: string,
|
|
7
|
+
args: T[] = [],
|
|
8
|
+
): string {
|
|
9
|
+
if (typeof errorMessages[key] === 'function') {
|
|
10
|
+
return (errorMessages[key] as GenericFnOpt<T>)(...args)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return errorMessages[key] as string
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { requiredFn } from '../index'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('requiredFn', () => {
|
|
5
|
+
it('returns true for non-empty string', () => {
|
|
6
|
+
const rule = requiredFn()
|
|
7
|
+
const result = rule('non-empty')
|
|
8
|
+
expect(result).toBe(true)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns false for empty string', () => {
|
|
12
|
+
const rule = requiredFn()
|
|
13
|
+
const result = rule('')
|
|
14
|
+
expect(result).toBe('Le champ est requis.')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('returns true for non-empty array', () => {
|
|
18
|
+
const rule = requiredFn()
|
|
19
|
+
const result = rule(['item'])
|
|
20
|
+
expect(result).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('returns false for empty array', () => {
|
|
24
|
+
const rule = requiredFn()
|
|
25
|
+
const result = rule([])
|
|
26
|
+
expect(result).toBe('Le champ est requis.')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('returns true for non-null value', () => {
|
|
30
|
+
const rule = requiredFn()
|
|
31
|
+
const result = rule('value')
|
|
32
|
+
expect(result).toBe(true)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('returns false for null value', () => {
|
|
36
|
+
const rule = requiredFn()
|
|
37
|
+
const result = rule(null)
|
|
38
|
+
expect(result).toBe('Le champ est requis.')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('returns custom error message for empty string', () => {
|
|
42
|
+
const customMessages = { default: 'Custom required message' }
|
|
43
|
+
const rule = requiredFn(customMessages)
|
|
44
|
+
const result = rule('')
|
|
45
|
+
expect(result).toBe('Custom required message')
|
|
46
|
+
})
|
|
47
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ruleMessage } from '../ruleMessageHelper'
|
|
2
|
+
import { describe, it, expect } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('ruleMessage', () => {
|
|
5
|
+
it('returns the correct message for a string error message', () => {
|
|
6
|
+
const errorMessages = { required: 'This field is required' }
|
|
7
|
+
const result = ruleMessage(errorMessages, 'required')
|
|
8
|
+
expect(result).toBe('This field is required')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns the correct message for a function error message', () => {
|
|
12
|
+
const errorMessages = { minLength: (min: number) => `Minimum length is ${min}` }
|
|
13
|
+
const result = ruleMessage(errorMessages, 'minLength', [5])
|
|
14
|
+
expect(result).toBe('Minimum length is 5')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('handles multiple arguments for a function error message', () => {
|
|
18
|
+
const errorMessages = { range: (min: number, max: number) => `Value must be between ${min} and ${max}` }
|
|
19
|
+
const result = ruleMessage(errorMessages, 'range', [1, 10])
|
|
20
|
+
expect(result).toBe('Value must be between 1 and 10')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Value = string | null
|
|
2
|
+
export type ValidationResult = string | boolean
|
|
3
|
+
export type ValidationRule<T = Value> = (value: T) => ValidationResult
|
|
4
|
+
|
|
5
|
+
export interface ValidationRules {
|
|
6
|
+
[key: string]: ValidationRule
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type GenericFnOpt<T> = (arg?: T) => string
|
|
10
|
+
export type GenericFn<T> = (arg: T) => string
|
|
11
|
+
|
|
12
|
+
export interface ErrorMessages<T = string> {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
14
|
+
[key: string]: GenericFn<T> | GenericFnOpt<T> | any
|
|
15
|
+
}
|