@rainbow-oh/yee-c 0.5.1 → 0.6.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/cjs/Anchor/anchor-item.js +10 -2
- package/dist/cjs/Anchor/interface.d.ts +1 -1
- package/dist/cjs/Dialog/dialog.js +16 -2
- package/dist/cjs/Dialog/interface.d.ts +1 -1
- package/dist/cjs/Input/style/index.less +2 -0
- package/dist/cjs/Table/demo/components-override.d.ts +3 -0
- package/dist/cjs/Table/demo/components-override.js +54 -0
- package/dist/cjs/Table/demo/grouping.d.ts +3 -0
- package/dist/cjs/Table/demo/grouping.js +129 -0
- package/dist/cjs/Table/hooks/useColumns.d.ts +2 -2
- package/dist/cjs/Table/hooks/useColumns.js +15 -37
- package/dist/cjs/Table/index.d.ts +1 -1
- package/dist/cjs/Table/interface.d.ts +59 -8
- package/dist/cjs/Table/style/index.less +19 -1
- package/dist/cjs/Table/table.js +5 -7
- package/dist/cjs/Table/tbody/cell.d.ts +0 -1
- package/dist/cjs/Table/tbody/cell.js +0 -4
- package/dist/cjs/Table/tbody/index.js +19 -2
- package/dist/cjs/Table/tbody/row.js +15 -11
- package/dist/cjs/Table/theader/cell.js +7 -1
- package/dist/cjs/Table/theader/index.d.ts +5 -5
- package/dist/cjs/Table/theader/index.js +41 -27
- package/dist/cjs/Table/util/header.d.ts +23 -0
- package/dist/cjs/Table/util/header.js +109 -0
- package/dist/cjs/TextArea/style/index.less +1 -0
- package/dist/cjs/style/size.css +1 -0
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +2 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Anchor/anchor-item.js +4 -3
- package/dist/esm/Anchor/interface.d.ts +1 -1
- package/dist/esm/Dialog/dialog.js +4 -2
- package/dist/esm/Dialog/interface.d.ts +1 -1
- package/dist/esm/Input/style/index.less +2 -0
- package/dist/esm/Table/demo/components-override.d.ts +3 -0
- package/dist/esm/Table/demo/components-override.js +86 -0
- package/dist/esm/Table/demo/grouping.d.ts +3 -0
- package/dist/esm/Table/demo/grouping.js +102 -0
- package/dist/esm/Table/hooks/useColumns.d.ts +2 -2
- package/dist/esm/Table/hooks/useColumns.js +24 -50
- package/dist/esm/Table/index.d.ts +1 -1
- package/dist/esm/Table/interface.d.ts +59 -8
- package/dist/esm/Table/style/index.less +19 -1
- package/dist/esm/Table/table.js +5 -7
- package/dist/esm/Table/tbody/cell.d.ts +0 -1
- package/dist/esm/Table/tbody/cell.js +0 -5
- package/dist/esm/Table/tbody/index.js +21 -2
- package/dist/esm/Table/tbody/row.js +19 -15
- package/dist/esm/Table/theader/cell.js +6 -2
- package/dist/esm/Table/theader/index.d.ts +5 -5
- package/dist/esm/Table/theader/index.js +48 -35
- package/dist/esm/Table/util/header.d.ts +23 -0
- package/dist/esm/Table/util/header.js +107 -0
- package/dist/esm/TextArea/style/index.less +1 -0
- package/dist/esm/style/size.css +1 -0
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Anchor/anchor-item.tsx +7 -3
- package/src/Anchor/interface.ts +1 -1
- package/src/Dialog/dialog.tsx +10 -2
- package/src/Dialog/interface.ts +1 -1
- package/src/Input/style/index.less +2 -0
- package/src/Table/demo/components-override.tsx +49 -0
- package/src/Table/demo/grouping.tsx +104 -0
- package/src/Table/hooks/useColumns.ts +29 -46
- package/src/Table/index.en-US.md +31 -3
- package/src/Table/index.ts +4 -0
- package/src/Table/index.zh-CN.md +30 -2
- package/src/Table/interface.ts +66 -8
- package/src/Table/style/index.less +19 -1
- package/src/Table/table.tsx +5 -7
- package/src/Table/tbody/cell.tsx +0 -6
- package/src/Table/tbody/index.tsx +21 -2
- package/src/Table/tbody/row.tsx +25 -14
- package/src/Table/theader/cell.tsx +4 -0
- package/src/Table/theader/index.tsx +61 -42
- package/src/Table/util/header.ts +111 -0
- package/src/TextArea/style/index.less +1 -0
- package/src/style/size.css +1 -0
- package/src/version.ts +1 -1
|
@@ -8,6 +8,7 @@ import React, { useMemo } from 'react';
|
|
|
8
8
|
import useDeepCompareMemo from "../../hooks/useDeepCompareMemo";
|
|
9
9
|
import deepClone from "../../utils/deepClone";
|
|
10
10
|
import { handleColumns } from "../util";
|
|
11
|
+
import { flattenLeafColumns, injectSelectionExpand, parseHeaderRows } from "../util/header";
|
|
11
12
|
export default function useColumns(_ref) {
|
|
12
13
|
var children = _ref.children,
|
|
13
14
|
columns = _ref.columns,
|
|
@@ -15,64 +16,37 @@ export default function useColumns(_ref) {
|
|
|
15
16
|
expandable = _ref.expandable;
|
|
16
17
|
var shouldRenderSelection = !!rowSelection;
|
|
17
18
|
var shouldRenderExpand = !!expandable;
|
|
18
|
-
var getColumnsFromChild = function getColumnsFromChild(
|
|
19
|
-
var
|
|
20
|
-
React.Children.forEach(
|
|
19
|
+
var getColumnsFromChild = function getColumnsFromChild(childs) {
|
|
20
|
+
var cols = [];
|
|
21
|
+
React.Children.forEach(childs, function (child) {
|
|
21
22
|
if (child) {
|
|
22
|
-
|
|
23
|
+
cols.push(_objectSpread({}, child.props));
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
|
-
return
|
|
26
|
+
return cols.length ? cols : null;
|
|
26
27
|
};
|
|
27
28
|
var childColumns = useMemo(function () {
|
|
28
29
|
return children ? getColumnsFromChild(children) : null;
|
|
29
30
|
}, [children]);
|
|
30
31
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_expandable$visible = expandable.visible,
|
|
48
|
-
visible = _expandable$visible === void 0 ? true : _expandable$visible;
|
|
49
|
-
var _loc = _index ? _index - 1 : rowSelection ? 1 : 0;
|
|
50
|
-
if (visible !== false) {
|
|
51
|
-
result.splice(_loc, 0, _objectSpread(_objectSpread({
|
|
52
|
-
width: 50
|
|
53
|
-
}, expandable), {}, {
|
|
54
|
-
key: 'YEE_EXPAND_COL'
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
result = handleColumns(result);
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// const [mergedColumns, setMergedColumns] = React.useState(
|
|
63
|
-
// wrapColumns(childColumns || columns || []),
|
|
64
|
-
// );
|
|
65
|
-
|
|
66
|
-
// useDeepCompareEffect(() => {
|
|
67
|
-
// const merged = wrapColumns(childColumns || columns || []);
|
|
68
|
-
// setMergedColumns(merged);
|
|
69
|
-
// }, [childColumns, columns, shouldRenderSelection, shouldRenderExpand]);
|
|
70
|
-
|
|
71
|
-
var mergedColumns = useDeepCompareMemo(function () {
|
|
72
|
-
return wrapColumns(childColumns || columns || []);
|
|
73
|
-
}, [childColumns, columns, shouldRenderSelection, shouldRenderExpand]);
|
|
32
|
+
// Build the column tree (with selection/expand injected at the top level),
|
|
33
|
+
// then derive both the flat leaf columns (body/colgroup/summary/sorter) and
|
|
34
|
+
// the 2D header rows (thead multi-level rendering).
|
|
35
|
+
var _useDeepCompareMemo = useDeepCompareMemo(function () {
|
|
36
|
+
var base = deepClone(childColumns || columns || []) || [];
|
|
37
|
+
var tree = injectSelectionExpand(base, rowSelection, expandable);
|
|
38
|
+
var leaves = flattenLeafColumns(tree);
|
|
39
|
+
var wraped = handleColumns(leaves);
|
|
40
|
+
var rows = parseHeaderRows(tree);
|
|
41
|
+
return {
|
|
42
|
+
wrapedColumns: wraped,
|
|
43
|
+
headerRows: rows
|
|
44
|
+
};
|
|
45
|
+
}, [childColumns, columns, shouldRenderSelection, shouldRenderExpand]),
|
|
46
|
+
wrapedColumns = _useDeepCompareMemo.wrapedColumns,
|
|
47
|
+
headerRows = _useDeepCompareMemo.headerRows;
|
|
74
48
|
return {
|
|
75
|
-
wrapedColumns:
|
|
76
|
-
|
|
49
|
+
wrapedColumns: wrapedColumns,
|
|
50
|
+
headerRows: headerRows
|
|
77
51
|
};
|
|
78
52
|
}
|
|
@@ -2,7 +2,7 @@ import Column from './column';
|
|
|
2
2
|
import Summary from './summary';
|
|
3
3
|
import InternalTable from './table';
|
|
4
4
|
import Head from './theader';
|
|
5
|
-
export type { ColumnProps, PaginationType, RowSelectionType, TableProps, onChangeParams, } from './interface';
|
|
5
|
+
export type { ColumnProps, PaginationType, RowSelectionType, TableProps, TableComponents, TableBodyComponents, TableRowRendererProps, HeaderCell, onChangeParams, } from './interface';
|
|
6
6
|
type TableType = typeof InternalTable & {
|
|
7
7
|
Column: typeof Column;
|
|
8
8
|
Summary: typeof Summary;
|
|
@@ -66,6 +66,14 @@ export interface HeadCellProps extends Omit<WrapedColumnProps, 'title'> {
|
|
|
66
66
|
};
|
|
67
67
|
onSort?: (dataIndex: string, sorter: any) => void;
|
|
68
68
|
onInternalFilter?: (dataIndex: string, value: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Horizontal span, used for grouped header cells
|
|
71
|
+
*/
|
|
72
|
+
colSpan?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Vertical span, used for grouped header cells
|
|
75
|
+
*/
|
|
76
|
+
rowSpan?: number;
|
|
69
77
|
}
|
|
70
78
|
export interface RowSelectionType {
|
|
71
79
|
/**
|
|
@@ -226,9 +234,9 @@ export interface ColumnProps {
|
|
|
226
234
|
*/
|
|
227
235
|
helper?: string | React.ReactNode;
|
|
228
236
|
/**
|
|
229
|
-
*
|
|
237
|
+
* Sub-columns for header grouping (multi-level header). Use cell `render` for custom cell content.
|
|
230
238
|
*/
|
|
231
|
-
children?:
|
|
239
|
+
children?: ColumnProps[];
|
|
232
240
|
/**
|
|
233
241
|
* Set cell properties
|
|
234
242
|
*/
|
|
@@ -252,7 +260,50 @@ export interface WrapedColumnProps extends ColumnProps, ExpandableType, Omit<Row
|
|
|
252
260
|
*/
|
|
253
261
|
isFixedRightFirst?: boolean;
|
|
254
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* A header cell resolved from the column tree, with computed span info for multi-level headers.
|
|
265
|
+
*/
|
|
266
|
+
export interface HeaderCell {
|
|
267
|
+
/**
|
|
268
|
+
* The source wrapped column (leaf or group)
|
|
269
|
+
*/
|
|
270
|
+
column: WrapedColumnProps;
|
|
271
|
+
/**
|
|
272
|
+
* Horizontal span (number of leaf columns covered)
|
|
273
|
+
*/
|
|
274
|
+
colSpan: number;
|
|
275
|
+
/**
|
|
276
|
+
* Vertical span (number of header rows covered)
|
|
277
|
+
*/
|
|
278
|
+
rowSpan: number;
|
|
279
|
+
/**
|
|
280
|
+
* Whether this cell has sub-columns (group header)
|
|
281
|
+
*/
|
|
282
|
+
hasSubColumns?: boolean;
|
|
283
|
+
}
|
|
255
284
|
type DownloadType = ButtonProps;
|
|
285
|
+
/**
|
|
286
|
+
* 行接管渲染器收到的 props(components.body.row)
|
|
287
|
+
*/
|
|
288
|
+
export interface TableRowRendererProps {
|
|
289
|
+
record: Record<string, any>;
|
|
290
|
+
index: number;
|
|
291
|
+
columns: WrapedColumnProps[];
|
|
292
|
+
/** 当前行 key 值(= record[rowKey]),可作 sortable id */
|
|
293
|
+
rowKey: string | number;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 可被外部接管的 <tbody> / 行渲染
|
|
297
|
+
*/
|
|
298
|
+
export interface TableBodyComponents {
|
|
299
|
+
/** 替换 <tbody>;常用于在外部包 SortableContext 等 Provider */
|
|
300
|
+
tbody?: React.ElementType;
|
|
301
|
+
/** 整行接管:消费方自行渲染 <tr> + 单元格(含拖拽手柄等) */
|
|
302
|
+
row?: React.ComponentType<TableRowRendererProps>;
|
|
303
|
+
}
|
|
304
|
+
export interface TableComponents {
|
|
305
|
+
body?: TableBodyComponents;
|
|
306
|
+
}
|
|
256
307
|
export type SemanticProps = {
|
|
257
308
|
/**
|
|
258
309
|
* Semantic class names
|
|
@@ -265,7 +316,7 @@ export type SemanticProps = {
|
|
|
265
316
|
/**
|
|
266
317
|
* Custom table elements
|
|
267
318
|
*/
|
|
268
|
-
components?:
|
|
319
|
+
components?: TableComponents;
|
|
269
320
|
};
|
|
270
321
|
export interface HeaderProps extends SemanticProps {
|
|
271
322
|
/**
|
|
@@ -316,8 +367,8 @@ export interface TableRowProps {
|
|
|
316
367
|
stripe?: boolean;
|
|
317
368
|
expandedKeyType?: string;
|
|
318
369
|
onRow?: (record: Record<string, any>, index: number) => Record<string, any>;
|
|
319
|
-
rowClassName?: (record: Record<string, any>, index: number) => string;
|
|
320
|
-
rowStyle?: (record: Record<string, any>, index: number) => React.CSSProperties;
|
|
370
|
+
rowClassName?: (record: Record<string, any>, index: number) => string | undefined;
|
|
371
|
+
rowStyle?: (record: Record<string, any>, index: number) => React.CSSProperties | undefined;
|
|
321
372
|
onDoubleClick?: (record: Record<string, any>, event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
322
373
|
onExpand: ({ expanded, record, index, }: {
|
|
323
374
|
expanded: boolean;
|
|
@@ -403,7 +454,7 @@ export interface TableProps extends FooterProps, Omit<HeaderProps, 'pageData'>,
|
|
|
403
454
|
/**
|
|
404
455
|
* Custom table elements
|
|
405
456
|
*/
|
|
406
|
-
components?:
|
|
457
|
+
components?: TableComponents;
|
|
407
458
|
/**
|
|
408
459
|
* Whether to show outer and column borders
|
|
409
460
|
*/
|
|
@@ -447,11 +498,11 @@ export interface TableProps extends FooterProps, Omit<HeaderProps, 'pageData'>,
|
|
|
447
498
|
/**
|
|
448
499
|
* Row class name, unlike classNames, this prop can be set dynamically via a function
|
|
449
500
|
*/
|
|
450
|
-
rowClassName?: (record: object) => string;
|
|
501
|
+
rowClassName?: (record: object) => string | undefined;
|
|
451
502
|
/**
|
|
452
503
|
* Row style, unlike styles, this prop can be set dynamically via a function
|
|
453
504
|
*/
|
|
454
|
-
rowStyle?: (record: object) => React.CSSProperties;
|
|
505
|
+
rowStyle?: (record: object) => React.CSSProperties | undefined;
|
|
455
506
|
/**
|
|
456
507
|
* Pagination config
|
|
457
508
|
*/
|
|
@@ -153,7 +153,25 @@
|
|
|
153
153
|
|
|
154
154
|
&-tbody {
|
|
155
155
|
@{pls}-cell {
|
|
156
|
-
background-color: var(--yee-table-cell-bg-color,
|
|
156
|
+
background-color: var(--yee-table-cell-bg-color, inherit);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@{pls}-row {
|
|
160
|
+
&:hover {
|
|
161
|
+
background-color: var(--yee-table-tbody-tr-hover-bg-color);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&-odd-row {
|
|
167
|
+
> @{pls}-cell {
|
|
168
|
+
background-color: var(--yee-table-odd-row-bg-color);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&-even-row {
|
|
173
|
+
> @{pls}-cell {
|
|
174
|
+
background-color: var(--yee-table-even-row-bg-color);
|
|
157
175
|
}
|
|
158
176
|
}
|
|
159
177
|
|
package/dist/esm/Table/table.js
CHANGED
|
@@ -83,7 +83,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
83
83
|
rowSelection: rowSelection
|
|
84
84
|
}),
|
|
85
85
|
wrapedColumns = _useColumns.wrapedColumns,
|
|
86
|
-
|
|
86
|
+
headerRows = _useColumns.headerRows;
|
|
87
87
|
|
|
88
88
|
// Filter
|
|
89
89
|
var _useFilter = useFilter({
|
|
@@ -95,7 +95,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
95
95
|
// Sort
|
|
96
96
|
var _useSorter = useSorter({
|
|
97
97
|
data: filteredData,
|
|
98
|
-
columns:
|
|
98
|
+
columns: wrapedColumns
|
|
99
99
|
}),
|
|
100
100
|
sortedData = _useSorter.data,
|
|
101
101
|
sorters = _useSorter.sorters,
|
|
@@ -133,7 +133,6 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
133
133
|
}),
|
|
134
134
|
selectedRowKeys = _useSelection.selectedRowKeys,
|
|
135
135
|
checkedAll = _useSelection.checkedAll,
|
|
136
|
-
pageDataRowKeys = _useSelection.pageDataRowKeys,
|
|
137
136
|
onCheckAll = _useSelection.onCheckAll,
|
|
138
137
|
onSelectionChange = _useSelection.onChange;
|
|
139
138
|
|
|
@@ -185,7 +184,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
185
184
|
prefixCls: prefixCls,
|
|
186
185
|
header: header,
|
|
187
186
|
download: download,
|
|
188
|
-
columns:
|
|
187
|
+
columns: wrapedColumns,
|
|
189
188
|
pageData: pageData,
|
|
190
189
|
dataSource: dataSource
|
|
191
190
|
});
|
|
@@ -196,8 +195,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
196
195
|
}
|
|
197
196
|
var ths = omit(rest, ['rowSelection']);
|
|
198
197
|
return /*#__PURE__*/React.createElement(THeader, _extends({}, ths, {
|
|
199
|
-
|
|
200
|
-
pageDataRowKeys: pageDataRowKeys,
|
|
198
|
+
headerRows: headerRows,
|
|
201
199
|
checkedAll: checkedAll,
|
|
202
200
|
sorters: sorters,
|
|
203
201
|
onSort: onSort,
|
|
@@ -235,7 +233,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
235
233
|
var table = /*#__PURE__*/React.createElement(TableCtx.Provider, {
|
|
236
234
|
value: {
|
|
237
235
|
prefixCls: prefixCls,
|
|
238
|
-
columns:
|
|
236
|
+
columns: wrapedColumns,
|
|
239
237
|
classNames: classNames,
|
|
240
238
|
styles: styles,
|
|
241
239
|
components: components,
|
|
@@ -22,7 +22,6 @@ var TableCell = function TableCell(props) {
|
|
|
22
22
|
className = column.className,
|
|
23
23
|
styles = column.styles,
|
|
24
24
|
classNames = column.classNames,
|
|
25
|
-
children = column.children,
|
|
26
25
|
onCell = column.onCell,
|
|
27
26
|
render = column.render;
|
|
28
27
|
var _useContext = useContext(TableCtx),
|
|
@@ -31,10 +30,6 @@ var TableCell = function TableCell(props) {
|
|
|
31
30
|
if (render) {
|
|
32
31
|
return typeof render === 'function' ? render(record, rowIndex) : render;
|
|
33
32
|
}
|
|
34
|
-
if (typeof children === 'function') {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
return children(record, rowIndex);
|
|
37
|
-
}
|
|
38
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
39
34
|
className: clsx("".concat(prefixCls, "-cell-inner"), classNames === null || classNames === void 0 ? void 0 : classNames.inner),
|
|
40
35
|
style: styles === null || styles === void 0 ? void 0 : styles.inner
|
|
@@ -8,12 +8,15 @@ import { TableCtx } from "../table";
|
|
|
8
8
|
import LazyRow from "./lazy-row";
|
|
9
9
|
import TableRow from "./row";
|
|
10
10
|
var TableBody = function TableBody(props) {
|
|
11
|
+
var _components$body$tbod, _components$body, _components$body2;
|
|
11
12
|
var columns = props.columns,
|
|
12
13
|
pageData = props.pageData,
|
|
13
14
|
lazyLoad = props.lazyLoad,
|
|
14
15
|
rest = _objectWithoutProperties(props, _excluded);
|
|
15
16
|
var _React$useContext = React.useContext(TableCtx),
|
|
16
|
-
prefixCls = _React$useContext.prefixCls
|
|
17
|
+
prefixCls = _React$useContext.prefixCls,
|
|
18
|
+
components = _React$useContext.components,
|
|
19
|
+
rowKey = _React$useContext.rowKey;
|
|
17
20
|
var _useLocale = useLocale(),
|
|
18
21
|
locale = _useLocale.locale;
|
|
19
22
|
var tableLocale = locale.table;
|
|
@@ -26,6 +29,11 @@ var TableBody = function TableBody(props) {
|
|
|
26
29
|
}, tableLocale.emptyText)));
|
|
27
30
|
var dataLength = pageData.length;
|
|
28
31
|
if (dataLength === 0) return empty;
|
|
32
|
+
var BodyWrapper = (_components$body$tbod = components === null || components === void 0 || (_components$body = components.body) === null || _components$body === void 0 ? void 0 : _components$body.tbody) !== null && _components$body$tbod !== void 0 ? _components$body$tbod : 'tbody';
|
|
33
|
+
var RowRenderer = components === null || components === void 0 || (_components$body2 = components.body) === null || _components$body2 === void 0 ? void 0 : _components$body2.row;
|
|
34
|
+
var resolveRowKey = function resolveRowKey(record) {
|
|
35
|
+
return typeof rowKey === 'function' ? rowKey(record) : record[rowKey];
|
|
36
|
+
};
|
|
29
37
|
var getRenderRows = function getRenderRows() {
|
|
30
38
|
if (lazyLoad) {
|
|
31
39
|
return /*#__PURE__*/React.createElement(LazyRow, _extends({}, rest, {
|
|
@@ -34,6 +42,17 @@ var TableBody = function TableBody(props) {
|
|
|
34
42
|
}));
|
|
35
43
|
}
|
|
36
44
|
return pageData.map(function (record, index) {
|
|
45
|
+
// 整行接管:由外部组件渲染 <tr> + 单元格(可放拖拽手柄等)
|
|
46
|
+
if (RowRenderer) {
|
|
47
|
+
var rk = resolveRowKey(record);
|
|
48
|
+
return /*#__PURE__*/React.createElement(RowRenderer, {
|
|
49
|
+
key: rk !== null && rk !== void 0 ? rk : index,
|
|
50
|
+
record: record,
|
|
51
|
+
index: index,
|
|
52
|
+
columns: columns,
|
|
53
|
+
rowKey: rk
|
|
54
|
+
});
|
|
55
|
+
}
|
|
37
56
|
return /*#__PURE__*/React.createElement(TableRow, _extends({}, rest, {
|
|
38
57
|
columns: columns,
|
|
39
58
|
record: record,
|
|
@@ -42,7 +61,7 @@ var TableBody = function TableBody(props) {
|
|
|
42
61
|
}));
|
|
43
62
|
});
|
|
44
63
|
};
|
|
45
|
-
var tbody = /*#__PURE__*/React.createElement(
|
|
64
|
+
var tbody = /*#__PURE__*/React.createElement(BodyWrapper, {
|
|
46
65
|
className: "".concat(prefixCls, "-tbody")
|
|
47
66
|
}, getRenderRows());
|
|
48
67
|
return tbody;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["index", "record", "columns", "highlight", "stripe", "expandedKeyType", "expandedRowKeys", "selectedRowKeys", "expandable", "onExpand", "onRow", "rowClassName", "rowStyle", "onDoubleClick", "onSelectionChange"]
|
|
3
|
-
_excluded2 = ["type", "onCell"];
|
|
2
|
+
var _excluded = ["index", "record", "columns", "highlight", "stripe", "expandedKeyType", "expandedRowKeys", "selectedRowKeys", "expandable", "onExpand", "onRow", "rowClassName", "rowStyle", "onDoubleClick", "onSelectionChange"];
|
|
4
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -58,23 +57,28 @@ var TableRow = function TableRow(props) {
|
|
|
58
57
|
};
|
|
59
58
|
var getSelection = function getSelection(column) {
|
|
60
59
|
var type = column.type,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
var props = onCell ? onCell(record, index)
|
|
65
|
-
var checked = selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.includes(
|
|
66
|
-
|
|
60
|
+
colDisabled = column.disabled,
|
|
61
|
+
onCell = column.onCell;
|
|
62
|
+
var rowKeyValue = record[rowKey];
|
|
63
|
+
var props = (onCell === null || onCell === void 0 ? void 0 : onCell(record, index)) || {};
|
|
64
|
+
var checked = selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.includes(rowKeyValue);
|
|
65
|
+
|
|
66
|
+
// rowSelection.disabled may be a boolean, a per-row array, or a function
|
|
67
|
+
var disabled = typeof colDisabled === 'function' ? colDisabled(record, index) : Array.isArray(colDisabled) ? colDisabled[index] : !!colDisabled;
|
|
68
|
+
|
|
69
|
+
// Only forward input-relevant props. Spreading the whole column would leak
|
|
70
|
+
// rowSelection fields (selectedRowKeys/selectAll/...) and the synthetic
|
|
71
|
+
// `key` onto the DOM <input>.
|
|
72
|
+
var commonProps = _objectSpread({
|
|
67
73
|
checked: checked,
|
|
68
|
-
value:
|
|
69
|
-
onChange: onSelectionChange
|
|
70
|
-
|
|
74
|
+
value: rowKeyValue,
|
|
75
|
+
onChange: onSelectionChange,
|
|
76
|
+
disabled: disabled
|
|
77
|
+
}, props);
|
|
71
78
|
if (type === 'checkbox') {
|
|
72
|
-
// @ts-ignore
|
|
73
79
|
return /*#__PURE__*/React.createElement(Checkbox, commonProps);
|
|
74
|
-
} else {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
return /*#__PURE__*/React.createElement(Radio, commonProps);
|
|
77
80
|
}
|
|
81
|
+
return /*#__PURE__*/React.createElement(Radio, commonProps);
|
|
78
82
|
};
|
|
79
83
|
var colSpanStart = Infinity;
|
|
80
84
|
var colSpanEnd = -1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["fixed", "isFixedLeftLast", "isFixedRightFirst", "align", "title", "dataIndex", "sorter", "filter", "sorters", "className", "styles", "classNames", "showSorterTooltip", "tableActionBarShowOnHover", "internalFilters", "style", "width", "onHeaderCell", "onSort", "onInternalFilter"];
|
|
2
|
+
var _excluded = ["fixed", "isFixedLeftLast", "isFixedRightFirst", "align", "title", "dataIndex", "sorter", "filter", "sorters", "className", "styles", "classNames", "showSorterTooltip", "tableActionBarShowOnHover", "internalFilters", "style", "width", "colSpan", "rowSpan", "onHeaderCell", "onSort", "onInternalFilter"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -34,6 +34,8 @@ var HeadCell = function HeadCell(props) {
|
|
|
34
34
|
internalFilters = props.internalFilters,
|
|
35
35
|
style = props.style,
|
|
36
36
|
width = props.width,
|
|
37
|
+
colSpan = props.colSpan,
|
|
38
|
+
rowSpan = props.rowSpan,
|
|
37
39
|
onHeaderCell = props.onHeaderCell,
|
|
38
40
|
onSort = props.onSort,
|
|
39
41
|
onInternalFilter = props.onInternalFilter,
|
|
@@ -123,7 +125,9 @@ var HeadCell = function HeadCell(props) {
|
|
|
123
125
|
return _objectSpread(_objectSpread({}, cellProps), {}, {
|
|
124
126
|
className: cls,
|
|
125
127
|
scope: 'col',
|
|
126
|
-
style: styles
|
|
128
|
+
style: styles,
|
|
129
|
+
colSpan: colSpan,
|
|
130
|
+
rowSpan: rowSpan
|
|
127
131
|
});
|
|
128
132
|
};
|
|
129
133
|
var thProps = getThProps();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { HeaderCell } from '../interface';
|
|
3
3
|
export interface TableHeadProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Resolved 2D header rows (one array per header row), produced by parseHeaderRows
|
|
6
|
+
*/
|
|
7
|
+
headerRows?: HeaderCell[][];
|
|
8
8
|
}
|
|
9
9
|
declare const _default: React.NamedExoticComponent<any>;
|
|
10
10
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["
|
|
1
|
+
var _excluded = ["headerRows", "onCheckAll", "checkedAll", "onHeaderRow"],
|
|
2
2
|
_excluded2 = ["children"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -9,49 +9,62 @@ import Checkbox from "../../Checkbox";
|
|
|
9
9
|
import { TableCtx } from "../table";
|
|
10
10
|
import HeadCell from "./cell";
|
|
11
11
|
var TableHead = function TableHead(props) {
|
|
12
|
-
var
|
|
12
|
+
var _props$headerRows = props.headerRows,
|
|
13
|
+
headerRows = _props$headerRows === void 0 ? [] : _props$headerRows,
|
|
13
14
|
onCheckAll = props.onCheckAll,
|
|
14
15
|
checkedAll = props.checkedAll,
|
|
15
16
|
onHeaderRow = props.onHeaderRow,
|
|
16
17
|
rest = _objectWithoutProperties(props, _excluded);
|
|
17
18
|
var _useContext = useContext(TableCtx),
|
|
18
19
|
prefixCls = _useContext.prefixCls;
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
}
|
|
20
|
+
var renderCell = function renderCell(cell, rowIndex, colIndex) {
|
|
21
|
+
var column = cell.column,
|
|
22
|
+
colSpan = cell.colSpan,
|
|
23
|
+
rowSpan = cell.rowSpan;
|
|
24
|
+
var key = column.key,
|
|
25
|
+
type = column.type,
|
|
26
|
+
visible = column.visible;
|
|
27
|
+
var cellKey = 'title-column-' + (column.key || column.dataIndex || "".concat(rowIndex, "-").concat(colIndex));
|
|
28
|
+
if (key === 'YEE_SELECTION_COL') {
|
|
29
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
30
|
+
className: "".concat(prefixCls, "-cell ").concat(prefixCls, "-selection-col"),
|
|
31
|
+
scope: "col",
|
|
32
|
+
key: cellKey,
|
|
33
|
+
colSpan: colSpan,
|
|
34
|
+
rowSpan: rowSpan
|
|
35
|
+
}, type === 'checkbox' ? /*#__PURE__*/React.createElement(Checkbox, {
|
|
36
|
+
checked: checkedAll,
|
|
37
|
+
onChange: onCheckAll
|
|
38
|
+
}) : null);
|
|
39
|
+
}
|
|
40
|
+
if (key === 'YEE_EXPAND_COL' && visible !== false) {
|
|
41
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
42
|
+
className: clsx("".concat(prefixCls, "-cell"), "".concat(prefixCls, "-expand-col")),
|
|
43
|
+
scope: "col",
|
|
44
|
+
key: cellKey,
|
|
45
|
+
colSpan: colSpan,
|
|
46
|
+
rowSpan: rowSpan
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/React.createElement(HeadCell, _extends({}, rest, column, {
|
|
50
|
+
colSpan: colSpan,
|
|
51
|
+
rowSpan: rowSpan,
|
|
52
|
+
key: cellKey
|
|
53
|
+
}));
|
|
48
54
|
};
|
|
49
|
-
var rowProps = onHeaderRow ? onHeaderRow(columns) : {};
|
|
50
55
|
return /*#__PURE__*/React.createElement("thead", {
|
|
51
56
|
className: clsx("".concat(prefixCls, "-thead"))
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
}, headerRows.map(function (row, rowIndex) {
|
|
58
|
+
var rowColumns = row.map(function (cell) {
|
|
59
|
+
return cell.column;
|
|
60
|
+
});
|
|
61
|
+
var rowProps = onHeaderRow ? onHeaderRow(rowColumns) : {};
|
|
62
|
+
return /*#__PURE__*/React.createElement("tr", _extends({}, rowProps, {
|
|
63
|
+
key: "thead-row-".concat(rowIndex)
|
|
64
|
+
}), row.map(function (cell, colIndex) {
|
|
65
|
+
return renderCell(cell, rowIndex, colIndex);
|
|
66
|
+
}));
|
|
67
|
+
}));
|
|
55
68
|
};
|
|
56
69
|
var Row = function Row(props) {
|
|
57
70
|
var children = props.children,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ColumnProps, ExpandableType, HeaderCell, RowSelectionType, WrapedColumnProps } from '../interface';
|
|
2
|
+
type FixedType = ColumnProps['fixed'];
|
|
3
|
+
/**
|
|
4
|
+
* Recursively flatten a (possibly grouped) column tree into its leaf columns.
|
|
5
|
+
* A parent's `fixed` is inherited by its children when the child does not set its own.
|
|
6
|
+
*/
|
|
7
|
+
export declare function flattenLeafColumns(columns: WrapedColumnProps[], parentFixed?: FixedType): WrapedColumnProps[];
|
|
8
|
+
/**
|
|
9
|
+
* Convert a column tree into a 2D array of header cells (one array per header row),
|
|
10
|
+
* computing each cell's colSpan/rowSpan. Mirrors rc-table's parseHeaderRows.
|
|
11
|
+
*
|
|
12
|
+
* - Pass 1 (DFS): place each column into the row matching its depth; a group's
|
|
13
|
+
* colSpan equals the sum of its children's colSpans.
|
|
14
|
+
* - Pass 2: leaf cells (no sub-columns) get rowSpan = rowCount - rowIndex so
|
|
15
|
+
* they stretch down to the last header row; group cells keep rowSpan = 1.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseHeaderRows(rootColumns: WrapedColumnProps[]): HeaderCell[][];
|
|
18
|
+
/**
|
|
19
|
+
* Inject selection / expand columns into the top level of the column tree.
|
|
20
|
+
* `index` is a 1-based position among the top-level columns.
|
|
21
|
+
*/
|
|
22
|
+
export declare function injectSelectionExpand(columns: WrapedColumnProps[], rowSelection?: RowSelectionType, expandable?: ExpandableType): WrapedColumnProps[];
|
|
23
|
+
export {};
|