@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.
Files changed (150) hide show
  1. package/dist/design-system-v3.d.ts +932 -224
  2. package/dist/design-system-v3.js +3374 -1502
  3. package/dist/design-system-v3.umd.cjs +6 -6
  4. package/dist/style.css +1 -1
  5. package/package.json +2 -1
  6. package/src/assets/tokens.scss +0 -1
  7. package/src/components/Alert/Accessibilite.mdx +14 -0
  8. package/src/components/Alert/Accessibilite.stories.ts +166 -0
  9. package/src/components/Alert/AccessibiliteItems.ts +152 -0
  10. package/src/components/Alert/constants/ExpertiseLevelEnum.ts +4 -0
  11. package/src/components/BackBtn/Accessibilite.mdx +14 -0
  12. package/src/components/BackBtn/Accessibilite.stories.ts +166 -0
  13. package/src/components/BackBtn/AccessibiliteItems.ts +132 -0
  14. package/src/components/BackBtn/constants/ExpertiseLevelEnum.ts +4 -0
  15. package/src/components/BackToTopBtn/Accessibilite.mdx +14 -0
  16. package/src/components/BackToTopBtn/Accessibilite.stories.ts +166 -0
  17. package/src/components/BackToTopBtn/AccessibiliteItems.ts +82 -0
  18. package/src/components/BackToTopBtn/constants/ExpertiseLevelEnum.ts +4 -0
  19. package/src/components/CollapsibleList/Accessibilite.mdx +14 -0
  20. package/src/components/CollapsibleList/Accessibilite.stories.ts +166 -0
  21. package/src/components/CollapsibleList/AccessibiliteItems.ts +129 -0
  22. package/src/components/CollapsibleList/constants/ExpertiseLevelEnum.ts +4 -0
  23. package/src/components/CopyBtn/Accessibilite.mdx +14 -0
  24. package/src/components/CopyBtn/Accessibilite.stories.ts +166 -0
  25. package/src/components/CopyBtn/AccessibiliteItems.ts +135 -0
  26. package/src/components/CopyBtn/config.ts +2 -0
  27. package/src/components/CopyBtn/constants/ExpertiseLevelEnum.ts +4 -0
  28. package/src/components/Customs/SyBtnSelect/SyBtnSelect.mdx +44 -0
  29. package/src/components/Customs/SyBtnSelect/SyBtnSelect.stories.ts +606 -0
  30. package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +246 -0
  31. package/src/components/Customs/SyBtnSelect/tests/SyBtnSelect.spec.ts +168 -0
  32. package/src/components/Customs/SyInputSelect/SyInputSelect.mdx +40 -0
  33. package/src/components/Customs/{CustomInputSelect/CustomInputSelect.stories.ts → SyInputSelect/SyInputSelect.stories.ts} +29 -29
  34. package/src/components/Customs/{CustomInputSelect/CustomInputSelect.vue → SyInputSelect/SyInputSelect.vue} +10 -2
  35. package/src/components/Customs/SyInputSelect/tests/SyInputSelect.spec.ts +140 -0
  36. package/src/components/Customs/{CustomSelect/CustomSelect.mdx → SySelect/SySelect.mdx} +8 -8
  37. package/src/components/Customs/{CustomSelect/CustomSelect.stories.ts → SySelect/SySelect.stories.ts} +25 -25
  38. package/src/components/Customs/{CustomSelect/CustomSelect.vue → SySelect/SySelect.vue} +9 -5
  39. package/src/components/Customs/{CustomInputSelect/tests/CustomInputSelect.spec.ts → SySelect/tests/SySelect.spec.ts} +48 -71
  40. package/src/components/Customs/SyTextField/SyTextField.mdx +44 -0
  41. package/src/components/Customs/{CustomTextField/CustomTextField.stories.ts → SyTextField/SyTextField.stories.ts} +34 -34
  42. package/src/components/Customs/{CustomTextField/tests/CustomTextField.spec.ts → SyTextField/tests/SyTextField.spec.ts} +3 -3
  43. package/src/components/Customs/{CustomTextField/tests/__snapshots__/CustomTextField.spec.ts.snap → SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap} +3 -5
  44. package/src/components/DialogBox/DialogBox.mdx +14 -0
  45. package/src/components/DialogBox/DialogBox.stories.ts +798 -0
  46. package/src/components/DialogBox/DialogBox.vue +181 -0
  47. package/src/components/DialogBox/config.ts +25 -0
  48. package/src/components/DialogBox/locales.ts +5 -0
  49. package/src/components/DialogBox/tests/DialogBox.spec.ts +329 -0
  50. package/src/components/DialogBox/tests/__snapshots__/DialogBox.spec.ts.snap +46 -0
  51. package/src/components/ErrorPage/ErrorPage.mdx +21 -0
  52. package/src/components/ErrorPage/ErrorPage.stories.ts +133 -0
  53. package/src/components/ErrorPage/ErrorPage.vue +93 -0
  54. package/src/components/ErrorPage/locales.ts +5 -0
  55. package/src/components/ErrorPage/tests/ErrorPage.spec.ts +40 -0
  56. package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +78 -0
  57. package/src/components/FooterBar/FooterBar.stories.ts +556 -8
  58. package/src/components/FooterBar/config.ts +2 -3
  59. package/src/components/FooterBar/tests/FooterBar.spec.ts +1 -1
  60. package/src/components/FooterBar/tests/FooterBarConfig.spec.ts +1 -1
  61. package/src/components/FooterBar/tests/__snapshots__/FooterBar.spec.ts.snap +2 -2
  62. package/src/components/FranceConnectBtn/Accessibilite.mdx +14 -0
  63. package/src/components/FranceConnectBtn/Accessibilite.stories.ts +194 -0
  64. package/src/components/FranceConnectBtn/AccessibiliteItems.ts +199 -0
  65. package/src/components/FranceConnectBtn/constants/ExpertiseLevelEnum.ts +4 -0
  66. package/src/components/HeaderBar/HeaderBar.stories.ts +60 -2
  67. package/src/components/HeaderNavigationBar/HeaderNavigationBar.mdx +6 -6
  68. package/src/components/HeaderNavigationBar/tests/HeaderNavigationBar.spec.ts +1 -1
  69. package/src/components/HeaderToolbar/HeaderToolbar.vue +2 -2
  70. package/src/components/HeaderToolbar/tests/HeaderToolbar.spec.ts +36 -2
  71. package/src/components/LangBtn/Accessibilite.mdx +14 -0
  72. package/src/components/LangBtn/Accessibilite.stories.ts +166 -0
  73. package/src/components/LangBtn/AccessibiliteItems.ts +132 -0
  74. package/src/components/LangBtn/constants/ExpertiseLevelEnum.ts +4 -0
  75. package/src/components/LangBtn/tests/LangBtn.spec.ts +1 -1
  76. package/src/components/LangBtn/tests/__snapshots__/LangBtn.spec.ts.snap +1 -1
  77. package/src/components/MaintenancePage/MaintenancePage.mdx +11 -0
  78. package/src/components/MaintenancePage/MaintenancePage.stories.ts +41 -0
  79. package/src/components/MaintenancePage/MaintenancePage.vue +25 -0
  80. package/src/components/MaintenancePage/assets/maintenance.svg +1 -0
  81. package/src/components/MaintenancePage/index.ts +3 -0
  82. package/src/components/MaintenancePage/locales.ts +5 -0
  83. package/src/components/MaintenancePage/tests/MaintenancePage.spec.ts +12 -0
  84. package/src/components/MaintenancePage/tests/__snapshots__/MaintenancePage.spec.ts.snap +3 -0
  85. package/src/components/NotFoundPage/NotFoundPage.mdx +19 -0
  86. package/src/components/NotFoundPage/NotFoundPage.stories.ts +76 -0
  87. package/src/components/NotFoundPage/NotFoundPage.vue +52 -0
  88. package/src/components/NotFoundPage/assets/not-found.svg +1 -0
  89. package/src/components/NotFoundPage/locales.ts +6 -0
  90. package/src/components/NotFoundPage/tests/NotFoundPage.spec.ts +38 -0
  91. package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +76 -0
  92. package/src/components/NotificationBar/Accessibilite.mdx +14 -0
  93. package/src/components/NotificationBar/Accessibilite.stories.ts +166 -0
  94. package/src/components/NotificationBar/AccessibiliteItems.ts +174 -0
  95. package/src/components/NotificationBar/constants/ExpertiseLevelEnum.ts +4 -0
  96. package/src/components/NotificationBar/options.ts +1 -0
  97. package/src/components/PageContainer/Accessibilite.mdx +14 -0
  98. package/src/components/PageContainer/Accessibilite.stories.ts +166 -0
  99. package/src/components/PageContainer/AccessibiliteItems.ts +52 -0
  100. package/src/components/PageContainer/constants/ExpertiseLevelEnum.ts +4 -0
  101. package/src/components/PhoneField/PhoneField.vue +5 -5
  102. package/src/components/PhoneField/tests/PhoneField.spec.ts +3 -3
  103. package/src/components/SkipLink/Accessibilite.mdx +14 -0
  104. package/src/components/SkipLink/Accessibilite.stories.ts +167 -0
  105. package/src/components/SkipLink/AccessibiliteItems.ts +77 -0
  106. package/src/components/SkipLink/constants/ExpertiseLevelEnum.ts +4 -0
  107. package/src/components/SocialMediaLinks/SocialMediaLinks.mdx +17 -13
  108. package/src/components/SocialMediaLinks/SocialMediaLinks.stories.ts +2 -1
  109. package/src/components/SocialMediaLinks/tests/SocialMediaLinks.spec.ts +1 -1
  110. package/src/components/SocialMediaLinks/tests/__snapshots__/SocialMediaLinks.spec.ts.snap +2 -2
  111. package/src/components/SubHeader/SubHeader.vue +1 -1
  112. package/src/components/UserMenuBtn/UserMenuBtn.mdx +35 -0
  113. package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +438 -0
  114. package/src/components/UserMenuBtn/UserMenuBtn.vue +105 -0
  115. package/src/components/UserMenuBtn/config.ts +24 -0
  116. package/src/components/UserMenuBtn/tests/UserMenuBtn.spec.ts +125 -0
  117. package/src/components/index.ts +12 -3
  118. package/src/composables/index.ts +8 -0
  119. package/src/composables/rules/tests/useFieldValidation.spec.ts +82 -0
  120. package/src/composables/rules/useFieldValidation.ts +53 -0
  121. package/src/designTokens/index.ts +2 -0
  122. package/src/designTokens/tokens/cnam/cnamDarkTheme.ts +5 -0
  123. package/src/designTokens/tokens/cnam/cnamLightTheme.ts +1 -0
  124. package/src/main.ts +2 -0
  125. package/src/stories/Fondamentaux/Arrondis.mdx +24 -0
  126. package/src/stories/{Guidelines → Fondamentaux}/Colors.mdx +1 -1
  127. package/src/stories/Fondamentaux/Conteneurs.mdx +7 -0
  128. package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +7 -0
  129. package/src/stories/Fondamentaux/Elevations.mdx +14 -0
  130. package/src/stories/Fondamentaux/Espacements.mdx +29 -0
  131. package/src/stories/{Guidelines → Fondamentaux}/Introduction.mdx +1 -1
  132. package/src/stories/Fondamentaux/StylesTypographiques.mdx +33 -0
  133. package/src/stories/Fondamentaux/Typographie.mdx +58 -0
  134. package/src/stories/GuideDuDev/CommentUtiliserLesRules.mdx +132 -0
  135. package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.stories.ts +1 -1
  136. package/src/stories/{Fondamentaux → Guidelines}/EcoConception/Econception.stories.ts +2 -2
  137. package/src/components/Customs/CustomInputSelect/CustomInputSelect.mdx +0 -40
  138. package/src/components/Customs/CustomSelect/tests/CustomSelect.spec.ts +0 -236
  139. package/src/components/Customs/CustomTextField/CustomTextField.mdx +0 -44
  140. package/src/stories/Guidelines/CustomisationEtThemes.mdx +0 -3
  141. package/src/stories/Guidelines/Typo.mdx +0 -53
  142. /package/src/components/Customs/{CustomInputSelect → SyInputSelect}/config.ts +0 -0
  143. /package/src/components/Customs/{CustomTextField/CustomTextField.vue → SyTextField/SyTextField.vue} +0 -0
  144. /package/src/components/Customs/{CustomTextField → SyTextField}/types.d.ts +0 -0
  145. /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/Accessibilite.mdx +0 -0
  146. /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/AccessibiliteItems.ts +0 -0
  147. /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/ExpertiseLevelEnum.ts +0 -0
  148. /package/src/stories/{Fondamentaux → Guidelines}/Accessibilite/constants/RGAALevelEnum.ts +0 -0
  149. /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/EcoConception.mdx +0 -0
  150. /package/src/stories/{Fondamentaux → Guidelines}/EcoConception/ecoDesignItems.ts +0 -0
