@zap-wunschlachen/wl-shared-components 1.0.76 → 1.0.78
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/.github/workflows/playwright.yml +229 -229
- package/.github/workflows/static.yml +61 -61
- package/.github/workflows/update-snapshots.yml +37 -37
- package/.prettierrc.json +8 -8
- package/.storybook/main.ts +18 -18
- package/.storybook/preview.ts +37 -37
- package/.storybook/storyWrapper.vue +18 -18
- package/.storybook/withVuetifyTheme.decorator.ts +21 -21
- package/App.vue +139 -139
- package/README.md +56 -56
- package/docs/assets.md +62 -62
- package/heroicons.ts +75 -75
- package/index.html +19 -19
- package/package.json +71 -71
- package/playwright.config.ts +48 -48
- package/public/background.svg +60 -60
- package/public/style.css +187 -187
- package/public/technologies.svg +22 -22
- package/scripts/check-translations.ts +352 -352
- package/src/assets/css/base.css +242 -242
- package/src/assets/css/variables.css +176 -176
- package/src/components/Accordion/Accordion.css +65 -65
- package/src/components/Accordion/AccordionGroup.vue +88 -88
- package/src/components/Accordion/AccordionItem.vue +272 -272
- package/src/components/Accordion/presets/default.css +4 -4
- package/src/components/Accordion/presets/elevated.css +25 -25
- package/src/components/Accordion/presets/filled.css +26 -26
- package/src/components/Accordion/presets/index.css +5 -5
- package/src/components/Accordion/presets/plain.css +34 -34
- package/src/components/Appointment/Card/Actions.css +54 -54
- package/src/components/Appointment/Card/Actions.vue +99 -99
- package/src/components/Appointment/Card/AnamneseNotification.css +20 -20
- package/src/components/Appointment/Card/AnamneseNotification.vue +23 -23
- package/src/components/Appointment/Card/Card.css +99 -99
- package/src/components/Appointment/Card/Card.vue +97 -97
- package/src/components/Appointment/Card/Details.css +62 -62
- package/src/components/Appointment/Card/Details.vue +44 -44
- package/src/components/Audio/Audio.vue +187 -187
- package/src/components/Audio/Waveform.vue +118 -118
- package/src/components/Banner/Banner.css +29 -29
- package/src/components/Banner/Banner.vue +89 -89
- package/src/components/Button/Button.vue +257 -257
- package/src/components/CheckBox/CheckBox.css +234 -234
- package/src/components/CheckBox/Checkbox.vue +184 -184
- package/src/components/DateInput/DateInput.css +2 -2
- package/src/components/DateInput/DateInput.vue +376 -370
- package/src/components/Dialog/Dialog.css +6 -6
- package/src/components/Dialog/Dialog.vue +46 -46
- package/src/components/EditField/EditField.css +19 -19
- package/src/components/EditField/EditField.vue +211 -211
- package/src/components/ErrorPage/ErrorPage.css +172 -172
- package/src/components/IconBullet/IconBullet.vue +104 -104
- package/src/components/IconBullet/IconBulletList.vue +55 -55
- package/src/components/Icons/AdvanceAppointments.vue +161 -161
- package/src/components/Icons/Audio/CloudFailed.vue +27 -27
- package/src/components/Icons/Audio/CloudSaved.vue +28 -28
- package/src/components/Icons/Audio/Delete.vue +22 -22
- package/src/components/Icons/Audio/Pause.vue +25 -25
- package/src/components/Icons/Audio/Play.vue +22 -22
- package/src/components/Icons/Calendar.vue +28 -28
- package/src/components/Icons/CalendarNotification.vue +137 -137
- package/src/components/Icons/Chair.vue +43 -43
- package/src/components/Icons/ChairNotification.vue +46 -46
- package/src/components/Icons/Circle.vue +66 -66
- package/src/components/Icons/FavIcon.vue +69 -69
- package/src/components/Icons/FilledCircle.vue +11 -11
- package/src/components/Icons/Group3.vue +57 -57
- package/src/components/Icons/Play.vue +16 -16
- package/src/components/Icons/RingNotification.vue +65 -65
- package/src/components/Icons/SolidArrowRight.vue +14 -14
- package/src/components/Icons/checkbox.vue +19 -19
- package/src/components/Icons/outlineChecked.vue +38 -38
- package/src/components/Input/Input.css +234 -234
- package/src/components/Input/Input.vue +281 -281
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.css +7 -7
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.vue +116 -116
- package/src/components/Laboratory/ChatBoxImage/ChatBoxImage.vue +81 -81
- package/src/components/Laboratory/ChatMessage/ChatMessage.vue +113 -113
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.css +4 -4
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.vue +99 -99
- package/src/components/Laboratory/ChatNotification/ChatNotification.vue +130 -130
- package/src/components/Laboratory/DocumentCard/DocumentCard.css +3 -3
- package/src/components/Laboratory/DocumentCard/DocumentCard.vue +50 -50
- package/src/components/Laboratory/DocumentCard/DocumentCardItem.vue +53 -53
- package/src/components/Laboratory/InfoCard/InfoCard.vue +162 -162
- package/src/components/Laboratory/MainColumnsBar/MainColumnsBar.vue +102 -102
- package/src/components/Laboratory/ProgressCircle/ProgressCircle.vue +152 -152
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.css +33 -33
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.vue +75 -75
- package/src/components/Laboratory/SelectionColumnBar/SelectionColumnBar.vue +92 -92
- package/src/components/Laboratory/StatusNotification/StatusNotification.vue +49 -49
- package/src/components/Laboratory/TagLabel/TagLabel.vue +126 -126
- package/src/components/Laboratory/TagLabelGroup/TagLabelGroup.vue +97 -97
- package/src/components/Laboratory/TicketCard/TicketCard.css +3 -3
- package/src/components/Laboratory/TicketCard/TicketCard.vue +143 -143
- package/src/components/Laboratory/TimeLine/TimeLineEvent.css +18 -18
- package/src/components/Laboratory/TimeLine/TimeLineEvent.vue +119 -119
- package/src/components/Laboratory/TimeLine/Timeline.css +4 -4
- package/src/components/Laboratory/TimeLine/Timeline.vue +30 -30
- package/src/components/Loader/Loader.css +78 -78
- package/src/components/MaintenanceBanner/MaintenanceBanner.css +353 -353
- package/src/components/MaintenanceBanner/MaintenanceBanner.vue +140 -140
- package/src/components/MaintenanceBanner/MaintenanceIllustration.vue +54 -54
- package/src/components/Modal/Modal.css +5 -5
- package/src/components/Modal/Modal.vue +29 -29
- package/src/components/NotificationBubble/NotificationBubble.css +4 -4
- package/src/components/NotificationBubble/NotificationBubble.vue +90 -90
- package/src/components/OtpInput/OtpInput.css +43 -43
- package/src/components/OtpInput/OtpInput.vue +181 -181
- package/src/components/PhoneInput/PhoneInput.css +151 -126
- package/src/components/PhoneInput/PhoneInput.vue +230 -139
- package/src/components/RadioGroup/RadioGroup.css +65 -0
- package/src/components/RadioGroup/RadioGroup.vue +134 -0
- package/src/components/Select/Select.css +172 -172
- package/src/components/Select/Select.vue +377 -377
- package/src/components/SelectAutocomplete/SelectAutocomplete.css +172 -172
- package/src/components/SelectAutocomplete/SelectAutocomplete.vue +414 -414
- package/src/components/TextArea/TextArea.css +269 -269
- package/src/components/TextArea/TextArea.vue +207 -207
- package/src/components/TickBox/TickBox.css +116 -116
- package/src/components/TickBox/TickBox.vue +172 -172
- package/src/components/Tile/Tile.css +106 -106
- package/src/components/Tile/Tile.vue +173 -173
- package/src/components/accessibility.css +218 -218
- package/src/components/index.ts +110 -109
- package/src/constants/iconEnums.ts +3 -3
- package/src/i18n/i18n.ts +15 -15
- package/src/i18n/locales/de.json +30 -30
- package/src/i18n/locales/en.json +30 -30
- package/src/index.ts +43 -43
- package/src/main.ts +11 -11
- package/src/pages/AccordionGroupPage.vue +873 -873
- package/src/pages/AllPage.vue +2483 -2365
- package/src/pages/SelectPage.vue +1302 -1302
- package/src/pages/TilePage.vue +902 -902
- package/src/plugins/vuetify.ts +54 -54
- package/src/shims-vue.d.ts +30 -30
- package/src/utils/index.ts +733 -733
- package/src/vite-env.d.ts +1 -1
- package/tests/unit/accessibility/component-a11y.spec.ts +657 -657
- package/tests/unit/components/Accordion/AccordionGroup.spec.ts +228 -228
- package/tests/unit/components/Accordion/AccordionItem.spec.ts +257 -257
- package/tests/unit/components/Appointment/AnamneseNotification.spec.ts +176 -176
- package/tests/unit/components/Appointment/Card/Actions.spec.ts +436 -436
- package/tests/unit/components/Appointment/Card/Card.spec.ts +531 -531
- package/tests/unit/components/Appointment/Card/Details.spec.ts +395 -395
- package/tests/unit/components/Audio/Audio.spec.ts +403 -403
- package/tests/unit/components/Audio/Waveform.spec.ts +483 -483
- package/tests/unit/components/Background/Background.spec.ts +177 -177
- package/tests/unit/components/Core/AnamneseAnswerDialog.spec.ts +344 -0
- package/tests/unit/components/Core/Banner.spec.ts +187 -0
- package/tests/unit/components/Core/Button.spec.ts +346 -346
- package/tests/unit/components/Core/Checkbox.spec.ts +544 -544
- package/tests/unit/components/Core/DateInput.spec.ts +702 -702
- package/tests/unit/components/Core/Dialog.spec.ts +448 -448
- package/tests/unit/components/Core/EditField.spec.ts +541 -541
- package/tests/unit/components/Core/Input.spec.ts +512 -512
- package/tests/unit/components/Core/List.spec.ts +163 -0
- package/tests/unit/components/Core/ListItem.spec.ts +205 -0
- package/tests/unit/components/Core/Modal.spec.ts +518 -518
- package/tests/unit/components/Core/NotificationBubble.spec.ts +606 -606
- package/tests/unit/components/Core/OtpInput.spec.ts +708 -708
- package/tests/unit/components/Core/PhoneInput.spec.ts +757 -619
- package/tests/unit/components/Core/RadioGroup.spec.ts +318 -0
- package/tests/unit/components/Core/Select.spec.ts +712 -712
- package/tests/unit/components/Core/SelectAutocomplete.spec.ts +361 -0
- package/tests/unit/components/Core/TextArea.spec.ts +565 -565
- package/tests/unit/components/Core/TickBox.spec.ts +836 -836
- package/tests/unit/components/Core/Tile.spec.ts +286 -0
- package/tests/unit/components/DateInput/DateInput.spec.ts +128 -0
- package/tests/unit/components/ErrorPage/ErrorPage.spec.ts +313 -313
- package/tests/unit/components/ErrorPage/ErrorPageLogo.spec.ts +153 -153
- package/tests/unit/components/IconBullet/IconBullet.spec.ts +356 -356
- package/tests/unit/components/IconBullet/IconBulletList.spec.ts +371 -371
- package/tests/unit/components/Icons/AdvanceAppointments.spec.ts +186 -186
- package/tests/unit/components/Icons/Audio/CloudFailed.spec.ts +108 -108
- package/tests/unit/components/Icons/Audio/CloudSaved.spec.ts +149 -149
- package/tests/unit/components/Icons/Audio/Delete.spec.ts +158 -158
- package/tests/unit/components/Icons/Audio/Pause.spec.ts +208 -208
- package/tests/unit/components/Icons/Audio/Play.spec.ts +217 -217
- package/tests/unit/components/Icons/CalendarNotification.spec.ts +193 -193
- package/tests/unit/components/Icons/Chair.spec.ts +241 -241
- package/tests/unit/components/Icons/ChairNotification.spec.ts +318 -318
- package/tests/unit/components/Icons/Circle.spec.ts +255 -255
- package/tests/unit/components/Icons/FavIcon.spec.ts +259 -259
- package/tests/unit/components/Icons/FilledCircle.spec.ts +274 -274
- package/tests/unit/components/Icons/Group3.spec.ts +362 -362
- package/tests/unit/components/Icons/Logo.spec.ts +229 -229
- package/tests/unit/components/Icons/MiniLogo.spec.ts +38 -38
- package/tests/unit/components/Icons/RingNotification.spec.ts +400 -400
- package/tests/unit/components/Icons/SolidArrowRight.spec.ts +49 -49
- package/tests/unit/components/Icons/calendar.spec.ts +293 -293
- package/tests/unit/components/Icons/checkbox.spec.ts +315 -315
- package/tests/unit/components/Icons/outlineChecked.spec.ts +441 -441
- package/tests/unit/components/Icons/play.spec.ts +315 -315
- package/tests/unit/components/Laboratory/AppointmentCard.spec.ts +167 -167
- package/tests/unit/components/Laboratory/ChatBoxImage.spec.ts +179 -179
- package/tests/unit/components/Laboratory/ChatMessage.spec.ts +263 -263
- package/tests/unit/components/Laboratory/ChatMessageBadge.spec.ts +282 -282
- package/tests/unit/components/Laboratory/ChatNotification.spec.ts +256 -256
- package/tests/unit/components/Laboratory/DocumentCard.spec.ts +228 -228
- package/tests/unit/components/Laboratory/DocumentCardItem.spec.ts +236 -236
- package/tests/unit/components/Laboratory/InfoCard.spec.ts +308 -308
- package/tests/unit/components/Laboratory/MainColumnsBar.spec.ts +251 -251
- package/tests/unit/components/Laboratory/ProgressCircle.spec.ts +290 -290
- package/tests/unit/components/Laboratory/ProgressLinear.spec.ts +275 -275
- package/tests/unit/components/Laboratory/SelectionColumnBar.spec.ts +288 -288
- package/tests/unit/components/Laboratory/StatusNotification.spec.ts +296 -296
- package/tests/unit/components/Laboratory/TagLabel.spec.ts +353 -353
- package/tests/unit/components/Laboratory/TagLabelGroup.spec.ts +377 -377
- package/tests/unit/components/Laboratory/TicketCard.spec.ts +351 -351
- package/tests/unit/components/Laboratory/TimeLineEvent.spec.ts +381 -381
- package/tests/unit/components/Laboratory/Timeline.spec.ts +419 -419
- package/tests/unit/components/Loader/Loader.spec.ts +197 -197
- package/tests/unit/components/MaintenanceBanner/MaintenanceBanner.spec.ts +302 -302
- package/tests/unit/constants/iconEnums.spec.ts +39 -39
- package/tests/unit/i18n/i18n.spec.ts +88 -88
- package/tests/unit/plugins/vuetify.spec.ts +182 -182
- package/tests/unit/setup.ts +237 -237
- package/tests/unit/src/components/index.spec.ts.skip +192 -192
- package/tests/unit/src/index.spec.ts.skip +182 -182
- package/tests/unit/src/main.spec.ts +111 -111
- package/tests/unit/utils/accessibility.spec.ts +318 -318
- package/tests/unit/utils/anamnese.spec.ts +531 -0
- package/tsconfig.json +26 -26
- package/vite.config.ts +29 -29
- package/vitest.config.ts +91 -91
|
@@ -1,371 +1,377 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Input
|
|
3
|
-
v-bind="$attrs"
|
|
4
|
-
ref="inputRef"
|
|
5
|
-
id="date-input"
|
|
6
|
-
class="wl-date-input"
|
|
7
|
-
:class="{
|
|
8
|
-
'edit-layout': layout === 'edit-field'
|
|
9
|
-
}"
|
|
10
|
-
:variant="variant"
|
|
11
|
-
:placeholder="placeholder"
|
|
12
|
-
v-model="formattedDate"
|
|
13
|
-
:success="isDefaultLayout ? inputState === 'success' : false"
|
|
14
|
-
:error="inputState === 'error'"
|
|
15
|
-
@input="onDateInput"
|
|
16
|
-
:hint="isDefaultLayout ? inputMessage : ''"
|
|
17
|
-
:hideDetails="isDefaultLayout ? inputState
|
|
18
|
-
type="tel"
|
|
19
|
-
for="date-input"
|
|
20
|
-
data-testid="root">
|
|
21
|
-
<template #append>
|
|
22
|
-
<div class="date-wrapper" tabIndex="0" @keydown.enter.prevent="nativeDate?.showPicker()" >
|
|
23
|
-
<v-icon class="date-icon" icon="heroicons:calendar" :color="colors['input_default_icon_color']" />
|
|
24
|
-
<input
|
|
25
|
-
ref="nativeDate"
|
|
26
|
-
type="date"
|
|
27
|
-
tabIndex="-1"
|
|
28
|
-
:min="nativeMin"
|
|
29
|
-
:max="nativeMax"
|
|
30
|
-
class="native-date"
|
|
31
|
-
:value="isoValue"
|
|
32
|
-
@input.stop="onNativeDateChange"
|
|
33
|
-
/>
|
|
34
|
-
</div>
|
|
35
|
-
</template>
|
|
36
|
-
</Input>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script setup lang="ts">
|
|
40
|
-
import {
|
|
41
|
-
parse, parseISO, format, isValid, getHours,
|
|
42
|
-
getMinutes,
|
|
43
|
-
getSeconds,
|
|
44
|
-
getMilliseconds,
|
|
45
|
-
set,
|
|
46
|
-
startOfDay
|
|
47
|
-
} from "date-fns";
|
|
48
|
-
import { ref, watch, defineProps, defineEmits, computed, nextTick, inject, onUnmounted } from "vue";
|
|
49
|
-
import Input from "../Input/Input.vue";
|
|
50
|
-
import './DateInput.css';
|
|
51
|
-
import { useI18n } from 'vue-i18n';
|
|
52
|
-
import { siteColors } from "../../utils/index";
|
|
53
|
-
|
|
54
|
-
// Inject theme colors from ThemeProvider, fallback to global siteColors
|
|
55
|
-
const injectedThemeColors = inject('themeColors', null);
|
|
56
|
-
const colors = computed(() => {
|
|
57
|
-
if (injectedThemeColors) {
|
|
58
|
-
return (injectedThemeColors as any).value;
|
|
59
|
-
}
|
|
60
|
-
return siteColors;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Define props to accept an initial date value
|
|
64
|
-
const props = withDefaults(defineProps<{
|
|
65
|
-
modelValue?: string | null;
|
|
66
|
-
layout?: "default" | "edit-field";
|
|
67
|
-
minDate?: Date | null;
|
|
68
|
-
minDateErrorMessage?: string;
|
|
69
|
-
maxDate?: Date | null;
|
|
70
|
-
maxDateErrorMessage?: string;
|
|
71
|
-
variant?: string;
|
|
72
|
-
placeholder?: string;
|
|
73
|
-
invalidDateErrorMessage?: string;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
if (props.
|
|
97
|
-
return props.
|
|
98
|
-
}
|
|
99
|
-
return '';
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<Input
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
ref="inputRef"
|
|
5
|
+
id="date-input"
|
|
6
|
+
class="wl-date-input"
|
|
7
|
+
:class="{
|
|
8
|
+
'edit-layout': layout === 'edit-field'
|
|
9
|
+
}"
|
|
10
|
+
:variant="variant"
|
|
11
|
+
:placeholder="placeholder"
|
|
12
|
+
v-model="formattedDate"
|
|
13
|
+
:success="isDefaultLayout ? inputState === 'success' && !props.error : false"
|
|
14
|
+
:error="inputState === 'error' || props.error"
|
|
15
|
+
@input="onDateInput"
|
|
16
|
+
:hint="isDefaultLayout ? (inputState === 'error' ? inputMessage : (props.error ? props.errorMessage : '')) : ''"
|
|
17
|
+
:hideDetails="isDefaultLayout ? !(inputState === 'error' || props.error) : true"
|
|
18
|
+
type="tel"
|
|
19
|
+
for="date-input"
|
|
20
|
+
data-testid="root">
|
|
21
|
+
<template #append>
|
|
22
|
+
<div class="date-wrapper" tabIndex="0" @keydown.enter.prevent="nativeDate?.showPicker()" >
|
|
23
|
+
<v-icon class="date-icon" icon="heroicons:calendar" :color="colors['input_default_icon_color']" />
|
|
24
|
+
<input
|
|
25
|
+
ref="nativeDate"
|
|
26
|
+
type="date"
|
|
27
|
+
tabIndex="-1"
|
|
28
|
+
:min="nativeMin"
|
|
29
|
+
:max="nativeMax"
|
|
30
|
+
class="native-date"
|
|
31
|
+
:value="isoValue"
|
|
32
|
+
@input.stop="onNativeDateChange"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
</Input>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import {
|
|
41
|
+
parse, parseISO, format, isValid, getHours,
|
|
42
|
+
getMinutes,
|
|
43
|
+
getSeconds,
|
|
44
|
+
getMilliseconds,
|
|
45
|
+
set,
|
|
46
|
+
startOfDay
|
|
47
|
+
} from "date-fns";
|
|
48
|
+
import { ref, watch, defineProps, defineEmits, computed, nextTick, inject, onUnmounted } from "vue";
|
|
49
|
+
import Input from "../Input/Input.vue";
|
|
50
|
+
import './DateInput.css';
|
|
51
|
+
import { useI18n } from 'vue-i18n';
|
|
52
|
+
import { siteColors } from "../../utils/index";
|
|
53
|
+
|
|
54
|
+
// Inject theme colors from ThemeProvider, fallback to global siteColors
|
|
55
|
+
const injectedThemeColors = inject('themeColors', null);
|
|
56
|
+
const colors = computed(() => {
|
|
57
|
+
if (injectedThemeColors) {
|
|
58
|
+
return (injectedThemeColors as any).value;
|
|
59
|
+
}
|
|
60
|
+
return siteColors;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Define props to accept an initial date value
|
|
64
|
+
const props = withDefaults(defineProps<{
|
|
65
|
+
modelValue?: string | null;
|
|
66
|
+
layout?: "default" | "edit-field";
|
|
67
|
+
minDate?: Date | null;
|
|
68
|
+
minDateErrorMessage?: string;
|
|
69
|
+
maxDate?: Date | null;
|
|
70
|
+
maxDateErrorMessage?: string;
|
|
71
|
+
variant?: string;
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
invalidDateErrorMessage?: string;
|
|
74
|
+
/** External error override (e.g. for "required" validation). Internal errors take priority. */
|
|
75
|
+
error?: boolean;
|
|
76
|
+
/** Error message shown when external error is active and no internal error exists. */
|
|
77
|
+
errorMessage?: string;
|
|
78
|
+
}>(), {
|
|
79
|
+
modelValue: null,
|
|
80
|
+
layout: 'default',
|
|
81
|
+
variant: 'outlined',
|
|
82
|
+
error: false,
|
|
83
|
+
errorMessage: '',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const emit = defineEmits<{
|
|
87
|
+
(event: "update:modelValue", value: string | null): void;
|
|
88
|
+
(event: "update:valid", isValid: boolean): void;
|
|
89
|
+
}>();
|
|
90
|
+
|
|
91
|
+
const { t } = useI18n();
|
|
92
|
+
|
|
93
|
+
const placeholder = computed(() => props.placeholder || t('wl.date_input.placeholder', 'TT.MM.JJJJ'));
|
|
94
|
+
const invalidDateMessage = computed(() => props.invalidDateErrorMessage || t('wl.date_input.invalid_date', 'Bitte ein gültiges Datum eingeben'));
|
|
95
|
+
const maxDateMessage = computed(() => {
|
|
96
|
+
if (props.maxDate && isValid(props.maxDate)) {
|
|
97
|
+
return props.maxDateErrorMessage || t('wl.date_input.max_date_error', { date: format(props.maxDate, 'dd.MM.yyyy') });
|
|
98
|
+
}
|
|
99
|
+
return '';
|
|
100
|
+
});
|
|
101
|
+
const minDateMessage = computed(() => {
|
|
102
|
+
if (props.minDate && isValid(props.minDate)) {
|
|
103
|
+
return props.minDateErrorMessage || t('wl.date_input.min_date_error', { date: format(props.minDate, 'dd.MM.yyyy') });
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const ISO_FORMAT = "yyyy-MM-dd";
|
|
109
|
+
const DISPLAY_FORMAT = "dd.MM.yyyy";
|
|
110
|
+
|
|
111
|
+
// Local reactive state for the input
|
|
112
|
+
const formattedDate = ref("");
|
|
113
|
+
const inputState = ref<"idle" | "error" | "success">("idle");
|
|
114
|
+
const inputMessage = ref("");
|
|
115
|
+
const nativeDate = ref<HTMLInputElement | null>(null)
|
|
116
|
+
const inputRef = ref(null)
|
|
117
|
+
const invalidCharTimeout = ref<ReturnType<typeof setTimeout> | null>(null)
|
|
118
|
+
|
|
119
|
+
// Cleanup timeout on unmount
|
|
120
|
+
onUnmounted(() => {
|
|
121
|
+
if (invalidCharTimeout.value) {
|
|
122
|
+
clearTimeout(invalidCharTimeout.value);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const isDefaultLayout = computed(() => props.layout === "default")
|
|
127
|
+
|
|
128
|
+
// Emit validity changes when inputState or external error changes
|
|
129
|
+
watch([inputState, () => props.error], ([newState, extError]) => {
|
|
130
|
+
emit('update:valid', newState === 'success' && !extError);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Error messages for invalid input
|
|
134
|
+
const invalidCharMessage = computed(() => t('wl.date_input.invalid_char', 'Dieses Zeichen ist nicht erlaubt'));
|
|
135
|
+
const formatErrorMessage = computed(() => t('wl.date_input.format_error', 'Das Datum muss im Format TT.MM.JJJJ sein'));
|
|
136
|
+
|
|
137
|
+
const isoValue = computed(() => {
|
|
138
|
+
const parsed = parse(formattedDate.value, DISPLAY_FORMAT, new Date());
|
|
139
|
+
return isValid(parsed) ? format(parsed, ISO_FORMAT) : "";
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
watch(
|
|
143
|
+
() => props.modelValue,
|
|
144
|
+
(newDate) => {
|
|
145
|
+
const parsed = parseISO(newDate ?? '');
|
|
146
|
+
formattedDate.value = (parsed && isValid(parsed)) ? format(parsed, DISPLAY_FORMAT) : "";
|
|
147
|
+
},
|
|
148
|
+
{ immediate: true }
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const nativeMin = computed(() => {
|
|
152
|
+
if (props.minDate && isValid(props.minDate)) {
|
|
153
|
+
return format(props.minDate, ISO_FORMAT);
|
|
154
|
+
}
|
|
155
|
+
return "";
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const nativeMax = computed(() => {
|
|
159
|
+
if (props.maxDate && isValid(props.maxDate)) {
|
|
160
|
+
return format(props.maxDate, ISO_FORMAT);
|
|
161
|
+
}
|
|
162
|
+
return "";
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
function onDateInput(e: Event) {
|
|
166
|
+
const target = e.target as HTMLInputElement;
|
|
167
|
+
const rawValue = target.value;
|
|
168
|
+
|
|
169
|
+
// Clear any existing timeout
|
|
170
|
+
if (invalidCharTimeout.value) {
|
|
171
|
+
clearTimeout(invalidCharTimeout.value);
|
|
172
|
+
invalidCharTimeout.value = null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Check for invalid characters (not digits or dots)
|
|
176
|
+
const hasInvalidChars = /[^\d.]/.test(rawValue);
|
|
177
|
+
|
|
178
|
+
if (hasInvalidChars) {
|
|
179
|
+
// Show the invalid input temporarily with error message
|
|
180
|
+
formattedDate.value = rawValue;
|
|
181
|
+
inputState.value = "error";
|
|
182
|
+
inputMessage.value = invalidCharMessage.value;
|
|
183
|
+
|
|
184
|
+
// Remove invalid characters after 500ms
|
|
185
|
+
invalidCharTimeout.value = setTimeout(() => {
|
|
186
|
+
const cleanedValue = rawValue.replace(/[^\d]/g, "");
|
|
187
|
+
formattedDate.value = formatDateValue(cleanedValue);
|
|
188
|
+
validateAndEmit(formattedDate.value);
|
|
189
|
+
}, 500);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Check for invalid dot usage (dots are auto-inserted, so manual dots are invalid)
|
|
194
|
+
// Valid format is: DD.MM.YYYY - dots should only appear at positions 2 and 5
|
|
195
|
+
const dotCount = (rawValue.match(/\./g) || []).length;
|
|
196
|
+
const hasConsecutiveDots = /\.\./.test(rawValue);
|
|
197
|
+
const hasInvalidDots = dotCount > 0 && (
|
|
198
|
+
hasConsecutiveDots ||
|
|
199
|
+
dotCount > 2 ||
|
|
200
|
+
(rawValue.indexOf('.') !== -1 && rawValue.indexOf('.') !== 2) ||
|
|
201
|
+
(dotCount === 2 && rawValue.lastIndexOf('.') !== 5)
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
if (hasInvalidDots) {
|
|
205
|
+
// Show the invalid input temporarily with error message
|
|
206
|
+
formattedDate.value = rawValue;
|
|
207
|
+
inputState.value = "error";
|
|
208
|
+
inputMessage.value = invalidCharMessage.value;
|
|
209
|
+
|
|
210
|
+
// Remove dots and reformat after 500ms
|
|
211
|
+
invalidCharTimeout.value = setTimeout(() => {
|
|
212
|
+
const cleanedValue = rawValue.replace(/\./g, "");
|
|
213
|
+
formattedDate.value = formatDateValue(cleanedValue);
|
|
214
|
+
validateAndEmit(formattedDate.value);
|
|
215
|
+
}, 500);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Check if input exceeds 10 characters (TT.MM.JJJJ format)
|
|
220
|
+
if (rawValue.length > 10) {
|
|
221
|
+
// Show the overlength input temporarily with error message
|
|
222
|
+
formattedDate.value = rawValue;
|
|
223
|
+
inputState.value = "error";
|
|
224
|
+
inputMessage.value = formatErrorMessage.value;
|
|
225
|
+
|
|
226
|
+
// Remove excess characters after 500ms
|
|
227
|
+
invalidCharTimeout.value = setTimeout(() => {
|
|
228
|
+
formattedDate.value = rawValue.slice(0, 10);
|
|
229
|
+
validateAndEmit(formattedDate.value);
|
|
230
|
+
}, 500);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Format and validate normally
|
|
235
|
+
const formattedValue = formatDateValue(rawValue.replace(/[^\d]/g, ""));
|
|
236
|
+
formattedDate.value = formattedValue;
|
|
237
|
+
validateAndEmit(formattedValue);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function formatDateValue(digitsOnly: string): string {
|
|
241
|
+
let value = digitsOnly.replace(/\D/g, ""); // Keep only digits
|
|
242
|
+
|
|
243
|
+
// Insert dot after day (2 digits)
|
|
244
|
+
if (value.length > 2) {
|
|
245
|
+
value = value.slice(0, 2) + "." + value.slice(2);
|
|
246
|
+
}
|
|
247
|
+
// Insert dot after month (next 2 digits)
|
|
248
|
+
if (value.length > 5) {
|
|
249
|
+
value = value.slice(0, 5) + "." + value.slice(5);
|
|
250
|
+
}
|
|
251
|
+
// Limit to 10 characters (DD.MM.YYYY)
|
|
252
|
+
if (value.length > 10) {
|
|
253
|
+
value = value.slice(0, 10);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function validateAndEmit(value: string) {
|
|
260
|
+
// If incomplete date, reset state
|
|
261
|
+
if (value.length < 10) {
|
|
262
|
+
inputState.value = "idle";
|
|
263
|
+
inputMessage.value = "";
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Parse the date using dots as separator
|
|
268
|
+
const parsed = parseDateWithCurrentTime(value);
|
|
269
|
+
|
|
270
|
+
if (!isValid(parsed)) {
|
|
271
|
+
inputState.value = "error";
|
|
272
|
+
inputMessage.value = invalidDateMessage.value;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (props.minDate && isValid(props.minDate)) {
|
|
277
|
+
if (startOfDay(parsed) < startOfDay(props.minDate)) {
|
|
278
|
+
inputState.value = "error";
|
|
279
|
+
inputMessage.value = minDateMessage.value;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if(props.maxDate && isValid(props.maxDate)) {
|
|
285
|
+
if (startOfDay(parsed) > startOfDay(props.maxDate)) {
|
|
286
|
+
inputState.value = "error";
|
|
287
|
+
inputMessage.value = maxDateMessage.value;
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
inputState.value = "success";
|
|
293
|
+
inputMessage.value = "";
|
|
294
|
+
|
|
295
|
+
emit("update:modelValue", parsed.toISOString());
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Parse "dd.MM.yyyy" as a date, then apply the current local time (H:M:S.ms).
|
|
300
|
+
* Returns a new Date object.
|
|
301
|
+
*/
|
|
302
|
+
function parseDateWithCurrentTime(dateString: any) {
|
|
303
|
+
const now = new Date();
|
|
304
|
+
|
|
305
|
+
// 1) Parse date portion (defaults to midnight)
|
|
306
|
+
const parsedDate = parse(dateString, DISPLAY_FORMAT, now);
|
|
307
|
+
|
|
308
|
+
// 2) Overwrite the parsed date's time with the current local time
|
|
309
|
+
const result = set(parsedDate, {
|
|
310
|
+
hours: getHours(now),
|
|
311
|
+
minutes: getMinutes(now),
|
|
312
|
+
seconds: getSeconds(now),
|
|
313
|
+
milliseconds: getMilliseconds(now)
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function onNativeDateChange(e: Event) {
|
|
320
|
+
if (!nativeDate.value) return;
|
|
321
|
+
|
|
322
|
+
const [year, month, day] = nativeDate.value.value.split("-");
|
|
323
|
+
const reformatted = `${day}.${month}.${year}`;
|
|
324
|
+
const fakeEvent = { target: { value: reformatted } } as unknown as Event;
|
|
325
|
+
|
|
326
|
+
onDateInput(fakeEvent);
|
|
327
|
+
|
|
328
|
+
if (props.layout === 'edit-field') {
|
|
329
|
+
// When DateInput is used in EditField, clicking events in the native picker removes focus from EditField.
|
|
330
|
+
// Since saving is based on blur in EditField, we need to restore focus and then blur to trigger save.
|
|
331
|
+
nextTick(() => {
|
|
332
|
+
inputRef.value?.focus?.();
|
|
333
|
+
inputRef.value?.blur?.();
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Computed property to expose validity status
|
|
339
|
+
const isDateValid = computed(() => inputState.value === 'success');
|
|
340
|
+
|
|
341
|
+
defineExpose({
|
|
342
|
+
focus: () => inputRef.value?.focus?.(),
|
|
343
|
+
blur: () => inputRef.value?.blur?.(),
|
|
344
|
+
select: () => inputRef.value?.select?.(),
|
|
345
|
+
isValid: isDateValid
|
|
346
|
+
})
|
|
347
|
+
</script>
|
|
348
|
+
|
|
349
|
+
<style scoped>
|
|
350
|
+
.native-date {
|
|
351
|
+
position: absolute;
|
|
352
|
+
top: 0;
|
|
353
|
+
left: 0;
|
|
354
|
+
width: 100%;
|
|
355
|
+
height: 100%;
|
|
356
|
+
opacity: 0 !important;
|
|
357
|
+
background: transparent;
|
|
358
|
+
color: transparent;
|
|
359
|
+
cursor: pointer;
|
|
360
|
+
z-index: 2;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.date-wrapper {
|
|
364
|
+
position: relative;
|
|
365
|
+
width: 100%;
|
|
366
|
+
height: 100%;
|
|
367
|
+
display: inline-flex;
|
|
368
|
+
align-items: center;
|
|
369
|
+
justify-content: center;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.date-icon {
|
|
373
|
+
pointer-events: none;
|
|
374
|
+
cursor: pointer;
|
|
375
|
+
z-index: 1;
|
|
376
|
+
}
|
|
371
377
|
</style>
|