@veritree/ui 0.27.0 → 0.28.0-1
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/.claude/settings.local.json +10 -0
- package/index.js +105 -75
- package/mixins/floating-ui-content.js +17 -4
- package/mixins/floating-ui-item.js +31 -15
- package/mixins/floating-ui.js +142 -24
- package/mixins/form-control-icon.js +3 -3
- package/mixins/form-control.js +45 -20
- package/nuxt.js +38 -26
- package/package.json +17 -6
- package/src/components/Alert/VTAlert.vue +55 -14
- package/src/components/Avatar/VTAvatarImage.vue +6 -26
- package/src/components/Badge/VTBadge.vue +60 -0
- package/src/components/Badge/VTBadgeNew.vue +60 -0
- package/src/components/Breadcrumb/VTBreadcrumbItem.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbLink.vue +40 -0
- package/src/components/Breadcrumb/VTBreadcrumbList.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbRoot.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbSeparator.vue +19 -0
- package/src/components/Button/VTButton.vue +104 -56
- package/src/components/Carousel/VTCarousel.vue +69 -0
- package/src/components/Carousel/VTCarouselBackward.vue +36 -0
- package/src/components/Carousel/VTCarouselForward.vue +38 -0
- package/src/components/Carousel/VTCarouselTracker.vue +80 -0
- package/src/components/Checkbox/VTCheckbox.vue +134 -0
- package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
- package/src/components/Checkbox/VTCheckboxText.vue +20 -0
- package/src/components/Chip/VTChip.vue +29 -0
- package/src/components/Dialog/VTDialog.vue +59 -25
- package/src/components/Dialog/VTDialogClose.vue +3 -2
- package/src/components/Dialog/VTDialogContent.vue +29 -7
- package/src/components/Dialog/VTDialogFooter.vue +17 -2
- package/src/components/Dialog/VTDialogHeader.vue +2 -1
- package/src/components/Dialog/VTDialogMain.vue +5 -1
- package/src/components/Dialog/VTDialogOverlay.vue +5 -1
- package/src/components/Dialog/VTDialogTitle.vue +1 -1
- package/src/components/Disclosure/VTDisclosure.vue +2 -11
- package/src/components/Disclosure/VTDisclosureContent.vue +26 -52
- package/src/components/Disclosure/VTDisclosureDetails.vue +27 -2
- package/src/components/Disclosure/VTDisclosureHeader.vue +56 -89
- package/src/components/Disclosure/VTDisclosureIcon.vue +42 -31
- package/src/components/Divider/VTDivider.vue +9 -0
- package/src/components/Drawer/VTDrawer.vue +6 -15
- package/src/components/Drawer/VTDrawerClose.vue +5 -5
- package/src/components/Drawer/VTDrawerContent.vue +10 -10
- package/src/components/Drawer/VTDrawerFooter.vue +4 -4
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +0 -6
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +10 -1
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +7 -16
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +5 -1
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +1 -10
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +2 -4
- package/src/components/Form/VTFieldset.vue +5 -0
- package/src/components/Form/VTForm.vue +11 -0
- package/src/components/Form/VTFormCol.vue +20 -0
- package/src/components/Form/VTFormFeedback.vue +7 -1
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormLabelHelper.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +2 -5
- package/src/components/Form/VTInputDate.vue +602 -0
- package/src/components/Form/VTInputIcon.vue +3 -9
- package/src/components/Form/VTInputNumber.vue +198 -0
- package/src/components/Form/VTInputPassword.vue +14 -5
- package/src/components/Form/VTInputRange.vue +92 -0
- package/src/components/Form/VTLegend.vue +24 -0
- package/src/components/Form/VTTextarea.vue +2 -2
- package/src/components/Image/VTImage.vue +10 -10
- package/src/components/Listbox/VTListbox.vue +128 -9
- package/src/components/Listbox/VTListboxContent.vue +14 -1
- package/src/components/Listbox/VTListboxDivider.vue +21 -0
- package/src/components/Listbox/VTListboxGroup.vue +9 -0
- package/src/components/Listbox/VTListboxItem.vue +57 -15
- package/src/components/Listbox/VTListboxLabel.vue +5 -4
- package/src/components/Listbox/VTListboxList.vue +1 -6
- package/src/components/Listbox/VTListboxPlaceholder.vue +25 -0
- package/src/components/Listbox/VTListboxSearch.vue +12 -8
- package/src/components/Listbox/VTListboxTrigger.vue +87 -6
- package/src/components/Listbox/VTListboxTriggerHighlight.vue +204 -0
- package/src/components/Listbox/VTListboxViewport.vue +33 -0
- package/src/components/Popover/VTPopoverContent.vue +3 -3
- package/src/components/Popover/VTPopoverDivider.vue +1 -1
- package/src/components/Popover/VTPopoverItem.vue +6 -2
- package/src/components/ProgressBar/VTProgressBar.vue +35 -10
- package/src/components/ProgressBar/VTProgressBarIndicator.vue +53 -0
- package/src/components/ScrollShadows/VTScrollShadows.vue +76 -0
- package/src/components/Separator/VTSeparator.vue +13 -0
- package/src/components/Switch/VTSwitch.vue +61 -0
- package/src/components/Tabs/VTTab.vue +6 -5
- package/src/components/Tabs/VTTabGroup.vue +88 -9
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Toast/README.md +263 -0
- package/src/components/Toast/VTToast.vue +145 -0
- package/src/components/Toast/VTToastAction.vue +25 -0
- package/src/components/Toast/VTToastClose.vue +52 -0
- package/src/components/Toast/VTToastContent.vue +25 -0
- package/src/components/Toast/VTToastDescription.vue +36 -0
- package/src/components/Toast/VTToastIcon.vue +72 -0
- package/src/components/Toast/VTToastItem.vue +180 -0
- package/src/components/Toast/VTToastTitle.vue +34 -0
- package/src/components/Tooltip/VTTooltipTrigger.vue +3 -5
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +31 -13
- package/src/helpers/currency.js +21 -0
- package/src/utils/components.js +18 -0
- package/src/utils/images.js +31 -12
- package/src/components/Input/VTInput.vue +0 -82
- package/src/components/Input/VTInputDate.vue +0 -36
- package/src/components/Input/VTInputFile.vue +0 -60
- package/src/components/Input/VTInputUpload.vue +0 -54
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Range date picker -->
|
|
3
|
+
<DateRangePickerRoot
|
|
4
|
+
v-if="isRange"
|
|
5
|
+
v-model="rangeValue"
|
|
6
|
+
v-model:open="isOpen"
|
|
7
|
+
:min-value="minCalendarDate"
|
|
8
|
+
:max-value="maxCalendarDate"
|
|
9
|
+
:number-of-months="columns"
|
|
10
|
+
:fixed-weeks="fixedWeeks"
|
|
11
|
+
:initial-focus="initialFocus"
|
|
12
|
+
:placeholder="placeholder"
|
|
13
|
+
@update:model-value="onRangeSelect"
|
|
14
|
+
>
|
|
15
|
+
<DateRangePickerField v-slot="{ segments }">
|
|
16
|
+
<DateRangePickerTrigger
|
|
17
|
+
:id="id"
|
|
18
|
+
:class="classComputed"
|
|
19
|
+
:data-testid="dataTestid"
|
|
20
|
+
:disabled="disabled"
|
|
21
|
+
>
|
|
22
|
+
<span v-if="displayText">{{ displayText }}</span>
|
|
23
|
+
<slot v-else name="label">
|
|
24
|
+
<span class="text-gray-500">{{ label || format }}</span>
|
|
25
|
+
</slot>
|
|
26
|
+
<span
|
|
27
|
+
v-if="!iconless"
|
|
28
|
+
:class="[
|
|
29
|
+
disabled ? 'bg-gray-200' : 'bg-white',
|
|
30
|
+
'pointer-events-none absolute right-3 top-1/2 -translate-y-1/2',
|
|
31
|
+
]"
|
|
32
|
+
>
|
|
33
|
+
<IconCalendar class="-z-0 h-5 w-5 scale-90 text-gray-600" />
|
|
34
|
+
</span>
|
|
35
|
+
</DateRangePickerTrigger>
|
|
36
|
+
</DateRangePickerField>
|
|
37
|
+
|
|
38
|
+
<DateRangePickerContent
|
|
39
|
+
:side-offset="4"
|
|
40
|
+
class="vt-datepicker-content"
|
|
41
|
+
>
|
|
42
|
+
<DateRangePickerCalendar v-slot="{ grid, weekDays }">
|
|
43
|
+
<DateRangePickerHeader class="vt-calendar-header">
|
|
44
|
+
<DateRangePickerPrev class="vt-calendar-nav">
|
|
45
|
+
<IconChevronLeft class="h-4 w-4" />
|
|
46
|
+
</DateRangePickerPrev>
|
|
47
|
+
<DateRangePickerHeading class="vt-calendar-heading" />
|
|
48
|
+
<DateRangePickerNext class="vt-calendar-nav">
|
|
49
|
+
<IconChevronRight class="h-4 w-4" />
|
|
50
|
+
</DateRangePickerNext>
|
|
51
|
+
</DateRangePickerHeader>
|
|
52
|
+
<div class="vt-calendar-grids">
|
|
53
|
+
<DateRangePickerGrid
|
|
54
|
+
v-for="month in grid"
|
|
55
|
+
:key="month.value.toString()"
|
|
56
|
+
class="vt-calendar-grid unstyled"
|
|
57
|
+
>
|
|
58
|
+
<DateRangePickerGridHead>
|
|
59
|
+
<DateRangePickerGridRow>
|
|
60
|
+
<DateRangePickerHeadCell
|
|
61
|
+
v-for="day in weekDays"
|
|
62
|
+
:key="day"
|
|
63
|
+
class="vt-calendar-head-cell"
|
|
64
|
+
>
|
|
65
|
+
{{ day }}
|
|
66
|
+
</DateRangePickerHeadCell>
|
|
67
|
+
</DateRangePickerGridRow>
|
|
68
|
+
</DateRangePickerGridHead>
|
|
69
|
+
<DateRangePickerGridBody>
|
|
70
|
+
<DateRangePickerGridRow
|
|
71
|
+
v-for="(weekDates, index) in month.rows"
|
|
72
|
+
:key="`weekDate-${index}`"
|
|
73
|
+
>
|
|
74
|
+
<DateRangePickerCell
|
|
75
|
+
v-for="weekDate in weekDates"
|
|
76
|
+
:key="weekDate.toString()"
|
|
77
|
+
:date="weekDate"
|
|
78
|
+
class="vt-calendar-cell"
|
|
79
|
+
>
|
|
80
|
+
<DateRangePickerCellTrigger
|
|
81
|
+
:day="weekDate"
|
|
82
|
+
:month="month.value"
|
|
83
|
+
class="vt-calendar-cell-trigger"
|
|
84
|
+
/>
|
|
85
|
+
</DateRangePickerCell>
|
|
86
|
+
</DateRangePickerGridRow>
|
|
87
|
+
</DateRangePickerGridBody>
|
|
88
|
+
</DateRangePickerGrid>
|
|
89
|
+
</div>
|
|
90
|
+
</DateRangePickerCalendar>
|
|
91
|
+
<div class="mt-2 flex">
|
|
92
|
+
<VTButton size="small" variant="secondary" @click.prevent="onClear">
|
|
93
|
+
Clear
|
|
94
|
+
</VTButton>
|
|
95
|
+
</div>
|
|
96
|
+
</DateRangePickerContent>
|
|
97
|
+
</DateRangePickerRoot>
|
|
98
|
+
|
|
99
|
+
<!-- Single date picker -->
|
|
100
|
+
<DatePickerRoot
|
|
101
|
+
v-else
|
|
102
|
+
v-model="singleValue"
|
|
103
|
+
v-model:open="isOpen"
|
|
104
|
+
:min-value="minCalendarDate"
|
|
105
|
+
:max-value="maxCalendarDate"
|
|
106
|
+
:number-of-months="columns"
|
|
107
|
+
:fixed-weeks="fixedWeeks"
|
|
108
|
+
:initial-focus="initialFocus"
|
|
109
|
+
:placeholder="placeholder"
|
|
110
|
+
@update:model-value="onSingleSelect"
|
|
111
|
+
>
|
|
112
|
+
<DatePickerField v-slot="{ segments }">
|
|
113
|
+
<DatePickerTrigger
|
|
114
|
+
:id="id"
|
|
115
|
+
:class="classComputed"
|
|
116
|
+
:data-testid="dataTestid"
|
|
117
|
+
:disabled="disabled"
|
|
118
|
+
>
|
|
119
|
+
<span v-if="displayText">{{ displayText }}</span>
|
|
120
|
+
<slot v-else name="label">
|
|
121
|
+
<span class="text-gray-500">{{ label || format }}</span>
|
|
122
|
+
</slot>
|
|
123
|
+
<span
|
|
124
|
+
v-if="!iconless"
|
|
125
|
+
:class="[
|
|
126
|
+
disabled ? 'bg-gray-200' : 'bg-white',
|
|
127
|
+
'pointer-events-none absolute right-3 top-1/2 -translate-y-1/2',
|
|
128
|
+
]"
|
|
129
|
+
>
|
|
130
|
+
<IconCalendar class="-z-0 h-5 w-5 scale-90 text-gray-600" />
|
|
131
|
+
</span>
|
|
132
|
+
</DatePickerTrigger>
|
|
133
|
+
</DatePickerField>
|
|
134
|
+
|
|
135
|
+
<DatePickerContent
|
|
136
|
+
:side-offset="4"
|
|
137
|
+
class="vt-datepicker-content"
|
|
138
|
+
>
|
|
139
|
+
<DatePickerCalendar v-slot="{ grid, weekDays }">
|
|
140
|
+
<DatePickerHeader class="vt-calendar-header">
|
|
141
|
+
<DatePickerPrev class="vt-calendar-nav">
|
|
142
|
+
<IconChevronLeft class="h-4 w-4" />
|
|
143
|
+
</DatePickerPrev>
|
|
144
|
+
<DatePickerHeading class="vt-calendar-heading" />
|
|
145
|
+
<DatePickerNext class="vt-calendar-nav">
|
|
146
|
+
<IconChevronRight class="h-4 w-4" />
|
|
147
|
+
</DatePickerNext>
|
|
148
|
+
</DatePickerHeader>
|
|
149
|
+
<div class="vt-calendar-grids">
|
|
150
|
+
<DatePickerGrid
|
|
151
|
+
v-for="month in grid"
|
|
152
|
+
:key="month.value.toString()"
|
|
153
|
+
class="vt-calendar-grid unstyled"
|
|
154
|
+
>
|
|
155
|
+
<DatePickerGridHead>
|
|
156
|
+
<DatePickerGridRow>
|
|
157
|
+
<DatePickerHeadCell
|
|
158
|
+
v-for="day in weekDays"
|
|
159
|
+
:key="day"
|
|
160
|
+
class="vt-calendar-head-cell"
|
|
161
|
+
>
|
|
162
|
+
{{ day }}
|
|
163
|
+
</DatePickerHeadCell>
|
|
164
|
+
</DatePickerGridRow>
|
|
165
|
+
</DatePickerGridHead>
|
|
166
|
+
<DatePickerGridBody>
|
|
167
|
+
<DatePickerGridRow
|
|
168
|
+
v-for="(weekDates, index) in month.rows"
|
|
169
|
+
:key="`weekDate-${index}`"
|
|
170
|
+
>
|
|
171
|
+
<DatePickerCell
|
|
172
|
+
v-for="weekDate in weekDates"
|
|
173
|
+
:key="weekDate.toString()"
|
|
174
|
+
:date="weekDate"
|
|
175
|
+
class="vt-calendar-cell"
|
|
176
|
+
>
|
|
177
|
+
<DatePickerCellTrigger
|
|
178
|
+
:day="weekDate"
|
|
179
|
+
:month="month.value"
|
|
180
|
+
class="vt-calendar-cell-trigger"
|
|
181
|
+
/>
|
|
182
|
+
</DatePickerCell>
|
|
183
|
+
</DatePickerGridRow>
|
|
184
|
+
</DatePickerGridBody>
|
|
185
|
+
</DatePickerGrid>
|
|
186
|
+
</div>
|
|
187
|
+
</DatePickerCalendar>
|
|
188
|
+
<div class="mt-2 flex">
|
|
189
|
+
<VTButton size="small" variant="secondary" @click.prevent="onClear">
|
|
190
|
+
Clear
|
|
191
|
+
</VTButton>
|
|
192
|
+
</div>
|
|
193
|
+
</DatePickerContent>
|
|
194
|
+
</DatePickerRoot>
|
|
195
|
+
</template>
|
|
196
|
+
|
|
197
|
+
<script>
|
|
198
|
+
import {
|
|
199
|
+
DatePickerRoot,
|
|
200
|
+
DatePickerField,
|
|
201
|
+
DatePickerTrigger,
|
|
202
|
+
DatePickerContent,
|
|
203
|
+
DatePickerCalendar,
|
|
204
|
+
DatePickerHeader,
|
|
205
|
+
DatePickerHeading,
|
|
206
|
+
DatePickerPrev,
|
|
207
|
+
DatePickerNext,
|
|
208
|
+
DatePickerGrid,
|
|
209
|
+
DatePickerGridHead,
|
|
210
|
+
DatePickerGridBody,
|
|
211
|
+
DatePickerGridRow,
|
|
212
|
+
DatePickerHeadCell,
|
|
213
|
+
DatePickerCell,
|
|
214
|
+
DatePickerCellTrigger,
|
|
215
|
+
DateRangePickerRoot,
|
|
216
|
+
DateRangePickerField,
|
|
217
|
+
DateRangePickerTrigger,
|
|
218
|
+
DateRangePickerContent,
|
|
219
|
+
DateRangePickerCalendar,
|
|
220
|
+
DateRangePickerHeader,
|
|
221
|
+
DateRangePickerHeading,
|
|
222
|
+
DateRangePickerPrev,
|
|
223
|
+
DateRangePickerNext,
|
|
224
|
+
DateRangePickerGrid,
|
|
225
|
+
DateRangePickerGridHead,
|
|
226
|
+
DateRangePickerGridBody,
|
|
227
|
+
DateRangePickerGridRow,
|
|
228
|
+
DateRangePickerHeadCell,
|
|
229
|
+
DateRangePickerCell,
|
|
230
|
+
DateRangePickerCellTrigger,
|
|
231
|
+
} from 'reka-ui';
|
|
232
|
+
import { CalendarDate, today, getLocalTimeZone } from '@internationalized/date';
|
|
233
|
+
import {
|
|
234
|
+
formControlMixin,
|
|
235
|
+
formControlStyleMixin,
|
|
236
|
+
} from '../../../mixins/form-control';
|
|
237
|
+
import dayjs from 'dayjs';
|
|
238
|
+
import utc from 'dayjs/plugin/utc';
|
|
239
|
+
|
|
240
|
+
dayjs.extend(utc);
|
|
241
|
+
|
|
242
|
+
export default {
|
|
243
|
+
name: 'VTInputDate',
|
|
244
|
+
|
|
245
|
+
components: {
|
|
246
|
+
DatePickerRoot, DatePickerField, DatePickerTrigger, DatePickerContent,
|
|
247
|
+
DatePickerCalendar, DatePickerHeader, DatePickerHeading, DatePickerPrev,
|
|
248
|
+
DatePickerNext, DatePickerGrid, DatePickerGridHead, DatePickerGridBody,
|
|
249
|
+
DatePickerGridRow, DatePickerHeadCell, DatePickerCell, DatePickerCellTrigger,
|
|
250
|
+
DateRangePickerRoot, DateRangePickerField, DateRangePickerTrigger,
|
|
251
|
+
DateRangePickerContent, DateRangePickerCalendar, DateRangePickerHeader,
|
|
252
|
+
DateRangePickerHeading, DateRangePickerPrev, DateRangePickerNext,
|
|
253
|
+
DateRangePickerGrid, DateRangePickerGridHead, DateRangePickerGridBody,
|
|
254
|
+
DateRangePickerGridRow, DateRangePickerHeadCell, DateRangePickerCell,
|
|
255
|
+
DateRangePickerCellTrigger,
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
mixins: [formControlMixin, formControlStyleMixin],
|
|
259
|
+
|
|
260
|
+
props: {
|
|
261
|
+
id: {
|
|
262
|
+
type: String,
|
|
263
|
+
default: null,
|
|
264
|
+
},
|
|
265
|
+
dataTestid: {
|
|
266
|
+
type: String,
|
|
267
|
+
default: null,
|
|
268
|
+
},
|
|
269
|
+
label: {
|
|
270
|
+
type: String,
|
|
271
|
+
default: null,
|
|
272
|
+
},
|
|
273
|
+
format: {
|
|
274
|
+
type: String,
|
|
275
|
+
default: 'YYYY-MM-DD',
|
|
276
|
+
},
|
|
277
|
+
min: {
|
|
278
|
+
type: [String, Date],
|
|
279
|
+
default: null,
|
|
280
|
+
},
|
|
281
|
+
max: {
|
|
282
|
+
type: [String, Date],
|
|
283
|
+
default: null,
|
|
284
|
+
},
|
|
285
|
+
iconless: {
|
|
286
|
+
type: Boolean,
|
|
287
|
+
default: false,
|
|
288
|
+
},
|
|
289
|
+
useUtc: {
|
|
290
|
+
type: Boolean,
|
|
291
|
+
default: false,
|
|
292
|
+
},
|
|
293
|
+
placement: {
|
|
294
|
+
type: String,
|
|
295
|
+
default: 'bottom-start',
|
|
296
|
+
},
|
|
297
|
+
isRange: {
|
|
298
|
+
type: Boolean,
|
|
299
|
+
default: false,
|
|
300
|
+
},
|
|
301
|
+
columns: {
|
|
302
|
+
type: Number,
|
|
303
|
+
default: 1,
|
|
304
|
+
},
|
|
305
|
+
fixedWeeks: {
|
|
306
|
+
type: Boolean,
|
|
307
|
+
default: true,
|
|
308
|
+
},
|
|
309
|
+
initialFocus: {
|
|
310
|
+
type: Boolean,
|
|
311
|
+
default: false,
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
emits: ['update:modelValue', 'change', 'shown', 'hidden'],
|
|
316
|
+
|
|
317
|
+
data() {
|
|
318
|
+
return {
|
|
319
|
+
singleValue: undefined,
|
|
320
|
+
rangeValue: undefined,
|
|
321
|
+
placeholder: today(getLocalTimeZone()),
|
|
322
|
+
isOpen: false,
|
|
323
|
+
};
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
computed: {
|
|
327
|
+
displayText() {
|
|
328
|
+
if (!this.modelValue) return '';
|
|
329
|
+
|
|
330
|
+
if (this.isRange) {
|
|
331
|
+
const start = this.modelValue.start || this.modelValue[0];
|
|
332
|
+
const end = this.modelValue.end || this.modelValue[1];
|
|
333
|
+
if (start && end) {
|
|
334
|
+
return `${this.formatDate(start)} – ${this.formatDate(end)}`;
|
|
335
|
+
}
|
|
336
|
+
return '';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return this.formatDate(this.modelValue);
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
minCalendarDate() {
|
|
343
|
+
return this.toCalendarDate(this.min);
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
maxCalendarDate() {
|
|
347
|
+
return this.toCalendarDate(this.max);
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
watch: {
|
|
352
|
+
modelValue: {
|
|
353
|
+
immediate: true,
|
|
354
|
+
handler(val) {
|
|
355
|
+
if (!val) {
|
|
356
|
+
this.singleValue = undefined;
|
|
357
|
+
this.rangeValue = undefined;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (this.isRange) {
|
|
362
|
+
const start = val.start || val[0];
|
|
363
|
+
const end = val.end || val[1];
|
|
364
|
+
if (start && end) {
|
|
365
|
+
this.rangeValue = {
|
|
366
|
+
start: this.toCalendarDate(start),
|
|
367
|
+
end: this.toCalendarDate(end),
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
this.singleValue = this.toCalendarDate(val);
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
isOpen(val) {
|
|
377
|
+
if (val) {
|
|
378
|
+
this.$emit('shown');
|
|
379
|
+
} else {
|
|
380
|
+
// Reset placeholder to selected date or today so focus is correct on reopen
|
|
381
|
+
if (this.singleValue) {
|
|
382
|
+
this.placeholder = this.singleValue;
|
|
383
|
+
} else if (this.rangeValue?.start) {
|
|
384
|
+
this.placeholder = this.rangeValue.start;
|
|
385
|
+
} else {
|
|
386
|
+
this.placeholder = today(getLocalTimeZone());
|
|
387
|
+
}
|
|
388
|
+
this.$emit('hidden');
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
methods: {
|
|
394
|
+
toCalendarDate(value) {
|
|
395
|
+
if (!value) return undefined;
|
|
396
|
+
if (value instanceof CalendarDate) return value;
|
|
397
|
+
const d = dayjs(value);
|
|
398
|
+
if (!d.isValid()) return undefined;
|
|
399
|
+
return new CalendarDate(d.year(), d.month() + 1, d.date());
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
calendarDateToString(calDate) {
|
|
403
|
+
if (!calDate) return null;
|
|
404
|
+
return `${calDate.year}-${String(calDate.month).padStart(2, '0')}-${String(calDate.day).padStart(2, '0')}`;
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
formatDate(value) {
|
|
408
|
+
if (!value) return '';
|
|
409
|
+
let date = dayjs(value);
|
|
410
|
+
if (this.useUtc) {
|
|
411
|
+
date = date.utc();
|
|
412
|
+
}
|
|
413
|
+
return date.format(this.format);
|
|
414
|
+
},
|
|
415
|
+
|
|
416
|
+
onSingleSelect(calDate) {
|
|
417
|
+
if (!calDate) return;
|
|
418
|
+
const value = this.calendarDateToString(calDate);
|
|
419
|
+
this.$emit('update:modelValue', value);
|
|
420
|
+
this.$emit('change', value);
|
|
421
|
+
this.isOpen = false;
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
onRangeSelect(range) {
|
|
425
|
+
if (!range?.start || !range?.end) return;
|
|
426
|
+
const value = {
|
|
427
|
+
start: this.calendarDateToString(range.start),
|
|
428
|
+
end: this.calendarDateToString(range.end),
|
|
429
|
+
};
|
|
430
|
+
this.$emit('update:modelValue', value);
|
|
431
|
+
this.$emit('change', value);
|
|
432
|
+
},
|
|
433
|
+
|
|
434
|
+
onClear() {
|
|
435
|
+
this.singleValue = undefined;
|
|
436
|
+
this.rangeValue = undefined;
|
|
437
|
+
this.$emit('update:modelValue', null);
|
|
438
|
+
this.$emit('change', null);
|
|
439
|
+
this.isOpen = false;
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
</script>
|
|
444
|
+
|
|
445
|
+
<style>
|
|
446
|
+
.vt-datepicker-content {
|
|
447
|
+
background: white;
|
|
448
|
+
border-radius: 0.5rem;
|
|
449
|
+
padding: 0.75rem;
|
|
450
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
451
|
+
z-index: 50;
|
|
452
|
+
animation: vt-datepicker-enter 0.15s ease-out;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.vt-datepicker-content[data-state="closed"] {
|
|
456
|
+
animation: vt-datepicker-leave 0.1s ease-in;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
@keyframes vt-datepicker-enter {
|
|
460
|
+
from {
|
|
461
|
+
opacity: 0;
|
|
462
|
+
transform: translateY(15px);
|
|
463
|
+
}
|
|
464
|
+
to {
|
|
465
|
+
opacity: 1;
|
|
466
|
+
transform: translateY(0);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
@keyframes vt-datepicker-leave {
|
|
471
|
+
from {
|
|
472
|
+
opacity: 1;
|
|
473
|
+
transform: translateY(0);
|
|
474
|
+
}
|
|
475
|
+
to {
|
|
476
|
+
opacity: 0;
|
|
477
|
+
transform: translateY(15px);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.vt-calendar-header {
|
|
482
|
+
display: flex;
|
|
483
|
+
align-items: center;
|
|
484
|
+
justify-content: space-between;
|
|
485
|
+
padding: 0.25rem 0 0.5rem;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.vt-calendar-heading {
|
|
489
|
+
font-weight: 500;
|
|
490
|
+
font-size: 0.875rem;
|
|
491
|
+
color: #374151;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.vt-calendar-nav {
|
|
495
|
+
display: inline-flex;
|
|
496
|
+
align-items: center;
|
|
497
|
+
justify-content: center;
|
|
498
|
+
width: 1.75rem;
|
|
499
|
+
height: 1.75rem;
|
|
500
|
+
border-radius: 0.375rem;
|
|
501
|
+
border: none;
|
|
502
|
+
background: transparent;
|
|
503
|
+
color: #6b7280;
|
|
504
|
+
cursor: pointer;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.vt-calendar-nav:hover {
|
|
508
|
+
background-color: #f3f4f6;
|
|
509
|
+
color: #111827;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.vt-calendar-grids {
|
|
513
|
+
display: flex;
|
|
514
|
+
gap: 1rem;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.vt-calendar-grid {
|
|
518
|
+
width: 100%;
|
|
519
|
+
border-collapse: collapse;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.vt-calendar-head-cell,
|
|
523
|
+
.vt-calendar-cell-trigger {
|
|
524
|
+
text-align: center;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.vt-calendar-head-cell {
|
|
528
|
+
height: 2rem;
|
|
529
|
+
font-size: 0.75rem;
|
|
530
|
+
font-weight: 500;
|
|
531
|
+
color: #9ca3af;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.vt-calendar-cell {
|
|
535
|
+
padding: 1px;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.vt-calendar-cell-trigger {
|
|
539
|
+
display: inline-flex;
|
|
540
|
+
align-items: center;
|
|
541
|
+
justify-content: center;
|
|
542
|
+
width: 2.25rem;
|
|
543
|
+
height: 2.25rem;
|
|
544
|
+
border-radius: 0.375rem;
|
|
545
|
+
border: none;
|
|
546
|
+
background: transparent;
|
|
547
|
+
font-size: 0.8125rem;
|
|
548
|
+
color: #374151;
|
|
549
|
+
cursor: pointer;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.vt-calendar-cell-trigger:hover {
|
|
553
|
+
background-color: #f3f4f6;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.vt-calendar-cell-trigger[data-selected] {
|
|
557
|
+
background-color: #191919;
|
|
558
|
+
color: white;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.vt-calendar-cell-trigger[data-today] {
|
|
562
|
+
font-weight: 700;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.vt-calendar-cell-trigger[data-focused],
|
|
566
|
+
.vt-calendar-cell-trigger:focus-visible {
|
|
567
|
+
outline: 2px solid #191919;
|
|
568
|
+
outline-offset: -2px;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.vt-calendar-cell-trigger[data-disabled] {
|
|
572
|
+
color: #d1d5db;
|
|
573
|
+
pointer-events: none;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.vt-calendar-cell-trigger[data-outside-view] {
|
|
577
|
+
color: #d1d5db;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.vt-calendar-cell-trigger[data-unavailable] {
|
|
581
|
+
color: #d1d5db;
|
|
582
|
+
text-decoration: line-through;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/* Range selection styles */
|
|
586
|
+
.vt-calendar-cell-trigger[data-selection-start] {
|
|
587
|
+
background-color: #191919;
|
|
588
|
+
color: white;
|
|
589
|
+
border-radius: 0.375rem 0 0 0.375rem;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.vt-calendar-cell-trigger[data-selection-end] {
|
|
593
|
+
background-color: #191919;
|
|
594
|
+
color: white;
|
|
595
|
+
border-radius: 0 0.375rem 0.375rem 0;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.vt-calendar-cell-trigger[data-highlighted] {
|
|
599
|
+
background-color: #e5e7eb;
|
|
600
|
+
border-radius: 0;
|
|
601
|
+
}
|
|
602
|
+
</style>
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
<div :class="classComputedWrapper">
|
|
3
3
|
<input
|
|
4
4
|
:class="classComputed"
|
|
5
|
-
:value="
|
|
5
|
+
:value="modelValue"
|
|
6
6
|
:disabled="disabled"
|
|
7
|
-
v-bind="
|
|
8
|
-
v-on="listeners"
|
|
7
|
+
v-bind="attrsComputed"
|
|
9
8
|
/>
|
|
10
9
|
<div :class="classComputedWrapperIcon">
|
|
11
|
-
<
|
|
10
|
+
<slot name="icon" />
|
|
12
11
|
</div>
|
|
13
12
|
</div>
|
|
14
13
|
</template>
|
|
@@ -22,11 +21,6 @@ export default {
|
|
|
22
21
|
mixins: [formControlIconMixin],
|
|
23
22
|
|
|
24
23
|
props: {
|
|
25
|
-
icon: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: null,
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
24
|
iconPlacement: {
|
|
31
25
|
type: String,
|
|
32
26
|
default: 'left',
|