@@ -0,0 +1,438 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3'
2
+ import UserMenuBtn from './UserMenuBtn.vue'
3
+
4
+ const meta = {
5
+ title: 'Composants/Boutons/UserMenuBtn',
6
+ component: UserMenuBtn,
7
+ parameters: {
8
+ layout: 'fullscreen',
9
+ controls: { exclude: ['modelValue', 'label', 'icon', 'logoutIcon'] },
10
+ },
11
+ argTypes: {
12
+ hideLogoutBtn: { control: 'boolean' },
13
+ hideUserIcon: { control: 'boolean' },
14
+ isMobileView: { control: 'boolean' },
15
+ fullName: { control: 'text' },
16
+ additionalInformation: { control: 'text' },
17
+ },
18
+ } satisfies Meta<typeof UserMenuBtn>
19
+
20
+ export default meta
21
+
22
+ type Story = StoryObj<typeof meta>
23
+
24
+ export const Default: Story = {
25
+ parameters: {
26
+ sourceCode: [
27
+ {
28
+ name: 'Template',
29
+ code: `<template>
30
+ <UserMenuBtn
31
+ v-model="selected"
32
+ :menuItems="menuItems"
33
+ />
34
+ </template>`,
35
+ },
36
+ {
37
+ name: 'Script',
38
+ code: `<script setup lang="ts">
39
+ import { ref } from 'vue'
40
+ import UserMenuBtn from '@cnamts/synapse'
41
+
42
+ const selected = ref(null)
43
+ const menuItems = ref([
44
+ { text: 'Administration', value: 'Administration' },
45
+ { text: 'Profil', value: 'Profil' },
46
+ { text: 'Paramètres', value: 'Paramètres' },
47
+ ])
48
+ </script>`,
49
+ },
50
+ ],
51
+ },
52
+ args: {
53
+ menuItems: [
54
+ { text: 'Administration', value: 'Administration' },
55
+ { text: 'Profil', value: 'Profil' },
56
+ { text: 'Paramètres', value: 'Paramètres' },
57
+ ],
58
+ modelValue: null,
59
+ hideLogoutBtn: false,
60
+ hideUserIcon: false,
61
+ isMobileView: false,
62
+ vuetifyOptions: undefined,
63
+ },
64
+ render: (args) => {
65
+ return {
66
+ components: { UserMenuBtn },
67
+ setup() {
68
+ return { args }
69
+ },
70
+ template: `
71
+ <div class="pa-4">
72
+ <UserMenuBtn v-bind="args"/>
73
+ </div>`,
74
+ }
75
+ },
76
+ }
77
+ export const HideLogoutButton: Story = {
78
+ parameters: {
79
+ sourceCode: [
80
+ {
81
+ name: 'Template',
82
+ code: `<template>
83
+ <UserMenuBtn
84
+ v-model="selected"
85
+ :menuItems="menuItems"
86
+ :hide-logout-btn="hideLogOut"
87
+ />
88
+ </template>`,
89
+ },
90
+ {
91
+ name: 'Script',
92
+ code: `<script setup lang="ts">
93
+ import { ref } from 'vue'
94
+ import UserMenuBtn from '@cnamts/synapse'
95
+
96
+ const selected = ref(null)
97
+ const menuItems = ref([
98
+ { text: 'Administration', value: 'Administration' },
99
+ { text: 'Profil', value: 'Profil' },
100
+ { text: 'Paramètres', value: 'Paramètres' },
101
+ ])
102
+
103
+ const hideLogOut = ref(true)
104
+ </script>`,
105
+ },
106
+ ],
107
+ },
108
+ args: {
109
+ ...Default.args,
110
+ hideLogoutBtn: true,
111
+ },
112
+ render: (args) => {
113
+ return {
114
+ components: { UserMenuBtn },
115
+ setup() {
116
+ return { args }
117
+ },
118
+ template: `
119
+ <div class="pa-4">
120
+ <UserMenuBtn v-bind="args"/>
121
+ </div>`,
122
+ }
123
+ },
124
+ }
125
+
126
+ export const HideUserIcon: Story = {
127
+ parameters: {
128
+ sourceCode: [
129
+ {
130
+ name: 'Template',
131
+ code: `<template>
132
+ <UserMenuBtn
133
+ v-model="selected"
134
+ :menuItems="menuItems"
135
+ :hide-user-icon="hideUserIcon"
136
+ />
137
+ </template>`,
138
+ },
139
+ {
140
+ name: 'Script',
141
+ code: `<script setup lang="ts">
142
+ import { ref } from 'vue'
143
+ import UserMenuBtn from '@cnamts/synapse'
144
+
145
+ const selected = ref(null)
146
+ const menuItems = ref([
147
+ { text: 'Administration', value: 'Administration' },
148
+ { text: 'Profil', value: 'Profil' },
149
+ { text: 'Paramètres', value: 'Paramètres' },
150
+ ])
151
+
152
+ const hideUserIcon = ref(true)
153
+ </script>`,
154
+ },
155
+ ],
156
+ },
157
+ args: {
158
+ ...Default.args,
159
+ hideUserIcon: true,
160
+ },
161
+ render: (args) => {
162
+ return {
163
+ components: { UserMenuBtn },
164
+ setup() {
165
+ return { args }
166
+ },
167
+ template: `
168
+ <div class="pa-4">
169
+ <UserMenuBtn v-bind="args"/>
170
+ </div>`,
171
+ }
172
+ },
173
+ }
174
+
175
+ export const MobileVersion: Story = {
176
+ parameters: {
177
+ sourceCode: [
178
+ {
179
+ name: 'Template',
180
+ code: `<template>
181
+ <UserMenuBtn
182
+ v-model="selected"
183
+ :menuItems="menuItems"
184
+ :is-mobile-view="isMobileVersion"
185
+ />
186
+ </template>`,
187
+ },
188
+ {
189
+ name: 'Script',
190
+ code: `<script setup lang="ts">
191
+ import { ref } from 'vue'
192
+ import UserMenuBtn from '@cnamts/synapse'
193
+
194
+ const selected = ref(null)
195
+ const menuItems = ref([
196
+ { text: 'Administration', value: 'Administration' },
197
+ { text: 'Profil', value: 'Profil' },
198
+ { text: 'Paramètres', value: 'Paramètres' },
199
+ ])
200
+
201
+ const isMobileVersion = ref(true)
202
+ </script>`,
203
+ },
204
+ ],
205
+ },
206
+ args: {
207
+ ...Default.args,
208
+ isMobileView: true,
209
+ },
210
+ render: (args) => {
211
+ return {
212
+ components: { UserMenuBtn },
213
+ setup() {
214
+ return { args }
215
+ },
216
+ template: `
217
+ <div class="pa-4">
218
+ <UserMenuBtn v-bind="args"/>
219
+ </div>`,
220
+ }
221
+ },
222
+ }
223
+
224
+ export const CustomFullName: Story = {
225
+ parameters: {
226
+ sourceCode: [
227
+ {
228
+ name: 'Template',
229
+ code: `<template>
230
+ <UserMenuBtn
231
+ v-model="selected"
232
+ :menuItems="menuItems"
233
+ :fullName="fullName"
234
+ />
235
+ </template>`,
236
+ },
237
+ {
238
+ name: 'Script',
239
+ code: `<script setup lang="ts">
240
+ import { ref } from 'vue'
241
+ import UserMenuBtn from '@cnamts/synapse'
242
+
243
+ const selected = ref(null)
244
+ const menuItems = ref([
245
+ { text: 'Administration', value: 'Administration' },
246
+ { text: 'Profil', value: 'Profil' },
247
+ { text: 'Paramètres', value: 'Paramètres' },
248
+ ])
249
+
250
+ const fullName = ref('John Doe')
251
+ </script>`,
252
+ },
253
+ ],
254
+ },
255
+ args: {
256
+ ...Default.args,
257
+ fullName: 'John Doe',
258
+ },
259
+ render: (args) => {
260
+ return {
261
+ components: { UserMenuBtn },
262
+ setup() {
263
+ return { args }
264
+ },
265
+ template: `
266
+ <div class="pa-4">
267
+ <UserMenuBtn v-bind="args"/>
268
+ </div>`,
269
+ }
270
+ },
271
+ }
272
+
273
+ export const CustomAdditionalInformation: Story = {
274
+ parameters: {
275
+ sourceCode: [
276
+ {
277
+ name: 'Template',
278
+ code: `<template>
279
+ <UserMenuBtn
280
+ v-model="selected"
281
+ :menuItems="menuItems"
282
+ :additionalInformation="additionalInformation"
283
+ />
284
+ </template>`,
285
+ },
286
+ {
287
+ name: 'Script',
288
+ code: `<script setup lang="ts">
289
+ import { ref } from 'vue'
290
+ import UserMenuBtn from '@cnamts/synapse'
291
+
292
+ const selected = ref(null)
293
+ const menuItems = ref([
294
+ { text: 'Administration', value: 'Administration' },
295
+ { text: 'Profil', value: 'Profil' },
296
+ { text: 'Paramètres', value: 'Paramètres' },
297
+ ])
298
+
299
+ const additionalInformation = ref('Custom Information')
300
+ </script>`,
301
+ },
302
+ ],
303
+ },
304
+ args: {
305
+ ...Default.args,
306
+ additionalInformation: 'Custom Information',
307
+ },
308
+ render: (args) => {
309
+ return {
310
+ components: { UserMenuBtn },
311
+ setup() {
312
+ return { args }
313
+ },
314
+ template: `
315
+ <div class="pa-4">
316
+ <UserMenuBtn v-bind="args"/>
317
+ </div>`,
318
+ }
319
+ },
320
+ }
321
+
322
+ export const WithVuetifyOptions: Story = {
323
+ parameters: {
324
+ sourceCode: [
325
+ {
326
+ name: 'Template',
327
+ code: `<template>
328
+ <UserMenuBtn
329
+ v-model="selected"
330
+ :menuItems="menuItems"
331
+ :vuetify-options="vuetifyOptions"
332
+ />
333
+ </template>`,
334
+ },
335
+ {
336
+ name: 'Script',
337
+ code: `<script setup lang="ts">
338
+ import { ref } from 'vue'
339
+ import UserMenuBtn from '@cnamts/synapse'
340
+
341
+ const selected = ref(null)
342
+ const menuItems = ref([
343
+ { text: 'Administration', value: 'Administration' },
344
+ { text: 'Profil', value: 'Profil' },
345
+ { text: 'Paramètres', value: 'Paramètres' },
346
+ ])
347
+
348
+ const handleLogout = () => {
349
+ alert('User logged out')
350
+ }
351
+
352
+ const vuetifyOptions = ref({
353
+ menu: { minWidth: '250px' },
354
+ btn: { variant: 'outlined' },
355
+ icon: { color: 'warning' },
356
+ logoutListItem: { class: 'text-warning' },
357
+ logoutIcon: { color: 'warning' },
358
+ })
359
+ </script>`,
360
+ },
361
+ ],
362
+ },
363
+ args: {
364
+ ...Default.args,
365
+ vuetifyOptions: {
366
+ menu: { minWidth: '250px' },
367
+ btn: { variant: 'outlined' },
368
+ icon: { color: 'warning' },
369
+ logoutListItem: { class: 'text-warning' },
370
+ logoutIcon: { color: 'warning' },
371
+ },
372
+ },
373
+ render: (args) => {
374
+ return {
375
+ components: { UserMenuBtn },
376
+ setup() {
377
+ return { args }
378
+ },
379
+ template: `
380
+ <div class="pa-4">
381
+ <UserMenuBtn v-bind="args"/>
382
+ </div>`,
383
+ }
384
+ },
385
+ }
386
+
387
+ export const LogoutEvent: Story = {
388
+ parameters: {
389
+ sourceCode: [
390
+ {
391
+ name: 'Template',
392
+ code: `<template>
393
+ <UserMenuBtn
394
+ v-model="selected"
395
+ :menuItems="menuItems"
396
+ @logout="handleLogout"
397
+ />
398
+ </template>`,
399
+ },
400
+ {
401
+ name: 'Script',
402
+ code: `<script setup lang="ts">
403
+ import { ref } from 'vue'
404
+ import UserMenuBtn from '@cnamts/synapse'
405
+
406
+ const selected = ref(null)
407
+ const menuItems = ref([
408
+ { text: 'Administration', value: 'Administration' },
409
+ { text: 'Profil', value: 'Profil' },
410
+ { text: 'Paramètres', value: 'Paramètres' },
411
+ ])
412
+
413
+ const handleLogout = () => {
414
+ alert('Logout event triggered')
415
+ }
416
+ </script>`,
417
+ },
418
+ ],
419
+ },
420
+ args: {
421
+ ...Default.args,
422
+ },
423
+ render: (args) => {
424
+ return {
425
+ components: { UserMenuBtn },
426
+ setup() {
427
+ const handleLogout = () => {
428
+ alert('Logout event triggered')
429
+ }
430
+ return { args, handleLogout }
431
+ },
432
+ template: `
433
+ <div class="pa-4">
434
+ <UserMenuBtn v-bind="args" @logout="handleLogout"/>
435
+ </div>`,
436
+ }
437
+ },
438
+ }
@@ -0,0 +1,105 @@
1
+ <script lang="ts" setup>
2
+ import { defineProps, defineEmits, withDefaults, computed } from 'vue'
3
+ import SyBtnSelect from '../Customs/SyBtnSelect/SyBtnSelect.vue'
4
+ import { useDisplay } from 'vuetify'
5
+ import { mdiAccount, mdiLoginVariant } from '@mdi/js'
6
+ import useCustomizableOptions, { type CustomizableOptions } from '@/composables/useCustomizableOptions'
7
+ import { defaultOptions } from './config'
8
+
9
+ const props = withDefaults(defineProps<CustomizableOptions & {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
11
+ modelValue: string | Record<string, any> | null | undefined
12
+ menuItems?: { text: string, value: string }[]
13
+ additionalInformation?: string
14
+ fullName?: string
15
+ hideLogoutBtn?: boolean
16
+ logoutIcon?: string
17
+ isMobileView?: boolean
18
+ hideUserIcon?: boolean
19
+ }>(), {
20
+ modelValue: null,
21
+ menuItems: () => [],
22
+ additionalInformation: 'Information supplémentaire',
23
+ fullName: 'Prénom Nom',
24
+ hideLogoutBtn: false,
25
+ logoutIcon: 'mdiLoginVariant',
26
+ isMobileView: false,
27
+ hideUserIcon: false,
28
+ })
29
+
30
+ const emit = defineEmits(['update:modelValue', 'logout'])
31
+ const { smAndDown } = useDisplay()
32
+
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
34
+ const options = useCustomizableOptions(defaultOptions, props) as any
35
+
36
+ const isMobileView = computed(() => {
37
+ return props.isMobileView || smAndDown.value
38
+ })
39
+
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
41
+ function updateModelValue(value: any) {
42
+ emit('update:modelValue', value)
43
+ }
44
+ </script>
45
+
46
+ <template>
47
+ <SyBtnSelect
48
+ :is-mobile-view="isMobileView"
49
+ :icon-only="isMobileView"
50
+ :menu-items="menuItems"
51
+ :model-value="props.modelValue ?? undefined"
52
+ :options="options"
53
+ :primary-info="fullName"
54
+ :secondary-info="additionalInformation"
55
+ :hide-icon="hideUserIcon"
56
+ class="user-menu-btn"
57
+ @update:model-value="updateModelValue"
58
+ >
59
+ <template #append-icon>
60
+ <VIcon
61
+ v-if="!hideUserIcon"
62
+ :size="isMobileView ? 'x-large' : 'default'"
63
+ class="vd-user-icon mr-0 pa-2"
64
+ v-bind="options['icon']"
65
+ >
66
+ {{ mdiAccount }}
67
+ </VIcon>
68
+ </template>
69
+ <template #footer-list-item>
70
+ <VListItem
71
+ v-if="!hideLogoutBtn"
72
+ class="logout"
73
+ v-bind="options['logoutListItem']"
74
+ @click="$emit('logout')"
75
+ >
76
+ <div class="d-flex">
77
+ <VIcon
78
+ :icon="mdiLoginVariant"
79
+ class="mr-4"
80
+ v-bind="options['logoutIcon']"
81
+ />
82
+ <VListItemTitle>
83
+ Logout
84
+ </VListItemTitle>
85
+ </div>
86
+ </VListItem>
87
+ </template>
88
+ </SyBtnSelect>
89
+ </template>
90
+
91
+ <style scoped>
92
+ @use '@/assets/tokens.scss';
93
+ .vd-user-icon {
94
+ width: 40px;
95
+ height: 40px;
96
+ background: tokens.$grey-lighten-90;
97
+ border-radius: 50%;
98
+
99
+ svg,
100
+ .v-icon__svg {
101
+ width: 24px;
102
+ height: 24px;
103
+ }
104
+ }
105
+ </style>
@@ -0,0 +1,24 @@
1
+ export const defaultOptions = {
2
+ menu: {
3
+ offsetY: true,
4
+ zIndex: 4,
5
+ minWidth: '198px',
6
+ maxWidth: 'auto',
7
+ nudgeRight: 0,
8
+ },
9
+ btn: {
10
+ variant: 'text',
11
+ height: 'auto',
12
+ },
13
+ icon: {
14
+ color: 'avatar',
15
+ },
16
+ logoutListItem: {
17
+ class: 'text-primary',
18
+ minWidth: '198px',
19
+ },
20
+ logoutIcon: {
21
+ color: 'primary',
22
+ class: 'mr-4',
23
+ },
24
+ }
@@ -0,0 +1,125 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import UserMenuBtn from '../UserMenuBtn.vue'
4
+ import { vuetify } from '@tests/unit/setup'
5
+ import { nextTick } from 'vue'
6
+
7
+ describe('UserMenuBtn', () => {
8
+ it('renders the component', () => {
9
+ const wrapper = mount(UserMenuBtn, {
10
+ global: {
11
+ plugins: [vuetify],
12
+ },
13
+ props: {
14
+ modelValue: null,
15
+ menuItems: [{ text: 'Item 1', value: 'item1' }],
16
+ additionalInformation: 'Additional Info',
17
+ fullName: 'John Doe',
18
+ hideLogoutBtn: false,
19
+ isMobileView: false,
20
+ hideUserIcon: false,
21
+ },
22
+ })
23
+ expect(wrapper.exists()).toBe(true)
24
+ })
25
+
26
+ it('displays the full name', () => {
27
+ const wrapper = mount(UserMenuBtn, {
28
+ global: {
29
+ plugins: [vuetify],
30
+ },
31
+ props: {
32
+ modelValue: null,
33
+ fullName: 'John Doe',
34
+ },
35
+ })
36
+ expect(wrapper.text()).toContain('John Doe')
37
+ })
38
+
39
+ it('does not render logout button when hidden', () => {
40
+ const wrapper = mount(UserMenuBtn, {
41
+ global: {
42
+ plugins: [vuetify],
43
+ },
44
+ props: {
45
+ modelValue: null,
46
+ hideLogoutBtn: true,
47
+ },
48
+ })
49
+ expect(wrapper.find('.logout').exists()).toBe(false)
50
+ })
51
+
52
+ it('renders user icon when not hidden', () => {
53
+ const wrapper = mount(UserMenuBtn, {
54
+ global: {
55
+ plugins: [vuetify],
56
+ },
57
+ props: {
58
+ modelValue: null,
59
+ hideUserIcon: false,
60
+ },
61
+ })
62
+ expect(wrapper.find('.vd-user-icon').exists()).toBe(true)
63
+ })
64
+
65
+ it('does not render user icon when hidden', () => {
66
+ const wrapper = mount(UserMenuBtn, {
67
+ global: {
68
+ plugins: [vuetify],
69
+ },
70
+ props: {
71
+ modelValue: null,
72
+ hideUserIcon: true,
73
+ },
74
+ })
75
+ expect(wrapper.find('.vd-user-icon').exists()).toBe(false)
76
+ })
77
+
78
+ it('emits "update:modelValue" when selected changes', async () => {
79
+ const wrapper = mount(UserMenuBtn, {
80
+ global: {
81
+ plugins: [vuetify],
82
+ },
83
+ props: {
84
+ modelValue: null,
85
+ },
86
+ })
87
+ wrapper.vm.$emit('update:modelValue', 'item1')
88
+ await nextTick()
89
+ const emitted = wrapper.emitted('update:modelValue')
90
+ expect(emitted).toBeTruthy()
91
+ if (emitted && emitted[0]) {
92
+ expect(emitted[0]).toEqual(['item1'])
93
+ }
94
+ })
95
+
96
+ it('computes mobile view correctly based on props and display', () => {
97
+ const wrapper = mount(UserMenuBtn, {
98
+ global: {
99
+ plugins: [vuetify],
100
+ },
101
+ props: {
102
+ modelValue: null,
103
+ isMobileView: true,
104
+ },
105
+ })
106
+ expect(wrapper.vm.isMobileView).toBe(true)
107
+ })
108
+ it('emits "update:modelValue" when updateModelValue is called via event', async () => {
109
+ const wrapper = mount(UserMenuBtn, {
110
+ global: {
111
+ plugins: [vuetify],
112
+ },
113
+ props: {
114
+ modelValue: null,
115
+ menuItems: [{ text: 'Item 1', value: 'item1' }],
116
+ },
117
+ })
118
+
119
+ const SyBtnSelect = wrapper.findComponent({ name: 'SyBtnSelect' })
120
+ await SyBtnSelect.vm.$emit('update:model-value', 'test-value')
121
+
122
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy()
123
+ expect(wrapper.emitted('update:modelValue')![0]).toEqual(['test-value'])
124
+ })
125
+ })