@rainbow-oh/yee-c 0.8.12 → 0.8.14
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/cjs/Pagination/style/index.less +4 -0
- package/dist/cjs/Spin/demo/types.js +1 -1
- package/dist/cjs/Spin/indicator.js +4 -2
- package/dist/cjs/Spin/style/index.less +2 -8
- package/dist/cjs/Table/col-group.d.ts +2 -2
- package/dist/cjs/Table/col-group.js +1 -1
- package/dist/cjs/Table/demo/sorter-callback.js +3 -2
- package/dist/cjs/Table/demo/sorter.js +3 -2
- package/dist/cjs/Table/hooks/useExpand.d.ts +2 -2
- package/dist/cjs/Table/hooks/useFilter.d.ts +8 -2
- package/dist/cjs/Table/hooks/useFilter.js +36 -22
- package/dist/cjs/Table/hooks/usePagination.js +8 -8
- package/dist/cjs/Table/hooks/useSelection.d.ts +3 -3
- package/dist/cjs/Table/hooks/useSelection.js +8 -9
- package/dist/cjs/Table/hooks/useSorter.d.ts +6 -3
- package/dist/cjs/Table/hooks/useSorter.js +193 -87
- package/dist/cjs/Table/interface.d.ts +10 -7
- package/dist/cjs/Table/table.js +51 -45
- package/dist/cjs/Table/tbody/index.js +13 -5
- package/dist/cjs/Table/tbody/lazy-row.js +6 -3
- package/dist/cjs/Table/tbody/row.js +5 -4
- package/dist/cjs/Table/theader/cell.js +4 -0
- package/dist/cjs/Table/theader/filter.js +52 -20
- package/dist/cjs/Table/util/index.js +5 -3
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Pagination/style/index.less +4 -0
- package/dist/esm/Spin/demo/types.js +6 -3
- package/dist/esm/Spin/indicator.js +4 -2
- package/dist/esm/Spin/style/index.less +2 -8
- package/dist/esm/Table/col-group.d.ts +2 -2
- package/dist/esm/Table/col-group.js +1 -1
- package/dist/esm/Table/demo/sorter-callback.js +3 -2
- package/dist/esm/Table/demo/sorter.js +3 -2
- package/dist/esm/Table/hooks/useExpand.d.ts +2 -2
- package/dist/esm/Table/hooks/useFilter.d.ts +8 -2
- package/dist/esm/Table/hooks/useFilter.js +52 -32
- package/dist/esm/Table/hooks/usePagination.js +8 -10
- package/dist/esm/Table/hooks/useSelection.d.ts +3 -3
- package/dist/esm/Table/hooks/useSelection.js +16 -11
- package/dist/esm/Table/hooks/useSorter.d.ts +6 -3
- package/dist/esm/Table/hooks/useSorter.js +218 -105
- package/dist/esm/Table/interface.d.ts +10 -7
- package/dist/esm/Table/table.js +42 -47
- package/dist/esm/Table/tbody/index.js +8 -5
- package/dist/esm/Table/tbody/lazy-row.js +7 -3
- package/dist/esm/Table/tbody/row.js +7 -6
- package/dist/esm/Table/theader/cell.js +7 -1
- package/dist/esm/Table/theader/filter.js +75 -27
- package/dist/esm/Table/util/index.js +6 -3
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Pagination/style/index.less +4 -0
- package/src/Spin/demo/types.tsx +3 -3
- package/src/Spin/index.en-US.md +2 -8
- package/src/Spin/index.zh-CN.md +2 -8
- package/src/Spin/indicator.tsx +2 -0
- package/src/Spin/style/index.less +2 -8
- package/src/Table/col-group.tsx +1 -1
- package/src/Table/demo/sorter-callback.tsx +3 -2
- package/src/Table/demo/sorter.tsx +3 -2
- package/src/Table/hooks/useExpand.ts +3 -3
- package/src/Table/hooks/useFilter.ts +47 -23
- package/src/Table/hooks/usePagination.ts +9 -10
- package/src/Table/hooks/useSelection.ts +18 -20
- package/src/Table/hooks/useSorter.ts +236 -82
- package/src/Table/interface.ts +19 -7
- package/src/Table/table.tsx +54 -49
- package/src/Table/tbody/index.tsx +14 -5
- package/src/Table/tbody/lazy-row.tsx +6 -3
- package/src/Table/tbody/row.tsx +5 -4
- package/src/Table/theader/cell.tsx +10 -0
- package/src/Table/theader/filter.tsx +64 -22
- package/src/Table/util/index.ts +3 -1
- package/src/version.ts +1 -1
|
@@ -23,7 +23,7 @@ export interface ExpandableType {
|
|
|
23
23
|
/**
|
|
24
24
|
* Default expanded rows
|
|
25
25
|
*/
|
|
26
|
-
defaultExpandedRowKeys?:
|
|
26
|
+
defaultExpandedRowKeys?: SelectionKeyType[];
|
|
27
27
|
/**
|
|
28
28
|
* Expanded rows
|
|
29
29
|
*/
|
|
@@ -51,6 +51,7 @@ export interface ExpandableType {
|
|
|
51
51
|
expandedRowRender?: (record: object, index: number, page: Record<string, any>) => React.ReactNode;
|
|
52
52
|
}
|
|
53
53
|
export type SelectionKeyType = string | number;
|
|
54
|
+
export type FilterValue = string | number;
|
|
54
55
|
export type ColumnSemanticType = 'inner' | 'action';
|
|
55
56
|
export interface HeadCellProps extends Omit<WrapedColumnProps, 'title'> {
|
|
56
57
|
prefixCls?: string;
|
|
@@ -186,7 +187,7 @@ export interface ColumnProps {
|
|
|
186
187
|
/**
|
|
187
188
|
* Filter callback function
|
|
188
189
|
*/
|
|
189
|
-
onFilter?: (value:
|
|
190
|
+
onFilter?: (value: FilterValue, record: Record<string, any>) => boolean;
|
|
190
191
|
};
|
|
191
192
|
/**
|
|
192
193
|
* Sorter config
|
|
@@ -195,9 +196,10 @@ export interface ColumnProps {
|
|
|
195
196
|
/**
|
|
196
197
|
* Sort function
|
|
197
198
|
*/
|
|
198
|
-
sort?: () => number
|
|
199
|
+
sort?: (a: Record<string, unknown>, b: Record<string, unknown>) => number;
|
|
199
200
|
/**
|
|
200
|
-
*
|
|
201
|
+
* Enable multi-column sorting. A positive number limits the active
|
|
202
|
+
* sorters; when exceeded, the earliest activated sorter is removed.
|
|
201
203
|
*/
|
|
202
204
|
multiple?: boolean | number;
|
|
203
205
|
/**
|
|
@@ -359,6 +361,7 @@ export interface TableRowProps {
|
|
|
359
361
|
pageSize: number;
|
|
360
362
|
index: number;
|
|
361
363
|
record: Record<string, any>;
|
|
364
|
+
rowKeyValue: SelectionKeyType;
|
|
362
365
|
columns: ColumnProps[];
|
|
363
366
|
expandable?: ExpandableType;
|
|
364
367
|
expandedRowKeys?: Array<string | number>;
|
|
@@ -375,7 +378,7 @@ export interface TableRowProps {
|
|
|
375
378
|
record: Record<string, any>;
|
|
376
379
|
index: number;
|
|
377
380
|
}) => void;
|
|
378
|
-
onSelectionChange: (event: ChangeEvent<HTMLInputElement
|
|
381
|
+
onSelectionChange: (event: ChangeEvent<HTMLInputElement>, key: SelectionKeyType) => void;
|
|
379
382
|
}
|
|
380
383
|
type LazyLoadType = {
|
|
381
384
|
lazyLoadRows?: number;
|
|
@@ -389,7 +392,7 @@ export interface LazyRowProps extends TableRowProps {
|
|
|
389
392
|
};
|
|
390
393
|
lazyLoad?: boolean | LazyLoadType;
|
|
391
394
|
}
|
|
392
|
-
export interface TableBodyProps extends Omit<LazyRowProps, 'index' | 'record'> {
|
|
395
|
+
export interface TableBodyProps extends Omit<LazyRowProps, 'index' | 'record' | 'rowKeyValue'> {
|
|
393
396
|
pageData: Array<Record<string, any>>;
|
|
394
397
|
noData?: React.ReactNode;
|
|
395
398
|
}
|
|
@@ -542,7 +545,7 @@ export interface TableProps extends FooterProps, Omit<HeaderProps, 'pageData'>,
|
|
|
542
545
|
* Set the unique key for rows
|
|
543
546
|
* @default id
|
|
544
547
|
*/
|
|
545
|
-
rowKey?: string | ((record: Record<string, any>) =>
|
|
548
|
+
rowKey?: string | ((record: Record<string, any>) => SelectionKeyType);
|
|
546
549
|
/**
|
|
547
550
|
* Summary bar
|
|
548
551
|
*/
|
package/dist/cjs/Table/table.js
CHANGED
|
@@ -155,13 +155,24 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
155
155
|
expandable,
|
|
156
156
|
rowSelection
|
|
157
157
|
});
|
|
158
|
-
const {
|
|
159
|
-
data:
|
|
158
|
+
const {
|
|
159
|
+
data: filteredData,
|
|
160
|
+
filterRecords,
|
|
161
|
+
onFilter: onFilterInternal
|
|
162
|
+
} = (0, import_useFilter.default)({
|
|
163
|
+
data: dataSource,
|
|
164
|
+
columns: wrapedColumns
|
|
160
165
|
});
|
|
166
|
+
const filters = (0, import_react.useMemo)(
|
|
167
|
+
() => Object.fromEntries(
|
|
168
|
+
filterRecords.map(({ dataIndex, value }) => [dataIndex, value])
|
|
169
|
+
),
|
|
170
|
+
[filterRecords]
|
|
171
|
+
);
|
|
161
172
|
const {
|
|
162
173
|
data: sortedData,
|
|
163
174
|
sorters,
|
|
164
|
-
onSort
|
|
175
|
+
onSort: onSortInternal
|
|
165
176
|
} = (0, import_useSorter.default)({ data: filteredData, columns: wrapedColumns });
|
|
166
177
|
const { pageData, current, pageSize, pagination } = (0, import_usePagination.default)({
|
|
167
178
|
data: sortedData,
|
|
@@ -170,13 +181,25 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
170
181
|
onChange({
|
|
171
182
|
pagination: info,
|
|
172
183
|
sorter: sorters,
|
|
173
|
-
filters
|
|
174
|
-
// TODO: Extract filter info from onFilterInternal
|
|
184
|
+
filters,
|
|
175
185
|
currentDataSource: sortedData,
|
|
176
186
|
action: "paginate"
|
|
177
187
|
});
|
|
178
188
|
} : void 0
|
|
179
189
|
});
|
|
190
|
+
const handleSort = import_react.default.useCallback(
|
|
191
|
+
(dataIndex) => {
|
|
192
|
+
const next = onSortInternal(dataIndex);
|
|
193
|
+
onChange == null ? void 0 : onChange({
|
|
194
|
+
pagination: pagination === false ? void 0 : { current, pageSize },
|
|
195
|
+
sorter: next.sorters,
|
|
196
|
+
filters,
|
|
197
|
+
currentDataSource: next.data,
|
|
198
|
+
action: "sort"
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
[onSortInternal, onChange, pagination, current, pageSize, filters]
|
|
202
|
+
);
|
|
180
203
|
const { expandedRowKeys, onExpand } = (0, import_useExpand.default)(
|
|
181
204
|
expandable,
|
|
182
205
|
allKeys,
|
|
@@ -188,7 +211,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
188
211
|
onCheckAll,
|
|
189
212
|
onChange: onSelectionChange
|
|
190
213
|
} = (0, import_useSelection.default)({ pageData, dataSource, getRowKey, rowSelection, allKeys });
|
|
191
|
-
const
|
|
214
|
+
const prevFilterRecordsRef = (0, import_react.useRef)(filterRecords);
|
|
192
215
|
const contentWrapperRef = (0, import_react.useRef)(null);
|
|
193
216
|
const contentRef = (0, import_react.useRef)(null);
|
|
194
217
|
const [horizontalScroll, setHorizontalScroll] = import_react.default.useState({
|
|
@@ -211,46 +234,29 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
211
234
|
(current2) => current2.left === next.left && current2.right === next.right ? current2 : next
|
|
212
235
|
);
|
|
213
236
|
}, []);
|
|
214
|
-
const onFilter = import_react.default.useCallback(
|
|
215
|
-
(...args) => {
|
|
216
|
-
onFilterInternal(...args);
|
|
217
|
-
if (onChange) {
|
|
218
|
-
onChange({
|
|
219
|
-
pagination: pagination === false ? void 0 : { current, pageSize },
|
|
220
|
-
sorter: sorters,
|
|
221
|
-
filters: void 0,
|
|
222
|
-
// TODO: Extract filter info from args
|
|
223
|
-
currentDataSource: filteredData,
|
|
224
|
-
action: "filter"
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
[
|
|
229
|
-
onChange,
|
|
230
|
-
pagination,
|
|
231
|
-
current,
|
|
232
|
-
pageSize,
|
|
233
|
-
sorters,
|
|
234
|
-
filteredData,
|
|
235
|
-
onFilterInternal
|
|
236
|
-
]
|
|
237
|
-
);
|
|
238
237
|
(0, import_react.useEffect)(() => {
|
|
239
|
-
if (
|
|
238
|
+
if (prevFilterRecordsRef.current === filterRecords)
|
|
240
239
|
return;
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
prevSortersRef.current = sorters;
|
|
244
|
-
onChange({
|
|
245
|
-
pagination: pagination === false ? void 0 : { current, pageSize },
|
|
246
|
-
sorter: sorters,
|
|
247
|
-
filters: void 0,
|
|
248
|
-
currentDataSource: sortedData,
|
|
249
|
-
action: "sort"
|
|
250
|
-
});
|
|
240
|
+
prevFilterRecordsRef.current = filterRecords;
|
|
241
|
+
if (!onChange)
|
|
251
242
|
return;
|
|
252
|
-
|
|
253
|
-
|
|
243
|
+
onChange({
|
|
244
|
+
pagination: pagination === false ? void 0 : { current, pageSize },
|
|
245
|
+
sorter: sorters,
|
|
246
|
+
filters,
|
|
247
|
+
currentDataSource: sortedData,
|
|
248
|
+
action: "filter"
|
|
249
|
+
});
|
|
250
|
+
}, [
|
|
251
|
+
filterRecords,
|
|
252
|
+
filters,
|
|
253
|
+
sortedData,
|
|
254
|
+
pagination,
|
|
255
|
+
current,
|
|
256
|
+
pageSize,
|
|
257
|
+
sorters,
|
|
258
|
+
onChange
|
|
259
|
+
]);
|
|
254
260
|
(0, import_react.useEffect)(() => {
|
|
255
261
|
updateHorizontalScroll();
|
|
256
262
|
const wrapper = contentWrapperRef.current;
|
|
@@ -290,9 +296,9 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
290
296
|
headerRows,
|
|
291
297
|
checkedAll,
|
|
292
298
|
sorters,
|
|
293
|
-
onSort,
|
|
299
|
+
onSort: handleSort,
|
|
294
300
|
onCheckAll,
|
|
295
|
-
onInternalFilter:
|
|
301
|
+
onInternalFilter: onFilterInternal
|
|
296
302
|
})
|
|
297
303
|
);
|
|
298
304
|
};
|
|
@@ -81,19 +81,26 @@ var TableBody = (props) => {
|
|
|
81
81
|
const resolveRowKey = (record) => typeof rowKey === "function" ? rowKey(record) : record[rowKey];
|
|
82
82
|
const getRenderRows = () => {
|
|
83
83
|
if (lazyLoad) {
|
|
84
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
84
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
+
import_lazy_row.default,
|
|
86
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
87
|
+
pageData,
|
|
88
|
+
columns,
|
|
89
|
+
resolveRowKey
|
|
90
|
+
})
|
|
91
|
+
);
|
|
85
92
|
}
|
|
86
93
|
return pageData.map((record, index) => {
|
|
94
|
+
const resolvedRowKey = resolveRowKey(record);
|
|
87
95
|
if (RowRenderer) {
|
|
88
|
-
const rk = resolveRowKey(record);
|
|
89
96
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
90
97
|
RowRenderer,
|
|
91
98
|
{
|
|
92
|
-
key:
|
|
99
|
+
key: resolvedRowKey != null ? resolvedRowKey : index,
|
|
93
100
|
record,
|
|
94
101
|
index,
|
|
95
102
|
columns,
|
|
96
|
-
rowKey:
|
|
103
|
+
rowKey: resolvedRowKey
|
|
97
104
|
}
|
|
98
105
|
);
|
|
99
106
|
}
|
|
@@ -102,8 +109,9 @@ var TableBody = (props) => {
|
|
|
102
109
|
__spreadProps(__spreadValues({}, rest), {
|
|
103
110
|
columns,
|
|
104
111
|
record,
|
|
112
|
+
rowKeyValue: resolvedRowKey,
|
|
105
113
|
index,
|
|
106
|
-
key: `row-${
|
|
114
|
+
key: resolvedRowKey != null ? resolvedRowKey : `row-${index}`
|
|
107
115
|
})
|
|
108
116
|
);
|
|
109
117
|
});
|
|
@@ -67,21 +67,24 @@ var createBlank = (size, key) => {
|
|
|
67
67
|
return size ? [/* @__PURE__ */ React.createElement("tr", { style: { height: `${size * 47}px`, width: "100%" }, key })] : [];
|
|
68
68
|
};
|
|
69
69
|
var LazyRow = (props) => {
|
|
70
|
-
const _a = props, { range, pageData, columns } = _a, rest = __objRest(_a, ["range", "pageData", "columns"]);
|
|
70
|
+
const _a = props, { range, pageData, columns, resolveRowKey } = _a, rest = __objRest(_a, ["range", "pageData", "columns", "resolveRowKey"]);
|
|
71
71
|
const { start, end } = range;
|
|
72
72
|
let result = [];
|
|
73
73
|
const pl = pageData.length;
|
|
74
74
|
const startBlank = createBlank(start, "row-start");
|
|
75
75
|
result = result.concat(startBlank);
|
|
76
76
|
for (let i = start; i < (end > pl ? pl : end); i++) {
|
|
77
|
+
const record = pageData[i];
|
|
78
|
+
const rowKeyValue = resolveRowKey(record);
|
|
77
79
|
result.push(
|
|
78
80
|
/* @__PURE__ */ React.createElement(
|
|
79
81
|
import_row.default,
|
|
80
82
|
__spreadProps(__spreadValues({}, rest), {
|
|
81
83
|
columns,
|
|
82
|
-
record
|
|
84
|
+
record,
|
|
85
|
+
rowKeyValue,
|
|
83
86
|
index: i,
|
|
84
|
-
key:
|
|
87
|
+
key: rowKeyValue != null ? rowKeyValue : `row-${i}`
|
|
85
88
|
})
|
|
86
89
|
)
|
|
87
90
|
);
|
|
@@ -74,6 +74,7 @@ var TableRow = (props) => {
|
|
|
74
74
|
const _a = props, {
|
|
75
75
|
index,
|
|
76
76
|
record,
|
|
77
|
+
rowKeyValue,
|
|
77
78
|
columns,
|
|
78
79
|
highlight,
|
|
79
80
|
stripe,
|
|
@@ -90,6 +91,7 @@ var TableRow = (props) => {
|
|
|
90
91
|
} = _a, rest = __objRest(_a, [
|
|
91
92
|
"index",
|
|
92
93
|
"record",
|
|
94
|
+
"rowKeyValue",
|
|
93
95
|
"columns",
|
|
94
96
|
"highlight",
|
|
95
97
|
"stripe",
|
|
@@ -104,9 +106,9 @@ var TableRow = (props) => {
|
|
|
104
106
|
"onDoubleClick",
|
|
105
107
|
"onSelectionChange"
|
|
106
108
|
]);
|
|
107
|
-
const { prefixCls
|
|
109
|
+
const { prefixCls } = (0, import_react.useContext)(import_table.TableCtx);
|
|
108
110
|
const expanded = expandedRowKeys == null ? void 0 : expandedRowKeys.includes(
|
|
109
|
-
expandedKeyType === "index" ? index + 1 :
|
|
111
|
+
expandedKeyType === "index" ? index + 1 : rowKeyValue
|
|
110
112
|
);
|
|
111
113
|
const high = import_react.default.useMemo(() => {
|
|
112
114
|
if (typeof highlight === "undefined")
|
|
@@ -128,14 +130,13 @@ var TableRow = (props) => {
|
|
|
128
130
|
};
|
|
129
131
|
const getSelection = (column) => {
|
|
130
132
|
const { type, disabled: colDisabled, onCell } = column;
|
|
131
|
-
const rowKeyValue = record[rowKey];
|
|
132
133
|
const props2 = (onCell == null ? void 0 : onCell(record, index)) || {};
|
|
133
134
|
const checked = selectedRowKeys == null ? void 0 : selectedRowKeys.includes(rowKeyValue);
|
|
134
135
|
const disabled = typeof colDisabled === "function" ? colDisabled(record, index) : Array.isArray(colDisabled) ? colDisabled[index] : !!colDisabled;
|
|
135
136
|
const commonProps = __spreadValues({
|
|
136
137
|
checked,
|
|
137
138
|
value: rowKeyValue,
|
|
138
|
-
onChange: onSelectionChange,
|
|
139
|
+
onChange: (event) => onSelectionChange(event, rowKeyValue),
|
|
139
140
|
disabled
|
|
140
141
|
}, props2);
|
|
141
142
|
if (type === "checkbox") {
|
|
@@ -122,12 +122,16 @@ var HeadCell = (props) => {
|
|
|
122
122
|
const showFilter = !!filter;
|
|
123
123
|
const sortOrder = dataIndex && (sorters == null ? void 0 : sorters[dataIndex]) || 0;
|
|
124
124
|
const displaySortOrder = sortOrder === -1 ? 2 : sortOrder;
|
|
125
|
+
const currentSortOrder = sortOrder === 1 ? "ascend" : sortOrder === -1 ? "descend" : null;
|
|
125
126
|
const handleSort = () => {
|
|
126
127
|
if (dataIndex && onSort) {
|
|
127
128
|
onSort(dataIndex, sorter);
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
const renderSort = () => {
|
|
132
|
+
if (typeof sorter === "object" && sorter.icon) {
|
|
133
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-column-sorter` }, sorter.icon(currentSortOrder));
|
|
134
|
+
}
|
|
131
135
|
const trigger = /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-column-sorter` }, /* @__PURE__ */ import_react.default.createElement(
|
|
132
136
|
import_arrow_icon.default,
|
|
133
137
|
{
|
|
@@ -49,13 +49,31 @@ var getStrLower = (str) => {
|
|
|
49
49
|
}
|
|
50
50
|
return str;
|
|
51
51
|
};
|
|
52
|
+
var areFilterValuesEqual = (a, b) => {
|
|
53
|
+
if (!Array.isArray(a) || !Array.isArray(b))
|
|
54
|
+
return a === b;
|
|
55
|
+
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
56
|
+
};
|
|
57
|
+
var hasFilterValue = (value) => Array.isArray(value) ? value.length > 0 : value !== "";
|
|
52
58
|
var HeaderFilter = import_react.default.memo((props) => {
|
|
53
59
|
const { filter, column, getPopupContainer, onInternalFilter } = props;
|
|
54
60
|
const { prefixCls } = (0, import_react.useContext)(import_table.TableCtx);
|
|
55
61
|
const { locale } = (0, import_locale.useLocale)();
|
|
56
62
|
const { table: tableLocale } = locale;
|
|
57
63
|
const { dataIndex } = column;
|
|
64
|
+
const {
|
|
65
|
+
items,
|
|
66
|
+
icon,
|
|
67
|
+
searchable = true,
|
|
68
|
+
filterMode = "menu",
|
|
69
|
+
filtered,
|
|
70
|
+
filterOnClose = true,
|
|
71
|
+
render
|
|
72
|
+
} = filter;
|
|
58
73
|
const inputRef = (0, import_react.useRef)(null);
|
|
74
|
+
const initialValue = items ? [] : "";
|
|
75
|
+
const committedValueRef = (0, import_react.useRef)(initialValue);
|
|
76
|
+
const [committedValue, setCommittedValue] = (0, import_react.useState)(initialValue);
|
|
59
77
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
60
78
|
const [selectNodes, setSelectNodes] = (0, import_react.useState)([]);
|
|
61
79
|
const [searchValue, setSearchValue] = (0, import_react.useState)("");
|
|
@@ -71,30 +89,34 @@ var HeaderFilter = import_react.default.memo((props) => {
|
|
|
71
89
|
const inputChange = (value) => {
|
|
72
90
|
setSearchValue(value);
|
|
73
91
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
const getCurrentValue = (type) => type === "search" ? searchValue : selectNodes;
|
|
93
|
+
const commitValue = (value) => {
|
|
94
|
+
const committed = Array.isArray(value) ? [...value] : value;
|
|
95
|
+
committedValueRef.current = committed;
|
|
96
|
+
setCommittedValue(committed);
|
|
78
97
|
};
|
|
79
|
-
const
|
|
98
|
+
const applyFilter = (type) => {
|
|
99
|
+
const value = getCurrentValue(type);
|
|
100
|
+
commitValue(value);
|
|
80
101
|
onInternalFilter({
|
|
81
102
|
dataIndex,
|
|
82
|
-
value
|
|
103
|
+
value,
|
|
83
104
|
type,
|
|
84
105
|
column
|
|
85
106
|
});
|
|
107
|
+
};
|
|
108
|
+
const reset = () => {
|
|
109
|
+
const value = items ? [] : "";
|
|
110
|
+
setSearchValue("");
|
|
111
|
+
setSelectNodes([]);
|
|
112
|
+
commitValue(value);
|
|
113
|
+
onInternalFilter({ dataIndex, value, column });
|
|
114
|
+
};
|
|
115
|
+
const ok = (type) => {
|
|
116
|
+
applyFilter(type);
|
|
86
117
|
setOpen(false);
|
|
87
118
|
};
|
|
88
119
|
let popup;
|
|
89
|
-
const {
|
|
90
|
-
items,
|
|
91
|
-
icon,
|
|
92
|
-
searchable = true,
|
|
93
|
-
filterMode = "menu"
|
|
94
|
-
// filtered,
|
|
95
|
-
// filterOnClose,
|
|
96
|
-
// onFilter,
|
|
97
|
-
} = filter;
|
|
98
120
|
const searchInputNode = searchable ? /* @__PURE__ */ import_react.default.createElement(
|
|
99
121
|
import_Input.default,
|
|
100
122
|
{
|
|
@@ -110,7 +132,9 @@ var HeaderFilter = import_react.default.memo((props) => {
|
|
|
110
132
|
ref: inputRef
|
|
111
133
|
}
|
|
112
134
|
) : null;
|
|
113
|
-
if (
|
|
135
|
+
if (render) {
|
|
136
|
+
popup = render();
|
|
137
|
+
} else if (items) {
|
|
114
138
|
let dataSource = [];
|
|
115
139
|
const inputValue = getStrLower(searchValue);
|
|
116
140
|
const filteredItems = inputValue ? items.filter(
|
|
@@ -152,15 +176,23 @@ var HeaderFilter = import_react.default.memo((props) => {
|
|
|
152
176
|
} else {
|
|
153
177
|
return null;
|
|
154
178
|
}
|
|
155
|
-
const handleOpenChange = (
|
|
156
|
-
|
|
179
|
+
const handleOpenChange = (nextOpen) => {
|
|
180
|
+
if (!nextOpen && open && filterOnClose && !render) {
|
|
181
|
+
const type = items ? "filter" : "search";
|
|
182
|
+
const value = getCurrentValue(type);
|
|
183
|
+
if (!areFilterValuesEqual(value, committedValueRef.current)) {
|
|
184
|
+
applyFilter(type);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
setOpen(nextOpen);
|
|
157
188
|
};
|
|
189
|
+
const isFiltered = filtered != null ? filtered : hasFilterValue(committedValue);
|
|
158
190
|
const renderTrigger = () => {
|
|
159
|
-
const trigger = typeof icon === "function" ? icon() : /* @__PURE__ */ import_react.default.createElement(
|
|
191
|
+
const trigger = typeof icon === "function" ? icon(isFiltered) : /* @__PURE__ */ import_react.default.createElement(
|
|
160
192
|
import_Button.default,
|
|
161
193
|
{
|
|
162
194
|
icon: items ? /* @__PURE__ */ import_react.default.createElement(import_lucide_react.ListFilter, { size: 14, strokeWidth: 1.5 }) : /* @__PURE__ */ import_react.default.createElement(import_lucide_react.Search, { size: 14, strokeWidth: 1.5 }),
|
|
163
|
-
variant:
|
|
195
|
+
variant: isFiltered ? "filled" : void 0,
|
|
164
196
|
type: "text",
|
|
165
197
|
size: "small"
|
|
166
198
|
}
|
|
@@ -40,7 +40,7 @@ __export(util_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(util_exports);
|
|
42
42
|
function handleColumns(columns) {
|
|
43
|
-
var _a;
|
|
43
|
+
var _a, _b;
|
|
44
44
|
let leftWidthCount = 0;
|
|
45
45
|
let rightWidthCount = 0;
|
|
46
46
|
for (let i = 0; i < columns.length; i++) {
|
|
@@ -48,7 +48,9 @@ function handleColumns(columns) {
|
|
|
48
48
|
if (col.fixed === true || col.fixed === "left") {
|
|
49
49
|
col.fixed = "left";
|
|
50
50
|
col.style = __spreadProps(__spreadValues({}, col.style), { left: leftWidthCount });
|
|
51
|
-
|
|
51
|
+
const nextFixed = (_a = columns[i + 1]) == null ? void 0 : _a.fixed;
|
|
52
|
+
const nextIsFixedLeft = nextFixed === true || nextFixed === "left";
|
|
53
|
+
if (!nextIsFixedLeft) {
|
|
52
54
|
col.isFixedLeftLast = true;
|
|
53
55
|
}
|
|
54
56
|
leftWidthCount = leftWidthCount + (col.width ? parseFloat(col.width) : 0);
|
|
@@ -58,7 +60,7 @@ function handleColumns(columns) {
|
|
|
58
60
|
const col = columns[j] || {};
|
|
59
61
|
if (col.fixed === "right") {
|
|
60
62
|
col.style = __spreadProps(__spreadValues({}, col.style), { right: rightWidthCount });
|
|
61
|
-
if (((
|
|
63
|
+
if (((_b = columns[j - 1]) == null ? void 0 : _b.fixed) !== "right") {
|
|
62
64
|
col.isFixedRightFirst = true;
|
|
63
65
|
}
|
|
64
66
|
rightWidthCount = rightWidthCount + (col.width ? parseFloat(col.width) : 0);
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -4,10 +4,13 @@ export default (function () {
|
|
|
4
4
|
return /*#__PURE__*/React.createElement(Space, {
|
|
5
5
|
direction: "vertical"
|
|
6
6
|
}, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Spin, {
|
|
7
|
-
variant: "dot"
|
|
7
|
+
variant: "dot",
|
|
8
|
+
color: "error"
|
|
8
9
|
}), /*#__PURE__*/React.createElement("span", null, "dot")), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Spin, {
|
|
9
|
-
variant: "ring"
|
|
10
|
+
variant: "ring",
|
|
11
|
+
color: "error"
|
|
10
12
|
}), /*#__PURE__*/React.createElement("span", null, "ring")), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Spin, {
|
|
11
|
-
variant: "spokes"
|
|
13
|
+
variant: "spokes",
|
|
14
|
+
color: "error"
|
|
12
15
|
}), /*#__PURE__*/React.createElement("span", null, "spokes")));
|
|
13
16
|
});
|
|
@@ -56,7 +56,8 @@ var SpokesSpinner = function SpokesSpinner(props) {
|
|
|
56
56
|
classNames = props.classNames,
|
|
57
57
|
styles = props.styles,
|
|
58
58
|
width = props.width,
|
|
59
|
-
height = props.height
|
|
59
|
+
height = props.height,
|
|
60
|
+
color = props.color;
|
|
60
61
|
var containerSize = sizeMap[size];
|
|
61
62
|
var count = 8;
|
|
62
63
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -75,7 +76,8 @@ var SpokesSpinner = function SpokesSpinner(props) {
|
|
|
75
76
|
className: "".concat(prefixCls, "-spokes-line"),
|
|
76
77
|
style: {
|
|
77
78
|
transform: "rotate(".concat(i * (360 / count), "deg)"),
|
|
78
|
-
animationDelay: "".concat(i * 1 / count, "s")
|
|
79
|
+
animationDelay: "".concat(i * 1 / count, "s"),
|
|
80
|
+
backgroundColor: color
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
})));
|
|
@@ -43,10 +43,7 @@
|
|
|
43
43
|
display: block;
|
|
44
44
|
border-style: solid;
|
|
45
45
|
border-color: var(--yee-color-bg-layout, rgba(0, 0, 0, 8%));
|
|
46
|
-
border-top-color: var(
|
|
47
|
-
--yee-spin-default-color,
|
|
48
|
-
var(--yee-color-primary, #1677ff)
|
|
49
|
-
);
|
|
46
|
+
border-top-color: var(--m-indicator-dot-bg-color);
|
|
50
47
|
border-radius: 50%;
|
|
51
48
|
animation: yee-spin-ring-rotate 0.8s linear infinite;
|
|
52
49
|
}
|
|
@@ -67,10 +64,7 @@
|
|
|
67
64
|
height: 40%;
|
|
68
65
|
margin-left: -1px;
|
|
69
66
|
transform-origin: center bottom;
|
|
70
|
-
background-color: var(
|
|
71
|
-
--yee-spin-default-color,
|
|
72
|
-
var(--yee-color-primary, #1677ff)
|
|
73
|
-
);
|
|
67
|
+
background-color: var(--m-indicator-dot-bg-color);
|
|
74
68
|
border-radius: 1px;
|
|
75
69
|
animation: yee-spin-spokes-fade 1.2s linear infinite;
|
|
76
70
|
}
|
|
@@ -3,5 +3,5 @@ import { ColumnProps } from './interface';
|
|
|
3
3
|
interface TableColGroupProps {
|
|
4
4
|
columns: Array<ColumnProps>;
|
|
5
5
|
}
|
|
6
|
-
declare const
|
|
7
|
-
export default
|
|
6
|
+
declare const ColGroup: React.MemoExoticComponent<({ columns }: TableColGroupProps) => React.JSX.Element>;
|
|
7
|
+
export default ColGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExpandableType } from '../interface';
|
|
2
|
-
export default function useExpand(expandable: ExpandableType | undefined, allKeys:
|
|
1
|
+
import { ExpandableType, SelectionKeyType } from '../interface';
|
|
2
|
+
export default function useExpand(expandable: ExpandableType | undefined, allKeys: SelectionKeyType[], getRowKey: (record: Record<string, any>) => SelectionKeyType): {
|
|
3
3
|
expandedRowKeys: (string | number)[];
|
|
4
4
|
onExpand: ({ expanded, record, }: {
|
|
5
5
|
expanded: boolean;
|