@coreui/vue-pro 4.7.0 → 4.8.0-next.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/dist/components/calendar/utils.d.ts +23 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/modal/CModal.d.ts +4 -20
- package/dist/components/multi-select/CMultiSelect.d.ts +35 -44
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +13 -11
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +14 -0
- package/dist/components/multi-select/utils.d.ts +6 -0
- package/dist/components/offcanvas/COffcanvas.d.ts +35 -18
- package/dist/components/smart-table/CSmartTable.d.ts +65 -87
- package/dist/components/smart-table/CSmartTableBody.d.ts +16 -40
- package/dist/components/smart-table/CSmartTableHead.d.ts +17 -58
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/components/smart-table/types.d.ts +50 -0
- package/dist/components/smart-table/utils.d.ts +17 -0
- package/dist/components/table/CTable.d.ts +1 -1
- package/dist/components/time-picker/types.d.ts +15 -0
- package/dist/components/time-picker/utils.d.ts +23 -0
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +23 -0
- package/dist/components/virtual-scroller/index.d.ts +6 -0
- package/dist/index.es.js +943 -885
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +943 -883
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/isObjectInArray.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/calendar/CCalendar.ts +1 -1
- package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -1
- package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
- package/src/components/element-cover/CElementCover.ts +14 -14
- package/src/components/index.ts +1 -0
- package/src/components/modal/CModal.ts +10 -10
- package/src/components/multi-select/CMultiSelect.ts +33 -99
- package/src/components/multi-select/CMultiSelectNativeSelect.ts +2 -1
- package/src/components/multi-select/CMultiSelectOptions.ts +31 -17
- package/src/components/multi-select/CMultiSelectSelection.ts +2 -1
- package/src/components/multi-select/types.ts +15 -0
- package/src/components/multi-select/utils.ts +92 -0
- package/src/components/offcanvas/COffcanvas.ts +50 -28
- package/src/components/smart-table/CSmartTable.ts +365 -268
- package/src/components/smart-table/CSmartTableBody.ts +126 -137
- package/src/components/smart-table/CSmartTableHead.ts +53 -138
- package/src/components/smart-table/CSmartTableInterface.ts +1 -1
- package/src/components/smart-table/types.ts +61 -0
- package/src/components/smart-table/utils.ts +212 -0
- package/src/components/time-picker/CTimePicker.ts +49 -27
- package/src/components/time-picker/types.ts +15 -0
- package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
- package/src/components/virtual-scroller/CVirtualScroller.ts +109 -0
- package/src/components/virtual-scroller/index.ts +10 -0
- package/src/utils/index.ts +1 -3
- package/src/utils/getNextSibling.ts +0 -18
- package/src/utils/getPreviousSibling.ts +0 -18
|
@@ -1,76 +1,40 @@
|
|
|
1
1
|
import { defineComponent, h, PropType } from 'vue'
|
|
2
2
|
|
|
3
|
-
import { CTableBody, CTableDataCell, CTableRow } from '../table/'
|
|
4
3
|
import { CFormCheck } from '../form/'
|
|
4
|
+
import { CTableBody, CTableDataCell, CTableRow } from '../table/'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { getClickedColumnName, getTableDataCellProps, isObjectInArray } from './utils'
|
|
7
|
+
|
|
8
|
+
import type { Item } from './types'
|
|
7
9
|
|
|
8
10
|
const CSmartTableBody = defineComponent({
|
|
9
11
|
name: 'CSmartTableBody',
|
|
10
12
|
props: {
|
|
11
|
-
clickableRows:
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
clickableRows: Boolean,
|
|
14
|
+
columnNames: {
|
|
15
|
+
type: Array as PropType<string[]>,
|
|
16
|
+
default: () => [],
|
|
17
|
+
require: true,
|
|
14
18
|
},
|
|
15
19
|
currentItems: {
|
|
16
20
|
type: Array as PropType<Item[]>,
|
|
17
21
|
default: () => [],
|
|
18
|
-
required: false,
|
|
19
22
|
},
|
|
20
23
|
firstItemOnActivePageIndex: {
|
|
21
24
|
type: Number,
|
|
22
25
|
require: true,
|
|
23
26
|
default: 0,
|
|
24
27
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
default: undefined,
|
|
28
|
-
require: false,
|
|
29
|
-
},
|
|
30
|
-
rawColumnNames: {
|
|
31
|
-
type: Array as PropType<string[]>,
|
|
32
|
-
default: () => [],
|
|
33
|
-
require: true,
|
|
34
|
-
},
|
|
35
|
-
scopedSlots: {
|
|
36
|
-
type: Object,
|
|
37
|
-
default: undefined,
|
|
38
|
-
require: false,
|
|
39
|
-
},
|
|
28
|
+
noItemsLabel: String,
|
|
29
|
+
scopedSlots: Object,
|
|
40
30
|
selectable: Boolean,
|
|
31
|
+
selected: Array as PropType<Item[]>,
|
|
41
32
|
},
|
|
42
33
|
emits: ['rowChecked', 'rowClick'],
|
|
43
34
|
setup(props, { emit }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
columnName: string,
|
|
48
|
-
event: MouseEvent | boolean,
|
|
49
|
-
) => {
|
|
50
|
-
emit('rowClick', item, index, columnName, event)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const handleRowChecked = (id: number, value: boolean) => {
|
|
54
|
-
emit('rowChecked', id, value)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const tableDataCellProps = (item: Item, colName: string) => {
|
|
58
|
-
const props = item._cellProps && {
|
|
59
|
-
...(item._cellProps['all'] && { ...item._cellProps['all'] }),
|
|
60
|
-
...(item._cellProps[colName] && { ...item._cellProps[colName] }),
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return props
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const getColumnName = (event: MouseEvent): string => {
|
|
67
|
-
const target = event.target as HTMLTextAreaElement
|
|
68
|
-
const closest = target.closest('tr')
|
|
69
|
-
const children = closest ? Array.from(closest.children) : []
|
|
70
|
-
const clickedCell = children.filter((child) => child.contains(target))[0]
|
|
71
|
-
return props.rawColumnNames[children.indexOf(clickedCell)]
|
|
72
|
-
}
|
|
73
|
-
|
|
35
|
+
const colspan: number = props.selectable
|
|
36
|
+
? props.columnNames.length + 1
|
|
37
|
+
: props.columnNames.length
|
|
74
38
|
return () =>
|
|
75
39
|
h(
|
|
76
40
|
CTableBody,
|
|
@@ -79,102 +43,127 @@ const CSmartTableBody = defineComponent({
|
|
|
79
43
|
},
|
|
80
44
|
{
|
|
81
45
|
default: () =>
|
|
82
|
-
props.currentItems.
|
|
83
|
-
|
|
84
|
-
CTableRow,
|
|
85
|
-
{
|
|
86
|
-
...(item._props && { ...item._props }),
|
|
87
|
-
...(props.clickableRows && { tabindex: 0 }),
|
|
88
|
-
onClick: (event: MouseEvent) =>
|
|
89
|
-
handleRowClick(
|
|
90
|
-
item,
|
|
91
|
-
trIndex + props.firstItemOnActivePageIndex,
|
|
92
|
-
getColumnName(event),
|
|
93
|
-
event,
|
|
94
|
-
),
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
default: () => [
|
|
98
|
-
props.selectable &&
|
|
99
|
-
h(CTableDataCell, {}, () =>
|
|
100
|
-
h(CFormCheck, {
|
|
101
|
-
checked: item._selected ? item._selected : false,
|
|
102
|
-
onChange: (event: Event) =>
|
|
103
|
-
handleRowChecked(item._id, (event.target as HTMLInputElement).checked),
|
|
104
|
-
}),
|
|
105
|
-
),
|
|
106
|
-
props.rawColumnNames.map((colName) =>
|
|
107
|
-
props.scopedSlots &&
|
|
108
|
-
props.scopedSlots[colName] &&
|
|
109
|
-
typeof props.scopedSlots[colName] === 'function'
|
|
110
|
-
? h(props.scopedSlots[colName], { item: item })
|
|
111
|
-
: h(
|
|
112
|
-
CTableDataCell,
|
|
113
|
-
{
|
|
114
|
-
...tableDataCellProps(item, colName),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
default: () => String(item[colName]),
|
|
118
|
-
},
|
|
119
|
-
),
|
|
120
|
-
),
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
),
|
|
124
|
-
props.scopedSlots &&
|
|
125
|
-
props.scopedSlots['details'] && [
|
|
126
|
-
h(CTableRow, {
|
|
127
|
-
colspan: props.selectable
|
|
128
|
-
? props.rawColumnNames.length + 1
|
|
129
|
-
: props.rawColumnNames.length,
|
|
130
|
-
class: 'p-0',
|
|
131
|
-
style: { 'border-bottom-width': '0' },
|
|
132
|
-
tabindex: '-1',
|
|
133
|
-
}),
|
|
46
|
+
props.currentItems.length
|
|
47
|
+
? props.currentItems.map((item: Item, trIndex) => [
|
|
134
48
|
h(
|
|
135
49
|
CTableRow,
|
|
136
50
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
onClick: (event: MouseEvent) =>
|
|
140
|
-
|
|
51
|
+
...(item._props && { ...item._props }),
|
|
52
|
+
...(props.clickableRows && { tabindex: 0 }),
|
|
53
|
+
onClick: (event: MouseEvent) => {
|
|
54
|
+
emit(
|
|
55
|
+
'rowClick',
|
|
141
56
|
item,
|
|
142
57
|
trIndex + props.firstItemOnActivePageIndex,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
58
|
+
getClickedColumnName(
|
|
59
|
+
event.target as HTMLTextAreaElement,
|
|
60
|
+
props.columnNames,
|
|
61
|
+
),
|
|
62
|
+
event,
|
|
63
|
+
)
|
|
64
|
+
},
|
|
146
65
|
},
|
|
147
66
|
{
|
|
148
|
-
default: () =>
|
|
149
|
-
|
|
150
|
-
CTableDataCell,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
67
|
+
default: () => [
|
|
68
|
+
props.selectable &&
|
|
69
|
+
h(CTableDataCell, {}, () =>
|
|
70
|
+
h(CFormCheck, {
|
|
71
|
+
checked:
|
|
72
|
+
props.selected &&
|
|
73
|
+
isObjectInArray(props.selected, item, [
|
|
74
|
+
'_cellProps',
|
|
75
|
+
'_props',
|
|
76
|
+
'_selected',
|
|
77
|
+
]),
|
|
78
|
+
onChange: (event: Event) => {
|
|
79
|
+
emit('rowChecked', item, (event.target as HTMLInputElement).checked)
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
),
|
|
83
|
+
props.columnNames.map((colName) =>
|
|
84
|
+
props.scopedSlots &&
|
|
85
|
+
props.scopedSlots[colName] &&
|
|
86
|
+
typeof props.scopedSlots[colName] === 'function'
|
|
87
|
+
? h(props.scopedSlots[colName], { item: item })
|
|
88
|
+
: h(
|
|
89
|
+
CTableDataCell,
|
|
90
|
+
{
|
|
91
|
+
...getTableDataCellProps(item, colName),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
default: () => String(item[colName]),
|
|
95
|
+
},
|
|
96
|
+
),
|
|
173
97
|
),
|
|
98
|
+
],
|
|
174
99
|
},
|
|
175
100
|
),
|
|
176
|
-
|
|
177
|
-
|
|
101
|
+
props.scopedSlots &&
|
|
102
|
+
props.scopedSlots['details'] && [
|
|
103
|
+
h(CTableRow, {
|
|
104
|
+
colspan: props.selectable
|
|
105
|
+
? props.columnNames.length + 1
|
|
106
|
+
: props.columnNames.length,
|
|
107
|
+
class: 'p-0',
|
|
108
|
+
style: { 'border-bottom-width': '0' },
|
|
109
|
+
tabindex: '-1',
|
|
110
|
+
}),
|
|
111
|
+
h(
|
|
112
|
+
CTableRow,
|
|
113
|
+
{
|
|
114
|
+
class: 'p-0',
|
|
115
|
+
key: `details${trIndex}`,
|
|
116
|
+
onClick: (event: MouseEvent) => {
|
|
117
|
+
emit(
|
|
118
|
+
'rowClick',
|
|
119
|
+
item,
|
|
120
|
+
trIndex + props.firstItemOnActivePageIndex,
|
|
121
|
+
getClickedColumnName(
|
|
122
|
+
event.target as HTMLTextAreaElement,
|
|
123
|
+
props.columnNames,
|
|
124
|
+
),
|
|
125
|
+
true,
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
default: () =>
|
|
131
|
+
h(
|
|
132
|
+
CTableDataCell,
|
|
133
|
+
{
|
|
134
|
+
colspan: props.selectable
|
|
135
|
+
? props.columnNames.length + 1
|
|
136
|
+
: props.columnNames.length,
|
|
137
|
+
class: 'p-0',
|
|
138
|
+
style: { border: 0 },
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
default: () =>
|
|
142
|
+
props.scopedSlots &&
|
|
143
|
+
props.scopedSlots['details'] &&
|
|
144
|
+
h(props.scopedSlots['details'], {
|
|
145
|
+
item: item,
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
),
|
|
151
|
+
],
|
|
152
|
+
])
|
|
153
|
+
: h(
|
|
154
|
+
CTableRow,
|
|
155
|
+
{},
|
|
156
|
+
{
|
|
157
|
+
default: () =>
|
|
158
|
+
h(
|
|
159
|
+
CTableDataCell,
|
|
160
|
+
{ colspan: colspan },
|
|
161
|
+
{
|
|
162
|
+
default: () => props.noItemsLabel,
|
|
163
|
+
},
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
),
|
|
178
167
|
},
|
|
179
168
|
)
|
|
180
169
|
},
|
|
@@ -1,164 +1,70 @@
|
|
|
1
1
|
import { defineComponent, h, PropType } from 'vue'
|
|
2
|
-
import { CTableHead, CTableFoot } from '../table/'
|
|
3
|
-
import { CTableHeaderCell } from '../table/CTableHeaderCell'
|
|
4
|
-
import { CTableRow } from '../table/CTableRow'
|
|
5
2
|
|
|
6
3
|
import { CFormCheck, CFormInput } from '../form/'
|
|
4
|
+
import { CTableFoot, CTableHead, CTableHeaderCell, CTableRow } from '../table/'
|
|
7
5
|
|
|
8
6
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from './
|
|
7
|
+
getColumnKey,
|
|
8
|
+
getColumnLabel,
|
|
9
|
+
getColumnSorterState,
|
|
10
|
+
getColumnValues,
|
|
11
|
+
getTableHeaderCellProps,
|
|
12
|
+
getTableHeaderCellStyles,
|
|
13
|
+
} from './utils'
|
|
14
|
+
|
|
15
|
+
import type { Column, ColumnFilter, ColumnFilterValue, Item, Sorter, SorterValue } from './types'
|
|
16
16
|
|
|
17
17
|
const CSmartTableHead = defineComponent({
|
|
18
18
|
name: 'CSmartTableHead',
|
|
19
19
|
props: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
default: '',
|
|
24
|
-
},
|
|
25
|
-
columnFilter: {
|
|
26
|
-
type: [Boolean, Object] as PropType<boolean | ColumnFilter>,
|
|
27
|
-
require: false,
|
|
28
|
-
},
|
|
29
|
-
columnFilterValue: {
|
|
30
|
-
type: Object as PropType<ColumnFilterValue>,
|
|
31
|
-
required: false,
|
|
32
|
-
},
|
|
33
|
-
columnSorter: {
|
|
34
|
-
type: [Boolean, Object] as PropType<boolean | Sorter>,
|
|
35
|
-
default: undefined,
|
|
36
|
-
require: false,
|
|
37
|
-
},
|
|
20
|
+
columnFilter: [Boolean, Object] as PropType<boolean | ColumnFilter>,
|
|
21
|
+
columnFilterValue: Object as PropType<ColumnFilterValue>,
|
|
22
|
+
columnSorter: [Boolean, Object] as PropType<boolean | Sorter>,
|
|
38
23
|
component: {
|
|
39
24
|
type: String,
|
|
40
25
|
default: 'head',
|
|
41
|
-
require: false,
|
|
42
26
|
},
|
|
43
27
|
columns: {
|
|
44
28
|
type: Array as PropType<(Column | string)[]>,
|
|
45
29
|
default: () => [],
|
|
46
|
-
required: false,
|
|
47
30
|
},
|
|
48
31
|
items: {
|
|
49
32
|
type: Array as PropType<Item[]>,
|
|
50
33
|
default: () => [],
|
|
51
|
-
required: false,
|
|
52
34
|
},
|
|
53
35
|
selectable: Boolean,
|
|
54
|
-
selectAll: [Boolean,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
default: undefined,
|
|
58
|
-
require: false,
|
|
59
|
-
},
|
|
36
|
+
selectAll: [Boolean, Object] as PropType<boolean | { external?: boolean }>,
|
|
37
|
+
selectedAll: [Boolean, String],
|
|
38
|
+
sorterState: Object as PropType<SorterValue>,
|
|
60
39
|
},
|
|
61
40
|
emits: ['customFilterChange', 'filterInput', 'filterChange', 'selectAllChecked', 'sortClick'],
|
|
62
41
|
setup(props, { slots, emit }) {
|
|
63
|
-
const handleSortClick = (key: string, index: number) => {
|
|
64
|
-
emit('sortClick', key, index)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const tableHeaderCellProps = (column: Column | string) => {
|
|
68
|
-
if (typeof column === 'object' && column._props) {
|
|
69
|
-
return column._props
|
|
70
|
-
}
|
|
71
|
-
return {}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const tableHeaderCellStyles = (column: Column | string) => {
|
|
75
|
-
const style = { verticalAlign: 'middle', overflow: 'hidden', cursor: '' }
|
|
76
|
-
if (
|
|
77
|
-
props.columnSorter &&
|
|
78
|
-
(typeof column !== 'object' ||
|
|
79
|
-
(typeof column === 'object' && (typeof column.sorter === 'undefined' || column.sorter)))
|
|
80
|
-
) {
|
|
81
|
-
style.cursor = 'pointer'
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (typeof column === 'object' && column._style) {
|
|
85
|
-
return { ...style, ...column._style }
|
|
86
|
-
}
|
|
87
|
-
return style
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const pretifyName = (name: string) => {
|
|
91
|
-
return name
|
|
92
|
-
.replace(/[-_.]/g, ' ')
|
|
93
|
-
.replace(/ +/g, ' ')
|
|
94
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
95
|
-
.split(' ')
|
|
96
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
97
|
-
.join(' ')
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const label = (column: Column | string) =>
|
|
101
|
-
typeof column === 'object'
|
|
102
|
-
? column.label !== undefined
|
|
103
|
-
? column.label
|
|
104
|
-
: pretifyName(column.key)
|
|
105
|
-
: pretifyName(column)
|
|
106
|
-
|
|
107
|
-
const key = (column: Column | string) => (typeof column === 'object' ? column.key : column)
|
|
108
|
-
|
|
109
|
-
const getColumnSorterState = (key: string): string | number => {
|
|
110
|
-
if (props.sorterState && props.sorterState.column === key) {
|
|
111
|
-
if (props.sorterState.state) {
|
|
112
|
-
return props.sorterState.state
|
|
113
|
-
}
|
|
114
|
-
return 0
|
|
115
|
-
}
|
|
116
|
-
return 0
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const getValues = (items: Item[], key: string) => {
|
|
120
|
-
return items.map((a) => a[key])
|
|
121
|
-
}
|
|
122
|
-
|
|
123
42
|
const columnSorterIcon = (column: Column | string) => {
|
|
124
|
-
if (getColumnSorterState(
|
|
43
|
+
if (getColumnSorterState(getColumnKey(column), props.sorterState) === 0) {
|
|
125
44
|
return h(
|
|
126
45
|
'span',
|
|
127
46
|
{ class: 'opacity-25 float-end me-1' },
|
|
128
47
|
slots.sortingIcon && slots.sortingIcon(),
|
|
129
48
|
)
|
|
130
49
|
}
|
|
131
|
-
|
|
50
|
+
|
|
51
|
+
if (getColumnSorterState(getColumnKey(column), props.sorterState) === 'asc') {
|
|
132
52
|
return h(
|
|
133
53
|
'span',
|
|
134
54
|
{ class: 'float-end me-1' },
|
|
135
55
|
slots.sortingIconAscending && slots.sortingIconAscending(),
|
|
136
56
|
)
|
|
137
57
|
}
|
|
138
|
-
|
|
58
|
+
|
|
59
|
+
if (getColumnSorterState(getColumnKey(column), props.sorterState) === 'desc') {
|
|
139
60
|
return h(
|
|
140
61
|
'span',
|
|
141
62
|
{ class: 'float-end me-1' },
|
|
142
63
|
slots.sortingIconDescending && slots.sortingIconDescending(),
|
|
143
64
|
)
|
|
144
65
|
}
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
66
|
|
|
148
|
-
|
|
149
|
-
emit('customFilterChange', key, value)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const handleFilterInput = (key: string, value: string) => {
|
|
153
|
-
emit('filterInput', key, value)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const handleFilterChange = (key: string, value: string) => {
|
|
157
|
-
emit('filterChange', key, value)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const handleSelectAllChecked = () => {
|
|
161
|
-
emit('selectAllChecked')
|
|
67
|
+
return
|
|
162
68
|
}
|
|
163
69
|
|
|
164
70
|
return () =>
|
|
@@ -175,18 +81,22 @@ const CSmartTableHead = defineComponent({
|
|
|
175
81
|
props.selectable &&
|
|
176
82
|
h(CTableHeaderCell, {}, () =>
|
|
177
83
|
h(CFormCheck, {
|
|
178
|
-
checked: typeof props.
|
|
179
|
-
indeterminate: props.
|
|
180
|
-
onChange: () =>
|
|
84
|
+
checked: typeof props.selectedAll === 'boolean' ? props.selectAll : false,
|
|
85
|
+
indeterminate: props.selectedAll === 'indeterminate' ? true : false,
|
|
86
|
+
onChange: () => {
|
|
87
|
+
emit('selectAllChecked')
|
|
88
|
+
},
|
|
181
89
|
}),
|
|
182
90
|
),
|
|
183
91
|
props.columns.map((column, index: number) =>
|
|
184
92
|
h(
|
|
185
93
|
CTableHeaderCell,
|
|
186
94
|
{
|
|
187
|
-
...
|
|
188
|
-
onClick: () =>
|
|
189
|
-
|
|
95
|
+
...getTableHeaderCellProps(column),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
emit('sortClick', getColumnKey(column), index)
|
|
98
|
+
},
|
|
99
|
+
style: getTableHeaderCellStyles(column, props.columnSorter),
|
|
190
100
|
},
|
|
191
101
|
{
|
|
192
102
|
default: () => [
|
|
@@ -195,7 +105,7 @@ const CSmartTableHead = defineComponent({
|
|
|
195
105
|
{
|
|
196
106
|
class: 'd-inline',
|
|
197
107
|
},
|
|
198
|
-
|
|
108
|
+
getColumnLabel(column),
|
|
199
109
|
),
|
|
200
110
|
props.columnSorter &&
|
|
201
111
|
(typeof column !== 'object'
|
|
@@ -222,7 +132,7 @@ const CSmartTableHead = defineComponent({
|
|
|
222
132
|
h(
|
|
223
133
|
CTableHeaderCell,
|
|
224
134
|
{
|
|
225
|
-
...
|
|
135
|
+
...getTableHeaderCellProps(column),
|
|
226
136
|
},
|
|
227
137
|
{
|
|
228
138
|
default: () =>
|
|
@@ -234,25 +144,30 @@ const CSmartTableHead = defineComponent({
|
|
|
234
144
|
: column.filter
|
|
235
145
|
)
|
|
236
146
|
? typeof column !== 'string' && typeof column.filter === 'function'
|
|
237
|
-
? column.filter(
|
|
238
|
-
|
|
147
|
+
? column.filter(
|
|
148
|
+
getColumnValues(props.items, getColumnKey(column)),
|
|
149
|
+
(value: any) => {
|
|
150
|
+
emit('customFilterChange', getColumnKey(column), value)
|
|
151
|
+
},
|
|
239
152
|
)
|
|
240
153
|
: h(CFormInput, {
|
|
241
154
|
size: 'sm',
|
|
242
|
-
onInput: (event: Event) =>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(
|
|
246
|
-
),
|
|
247
|
-
onChange: (event: Event) =>
|
|
248
|
-
handleFilterChange(
|
|
249
|
-
key(column),
|
|
155
|
+
onInput: (event: Event) => {
|
|
156
|
+
emit(
|
|
157
|
+
'filterInput',
|
|
158
|
+
getColumnKey(column),
|
|
250
159
|
(event.target as HTMLInputElement).value,
|
|
251
|
-
)
|
|
252
|
-
|
|
160
|
+
)
|
|
161
|
+
},
|
|
162
|
+
onChange: (event: Event) => {
|
|
163
|
+
emit('filterChange', (event.target as HTMLInputElement).value)
|
|
164
|
+
},
|
|
165
|
+
'aria-label': `column name: '${getColumnLabel(
|
|
166
|
+
column,
|
|
167
|
+
)}' filter input`,
|
|
253
168
|
...(props.columnFilterValue &&
|
|
254
|
-
props.columnFilterValue[
|
|
255
|
-
value: props.columnFilterValue[
|
|
169
|
+
props.columnFilterValue[getColumnKey(column)] && {
|
|
170
|
+
value: props.columnFilterValue[getColumnKey(column)],
|
|
256
171
|
}),
|
|
257
172
|
})
|
|
258
173
|
: '',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { VNode } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type Column = {
|
|
4
|
+
filter?: boolean | ((values: any[], onChange: (value: any) => void) => VNode)
|
|
5
|
+
key: string
|
|
6
|
+
label?: string
|
|
7
|
+
sorter?: boolean
|
|
8
|
+
_style?: any
|
|
9
|
+
_props?: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ColumnFilter = {
|
|
13
|
+
lazy?: boolean
|
|
14
|
+
external?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ColumnFilterValue = {
|
|
18
|
+
[key: string]: any
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type FooterItem = {
|
|
22
|
+
label?: string
|
|
23
|
+
_props?: any
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type Item = {
|
|
27
|
+
[key: string]: number | string | any
|
|
28
|
+
_cellProps?: any
|
|
29
|
+
_props?: any
|
|
30
|
+
_selected?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type ItemsPerPageSelect = {
|
|
34
|
+
external?: boolean
|
|
35
|
+
label?: string
|
|
36
|
+
values?: Array<number>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type Pagination = {
|
|
40
|
+
external?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type Sorter = {
|
|
44
|
+
resetable?: boolean
|
|
45
|
+
external?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ScopedColumns = {
|
|
49
|
+
[key: string]: any
|
|
50
|
+
details?: (a: Item, b: number) => VNode
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type SorterValue = {
|
|
54
|
+
column?: string
|
|
55
|
+
state?: number | string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type TableFilter = {
|
|
59
|
+
lazy?: boolean
|
|
60
|
+
external?: boolean
|
|
61
|
+
}
|