@coreui/react-pro 4.11.0-next.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/accordion/index.d.ts +1 -2
- package/dist/components/calendar/CCalendar.d.ts +2 -2
- package/dist/components/dropdown/CDropdown.d.ts +7 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +3 -3
- package/dist/components/smart-table/CSmartTableHead.d.ts +1 -0
- package/dist/components/smart-table/types.d.ts +12 -0
- package/dist/components/smart-table/utils.d.ts +12 -1
- package/dist/index.es.js +198 -82
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +197 -82
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/accordion/index.ts +0 -2
- package/src/components/calendar/CCalendar.tsx +54 -18
- package/src/components/dropdown/CDropdown.tsx +13 -8
- package/src/components/dropdown/CDropdownMenu.tsx +45 -41
- package/src/components/multi-select/CMultiSelect.tsx +5 -3
- package/src/components/offcanvas/COffcanvas.tsx +3 -5
- package/src/components/smart-table/CSmartTable.tsx +3 -4
- package/src/components/smart-table/CSmartTableBody.tsx +4 -3
- package/src/components/smart-table/CSmartTableHead.tsx +42 -10
- package/src/components/smart-table/types.ts +13 -0
- package/src/components/smart-table/utils.ts +124 -5
|
@@ -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,12 +78,130 @@ export const getColumnLabel = (column: Column | string) =>
|
|
|
77
78
|
: pretifyName(column.key)
|
|
78
79
|
: pretifyName(column)
|
|
79
80
|
|
|
80
|
-
export const getColumnNames = (columns: (string | Column)[] | undefined, items: Item[]) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
// export const getColumnNames = (columns: (string | Column)[] | undefined, items: Item[]) =>
|
|
82
|
+
// columns
|
|
83
|
+
// ? columns.map((column: Column | string) => {
|
|
84
|
+
// return typeof column === 'object' ? column.key : column
|
|
85
|
+
// })
|
|
86
|
+
// : getColumnNamesFromItems(items)
|
|
87
|
+
|
|
88
|
+
export const getColumnNames = (
|
|
89
|
+
columns: (string | Column)[] | undefined,
|
|
90
|
+
items: Item[],
|
|
91
|
+
): string[] => {
|
|
92
|
+
if (columns) {
|
|
93
|
+
const _columns = []
|
|
94
|
+
|
|
95
|
+
for (const column of columns) {
|
|
96
|
+
if (typeof column === 'object' && column.children) {
|
|
97
|
+
_columns.push(...getColumnNames(column.children, []))
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
typeof column === 'object' ? _columns.push(column.key) : _columns.push(column)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return _columns
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return getColumnNamesFromItems(items)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const getColumns = (_columns: (Column | Group | string)[]): (Column | string)[] => {
|
|
111
|
+
const columns = []
|
|
112
|
+
|
|
113
|
+
for (const column of _columns) {
|
|
114
|
+
if (typeof column === 'object' && column.group && column.children) {
|
|
115
|
+
columns.push(...getColumns(column.children))
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeof column === 'object' && column.children) {
|
|
120
|
+
columns.push(...getColumns(column.children))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
columns.push(column)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return columns
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export const countColumns = (columns: Column[], counter = 0) => {
|
|
130
|
+
let _counter = counter
|
|
131
|
+
for (const column of columns) {
|
|
132
|
+
if (!column.children) {
|
|
133
|
+
_counter++
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (column.children) {
|
|
137
|
+
_counter = countColumns(column.children, _counter)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return _counter
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const getColumnGroups = (columns: (string | Column)[] | undefined) => {
|
|
145
|
+
const groups = []
|
|
146
|
+
|
|
147
|
+
const traverseColumns = (column: Column, deep = 0, colSpan = 0): Group[] => {
|
|
148
|
+
const groups = []
|
|
149
|
+
|
|
150
|
+
if (column.children) {
|
|
151
|
+
for (const _column of column.children) {
|
|
152
|
+
if (!_column.group) {
|
|
153
|
+
colSpan++
|
|
154
|
+
}
|
|
155
|
+
groups.push(...traverseColumns(_column, deep + 1, colSpan))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (typeof column === 'object' && column.group) {
|
|
160
|
+
const { children, group, ...rest } = column
|
|
161
|
+
groups.push({
|
|
162
|
+
deep: deep,
|
|
163
|
+
label: group,
|
|
164
|
+
...(children && { colspan: countColumns(children) }),
|
|
165
|
+
...rest,
|
|
84
166
|
})
|
|
85
|
-
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return groups
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (columns) {
|
|
173
|
+
for (const column of columns) {
|
|
174
|
+
if (typeof column === 'object' && column.group) {
|
|
175
|
+
const objects = traverseColumns(column)
|
|
176
|
+
|
|
177
|
+
if (objects) {
|
|
178
|
+
for (const object of objects) {
|
|
179
|
+
const { deep, ...rest } = object
|
|
180
|
+
|
|
181
|
+
if (deep === undefined) {
|
|
182
|
+
continue
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (let i = 0; i < deep; i++) {
|
|
186
|
+
if (groups[i]) {
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
groups.push([])
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (groups[deep]) {
|
|
194
|
+
groups[deep].push(rest)
|
|
195
|
+
} else {
|
|
196
|
+
groups.push([rest])
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return groups
|
|
204
|
+
}
|
|
86
205
|
|
|
87
206
|
export const getColumnNamesFromItems = (items: Item[]) =>
|
|
88
207
|
Object.keys(items[0] || {}).filter((el) => el.charAt(0) !== '_')
|