@cnamts/synapse 1.0.1 → 1.0.2
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/{DateFilter-BmRuzQ9Z.js → DateFilter-YWOTbfeL.js} +1 -1
- package/dist/{NumberFilter-CnIPDHqx.js → NumberFilter-DMmMgALM.js} +1 -1
- package/dist/{PeriodFilter-CZwZ8CnQ.js → PeriodFilter-Bok5BHcn.js} +1 -1
- package/dist/SelectFilter-BKud2WhN.js +136 -0
- package/dist/{TextFilter-DTxZHJwX.js → TextFilter-DvMf2thH.js} +1 -1
- package/dist/components/Accordion/Accordion.d.ts +2 -1
- package/dist/components/Accordion/composables/useAccordionGroupCommunication.d.ts +5 -0
- package/dist/components/Accordion/composables/useAccordionKeyboardNavigation.d.ts +12 -0
- package/dist/components/Accordion/composables/useAccordionState.d.ts +13 -0
- package/dist/components/Customs/SyCheckbox/SyCheckbox.d.ts +85 -0
- package/dist/components/Customs/SyInputSelect/SyInputSelect.d.ts +2 -0
- package/dist/components/Customs/SySelect/SySelect.d.ts +33 -13
- package/dist/components/Customs/SyTextField/SyTextField.d.ts +2 -2
- package/dist/components/DatePicker/ComplexDatePicker/ComplexDatePicker.d.ts +1585 -1452
- package/dist/components/DatePicker/DatePicker/DatePicker.d.ts +16 -2
- package/dist/components/DatePicker/DateTextInput/DateTextInput.d.ts +3 -1
- package/dist/components/DatePicker/composables/index.d.ts +2 -0
- package/dist/components/DatePicker/composables/useAsteriskDisplay.d.ts +14 -0
- package/dist/components/DatePicker/composables/useDateAutoClamp.d.ts +16 -0
- package/dist/components/DatePicker/composables/useDateRangeInput.d.ts +1 -1
- package/dist/components/DatePicker/composables/useDisplayedDateString.d.ts +3 -0
- package/dist/components/DatePicker/composables/useInputBlurHandler.d.ts +1 -0
- package/dist/components/DatePicker/composables/useMonthButtonCustomization.d.ts +5 -2
- package/dist/components/NirField/NirField.d.ts +7 -3
- package/dist/components/NirField/nirValidation.d.ts +1 -1
- package/dist/components/PasswordField/PasswordField.d.ts +2 -0
- package/dist/components/PeriodField/PeriodField.d.ts +52 -8
- package/dist/components/PhoneField/PhoneField.d.ts +2 -2
- package/dist/components/RangeField/RangeField.d.ts +2 -0
- package/dist/components/SearchListField/SearchListField.d.ts +9 -0
- package/dist/components/SyTextArea/SyTextArea.d.ts +2 -0
- package/dist/components/Tables/SyServerTable/SyServerTable.d.ts +14 -9
- package/dist/components/Tables/SyTable/SyTable.d.ts +12 -7
- package/dist/components/Tables/common/SyTablePagination.d.ts +1636 -0
- package/dist/components/Tables/common/TableHeader.d.ts +2 -20
- package/dist/components/Tables/common/filters/SelectFilter.d.ts +5 -5
- package/dist/components/Tables/common/filters/getFilterComponent.d.ts +1 -0
- package/dist/components/Tables/common/filters/locales.d.ts +4 -0
- package/dist/components/Tables/common/filters/logics/date.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/number.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/period.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/select.d.ts +1 -0
- package/dist/components/Tables/common/filters/logics/text.d.ts +1 -0
- package/dist/components/Tables/common/locales.d.ts +21 -0
- package/dist/components/Tables/common/organizeColumns/OrganizeColumns.d.ts +267 -0
- package/dist/components/Tables/common/organizeColumns/sortHeaders.d.ts +2 -0
- package/dist/components/Tables/common/tableFilterUtils.d.ts +1 -0
- package/dist/components/Tables/common/tableStorageUtils.d.ts +41 -1
- package/dist/components/Tables/common/tableUtils.d.ts +42 -5
- package/dist/components/Tables/common/types.d.ts +19 -8
- package/dist/components/Tables/common/usePagination.d.ts +22 -0
- package/dist/components/Tables/common/useTableCheckbox.d.ts +20 -0
- package/dist/components/Tables/common/useTableHeaders.d.ts +76 -0
- package/dist/components/Tables/common/useTableItems.d.ts +24 -0
- package/dist/components/Tables/common/useTableOptions.d.ts +18 -0
- package/dist/components/ToolbarContainer/ToolbarContainer.d.ts +11 -0
- package/dist/components/UserMenuBtn/UserMenuBtn.d.ts +9 -2
- package/dist/components/index.d.ts +8 -6
- package/dist/design-system-v3.js +58 -56
- package/dist/design-system-v3.umd.cjs +22 -22
- package/dist/main-Cx8qG7YR.js +16344 -0
- package/dist/stories/Accessibilite/Vuetify/VuetifyItems.d.ts +14 -2
- package/dist/stories/DesignTokens/StylesTypographiques.stories.new.d.ts +8 -0
- package/dist/stories/DesignTokens/TypographyDisplay.d.ts +28 -0
- package/dist/stories/DesignTokens/vue-shims.d.ts +6 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/common/imgs/accessibility-svgrepo-com.svg +4 -0
- package/src/components/Accordion/Accessibilite/AccessibilityGuide.mdx +249 -0
- package/src/components/Accordion/Accordion.vue +48 -76
- package/src/components/Accordion/composables/__tests__/useAccordionGroupCommunication.spec.ts +146 -0
- package/src/components/Accordion/composables/__tests__/useAccordionKeyboardNavigation.spec.ts +209 -0
- package/src/components/Accordion/composables/__tests__/useAccordionState.spec.ts +144 -0
- package/src/components/Accordion/composables/useAccordionGroupCommunication.ts +52 -0
- package/src/components/Accordion/composables/useAccordionKeyboardNavigation.ts +111 -0
- package/src/components/Accordion/composables/useAccordionState.ts +59 -0
- package/src/components/Accordion/tests/__snapshots__/accordion.spec.ts.snap +3 -0
- package/src/components/Customs/SyCheckbox/Accessibilite.mdx +303 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.mdx +50 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.stories.ts +630 -0
- package/src/components/Customs/SyCheckbox/SyCheckbox.vue +326 -0
- package/src/components/Customs/SyCheckbox/tests/SyCheckbox.spec.ts +201 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.stories.ts +1 -0
- package/src/components/Customs/SyInputSelect/SyInputSelect.vue +8 -1
- package/src/components/Customs/SySelect/SySelect.stories.ts +160 -0
- package/src/components/Customs/SySelect/SySelect.vue +291 -32
- package/src/components/Customs/SySelect/tests/SySelect.spec.ts +230 -0
- package/src/components/Customs/SyTextField/SyTextField.stories.ts +3 -2
- package/src/components/Customs/SyTextField/SyTextField.vue +19 -8
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.stories.ts +241 -31
- package/src/components/DatePicker/ComplexDatePicker/ComplexDatePicker.vue +305 -57
- package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.events.spec.ts +161 -0
- package/src/components/DatePicker/ComplexDatePicker/tests/ComplexDatePicker.spec.ts +4 -2
- package/src/components/DatePicker/DatePicker/DatePicker.stories.ts +259 -137
- package/src/components/DatePicker/DatePicker/DatePicker.vue +153 -25
- package/src/components/DatePicker/DatePicker/tests/DatePicker.events.spec.ts +189 -0
- package/src/components/DatePicker/DatePicker/{DatePicker.spec.ts → tests/DatePicker.spec.ts} +1 -15
- package/src/components/DatePicker/DateTextInput/DateRange.stories.ts +24 -14
- package/src/components/DatePicker/DateTextInput/DateTextInput.events.spec.ts +148 -0
- package/src/components/DatePicker/DateTextInput/DateTextInput.spec.ts +3 -1
- package/src/components/DatePicker/DateTextInput/DateTextInput.vue +200 -5
- package/src/components/DatePicker/DateTextInput/NoCalendar.stories.ts +241 -31
- package/src/components/DatePicker/composables/index.ts +2 -0
- package/src/components/DatePicker/composables/tests/useDateAutoClamp.spec.ts +190 -0
- package/src/components/DatePicker/composables/tests/useInputBlurHandler.spec.ts +182 -4
- package/src/components/DatePicker/composables/tests/useMonthButtonCustomization.spec.ts +105 -80
- package/src/components/DatePicker/composables/useAsteriskDisplay.ts +31 -0
- package/src/components/DatePicker/composables/useDateAutoClamp.ts +136 -0
- package/src/components/DatePicker/composables/useDateRangeInput.ts +21 -18
- package/src/components/DatePicker/composables/useDisplayedDateString.ts +13 -1
- package/src/components/DatePicker/composables/useInputBlurHandler.ts +84 -20
- package/src/components/DatePicker/composables/useMonthButtonCustomization.ts +149 -51
- package/src/components/DiacriticPicker/DiacriticPicker.stories.ts +10 -0
- package/src/components/ErrorPage/Accessibilite.stories.ts +8 -0
- package/src/components/ErrorPage/ErrorPage.vue +12 -6
- package/src/components/ErrorPage/tests/__snapshots__/ErrorPage.spec.ts.snap +4 -4
- package/src/components/NirField/NirField.mdx +22 -9
- package/src/components/NirField/NirField.stories.ts +26 -2
- package/src/components/NirField/NirField.vue +209 -22
- package/src/components/NirField/nirValidation.ts +17 -3
- package/src/components/NirField/tests/NirField.spec.ts +2 -2
- package/src/components/NotFoundPage/Accessibilite.stories.ts +8 -0
- package/src/components/NotFoundPage/NotFoundPage.vue +2 -1
- package/src/components/NotFoundPage/tests/__snapshots__/NotFoundPage.spec.ts.snap +8 -6
- package/src/components/PaginatedTable/PaginatedTable.mdx +2 -0
- package/src/components/PasswordField/PasswordField.stories.ts +4 -0
- package/src/components/PasswordField/PasswordField.vue +3 -0
- package/src/components/PeriodField/PeriodField.vue +2 -0
- package/src/components/PhoneField/PhoneField.stories.ts +15 -15
- package/src/components/PhoneField/PhoneField.vue +1 -1
- package/src/components/RangeField/RangeField.stories.ts +9 -0
- package/src/components/RangeField/RangeField.vue +4 -0
- package/src/components/RangeField/tests/__snapshots__/RangeField.spec.ts.snap +12 -0
- package/src/components/SearchListField/SearchListField.vue +5 -0
- package/src/components/SyTextArea/SyTextArea.vue +3 -0
- package/src/components/SyTextArea/tests/SyTextArea.spec.ts +0 -1
- package/src/components/Tables/SyServerTable/FilterRules.stories.ts +632 -15
- package/src/components/Tables/SyServerTable/SyServerTable.mdx +15 -5
- package/src/components/Tables/SyServerTable/SyServerTable.stories.ts +2844 -1377
- package/src/components/Tables/SyServerTable/SyServerTable.vue +155 -66
- package/src/components/Tables/SyServerTable/tests/SyServerTable.spec.ts +256 -4
- package/src/components/Tables/SyTable/FilterRules.stories.ts +183 -0
- package/src/components/Tables/SyTable/SyTable.mdx +14 -4
- package/src/components/Tables/SyTable/SyTable.stories.ts +1265 -477
- package/src/components/Tables/SyTable/SyTable.vue +152 -72
- package/src/components/Tables/SyTable/tests/SyTable.spec.ts +366 -4
- package/src/components/Tables/common/SyTableFilter.vue +3 -56
- package/src/components/Tables/common/SyTablePagination.vue +375 -0
- package/src/components/Tables/common/TableHeader.vue +10 -26
- package/src/components/Tables/common/filters/SelectFilter.vue +131 -22
- package/src/components/Tables/common/filters/getFilterComponent.ts +54 -0
- package/src/components/Tables/common/filters/locales.ts +4 -0
- package/src/components/Tables/common/filters/logics/date.ts +12 -0
- package/src/components/Tables/common/filters/logics/number.ts +48 -0
- package/src/components/Tables/common/filters/logics/period.ts +25 -0
- package/src/components/Tables/common/filters/logics/select.ts +27 -0
- package/src/components/Tables/common/filters/logics/tests/TextFilterLogic.spec.ts +177 -0
- package/src/components/Tables/common/filters/logics/text.ts +62 -0
- package/src/components/Tables/common/filters/tests/TextFilter.spec.ts +11 -11
- package/src/components/Tables/common/locales.ts +24 -0
- package/src/components/Tables/common/organizeColumns/OrganizeColumns.vue +269 -0
- package/src/components/Tables/common/organizeColumns/sortHeaders.ts +9 -0
- package/src/components/Tables/common/tableFilterUtils.ts +43 -295
- package/src/components/Tables/common/tableStorageUtils.ts +27 -2
- package/src/components/Tables/common/tableStyles.scss +26 -0
- package/src/components/Tables/common/tableUtils.ts +3 -16
- package/src/components/Tables/common/tests/SyTablePagination.spec.ts +170 -0
- package/src/components/Tables/common/tests/filterByRange.spec.ts +215 -0
- package/src/components/Tables/common/tests/tableFilterUtils.spec.ts +0 -14
- package/src/components/Tables/common/tests/tableUtils.spec.ts +7 -51
- package/src/components/Tables/common/types.ts +17 -6
- package/src/components/Tables/common/usePagination.ts +83 -0
- package/src/components/Tables/common/useTableCheckbox.ts +58 -0
- package/src/components/Tables/common/useTableHeaders.ts +88 -0
- package/src/components/Tables/common/useTableItems.ts +87 -0
- package/src/components/Tables/common/useTableOptions.ts +93 -0
- package/src/components/ToolbarContainer/ToolbarContainer.mdx +16 -0
- package/src/components/ToolbarContainer/ToolbarContainer.stories.ts +675 -0
- package/src/components/ToolbarContainer/ToolbarContainer.vue +128 -0
- package/src/components/ToolbarContainer/tests/ToolbarContainer.spec.ts +156 -0
- package/src/components/UserMenuBtn/UserMenuBtn.stories.ts +74 -0
- package/src/components/UserMenuBtn/UserMenuBtn.vue +19 -17
- package/src/components/index.ts +8 -6
- package/src/stories/Accessibilite/Aculturation/AuditDesignSystem.mdx +293 -20
- package/src/stories/Accessibilite/Aculturation/SensibilisationAccessibilite.mdx +448 -54
- package/src/stories/Accessibilite/Audit/RGAA.mdx +231 -23
- package/src/stories/Accessibilite/Avancement/Avancement.mdx +591 -7
- package/src/stories/Accessibilite/Avancement/Avancement.stories.ts +139 -38
- package/src/stories/Accessibilite/Introduction.mdx +258 -18
- package/src/stories/Accessibilite/KitDePreAudit/Echantillonnage.mdx +221 -31
- package/src/stories/Accessibilite/KitDePreAudit/Introduction.mdx +204 -22
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Introduction.mdx +537 -24
- package/src/stories/Accessibilite/KitDePreAudit/Outils/LecteursDEcran.mdx +577 -70
- package/src/stories/Accessibilite/KitDePreAudit/Outils/Tanaguru.mdx +382 -31
- package/src/stories/Accessibilite/KitDePreAudit/Preaudit.mdx +419 -81
- package/src/stories/Accessibilite/Vuetify/Vuetify.mdx +132 -6
- package/src/stories/Accessibilite/Vuetify/Vuetify.stories.ts +370 -146
- package/src/stories/Accessibilite/Vuetify/VuetifyItems.ts +35 -57
- package/src/stories/Demarrer/Accueil.stories.ts +20 -5
- package/src/stories/DesignTokens/StylesTypographiques.mdx +10 -9
- package/src/stories/DesignTokens/StylesTypographiques.stories.new.ts +397 -0
- package/src/stories/DesignTokens/StylesTypographiques.stories.ts +397 -0
- package/src/stories/DesignTokens/TypographyDisplay.vue +155 -0
- package/src/stories/DesignTokens/vue-shims.d.ts +6 -0
- package/src/stories/GuideDuDev/LesBreackingChanges.mdx +0 -2
- package/src/stories/GuideDuDev/MigrationDepuisBridge.mdx +1 -1
- package/src/stories/GuideDuDev/MigrationDepuisVue2.mdx +1 -1
- package/src/stories/GuideDuDev/PortailAgent.mdx +10 -0
- package/src/stories/GuideDuDev/PortailAgent.stories.ts +506 -0
- package/src/stories/GuideDuDev/Theme.mdx +41 -0
- package/dist/SelectFilter-Cj-GW2Cc.js +0 -97
- package/dist/main-WDqeoGM-.js +0 -14788
- package/src/components/PaginatedTable/tests/__snapshots__/PaginatedTable.spec.ts.snap +0 -886
- package/src/components/Tables/SyServerTable/tests/__snapshots__/SyServerTable.spec.ts.snap +0 -521
- package/src/components/Tables/SyTable/tests/__snapshots__/SyTable.spec.ts.snap +0 -521
- package/src/stories/DesignTokens/ThemePA.mdx +0 -35
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
const toolbar = ref<HTMLDivElement>()
|
|
5
|
+
|
|
6
|
+
let tools: Array<HTMLElement>
|
|
7
|
+
|
|
8
|
+
onMounted(() => {
|
|
9
|
+
tools = Array.from(toolbar.value?.querySelectorAll<HTMLElement>('button:not([disabled]), a:not([disabled]), input:not([disabled])') || [])
|
|
10
|
+
tools?.forEach((el) => {
|
|
11
|
+
el.setAttribute('tabindex', '-1')
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
function selectNextElement(e: Event & { target: HTMLElement }) {
|
|
16
|
+
const currentIndex = tools.findIndex(tool => tool === e.target)
|
|
17
|
+
|
|
18
|
+
const nextIndex = currentIndex < tools.length - 1 ? currentIndex + 1 : 0
|
|
19
|
+
|
|
20
|
+
const nextElem = tools.at(nextIndex)
|
|
21
|
+
|
|
22
|
+
e.target.setAttribute('tabindex', '-1')
|
|
23
|
+
nextElem?.setAttribute('tabindex', '0')
|
|
24
|
+
nextElem?.focus()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function selectPrevElement(e: Event & { target: HTMLElement }) {
|
|
28
|
+
let currentIndex = tools.findIndex(tool => tool === e.target)
|
|
29
|
+
|
|
30
|
+
const prevIndex = currentIndex > 0 ? currentIndex - 1 : tools.length - 1
|
|
31
|
+
|
|
32
|
+
const nextElem = tools.at(prevIndex)
|
|
33
|
+
|
|
34
|
+
e.target.setAttribute('tabindex', '-1')
|
|
35
|
+
nextElem?.setAttribute('tabindex', '0')
|
|
36
|
+
nextElem?.focus()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function selectFirstElement() {
|
|
40
|
+
const firstElement = tools.at(0)
|
|
41
|
+
if (!firstElement) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
document.activeElement?.setAttribute('tabindex', '-1')
|
|
45
|
+
firstElement.setAttribute('tabindex', '0')
|
|
46
|
+
firstElement.focus()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function selectLastElement() {
|
|
50
|
+
const lastElement = tools.at(-1)
|
|
51
|
+
if (!lastElement) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
document.activeElement?.setAttribute('tabindex', '-1')
|
|
55
|
+
lastElement.setAttribute('tabindex', '0')
|
|
56
|
+
lastElement.focus()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let lastElementFocused: HTMLElement | undefined = undefined
|
|
60
|
+
|
|
61
|
+
function setupFocus() {
|
|
62
|
+
// Remove the ability to tab into the toolbar to be able to shift focus to previous focusable element
|
|
63
|
+
toolbar.value?.setAttribute('tabindex', '-1')
|
|
64
|
+
|
|
65
|
+
if (lastElementFocused) {
|
|
66
|
+
// If there is a last focused element, restore focus to it
|
|
67
|
+
lastElementFocused.setAttribute('tabindex', '0')
|
|
68
|
+
lastElementFocused.focus()
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
selectFirstElement()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function saveFocus(e: FocusEvent) {
|
|
76
|
+
// Save the last focused element to restore focus later
|
|
77
|
+
if (e.target !== e.currentTarget) {
|
|
78
|
+
lastElementFocused = e.target as HTMLElement
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function blurToolbar(e: FocusEvent) {
|
|
83
|
+
// When an item of the toolbar is blured it should not be focusable anymore
|
|
84
|
+
(e.target as HTMLElement)?.setAttribute('tabindex', '-1')
|
|
85
|
+
|
|
86
|
+
// When the toolbar loses focus, we need to set its focusable
|
|
87
|
+
if (toolbar.value?.contains(e.relatedTarget as HTMLElement)) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
toolbar.value?.setAttribute('tabindex', '0')
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<!-- eslint-disable vuejs-accessibility/no-static-element-interactions -->
|
|
95
|
+
<template>
|
|
96
|
+
<div
|
|
97
|
+
ref="toolbar"
|
|
98
|
+
role="toolbar"
|
|
99
|
+
tabindex="0"
|
|
100
|
+
class="sy-toolbar"
|
|
101
|
+
@keydown.left="selectPrevElement"
|
|
102
|
+
@keydown.right="selectNextElement"
|
|
103
|
+
@keydown.up="selectPrevElement"
|
|
104
|
+
@keydown.down="selectNextElement"
|
|
105
|
+
@keydown.home.prevent="selectFirstElement"
|
|
106
|
+
@keydown.end.prevent="selectLastElement"
|
|
107
|
+
@focus="setupFocus"
|
|
108
|
+
@focus.capture="saveFocus"
|
|
109
|
+
@blur.capture="blurToolbar"
|
|
110
|
+
>
|
|
111
|
+
<slot />
|
|
112
|
+
</div>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<style scoped>
|
|
116
|
+
.sy-toolbar:has(:focus-visible) {
|
|
117
|
+
position: relative;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.sy-toolbar:has(:focus-visible)::after {
|
|
121
|
+
content: '';
|
|
122
|
+
display: block;
|
|
123
|
+
position: absolute;
|
|
124
|
+
inset: -6px;
|
|
125
|
+
border-radius: 5px;
|
|
126
|
+
border: 2px solid rgb(var(--v-theme-primary));
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Toolbar from '../ToolbarContainer.vue'
|
|
4
|
+
import { VBtn } from 'vuetify/components'
|
|
5
|
+
import { vuetify } from '@tests/unit/setup'
|
|
6
|
+
import { defineComponent } from 'vue'
|
|
7
|
+
|
|
8
|
+
describe('ToolbarContainer.vue', () => {
|
|
9
|
+
it('renders default slot content', () => {
|
|
10
|
+
const wrapper = mount(Toolbar, {
|
|
11
|
+
global: {
|
|
12
|
+
plugins: [vuetify],
|
|
13
|
+
},
|
|
14
|
+
slots: {
|
|
15
|
+
default: '<div class="toolbar-content">Toolbar Content</div>',
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
expect(wrapper.find('.toolbar-content').exists()).toBe(true)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('applies custom classes', () => {
|
|
23
|
+
const wrapper = mount(Toolbar, {
|
|
24
|
+
global: {
|
|
25
|
+
plugins: [vuetify],
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
class: 'custom-toolbar',
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
expect(wrapper.classes()).toContain('custom-toolbar')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('set the focus to the first button', async () => {
|
|
36
|
+
const wrapper = mount(Toolbar, {
|
|
37
|
+
attachTo: document.body,
|
|
38
|
+
global: {
|
|
39
|
+
plugins: [vuetify],
|
|
40
|
+
},
|
|
41
|
+
slots: {
|
|
42
|
+
default: `
|
|
43
|
+
<div>
|
|
44
|
+
<VBtn>Action 1</VBtn>
|
|
45
|
+
<VBtn>Action 2</VBtn>
|
|
46
|
+
</div>
|
|
47
|
+
`,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const toolbar = wrapper.find('.sy-toolbar')
|
|
52
|
+
const firstButton = wrapper.find('button.v-btn')
|
|
53
|
+
|
|
54
|
+
await toolbar.trigger('focus')
|
|
55
|
+
expect(document.activeElement).toBe(firstButton.element)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('focuses the button when the navigation key are pressed', async () => {
|
|
59
|
+
const wrapper = mount(Toolbar, {
|
|
60
|
+
attachTo: document.body,
|
|
61
|
+
global: {
|
|
62
|
+
plugins: [vuetify],
|
|
63
|
+
},
|
|
64
|
+
slots: {
|
|
65
|
+
default: `
|
|
66
|
+
<div>
|
|
67
|
+
<VBtn>Action 1</VBtn>
|
|
68
|
+
<VBtn>Action 2</VBtn>
|
|
69
|
+
</div>
|
|
70
|
+
`,
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const toolbar = wrapper.find('.sy-toolbar')
|
|
75
|
+
const firstButton = wrapper.find('button.v-btn')
|
|
76
|
+
const secondButton = wrapper.findAll('button.v-btn')[1]
|
|
77
|
+
|
|
78
|
+
await toolbar.trigger('focus')
|
|
79
|
+
await firstButton.trigger('keydown', { key: 'ArrowRight' })
|
|
80
|
+
expect(document.activeElement).toBe(secondButton.element)
|
|
81
|
+
await secondButton.trigger('keydown', { key: 'ArrowLeft' })
|
|
82
|
+
expect(document.activeElement).toBe(firstButton.element)
|
|
83
|
+
await firstButton.trigger('keydown', { key: 'ArrowDown' })
|
|
84
|
+
expect(document.activeElement).toBe(secondButton.element)
|
|
85
|
+
await secondButton.trigger('keydown', { key: 'ArrowUp' })
|
|
86
|
+
expect(document.activeElement).toBe(firstButton.element)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('focuses the first and last buttons when Home and End keys are pressed', async () => {
|
|
90
|
+
const wrapper = mount(Toolbar, {
|
|
91
|
+
attachTo: document.body,
|
|
92
|
+
global: {
|
|
93
|
+
plugins: [vuetify],
|
|
94
|
+
},
|
|
95
|
+
slots: {
|
|
96
|
+
default: `
|
|
97
|
+
<div>
|
|
98
|
+
<VBtn>Action 1</VBtn>
|
|
99
|
+
<VBtn>Action 2</VBtn>
|
|
100
|
+
<VBtn>Action 3</VBtn>
|
|
101
|
+
<VBtn>Action 4</VBtn>
|
|
102
|
+
</div>
|
|
103
|
+
`,
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const toolbar = wrapper.find('.sy-toolbar')
|
|
108
|
+
const firstButton = wrapper.find('button.v-btn')
|
|
109
|
+
const lastButton = wrapper.findAll('button.v-btn')[3]
|
|
110
|
+
|
|
111
|
+
await toolbar.trigger('focus')
|
|
112
|
+
await firstButton.trigger('keydown', { key: 'End' })
|
|
113
|
+
expect(document.activeElement).toBe(lastButton.element)
|
|
114
|
+
await lastButton.trigger('keydown', { key: 'Home' })
|
|
115
|
+
expect(document.activeElement).toBe(firstButton.element)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('keeps in memory the last focused button', async () => {
|
|
119
|
+
const TestComponent = defineComponent({
|
|
120
|
+
components: {
|
|
121
|
+
Toolbar,
|
|
122
|
+
VBtn,
|
|
123
|
+
},
|
|
124
|
+
template: `
|
|
125
|
+
<div>
|
|
126
|
+
<Toolbar>
|
|
127
|
+
<VBtn>Action 1</VBtn>
|
|
128
|
+
<VBtn>Action 2</VBtn>
|
|
129
|
+
<VBtn>Action 3</VBtn>
|
|
130
|
+
</Toolbar>
|
|
131
|
+
<VBtn>Action 4</VBtn>
|
|
132
|
+
</div>
|
|
133
|
+
`,
|
|
134
|
+
})
|
|
135
|
+
const wrapper = mount(TestComponent, {
|
|
136
|
+
attachTo: document.body,
|
|
137
|
+
global: {
|
|
138
|
+
plugins: [vuetify],
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const toolbar = wrapper.find('.sy-toolbar')
|
|
143
|
+
const firstButton = wrapper.find('button.v-btn')
|
|
144
|
+
const secondButton = wrapper.findAll('button.v-btn')[1]
|
|
145
|
+
const lastButton = wrapper.findAll<HTMLElement>('button.v-btn')[3]
|
|
146
|
+
|
|
147
|
+
await toolbar.trigger('focus')
|
|
148
|
+
expect(document.activeElement).toBe(firstButton.element)
|
|
149
|
+
await firstButton.trigger('keydown', { key: 'ArrowRight' })
|
|
150
|
+
expect(document.activeElement).toBe(secondButton.element)
|
|
151
|
+
await lastButton.element.focus()
|
|
152
|
+
expect(document.activeElement).toBe(lastButton.element)
|
|
153
|
+
await toolbar.trigger('focus')
|
|
154
|
+
expect(document.activeElement).toBe(secondButton.element)
|
|
155
|
+
})
|
|
156
|
+
})
|
|
@@ -111,6 +111,13 @@ const meta = {
|
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
|
+
'default': {
|
|
115
|
+
control: false,
|
|
116
|
+
description: 'Ecrase le contenu du menu utilisateur',
|
|
117
|
+
table: {
|
|
118
|
+
category: 'slots',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
114
121
|
'onLogout': {
|
|
115
122
|
action: 'logout',
|
|
116
123
|
description: 'Événement déclenché lors de la déconnexion de l\'utilisateur',
|
|
@@ -594,3 +601,70 @@ export const LogoutEvent: Story = {
|
|
|
594
601
|
}
|
|
595
602
|
},
|
|
596
603
|
}
|
|
604
|
+
|
|
605
|
+
export const Slot: Story = {
|
|
606
|
+
parameters: {
|
|
607
|
+
sourceCode: [
|
|
608
|
+
{
|
|
609
|
+
name: 'Template',
|
|
610
|
+
code: `<template>
|
|
611
|
+
<UserMenuBtn
|
|
612
|
+
v-model="selected"
|
|
613
|
+
:full-name="fullName"
|
|
614
|
+
>
|
|
615
|
+
<div class="ma-6 text-center">
|
|
616
|
+
<p class="text-h6">
|
|
617
|
+
Bienvenue, {{ fullName }}
|
|
618
|
+
</p>
|
|
619
|
+
|
|
620
|
+
<p class="mt-2">
|
|
621
|
+
La création de votre compte est en cours,<br> vos services seront accessibles dans les prochains jours.
|
|
622
|
+
</p>
|
|
623
|
+
</div>
|
|
624
|
+
</UserMenuBtn>
|
|
625
|
+
</template>`,
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: 'Script',
|
|
629
|
+
code: `<script setup lang="ts">
|
|
630
|
+
import { ref } from 'vue'
|
|
631
|
+
import { UserMenuBtn } from '@cnamts/synapse'
|
|
632
|
+
|
|
633
|
+
const selected = ref(null)
|
|
634
|
+
const fullName = ref('John Doe')
|
|
635
|
+
|
|
636
|
+
</script>`,
|
|
637
|
+
},
|
|
638
|
+
],
|
|
639
|
+
},
|
|
640
|
+
args: {
|
|
641
|
+
modelValue: null,
|
|
642
|
+
hideLogoutBtn: false,
|
|
643
|
+
hideUserIcon: false,
|
|
644
|
+
isMobileView: false,
|
|
645
|
+
vuetifyOptions: undefined,
|
|
646
|
+
fullName: 'John Doe',
|
|
647
|
+
},
|
|
648
|
+
render: (args) => {
|
|
649
|
+
return {
|
|
650
|
+
components: { UserMenuBtn },
|
|
651
|
+
setup() {
|
|
652
|
+
return { args }
|
|
653
|
+
},
|
|
654
|
+
template: `
|
|
655
|
+
<div class="pa-4">
|
|
656
|
+
<UserMenuBtn v-bind="args">
|
|
657
|
+
<div class="ma-6 text-center">
|
|
658
|
+
<p class="text-h6">
|
|
659
|
+
Bienvenue, {{ args.fullName }}
|
|
660
|
+
</p>
|
|
661
|
+
|
|
662
|
+
<p class="mt-2">
|
|
663
|
+
La création de votre compte est en cours,<br> vos services seront accessibles dans les prochains jours.
|
|
664
|
+
</p>
|
|
665
|
+
</div>
|
|
666
|
+
</UserMenuBtn>
|
|
667
|
+
</div>`,
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
}
|
|
@@ -64,23 +64,25 @@
|
|
|
64
64
|
</VIcon>
|
|
65
65
|
</template>
|
|
66
66
|
<template #footer-list-item>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
<slot>
|
|
68
|
+
<VListItem
|
|
69
|
+
v-if="!hideLogoutBtn"
|
|
70
|
+
class="logout"
|
|
71
|
+
v-bind="options['logoutListItem']"
|
|
72
|
+
@click="$emit('logout')"
|
|
73
|
+
>
|
|
74
|
+
<div class="d-flex">
|
|
75
|
+
<VIcon
|
|
76
|
+
:icon="mdiLoginVariant"
|
|
77
|
+
class="mr-4"
|
|
78
|
+
v-bind="options['logoutIcon']"
|
|
79
|
+
/>
|
|
80
|
+
<VListItemTitle class="logout">
|
|
81
|
+
{{ props.logoutText }}
|
|
82
|
+
</VListItemTitle>
|
|
83
|
+
</div>
|
|
84
|
+
</VListItem>
|
|
85
|
+
</slot>
|
|
84
86
|
</template>
|
|
85
87
|
</SyBtnSelect>
|
|
86
88
|
</template>
|
package/src/components/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as DatePicker } from '@/components/DatePicker/DatePicker/DatePicker.vue'
|
|
2
|
+
export { useDateFormat } from '../composables/date/useDateFormatDayjs'
|
|
2
3
|
export { useFieldValidation } from '../composables/rules/useFieldValidation'
|
|
3
4
|
export type { RuleOptions } from '../composables/rules/useFieldValidation'
|
|
4
|
-
export { useNotificationService } from '../services/NotificationService'
|
|
5
5
|
export { useValidation } from '../composables/validation/useValidation'
|
|
6
|
-
export {
|
|
6
|
+
export { useNotificationService } from '../services/NotificationService'
|
|
7
7
|
export { default as Accordion } from './Accordion/Accordion.vue'
|
|
8
8
|
export { default as BackBtn } from './BackBtn/BackBtn.vue'
|
|
9
9
|
export { default as BackToTopBtn } from './BackToTopBtn/BackToTopBtn.vue'
|
|
@@ -23,8 +23,8 @@ export { default as SyTextField } from './Customs/SyTextField/SyTextField.vue'
|
|
|
23
23
|
export { default as DataList } from './DataList/DataList.vue'
|
|
24
24
|
export { default as DataListGroup } from './DataListGroup/DataListGroup.vue'
|
|
25
25
|
export { default as DataListItem } from './DataListItem/DataListItem.vue'
|
|
26
|
-
export { default as DialogBox } from './DialogBox/DialogBox.vue'
|
|
27
26
|
export { default as DiacriticPicker } from './DiacriticPicker/DiacriticPicker.vue'
|
|
27
|
+
export { default as DialogBox } from './DialogBox/DialogBox.vue'
|
|
28
28
|
export { default as DownloadBtn } from './DownloadBtn/DownloadBtn.vue'
|
|
29
29
|
export { default as ErrorPage } from './ErrorPage/ErrorPage.vue'
|
|
30
30
|
export { default as ExternalLinks } from './ExternalLinks/ExternalLinks.vue'
|
|
@@ -45,7 +45,6 @@ export { default as HeaderMenuBtn } from './HeaderBar/HeaderMenuBtn/HeaderMenuBt
|
|
|
45
45
|
export { default as HeaderLoading } from './HeaderLoading/HeaderLoading.vue'
|
|
46
46
|
export { default as HeaderNavigationBar } from './HeaderNavigationBar/HeaderNavigationBar.vue'
|
|
47
47
|
export { default as HeaderToolbar } from './HeaderToolbar/HeaderToolbar.vue'
|
|
48
|
-
export { indicatifs } from './PhoneField/indicatifs'
|
|
49
48
|
export { default as LangBtn } from './LangBtn/LangBtn.vue'
|
|
50
49
|
export { default as Logo } from './Logo/Logo.vue'
|
|
51
50
|
export { default as LogoBrandSection } from './LogoBrandSection/LogoBrandSection.vue'
|
|
@@ -59,6 +58,7 @@ export { default as PageContainer } from './PageContainer/PageContainer.vue'
|
|
|
59
58
|
export { default as PaginatedTable } from './PaginatedTable/PaginatedTable.vue'
|
|
60
59
|
export { default as PasswordField } from './PasswordField/PasswordField.vue'
|
|
61
60
|
export { default as PeriodField } from './PeriodField/PeriodField.vue'
|
|
61
|
+
export { indicatifs } from './PhoneField/indicatifs'
|
|
62
62
|
export { default as PhoneField } from './PhoneField/PhoneField.vue'
|
|
63
63
|
export { default as RangeField } from './RangeField/RangeField.vue'
|
|
64
64
|
export { default as RatingPicker } from './RatingPicker/RatingPicker.vue'
|
|
@@ -68,9 +68,11 @@ export { default as SkipLink } from './SkipLink/SkipLink.vue'
|
|
|
68
68
|
export { default as SocialMediaLinks } from './SocialMediaLinks/SocialMediaLinks.vue'
|
|
69
69
|
export { default as SubHeader } from './SubHeader/SubHeader.vue'
|
|
70
70
|
export { default as SyAlert } from './SyAlert/SyAlert.vue'
|
|
71
|
+
export { default as SyCheckbox } from './Customs/SyCheckbox/SyCheckbox.vue'
|
|
71
72
|
export { default as SyTextArea } from './SyTextArea/SyTextArea.vue'
|
|
73
|
+
export { default as SyServerTable } from './Tables/SyServerTable/SyServerTable.vue'
|
|
74
|
+
export { default as SyTable } from './Tables/SyTable/SyTable.vue'
|
|
72
75
|
export { default as TableToolbar } from './TableToolbar/TableToolbar.vue'
|
|
76
|
+
export { default as ToolbarContainer } from './ToolbarContainer/ToolbarContainer.vue'
|
|
73
77
|
export { default as UploadWorkflow } from './UploadWorkflow/UploadWorkflow.vue'
|
|
74
78
|
export { default as UserMenuBtn } from './UserMenuBtn/UserMenuBtn.vue'
|
|
75
|
-
export { default as SyTable } from './Tables/SyTable/SyTable.vue'
|
|
76
|
-
export { default as SyServerTable } from './Tables/SyServerTable/SyServerTable.vue'
|