@cnamts/synapse 0.0.16-alpha → 1.0.0
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/components/Accordion/Accordion.d.ts +39 -0
- package/dist/components/Accordion/config.d.ts +9 -0
- package/dist/components/ChipList/ChipList.d.ts +1 -1
- package/dist/components/CopyBtn/CopyBtn.d.ts +2 -0
- package/dist/components/Customs/SyInputSelect/SyInputSelect.d.ts +12 -0
- package/dist/components/Customs/SySelect/SySelect.d.ts +43 -16
- package/dist/components/Customs/SyTextField/SyTextField.d.ts +17 -17
- package/dist/components/DatePicker/DatePicker.d.ts +34 -34
- package/dist/components/DatePicker/DateTextInput.d.ts +16 -16
- package/dist/components/DiacriticPicker/DiacriticPicker.d.ts +27 -0
- package/dist/components/DiacriticPicker/config.d.ts +14 -0
- package/dist/components/DiacriticPicker/locales.d.ts +6 -0
- package/dist/components/DownloadBtn/DownloadBtn.d.ts +1 -1
- package/dist/components/FooterBar/FooterBar.d.ts +1 -1
- package/dist/components/NirField/NirField.d.ts +34 -32
- package/dist/components/NotificationBar/NotificationBar.d.ts +1 -1
- package/dist/components/PasswordField/PasswordField.d.ts +1 -1
- package/dist/components/PeriodField/PeriodField.d.ts +64 -64
- package/dist/components/PhoneField/PhoneField.d.ts +1 -0
- package/dist/components/PhoneField/tests/types.d.ts +18 -0
- package/dist/components/SyTextArea/SyTextArea.d.ts +900 -0
- package/dist/components/SyTextArea/locales.d.ts +3 -0
- package/dist/components/SyTextArea/trimStartOnUpdate.d.ts +1 -0
- package/dist/components/SyTextArea/useTextActions.d.ts +13 -0
- package/dist/components/SyTextArea/wrapText.d.ts +1 -0
- package/dist/components/TableToolbar/TableToolbar.d.ts +10 -4
- package/dist/components/TableToolbar/config.d.ts +3 -2
- package/dist/components/index.d.ts +3 -0
- package/dist/composables/date/useHolidayDay.d.ts +36 -0
- package/dist/design-system-v3.js +4202 -3529
- package/dist/design-system-v3.umd.cjs +4 -1
- package/dist/designTokens/tokens/pa/paLightTheme.d.ts +1 -32
- package/dist/style.css +1 -1
- package/dist/utils/rules/index.d.ts +1 -0
- package/dist/utils/rules/isHolidayDay/index.d.ts +11 -0
- package/dist/utils/rules/isHolidayDay/locales.d.ts +2 -0
- package/package.json +3 -2
- package/src/assets/settings.scss +12 -0
- package/src/components/Accordion/Accordion.mdx +69 -0
- package/src/components/Accordion/Accordion.stories.ts +262 -0
- package/src/components/Accordion/Accordion.vue +319 -0
- package/src/components/Accordion/config.ts +9 -0
- package/src/components/Accordion/tests/__snapshots__/accordion.spec.ts.snap +155 -0
- package/src/components/Accordion/tests/accordion.spec.ts +492 -0
- package/src/components/CopyBtn/CopyBtn.stories.ts +189 -0
- package/src/components/CopyBtn/CopyBtn.vue +29 -1
- package/src/components/CopyBtn/tests/CopyBtn.spec.ts +102 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +155 -1
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +97 -14
- package/src/components/Customs/SyInputSelect/tests/SyInputSelect.spec.ts +386 -106
- package/src/components/Customs/SySelect/SySelect.stories.ts +121 -2
- package/src/components/Customs/SySelect/SySelect.vue +33 -8
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +290 -1
- package/src/components/Customs/SyTextField/SyTextField.vue +5 -3
- package/src/components/DatePicker/DatePicker.vue +16 -3
- package/src/components/DatePicker/DateTextInput.vue +16 -5
- package/src/components/DatePicker/examples/DatePickerHolidayRule.vue +130 -0
- package/src/components/DiacriticPicker/DiacriticPicker.mdx +104 -0
- package/src/components/DiacriticPicker/DiacriticPicker.stories.ts +447 -0
- package/src/components/DiacriticPicker/DiacriticPicker.vue +262 -0
- package/src/components/DiacriticPicker/config.ts +15 -0
- package/src/components/DiacriticPicker/locales.ts +6 -0
- package/src/components/DiacriticPicker/tests/DiatriticPicker.spec.ts +132 -0
- package/src/components/DialogBox/DialogBox.vue +1 -3
- package/src/components/NirField/NirField.stories.ts +172 -0
- package/src/components/NirField/NirField.vue +15 -7
- package/src/components/NotificationBar/Accessibilite.stories.ts +1 -1
- package/src/components/NotificationBar/NotificationBar.stories.ts +14 -0
- package/src/components/NotificationBar/NotificationBar.vue +26 -3
- package/src/components/NotificationBar/{options.ts → config.ts} +0 -1
- package/src/components/PaginatedTable/PaginatedTable.vue +0 -11
- package/src/components/PasswordField/PasswordField.stories.ts +4 -3
- package/src/components/PasswordField/PasswordField.vue +26 -18
- package/src/components/PasswordField/tests/PasswordField.spec.ts +1 -10
- package/src/components/PhoneField/PhoneField.stories.ts +143 -0
- package/src/components/PhoneField/PhoneField.vue +88 -30
- package/src/components/PhoneField/tests/PhoneField.additional.spec.ts +266 -0
- package/src/components/PhoneField/tests/PhoneField.spec.ts +248 -28
- package/src/components/PhoneField/tests/types.d.ts +19 -0
- package/src/components/SyTextArea/SyTextArea.mdx +17 -0
- package/src/components/SyTextArea/SyTextArea.stories.ts +322 -0
- package/src/components/SyTextArea/SyTextArea.vue +113 -0
- package/src/components/SyTextArea/locales.ts +3 -0
- package/src/components/SyTextArea/tests/SyTextArea.spec.ts +194 -0
- package/src/components/SyTextArea/trimStartOnUpdate.ts +12 -0
- package/src/components/SyTextArea/useTextActions.ts +52 -0
- package/src/components/SyTextArea/wrapText.ts +42 -0
- package/src/components/TableToolbar/TableToolbar.mdx +86 -1
- package/src/components/TableToolbar/TableToolbar.stories.ts +422 -74
- package/src/components/TableToolbar/TableToolbar.vue +25 -8
- package/src/components/TableToolbar/config.ts +3 -2
- package/src/components/TableToolbar/tests/__snapshots__/TableToolbar.spec.ts.snap +35 -12
- package/src/components/index.ts +3 -0
- package/src/composables/date/useHolidayDay.ts +98 -0
- package/src/composables/rules/useFieldValidation.ts +16 -3
- package/src/composables/validation/useValidation.ts +2 -1
- package/src/designTokens/tokens/pa/paLightTheme.ts +10 -41
- package/src/stories/Accessibilite/Introduction.mdx +5 -2
- package/src/stories/DesignTokens/colors.stories.ts +100 -41
- package/src/utils/rules/index.ts +1 -0
- package/src/utils/rules/isHolidayDay/IsHolidayDay.mdx +52 -0
- package/src/utils/rules/isHolidayDay/IsHolidayDay.stories.ts +129 -0
- package/src/utils/rules/isHolidayDay/index.ts +36 -0
- package/src/utils/rules/isHolidayDay/locales.ts +5 -0
- package/src/utils/rules/isHolidayDay/tests/isHolidayDay.spec.ts +35 -0
- /package/dist/components/NotificationBar/{options.d.ts → config.d.ts} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { mdiChevronDown, mdiInformation } from '@mdi/js'
|
|
2
|
+
import { mdiChevronDown, mdiInformation, mdiCloseCircle } from '@mdi/js'
|
|
3
3
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
4
|
import useCustomizableOptions, { type CustomizableOptions } from '@/composables/useCustomizableOptions'
|
|
5
|
+
import { useValidation, type ValidationRule } from '@/composables/validation/useValidation'
|
|
5
6
|
import defaultOptions from './config'
|
|
6
7
|
|
|
7
8
|
const props = withDefaults(defineProps<CustomizableOptions & {
|
|
@@ -16,7 +17,11 @@
|
|
|
16
17
|
isHeaderToolbar?: boolean
|
|
17
18
|
displayAsterisk?: boolean
|
|
18
19
|
readonly?: boolean
|
|
20
|
+
clearable?: boolean
|
|
21
|
+
customRules?: ValidationRule[]
|
|
22
|
+
disableErrorHandling?: boolean
|
|
19
23
|
}>(), {
|
|
24
|
+
|
|
20
25
|
modelValue: null,
|
|
21
26
|
items: () => [],
|
|
22
27
|
textKey: 'text',
|
|
@@ -28,11 +33,38 @@
|
|
|
28
33
|
isHeaderToolbar: false,
|
|
29
34
|
displayAsterisk: false,
|
|
30
35
|
readonly: false,
|
|
36
|
+
clearable: false,
|
|
37
|
+
customRules: () => [],
|
|
38
|
+
disableErrorHandling: false,
|
|
31
39
|
})
|
|
32
40
|
|
|
33
41
|
const options = useCustomizableOptions(defaultOptions, props)
|
|
34
42
|
|
|
35
|
-
const emit = defineEmits(['update:modelValue'])
|
|
43
|
+
const emit = defineEmits(['update:modelValue', 'update:errorMessages'])
|
|
44
|
+
|
|
45
|
+
// Déclaration de localErrorMessages avant son utilisation
|
|
46
|
+
const localErrorMessages = ref<string | string[]>(props.errorMessages as string | string[])
|
|
47
|
+
|
|
48
|
+
// Initialisation du composable de validation
|
|
49
|
+
const validation = useValidation({
|
|
50
|
+
customRules: props.customRules,
|
|
51
|
+
fieldIdentifier: props.label,
|
|
52
|
+
disableErrorHandling: props.disableErrorHandling,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Synchronisation des messages externes
|
|
56
|
+
watch(() => props.errorMessages, (newVal) => {
|
|
57
|
+
if (Array.isArray(newVal)) {
|
|
58
|
+
validation.errors.value = newVal
|
|
59
|
+
}
|
|
60
|
+
else if (newVal) {
|
|
61
|
+
validation.errors.value = [newVal]
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
validation.errors.value = []
|
|
65
|
+
}
|
|
66
|
+
localErrorMessages.value = validation.errors.value
|
|
67
|
+
}, { immediate: true })
|
|
36
68
|
|
|
37
69
|
const isOpen = ref(false)
|
|
38
70
|
const selectedItem = ref<Record<string, unknown> | string | null>(props.modelValue)
|
|
@@ -48,6 +80,7 @@
|
|
|
48
80
|
}
|
|
49
81
|
|
|
50
82
|
const isRequired = computed(() => {
|
|
83
|
+
if (props.readonly) return
|
|
51
84
|
return (props.required || props.errorMessages.length > 0) && !selectedItem.value
|
|
52
85
|
})
|
|
53
86
|
|
|
@@ -58,6 +91,8 @@
|
|
|
58
91
|
selectedItem.value = item
|
|
59
92
|
emit('update:modelValue', item)
|
|
60
93
|
isOpen.value = false
|
|
94
|
+
validateField(item)
|
|
95
|
+
emit('update:errorMessages', localErrorMessages.value)
|
|
61
96
|
}
|
|
62
97
|
|
|
63
98
|
const getItemText = (item: unknown) => {
|
|
@@ -83,6 +118,8 @@
|
|
|
83
118
|
|
|
84
119
|
watch(() => props.modelValue, (newValue) => {
|
|
85
120
|
selectedItem.value = newValue
|
|
121
|
+
validateField(newValue)
|
|
122
|
+
emit('update:errorMessages', localErrorMessages.value)
|
|
86
123
|
})
|
|
87
124
|
|
|
88
125
|
watch([isOpen, hasError], ([newIsOpen, newHasError]) => {
|
|
@@ -95,6 +132,7 @@
|
|
|
95
132
|
})
|
|
96
133
|
|
|
97
134
|
watch(() => props.errorMessages, (newValue) => {
|
|
135
|
+
if (props.readonly) return
|
|
98
136
|
localErrorMessages.value = newValue
|
|
99
137
|
hasError.value = newValue.length > 0
|
|
100
138
|
})
|
|
@@ -129,18 +167,48 @@
|
|
|
129
167
|
})
|
|
130
168
|
})
|
|
131
169
|
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
170
|
+
// Construction des règles de validation
|
|
171
|
+
const defaultRules = computed<ValidationRule[]>(() => props.required
|
|
172
|
+
? [{
|
|
173
|
+
type: 'required',
|
|
174
|
+
options: {
|
|
175
|
+
message: `Le champ ${props.label || 'ce champ'} est requis.`,
|
|
176
|
+
fieldIdentifier: props.label,
|
|
177
|
+
},
|
|
178
|
+
}]
|
|
179
|
+
: [],
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
const validateField = (value: unknown) => {
|
|
183
|
+
if (props.readonly) {
|
|
184
|
+
validation.clearValidation()
|
|
185
|
+
localErrorMessages.value = []
|
|
186
|
+
return true
|
|
137
187
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
188
|
+
|
|
189
|
+
if (!value && !props.required) {
|
|
190
|
+
validation.clearValidation()
|
|
191
|
+
localErrorMessages.value = []
|
|
192
|
+
return true
|
|
141
193
|
}
|
|
142
|
-
|
|
143
|
-
|
|
194
|
+
|
|
195
|
+
const result = validation.validateField(
|
|
196
|
+
value,
|
|
197
|
+
[...defaultRules.value, ...(props.customRules || [])],
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
localErrorMessages.value = validation.errors.value
|
|
201
|
+
return !result.hasError
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const validateOnSubmit = () => {
|
|
205
|
+
const isValid = validateField(selectedItem.value)
|
|
206
|
+
hasError.value = !isValid
|
|
207
|
+
return isValid
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const checkForErrors = () => {
|
|
211
|
+
return validateField(selectedItem.value)
|
|
144
212
|
}
|
|
145
213
|
|
|
146
214
|
defineExpose({
|
|
@@ -149,6 +217,9 @@
|
|
|
149
217
|
selectItem,
|
|
150
218
|
selectedItem,
|
|
151
219
|
getItemText,
|
|
220
|
+
validateOnSubmit,
|
|
221
|
+
validateField,
|
|
222
|
+
checkForErrors,
|
|
152
223
|
})
|
|
153
224
|
</script>
|
|
154
225
|
|
|
@@ -166,14 +237,19 @@
|
|
|
166
237
|
<div
|
|
167
238
|
ref="menu"
|
|
168
239
|
v-click-outside="closeList"
|
|
169
|
-
:class="[
|
|
240
|
+
:class="[
|
|
241
|
+
'sy-input-select',
|
|
242
|
+
buttonClass,
|
|
243
|
+
hasError ? 'text-error' : 'text-'+options.menu.color,
|
|
244
|
+
hasError ? 'error--text' : ''
|
|
245
|
+
]"
|
|
170
246
|
role="menu"
|
|
171
247
|
tabindex="0"
|
|
172
248
|
@click="toggleMenu"
|
|
173
249
|
@keydown.enter.prevent="toggleMenu"
|
|
174
250
|
@keydown.space.prevent="toggleMenu"
|
|
175
251
|
>
|
|
176
|
-
<span>{{ selectedItemText }}</span>
|
|
252
|
+
<span :class="{ 'error--text': hasError }">{{ selectedItemText }}</span>
|
|
177
253
|
<VIcon
|
|
178
254
|
v-if="hasError"
|
|
179
255
|
class="ml-2"
|
|
@@ -182,6 +258,13 @@
|
|
|
182
258
|
{{ mdiInformation }}
|
|
183
259
|
</VIcon>
|
|
184
260
|
<VIcon> {{ mdiChevronDown }}</VIcon>
|
|
261
|
+
<VIcon
|
|
262
|
+
v-if="selectedItemText && props.clearable"
|
|
263
|
+
aria-label="Supprimer"
|
|
264
|
+
@click.stop.prevent="selectItem(null)"
|
|
265
|
+
>
|
|
266
|
+
{{ mdiCloseCircle }}
|
|
267
|
+
</VIcon>
|
|
185
268
|
</div>
|
|
186
269
|
<VList
|
|
187
270
|
v-if="isOpen"
|