@coreui/vue-pro 4.4.2 → 4.6.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.
Files changed (27) hide show
  1. package/dist/components/calendar/CCalendar.d.ts +41 -3
  2. package/dist/components/date-picker/CDatePicker.d.ts +41 -3
  3. package/dist/components/date-range-picker/CDateRangePicker.d.ts +160 -3
  4. package/dist/components/multi-select/CMultiSelect copy.d.ts +305 -0
  5. package/dist/components/multi-select/CMultiSelect.d.ts +168 -0
  6. package/dist/components/smart-table/CSmartTable.d.ts +2 -2
  7. package/dist/components/smart-table/CSmartTableHead.d.ts +15 -3
  8. package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
  9. package/dist/components/table/CTable.d.ts +170 -8
  10. package/dist/components/table/CTableDataCell.d.ts +14 -0
  11. package/dist/index.es.js +1006 -474
  12. package/dist/index.es.js.map +1 -1
  13. package/dist/index.js +1006 -474
  14. package/dist/index.js.map +1 -1
  15. package/package.json +2 -2
  16. package/src/components/calendar/CCalendar.ts +46 -4
  17. package/src/components/date-picker/CDatePicker.ts +33 -1
  18. package/src/components/date-range-picker/CDateRangePicker.ts +286 -170
  19. package/src/components/form/CFormInput.ts +1 -1
  20. package/src/components/multi-select/CMultiSelect.ts +204 -93
  21. package/src/components/smart-table/CSmartTable.ts +22 -21
  22. package/src/components/smart-table/CSmartTableHead.ts +45 -24
  23. package/src/components/smart-table/CSmartTableInterface.ts +1 -1
  24. package/src/components/smart-table/CSmartTableItemsPerPageSelector.ts +1 -1
  25. package/src/components/table/CTable.ts +243 -9
  26. package/src/components/table/CTableDataCell.ts +9 -1
  27. package/src/components/time-picker/CTimePicker.ts +125 -44
@@ -5,6 +5,7 @@ import { format as dateFormat } from 'date-fns'
5
5
  import { CButton } from '../button'
6
6
  import { CCalendar } from '../calendar'
7
7
  import { CFormInput, CInputGroup, CInputGroupText } from '../form'
8
+ import { CFormControlWrapper } from './../form/CFormControlWrapper'
8
9
  import { CPicker } from '../picker'
9
10
  import { CTimePicker } from '../time-picker'
10
11
 
@@ -114,6 +115,29 @@ const CDateRangePicker = defineComponent({
114
115
  return ['ghost', 'outline'].includes(value)
115
116
  },
116
117
  },
118
+ /**
119
+ * Set the format of day name.
120
+ *
121
+ * @default 'numeric'
122
+ * @since 4.6.0
123
+ */
124
+ dayFormat: {
125
+ type: [Function, String],
126
+ default: 'numeric',
127
+ required: false,
128
+ validator: (value: string) => {
129
+ if (typeof value === 'string') {
130
+ return ['numeric', '2-digit'].includes(value)
131
+ }
132
+ if (typeof value === 'function') {
133
+ return true
134
+ }
135
+ if (typeof value === 'function') {
136
+ return true
137
+ }
138
+ return false
139
+ },
140
+ },
117
141
  /**
118
142
  * Toggle the disabled state for the component.
119
143
  */
