@cnamts/synapse 0.0.2-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/README.md +1 -1
- package/dist/design-system-v3.d.ts +712 -27
- package/dist/design-system-v3.js +2745 -5384
- package/dist/design-system-v3.umd.cjs +10 -2
- package/dist/style.css +1 -1
- package/package.json +32 -29
- package/src/components/Alert/Alert.mdx +1 -1
- package/src/components/Alert/Alert.stories.ts +91 -1
- package/src/components/Alert/Alert.vue +8 -8
- 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/FranceConnectBtn/FranceConnectBtn.vue +2 -2
- package/src/components/HeaderBar/HeaderBar.mdx +256 -0
- package/src/components/HeaderBar/HeaderBar.stories.ts +703 -0
- package/src/components/HeaderBar/HeaderBar.vue +276 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.mdx +433 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.stories.ts +1089 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.vue +234 -0
- 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/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.vue +51 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/tests/HeaderMenuItem.spec.ts +16 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/tests/__snapshots__/HeaderMenuItem.spec.ts.snap +3 -0
- 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/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.vue +51 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/tests/HeaderMenuSection.spec.ts +31 -0
- 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/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.vue +194 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/tests/HeaderSubMenu.spec.ts +63 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/conts.ts +1 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/locals.ts +4 -0
- 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/HeaderBurgerMenu/tests/useHandleSubMenus.spec.ts +158 -0
- package/src/components/HeaderBar/HeaderBurgerMenu/useHandleSubMenus.ts +49 -0
- package/src/components/HeaderBar/HeaderLogo/HeaderLogo.vue +143 -0
- package/src/components/HeaderBar/HeaderLogo/locales.ts +3 -0
- package/src/components/HeaderBar/HeaderLogo/logos/Logo-mobile.vue +117 -0
- package/src/components/HeaderBar/HeaderLogo/logos/Logo.vue +279 -0
- package/src/components/HeaderBar/HeaderLogo/tests/HeaderLogo.spec.ts +119 -0
- package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +84 -0
- package/src/components/HeaderBar/HeaderMenuBtn/locals.ts +4 -0
- 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 +6 -0
- package/src/components/HeaderBar/consts.ts +2 -0
- package/src/components/HeaderBar/locales.ts +3 -0
- package/src/components/HeaderBar/tests/HeaderBar.spec.ts +216 -0
- package/src/components/HeaderBar/tests/__snapshots__/HeaderBar.spec.ts.snap +45 -0
- package/src/components/HeaderBar/tests/useHeaderResponsiveMode.spec.ts +26 -0
- package/src/components/HeaderBar/tests/useScrollDirection.spec.ts +34 -0
- package/src/components/HeaderBar/useHeaderResponsiveMode.ts +25 -0
- package/src/components/HeaderBar/useScrollDirection.ts +26 -0
- 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 +7 -9
- 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/PageContainer/PageContainer.vue +0 -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/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/Logo/{types.d.ts → types.ts} +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type { PropType } from 'vue'
|
|
4
|
+
|
|
5
|
+
import { locales } from './locales'
|
|
6
|
+
import DataListItem from '@/components/DataListItem/DataListItem.vue'
|
|
7
|
+
import DataListLoading from './DataListLoading/DataListLoading.vue'
|
|
8
|
+
|
|
9
|
+
import type { DataListIcons, DataListItem as DataListItemInterface, ItemClass } from './types'
|
|
10
|
+
import { useWidthable } from '@/composables/widthable'
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
items: {
|
|
14
|
+
type: Array as PropType<DataListItemInterface[]>,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
icons: {
|
|
18
|
+
type: Object as PropType<DataListIcons | undefined>,
|
|
19
|
+
default: undefined,
|
|
20
|
+
},
|
|
21
|
+
listTitle: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: undefined,
|
|
24
|
+
},
|
|
25
|
+
titleClass: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'text-subtitle-1 font-weight-bold mb-3',
|
|
28
|
+
},
|
|
29
|
+
row: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
placeholder: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: undefined,
|
|
36
|
+
},
|
|
37
|
+
loading: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
itemsNumberLoading: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 1,
|
|
44
|
+
},
|
|
45
|
+
headingLoading: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
renderHtmlValue: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
maxWidth: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: undefined,
|
|
56
|
+
},
|
|
57
|
+
minWidth: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: undefined,
|
|
60
|
+
},
|
|
61
|
+
width: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: undefined,
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const { widthStyles } = useWidthable(props)
|
|
68
|
+
|
|
69
|
+
const emit = defineEmits(['click:item-action'])
|
|
70
|
+
|
|
71
|
+
const label = computed(() => (props.loading ? locales.loadingLabel : undefined))
|
|
72
|
+
|
|
73
|
+
const getIcon = (iconName?: string): string | undefined => {
|
|
74
|
+
if (!iconName || !props.icons) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
return props.icons?.[iconName]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const getItemClass = (index: number, itemClass?: string): ItemClass => {
|
|
81
|
+
const margin = {
|
|
82
|
+
'mb-2': index !== props.items.length - 1,
|
|
83
|
+
}
|
|
84
|
+
return [margin, itemClass]
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<div
|
|
90
|
+
:aria-label="label"
|
|
91
|
+
:style="widthStyles"
|
|
92
|
+
class="vd-data-list"
|
|
93
|
+
>
|
|
94
|
+
<VFadeTransition mode="out-in">
|
|
95
|
+
<DataListLoading
|
|
96
|
+
v-if="loading"
|
|
97
|
+
:items-number="itemsNumberLoading"
|
|
98
|
+
:heading="headingLoading"
|
|
99
|
+
:title-class="titleClass"
|
|
100
|
+
:row="row"
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<div v-else>
|
|
104
|
+
<slot name="title">
|
|
105
|
+
<h4
|
|
106
|
+
v-if="listTitle"
|
|
107
|
+
:class="titleClass"
|
|
108
|
+
>
|
|
109
|
+
{{ listTitle }}
|
|
110
|
+
</h4>
|
|
111
|
+
</slot>
|
|
112
|
+
|
|
113
|
+
<ul v-if="items.length">
|
|
114
|
+
<DataListItem
|
|
115
|
+
v-for="(item, index) in items"
|
|
116
|
+
:key="index"
|
|
117
|
+
:label="item.key"
|
|
118
|
+
:value="item.value"
|
|
119
|
+
:action="item.action"
|
|
120
|
+
:chip="item.chip"
|
|
121
|
+
:row="row"
|
|
122
|
+
:render-html-value="renderHtmlValue"
|
|
123
|
+
:icon="getIcon(item.icon)"
|
|
124
|
+
:placeholder="placeholder"
|
|
125
|
+
:vuetify-options="item.options"
|
|
126
|
+
:class="getItemClass(index, item.class)"
|
|
127
|
+
class="vd-data-list-item text-body-1"
|
|
128
|
+
@click:action="emit('click:item-action', index)"
|
|
129
|
+
/>
|
|
130
|
+
</ul>
|
|
131
|
+
</div>
|
|
132
|
+
</VFadeTransition>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
|
|
136
|
+
<style lang="scss" scoped>
|
|
137
|
+
:deep(ul) {
|
|
138
|
+
list-style: none;
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import HeaderLoading from '@/components/HeaderLoading/HeaderLoading.vue'
|
|
4
|
+
|
|
5
|
+
// Define props
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
itemsNumber: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 1,
|
|
10
|
+
},
|
|
11
|
+
heading: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false,
|
|
14
|
+
},
|
|
15
|
+
row: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const itemWidth = computed(() => (props.row ? '150px' : '90px'))
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
class="vd-data-list-loading"
|
|
28
|
+
>
|
|
29
|
+
<HeaderLoading
|
|
30
|
+
v-if="heading"
|
|
31
|
+
width="100px"
|
|
32
|
+
height="1.5rem"
|
|
33
|
+
class="mb-4"
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<ul>
|
|
37
|
+
<li
|
|
38
|
+
v-for="index in itemsNumber"
|
|
39
|
+
:key="index + '-loading-item'"
|
|
40
|
+
:class="{ 'mb-4': index !== itemsNumber }"
|
|
41
|
+
class="vd-data-list-loading-item"
|
|
42
|
+
>
|
|
43
|
+
<HeaderLoading
|
|
44
|
+
v-if="!row"
|
|
45
|
+
width="60px"
|
|
46
|
+
height="1rem"
|
|
47
|
+
class="mb-1"
|
|
48
|
+
/>
|
|
49
|
+
<HeaderLoading
|
|
50
|
+
:width="itemWidth"
|
|
51
|
+
height="1.5rem"
|
|
52
|
+
/>
|
|
53
|
+
</li>
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import { vuetify } from '@tests/unit/setup'
|
|
4
|
+
|
|
5
|
+
import DataListLoading from '../DataListLoading.vue'
|
|
6
|
+
|
|
7
|
+
describe('DataListLoading', () => {
|
|
8
|
+
it('renders correctly', () => {
|
|
9
|
+
const wrapper = mount(DataListLoading, {
|
|
10
|
+
global: {
|
|
11
|
+
plugins: [vuetify],
|
|
12
|
+
},
|
|
13
|
+
props: {
|
|
14
|
+
heading: true,
|
|
15
|
+
itemsNumber: 3,
|
|
16
|
+
row: true,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const elExists = wrapper.find('.vd-data-list-loading-item').exists()
|
|
21
|
+
expect(elExists).toBe(true)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { type DOMWrapper, mount } from '@vue/test-utils'
|
|
3
|
+
import { vuetify } from '@tests/unit/setup'
|
|
4
|
+
|
|
5
|
+
import DataList from '../DataList.vue'
|
|
6
|
+
import type { DataListItem } from '../types'
|
|
7
|
+
|
|
8
|
+
const items = [
|
|
9
|
+
{
|
|
10
|
+
key: 'Civility',
|
|
11
|
+
value: '',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: 'Name',
|
|
15
|
+
value: 'Dupont',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: 'First name',
|
|
19
|
+
value: 'Paul',
|
|
20
|
+
},
|
|
21
|
+
] as DataListItem[]
|
|
22
|
+
|
|
23
|
+
describe('DataList', () => {
|
|
24
|
+
it('renders correctly', () => {
|
|
25
|
+
const wrapper = mount(DataList, {
|
|
26
|
+
global: {
|
|
27
|
+
plugins: [vuetify],
|
|
28
|
+
},
|
|
29
|
+
props: {
|
|
30
|
+
items: items,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const elExists = wrapper.find('.vd-data-list').exists()
|
|
35
|
+
expect(elExists).toBe(true)
|
|
36
|
+
|
|
37
|
+
// Check items exists
|
|
38
|
+
const itemsExists = wrapper.find('.vd-data-list-item').exists()
|
|
39
|
+
expect(itemsExists).toBe(true)
|
|
40
|
+
|
|
41
|
+
const titleExists = wrapper.find('h4').exists()
|
|
42
|
+
expect(titleExists).toBe(false)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('renders correctly with a title', () => {
|
|
46
|
+
const wrapper = mount(DataList, {
|
|
47
|
+
global: {
|
|
48
|
+
plugins: [vuetify],
|
|
49
|
+
},
|
|
50
|
+
props: {
|
|
51
|
+
items: items,
|
|
52
|
+
listTitle: 'Informations',
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const elExists = wrapper.find('h4').exists()
|
|
57
|
+
expect(elExists).toBe(true)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('renders correctly with an empty list', () => {
|
|
61
|
+
const wrapper = mount(DataList, {
|
|
62
|
+
global: {
|
|
63
|
+
plugins: [vuetify],
|
|
64
|
+
},
|
|
65
|
+
props: {
|
|
66
|
+
items: [],
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Check items does not exist
|
|
71
|
+
const itemsExists = wrapper.find('.vd-data-list-item').exists()
|
|
72
|
+
expect(itemsExists).toBe(false)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('renders correctly with an icon', () => {
|
|
76
|
+
const listWithIcon = items
|
|
77
|
+
|
|
78
|
+
// Add an action to the second item
|
|
79
|
+
listWithIcon[1].icon = 'mdiTest'
|
|
80
|
+
|
|
81
|
+
const wrapper = mount(DataList, {
|
|
82
|
+
global: {
|
|
83
|
+
plugins: [vuetify],
|
|
84
|
+
},
|
|
85
|
+
props: {
|
|
86
|
+
items: listWithIcon,
|
|
87
|
+
icons: {
|
|
88
|
+
mdiTest: 'test',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
// Check items does not exist
|
|
94
|
+
const itemsExists = wrapper.find('.vd-data-list-item .v-icon').exists()
|
|
95
|
+
expect(itemsExists).toBe(true)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('renders correctly with a class', async () => {
|
|
99
|
+
const listWithClass = items
|
|
100
|
+
|
|
101
|
+
// Add a class to the second item
|
|
102
|
+
listWithClass[1].class = 'custom-class'
|
|
103
|
+
|
|
104
|
+
const wrapper = mount(DataList, {
|
|
105
|
+
global: {
|
|
106
|
+
plugins: [vuetify],
|
|
107
|
+
},
|
|
108
|
+
props: {
|
|
109
|
+
items: listWithClass,
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// Check that items now exist
|
|
114
|
+
const itemsExists = wrapper
|
|
115
|
+
.find('.vd-data-list-item.custom-class')
|
|
116
|
+
.exists()
|
|
117
|
+
|
|
118
|
+
expect(itemsExists).toBe(true)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('renders loading state correctly', async () => {
|
|
122
|
+
const wrapper = mount(DataList, {
|
|
123
|
+
global: {
|
|
124
|
+
plugins: [vuetify],
|
|
125
|
+
},
|
|
126
|
+
props: {
|
|
127
|
+
items: items,
|
|
128
|
+
loading: true,
|
|
129
|
+
itemsNumberLoading: 3,
|
|
130
|
+
headingLoading: true,
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
// Check that items does not exist
|
|
135
|
+
let itemsExists = wrapper.find('.vd-data-list-item').exists()
|
|
136
|
+
expect(itemsExists).toBe(false)
|
|
137
|
+
|
|
138
|
+
await wrapper.setProps({
|
|
139
|
+
loading: false,
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// Check that items now exist
|
|
143
|
+
itemsExists = wrapper.find('.vd-data-list-item').exists()
|
|
144
|
+
expect(itemsExists).toBe(true)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('renders correctly with an action', async () => {
|
|
148
|
+
const listWithAction = items
|
|
149
|
+
|
|
150
|
+
// Add an action to the second item
|
|
151
|
+
listWithAction[1].action = 'Edit'
|
|
152
|
+
|
|
153
|
+
const wrapper = mount(DataList, {
|
|
154
|
+
global: {
|
|
155
|
+
plugins: [vuetify],
|
|
156
|
+
},
|
|
157
|
+
props: {
|
|
158
|
+
items: listWithAction,
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
const itemWithAction = wrapper.findAll('.vd-data-list-item').at(1)
|
|
163
|
+
expect(itemWithAction?.exists()).toBe(true)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('emits action event', async () => {
|
|
167
|
+
const listWithAction = items
|
|
168
|
+
|
|
169
|
+
// Add an action to the second item
|
|
170
|
+
listWithAction[2].action = 'Edit'
|
|
171
|
+
|
|
172
|
+
const wrapper = mount(DataList, {
|
|
173
|
+
global: {
|
|
174
|
+
plugins: [vuetify],
|
|
175
|
+
},
|
|
176
|
+
props: {
|
|
177
|
+
items: listWithAction,
|
|
178
|
+
},
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
// Find the second item element
|
|
182
|
+
const itemWithAction = wrapper.findAll('.vd-data-list-item').at(2)
|
|
183
|
+
expect(itemWithAction?.exists()).toBe(true)
|
|
184
|
+
|
|
185
|
+
const actionBtn = (itemWithAction as DOMWrapper<Element>).find(
|
|
186
|
+
'.vd-data-list-item-action-btn',
|
|
187
|
+
)
|
|
188
|
+
expect(actionBtn.exists()).toBe(true)
|
|
189
|
+
|
|
190
|
+
await actionBtn.trigger('click')
|
|
191
|
+
|
|
192
|
+
expect(wrapper.emitted('click:item-action')).toEqual([[2]])
|
|
193
|
+
})
|
|
194
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCustomizableOptions } from '@/composables/useCustomizableOptions'
|
|
2
|
+
|
|
3
|
+
export interface IndexedObject<Type = string> {
|
|
4
|
+
[key: string]: Type
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface DataListItem {
|
|
8
|
+
key: string
|
|
9
|
+
value?: string | number
|
|
10
|
+
action?: string
|
|
11
|
+
chip?: boolean
|
|
12
|
+
icon?: string
|
|
13
|
+
options?: useCustomizableOptions
|
|
14
|
+
class?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type DataList = DataListItem[]
|
|
18
|
+
|
|
19
|
+
export interface DataListIcons {
|
|
20
|
+
[iconName: string]: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ItemClass = (string | undefined | IndexedObject<boolean>)[]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Controls, Canvas, Meta, Source } from '@storybook/blocks';
|
|
2
|
+
import * as DataListGroup from './DataListGroup.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={DataListGroup} />
|
|
5
|
+
|
|
6
|
+
# DataListGroup
|
|
7
|
+
|
|
8
|
+
L’élément `DataListGroup` est utilisé pour afficher une liste de DataList.
|
|
9
|
+
|
|
10
|
+
<Canvas of={DataListGroup.Default} />
|
|
11
|
+
|
|
12
|
+
# API
|
|
13
|
+
|
|
14
|
+
<Controls of={DataListGroup.Default} />
|
|
15
|
+
|
|
16
|
+
# Exemple d'utilisation
|
|
17
|
+
|
|
18
|
+
<Source dark code={`
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import DataListGroup from '@cnamts/synapse'
|
|
21
|
+
|
|
22
|
+
const items = [
|
|
23
|
+
{
|
|
24
|
+
title: 'Informations patient',
|
|
25
|
+
items: [
|
|
26
|
+
{
|
|
27
|
+
key: 'Nom',
|
|
28
|
+
value: 'Dupont',
|
|
29
|
+
icon: 'accountIcon',
|
|
30
|
+
chip: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: 'Prénom',
|
|
34
|
+
value: 'Paul',
|
|
35
|
+
icon: 'accountIcon',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'Date de naissance',
|
|
39
|
+
value: '24/09/1970',
|
|
40
|
+
icon: 'calendarIcon',
|
|
41
|
+
action: 'Modifier',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: 'Médecin traitant',
|
|
47
|
+
items: [
|
|
48
|
+
{
|
|
49
|
+
key: 'Nom du praticien',
|
|
50
|
+
value: 'Gérard Leblanc',
|
|
51
|
+
icon: 'doctorIcon',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
key: 'N° RPPS',
|
|
56
|
+
value: 'XXXXX',
|
|
57
|
+
icon: 'cardAccountIcon',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Autres informations',
|
|
63
|
+
items: [
|
|
64
|
+
{
|
|
65
|
+
key: 'Dernière modification',
|
|
66
|
+
value: '04/06/2020',
|
|
67
|
+
icon: 'editIcon',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<DataListGroup :items="items" />
|
|
76
|
+
</template>
|
|
77
|
+
`} />
|