@cnamts/synapse 0.0.7-alpha → 0.0.9-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 +785 -372
- package/dist/design-system-v3.js +4993 -3357
- package/dist/design-system-v3.umd.cjs +1 -10
- package/dist/style.css +1 -1
- package/package.json +10 -2
- package/src/assets/settings.scss +2 -2
- package/src/assets/tokens.scss +107 -112
- package/src/components/BackBtn/BackBtn.vue +4 -4
- package/src/components/BackToTopBtn/BackToTopBtn.vue +1 -0
- package/src/components/CollapsibleList/CollapsibleList.mdx +1 -1
- package/src/components/CollapsibleList/CollapsibleList.vue +43 -44
- package/src/components/ContextualMenu/Accessibilite.mdx +14 -0
- package/src/components/ContextualMenu/Accessibilite.stories.ts +191 -0
- package/src/components/ContextualMenu/AccessibiliteItems.ts +89 -0
- package/src/components/ContextualMenu/ContextualMenu.mdx +118 -0
- package/src/components/ContextualMenu/ContextualMenu.stories.ts +430 -0
- package/src/components/ContextualMenu/ContextualMenu.vue +101 -0
- package/src/components/ContextualMenu/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/ContextualMenu/tests/ContextualMenu.spec.ts +115 -0
- package/src/components/ContextualMenu/tests/__snapshots__/ContextualMenu.spec.ts.snap +10 -0
- package/src/components/ContextualMenu/types.ts +5 -0
- package/src/components/CookieBanner/CookieBanner.stories.ts +1 -2
- package/src/components/CookieBanner/CookieBanner.vue +13 -10
- package/src/components/CookieBanner/tests/__snapshots__/CookieBanner.spec.ts.snap +17 -15
- package/src/components/CookiesSelection/CookiesInformation/CookiesInformation.vue +6 -1
- package/src/components/CookiesSelection/CookiesInformation/locales.ts +1 -0
- package/src/components/CookiesSelection/CookiesTable/CookiesTable.vue +1 -0
- package/src/components/CookiesSelection/tests/__snapshots__/CookiesSelection.spec.ts.snap +17 -15
- package/src/components/CopyBtn/CopyBtn.vue +7 -7
- package/src/components/Customs/SyBtnSelect/SyBtnSelect.vue +26 -26
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +24 -24
- package/src/components/Customs/SySelect/SySelect.stories.ts +7 -7
- package/src/components/Customs/SySelect/SySelect.vue +36 -30
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +2 -2
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +187 -2
- package/src/components/Customs/SyTextField/SyTextField.vue +185 -16
- package/src/components/Customs/SyTextField/tests/SyTextField.spec.ts +2 -4
- package/src/components/Customs/SyTextField/tests/__snapshots__/SyTextField.spec.ts.snap +18 -16
- package/src/components/Customs/SyTextField/types.d.ts +2 -2
- package/src/components/DataList/DataList.stories.ts +3 -2
- package/src/components/DataList/DataList.vue +1 -1
- package/src/components/DataListGroup/DataListGroup.stories.ts +3 -2
- package/src/components/DataListItem/DataListItem.vue +12 -12
- package/src/components/DatePicker/DatePicker.mdx +191 -0
- package/src/components/DatePicker/DatePicker.stories.ts +787 -0
- package/src/components/DatePicker/DatePicker.vue +560 -0
- package/src/components/DatePicker/DateTextInput.vue +409 -0
- package/src/components/DatePicker/tests/DatePicker.spec.ts +266 -0
- package/src/components/DialogBox/DialogBox.mdx +28 -2
- package/src/components/DialogBox/DialogBox.stories.ts +2 -2
- package/src/components/DialogBox/DialogBox.vue +3 -2
- package/src/components/DownloadBtn/DownloadBtn.vue +2 -1
- package/src/components/ExternalLinks/Accessibilite.mdx +14 -0
- package/src/components/ExternalLinks/Accessibilite.stories.ts +191 -0
- package/src/components/ExternalLinks/AccessibiliteItems.ts +197 -0
- package/src/components/ExternalLinks/ExternalLinks.mdx +86 -0
- package/src/components/ExternalLinks/ExternalLinks.stories.ts +553 -0
- package/src/components/ExternalLinks/ExternalLinks.vue +200 -0
- package/src/components/ExternalLinks/config.ts +34 -0
- package/src/components/ExternalLinks/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/ExternalLinks/locales.ts +4 -0
- package/src/components/ExternalLinks/tests/ExternalLinks.spec.ts +154 -0
- package/src/components/ExternalLinks/tests/__snapshots__/ExternalLinks.spec.ts.snap +159 -0
- package/src/components/FileUpload/FileUpload.mdx +165 -0
- package/src/components/FileUpload/FileUpload.stories.ts +429 -0
- package/src/components/FileUpload/FileUpload.vue +195 -0
- package/src/components/FileUpload/FileUploadContent.vue +109 -0
- package/src/components/FileUpload/locales.ts +10 -0
- package/src/components/FileUpload/tests/FileUpload.spec.ts +332 -0
- package/src/components/FileUpload/tests/__snapshots__/FileUpload.spec.ts.snap +7 -0
- package/src/components/FileUpload/useFileDrop.ts +23 -0
- package/src/components/FileUpload/validateFiles.ts +39 -0
- package/src/components/FooterBar/FooterBar.vue +105 -80
- package/src/components/FranceConnectBtn/FranceConnectBtn.vue +14 -13
- package/src/components/HeaderBar/HeaderBar.vue +3 -3
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderBurgerMenu.vue +11 -7
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuItem/HeaderMenuItem.vue +5 -5
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderMenuSection/HeaderMenuSection.vue +2 -2
- package/src/components/HeaderBar/HeaderBurgerMenu/HeaderSubMenu/HeaderSubMenu.vue +10 -8
- package/src/components/HeaderBar/HeaderLogo/HeaderLogo.vue +2 -2
- package/src/components/HeaderBar/HeaderLogo/logos/Logo-mobile.vue +2 -1
- package/src/components/HeaderBar/HeaderLogo/logos/Logo.vue +2 -1
- package/src/components/HeaderBar/HeaderMenuBtn/HeaderMenuBtn.vue +10 -10
- package/src/components/HeaderBar/consts.scss +1 -1
- package/src/components/HeaderLoading/HeaderLoading.vue +12 -11
- package/src/components/HeaderNavigationBar/HeaderNavigationBar.vue +2 -1
- package/src/components/HeaderNavigationBar/HorizontalNavbar/HorizontalNavbar.vue +9 -9
- package/src/components/HeaderToolbar/HeaderToolbar.vue +215 -202
- package/src/components/LangBtn/LangBtn.vue +8 -6
- package/src/components/LogoBrandSection/LogoBrandSection.stories.ts +2 -2
- package/src/components/NirField/NirField.stories.ts +8 -8
- package/src/components/NirField/NirField.vue +46 -48
- package/src/components/NotFoundPage/NotFoundPage.stories.ts +33 -2
- package/src/components/NotFoundPage/NotFoundPage.vue +17 -0
- package/src/components/NotificationBar/NotificationBar.mdx +5 -5
- package/src/components/NotificationBar/NotificationBar.stories.ts +410 -314
- package/src/components/NotificationBar/NotificationBar.vue +43 -41
- package/src/components/PageContainer/PageContainer.vue +4 -4
- package/src/components/PasswordField/Accessibilite.mdx +14 -0
- package/src/components/PasswordField/Accessibilite.stories.ts +191 -0
- package/src/components/PasswordField/AccessibiliteItems.ts +184 -0
- package/src/components/PasswordField/PasswordField.mdx +70 -0
- package/src/components/PasswordField/PasswordField.stories.ts +213 -0
- package/src/components/PasswordField/PasswordField.vue +189 -0
- package/src/components/PasswordField/config.ts +11 -0
- package/src/components/PasswordField/constants/ExpertiseLevelEnum.ts +4 -0
- package/src/components/PasswordField/locales.ts +4 -0
- package/src/components/PasswordField/tests/PasswordField.spec.ts +96 -0
- package/src/components/PhoneField/PhoneField.mdx +0 -2
- package/src/components/PhoneField/PhoneField.stories.ts +10 -50
- package/src/components/PhoneField/PhoneField.vue +77 -93
- package/src/components/PhoneField/tests/PhoneField.spec.ts +0 -15
- package/src/components/RangeField/RangeField.mdx +54 -0
- package/src/components/RangeField/RangeField.stories.ts +189 -0
- package/src/components/RangeField/RangeField.vue +157 -0
- package/src/components/RangeField/RangeSlider/RangeSlider.vue +387 -0
- package/src/components/RangeField/RangeSlider/Tooltip/Tooltip.vue +64 -0
- package/src/components/RangeField/RangeSlider/tests/__snapshots__/rangeSlider.spec.ts.snap +27 -0
- package/src/components/RangeField/RangeSlider/tests/rangeSlider.spec.ts +100 -0
- package/src/components/RangeField/RangeSlider/tests/useDoubleSlider.spec.ts +246 -0
- package/src/components/RangeField/RangeSlider/tests/useMouseSlide.spec.ts +204 -0
- package/src/components/RangeField/RangeSlider/tests/useThumb.spec.ts +22 -0
- package/src/components/RangeField/RangeSlider/tests/useThumbKeyboard.spec.ts +233 -0
- package/src/components/RangeField/RangeSlider/tests/useTooltipsNudge.spec.ts +150 -0
- package/src/components/RangeField/RangeSlider/tests/useTrack.spec.ts +314 -0
- package/src/components/RangeField/RangeSlider/tests/vAnimateClick.spec.ts +32 -0
- package/src/components/RangeField/RangeSlider/types.ts +15 -0
- package/src/components/RangeField/RangeSlider/useMouseSlide.ts +109 -0
- package/src/components/RangeField/RangeSlider/useRangeSlider.ts +126 -0
- package/src/components/RangeField/RangeSlider/useThumb.ts +18 -0
- package/src/components/RangeField/RangeSlider/useThumbKeyboard.ts +84 -0
- package/src/components/RangeField/RangeSlider/useTooltipsNudge.ts +92 -0
- package/src/components/RangeField/RangeSlider/useTrack.ts +116 -0
- package/src/components/RangeField/RangeSlider/vAnimateClick.ts +19 -0
- package/src/components/RangeField/config.ts +7 -0
- package/src/components/RangeField/locales.ts +4 -0
- package/src/components/RangeField/tests/RangeField.spec.ts +224 -0
- package/src/components/RangeField/tests/__snapshots__/RangeField.spec.ts.snap +379 -0
- package/src/components/RatingPicker/EmotionPicker/EmotionPicker.vue +205 -0
- package/src/components/RatingPicker/EmotionPicker/locales.ts +3 -0
- package/src/components/RatingPicker/EmotionPicker/tests/EmotionPicker.spec.ts +104 -0
- package/src/components/RatingPicker/EmotionPicker/tests/__snapshots__/EmotionPicker.spec.ts.snap +66 -0
- package/src/components/RatingPicker/NumberPicker/NumberPicker.vue +159 -0
- package/src/components/RatingPicker/NumberPicker/locales.ts +4 -0
- package/src/components/RatingPicker/NumberPicker/tests/NumberPicker.spec.ts +73 -0
- package/src/components/RatingPicker/NumberPicker/tests/__snapshots__/NumberPicker.spec.ts.snap +105 -0
- package/src/components/RatingPicker/Rating.ts +45 -0
- package/src/components/RatingPicker/RatingPicker.mdx +56 -0
- package/src/components/RatingPicker/RatingPicker.stories.ts +515 -0
- package/src/components/RatingPicker/RatingPicker.vue +122 -0
- package/src/components/RatingPicker/StarsPicker/StarsPicker.vue +116 -0
- package/src/components/RatingPicker/StarsPicker/tests/StarsPicker.spec.ts +95 -0
- package/src/components/RatingPicker/StarsPicker/tests/__snapshots__/StarsPicker.spec.ts.snap +36 -0
- package/src/components/RatingPicker/locales.ts +3 -0
- package/src/components/RatingPicker/tests/Rating.spec.ts +104 -0
- package/src/components/RatingPicker/tests/RatingPicker.spec.ts +187 -0
- package/src/components/RatingPicker/tests/__snapshots__/RatingPicker.spec.ts.snap +108 -0
- package/src/components/SearchListField/SearchListField.mdx +74 -0
- package/src/components/SearchListField/SearchListField.stories.ts +126 -0
- package/src/components/SearchListField/SearchListField.vue +194 -0
- package/src/components/SearchListField/locales.ts +5 -0
- package/src/components/SearchListField/tests/SearchListField.spec.ts +323 -0
- package/src/components/SearchListField/types.d.ts +4 -0
- package/src/components/SelectBtnField/SelectBtnField.mdx +50 -0
- package/src/components/SelectBtnField/SelectBtnField.stories.ts +763 -0
- package/src/components/SelectBtnField/SelectBtnField.vue +283 -0
- package/src/components/SelectBtnField/config.ts +11 -0
- package/src/components/SelectBtnField/tests/SelectBtnField.spec.ts +327 -0
- package/src/components/SelectBtnField/tests/__snapshots__/SelectBtnField.spec.ts.snap +125 -0
- package/src/components/SelectBtnField/types.d.ts +11 -0
- package/src/components/SkipLink/SkipLink.vue +10 -10
- package/src/components/SocialMediaLinks/SocialMediaLinks.vue +28 -26
- package/src/components/SubHeader/SubHeader.vue +32 -31
- package/src/components/SyAlert/SyAlert.vue +12 -12
- package/src/components/UserMenuBtn/UserMenuBtn.vue +1 -1
- package/src/components/UserMenuBtn/config.ts +1 -1
- package/src/components/index.ts +17 -7
- package/src/composables/rules/useFieldValidation.ts +172 -44
- package/src/designTokens/index.ts +6 -4
- package/src/designTokens/{bootstrapColors.md → paColors.md} +1 -1
- package/src/designTokens/tokens/cnam/cnamLightTheme.ts +2 -0
- package/src/designTokens/tokens/pa/paColors.ts +171 -0
- package/src/designTokens/tokens/pa/paContextual.ts +58 -0
- package/src/designTokens/tokens/pa/paDarkTheme.ts +5 -0
- package/src/designTokens/tokens/pa/paLightTheme.ts +123 -0
- package/src/designTokens/tokens/pa/paSemantic.ts +87 -0
- package/src/stories/Fondamentaux/CustomisationEtThemes.mdx +52 -2
- package/src/stories/GuideDuDev/CreerUneIssue.mdx +64 -0
- package/src/stories/GuideDuDev/{CommentUtiliserLesRules.mdx → UtiliserLesRules.mdx} +2 -2
- package/src/stories/GuideDuDev/components.stories.ts +9 -7
- package/src/stories/Guidelines/Vuetify/Vuetify.stories.ts +163 -88
- package/src/stories/Guidelines/Vuetify/VuetifyItems.ts +250 -23
- package/src/temp/TestDTComponent.vue +5 -6
- package/src/utils/calcHumanFileSize/index.ts +12 -0
- package/src/utils/calcHumanFileSize/tests/calcHumanFileSize.spec.ts +21 -0
- package/src/designTokens/tokens/bootstrap/bootstrapColors.ts +0 -158
- package/src/designTokens/tokens/bootstrap/bootstrapLightTheme.ts +0 -22
- package/src/stories/GuideDuDev/CommentContribuer.mdx +0 -22
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/vue3'
|
|
2
|
+
import RatingPicker from './RatingPicker.vue'
|
|
3
|
+
import SySelect from '@/components/Customs/SySelect/SySelect.vue'
|
|
4
|
+
import { VBtn, VSpacer } from 'vuetify/components'
|
|
5
|
+
import { fn } from '@storybook/test'
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Composants/Feedback/RatingPicker',
|
|
9
|
+
component: RatingPicker,
|
|
10
|
+
decorators: [
|
|
11
|
+
() => ({
|
|
12
|
+
template: '<div style="padding: 20px;"><story/></div>',
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: 'fullscreen',
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
type: {
|
|
20
|
+
description: 'Le type de notation.',
|
|
21
|
+
control: {
|
|
22
|
+
type: 'select',
|
|
23
|
+
options: ['emotion', 'number', 'stars'],
|
|
24
|
+
},
|
|
25
|
+
table: {
|
|
26
|
+
type: {
|
|
27
|
+
summary: 'emotion, number, stars',
|
|
28
|
+
},
|
|
29
|
+
defaultValue: {
|
|
30
|
+
summary: 'emotion',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
description: 'Le libellé du champ.',
|
|
36
|
+
control: 'text',
|
|
37
|
+
default: null,
|
|
38
|
+
table: {
|
|
39
|
+
type: {
|
|
40
|
+
summary: 'string | null',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
readonly: {
|
|
45
|
+
description: 'Si le champ est en lecture seule.',
|
|
46
|
+
control: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
table: {
|
|
49
|
+
type: {
|
|
50
|
+
summary: 'boolean',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
itemLabels: {
|
|
55
|
+
description: 'Les libellés des items.',
|
|
56
|
+
control: 'object',
|
|
57
|
+
default: null,
|
|
58
|
+
table: {
|
|
59
|
+
type: {
|
|
60
|
+
summary: 'string[]',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
twoEmotions: {
|
|
65
|
+
description: 'Si le champ est en deux émotions.',
|
|
66
|
+
control: 'boolean',
|
|
67
|
+
default: false,
|
|
68
|
+
table: {
|
|
69
|
+
type: {
|
|
70
|
+
summary: 'boolean',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
hideAlert: {
|
|
75
|
+
description: 'Si le champ est en alerte.',
|
|
76
|
+
control: 'boolean',
|
|
77
|
+
default: false,
|
|
78
|
+
table: {
|
|
79
|
+
type: {
|
|
80
|
+
summary: 'boolean',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
modelValue: {
|
|
85
|
+
description: 'La valeur sélectionnée.',
|
|
86
|
+
control: 'number',
|
|
87
|
+
default: -1,
|
|
88
|
+
table: {
|
|
89
|
+
type: {
|
|
90
|
+
summary: 'number',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
} satisfies Meta<typeof RatingPicker>
|
|
96
|
+
|
|
97
|
+
export default meta
|
|
98
|
+
|
|
99
|
+
type Story = StoryObj<typeof meta>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Story par défaut
|
|
103
|
+
*/
|
|
104
|
+
export const Default: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
'type': 'emotion',
|
|
107
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
108
|
+
'readonly': false,
|
|
109
|
+
'twoEmotions': false,
|
|
110
|
+
'hideAlert': false,
|
|
111
|
+
'modelValue': -1,
|
|
112
|
+
'onUpdate:modelValue': fn(),
|
|
113
|
+
},
|
|
114
|
+
render: (args) => {
|
|
115
|
+
return {
|
|
116
|
+
components: { RatingPicker },
|
|
117
|
+
setup() {
|
|
118
|
+
return { args }
|
|
119
|
+
},
|
|
120
|
+
template: `
|
|
121
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
122
|
+
`,
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
parameters: {
|
|
126
|
+
sourceCode: [
|
|
127
|
+
{
|
|
128
|
+
name: 'Template',
|
|
129
|
+
code: `
|
|
130
|
+
<template>
|
|
131
|
+
<RatingPicker
|
|
132
|
+
v-model="ratingEmotion"
|
|
133
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
134
|
+
type="emotion"
|
|
135
|
+
/>
|
|
136
|
+
</template>
|
|
137
|
+
`,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'Script',
|
|
141
|
+
code: `
|
|
142
|
+
<script setup lang="ts">
|
|
143
|
+
import { ref } from 'vue'
|
|
144
|
+
import RatingPicker from '@cnamts/synapse'
|
|
145
|
+
|
|
146
|
+
const ratingEmotion = ref(-1)
|
|
147
|
+
</script>
|
|
148
|
+
`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const TwoEmotions: Story = {
|
|
155
|
+
args: {
|
|
156
|
+
'type': 'emotion',
|
|
157
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
158
|
+
'readonly': false,
|
|
159
|
+
'twoEmotions': true,
|
|
160
|
+
'hideAlert': false,
|
|
161
|
+
'modelValue': -1,
|
|
162
|
+
'onUpdate:modelValue': fn(),
|
|
163
|
+
},
|
|
164
|
+
render: (args) => {
|
|
165
|
+
return {
|
|
166
|
+
components: { RatingPicker },
|
|
167
|
+
setup() {
|
|
168
|
+
return { args }
|
|
169
|
+
},
|
|
170
|
+
template: `
|
|
171
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
172
|
+
`,
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
parameters: {
|
|
176
|
+
sourceCode: [
|
|
177
|
+
{
|
|
178
|
+
name: 'Template',
|
|
179
|
+
code: `
|
|
180
|
+
<template>
|
|
181
|
+
<RatingPicker
|
|
182
|
+
v-model="ratingEmotion"
|
|
183
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
184
|
+
type="emotion"
|
|
185
|
+
two-emotions
|
|
186
|
+
/>
|
|
187
|
+
</template>
|
|
188
|
+
`,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'Script',
|
|
192
|
+
code: `
|
|
193
|
+
<script setup lang="ts">
|
|
194
|
+
import { ref } from 'vue'
|
|
195
|
+
import RatingPicker from '@cnamts/synapse'
|
|
196
|
+
|
|
197
|
+
const ratingEmotion = ref(-1)
|
|
198
|
+
</script>
|
|
199
|
+
`,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export const Numbers: Story = {
|
|
206
|
+
args: {
|
|
207
|
+
'type': 'number',
|
|
208
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
209
|
+
'readonly': false,
|
|
210
|
+
'hideAlert': false,
|
|
211
|
+
'modelValue': -1,
|
|
212
|
+
'onUpdate:modelValue': fn(),
|
|
213
|
+
},
|
|
214
|
+
render: (args) => {
|
|
215
|
+
return {
|
|
216
|
+
components: { RatingPicker },
|
|
217
|
+
setup() {
|
|
218
|
+
return { args }
|
|
219
|
+
},
|
|
220
|
+
template: `
|
|
221
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
222
|
+
`,
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
parameters: {
|
|
226
|
+
sourceCode: [
|
|
227
|
+
{
|
|
228
|
+
name: 'Template',
|
|
229
|
+
code: `
|
|
230
|
+
<template>
|
|
231
|
+
<RatingPicker
|
|
232
|
+
v-model="ratingNumber"
|
|
233
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
234
|
+
type="number"
|
|
235
|
+
/>
|
|
236
|
+
</template>
|
|
237
|
+
`,
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'Script',
|
|
241
|
+
code: `
|
|
242
|
+
<script setup lang="ts">
|
|
243
|
+
import { ref } from 'vue'
|
|
244
|
+
import RatingPicker from '@cnamts/synapse'
|
|
245
|
+
|
|
246
|
+
const ratingNumber = ref(-1)
|
|
247
|
+
</script>
|
|
248
|
+
`,
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export const Stars: Story = {
|
|
255
|
+
args: {
|
|
256
|
+
'type': 'star',
|
|
257
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
258
|
+
'readonly': false,
|
|
259
|
+
'hideAlert': false,
|
|
260
|
+
'modelValue': -1,
|
|
261
|
+
'onUpdate:modelValue': fn(),
|
|
262
|
+
},
|
|
263
|
+
render: (args) => {
|
|
264
|
+
return {
|
|
265
|
+
components: { RatingPicker },
|
|
266
|
+
setup() {
|
|
267
|
+
return { args }
|
|
268
|
+
},
|
|
269
|
+
template: `
|
|
270
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
271
|
+
`,
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
parameters: {
|
|
275
|
+
sourceCode: [
|
|
276
|
+
{
|
|
277
|
+
name: 'Template',
|
|
278
|
+
code: `
|
|
279
|
+
<template>
|
|
280
|
+
<RatingPicker
|
|
281
|
+
v-model="ratingStar"
|
|
282
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
283
|
+
type="star"
|
|
284
|
+
/>
|
|
285
|
+
</template>
|
|
286
|
+
`,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'Script',
|
|
290
|
+
code: `
|
|
291
|
+
<script setup lang="ts">
|
|
292
|
+
import { ref } from 'vue'
|
|
293
|
+
import RatingPicker from '@cnamts/synapse'
|
|
294
|
+
|
|
295
|
+
const ratingStar = ref(-1)
|
|
296
|
+
</script>
|
|
297
|
+
`,
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export const ReadOnly: Story = {
|
|
304
|
+
args: {
|
|
305
|
+
'type': 'emotion',
|
|
306
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
307
|
+
'readonly': true,
|
|
308
|
+
'twoEmotions': false,
|
|
309
|
+
'hideAlert': false,
|
|
310
|
+
'modelValue': -1,
|
|
311
|
+
'onUpdate:modelValue': fn(),
|
|
312
|
+
},
|
|
313
|
+
render: (args) => {
|
|
314
|
+
return {
|
|
315
|
+
components: { RatingPicker },
|
|
316
|
+
setup() {
|
|
317
|
+
return { args }
|
|
318
|
+
},
|
|
319
|
+
template: `
|
|
320
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
321
|
+
`,
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
parameters: {
|
|
325
|
+
sourceCode: [
|
|
326
|
+
{
|
|
327
|
+
name: 'Template',
|
|
328
|
+
code: `
|
|
329
|
+
<template>
|
|
330
|
+
<RatingPicker
|
|
331
|
+
v-model="ratingEmotion"
|
|
332
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
333
|
+
type="emotion"
|
|
334
|
+
read-only
|
|
335
|
+
/>
|
|
336
|
+
</template>
|
|
337
|
+
`,
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: 'Script',
|
|
341
|
+
code: `
|
|
342
|
+
<script setup lang="ts">
|
|
343
|
+
import { ref } from 'vue'
|
|
344
|
+
import RatingPicker from '@cnamts/synapse'
|
|
345
|
+
|
|
346
|
+
const ratingEmotion = ref(-1)
|
|
347
|
+
</script>
|
|
348
|
+
`,
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export const HideAlert: Story = {
|
|
355
|
+
args: {
|
|
356
|
+
'type': 'emotion',
|
|
357
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
358
|
+
'readonly': false,
|
|
359
|
+
'twoEmotions': false,
|
|
360
|
+
'hideAlert': true,
|
|
361
|
+
'modelValue': -1,
|
|
362
|
+
'onUpdate:modelValue': fn(),
|
|
363
|
+
},
|
|
364
|
+
render: (args) => {
|
|
365
|
+
return {
|
|
366
|
+
components: { RatingPicker },
|
|
367
|
+
setup() {
|
|
368
|
+
return { args }
|
|
369
|
+
},
|
|
370
|
+
template: `
|
|
371
|
+
<RatingPicker v-bind="args" v-model="args.modelValue"/>
|
|
372
|
+
`,
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
parameters: {
|
|
376
|
+
sourceCode: [
|
|
377
|
+
{
|
|
378
|
+
name: 'Template',
|
|
379
|
+
code: `
|
|
380
|
+
<template>
|
|
381
|
+
<RatingPicker
|
|
382
|
+
v-model="ratingEmotion"
|
|
383
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
384
|
+
type="emotion"
|
|
385
|
+
hide-alert
|
|
386
|
+
/>
|
|
387
|
+
</template>
|
|
388
|
+
`,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: 'Script',
|
|
392
|
+
code: `
|
|
393
|
+
<script setup lang="ts">
|
|
394
|
+
import { ref } from 'vue'
|
|
395
|
+
import RatingPicker from '@cnamts/synapse'
|
|
396
|
+
|
|
397
|
+
const ratingEmotion = ref(-1)
|
|
398
|
+
</script>
|
|
399
|
+
`,
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
},
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export const DefaultSlot: Story = {
|
|
406
|
+
args: {
|
|
407
|
+
'type': 'emotion',
|
|
408
|
+
'label': 'Êtes-vous satisfait de ce service ?',
|
|
409
|
+
'readonly': false,
|
|
410
|
+
'twoEmotions': false,
|
|
411
|
+
'hideAlert': false,
|
|
412
|
+
'modelValue': -1,
|
|
413
|
+
'onUpdate:modelValue': fn(),
|
|
414
|
+
},
|
|
415
|
+
render: (args) => {
|
|
416
|
+
return {
|
|
417
|
+
components: { RatingPicker, SySelect, VBtn, VSpacer },
|
|
418
|
+
setup() {
|
|
419
|
+
const items = [
|
|
420
|
+
{
|
|
421
|
+
text: 'Via une recherche internet',
|
|
422
|
+
value: 'internet',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
text: 'Via un professionnel de santé',
|
|
426
|
+
value: 'professional',
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
text: 'Via un ami',
|
|
430
|
+
value: 'friend',
|
|
431
|
+
},
|
|
432
|
+
]
|
|
433
|
+
return { args, items }
|
|
434
|
+
},
|
|
435
|
+
template: `
|
|
436
|
+
<RatingPicker v-bind="args" v-model="args.modelValue">
|
|
437
|
+
<SySelect
|
|
438
|
+
:items="items"
|
|
439
|
+
label="Comment avez-vous connu ce service ?"
|
|
440
|
+
class="mt-8"
|
|
441
|
+
/>
|
|
442
|
+
<div class="d-flex">
|
|
443
|
+
<VSpacer/>
|
|
444
|
+
|
|
445
|
+
<VBtn
|
|
446
|
+
right
|
|
447
|
+
color="primary"
|
|
448
|
+
>
|
|
449
|
+
Terminé
|
|
450
|
+
</VBtn>
|
|
451
|
+
</div>
|
|
452
|
+
</RatingPicker>
|
|
453
|
+
`,
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
parameters: {
|
|
457
|
+
sourceCode: [
|
|
458
|
+
{
|
|
459
|
+
name: 'Template',
|
|
460
|
+
code: `
|
|
461
|
+
<template>
|
|
462
|
+
<RatingPicker
|
|
463
|
+
v-model="ratingEmotion"
|
|
464
|
+
label="Êtes-vous satisfait de ce service ?"
|
|
465
|
+
type="emotion"
|
|
466
|
+
>
|
|
467
|
+
<SySelect
|
|
468
|
+
:items="items"
|
|
469
|
+
label="Comment avez-vous connu ce service ?"
|
|
470
|
+
class="mt-8"
|
|
471
|
+
/>
|
|
472
|
+
<div class="d-flex">
|
|
473
|
+
<VSpacer/>
|
|
474
|
+
|
|
475
|
+
<VBtn
|
|
476
|
+
right
|
|
477
|
+
color="primary"
|
|
478
|
+
>
|
|
479
|
+
Terminé
|
|
480
|
+
</VBtn>
|
|
481
|
+
</div>
|
|
482
|
+
</RatingPicker>
|
|
483
|
+
</template>
|
|
484
|
+
`,
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
name: 'Script',
|
|
488
|
+
code: `
|
|
489
|
+
<script setup lang="ts">
|
|
490
|
+
import { ref } from 'vue'
|
|
491
|
+
import {RatingPicker, SySelect} from '@cnamts/synapse'
|
|
492
|
+
import { VBtn, VSpacer } from 'vuetify/components'
|
|
493
|
+
|
|
494
|
+
const ratingEmotion = ref(-1)
|
|
495
|
+
|
|
496
|
+
const items = [
|
|
497
|
+
{
|
|
498
|
+
text: 'Via une recherche internet',
|
|
499
|
+
value: 'internet'
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
text: 'Via un professionnel de santé',
|
|
503
|
+
value: 'professional'
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
text: 'Via un ami',
|
|
507
|
+
value: 'friend'
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
</script>
|
|
511
|
+
`,
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
},
|
|
515
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { type PropType, computed, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import EmotionPicker from './EmotionPicker/EmotionPicker.vue'
|
|
5
|
+
import NumberPicker from './NumberPicker/NumberPicker.vue'
|
|
6
|
+
import StarsPicker from './StarsPicker/StarsPicker.vue'
|
|
7
|
+
import SyAlert from '@/components/SyAlert/SyAlert.vue'
|
|
8
|
+
|
|
9
|
+
import { RATING_ENUM_VALUES, RatingEnum, AlertTypeEnum } from './Rating'
|
|
10
|
+
import { propValidator } from '@/utils/propValidator'
|
|
11
|
+
import { locales } from './locales'
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
validator: (value: string) => propValidator('type', RATING_ENUM_VALUES, value),
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
type: String as PropType<string | null>,
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
23
|
+
readonly: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
itemLabels: {
|
|
28
|
+
type: Array as PropType<string[]>,
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
twoEmotions: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false,
|
|
34
|
+
},
|
|
35
|
+
hideAlert: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
modelValue: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: -1,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits(['update:modelValue'])
|
|
46
|
+
|
|
47
|
+
const alertTypeEnumRef = ref(AlertTypeEnum)
|
|
48
|
+
const internalValue = ref(-1)
|
|
49
|
+
const displayAdditionalContent = ref(false)
|
|
50
|
+
|
|
51
|
+
const ratingComponent = computed(() => {
|
|
52
|
+
if (props.type === RatingEnum.EMOTION) {
|
|
53
|
+
return EmotionPicker as unknown as string
|
|
54
|
+
}
|
|
55
|
+
else if (props.type === RatingEnum.NUMBER) {
|
|
56
|
+
return NumberPicker as unknown as string
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return StarsPicker as unknown as string
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const length = computed(() => {
|
|
64
|
+
if (props.type === RatingEnum.EMOTION) {
|
|
65
|
+
return props.twoEmotions ? 2 : 3
|
|
66
|
+
}
|
|
67
|
+
return undefined
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const hasAnswered = computed(() => props.modelValue !== -1)
|
|
71
|
+
|
|
72
|
+
function showAdditionalContent(value: number): void {
|
|
73
|
+
const starsUnsatisfied = props.type === RatingEnum.STARS && value <= 3
|
|
74
|
+
const numberUnsatisfied = props.type === RatingEnum.NUMBER && value <= 7
|
|
75
|
+
const isEmotion = props.type === RatingEnum.EMOTION
|
|
76
|
+
const isEmotionLow = props.twoEmotions ? value < 2 : value < 3
|
|
77
|
+
const emotionUnsatisfied = isEmotion && isEmotionLow
|
|
78
|
+
if (starsUnsatisfied || numberUnsatisfied || emotionUnsatisfied) {
|
|
79
|
+
displayAdditionalContent.value = true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function setValue(value: number): void {
|
|
84
|
+
internalValue.value = value
|
|
85
|
+
showAdditionalContent(value)
|
|
86
|
+
emit('update:modelValue', value)
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<div class="vd-rating-picker">
|
|
92
|
+
<component
|
|
93
|
+
:is="ratingComponent"
|
|
94
|
+
:model-value="internalValue"
|
|
95
|
+
:label="props.label"
|
|
96
|
+
:length="length"
|
|
97
|
+
:readonly="props.readonly || hasAnswered"
|
|
98
|
+
:item-labels="props.itemLabels || undefined"
|
|
99
|
+
@update:model-value="setValue"
|
|
100
|
+
>
|
|
101
|
+
<template #label>
|
|
102
|
+
<slot name="label">
|
|
103
|
+
{{ props.label }}
|
|
104
|
+
</slot>
|
|
105
|
+
</template>
|
|
106
|
+
</component>
|
|
107
|
+
|
|
108
|
+
<template v-if="hasAnswered">
|
|
109
|
+
<SyAlert
|
|
110
|
+
v-if="!props.hideAlert"
|
|
111
|
+
:class="{ 'mb-4': displayAdditionalContent }"
|
|
112
|
+
outlined
|
|
113
|
+
:type="alertTypeEnumRef.SUCCESS"
|
|
114
|
+
class="mt-4"
|
|
115
|
+
>
|
|
116
|
+
{{ locales.thanks }}
|
|
117
|
+
</SyAlert>
|
|
118
|
+
|
|
119
|
+
<slot v-if="displayAdditionalContent" />
|
|
120
|
+
</template>
|
|
121
|
+
</div>
|
|
122
|
+
</template>
|