@@ -131,6 +155,30 @@ const CDateRangePicker = defineComponent({
131
155
  type: [Date, String],
132
156
  required: false,
133
157
  },
158
+ /**
159
+ * Provide valuable, actionable feedback.
160
+ *
161
+ * @since 4.6.0
162
+ */
163
+ feedback: {
164
+ type: String,
165
+ },
166
+ /**
167
+ * Provide valuable, actionable feedback.
168
+ *
169
+ * @since 4.6.0
170
+ */
171
+ feedbackInvalid: {
172
+ type: String,
173
+ },
174
+ /**
175
+ * Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
176
+ *
177
+ * @since 4.6.0
178
+ */
179
+ feedbackValid: {
180
+ type: String,
181
+ },
134
182
  /**
135
183
  * Sets the day of start week.
136
184
  * - 0 - Sunday,
@@ -173,6 +221,20 @@ const CDateRangePicker = defineComponent({
173
221
  * Toggle the readonly state for the component.
174
222
  */
175
223
  inputReadOnly: Boolean,
224
+ /**
225
+ * Set component validation state to invalid.
226
+ *
227
+ * @since 4.6.0
228
+ */
229
+ invalid: Boolean,
230
+ /**
231
+ * Add a caption for a component.
232
+ *
233
+ * @since 4.6.0
234
+ */
235
+ label: {
236
+ type: String,
237
+ },
176
238
  /**
177
239
  * Sets the default locale for components. If not set, it is inherited from the navigator.language.
178
240
  */
@@ -199,6 +261,12 @@ const CDateRangePicker = defineComponent({
199
261
  type: Boolean,
200
262
  default: true,
201
263
  },
264
+ /**
265
+ * Reorder year-month navigation, and render year first.
266
+ *
267
+ * @since 4.6.0
268
+ */
269
+ navYearFirst: Boolean,
202
270
  /**
203
271
  * Specifies a short hint that is visible in the input.
204
272
  */
@@ -246,6 +314,14 @@ const CDateRangePicker = defineComponent({
246
314
  startDate: {
247
315
  type: [Date, String],
248
316
  },
317
+ /**
318
+ * Add helper text to the component.
319
+ *
320
+ * @since 4.6.0
321
+ */
322
+ text: {
323
+ type: String,
324
+ },
249
325
  /**
250
326
  * Provide an additional time selection by adding select boxes to choose times.
251
327
  */
@@ -289,13 +365,25 @@ const CDateRangePicker = defineComponent({
289
365
  return ['ghost', 'outline'].includes(value)
290
366
  },
291
367
  },
368
+ /**
369
+ * Display validation feedback in a styled tooltip.
370
+ *
371
+ * @since 4.6.0
372
+ */
373
+ tooltipFeedback: Boolean,
374
+ /**
375
+ * Set component validation state to valid.
376
+ *
377
+ * @since 4.6.0
378
+ */
379
+ valid: Boolean,
292
380
  /**
293
381
  * Set length or format of day name.
294
382
  *
295
383
  * @type number | 'long' | 'narrow' | 'short'
296
384
  */
297
385
  weekdayFormat: {
298
- type: [Number, String],
386
+ type: [Function, Number, String],
299
387
  default: 2,
300
388
  validator: (value: string | number) => {
301
389
  if (typeof value === 'string') {
@@ -304,6 +392,9 @@ const CDateRangePicker = defineComponent({
304
392
  if (typeof value === 'number') {
305
393
  return true
306
394
  }
395
+ if (typeof value === 'function') {
396
+ return true
397
+ }
307
398
  return false
308
399
  },
309
400
  },
@@ -332,7 +423,7 @@ const CDateRangePicker = defineComponent({
332
423
  */
333
424
  'start-date-change',
334
425
  ],
335
- setup(props, { slots, emit }) {
426
+ setup(props, { slots, attrs, emit }) {
336
427
  const calendarDate = ref<Date>(
337
428
  props.calendarDate
338
429
  ? new Date(props.calendarDate)
@@ -557,192 +648,217 @@ const CDateRangePicker = defineComponent({
557
648
 
558
649
  return () =>
559
650
  h(
560
- CPicker,
651
+ CFormControlWrapper,
561
652
  {
562
- cancelButton: props.cancelButton,
563
- cancelButtonColor: props.cancelButtonColor,
564
- cancelButtonSize: props.cancelButtonSize,
565
- cancelButtonVariant: props.cancelButtonVariant,
566
- class: 'date-picker',
567
- confirmButton: props.confirmButton,
568
- confirmButtonColor: props.confirmButtonColor,
569
- confirmButtonSize: props.confirmButtonSize,
570
- confirmButtonVariant: props.confirmButtonVariant,
571
- disabled: props.disabled,
572
- footer: props.footer || props.timepicker,
653
+ describedby: attrs['aria-describedby'],
654
+ feedback: props.feedback,
655
+ feedbackInvalid: props.feedbackInvalid,
656
+ feedbackValid: props.feedbackValid,
573
657
  id: props.id,
574
- onCancel: () => {
575
- startDate.value = initialStartDate.value
576
- endDate.value = initialEndDate.value
577
- },
578
- onHide: () => {
579
- emit('hide')
580
- },
581
- onShow: () => {
582
- if (startDate.value) {
583
- initialStartDate.value = new Date(startDate.value)
584
- }
585
-
586
- if (endDate.value) {
587
- initialEndDate.value = new Date(endDate.value)
588
- }
589
-
590
- emit('show')
591
- },
658
+ invalid: props.invalid,
659
+ label: props.label,
660
+ text: props.text,
661
+ tooltipFeedback: props.tooltipFeedback,
662
+ valid: props.valid,
592
663
  },
593
664
  {
594
- ...(slots.cancelButton && {
595
- cancelButton: () => slots.cancelButton && slots.cancelButton(),
596
- }),
597
- ...(slots.confirmButton && {
598
- confirmButton: () => slots.confirmButton && slots.confirmButton(),
599
- }),
600
- toggler: () => InputGroup(),
601
- footer: () =>
665
+ default: () =>
602
666
  h(
603
- CButton,
667
+ CPicker,
604
668
  {
605
- class: 'me-auto',
606
- color: props.todayButtonColor,
607
- size: props.todayButtonSize,
608
- variant: props.todayButtonVariant,
609
- onClick: () => {
610
- const date = new Date()
611
- startDate.value = date
612
- endDate.value = date
613
- calendarDate.value = date
669
+ cancelButton: props.cancelButton,
670
+ cancelButtonColor: props.cancelButtonColor,
671
+ cancelButtonSize: props.cancelButtonSize,
672
+ cancelButtonVariant: props.cancelButtonVariant,
673
+ class: ['date-picker', { 'is-invalid': props.invalid, 'is-valid': props.valid }],
674
+ confirmButton: props.confirmButton,
675
+ confirmButtonColor: props.confirmButtonColor,
676
+ confirmButtonSize: props.confirmButtonSize,
677
+ confirmButtonVariant: props.confirmButtonVariant,
678
+ disabled: props.disabled,
679
+ footer: props.footer || props.timepicker,
680
+ id: props.id,
681
+ onCancel: () => {
682
+ startDate.value = initialStartDate.value
683
+ endDate.value = initialEndDate.value
684
+ },
685
+ onHide: () => {
686
+ emit('hide')
687
+ },
688
+ onShow: () => {
689
+ if (startDate.value) {
690
+ initialStartDate.value = new Date(startDate.value)
691
+ }
692
+
693
+ if (endDate.value) {
694
+ initialEndDate.value = new Date(endDate.value)
695
+ }
696
+
697
+ emit('show')
614
698
  },
615
699
  },
616
- () => props.todayButton,
617
- ),
618
- default: () =>
619
- h(
620
- 'div',
621
700
  {
622
- class: 'date-picker-body',
623
- },
624
- [
625
- props.ranges &&
701
+ ...(slots.cancelButton && {
702
+ cancelButton: () => slots.cancelButton && slots.cancelButton(),
703
+ }),
704
+ ...(slots.confirmButton && {
705
+ confirmButton: () => slots.confirmButton && slots.confirmButton(),
706
+ }),
707
+ toggler: () => InputGroup(),
708
+ footer: () =>
626
709
  h(
627
- 'div',
628
- { class: 'date-picker-ranges' },
629
- Object.keys(props.ranges).map((key: string) =>
630
- h(
631
- CButton,
632
- {
633
- color: 'secondary',
634
- onClick: () => {
635
- if (props.ranges) {
636
- startDate.value = props.ranges[key][0]
637
- endDate.value = props.ranges[key][1]
638
- }
639
- },
640
- variant: 'ghost',
641
- },
642
- () => key,
643
- ),
644
- ),
645
- ),
646
- h(
647
- 'div',
648
- { class: 'date-picker-calendars' },
649
- h(
650
- CCalendar,
710
+ CButton,
651
711
  {
652
- calendarDate: new Date(
653
- calendarDate.value.getFullYear(),
654
- calendarDate.value.getMonth(),
655
- 1,
656
- ),
657
- calendars: props.calendars,
658
- disabledDates: props.disabledDates,
659
- ...(endDate.value && { endDate: endDate.value }),
660
- firstDayOfWeek: props.firstDayOfWeek,
661
- locale: props.locale,
662
- maxDate: maxDate.value,
663
- minDate: minDate.value,
664
- navigation: props.navigation,
665
- range: props.range,
666
- selectEndDate: selectEndDate.value,
667
- ...(startDate.value && { startDate: startDate.value }),
668
- onCalendarCellHover: (date: Date | null) => handleCalendarCellHover(date),
669
- onCalendarDateChange: (date: Date) => handleCalendarDateChange(date),
670
- onStartDateChange: (date: Date) => handleStartDateChange(date),
671
- onEndDateChange: (date: Date) => handleEndDateChange(date),
672
- },
673
- {
674
- /**
675
- * @slot Location for next icon.
676
- */
677
- ...(slots.navNextIcon && {
678
- navNextIcon: () => slots.navNextIcon && slots.navNextIcon(),
679
- }),
680
- /**
681
- * @slot Location for next double icon.
682
- */
683
- ...(slots.navNextDoubleIcon && {
684
- navNextDoubleIcon: () =>
685
- slots.navNextDoubleIcon && slots.navNextDoubleIcon(),
686
- }),
687
- /**
688
- * @slot Location for previous icon.
689
- */
690
- ...(slots.navPrevIcon && {
691
- navPrevIcon: () => slots.navPrevIcon && slots.navPrevIcon(),
692
- }),
693
- /**
694
- * @slot Location for double previous icon.
695
- */
696
- ...(slots.navPrevDoubleIcon && {
697
- navPrevDoubleIcon: () =>
698
- slots.navPrevDoubleIcon && slots.navPrevDoubleIcon(),
699
- }),
712
+ class: 'me-auto',
713
+ color: props.todayButtonColor,
714
+ size: props.todayButtonSize,
715
+ variant: props.todayButtonVariant,
716
+ onClick: () => {
717
+ const date = new Date()
718
+ startDate.value = date
719
+ endDate.value = date
720
+ calendarDate.value = date
721
+ },
700
722
  },
723
+ () => props.todayButton,
701
724
  ),
702
- ),
703
- props.timepicker &&
725
+ default: () =>
704
726
  h(
705
727
  'div',
706
- { class: 'date-picker-timepickers' },
707
- isMobile.value || (props.range && props.calendars === 1)
708
- ? [
709
- h(CTimePicker, {
710
- container: 'inline',
711
- disabled: startDate.value === null ? true : false,
712
- locale: props.locale,
713
- onChange: (_: any, __: any, date: Date) => handleStartDateChange(date),
714
- time: startDate.value,
715
- variant: 'select',
716
- }),
717
- h(CTimePicker, {
718
- container: 'inline',
719
- disabled: endDate.value === null ? true : false,
720
- locale: props.locale,
721
- onChange: (_: any, __: any, date: Date) => handleEndDateChange(date),
722
- time: endDate.value,
723
- variant: 'select',
724
- }),
725
- ]
726
- : [...Array(props.calendars)].map((_, index) =>
727
- h(CTimePicker, {
728
- container: 'inline',
729
- disabled:
730
- index === 0
731
- ? startDate.value === null
732
- ? true
733
- : false
734
- : endDate.value === null
735
- ? true
736
- : false,
728
+ {
729
+ class: 'date-picker-body',
730
+ },
731
+ [
732
+ props.ranges &&
733
+ h(
734
+ 'div',
735
+ { class: 'date-picker-ranges' },
736
+ Object.keys(props.ranges).map((key: string) =>
737
+ h(
738
+ CButton,
739
+ {
740
+ color: 'secondary',
741
+ onClick: () => {
742
+ if (props.ranges) {
743
+ startDate.value = props.ranges[key][0]
744
+ endDate.value = props.ranges[key][1]
745
+ }
746
+ },
747
+ variant: 'ghost',
748
+ },
749
+ () => key,
750
+ ),
751
+ ),
752
+ ),
753
+ h(
754
+ 'div',
755
+ { class: 'date-picker-calendars' },
756
+ h(
757
+ CCalendar,
758
+ {
759
+ calendarDate: new Date(
760
+ calendarDate.value.getFullYear(),
761
+ calendarDate.value.getMonth(),
762
+ 1,
763
+ ),
764
+ calendars: props.calendars,
765
+ dayFormat: props.dayFormat,
766
+ disabledDates: props.disabledDates,
767
+ ...(endDate.value && { endDate: endDate.value }),
768
+ firstDayOfWeek: props.firstDayOfWeek,
737
769
  locale: props.locale,
738
- onChange: (_: any, __: any, date: Date) =>
739
- index === 0 ? handleStartDateChange(date) : handleEndDateChange(date),
740
- time: index === 0 ? startDate.value : endDate.value,
741
- variant: 'select',
742
- }),
770
+ maxDate: maxDate.value,
771
+ minDate: minDate.value,
772
+ navYearFirst: props.navYearFirst,
773
+ navigation: props.navigation,
774
+ range: props.range,
775
+ selectEndDate: selectEndDate.value,
776
+ ...(startDate.value && { startDate: startDate.value }),
777
+ onCalendarCellHover: (date: Date | null) =>
778
+ handleCalendarCellHover(date),
779
+ onCalendarDateChange: (date: Date) => handleCalendarDateChange(date),
780
+ onStartDateChange: (date: Date) => handleStartDateChange(date),
781
+ onEndDateChange: (date: Date) => handleEndDateChange(date),
782
+ },
783
+ {
784
+ /**
785
+ * @slot Location for next icon.
786
+ */
787
+ ...(slots.navNextIcon && {
788
+ navNextIcon: () => slots.navNextIcon && slots.navNextIcon(),
789
+ }),
790
+ /**
791
+ * @slot Location for next double icon.
792
+ */
793
+ ...(slots.navNextDoubleIcon && {
794
+ navNextDoubleIcon: () =>
795
+ slots.navNextDoubleIcon && slots.navNextDoubleIcon(),
796
+ }),
797
+ /**
798
+ * @slot Location for previous icon.
799
+ */
800
+ ...(slots.navPrevIcon && {
801
+ navPrevIcon: () => slots.navPrevIcon && slots.navPrevIcon(),
802
+ }),
803
+ /**
804
+ * @slot Location for double previous icon.
805
+ */
806
+ ...(slots.navPrevDoubleIcon && {
807
+ navPrevDoubleIcon: () =>
808
+ slots.navPrevDoubleIcon && slots.navPrevDoubleIcon(),
809
+ }),
810
+ },
743
811
  ),
812
+ ),
813
+ props.timepicker &&
814
+ h(
815
+ 'div',
816
+ { class: 'date-picker-timepickers' },
817
+ isMobile.value || (props.range && props.calendars === 1)
818
+ ? [
819
+ h(CTimePicker, {
820
+ container: 'inline',
821
+ disabled: startDate.value === null ? true : false,
822
+ locale: props.locale,
823
+ onChange: (_: any, __: any, date: Date) =>
824
+ handleStartDateChange(date),
825
+ time: startDate.value,
826
+ variant: 'select',
827
+ }),
828
+ h(CTimePicker, {
829
+ container: 'inline',
830
+ disabled: endDate.value === null ? true : false,
831
+ locale: props.locale,
832
+ onChange: (_: any, __: any, date: Date) =>
833
+ handleEndDateChange(date),
834
+ time: endDate.value,
835
+ variant: 'select',
836
+ }),
837
+ ]
838
+ : [...Array(props.calendars)].map((_, index) =>
839
+ h(CTimePicker, {
840
+ container: 'inline',
841
+ disabled:
842
+ index === 0
843
+ ? startDate.value === null
844
+ ? true
845
+ : false
846
+ : endDate.value === null
847
+ ? true
848
+ : false,
849
+ locale: props.locale,
850
+ onChange: (_: any, __: any, date: Date) =>
851
+ index === 0
852
+ ? handleStartDateChange(date)
853
+ : handleEndDateChange(date),
854
+ time: index === 0 ? startDate.value : endDate.value,
855
+ variant: 'select',
856
+ }),
857
+ ),
858
+ ),
859
+ ],
744
860
  ),
745
- ],
861
+ },
746
862
  ),
747
863
  },
748
864
  )
@@ -188,7 +188,7 @@ const CFormInput = defineComponent({
188
188
  onInput: (event: InputEvent) => handleInput(event),
189
189
  readonly: props.readonly,
190
190
  type: props.type,
191
- ...(props.modelValue && { value: props.modelValue }),
191
+ ...((props.modelValue || props.modelValue === 0) && { value: props.modelValue })
192
192
  },
193
193
  slots.default && slots.default(),
194
194
  ),