@coreui/vue-pro 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/calendar/CCalendar.d.ts +198 -0
- package/dist/components/calendar/index.d.ts +6 -0
- package/dist/components/carousel/CCarousel.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +414 -0
- package/dist/components/date-picker/index.d.ts +6 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +563 -0
- package/dist/components/date-range-picker/index.d.ts +6 -0
- package/dist/components/form/CFormCheck.d.ts +88 -39
- package/dist/components/form/CFormControlValidation.d.ts +98 -0
- package/dist/components/form/CFormControlWrapper.d.ts +6 -0
- package/dist/components/form/CFormFeedback.d.ts +2 -2
- package/dist/components/form/CFormInput.d.ts +125 -25
- package/dist/components/form/CFormRange.d.ts +18 -16
- package/dist/components/form/CFormSelect.d.ts +125 -16
- package/dist/components/form/CFormSwitch.d.ts +0 -23
- package/dist/components/form/CFormTextarea.d.ts +125 -24
- package/dist/components/index.d.ts +5 -0
- package/dist/components/modal/CModal.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
- package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
- package/dist/components/picker/CPicker.d.ts +11 -0
- package/dist/components/picker/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/sidebar/CSidebar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +35 -99
- package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
- package/dist/components/time-picker/CTimePicker.d.ts +10 -0
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
- package/dist/components/time-picker/index.d.ts +6 -0
- package/dist/components/toast/CToast.d.ts +8 -2
- package/dist/index.es.js +6249 -1276
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +6256 -1273
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +23 -0
- package/dist/utils/time.d.ts +21 -0
- package/dist/utils/transition.d.ts +3 -0
- package/package.json +11 -10
- package/src/components/backdrop/CBackdrop.ts +8 -6
- package/src/components/button/CButton.ts +2 -2
- package/src/components/calendar/CCalendar.ts +616 -0
- package/src/components/calendar/index.ts +10 -0
- package/src/components/collapse/CCollapse.ts +5 -6
- package/src/components/date-picker/CDatePicker.ts +240 -0
- package/src/components/date-picker/index.ts +10 -0
- package/src/components/date-range-picker/CDateRangePicker.ts +733 -0
- package/src/components/date-range-picker/index.ts +10 -0
- package/src/components/dropdown/CDropdownMenu.ts +4 -2
- package/src/components/dropdown/CDropdownToggle.ts +24 -9
- package/src/components/form/CFormCheck.ts +119 -94
- package/src/components/form/CFormControlValidation.ts +97 -0
- package/src/components/form/CFormControlWrapper.ts +106 -0
- package/src/components/form/CFormInput.ts +113 -29
- package/src/components/form/CFormRange.ts +25 -11
- package/src/components/form/CFormSelect.ts +126 -41
- package/src/components/form/CFormSwitch.ts +2 -21
- package/src/components/form/CFormTextarea.ts +105 -25
- package/src/components/index.ts +5 -0
- package/src/components/modal/CModal.ts +14 -6
- package/src/components/nav/CNavGroup.ts +4 -6
- package/src/components/offcanvas/COffcanvas.ts +5 -7
- package/src/components/pagination/CSmartPagination.ts +4 -4
- package/src/components/picker/CPicker.ts +221 -0
- package/src/components/picker/index.ts +10 -0
- package/src/components/popover/CPopover.ts +5 -5
- package/src/components/smart-table/CSmartTable.ts +17 -49
- package/src/components/smart-table/CSmartTableInterface.ts +5 -3
- package/src/components/tabs/CTabPane.ts +4 -6
- package/src/components/time-picker/CTimePicker.ts +405 -0
- package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
- package/src/components/time-picker/index.ts +10 -0
- package/src/components/toast/CToast.ts +17 -12
- package/src/components/tooltip/CTooltip.ts +5 -5
- package/src/utils/calendar.ts +270 -0
- package/src/utils/time.ts +84 -0
- package/src/utils/transition.ts +65 -0
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, ref, watch } from 'vue'
|
|
2
|
+
|
|
3
|
+
import { CButton } from '../button'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
createGroupsInArray,
|
|
7
|
+
getMonthDetails,
|
|
8
|
+
getMonthsNames,
|
|
9
|
+
getYears,
|
|
10
|
+
isDateDisabled,
|
|
11
|
+
isDateInRange,
|
|
12
|
+
isDateSelected,
|
|
13
|
+
isDisableDateInRange,
|
|
14
|
+
isLastDayOfMonth,
|
|
15
|
+
isSameDateAs,
|
|
16
|
+
isToday,
|
|
17
|
+
isStartDate,
|
|
18
|
+
isEndDate,
|
|
19
|
+
} from '../../utils/calendar'
|
|
20
|
+
|
|
21
|
+
const CCalendar = defineComponent({
|
|
22
|
+
name: 'CCalendar',
|
|
23
|
+
props: {
|
|
24
|
+
/**
|
|
25
|
+
* Default date of the component
|
|
26
|
+
*/
|
|
27
|
+
calendarDate: {
|
|
28
|
+
type: [Date, String],
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* The number of calendars that render on desktop devices.
|
|
32
|
+
*/
|
|
33
|
+
calendars: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 1,
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Specify the list of dates that cannot be selected.
|
|
39
|
+
*/
|
|
40
|
+
disabledDates: {
|
|
41
|
+
type: Array as PropType<Date[] | Date[][]>,
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Initial selected to date (range).
|
|
45
|
+
*/
|
|
46
|
+
endDate: {
|
|
47
|
+
type: [Date, String],
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Sets the day of start week.
|
|
51
|
+
* - 0 - Sunday,
|
|
52
|
+
* - 1 - Monday,
|
|
53
|
+
* - 2 - Tuesday,
|
|
54
|
+
* - 3 - Wednesday,
|
|
55
|
+
* - 4 - Thursday,
|
|
56
|
+
* - 5 - Friday,
|
|
57
|
+
* - 6 - Saturday,
|
|
58
|
+
*/
|
|
59
|
+
firstDayOfWeek: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: 1,
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Sets the default locale for components. If not set, it is inherited from the navigator.language.
|
|
65
|
+
*/
|
|
66
|
+
locale: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'default',
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Max selectable date.
|
|
72
|
+
*/
|
|
73
|
+
maxDate: {
|
|
74
|
+
type: [Date, String],
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Min selectable date.
|
|
78
|
+
*/
|
|
79
|
+
minDate: {
|
|
80
|
+
type: [Date, String],
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Show arrows navigation.
|
|
84
|
+
*/
|
|
85
|
+
navigation: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true,
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Allow range selection.
|
|
91
|
+
*/
|
|
92
|
+
range: Boolean,
|
|
93
|
+
/**
|
|
94
|
+
* Toggle select mode between start and end date.
|
|
95
|
+
*/
|
|
96
|
+
selectEndDate: Boolean,
|
|
97
|
+
/**
|
|
98
|
+
* Initial selected date.
|
|
99
|
+
*/
|
|
100
|
+
startDate: {
|
|
101
|
+
type: [Date, String],
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Set length or format of day name.
|
|
105
|
+
*
|
|
106
|
+
* @type number | 'long' | 'narrow' | 'short'
|
|
107
|
+
*/
|
|
108
|
+
weekdayFormat: {
|
|
109
|
+
type: [Number, String],
|
|
110
|
+
default: 2,
|
|
111
|
+
validator: (value: string | number) => {
|
|
112
|
+
if (typeof value === 'string') {
|
|
113
|
+
return ['long', 'narrow', 'short'].includes(value)
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'number') {
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
return false
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
emits: [
|
|
123
|
+
/**
|
|
124
|
+
* Callback fired when the user hovers over the calendar cell.
|
|
125
|
+
*
|
|
126
|
+
* @property {Date | null} date
|
|
127
|
+
*/
|
|
128
|
+
'calendar-cell-hover',
|
|
129
|
+
/**
|
|
130
|
+
* Callback fired when the calendar date changed.
|
|
131
|
+
*
|
|
132
|
+
* @property {Date | null} date
|
|
133
|
+
*/
|
|
134
|
+
'calendar-date-change',
|
|
135
|
+
/**
|
|
136
|
+
* Callback fired when the start date changed.
|
|
137
|
+
*
|
|
138
|
+
* @property {Date | null} date
|
|
139
|
+
*/
|
|
140
|
+
'start-date-change',
|
|
141
|
+
/**
|
|
142
|
+
* Callback fired when the end date changed.
|
|
143
|
+
*
|
|
144
|
+
* @property {Date | null} date
|
|
145
|
+
*/
|
|
146
|
+
'end-date-change',
|
|
147
|
+
],
|
|
148
|
+
setup(props, { slots, emit }) {
|
|
149
|
+
const calendarDate = ref(
|
|
150
|
+
props.calendarDate
|
|
151
|
+
? new Date(props.calendarDate)
|
|
152
|
+
: props.startDate
|
|
153
|
+
? new Date(props.startDate)
|
|
154
|
+
: new Date(),
|
|
155
|
+
)
|
|
156
|
+
const startDate = ref(props.startDate ? new Date(props.startDate) : null)
|
|
157
|
+
const endDate = ref(props.endDate ? new Date(props.endDate) : null)
|
|
158
|
+
const hoverDate = ref<Date | null>(null)
|
|
159
|
+
const maxDate = ref(props.maxDate ? new Date(props.maxDate) : null)
|
|
160
|
+
const minDate = ref(props.minDate ? new Date(props.minDate) : null)
|
|
161
|
+
const selectEndDate = ref(props.selectEndDate)
|
|
162
|
+
const view = ref('days')
|
|
163
|
+
|
|
164
|
+
watch(
|
|
165
|
+
() => props.calendarDate,
|
|
166
|
+
() => {
|
|
167
|
+
if (props.calendarDate) {
|
|
168
|
+
calendarDate.value = new Date(props.calendarDate)
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
watch(
|
|
174
|
+
() => props.startDate,
|
|
175
|
+
() => {
|
|
176
|
+
const date = props.startDate ? new Date(props.startDate) : null
|
|
177
|
+
if (!isSameDateAs(date, startDate.value)) {
|
|
178
|
+
startDate.value = date
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
watch(
|
|
184
|
+
() => props.endDate,
|
|
185
|
+
() => {
|
|
186
|
+
const date = props.endDate ? new Date(props.endDate) : null
|
|
187
|
+
if (!isSameDateAs(date, endDate.value)) {
|
|
188
|
+
endDate.value = date
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
watch(
|
|
194
|
+
() => props.maxDate,
|
|
195
|
+
() => {
|
|
196
|
+
if (props.maxDate) {
|
|
197
|
+
maxDate.value = new Date(props.maxDate)
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
watch(
|
|
203
|
+
() => props.minDate,
|
|
204
|
+
() => {
|
|
205
|
+
if (props.minDate) {
|
|
206
|
+
minDate.value = new Date(props.minDate)
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
watch(
|
|
212
|
+
() => props.selectEndDate,
|
|
213
|
+
() => {
|
|
214
|
+
selectEndDate.value = props.selectEndDate
|
|
215
|
+
},
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
watch(startDate, () => {
|
|
219
|
+
emit('start-date-change', startDate.value)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
watch(endDate, () => {
|
|
223
|
+
emit('end-date-change', endDate.value)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const setCalendarPage = (years: number, months = 0) => {
|
|
227
|
+
const year = calendarDate.value.getFullYear()
|
|
228
|
+
const month = calendarDate.value.getMonth()
|
|
229
|
+
const d = new Date(year, month, 1)
|
|
230
|
+
|
|
231
|
+
years && d.setFullYear(d.getFullYear() + years)
|
|
232
|
+
months && d.setMonth(d.getMonth() + months)
|
|
233
|
+
|
|
234
|
+
calendarDate.value = d
|
|
235
|
+
|
|
236
|
+
emit('calendar-date-change', d)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const handleCellOnClick = (date: Date) => {
|
|
240
|
+
if (isDateDisabled(date, minDate.value, maxDate.value, props.disabledDates)) {
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (props.range) {
|
|
245
|
+
if (selectEndDate.value) {
|
|
246
|
+
selectEndDate.value = false
|
|
247
|
+
|
|
248
|
+
if (startDate.value && startDate.value > date) {
|
|
249
|
+
startDate.value = null
|
|
250
|
+
endDate.value = null
|
|
251
|
+
return
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (isDisableDateInRange(startDate.value, date, props.disabledDates)) {
|
|
255
|
+
startDate.value = null
|
|
256
|
+
endDate.value = null
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
endDate.value = date
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (endDate.value && endDate.value < date) {
|
|
265
|
+
startDate.value = null
|
|
266
|
+
endDate.value = null
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (isDisableDateInRange(date, endDate.value, props.disabledDates)) {
|
|
271
|
+
startDate.value = null
|
|
272
|
+
endDate.value = null
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
selectEndDate.value = true
|
|
277
|
+
startDate.value = date
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
startDate.value = date
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const handleCellMouseEnter = (date: Date) => {
|
|
285
|
+
if (isDateDisabled(date, minDate.value, maxDate.value, props.disabledDates)) {
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
hoverDate.value = date
|
|
290
|
+
emit('calendar-cell-hover', date)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const handleCellMouseLeave = () => {
|
|
294
|
+
hoverDate.value = null
|
|
295
|
+
emit('calendar-cell-hover', null)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const handleNavigationOnClick = (direction: string, double = false) => {
|
|
299
|
+
if (direction === 'prev') {
|
|
300
|
+
if (double) {
|
|
301
|
+
setCalendarPage(view.value !== 'days' ? -10 : -1)
|
|
302
|
+
return
|
|
303
|
+
}
|
|
304
|
+
if (view.value !== 'days') {
|
|
305
|
+
setCalendarPage(-1)
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
setCalendarPage(0, -1)
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
if (direction === 'next') {
|
|
312
|
+
if (double) {
|
|
313
|
+
setCalendarPage(view.value !== 'days' ? 10 : 1)
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
if (view.value !== 'days') {
|
|
317
|
+
setCalendarPage(1)
|
|
318
|
+
return
|
|
319
|
+
}
|
|
320
|
+
setCalendarPage(0, 1)
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const Calendar = (addMonths: number) => {
|
|
326
|
+
let date = calendarDate.value
|
|
327
|
+
|
|
328
|
+
if (addMonths !== 0) {
|
|
329
|
+
date = new Date(
|
|
330
|
+
calendarDate.value.getFullYear(),
|
|
331
|
+
calendarDate.value.getMonth() + addMonths,
|
|
332
|
+
1,
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const monthDetails = getMonthDetails(
|
|
337
|
+
date.getFullYear(),
|
|
338
|
+
date.getMonth(),
|
|
339
|
+
props.firstDayOfWeek,
|
|
340
|
+
)
|
|
341
|
+
const listOfMonths = createGroupsInArray(getMonthsNames(props.locale), 4)
|
|
342
|
+
const listOfYears = createGroupsInArray(getYears(date.getFullYear()), 4)
|
|
343
|
+
const weekDays = monthDetails[0]
|
|
344
|
+
|
|
345
|
+
return h('table', {}, [
|
|
346
|
+
view.value === 'days' &&
|
|
347
|
+
h(
|
|
348
|
+
'thead',
|
|
349
|
+
{},
|
|
350
|
+
h(
|
|
351
|
+
'tr',
|
|
352
|
+
{},
|
|
353
|
+
weekDays.map(({ date }: { date: Date }) => {
|
|
354
|
+
return h(
|
|
355
|
+
'th',
|
|
356
|
+
{ class: 'calendar-cell' },
|
|
357
|
+
h(
|
|
358
|
+
'div',
|
|
359
|
+
{
|
|
360
|
+
class: 'calendar-header-cell-inner',
|
|
361
|
+
},
|
|
362
|
+
props.weekdayFormat === 'string'
|
|
363
|
+
? date.toLocaleDateString(props.locale, { weekday: props.weekdayFormat })
|
|
364
|
+
: date
|
|
365
|
+
.toLocaleDateString(props.locale, { weekday: 'long' })
|
|
366
|
+
.slice(0, props.weekdayFormat),
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
}),
|
|
370
|
+
),
|
|
371
|
+
),
|
|
372
|
+
h('tbody', {}, [
|
|
373
|
+
view.value === 'days' &&
|
|
374
|
+
monthDetails.map((week) => {
|
|
375
|
+
return h(
|
|
376
|
+
'tr',
|
|
377
|
+
{},
|
|
378
|
+
week.map(({ date, month }: { date: Date; month: string }) => {
|
|
379
|
+
return h(
|
|
380
|
+
'td',
|
|
381
|
+
{
|
|
382
|
+
class: [
|
|
383
|
+
'calendar-cell',
|
|
384
|
+
{
|
|
385
|
+
today: isToday(date),
|
|
386
|
+
disabled: isDateDisabled(
|
|
387
|
+
date,
|
|
388
|
+
minDate.value,
|
|
389
|
+
maxDate.value,
|
|
390
|
+
props.disabledDates,
|
|
391
|
+
),
|
|
392
|
+
[month]: true,
|
|
393
|
+
last: isLastDayOfMonth(date),
|
|
394
|
+
range:
|
|
395
|
+
month === 'current' &&
|
|
396
|
+
isDateInRange(date, startDate.value, endDate.value),
|
|
397
|
+
'range-hover':
|
|
398
|
+
month === 'current' &&
|
|
399
|
+
(hoverDate.value && selectEndDate.value
|
|
400
|
+
? isDateInRange(date, startDate.value, hoverDate.value)
|
|
401
|
+
: isDateInRange(date, hoverDate.value, endDate.value)),
|
|
402
|
+
selected: isDateSelected(date, startDate.value, endDate.value),
|
|
403
|
+
start: isStartDate(date, startDate.value, endDate.value),
|
|
404
|
+
end: isEndDate(date, startDate.value, endDate.value),
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
title: date.toLocaleDateString(props.locale),
|
|
408
|
+
...(month === 'current' && {
|
|
409
|
+
onClick: () => handleCellOnClick(date),
|
|
410
|
+
onmouseenter: () => handleCellMouseEnter(date),
|
|
411
|
+
onmouseleave: () => handleCellMouseLeave(),
|
|
412
|
+
}),
|
|
413
|
+
},
|
|
414
|
+
h(
|
|
415
|
+
'div',
|
|
416
|
+
{
|
|
417
|
+
class: 'calendar-cell-inner',
|
|
418
|
+
},
|
|
419
|
+
date.toLocaleDateString(props.locale, { day: 'numeric' }),
|
|
420
|
+
),
|
|
421
|
+
)
|
|
422
|
+
}),
|
|
423
|
+
)
|
|
424
|
+
}),
|
|
425
|
+
view.value === 'months' &&
|
|
426
|
+
listOfMonths.map((row, index) => {
|
|
427
|
+
return h(
|
|
428
|
+
'tr',
|
|
429
|
+
{},
|
|
430
|
+
row.map((month, idx) => {
|
|
431
|
+
return h(
|
|
432
|
+
'td',
|
|
433
|
+
{
|
|
434
|
+
class: 'calendar-cell month',
|
|
435
|
+
onClick: () => {
|
|
436
|
+
setCalendarPage(0, index * 3 + idx - addMonths)
|
|
437
|
+
view.value = 'days'
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
h('div', { class: 'calendar-cell-inner' }, month),
|
|
441
|
+
)
|
|
442
|
+
}),
|
|
443
|
+
)
|
|
444
|
+
}),
|
|
445
|
+
view.value === 'years' &&
|
|
446
|
+
listOfYears.map((row) => {
|
|
447
|
+
return h(
|
|
448
|
+
'tr',
|
|
449
|
+
{},
|
|
450
|
+
row.map((year) => {
|
|
451
|
+
return h(
|
|
452
|
+
'td',
|
|
453
|
+
{
|
|
454
|
+
class: 'calendar-cell year',
|
|
455
|
+
onClick: () => {
|
|
456
|
+
calendarDate.value = new Date(
|
|
457
|
+
year,
|
|
458
|
+
date.getMonth() - addMonths,
|
|
459
|
+
date.getDate(),
|
|
460
|
+
)
|
|
461
|
+
view.value = 'months'
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
h('div', { class: 'calendar-cell-inner' }, year),
|
|
465
|
+
)
|
|
466
|
+
}),
|
|
467
|
+
)
|
|
468
|
+
}),
|
|
469
|
+
]),
|
|
470
|
+
])
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const Navigation = (addMonths: number) => {
|
|
474
|
+
let date = calendarDate.value
|
|
475
|
+
|
|
476
|
+
if (addMonths !== 0) {
|
|
477
|
+
date = new Date(
|
|
478
|
+
calendarDate.value.getFullYear(),
|
|
479
|
+
calendarDate.value.getMonth() + addMonths,
|
|
480
|
+
1,
|
|
481
|
+
)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return h('div', { class: 'calendar-nav' }, [
|
|
485
|
+
props.navigation &&
|
|
486
|
+
h(
|
|
487
|
+
'div',
|
|
488
|
+
{
|
|
489
|
+
class: 'calendar-nav-prev',
|
|
490
|
+
},
|
|
491
|
+
[
|
|
492
|
+
h(
|
|
493
|
+
CButton,
|
|
494
|
+
{
|
|
495
|
+
color: 'transparent',
|
|
496
|
+
size: 'sm',
|
|
497
|
+
onClick: () => handleNavigationOnClick('prev', true),
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
/**
|
|
501
|
+
* @slot Location for double previous icon.
|
|
502
|
+
*/
|
|
503
|
+
default: () =>
|
|
504
|
+
slots.navPrevDoubleIcon
|
|
505
|
+
? slots.navPrevDoubleIcon()
|
|
506
|
+
: h('span', { class: 'calendar-nav-icon calendar-nav-icon-double-prev' }),
|
|
507
|
+
},
|
|
508
|
+
),
|
|
509
|
+
view.value === 'days' &&
|
|
510
|
+
h(
|
|
511
|
+
CButton,
|
|
512
|
+
{
|
|
513
|
+
color: 'transparent',
|
|
514
|
+
size: 'sm',
|
|
515
|
+
onClick: () => handleNavigationOnClick('prev'),
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
/**
|
|
519
|
+
* @slot Location for previous icon.
|
|
520
|
+
*/
|
|
521
|
+
default: () =>
|
|
522
|
+
slots.navPrevIcon
|
|
523
|
+
? slots.navPrevIcon()
|
|
524
|
+
: h('span', { class: 'calendar-nav-icon calendar-nav-icon-prev' }),
|
|
525
|
+
},
|
|
526
|
+
),
|
|
527
|
+
],
|
|
528
|
+
),
|
|
529
|
+
h(
|
|
530
|
+
'div',
|
|
531
|
+
{
|
|
532
|
+
class: 'calendar-nav-date',
|
|
533
|
+
},
|
|
534
|
+
[
|
|
535
|
+
view.value === 'days' &&
|
|
536
|
+
h(
|
|
537
|
+
CButton,
|
|
538
|
+
{
|
|
539
|
+
color: 'transparent',
|
|
540
|
+
size: 'sm',
|
|
541
|
+
onClick: () => {
|
|
542
|
+
if (props.navigation) view.value = 'months'
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
() => date.toLocaleDateString(props.locale, { month: 'long' }),
|
|
546
|
+
),
|
|
547
|
+
h(
|
|
548
|
+
CButton,
|
|
549
|
+
{
|
|
550
|
+
color: 'transparent',
|
|
551
|
+
size: 'sm',
|
|
552
|
+
onClick: () => {
|
|
553
|
+
if (props.navigation) view.value = 'years'
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
() => date.toLocaleDateString(props.locale, { year: 'numeric' }),
|
|
557
|
+
),
|
|
558
|
+
],
|
|
559
|
+
),
|
|
560
|
+
props.navigation &&
|
|
561
|
+
h(
|
|
562
|
+
'div',
|
|
563
|
+
{
|
|
564
|
+
class: 'calendar-nav-next',
|
|
565
|
+
},
|
|
566
|
+
[
|
|
567
|
+
view.value === 'days' &&
|
|
568
|
+
h(
|
|
569
|
+
CButton,
|
|
570
|
+
{
|
|
571
|
+
color: 'transparent',
|
|
572
|
+
size: 'sm',
|
|
573
|
+
onClick: () => handleNavigationOnClick('next'),
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
/**
|
|
577
|
+
* @slot Location for next icon.
|
|
578
|
+
*/
|
|
579
|
+
default: () =>
|
|
580
|
+
slots.navNextIcon
|
|
581
|
+
? slots.navNextIcon()
|
|
582
|
+
: h('span', { class: 'calendar-nav-icon calendar-nav-icon-next' }),
|
|
583
|
+
},
|
|
584
|
+
),
|
|
585
|
+
h(
|
|
586
|
+
CButton,
|
|
587
|
+
{
|
|
588
|
+
color: 'transparent',
|
|
589
|
+
size: 'sm',
|
|
590
|
+
onClick: () => handleNavigationOnClick('next', true),
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
/**
|
|
594
|
+
* @slot Location for double next icon.
|
|
595
|
+
*/
|
|
596
|
+
default: () =>
|
|
597
|
+
slots.navNextDoubleIcon
|
|
598
|
+
? slots.navNextDoubleIcon()
|
|
599
|
+
: h('span', { class: 'calendar-nav-icon calendar-nav-icon-double-next' }),
|
|
600
|
+
},
|
|
601
|
+
),
|
|
602
|
+
],
|
|
603
|
+
),
|
|
604
|
+
])
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return () =>
|
|
608
|
+
h('div', { class: 'calendars' }, [
|
|
609
|
+
Array.from({ length: props.calendars }, (_, index) =>
|
|
610
|
+
h('div', { class: ['calendar', view.value] }, [Navigation(index), Calendar(index)]),
|
|
611
|
+
),
|
|
612
|
+
])
|
|
613
|
+
},
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
export { CCalendar }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defineComponent, h, Transition, ref, RendererElement, withDirectives } from 'vue'
|
|
2
|
+
|
|
2
3
|
import { vVisible } from '../../directives/v-c-visible'
|
|
4
|
+
import { executeAfterTransition } from './../../utils/transition'
|
|
3
5
|
|
|
4
6
|
const CCollapse = defineComponent({
|
|
5
7
|
name: 'CCollapse',
|
|
@@ -39,10 +41,9 @@ const CCollapse = defineComponent({
|
|
|
39
41
|
|
|
40
42
|
const handleEnter = (el: RendererElement, done: () => void) => {
|
|
41
43
|
emit('show')
|
|
42
|
-
|
|
43
|
-
done()
|
|
44
|
-
})
|
|
44
|
+
// collapsing.value = true
|
|
45
45
|
setTimeout(() => {
|
|
46
|
+
executeAfterTransition(() => done(), el as HTMLElement)
|
|
46
47
|
if (props.horizontal) {
|
|
47
48
|
el.style.width = `${el.scrollWidth}px`
|
|
48
49
|
return
|
|
@@ -69,10 +70,8 @@ const CCollapse = defineComponent({
|
|
|
69
70
|
|
|
70
71
|
const handleLeave = (el: RendererElement, done: () => void) => {
|
|
71
72
|
emit('hide')
|
|
72
|
-
el.addEventListener('transitionend', () => {
|
|
73
|
-
done()
|
|
74
|
-
})
|
|
75
73
|
setTimeout(() => {
|
|
74
|
+
executeAfterTransition(() => done(), el as HTMLElement)
|
|
76
75
|
if (props.horizontal) {
|
|
77
76
|
el.style.width = '0px'
|
|
78
77
|
return
|