@coreui/vue-pro 4.8.2 → 4.9.0-beta.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/README.md +1 -1
- package/dist/components/accordion/CAccordion.d.ts +1 -1
- package/dist/components/accordion/CAccordionBody.d.ts +1 -1
- package/dist/components/accordion/CAccordionButton.d.ts +1 -1
- package/dist/components/accordion/CAccordionHeader.d.ts +1 -1
- package/dist/components/accordion/CAccordionItem.d.ts +1 -1
- package/dist/components/alert/CAlert.d.ts +1 -1
- package/dist/components/alert/CAlertHeading.d.ts +1 -1
- package/dist/components/alert/CAlertLink.d.ts +1 -1
- package/dist/components/avatar/CAvatar.d.ts +1 -1
- package/dist/components/backdrop/CBackdrop.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/breadcrumb/CBreadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb/CBreadcrumbItem.d.ts +1 -1
- package/dist/components/button/CButton.d.ts +1 -1
- package/dist/components/button-group/CButtonGroup.d.ts +1 -1
- package/dist/components/button-group/CButtonToolbar.d.ts +1 -1
- package/dist/components/calendar/CCalendar.d.ts +33 -1
- package/dist/components/callout/CCallout.d.ts +1 -1
- package/dist/components/card/CCard.d.ts +1 -1
- package/dist/components/card/CCardBody.d.ts +1 -1
- package/dist/components/card/CCardFooter.d.ts +1 -1
- package/dist/components/card/CCardGroup.d.ts +1 -1
- package/dist/components/card/CCardHeader.d.ts +1 -1
- package/dist/components/card/CCardImage.d.ts +1 -1
- package/dist/components/card/CCardImageOverlay.d.ts +1 -1
- package/dist/components/card/CCardLink.d.ts +1 -1
- package/dist/components/card/CCardSubtitle.d.ts +1 -1
- package/dist/components/card/CCardText.d.ts +1 -1
- package/dist/components/card/CCardTitle.d.ts +1 -1
- package/dist/components/carousel/CCarousel.d.ts +1 -1
- package/dist/components/carousel/CCarouselCaption.d.ts +1 -1
- package/dist/components/carousel/CCarouselItem.d.ts +1 -1
- package/dist/components/close-button/CCloseButton.d.ts +1 -1
- package/dist/components/collapse/CCollapse.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +35 -3
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +89 -78
- package/dist/components/date-range-picker/utils.d.ts +1 -0
- package/dist/components/dropdown/CDropdown.d.ts +2 -2
- package/dist/components/dropdown/CDropdownDivider.d.ts +1 -1
- package/dist/components/dropdown/CDropdownHeader.d.ts +1 -1
- package/dist/components/dropdown/CDropdownItem.d.ts +1 -1
- package/dist/components/dropdown/CDropdownMenu.d.ts +1 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/components/element-cover/CElementCover.d.ts +1 -1
- package/dist/components/footer/CFooter.d.ts +1 -1
- package/dist/components/form/CForm.d.ts +1 -1
- package/dist/components/form/CFormCheck.d.ts +10 -2
- package/dist/components/form/CFormControl.d.ts +2 -2
- package/dist/components/form/CFormControlValidation.d.ts +1 -1
- package/dist/components/form/CFormControlWrapper.d.ts +1 -1
- package/dist/components/form/CFormFeedback.d.ts +1 -1
- package/dist/components/form/CFormFloating.d.ts +1 -1
- package/dist/components/form/CFormInput.d.ts +12 -12
- package/dist/components/form/CFormLabel.d.ts +1 -1
- package/dist/components/form/CFormRange.d.ts +1 -1
- package/dist/components/form/CFormSelect.d.ts +1 -1
- package/dist/components/form/CFormSwitch.d.ts +1 -1
- package/dist/components/form/CFormText.d.ts +1 -1
- package/dist/components/form/CFormTextarea.d.ts +3 -3
- package/dist/components/form/CInputGroup.d.ts +1 -1
- package/dist/components/form/CInputGroupText.d.ts +1 -1
- package/dist/components/grid/CCol.d.ts +1 -1
- package/dist/components/grid/CContainer.d.ts +1 -1
- package/dist/components/grid/CRow.d.ts +1 -1
- package/dist/components/header/CHeader.d.ts +1 -1
- package/dist/components/header/CHeaderBrand.d.ts +1 -1
- package/dist/components/header/CHeaderDivider.d.ts +1 -1
- package/dist/components/header/CHeaderNav.d.ts +1 -1
- package/dist/components/header/CHeaderText.d.ts +1 -1
- package/dist/components/header/CHeaderToggler.d.ts +1 -1
- package/dist/components/image/CImage.d.ts +1 -1
- package/dist/components/link/CLink.d.ts +1 -1
- package/dist/components/list-group/CListGroup.d.ts +1 -1
- package/dist/components/list-group/CListGroupItem.d.ts +1 -1
- package/dist/components/loading-button/CLoadingButton.d.ts +1 -1
- package/dist/components/modal/CModal.d.ts +1 -1
- package/dist/components/modal/CModalBody.d.ts +1 -1
- package/dist/components/modal/CModalFooter.d.ts +1 -1
- package/dist/components/modal/CModalHeader.d.ts +1 -1
- package/dist/components/modal/CModalTitle.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelect.d.ts +73 -59
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +9 -33
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +12 -41
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +6 -59
- package/dist/components/multi-select/types.d.ts +8 -3
- package/dist/components/multi-select/utils.d.ts +9 -4
- package/dist/components/nav/CNav.d.ts +1 -1
- package/dist/components/nav/CNavGroup.d.ts +1 -1
- package/dist/components/nav/CNavGroupItems.d.ts +1 -1
- package/dist/components/nav/CNavItem.d.ts +1 -1
- package/dist/components/nav/CNavLink.d.ts +1 -1
- package/dist/components/nav/CNavTitle.d.ts +1 -1
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/navbar/CNavbarBrand.d.ts +1 -1
- package/dist/components/navbar/CNavbarNav.d.ts +1 -1
- package/dist/components/navbar/CNavbarText.d.ts +1 -1
- package/dist/components/navbar/CNavbarToggler.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvasBody.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvasHeader.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvasTitle.d.ts +1 -1
- package/dist/components/pagination/CPagination.d.ts +1 -1
- package/dist/components/pagination/CPaginationItem.d.ts +1 -1
- package/dist/components/picker/CPicker.d.ts +57 -7
- package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
- package/dist/components/popover/CPopover.d.ts +2 -2
- package/dist/components/progress/CProgress.d.ts +1 -1
- package/dist/components/progress/CProgressBar.d.ts +1 -1
- package/dist/components/sidebar/CSidebar.d.ts +1 -1
- package/dist/components/sidebar/CSidebarBrand.d.ts +1 -1
- package/dist/components/sidebar/CSidebarFooter.d.ts +1 -1
- package/dist/components/sidebar/CSidebarHeader.d.ts +1 -1
- package/dist/components/sidebar/CSidebarNav.d.ts +1 -1
- package/dist/components/sidebar/CSidebarToggler.d.ts +1 -1
- package/dist/components/smart-pagination/CSmartPagination.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +20 -56
- package/dist/components/smart-table/CSmartTableBody.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableCleaner.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableFilter.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableHead.d.ts +10 -1
- package/dist/components/smart-table/CSmartTableItemsPerPageSelector.d.ts +1 -1
- package/dist/components/smart-table/types.d.ts +12 -0
- package/dist/components/smart-table/utils.d.ts +12 -2
- package/dist/components/spinner/CSpinner.d.ts +1 -1
- package/dist/components/table/CTable.d.ts +1 -1
- package/dist/components/table/CTableBody.d.ts +1 -1
- package/dist/components/table/CTableCaption.d.ts +1 -1
- package/dist/components/table/CTableDataCell.d.ts +1 -1
- package/dist/components/table/CTableFoot.d.ts +1 -1
- package/dist/components/table/CTableHead.d.ts +1 -1
- package/dist/components/table/CTableHeaderCell.d.ts +1 -1
- package/dist/components/table/CTableRow.d.ts +1 -1
- package/dist/components/tabs/CTabContent.d.ts +1 -1
- package/dist/components/tabs/CTabPane.d.ts +1 -1
- package/dist/components/time-picker/CTimePicker.d.ts +1 -1
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +1 -1
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/components/toast/CToastBody.d.ts +1 -1
- package/dist/components/toast/CToastClose.d.ts +1 -1
- package/dist/components/toast/CToastHeader.d.ts +1 -1
- package/dist/components/toast/CToaster.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +2 -2
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsE.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/useColorModes.d.ts +5 -0
- package/dist/directives/index.d.ts +1 -1
- package/dist/directives/v-c-visible.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +4224 -4159
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4226 -4160
- package/dist/index.js.map +1 -1
- package/dist/utils/getUID.d.ts +2 -0
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/isObjectInArray.d.ts +2 -0
- package/dist/utils/isRTL.d.ts +2 -0
- package/package.json +11 -11
- package/src/components/accordion/CAccordionItem.ts +2 -2
- package/src/components/backdrop/CBackdrop.ts +1 -1
- package/src/components/calendar/CCalendar.ts +111 -49
- package/src/components/carousel/CCarousel.ts +7 -7
- package/src/components/date-picker/CDatePicker.ts +16 -1
- package/src/components/date-range-picker/CDateRangePicker.ts +179 -128
- package/src/components/date-range-picker/utils.ts +49 -0
- package/src/components/dropdown/CDropdown.ts +34 -31
- package/src/components/dropdown/CDropdownMenu.ts +1 -1
- package/src/components/dropdown/CDropdownToggle.ts +1 -1
- package/src/components/element-cover/CElementCover.ts +1 -0
- package/src/components/form/CFormCheck.ts +10 -4
- package/src/components/form/CFormInput.ts +2 -2
- package/src/components/form/CFormLabel.ts +1 -1
- package/src/components/form/CFormSelect.ts +1 -1
- package/src/components/grid/CCol.ts +1 -1
- package/src/components/grid/CContainer.ts +1 -1
- package/src/components/header/CHeader.ts +1 -1
- package/src/components/modal/CModal.ts +1 -0
- package/src/components/multi-select/CMultiSelect.ts +337 -144
- package/src/components/multi-select/CMultiSelectNativeSelect.ts +8 -15
- package/src/components/multi-select/CMultiSelectOptions.ts +32 -39
- package/src/components/multi-select/CMultiSelectSelection.ts +24 -40
- package/src/components/multi-select/types.ts +10 -4
- package/src/components/multi-select/utils.ts +71 -37
- package/src/components/nav/CNavGroup.ts +4 -0
- package/src/components/navbar/CNavbar.ts +1 -1
- package/src/components/navbar/CNavbarBrand.ts +1 -1
- package/src/components/offcanvas/COffcanvas.ts +3 -2
- package/src/components/pagination/CPaginationItem.ts +1 -1
- package/src/components/picker/CPicker.ts +106 -157
- package/src/components/popover/CPopover.ts +18 -2
- package/src/components/props.ts +2 -6
- package/src/components/sidebar/CSidebar.ts +3 -2
- package/src/components/smart-table/CSmartTable.ts +45 -52
- package/src/components/smart-table/CSmartTableBody.ts +5 -3
- package/src/components/smart-table/CSmartTableHead.ts +41 -14
- package/src/components/smart-table/types.ts +13 -0
- package/src/components/smart-table/utils.ts +119 -21
- package/src/components/spinner/CSpinner.ts +4 -2
- package/src/components/table/CTable.ts +19 -18
- package/src/components/table/types.ts +19 -19
- package/src/components/time-picker/CTimePicker.ts +216 -125
- package/src/components/toast/CToast.ts +1 -1
- package/src/components/tooltip/CTooltip.ts +19 -3
- package/src/components/virtual-scroller/CVirtualScroller.ts +10 -8
- package/src/components/widgets/CWidgetStatsA.ts +1 -1
- package/src/components/widgets/CWidgetStatsB.ts +1 -1
- package/src/components/widgets/CWidgetStatsC.ts +1 -1
- package/src/components/widgets/CWidgetStatsE.ts +1 -1
- package/src/components/widgets/CWidgetStatsF.ts +1 -1
- package/src/composables/index.ts +3 -0
- package/src/composables/useColorModes.ts +57 -0
- package/src/directives/index.ts +1 -1
- package/src/directives/v-c-popover.ts +9 -13
- package/src/directives/v-c-tooltip.ts +8 -12
- package/src/directives/v-c-visible.ts +1 -1
- package/src/index.ts +8 -29
- package/src/utils/getUID.ts +9 -0
- package/src/utils/index.ts +4 -1
- package/src/utils/isObjectInArray.ts +14 -0
- package/src/utils/isRTL.ts +13 -0
|
@@ -1,93 +1,11 @@
|
|
|
1
|
-
import { defineComponent, h, PropType, ref, watch } from 'vue'
|
|
1
|
+
import { cloneVNode, defineComponent, h, PropType, ref, watch } from 'vue'
|
|
2
|
+
import { createPopper } from '@popperjs/core'
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
import { CDropdown, CDropdownMenu, CDropdownToggle } from '../dropdown/'
|
|
5
|
-
|
|
6
|
-
import { Color } from '../props'
|
|
4
|
+
import { isRTL } from '../../utils'
|
|
7
5
|
|
|
8
6
|
const CPicker = defineComponent({
|
|
9
7
|
name: 'CPicker',
|
|
10
8
|
props: {
|
|
11
|
-
...CDropdown.props,
|
|
12
|
-
/**
|
|
13
|
-
* Toggle visibility or set the content of cancel button.
|
|
14
|
-
*/
|
|
15
|
-
cancelButton: {
|
|
16
|
-
type: [Boolean, String],
|
|
17
|
-
default: 'Cancel',
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* Sets the color context of the cancel button to one of CoreUI’s themed colors.
|
|
21
|
-
*
|
|
22
|
-
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
23
|
-
*/
|
|
24
|
-
cancelButtonColor: {
|
|
25
|
-
...Color,
|
|
26
|
-
default: 'primary',
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Size the cancel button small or large.
|
|
30
|
-
*
|
|
31
|
-
* @values 'sm', 'lg'
|
|
32
|
-
*/
|
|
33
|
-
cancelButtonSize: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: 'sm',
|
|
36
|
-
validator: (value: string) => {
|
|
37
|
-
return ['sm', 'lg'].includes(value)
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Set the cancel button variant to an outlined button or a ghost button.
|
|
42
|
-
*
|
|
43
|
-
* @values 'ghost', 'outline'
|
|
44
|
-
*/
|
|
45
|
-
cancelButtonVariant: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: 'ghost',
|
|
48
|
-
validator: (value: string) => {
|
|
49
|
-
return ['ghost', 'outline'].includes(value)
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* Toggle visibility or set the content of confirm button.
|
|
54
|
-
*/
|
|
55
|
-
confirmButton: {
|
|
56
|
-
type: [Boolean, String],
|
|
57
|
-
default: 'OK',
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* Sets the color context of the confirm button to one of CoreUI’s themed colors.
|
|
61
|
-
*
|
|
62
|
-
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
63
|
-
*/
|
|
64
|
-
confirmButtonColor: {
|
|
65
|
-
...Color,
|
|
66
|
-
default: 'primary',
|
|
67
|
-
},
|
|
68
|
-
/**
|
|
69
|
-
* Size the confirm button small or large.
|
|
70
|
-
*
|
|
71
|
-
* @values 'sm', 'lg'
|
|
72
|
-
*/
|
|
73
|
-
confirmButtonSize: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: 'sm',
|
|
76
|
-
validator: (value: string) => {
|
|
77
|
-
return ['sm', 'lg'].includes(value)
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Set the confirm button variant to an outlined button or a ghost button.
|
|
82
|
-
*
|
|
83
|
-
* @values 'ghost', 'outline'
|
|
84
|
-
*/
|
|
85
|
-
confirmButtonVariant: {
|
|
86
|
-
type: String,
|
|
87
|
-
validator: (value: string) => {
|
|
88
|
-
return ['ghost', 'outline'].includes(value)
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
9
|
/**
|
|
92
10
|
* Set container type for the component.
|
|
93
11
|
*/
|
|
@@ -99,6 +17,10 @@ const CPicker = defineComponent({
|
|
|
99
17
|
* Toggle the disabled state for the component.
|
|
100
18
|
*/
|
|
101
19
|
disabled: Boolean,
|
|
20
|
+
/**
|
|
21
|
+
* A string of all className you want applied to the dropdown menu.
|
|
22
|
+
*/
|
|
23
|
+
dropdownClassNames: String,
|
|
102
24
|
/**
|
|
103
25
|
* Toggle visibility of footer element or set the content of footer.
|
|
104
26
|
*/
|
|
@@ -109,14 +31,6 @@ const CPicker = defineComponent({
|
|
|
109
31
|
visible: Boolean,
|
|
110
32
|
},
|
|
111
33
|
emits: [
|
|
112
|
-
/**
|
|
113
|
-
* Callback fired when the cancel button has been clicked.
|
|
114
|
-
*/
|
|
115
|
-
'cancel',
|
|
116
|
-
/**
|
|
117
|
-
* Callback fired when the confirm button has been clicked.
|
|
118
|
-
*/
|
|
119
|
-
'confirm',
|
|
120
34
|
/**
|
|
121
35
|
* Callback fired when the component requests to be hidden.
|
|
122
36
|
*/
|
|
@@ -126,7 +40,12 @@ const CPicker = defineComponent({
|
|
|
126
40
|
*/
|
|
127
41
|
'show',
|
|
128
42
|
],
|
|
129
|
-
setup(props, { emit, slots }) {
|
|
43
|
+
setup(props, { attrs, emit, slots }) {
|
|
44
|
+
const pickerRef = ref()
|
|
45
|
+
const dropdownRef = ref()
|
|
46
|
+
const togglerRef = ref()
|
|
47
|
+
|
|
48
|
+
const popper = ref()
|
|
130
49
|
const visible = ref(props.visible)
|
|
131
50
|
|
|
132
51
|
watch(
|
|
@@ -136,85 +55,115 @@ const CPicker = defineComponent({
|
|
|
136
55
|
},
|
|
137
56
|
)
|
|
138
57
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
58
|
+
watch(visible, () => {
|
|
59
|
+
if (props.container === 'inline') {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
143
62
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
63
|
+
if (visible.value) {
|
|
64
|
+
emit('show')
|
|
65
|
+
window.addEventListener('mouseup', handleMouseUp)
|
|
66
|
+
window.addEventListener('keyup', handleKeyUp)
|
|
67
|
+
initPopper()
|
|
68
|
+
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
emit('hide')
|
|
73
|
+
window.removeEventListener('mouseup', handleMouseUp)
|
|
74
|
+
window.removeEventListener('keyup', handleKeyUp)
|
|
75
|
+
|
|
76
|
+
destroyPopper()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const initPopper = () => {
|
|
80
|
+
if (togglerRef.value && dropdownRef.value) {
|
|
81
|
+
popper.value = createPopper(togglerRef.value, dropdownRef.value, {
|
|
82
|
+
placement: isRTL(pickerRef.value) ? 'bottom-end' : 'bottom-start',
|
|
83
|
+
modifiers: [
|
|
150
84
|
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
85
|
+
name: 'preventOverflow',
|
|
86
|
+
options: {
|
|
87
|
+
boundary: 'clippingParents',
|
|
88
|
+
},
|
|
155
89
|
},
|
|
156
|
-
/**
|
|
157
|
-
* @slot Location for the cancel button content.
|
|
158
|
-
*/
|
|
159
|
-
() => (slots.cancelButton ? slots.cancelButton() : props.cancelButton),
|
|
160
|
-
),
|
|
161
|
-
props.confirmButton &&
|
|
162
|
-
h(
|
|
163
|
-
CButton,
|
|
164
90
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
91
|
+
name: 'offset',
|
|
92
|
+
options: {
|
|
93
|
+
offset: [0, 2],
|
|
94
|
+
},
|
|
169
95
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
96
|
+
],
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const destroyPopper = () => {
|
|
102
|
+
if (popper.value) {
|
|
103
|
+
popper.value.destroy()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
popper.value = undefined
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const handleKeyUp = (event: KeyboardEvent) => {
|
|
110
|
+
if (event.key === 'Escape') {
|
|
111
|
+
visible.value = false
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const handleMouseUp = (event: Event) => {
|
|
116
|
+
if (pickerRef.value && pickerRef.value.contains(event.target as HTMLElement)) {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
visible.value = false
|
|
121
|
+
}
|
|
176
122
|
|
|
177
123
|
switch (props.container) {
|
|
178
|
-
case 'inline':
|
|
179
|
-
return () => h('div', { class: 'picker' }, slots.default && slots.default())
|
|
180
|
-
|
|
124
|
+
case 'inline': {
|
|
125
|
+
return () => h('div', { class: 'picker', ref: pickerRef }, slots.default && slots.default())
|
|
126
|
+
}
|
|
127
|
+
default: {
|
|
181
128
|
return () =>
|
|
182
129
|
h(
|
|
183
|
-
|
|
130
|
+
'div',
|
|
184
131
|
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
onHide: () => {
|
|
188
|
-
visible.value = false
|
|
189
|
-
emit('hide')
|
|
190
|
-
},
|
|
191
|
-
onShow: () => {
|
|
192
|
-
visible.value = true
|
|
193
|
-
emit('show')
|
|
194
|
-
},
|
|
195
|
-
variant: 'dropdown',
|
|
196
|
-
visible: visible.value,
|
|
197
|
-
},
|
|
198
|
-
() => [
|
|
199
|
-
h(
|
|
200
|
-
CDropdownToggle,
|
|
132
|
+
class: [
|
|
133
|
+
attrs.class,
|
|
201
134
|
{
|
|
202
|
-
|
|
203
|
-
disabled: visible.value || props.disabled,
|
|
135
|
+
show: visible.value,
|
|
204
136
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
137
|
+
],
|
|
138
|
+
ref: pickerRef,
|
|
139
|
+
},
|
|
140
|
+
[
|
|
141
|
+
/**
|
|
142
|
+
* @slot Location for the toggler element.
|
|
143
|
+
*/
|
|
144
|
+
slots.toggler &&
|
|
145
|
+
slots.toggler().map((slot) =>
|
|
146
|
+
cloneVNode(slot, {
|
|
147
|
+
onClick: () => {
|
|
148
|
+
if (!props.disabled && !visible.value) {
|
|
149
|
+
visible.value = true
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
ref: (el) => {
|
|
153
|
+
togglerRef.value = el
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
h('div', { class: props.dropdownClassNames, ref: dropdownRef }, [
|
|
213
158
|
slots.default && slots.default(),
|
|
214
|
-
|
|
159
|
+
/**
|
|
160
|
+
* @slot Location for the footer element.
|
|
161
|
+
*/
|
|
162
|
+
slots.footer && slots.footer(),
|
|
215
163
|
]),
|
|
216
164
|
],
|
|
217
165
|
)
|
|
166
|
+
}
|
|
218
167
|
}
|
|
219
168
|
},
|
|
220
169
|
})
|
|
@@ -2,6 +2,21 @@ import { defineComponent, h, PropType, ref, RendererElement, Teleport, Transitio
|
|
|
2
2
|
import { createPopper, Placement } from '@popperjs/core'
|
|
3
3
|
|
|
4
4
|
import { executeAfterTransition } from '../../utils/transition'
|
|
5
|
+
import { isRTL } from '../../utils'
|
|
6
|
+
|
|
7
|
+
const getPlacement = (placement: string, element: HTMLDivElement | null): Placement => {
|
|
8
|
+
switch (placement) {
|
|
9
|
+
case 'right': {
|
|
10
|
+
return isRTL(element) ? 'left' : 'right'
|
|
11
|
+
}
|
|
12
|
+
case 'left': {
|
|
13
|
+
return isRTL(element) ? 'right' : 'left'
|
|
14
|
+
}
|
|
15
|
+
default: {
|
|
16
|
+
return placement as Placement
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
5
20
|
|
|
6
21
|
const CPopover = defineComponent({
|
|
7
22
|
name: 'CPopover',
|
|
@@ -64,7 +79,7 @@ const CPopover = defineComponent({
|
|
|
64
79
|
*/
|
|
65
80
|
'show',
|
|
66
81
|
],
|
|
67
|
-
setup(props, { slots, emit }) {
|
|
82
|
+
setup(props, { attrs, slots, emit }) {
|
|
68
83
|
const togglerRef = ref()
|
|
69
84
|
const popoverRef = ref()
|
|
70
85
|
const popper = ref()
|
|
@@ -94,7 +109,7 @@ const CPopover = defineComponent({
|
|
|
94
109
|
const initPopper = () => {
|
|
95
110
|
if (togglerRef.value) {
|
|
96
111
|
popper.value = createPopper(togglerRef.value, popoverRef.value, {
|
|
97
|
-
placement: props.placement,
|
|
112
|
+
placement: getPlacement(props.placement, togglerRef.value),
|
|
98
113
|
modifiers: [
|
|
99
114
|
{
|
|
100
115
|
name: 'offset',
|
|
@@ -134,6 +149,7 @@ const CPopover = defineComponent({
|
|
|
134
149
|
class: 'popover fade bs-popover-auto',
|
|
135
150
|
ref: popoverRef,
|
|
136
151
|
role: 'tooltip',
|
|
152
|
+
...attrs,
|
|
137
153
|
},
|
|
138
154
|
[
|
|
139
155
|
h('div', { class: 'popover-arrow', 'data-popper-arrow': '' }),
|
package/src/components/props.ts
CHANGED
|
@@ -79,10 +79,6 @@ export const TextColor = {
|
|
|
79
79
|
|
|
80
80
|
export const Breakpoint = {
|
|
81
81
|
validator: (value: boolean | number): boolean => {
|
|
82
|
-
|
|
83
|
-
return true
|
|
84
|
-
} else {
|
|
85
|
-
return false
|
|
86
|
-
}
|
|
82
|
+
return typeof value == 'boolean' || typeof value == 'number' ? true : false
|
|
87
83
|
},
|
|
88
|
-
}
|
|
84
|
+
}
|
|
@@ -105,7 +105,7 @@ const CSidebar = defineComponent({
|
|
|
105
105
|
mobile.value = isOnMobile(sidebarRef.value)
|
|
106
106
|
inViewport.value = isInViewport(sidebarRef.value)
|
|
107
107
|
|
|
108
|
-
window.addEventListener('resize',
|
|
108
|
+
window.addEventListener('resize', handleResize)
|
|
109
109
|
window.addEventListener('mouseup', handleClickOutside)
|
|
110
110
|
window.addEventListener('keyup', handleKeyup)
|
|
111
111
|
|
|
@@ -116,11 +116,12 @@ const CSidebar = defineComponent({
|
|
|
116
116
|
})
|
|
117
117
|
|
|
118
118
|
onBeforeUnmount(() => {
|
|
119
|
-
window.removeEventListener('resize',
|
|
119
|
+
window.removeEventListener('resize', handleResize)
|
|
120
120
|
window.removeEventListener('mouseup', handleClickOutside)
|
|
121
121
|
window.removeEventListener('keyup', handleKeyup)
|
|
122
122
|
|
|
123
123
|
sidebarRef.value.removeEventListener('mouseup', handleOnClick)
|
|
124
|
+
// eslint-disable-next-line unicorn/no-invalid-remove-event-listener
|
|
124
125
|
sidebarRef.value.removeEventListener('transitionend', () => {
|
|
125
126
|
inViewport.value = isInViewport(sidebarRef.value)
|
|
126
127
|
})
|
|
@@ -11,12 +11,13 @@ import { CTable, CTableDataCell, CTableFoot, CTableRow } from '../table'
|
|
|
11
11
|
import { CSmartTableBody } from './CSmartTableBody'
|
|
12
12
|
import { CSmartTableHead } from './CSmartTableHead'
|
|
13
13
|
|
|
14
|
+
import { isObjectInArray } from '../../utils'
|
|
15
|
+
|
|
14
16
|
import {
|
|
15
17
|
filterColumns,
|
|
16
18
|
filterTable,
|
|
17
19
|
getColumnNames,
|
|
18
20
|
getColumnNamesFromItems,
|
|
19
|
-
isObjectInArray,
|
|
20
21
|
isSortable,
|
|
21
22
|
sortItems,
|
|
22
23
|
} from './utils'
|
|
@@ -49,15 +50,11 @@ const CSmartTable = defineComponent({
|
|
|
49
50
|
* Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable (`tabIndex="0"` `role="button"`, `color="danger"`), otherwise it is not clickable and transparent. Cleaner can be customized through the `cleanerIcon` slot.
|
|
50
51
|
*
|
|
51
52
|
*/
|
|
52
|
-
cleaner:
|
|
53
|
-
type: Boolean,
|
|
54
|
-
},
|
|
53
|
+
cleaner: Boolean,
|
|
55
54
|
/**
|
|
56
55
|
* Style table items as clickable.
|
|
57
56
|
*/
|
|
58
|
-
clickableRows:
|
|
59
|
-
type: Boolean,
|
|
60
|
-
},
|
|
57
|
+
clickableRows: Boolean,
|
|
61
58
|
/**
|
|
62
59
|
* When set, displays additional filter row between table header and items, allowing filtering by specific column.
|
|
63
60
|
* Column filter can be customized, by passing prop as object with additional options as keys. Available options:
|
|
@@ -169,9 +166,7 @@ const CSmartTable = defineComponent({
|
|
|
169
166
|
/**
|
|
170
167
|
* When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller.
|
|
171
168
|
*/
|
|
172
|
-
loading:
|
|
173
|
-
type: Boolean,
|
|
174
|
-
},
|
|
169
|
+
loading: Boolean,
|
|
175
170
|
/**
|
|
176
171
|
* ReactNode or string for passing custom noItemsLabel texts.
|
|
177
172
|
*/
|
|
@@ -188,9 +183,7 @@ const CSmartTable = defineComponent({
|
|
|
188
183
|
/**
|
|
189
184
|
* Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component.
|
|
190
185
|
*/
|
|
191
|
-
paginationProps:
|
|
192
|
-
type: Object,
|
|
193
|
-
},
|
|
186
|
+
paginationProps: Object,
|
|
194
187
|
/**
|
|
195
188
|
* Add checkboxes to make table rows selectable.
|
|
196
189
|
*/
|
|
@@ -227,15 +220,11 @@ const CSmartTable = defineComponent({
|
|
|
227
220
|
/**
|
|
228
221
|
* Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component.
|
|
229
222
|
*/
|
|
230
|
-
tableBodyProps:
|
|
231
|
-
type: Object,
|
|
232
|
-
},
|
|
223
|
+
tableBodyProps: Object,
|
|
233
224
|
/**
|
|
234
225
|
* Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component.
|
|
235
226
|
*/
|
|
236
|
-
tableFootProps:
|
|
237
|
-
type: Object,
|
|
238
|
-
},
|
|
227
|
+
tableFootProps: Object,
|
|
239
228
|
/**
|
|
240
229
|
* When set, displays table filter above table, allowing filtering by specific column.
|
|
241
230
|
*
|
|
@@ -263,21 +252,15 @@ const CSmartTable = defineComponent({
|
|
|
263
252
|
/**
|
|
264
253
|
* Value of table filter.
|
|
265
254
|
*/
|
|
266
|
-
tableFilterValue:
|
|
267
|
-
type: String,
|
|
268
|
-
},
|
|
255
|
+
tableFilterValue: String,
|
|
269
256
|
/**
|
|
270
257
|
* Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component.
|
|
271
258
|
*/
|
|
272
|
-
tableHeadProps:
|
|
273
|
-
type: Object,
|
|
274
|
-
},
|
|
259
|
+
tableHeadProps: Object,
|
|
275
260
|
/**
|
|
276
261
|
* Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component.
|
|
277
262
|
*/
|
|
278
|
-
tableProps:
|
|
279
|
-
type: Object,
|
|
280
|
-
},
|
|
263
|
+
tableProps: Object,
|
|
281
264
|
},
|
|
282
265
|
emits: [
|
|
283
266
|
/**
|
|
@@ -340,20 +323,19 @@ const CSmartTable = defineComponent({
|
|
|
340
323
|
],
|
|
341
324
|
setup(props, { emit, slots }) {
|
|
342
325
|
const activePage = ref(props.activePage)
|
|
343
|
-
const columnFilterState = ref<ColumnFilterValue>(
|
|
344
|
-
props.columnFilterValue ? props.columnFilterValue : {},
|
|
345
|
-
)
|
|
326
|
+
const columnFilterState = ref<ColumnFilterValue>(props.columnFilterValue ?? {})
|
|
346
327
|
const items = ref<Item[]>(
|
|
347
328
|
props.items.map((item: Item, index: number) => {
|
|
348
329
|
return { ...item, _id: index }
|
|
349
330
|
}),
|
|
350
331
|
)
|
|
351
332
|
const itemsNumber = ref(props.itemsNumber)
|
|
333
|
+
// eslint-disable-next-line unicorn/explicit-length-check
|
|
352
334
|
const itemsPerPage = ref<number>(props.itemsPerPage || items.value.length)
|
|
353
335
|
const selected = ref<Item[]>([])
|
|
354
336
|
const selectedAll = ref<boolean | string>()
|
|
355
337
|
const sorterState = ref<SorterValue>(props.sorterValue || {})
|
|
356
|
-
const tableFilterState = ref(props.tableFilterValue
|
|
338
|
+
const tableFilterState = ref(props.tableFilterValue ?? '')
|
|
357
339
|
|
|
358
340
|
watch(
|
|
359
341
|
() => props.activePage,
|
|
@@ -394,9 +376,13 @@ const CSmartTable = defineComponent({
|
|
|
394
376
|
|
|
395
377
|
if (Array.isArray(props.items)) {
|
|
396
378
|
items.value = props.items
|
|
379
|
+
// eslint-disable-next-line unicorn/explicit-length-check
|
|
397
380
|
itemsNumber.value = props.itemsNumber || props.items.length
|
|
398
381
|
}
|
|
399
382
|
},
|
|
383
|
+
{
|
|
384
|
+
immediate: true,
|
|
385
|
+
},
|
|
400
386
|
)
|
|
401
387
|
|
|
402
388
|
watch(
|
|
@@ -437,23 +423,31 @@ const CSmartTable = defineComponent({
|
|
|
437
423
|
emit('itemsPerPageChange', itemsPerPage.value)
|
|
438
424
|
})
|
|
439
425
|
|
|
440
|
-
watch(
|
|
441
|
-
|
|
426
|
+
watch(
|
|
427
|
+
[selected, itemsNumber],
|
|
428
|
+
() => {
|
|
429
|
+
if (props.selectable) {
|
|
430
|
+
emit('selectedItemsChange', selected)
|
|
442
431
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
432
|
+
if (selected.value.length === itemsNumber.value) {
|
|
433
|
+
selectedAll.value = true
|
|
434
|
+
return
|
|
435
|
+
}
|
|
447
436
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
437
|
+
if (selected.value.length === 0) {
|
|
438
|
+
selectedAll.value = false
|
|
439
|
+
return
|
|
440
|
+
}
|
|
452
441
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
442
|
+
if (selected.value.length > 0 && selected.value.length !== itemsNumber.value) {
|
|
443
|
+
selectedAll.value = 'indeterminate'
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
immediate: true,
|
|
449
|
+
},
|
|
450
|
+
)
|
|
457
451
|
|
|
458
452
|
onMounted(() => {
|
|
459
453
|
if (
|
|
@@ -541,11 +535,9 @@ const CSmartTable = defineComponent({
|
|
|
541
535
|
}
|
|
542
536
|
|
|
543
537
|
selected.value = items.value.map((item) => {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
return item
|
|
538
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
539
|
+
const { _cellProps, _props, _selected, ...rest } = item
|
|
540
|
+
return rest
|
|
549
541
|
})
|
|
550
542
|
}
|
|
551
543
|
|
|
@@ -738,7 +730,7 @@ const CSmartTable = defineComponent({
|
|
|
738
730
|
...props.tableHeadProps,
|
|
739
731
|
columnFilter: props.columnFilter,
|
|
740
732
|
columnFilterValue: columnFilterState.value,
|
|
741
|
-
columns: props.columns
|
|
733
|
+
columns: props.columns ?? columnNames.value,
|
|
742
734
|
columnSorter: props.columnSorter,
|
|
743
735
|
items: items.value,
|
|
744
736
|
selectable: props.selectable,
|
|
@@ -820,6 +812,7 @@ const CSmartTable = defineComponent({
|
|
|
820
812
|
selectable: props.selectable,
|
|
821
813
|
selectAll: props.selectAll,
|
|
822
814
|
selectedAll: selectedAll.value,
|
|
815
|
+
showGroups: false,
|
|
823
816
|
onSelectAllChecked: () => handleSelectAllChecked(),
|
|
824
817
|
}),
|
|
825
818
|
Array.isArray(props.footer) &&
|
|
@@ -3,8 +3,9 @@ import { defineComponent, h, PropType } from 'vue'
|
|
|
3
3
|
import { CFormCheck } from '../form/'
|
|
4
4
|
import { CTableBody, CTableDataCell, CTableRow } from '../table/'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { isObjectInArray } from '../../utils'
|
|
7
7
|
|
|
8
|
+
import { getClickedColumnName, getTableDataCellProps } from './utils'
|
|
8
9
|
import type { Item } from './types'
|
|
9
10
|
|
|
10
11
|
const CSmartTableBody = defineComponent({
|
|
@@ -43,7 +44,7 @@ const CSmartTableBody = defineComponent({
|
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
default: () =>
|
|
46
|
-
props.currentItems.length
|
|
47
|
+
props.currentItems.length > 0
|
|
47
48
|
? props.currentItems.map((item: Item, trIndex) => [
|
|
48
49
|
h(
|
|
49
50
|
CTableRow,
|
|
@@ -85,7 +86,8 @@ const CSmartTableBody = defineComponent({
|
|
|
85
86
|
props.scopedSlots[colName] &&
|
|
86
87
|
typeof props.scopedSlots[colName] === 'function'
|
|
87
88
|
? h(props.scopedSlots[colName], { item: item })
|
|
88
|
-
:
|
|
89
|
+
: typeof item[colName] !== 'undefined' &&
|
|
90
|
+
h(
|
|
89
91
|
CTableDataCell,
|
|
90
92
|
{
|
|
91
93
|
...getTableDataCellProps(item, colName),
|