@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
2
|
import DatePicker from '../DatePicker/DatePicker.vue'
|
|
3
3
|
import { ref } from 'vue'
|
|
4
|
+
import { fn } from '@storybook/test'
|
|
4
5
|
|
|
5
6
|
const meta = {
|
|
6
7
|
title: 'Composants/Formulaires/DatePicker/DateInput',
|
|
@@ -13,6 +14,7 @@ const meta = {
|
|
|
13
14
|
parameters: {
|
|
14
15
|
layout: 'fullscreen',
|
|
15
16
|
controls: { exclude: ['modelValue'] },
|
|
17
|
+
actions: { argTypesRegex: '^on.*' },
|
|
16
18
|
},
|
|
17
19
|
argTypes: {
|
|
18
20
|
placeholder: {
|
|
@@ -89,6 +91,10 @@ const meta = {
|
|
|
89
91
|
control: 'boolean',
|
|
90
92
|
description: 'Sélection de plage de dates',
|
|
91
93
|
},
|
|
94
|
+
autoClamp: {
|
|
95
|
+
control: 'boolean',
|
|
96
|
+
description: 'Active le clamping automatique des dates',
|
|
97
|
+
},
|
|
92
98
|
},
|
|
93
99
|
} as Meta<typeof DatePicker>
|
|
94
100
|
|
|
@@ -98,17 +104,25 @@ type Story = StoryObj<typeof meta>
|
|
|
98
104
|
|
|
99
105
|
export const Default: Story = {
|
|
100
106
|
args: {
|
|
101
|
-
noCalendar: true,
|
|
102
|
-
format: 'DD/MM/YYYY',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
'noCalendar': true,
|
|
108
|
+
'format': 'DD/MM/YYYY',
|
|
109
|
+
'dateFormatReturn': '',
|
|
110
|
+
'placeholder': 'JJ/MM/AAAA',
|
|
111
|
+
'label': 'Date avec règles de validation',
|
|
112
|
+
'required': true,
|
|
113
|
+
'disabled': false,
|
|
114
|
+
'readonly': false,
|
|
115
|
+
'isOutlined': true,
|
|
116
|
+
'displayIcon': true,
|
|
117
|
+
'displayAppendIcon': false,
|
|
118
|
+
'noIcon': false,
|
|
119
|
+
'displayRange': false,
|
|
120
|
+
'displayPrependIcon': false,
|
|
121
|
+
'showSuccessMessages': true,
|
|
122
|
+
'disableErrorHandling': false,
|
|
123
|
+
'onUpdate:modelValue': fn(),
|
|
124
|
+
'onFocus': fn(),
|
|
125
|
+
'onBlur': fn(),
|
|
112
126
|
},
|
|
113
127
|
render(args) {
|
|
114
128
|
const date = ref<string | null>(null)
|
|
@@ -132,6 +146,54 @@ export const Default: Story = {
|
|
|
132
146
|
},
|
|
133
147
|
}
|
|
134
148
|
|
|
149
|
+
export const Required: Story = {
|
|
150
|
+
args: {
|
|
151
|
+
'noCalendar': true,
|
|
152
|
+
'format': 'DD/MM/YYYY',
|
|
153
|
+
'dateFormatReturn': '',
|
|
154
|
+
'placeholder': 'JJ/MM/AAAA',
|
|
155
|
+
'label': 'Date avec règles de validation',
|
|
156
|
+
'required': true,
|
|
157
|
+
'disabled': false,
|
|
158
|
+
'readonly': false,
|
|
159
|
+
'isOutlined': true,
|
|
160
|
+
'displayIcon': true,
|
|
161
|
+
'displayAppendIcon': false,
|
|
162
|
+
'noIcon': false,
|
|
163
|
+
'displayRange': false,
|
|
164
|
+
'displayPrependIcon': false,
|
|
165
|
+
'showSuccessMessages': true,
|
|
166
|
+
'disableErrorHandling': false,
|
|
167
|
+
'onUpdate:modelValue': fn(),
|
|
168
|
+
'onFocus': fn(),
|
|
169
|
+
'onBlur': fn(),
|
|
170
|
+
},
|
|
171
|
+
render(args) {
|
|
172
|
+
const date = ref<string | null>(null)
|
|
173
|
+
return {
|
|
174
|
+
components: { DatePicker },
|
|
175
|
+
setup() {
|
|
176
|
+
return { args, date }
|
|
177
|
+
},
|
|
178
|
+
template: `
|
|
179
|
+
<div>
|
|
180
|
+
<h4 class="mb-4">Sans astérisque :</h4>
|
|
181
|
+
<DatePicker
|
|
182
|
+
v-model="date"
|
|
183
|
+
v-bind="args"
|
|
184
|
+
/>
|
|
185
|
+
<h4 class="mb-4">Avec astérisque :</h4>
|
|
186
|
+
<DatePicker
|
|
187
|
+
v-model="date"
|
|
188
|
+
v-bind="args"
|
|
189
|
+
displayAsterisk
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
`,
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
}
|
|
196
|
+
|
|
135
197
|
export const EuropeanFormat: Story = {
|
|
136
198
|
parameters: {
|
|
137
199
|
sourceCode: [
|
|
@@ -148,18 +210,32 @@ export const EuropeanFormat: Story = {
|
|
|
148
210
|
no-icon
|
|
149
211
|
no-calendar
|
|
150
212
|
/>
|
|
213
|
+
|
|
214
|
+
<DatePicker
|
|
215
|
+
v-model="date"
|
|
216
|
+
format="DD/MM/YYYY"
|
|
217
|
+
date-format-return="YYYY/MM/DD"
|
|
218
|
+
placeholder="JJ/MM/AAAA"
|
|
219
|
+
required
|
|
220
|
+
no-icon
|
|
221
|
+
no-calendar
|
|
222
|
+
displayAsterisk
|
|
223
|
+
/>
|
|
151
224
|
</template>
|
|
152
225
|
`,
|
|
153
226
|
},
|
|
154
227
|
],
|
|
155
228
|
},
|
|
156
229
|
args: {
|
|
157
|
-
noCalendar: true,
|
|
158
|
-
format: 'DD/MM/YYYY',
|
|
159
|
-
dateFormatReturn: 'YYYY/MM/DD',
|
|
160
|
-
placeholder: 'JJ/MM/AAAA',
|
|
161
|
-
required: true,
|
|
162
|
-
noIcon: true,
|
|
230
|
+
'noCalendar': true,
|
|
231
|
+
'format': 'DD/MM/YYYY',
|
|
232
|
+
'dateFormatReturn': 'YYYY/MM/DD',
|
|
233
|
+
'placeholder': 'JJ/MM/AAAA',
|
|
234
|
+
'required': true,
|
|
235
|
+
'noIcon': true,
|
|
236
|
+
'onUpdate:modelValue': fn(),
|
|
237
|
+
'onFocus': fn(),
|
|
238
|
+
'onBlur': fn(),
|
|
163
239
|
},
|
|
164
240
|
render(args) {
|
|
165
241
|
const date = ref<string | null>(null)
|
|
@@ -214,12 +290,12 @@ export const CustomRules: Story = {
|
|
|
214
290
|
],
|
|
215
291
|
},
|
|
216
292
|
args: {
|
|
217
|
-
noCalendar: true,
|
|
218
|
-
format: 'DD/MM/YYYY',
|
|
219
|
-
dateFormatReturn: 'DD/MM/YYYY',
|
|
220
|
-
placeholder: 'DD/MM/YYYY',
|
|
221
|
-
required: true,
|
|
222
|
-
customRules: [{
|
|
293
|
+
'noCalendar': true,
|
|
294
|
+
'format': 'DD/MM/YYYY',
|
|
295
|
+
'dateFormatReturn': 'DD/MM/YYYY',
|
|
296
|
+
'placeholder': 'DD/MM/YYYY',
|
|
297
|
+
'required': true,
|
|
298
|
+
'customRules': [{
|
|
223
299
|
type: 'custom',
|
|
224
300
|
options: {
|
|
225
301
|
validate: (value: string) => !value || !value.includes('2024'),
|
|
@@ -228,6 +304,9 @@ export const CustomRules: Story = {
|
|
|
228
304
|
fieldIdentifier: 'date',
|
|
229
305
|
},
|
|
230
306
|
}],
|
|
307
|
+
'onUpdate:modelValue': fn(),
|
|
308
|
+
'onFocus': fn(),
|
|
309
|
+
'onBlur': fn(),
|
|
231
310
|
},
|
|
232
311
|
render(args) {
|
|
233
312
|
const date = ref<string | null>('21/12/2024')
|
|
@@ -282,10 +361,10 @@ export const WarningRules: Story = {
|
|
|
282
361
|
],
|
|
283
362
|
},
|
|
284
363
|
args: {
|
|
285
|
-
noCalendar: true,
|
|
286
|
-
format: 'DD/MM/YYYY',
|
|
287
|
-
placeholder: 'JJ/MM/AAAA',
|
|
288
|
-
customWarningRules: [{
|
|
364
|
+
'noCalendar': true,
|
|
365
|
+
'format': 'DD/MM/YYYY',
|
|
366
|
+
'placeholder': 'JJ/MM/AAAA',
|
|
367
|
+
'customWarningRules': [{
|
|
289
368
|
type: 'custom',
|
|
290
369
|
options: {
|
|
291
370
|
validate: (value: string) => !value || !value.includes('2025'),
|
|
@@ -295,6 +374,9 @@ export const WarningRules: Story = {
|
|
|
295
374
|
isWarning: true,
|
|
296
375
|
},
|
|
297
376
|
}],
|
|
377
|
+
'onUpdate:modelValue': fn(),
|
|
378
|
+
'onFocus': fn(),
|
|
379
|
+
'onBlur': fn(),
|
|
298
380
|
},
|
|
299
381
|
render(args) {
|
|
300
382
|
const date = ref<string | null>('20/12/2025')
|
|
@@ -340,10 +422,13 @@ export const WithAppendIcon: Story = {
|
|
|
340
422
|
],
|
|
341
423
|
},
|
|
342
424
|
args: {
|
|
343
|
-
noCalendar: true,
|
|
344
|
-
format: 'DD/MM/YYYY',
|
|
345
|
-
placeholder: 'JJ/MM/AAAA',
|
|
346
|
-
displayAppendIcon: true,
|
|
425
|
+
'noCalendar': true,
|
|
426
|
+
'format': 'DD/MM/YYYY',
|
|
427
|
+
'placeholder': 'JJ/MM/AAAA',
|
|
428
|
+
'displayAppendIcon': true,
|
|
429
|
+
'onUpdate:modelValue': fn(),
|
|
430
|
+
'onFocus': fn(),
|
|
431
|
+
'onBlur': fn(),
|
|
347
432
|
},
|
|
348
433
|
render(args) {
|
|
349
434
|
const date = ref<string | null>(null)
|
|
@@ -458,6 +543,131 @@ export const WithErrorDisabled: Story = {
|
|
|
458
543
|
},
|
|
459
544
|
}
|
|
460
545
|
|
|
546
|
+
export const AutoClampFeature: Story = {
|
|
547
|
+
parameters: {
|
|
548
|
+
sourceCode: [
|
|
549
|
+
{
|
|
550
|
+
name: 'Template',
|
|
551
|
+
code: `
|
|
552
|
+
<template>
|
|
553
|
+
<div class="d-flex flex-column">
|
|
554
|
+
<h3>Démonstration de l'auto clamp dans DateTextInput</h3>
|
|
555
|
+
|
|
556
|
+
<h4 class="mt-4">Format DD/MM/YYYY (séparateur /)</h4>
|
|
557
|
+
<DatePicker
|
|
558
|
+
v-model="dateSlash"
|
|
559
|
+
placeholder="Saisie avec auto clamp - séparateur /"
|
|
560
|
+
format="DD/MM/YYYY"
|
|
561
|
+
noCalendar
|
|
562
|
+
autoClamp
|
|
563
|
+
/>
|
|
564
|
+
|
|
565
|
+
<h4 class="mt-4">Format DD-MM-YYYY (séparateur -)</h4>
|
|
566
|
+
<DatePicker
|
|
567
|
+
v-model="dateDash"
|
|
568
|
+
placeholder="Saisie avec auto clamp - séparateur -"
|
|
569
|
+
format="DD-MM-YYYY"
|
|
570
|
+
noCalendar
|
|
571
|
+
|
|
572
|
+
/>
|
|
573
|
+
|
|
574
|
+
<h4 class="mt-4">Format YYYY.MM.DD (séparateur .)</h4>
|
|
575
|
+
<DatePicker
|
|
576
|
+
v-model="dateDot"
|
|
577
|
+
placeholder="Saisie avec auto clamp - séparateur ."
|
|
578
|
+
format="YYYY.MM.DD"
|
|
579
|
+
noCalendar
|
|
580
|
+
/>
|
|
581
|
+
|
|
582
|
+
<h4 class="mt-4">Mode plage de dates (séparateur /)</h4>
|
|
583
|
+
<DatePicker
|
|
584
|
+
v-model="dateRange"
|
|
585
|
+
placeholder="Saisie plage avec auto clamp"
|
|
586
|
+
format="DD/MM/YYYY"
|
|
587
|
+
displayRange
|
|
588
|
+
noCalendar
|
|
589
|
+
autoClamp
|
|
590
|
+
/>
|
|
591
|
+
</div>
|
|
592
|
+
</template>
|
|
593
|
+
`,
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: 'Script',
|
|
597
|
+
code: `
|
|
598
|
+
<script setup lang="ts">
|
|
599
|
+
import { ref } from 'vue'
|
|
600
|
+
import { DatePicker } from '@cnamts/synapse'
|
|
601
|
+
|
|
602
|
+
const dateSlash = ref('')
|
|
603
|
+
const dateDash = ref('')
|
|
604
|
+
const dateDot = ref('')
|
|
605
|
+
const dateRange = ref('')
|
|
606
|
+
</script>
|
|
607
|
+
`,
|
|
608
|
+
},
|
|
609
|
+
],
|
|
610
|
+
},
|
|
611
|
+
render: () => {
|
|
612
|
+
return {
|
|
613
|
+
components: { DatePicker },
|
|
614
|
+
setup() {
|
|
615
|
+
const dateSlash = ref('')
|
|
616
|
+
const dateDash = ref('')
|
|
617
|
+
const dateDot = ref('')
|
|
618
|
+
const dateRange = ref('')
|
|
619
|
+
return { dateSlash, dateDash, dateDot, dateRange }
|
|
620
|
+
},
|
|
621
|
+
template: `
|
|
622
|
+
<div class="d-flex flex-column pa-4">
|
|
623
|
+
<h3>Démonstration de l'auto clamp dans DateTextInput</h3>
|
|
624
|
+
<div class="mb-4 mt-2">Saisissez uniquement des chiffres - les séparateurs seront ajoutés automatiquement selon le format défini</div>
|
|
625
|
+
|
|
626
|
+
<h4 class="mb-2">Format DD/MM/YYYY (séparateur /)</h4>
|
|
627
|
+
<DatePicker
|
|
628
|
+
v-model="dateSlash"
|
|
629
|
+
placeholder="Saisie avec auto clamp - séparateur /"
|
|
630
|
+
format="DD/MM/YYYY"
|
|
631
|
+
noCalendar
|
|
632
|
+
autoClamp
|
|
633
|
+
/>
|
|
634
|
+
<div class="caption mb-4">Valeur actuelle: {{ dateSlash || 'aucune date saisie' }}</div>
|
|
635
|
+
|
|
636
|
+
<h4 class="mb-2">Format DD-MM-YYYY (séparateur -)</h4>
|
|
637
|
+
<DatePicker
|
|
638
|
+
v-model="dateDash"
|
|
639
|
+
placeholder="Saisie avec auto clamp - séparateur -"
|
|
640
|
+
format="DD-MM-YYYY"
|
|
641
|
+
noCalendar
|
|
642
|
+
autoClamp
|
|
643
|
+
/>
|
|
644
|
+
<div class="caption mb-4">Valeur actuelle: {{ dateDash || 'aucune date saisie' }}</div>
|
|
645
|
+
|
|
646
|
+
<h4 class="mb-2">Format YYYY.MM.DD (séparateur .)</h4>
|
|
647
|
+
<DatePicker
|
|
648
|
+
v-model="dateDot"
|
|
649
|
+
placeholder="Saisie avec auto clamp - séparateur ."
|
|
650
|
+
format="YYYY.MM.DD"
|
|
651
|
+
noCalendar
|
|
652
|
+
/>
|
|
653
|
+
<div class="caption mb-4">Valeur actuelle: {{ dateDot || 'aucune date saisie' }}</div>
|
|
654
|
+
|
|
655
|
+
<h4 class="mb-2">Mode plage de dates (séparateur /)</h4>
|
|
656
|
+
<DatePicker
|
|
657
|
+
v-model="dateRange"
|
|
658
|
+
placeholder="Saisie plage avec auto clamp"
|
|
659
|
+
format="DD/MM/YYYY"
|
|
660
|
+
displayRange
|
|
661
|
+
noCalendar
|
|
662
|
+
autoClamp
|
|
663
|
+
/>
|
|
664
|
+
<div class="caption mb-4">Valeur actuelle: {{ dateRange || 'aucune plage saisie' }}</div>
|
|
665
|
+
</div>
|
|
666
|
+
`,
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
}
|
|
670
|
+
|
|
461
671
|
export const DifferentFormats: Story = {
|
|
462
672
|
parameters: {
|
|
463
673
|
sourceCode: [
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Date input and editing
|
|
4
4
|
export { useDateInputEditing } from './useDateInputEditing'
|
|
5
5
|
export { useDateRangeInput } from './useDateRangeInput'
|
|
6
|
+
export { useDateAutoClamp } from './useDateAutoClamp'
|
|
6
7
|
|
|
7
8
|
// Date selection and validation
|
|
8
9
|
export { useDateSelection } from './useDateSelection'
|
|
@@ -20,3 +21,4 @@ export { useInputBlurHandler } from './useInputBlurHandler'
|
|
|
20
21
|
export { useTodayButton } from './useTodayButton'
|
|
21
22
|
export { useWeekendDays } from './useWeekendDays'
|
|
22
23
|
export { useMonthButtonCustomization } from './useMonthButtonCustomization'
|
|
24
|
+
export { useAsteriskDisplay } from './useAsteriskDisplay'
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { useDateAutoClamp } from '../useDateAutoClamp'
|
|
3
|
+
|
|
4
|
+
describe('useDateAutoClamp', () => {
|
|
5
|
+
describe('clampDayToValidDate', () => {
|
|
6
|
+
it('devrait retourner le jour inchangé si valide', () => {
|
|
7
|
+
const { clampDayToValidDate } = useDateAutoClamp()
|
|
8
|
+
|
|
9
|
+
// Jour valide dans un mois standard
|
|
10
|
+
const result1 = clampDayToValidDate(15, 0, 2023) // 15 janvier 2023
|
|
11
|
+
expect(result1.day).toBe(15)
|
|
12
|
+
expect(result1.adjusted).toBe(false)
|
|
13
|
+
|
|
14
|
+
// Jour valide dans un mois de 30 jours
|
|
15
|
+
const result2 = clampDayToValidDate(30, 3, 2023) // 30 avril 2023
|
|
16
|
+
expect(result2.day).toBe(30)
|
|
17
|
+
expect(result2.adjusted).toBe(false)
|
|
18
|
+
|
|
19
|
+
// Jour valide dans un mois de 31 jours
|
|
20
|
+
const result3 = clampDayToValidDate(31, 0, 2023) // 31 janvier 2023
|
|
21
|
+
expect(result3.day).toBe(31)
|
|
22
|
+
expect(result3.adjusted).toBe(false)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('devrait ajuster le jour au dernier jour du mois si invalide', () => {
|
|
26
|
+
const { clampDayToValidDate } = useDateAutoClamp()
|
|
27
|
+
|
|
28
|
+
// Jour invalide dans un mois de 30 jours
|
|
29
|
+
const result1 = clampDayToValidDate(31, 3, 2023) // 31 avril 2023 -> 30 avril 2023
|
|
30
|
+
expect(result1.day).toBe(30)
|
|
31
|
+
expect(result1.adjusted).toBe(true)
|
|
32
|
+
|
|
33
|
+
// Jour invalide dans un mois de 28 jours (février non bissextile)
|
|
34
|
+
const result2 = clampDayToValidDate(29, 1, 2023) // 29 février 2023 -> 28 février 2023
|
|
35
|
+
expect(result2.day).toBe(28)
|
|
36
|
+
expect(result2.adjusted).toBe(true)
|
|
37
|
+
|
|
38
|
+
// Jour très invalide
|
|
39
|
+
const result3 = clampDayToValidDate(45, 5, 2023) // 45 juin 2023 -> 30 juin 2023
|
|
40
|
+
expect(result3.day).toBe(30)
|
|
41
|
+
expect(result3.adjusted).toBe(true)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('devrait gérer correctement les années bissextiles', () => {
|
|
45
|
+
const { clampDayToValidDate } = useDateAutoClamp()
|
|
46
|
+
|
|
47
|
+
// 29 février sur une année bissextile
|
|
48
|
+
const result1 = clampDayToValidDate(29, 1, 2024) // 29 février 2024
|
|
49
|
+
expect(result1.day).toBe(29)
|
|
50
|
+
expect(result1.adjusted).toBe(false)
|
|
51
|
+
|
|
52
|
+
// 29 février sur une année non bissextile
|
|
53
|
+
const result2 = clampDayToValidDate(29, 1, 2023) // 29 février 2023 -> 28 février 2023
|
|
54
|
+
expect(result2.day).toBe(28)
|
|
55
|
+
expect(result2.adjusted).toBe(true)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe('autoClampDate', () => {
|
|
60
|
+
it('devrait retourner la chaîne inchangée si vide', () => {
|
|
61
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
62
|
+
|
|
63
|
+
const result = autoClampDate('', 'DD/MM/YYYY')
|
|
64
|
+
expect(result.clampedDate).toBe('')
|
|
65
|
+
expect(result.adjusted).toBe(false)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('devrait retourner la chaîne inchangée si la date est valide', () => {
|
|
69
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
70
|
+
|
|
71
|
+
// Date valide au format DD/MM/YYYY
|
|
72
|
+
const result1 = autoClampDate('15/01/2023', 'DD/MM/YYYY')
|
|
73
|
+
expect(result1.clampedDate).toBe('15/01/2023')
|
|
74
|
+
expect(result1.adjusted).toBe(false)
|
|
75
|
+
|
|
76
|
+
// Date valide au format MM/DD/YYYY
|
|
77
|
+
const result2 = autoClampDate('01/15/2023', 'MM/DD/YYYY')
|
|
78
|
+
expect(result2.clampedDate).toBe('01/15/2023')
|
|
79
|
+
expect(result2.adjusted).toBe(false)
|
|
80
|
+
|
|
81
|
+
// Date valide au format YYYY-MM-DD
|
|
82
|
+
const result3 = autoClampDate('2023-01-15', 'YYYY-MM-DD')
|
|
83
|
+
expect(result3.clampedDate).toBe('2023-01-15')
|
|
84
|
+
expect(result3.adjusted).toBe(false)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('devrait ajuster les dates invalides au format DD/MM/YYYY', () => {
|
|
88
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
89
|
+
|
|
90
|
+
// 31 avril -> 30 avril
|
|
91
|
+
const result1 = autoClampDate('31/04/2023', 'DD/MM/YYYY')
|
|
92
|
+
expect(result1.clampedDate).toBe('30/04/2023')
|
|
93
|
+
expect(result1.adjusted).toBe(true)
|
|
94
|
+
|
|
95
|
+
// 29 février 2023 (non bissextile) -> 28 février
|
|
96
|
+
const result2 = autoClampDate('29/02/2023', 'DD/MM/YYYY')
|
|
97
|
+
expect(result2.clampedDate).toBe('28/02/2023')
|
|
98
|
+
expect(result2.adjusted).toBe(true)
|
|
99
|
+
|
|
100
|
+
// 29 février 2024 (bissextile) reste inchangé
|
|
101
|
+
const result3 = autoClampDate('29/02/2024', 'DD/MM/YYYY')
|
|
102
|
+
expect(result3.clampedDate).toBe('29/02/2024')
|
|
103
|
+
expect(result3.adjusted).toBe(false)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('devrait ajuster les dates invalides au format MM/DD/YYYY', () => {
|
|
107
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
108
|
+
|
|
109
|
+
// Avril 31 -> Avril 30
|
|
110
|
+
const result1 = autoClampDate('04/31/2023', 'MM/DD/YYYY')
|
|
111
|
+
expect(result1.clampedDate).toBe('04/30/2023')
|
|
112
|
+
expect(result1.adjusted).toBe(true)
|
|
113
|
+
|
|
114
|
+
// Février 29 2023 (non bissextile) -> Février 28
|
|
115
|
+
const result2 = autoClampDate('02/29/2023', 'MM/DD/YYYY')
|
|
116
|
+
expect(result2.clampedDate).toBe('02/28/2023')
|
|
117
|
+
expect(result2.adjusted).toBe(true)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('devrait ajuster les dates invalides au format YYYY-MM-DD', () => {
|
|
121
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
122
|
+
|
|
123
|
+
// 2023-04-31 -> 2023-04-30
|
|
124
|
+
const result1 = autoClampDate('2023-04-31', 'YYYY-MM-DD')
|
|
125
|
+
expect(result1.clampedDate).toBe('2023-04-30')
|
|
126
|
+
expect(result1.adjusted).toBe(true)
|
|
127
|
+
|
|
128
|
+
// 2023-02-29 (non bissextile) -> 2023-02-28
|
|
129
|
+
const result2 = autoClampDate('2023-02-29', 'YYYY-MM-DD')
|
|
130
|
+
expect(result2.clampedDate).toBe('2023-02-28')
|
|
131
|
+
expect(result2.adjusted).toBe(true)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('devrait gérer différents séparateurs', () => {
|
|
135
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
136
|
+
|
|
137
|
+
// Format avec tiret
|
|
138
|
+
const result1 = autoClampDate('31-04-2023', 'DD-MM-YYYY')
|
|
139
|
+
expect(result1.clampedDate).toBe('30-04-2023')
|
|
140
|
+
expect(result1.adjusted).toBe(true)
|
|
141
|
+
|
|
142
|
+
// Format avec point
|
|
143
|
+
const result2 = autoClampDate('31.04.2023', 'DD.MM.YYYY')
|
|
144
|
+
expect(result2.clampedDate).toBe('30.04.2023')
|
|
145
|
+
expect(result2.adjusted).toBe(true)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('devrait conserver le format de jour (D vs DD)', () => {
|
|
149
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
150
|
+
|
|
151
|
+
// Format avec D (jour sans zéro initial)
|
|
152
|
+
const result1 = autoClampDate('31/4/2023', 'D/M/YYYY')
|
|
153
|
+
expect(result1.clampedDate).toBe('30/4/2023')
|
|
154
|
+
expect(result1.adjusted).toBe(true)
|
|
155
|
+
|
|
156
|
+
// Format avec DD (jour avec zéro initial)
|
|
157
|
+
const result2 = autoClampDate('31/04/2023', 'DD/MM/YYYY')
|
|
158
|
+
expect(result2.clampedDate).toBe('30/04/2023')
|
|
159
|
+
expect(result2.adjusted).toBe(true)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('devrait retourner la chaîne originale si le format ne correspond pas', () => {
|
|
163
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
164
|
+
|
|
165
|
+
// Nombre de parties différent
|
|
166
|
+
const result1 = autoClampDate('31/04', 'DD/MM/YYYY')
|
|
167
|
+
expect(result1.clampedDate).toBe('31/04')
|
|
168
|
+
expect(result1.adjusted).toBe(false)
|
|
169
|
+
|
|
170
|
+
// Contient des caractères non numériques
|
|
171
|
+
const result2 = autoClampDate('31/04/202a', 'DD/MM/YYYY')
|
|
172
|
+
expect(result2.clampedDate).toBe('30/04/202a')
|
|
173
|
+
expect(result2.adjusted).toBe(true)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('devrait gérer les cas limites', () => {
|
|
177
|
+
const { autoClampDate } = useDateAutoClamp()
|
|
178
|
+
|
|
179
|
+
// Mois invalide
|
|
180
|
+
const result1 = autoClampDate('15/13/2023', 'DD/MM/YYYY')
|
|
181
|
+
expect(result1.clampedDate).toBe('15/13/2023')
|
|
182
|
+
expect(result1.adjusted).toBe(false)
|
|
183
|
+
|
|
184
|
+
// Jour négatif
|
|
185
|
+
const result2 = autoClampDate('-1/04/2023', 'DD/MM/YYYY')
|
|
186
|
+
expect(result2.clampedDate).toBe('-1/04/2023')
|
|
187
|
+
expect(result2.adjusted).toBe(false)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
})
|