@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,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, PropType } from 'vue'
|
|
1
|
+
import { computed, defineComponent, h, PropType } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { CFormCheck, CFormInput } from '../form/'
|
|
4
4
|
import { CTableFoot, CTableHead, CTableHeaderCell, CTableRow } from '../table/'
|
|
@@ -6,6 +6,8 @@ import { CTableFoot, CTableHead, CTableHeaderCell, CTableRow } from '../table/'
|
|
|
6
6
|
import {
|
|
7
7
|
getColumnKey,
|
|
8
8
|
getColumnLabel,
|
|
9
|
+
getColumnGroups,
|
|
10
|
+
getColumns,
|
|
9
11
|
getColumnSorterState,
|
|
10
12
|
getColumnValues,
|
|
11
13
|
getTableHeaderCellProps,
|
|
@@ -35,10 +37,17 @@ const CSmartTableHead = defineComponent({
|
|
|
35
37
|
selectable: Boolean,
|
|
36
38
|
selectAll: [Boolean, Object] as PropType<boolean | { external?: boolean }>,
|
|
37
39
|
selectedAll: [Boolean, String],
|
|
40
|
+
showGroups: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true,
|
|
43
|
+
},
|
|
38
44
|
sorterState: Object as PropType<SorterValue>,
|
|
39
45
|
},
|
|
40
46
|
emits: ['customFilterChange', 'filterInput', 'filterChange', 'selectAllChecked', 'sortClick'],
|
|
41
47
|
setup(props, { slots, emit }) {
|
|
48
|
+
const columns = computed(() => getColumns(props.columns))
|
|
49
|
+
const groups = computed(() => getColumnGroups(props.columns))
|
|
50
|
+
|
|
42
51
|
const columnSorterIcon = (column: Column | string) => {
|
|
43
52
|
if (getColumnSorterState(getColumnKey(column), props.sorterState) === 0) {
|
|
44
53
|
return h(
|
|
@@ -73,6 +82,24 @@ const CSmartTableHead = defineComponent({
|
|
|
73
82
|
{},
|
|
74
83
|
{
|
|
75
84
|
default: () => [
|
|
85
|
+
props.showGroups &&
|
|
86
|
+
groups.value &&
|
|
87
|
+
groups.value.length > 0 &&
|
|
88
|
+
groups.value.map((row) => [
|
|
89
|
+
h(CTableRow, {}, () => [
|
|
90
|
+
props.selectable && h(CTableHeaderCell),
|
|
91
|
+
row.map((cell) =>
|
|
92
|
+
h(
|
|
93
|
+
CTableHeaderCell,
|
|
94
|
+
{
|
|
95
|
+
colspan: cell.colspan,
|
|
96
|
+
...getTableHeaderCellProps(cell),
|
|
97
|
+
},
|
|
98
|
+
() => cell.label,
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
]),
|
|
102
|
+
]),
|
|
76
103
|
h(
|
|
77
104
|
CTableRow,
|
|
78
105
|
{},
|
|
@@ -81,14 +108,14 @@ const CSmartTableHead = defineComponent({
|
|
|
81
108
|
props.selectable &&
|
|
82
109
|
h(CTableHeaderCell, {}, () =>
|
|
83
110
|
h(CFormCheck, {
|
|
84
|
-
checked: typeof props.selectedAll === 'boolean' ? props.
|
|
111
|
+
checked: typeof props.selectedAll === 'boolean' ? props.selectedAll : false,
|
|
85
112
|
indeterminate: props.selectedAll === 'indeterminate' ? true : false,
|
|
86
113
|
onChange: () => {
|
|
87
114
|
emit('selectAllChecked')
|
|
88
115
|
},
|
|
89
116
|
}),
|
|
90
117
|
),
|
|
91
|
-
|
|
118
|
+
columns.value.map((column, index: number) =>
|
|
92
119
|
h(
|
|
93
120
|
CTableHeaderCell,
|
|
94
121
|
{
|
|
@@ -108,11 +135,11 @@ const CSmartTableHead = defineComponent({
|
|
|
108
135
|
getColumnLabel(column),
|
|
109
136
|
),
|
|
110
137
|
props.columnSorter &&
|
|
111
|
-
(typeof column
|
|
112
|
-
?
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
:
|
|
138
|
+
(typeof column === 'object'
|
|
139
|
+
? typeof column.sorter === 'undefined'
|
|
140
|
+
? true
|
|
141
|
+
: column.sorter
|
|
142
|
+
: true) &&
|
|
116
143
|
columnSorterIcon(column),
|
|
117
144
|
],
|
|
118
145
|
},
|
|
@@ -128,7 +155,7 @@ const CSmartTableHead = defineComponent({
|
|
|
128
155
|
{
|
|
129
156
|
default: () => [
|
|
130
157
|
props.selectable && h(CTableHeaderCell),
|
|
131
|
-
|
|
158
|
+
columns.value.map((column: Column | string) =>
|
|
132
159
|
h(
|
|
133
160
|
CTableHeaderCell,
|
|
134
161
|
{
|
|
@@ -137,11 +164,11 @@ const CSmartTableHead = defineComponent({
|
|
|
137
164
|
{
|
|
138
165
|
default: () =>
|
|
139
166
|
(
|
|
140
|
-
typeof column
|
|
141
|
-
?
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
:
|
|
167
|
+
typeof column === 'object'
|
|
168
|
+
? column.filter === undefined
|
|
169
|
+
? true
|
|
170
|
+
: column.filter
|
|
171
|
+
: true
|
|
145
172
|
)
|
|
146
173
|
? typeof column !== 'string' && typeof column.filter === 'function'
|
|
147
174
|
? column.filter(
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { VNode } from 'vue'
|
|
2
2
|
|
|
3
3
|
export type Column = {
|
|
4
|
+
children?: Column[]
|
|
4
5
|
filter?: boolean | ((values: any[], onChange: (value: any) => void) => VNode)
|
|
6
|
+
group?: string
|
|
5
7
|
key: string
|
|
6
8
|
label?: string
|
|
7
9
|
sorter?: boolean
|
|
@@ -23,6 +25,17 @@ export type FooterItem = {
|
|
|
23
25
|
_props?: any
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
export type Group = {
|
|
29
|
+
children?: Group[] | Column[]
|
|
30
|
+
colspan?: number
|
|
31
|
+
deep?: number
|
|
32
|
+
group?: string
|
|
33
|
+
key: string
|
|
34
|
+
label?: string
|
|
35
|
+
_style?: any
|
|
36
|
+
_props?: any
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
export type Item = {
|
|
27
40
|
[key: string]: number | string | any
|
|
28
41
|
_cellProps?: any
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
Column,
|
|
3
3
|
ColumnFilter,
|
|
4
4
|
ColumnFilterValue,
|
|
5
|
+
Group,
|
|
5
6
|
Item,
|
|
6
7
|
Sorter,
|
|
7
8
|
SorterValue,
|
|
@@ -77,13 +78,123 @@ export const getColumnLabel = (column: Column | string) =>
|
|
|
77
78
|
: pretifyName(column.key)
|
|
78
79
|
: pretifyName(column)
|
|
79
80
|
|
|
80
|
-
export const getColumnNames = (
|
|
81
|
-
columns
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
export const getColumnNames = (
|
|
82
|
+
columns: (string | Column)[] | undefined,
|
|
83
|
+
items: Item[],
|
|
84
|
+
): string[] => {
|
|
85
|
+
if (columns) {
|
|
86
|
+
const _columns = []
|
|
87
|
+
|
|
88
|
+
for (const column of columns) {
|
|
89
|
+
if (typeof column === 'object' && column.children) {
|
|
90
|
+
_columns.push(...getColumnNames(column.children, []))
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
typeof column === 'object' ? _columns.push(column.key) : _columns.push(column)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return _columns
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return getColumnNamesFromItems(items)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const getColumns = (_columns: (Column | Group | string)[]): (Column | string)[] => {
|
|
104
|
+
const columns = []
|
|
105
|
+
|
|
106
|
+
for (const column of _columns) {
|
|
107
|
+
if (typeof column === 'object' && column.group && column.children) {
|
|
108
|
+
columns.push(...getColumns(column.children))
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (typeof column === 'object' && column.children) {
|
|
113
|
+
columns.push(...getColumns(column.children))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
columns.push(column)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return columns
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const countColumns = (columns: Column[], counter = 0) => {
|
|
123
|
+
let _counter = counter
|
|
124
|
+
for (const column of columns) {
|
|
125
|
+
if (!column.children) {
|
|
126
|
+
_counter++
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (column.children) {
|
|
130
|
+
_counter = countColumns(column.children, _counter)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return _counter
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const getColumnGroups = (columns: (string | Column)[] | undefined) => {
|
|
138
|
+
const groups = []
|
|
139
|
+
|
|
140
|
+
const traverseColumns = (column: Column, deep = 0, colSpan = 0): Group[] => {
|
|
141
|
+
const groups = []
|
|
142
|
+
|
|
143
|
+
if (column.children) {
|
|
144
|
+
for (const _column of column.children) {
|
|
145
|
+
if (!_column.group) {
|
|
146
|
+
colSpan++
|
|
147
|
+
}
|
|
148
|
+
groups.push(...traverseColumns(_column, deep + 1, colSpan))
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof column === 'object' && column.group) {
|
|
153
|
+
const { children, group, ...rest } = column
|
|
154
|
+
groups.push({
|
|
155
|
+
deep: deep,
|
|
156
|
+
label: group,
|
|
157
|
+
...(children && { colspan: countColumns(children) }),
|
|
158
|
+
...rest,
|
|
85
159
|
})
|
|
86
|
-
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return groups
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (columns) {
|
|
166
|
+
for (const column of columns) {
|
|
167
|
+
if (typeof column === 'object' && column.group) {
|
|
168
|
+
const objects = traverseColumns(column)
|
|
169
|
+
|
|
170
|
+
if (objects) {
|
|
171
|
+
for (const object of objects) {
|
|
172
|
+
const { deep, ...rest } = object
|
|
173
|
+
|
|
174
|
+
if (deep === undefined) {
|
|
175
|
+
continue
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
for (let i = 0; i < deep; i++) {
|
|
179
|
+
if (groups[i]) {
|
|
180
|
+
continue
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
groups.push([])
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (groups[deep]) {
|
|
187
|
+
groups[deep].push(rest)
|
|
188
|
+
} else {
|
|
189
|
+
groups.push([rest])
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return groups
|
|
197
|
+
}
|
|
87
198
|
|
|
88
199
|
export const getColumnNamesFromItems = (items: Item[]) =>
|
|
89
200
|
Object.keys(items[0] || {}).filter((el) => el.charAt(0) !== '_')
|
|
@@ -132,7 +243,7 @@ export const getTableHeaderCellStyles = (
|
|
|
132
243
|
if (
|
|
133
244
|
columnSorter &&
|
|
134
245
|
(typeof column !== 'object' ||
|
|
135
|
-
(typeof column === 'object' && (
|
|
246
|
+
(typeof column === 'object' && (column.sorter === undefined || column.sorter)))
|
|
136
247
|
) {
|
|
137
248
|
style['cursor'] = 'pointer'
|
|
138
249
|
}
|
|
@@ -143,19 +254,6 @@ export const getTableHeaderCellStyles = (
|
|
|
143
254
|
return style
|
|
144
255
|
}
|
|
145
256
|
|
|
146
|
-
export const isObjectInArray = <T>(array: T[], item: T, ignore: string[] = []) =>
|
|
147
|
-
array.some((_item: T) => {
|
|
148
|
-
let result = true
|
|
149
|
-
for (const key in item) {
|
|
150
|
-
if (!ignore.includes(key) && item[key] !== _item[key]) {
|
|
151
|
-
result = false
|
|
152
|
-
break
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return result
|
|
157
|
-
})
|
|
158
|
-
|
|
159
257
|
export const isSortable = (
|
|
160
258
|
i: number,
|
|
161
259
|
columns: (string | Column)[] | undefined,
|
|
@@ -170,7 +268,7 @@ export const isSortable = (
|
|
|
170
268
|
columnSorter &&
|
|
171
269
|
(!columns ||
|
|
172
270
|
typeof column !== 'object' ||
|
|
173
|
-
(typeof column === 'object' && (
|
|
271
|
+
(typeof column === 'object' && (column.sorter === undefined || column.sorter))) &&
|
|
174
272
|
isDataColumn
|
|
175
273
|
)
|
|
176
274
|
}
|
|
@@ -68,8 +68,10 @@ const CSpinner = defineComponent({
|
|
|
68
68
|
{
|
|
69
69
|
class: [
|
|
70
70
|
`spinner-${props.variant}`,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
{
|
|
72
|
+
[`spinner-${props.variant}-${props.size}`]: props.size,
|
|
73
|
+
[`text-${props.color}`]: props.color,
|
|
74
|
+
},
|
|
73
75
|
],
|
|
74
76
|
role: 'status',
|
|
75
77
|
},
|
|
@@ -236,24 +236,25 @@ const CTable = defineComponent({
|
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
default: () => [
|
|
239
|
-
columnNames.value &&
|
|
240
|
-
(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
item._cellProps
|
|
247
|
-
|
|
248
|
-
item._cellProps
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
239
|
+
columnNames.value &&
|
|
240
|
+
columnNames.value.map(
|
|
241
|
+
(colName: string) =>
|
|
242
|
+
item[colName] !== undefined &&
|
|
243
|
+
h(
|
|
244
|
+
CTableDataCell,
|
|
245
|
+
{
|
|
246
|
+
...(item._cellProps &&
|
|
247
|
+
item._cellProps['all'] && { ...item._cellProps['all'] }),
|
|
248
|
+
...(item._cellProps &&
|
|
249
|
+
item._cellProps[colName] && {
|
|
250
|
+
...item._cellProps[colName],
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
default: () => item[colName],
|
|
255
|
+
},
|
|
256
|
+
),
|
|
257
|
+
),
|
|
257
258
|
],
|
|
258
259
|
},
|
|
259
260
|
),
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export type Column = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
label?: string
|
|
3
|
+
key: string
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
_style?: any
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
_props?: any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type FooterItem = {
|
|
11
|
+
label?: string
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
_props?: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Item = {
|
|
17
|
+
[key: string]: number | string | any
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
_props?: any
|
|
20
|
+
}
|