@coreui/vue-pro 4.3.0-beta.1 → 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 +15 -2
- package/dist/components/carousel/CCarousel.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +10 -2
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +86 -3
- 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/modal/CModal.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
- package/dist/components/time-picker/CTimePicker.d.ts +1 -1
- package/dist/components/toast/CToast.d.ts +7 -1
- package/dist/index.es.js +3583 -577
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3582 -576
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +3 -1
- package/dist/utils/time.d.ts +6 -2
- 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 +132 -62
- package/src/components/collapse/CCollapse.ts +5 -6
- package/src/components/date-picker/CDatePicker.ts +7 -10
- package/src/components/date-range-picker/CDateRangePicker.ts +198 -100
- 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/modal/CModal.ts +14 -6
- package/src/components/nav/CNavGroup.ts +4 -6
- package/src/components/offcanvas/COffcanvas.ts +5 -7
- package/src/components/picker/CPicker.ts +1 -0
- package/src/components/popover/CPopover.ts +5 -5
- package/src/components/tabs/CTabPane.ts +4 -6
- package/src/components/time-picker/CTimePicker.ts +12 -17
- package/src/components/toast/CToast.ts +17 -12
- package/src/components/tooltip/CTooltip.ts +5 -5
- package/src/utils/calendar.ts +86 -9
- package/src/utils/time.ts +29 -3
- package/src/utils/transition.ts +65 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { defineComponent, h, onMounted, PropType, ref, watch } from 'vue'
|
|
2
2
|
|
|
3
|
+
import { format as dateFormat } from 'date-fns'
|
|
4
|
+
|
|
3
5
|
import { CButton } from '../button'
|
|
4
6
|
import { CCalendar } from '../calendar'
|
|
5
7
|
import { CFormInput, CInputGroup, CInputGroupText } from '../form'
|
|
6
8
|
import { CPicker } from '../picker'
|
|
7
9
|
import { CTimePicker } from '../time-picker'
|
|
8
10
|
|
|
9
|
-
import {
|
|
11
|
+
import { getLocalDateFromString } from '../../utils/calendar'
|
|
10
12
|
|
|
11
13
|
import { Color } from '../props'
|
|
12
14
|
|
|
@@ -138,12 +140,16 @@ const CDateRangePicker = defineComponent({
|
|
|
138
140
|
* - 4 - Thursday,
|
|
139
141
|
* - 5 - Friday,
|
|
140
142
|
* - 6 - Saturday,
|
|
141
|
-
* - 7 - Sunday
|
|
142
143
|
*/
|
|
143
144
|
firstDayOfWeek: {
|
|
144
145
|
type: Number,
|
|
145
146
|
default: 1,
|
|
146
147
|
},
|
|
148
|
+
/**
|
|
149
|
+
* Set date format.
|
|
150
|
+
* We use date-fns to format dates. Visit https://date-fns.org/v2.28.0/docs/format to check accepted patterns.
|
|
151
|
+
*/
|
|
152
|
+
format: String,
|
|
147
153
|
/**
|
|
148
154
|
* Toggle visibility of footer element or set the content of footer.
|
|
149
155
|
*/
|
|
@@ -236,6 +242,45 @@ const CDateRangePicker = defineComponent({
|
|
|
236
242
|
* Provide an additional time selection by adding select boxes to choose times.
|
|
237
243
|
*/
|
|
238
244
|
timepicker: Boolean,
|
|
245
|
+
/**
|
|
246
|
+
* Toggle visibility or set the content of today button.
|
|
247
|
+
*/
|
|
248
|
+
todayButton: {
|
|
249
|
+
type: [Boolean, String],
|
|
250
|
+
default: 'Today',
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* Sets the color context of the today button to one of CoreUI’s themed colors.
|
|
254
|
+
*
|
|
255
|
+
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
256
|
+
*/
|
|
257
|
+
todayButtonColor: {
|
|
258
|
+
...Color,
|
|
259
|
+
default: 'primary',
|
|
260
|
+
},
|
|
261
|
+
/**
|
|
262
|
+
* Size the today button small or large.
|
|
263
|
+
*
|
|
264
|
+
* @values 'sm', 'lg'
|
|
265
|
+
*/
|
|
266
|
+
todayButtonSize: {
|
|
267
|
+
type: String,
|
|
268
|
+
default: 'sm',
|
|
269
|
+
validator: (value: string) => {
|
|
270
|
+
return ['sm', 'lg'].includes(value)
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
/**
|
|
274
|
+
* Set the today button variant to an outlined button or a ghost button.
|
|
275
|
+
*
|
|
276
|
+
* @values 'ghost', 'outline'
|
|
277
|
+
*/
|
|
278
|
+
todayButtonVariant: {
|
|
279
|
+
type: String,
|
|
280
|
+
validator: (value: string) => {
|
|
281
|
+
return ['ghost', 'outline'].includes(value)
|
|
282
|
+
},
|
|
283
|
+
},
|
|
239
284
|
/**
|
|
240
285
|
* Set length or format of day name.
|
|
241
286
|
*
|
|
@@ -289,6 +334,8 @@ const CDateRangePicker = defineComponent({
|
|
|
289
334
|
const endDate = ref<Date | null>(props.endDate ? new Date(props.endDate) : null)
|
|
290
335
|
const initialStartDate = ref<Date | null>(startDate.value ? new Date(startDate.value) : null)
|
|
291
336
|
const initialEndDate = ref<Date | null>(endDate.value ? new Date(endDate.value) : null)
|
|
337
|
+
const maxDate = ref(props.maxDate && new Date(props.maxDate))
|
|
338
|
+
const minDate = ref(props.minDate && new Date(props.minDate))
|
|
292
339
|
const selectEndDate = ref(false)
|
|
293
340
|
|
|
294
341
|
const isMobile = ref(false)
|
|
@@ -315,11 +362,35 @@ const CDateRangePicker = defineComponent({
|
|
|
315
362
|
},
|
|
316
363
|
)
|
|
317
364
|
|
|
318
|
-
|
|
365
|
+
watch(
|
|
366
|
+
() => props.maxDate,
|
|
367
|
+
() => {
|
|
368
|
+
if (props.maxDate) {
|
|
369
|
+
maxDate.value = new Date(props.maxDate)
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
watch(
|
|
375
|
+
() => props.minDate,
|
|
376
|
+
() => {
|
|
377
|
+
if (props.minDate) {
|
|
378
|
+
minDate.value = new Date(props.minDate)
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
const formatDate = (date: Date) => {
|
|
384
|
+
return props.format
|
|
385
|
+
? dateFormat(date, props.format)
|
|
386
|
+
: props.timepicker
|
|
387
|
+
? date.toLocaleString(props.format)
|
|
388
|
+
: date.toLocaleDateString(props.format)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const setInputValue = (date: Date | null) => {
|
|
319
392
|
if (date) {
|
|
320
|
-
return
|
|
321
|
-
? date.toLocaleString(props.locale)
|
|
322
|
-
: date.toLocaleDateString(props.locale)
|
|
393
|
+
return formatDate(date)
|
|
323
394
|
}
|
|
324
395
|
|
|
325
396
|
return ''
|
|
@@ -327,10 +398,10 @@ const CDateRangePicker = defineComponent({
|
|
|
327
398
|
|
|
328
399
|
const handleCalendarCellHover = (date: Date | null) => {
|
|
329
400
|
if (selectEndDate.value) {
|
|
330
|
-
inputEndHoverValue.value = date
|
|
401
|
+
inputEndHoverValue.value = date
|
|
331
402
|
return
|
|
332
403
|
}
|
|
333
|
-
inputStartHoverValue.value = date
|
|
404
|
+
inputStartHoverValue.value = date
|
|
334
405
|
}
|
|
335
406
|
|
|
336
407
|
const handleCalendarDateChange = (date: Date, difference?: number) => {
|
|
@@ -349,7 +420,7 @@ const CDateRangePicker = defineComponent({
|
|
|
349
420
|
selectEndDate.value = true
|
|
350
421
|
}
|
|
351
422
|
|
|
352
|
-
emit('start-date-change', date)
|
|
423
|
+
emit('start-date-change', date, date ? formatDate(date) : undefined)
|
|
353
424
|
}
|
|
354
425
|
|
|
355
426
|
const handleEndDateChange = (date: Date) => {
|
|
@@ -359,7 +430,7 @@ const CDateRangePicker = defineComponent({
|
|
|
359
430
|
selectEndDate.value = false
|
|
360
431
|
}
|
|
361
432
|
|
|
362
|
-
emit('end-date-change', date)
|
|
433
|
+
emit('end-date-change', date, date ? formatDate(date) : undefined)
|
|
363
434
|
}
|
|
364
435
|
|
|
365
436
|
const handleClear = (event: Event) => {
|
|
@@ -387,18 +458,23 @@ const CDateRangePicker = defineComponent({
|
|
|
387
458
|
selectEndDate.value = false
|
|
388
459
|
},
|
|
389
460
|
onInput: (event) => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
461
|
+
const date = getLocalDateFromString(
|
|
462
|
+
event.target.value,
|
|
463
|
+
props.locale,
|
|
464
|
+
props.timepicker,
|
|
465
|
+
)
|
|
466
|
+
if (date instanceof Date && date.getTime()) {
|
|
467
|
+
calendarDate.value = date
|
|
468
|
+
startDate.value = date
|
|
393
469
|
}
|
|
394
470
|
},
|
|
395
471
|
placeholder: Array.isArray(props.placeholder)
|
|
396
472
|
? props.placeholder[0]
|
|
397
473
|
: props.placeholder,
|
|
398
|
-
readonly: props.inputReadOnly,
|
|
474
|
+
readonly: props.inputReadOnly || typeof props.format === 'string',
|
|
399
475
|
value: inputStartHoverValue.value
|
|
400
|
-
? setInputValue(inputStartHoverValue.value
|
|
401
|
-
: setInputValue(startDate.value
|
|
476
|
+
? setInputValue(inputStartHoverValue.value)
|
|
477
|
+
: setInputValue(startDate.value),
|
|
402
478
|
}),
|
|
403
479
|
props.range &&
|
|
404
480
|
props.separator !== false &&
|
|
@@ -417,16 +493,21 @@ const CDateRangePicker = defineComponent({
|
|
|
417
493
|
selectEndDate.value = true
|
|
418
494
|
},
|
|
419
495
|
onInput: (event) => {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
496
|
+
const date = getLocalDateFromString(
|
|
497
|
+
event.target.value,
|
|
498
|
+
props.locale,
|
|
499
|
+
props.timepicker,
|
|
500
|
+
)
|
|
501
|
+
if (date instanceof Date && date.getTime()) {
|
|
502
|
+
calendarDate.value = date
|
|
503
|
+
endDate.value = date
|
|
423
504
|
}
|
|
424
505
|
},
|
|
425
506
|
placeholder: props.placeholder[1],
|
|
426
|
-
readonly: props.inputReadOnly,
|
|
507
|
+
readonly: props.inputReadOnly || typeof props.format === 'string',
|
|
427
508
|
value: inputEndHoverValue.value
|
|
428
|
-
? setInputValue(inputEndHoverValue.value
|
|
429
|
-
: setInputValue(endDate.value
|
|
509
|
+
? setInputValue(inputEndHoverValue.value)
|
|
510
|
+
: setInputValue(endDate.value),
|
|
430
511
|
}),
|
|
431
512
|
(props.indicator || props.cleaner) &&
|
|
432
513
|
h(CInputGroupText, {}, () => [
|
|
@@ -498,6 +579,23 @@ const CDateRangePicker = defineComponent({
|
|
|
498
579
|
confirmButton: () => slots.confirmButton && slots.confirmButton(),
|
|
499
580
|
}),
|
|
500
581
|
toggler: () => InputGroup(),
|
|
582
|
+
footer: () =>
|
|
583
|
+
h(
|
|
584
|
+
CButton,
|
|
585
|
+
{
|
|
586
|
+
class: 'me-auto',
|
|
587
|
+
color: props.todayButtonColor,
|
|
588
|
+
size: props.todayButtonSize,
|
|
589
|
+
variant: props.todayButtonVariant,
|
|
590
|
+
onClick: () => {
|
|
591
|
+
const date = new Date()
|
|
592
|
+
startDate.value = date
|
|
593
|
+
endDate.value = date
|
|
594
|
+
calendarDate.value = date
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
() => props.todayButton,
|
|
598
|
+
),
|
|
501
599
|
default: () =>
|
|
502
600
|
h(
|
|
503
601
|
'div',
|
|
@@ -529,82 +627,66 @@ const CDateRangePicker = defineComponent({
|
|
|
529
627
|
h(
|
|
530
628
|
'div',
|
|
531
629
|
{ class: 'date-picker-calendars' },
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
calendarDate.value.getMonth() + index,
|
|
540
|
-
1,
|
|
541
|
-
),
|
|
542
|
-
disabledDates: props.disabledDates,
|
|
543
|
-
...(endDate.value && { endDate: endDate.value }),
|
|
544
|
-
firstDayOfWeek: props.firstDayOfWeek,
|
|
545
|
-
locale: props.locale,
|
|
546
|
-
maxDate: props.maxDate,
|
|
547
|
-
minDate: props.minDate,
|
|
548
|
-
navigation: props.navigation,
|
|
549
|
-
range: true,
|
|
550
|
-
selectEndDate: selectEndDate.value,
|
|
551
|
-
...(startDate.value && { startDate: startDate.value }),
|
|
552
|
-
onCalendarCellHover: (date: Date | null) => handleCalendarCellHover(date),
|
|
553
|
-
onCalendarDateChange: (date: Date) =>
|
|
554
|
-
handleCalendarDateChange(date, index),
|
|
555
|
-
onStartDateChange: (date: Date) => handleStartDateChange(date),
|
|
556
|
-
onEndDateChange: (date: Date) => handleEndDateChange(date),
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
/**
|
|
560
|
-
* @slot Location for next icon.
|
|
561
|
-
*/
|
|
562
|
-
...(slots.navNextIcon && {
|
|
563
|
-
navNextIcon: () => slots.navNextIcon && slots.navNextIcon(),
|
|
564
|
-
}),
|
|
565
|
-
/**
|
|
566
|
-
* @slot Location for next double icon.
|
|
567
|
-
*/
|
|
568
|
-
...(slots.navNextDoubleIcon && {
|
|
569
|
-
navNextDoubleIcon: () =>
|
|
570
|
-
slots.navNextDoubleIcon && slots.navNextDoubleIcon(),
|
|
571
|
-
}),
|
|
572
|
-
/**
|
|
573
|
-
* @slot Location for previous icon.
|
|
574
|
-
*/
|
|
575
|
-
...(slots.navPrevIcon && {
|
|
576
|
-
navPrevIcon: () => slots.navPrevIcon && slots.navPrevIcon(),
|
|
577
|
-
}),
|
|
578
|
-
/**
|
|
579
|
-
* @slot Location for double previous icon.
|
|
580
|
-
*/
|
|
581
|
-
...(slots.navPrevDoubleIcon && {
|
|
582
|
-
navPrevDoubleIcon: () =>
|
|
583
|
-
slots.navPrevDoubleIcon && slots.navPrevDoubleIcon(),
|
|
584
|
-
}),
|
|
585
|
-
},
|
|
630
|
+
h(
|
|
631
|
+
CCalendar,
|
|
632
|
+
{
|
|
633
|
+
calendarDate: new Date(
|
|
634
|
+
calendarDate.value.getFullYear(),
|
|
635
|
+
calendarDate.value.getMonth(),
|
|
636
|
+
1,
|
|
586
637
|
),
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
638
|
+
calendars: props.calendars,
|
|
639
|
+
disabledDates: props.disabledDates,
|
|
640
|
+
...(endDate.value && { endDate: endDate.value }),
|
|
641
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
642
|
+
locale: props.locale,
|
|
643
|
+
maxDate: maxDate.value,
|
|
644
|
+
minDate: minDate.value,
|
|
645
|
+
navigation: props.navigation,
|
|
646
|
+
range: true,
|
|
647
|
+
selectEndDate: selectEndDate.value,
|
|
648
|
+
...(startDate.value && { startDate: startDate.value }),
|
|
649
|
+
onCalendarCellHover: (date: Date | null) => handleCalendarCellHover(date),
|
|
650
|
+
onCalendarDateChange: (date: Date) => handleCalendarDateChange(date),
|
|
651
|
+
onStartDateChange: (date: Date) => handleStartDateChange(date),
|
|
652
|
+
onEndDateChange: (date: Date) => handleEndDateChange(date),
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
/**
|
|
656
|
+
* @slot Location for next icon.
|
|
657
|
+
*/
|
|
658
|
+
...(slots.navNextIcon && {
|
|
659
|
+
navNextIcon: () => slots.navNextIcon && slots.navNextIcon(),
|
|
660
|
+
}),
|
|
661
|
+
/**
|
|
662
|
+
* @slot Location for next double icon.
|
|
663
|
+
*/
|
|
664
|
+
...(slots.navNextDoubleIcon && {
|
|
665
|
+
navNextDoubleIcon: () =>
|
|
666
|
+
slots.navNextDoubleIcon && slots.navNextDoubleIcon(),
|
|
667
|
+
}),
|
|
668
|
+
/**
|
|
669
|
+
* @slot Location for previous icon.
|
|
670
|
+
*/
|
|
671
|
+
...(slots.navPrevIcon && {
|
|
672
|
+
navPrevIcon: () => slots.navPrevIcon && slots.navPrevIcon(),
|
|
673
|
+
}),
|
|
674
|
+
/**
|
|
675
|
+
* @slot Location for double previous icon.
|
|
676
|
+
*/
|
|
677
|
+
...(slots.navPrevDoubleIcon && {
|
|
678
|
+
navPrevDoubleIcon: () =>
|
|
679
|
+
slots.navPrevDoubleIcon && slots.navPrevDoubleIcon(),
|
|
680
|
+
}),
|
|
681
|
+
},
|
|
682
|
+
),
|
|
683
|
+
),
|
|
684
|
+
props.timepicker &&
|
|
685
|
+
h(
|
|
686
|
+
'div',
|
|
687
|
+
{ class: 'date-picker-timepickers' },
|
|
688
|
+
isMobile.value || (props.range && props.calendars === 1)
|
|
689
|
+
? [
|
|
608
690
|
h(CTimePicker, {
|
|
609
691
|
container: 'inline',
|
|
610
692
|
disabled: startDate.value === null ? true : false,
|
|
@@ -621,10 +703,26 @@ const CDateRangePicker = defineComponent({
|
|
|
621
703
|
time: endDate.value,
|
|
622
704
|
variant: 'select',
|
|
623
705
|
}),
|
|
624
|
-
]
|
|
625
|
-
|
|
706
|
+
]
|
|
707
|
+
: [...Array(props.calendars)].map((_, index) =>
|
|
708
|
+
h(CTimePicker, {
|
|
709
|
+
container: 'inline',
|
|
710
|
+
disabled:
|
|
711
|
+
index === 0
|
|
712
|
+
? startDate.value === null
|
|
713
|
+
? true
|
|
714
|
+
: false
|
|
715
|
+
: endDate.value === null
|
|
716
|
+
? true
|
|
717
|
+
: false,
|
|
718
|
+
locale: props.locale,
|
|
719
|
+
onChange: (_: any, __: any, date: Date) =>
|
|
720
|
+
index === 0 ? handleStartDateChange(date) : handleEndDateChange(date),
|
|
721
|
+
time: index === 0 ? startDate.value : endDate.value,
|
|
722
|
+
variant: 'select',
|
|
723
|
+
}),
|
|
724
|
+
),
|
|
626
725
|
),
|
|
627
|
-
),
|
|
628
726
|
],
|
|
629
727
|
),
|
|
630
728
|
},
|