@rainbow-oh/yee-c 0.5.0 → 0.6.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.
Files changed (83) hide show
  1. package/dist/cjs/Descriptions/descriptions.js +8 -1
  2. package/dist/cjs/Descriptions/interface.d.ts +1 -1
  3. package/dist/cjs/Select/demo/size.js +2 -0
  4. package/dist/cjs/Select/interface.d.ts +2 -1
  5. package/dist/cjs/Selector/style/index.less +8 -0
  6. package/dist/cjs/Table/demo/components-override.d.ts +3 -0
  7. package/dist/cjs/Table/demo/components-override.js +54 -0
  8. package/dist/cjs/Table/demo/grouping.d.ts +3 -0
  9. package/dist/cjs/Table/demo/grouping.js +129 -0
  10. package/dist/cjs/Table/hooks/useColumns.d.ts +2 -2
  11. package/dist/cjs/Table/hooks/useColumns.js +15 -37
  12. package/dist/cjs/Table/index.d.ts +1 -1
  13. package/dist/cjs/Table/interface.d.ts +59 -8
  14. package/dist/cjs/Table/style/index.less +19 -1
  15. package/dist/cjs/Table/table.js +5 -7
  16. package/dist/cjs/Table/tbody/cell.d.ts +0 -1
  17. package/dist/cjs/Table/tbody/cell.js +0 -4
  18. package/dist/cjs/Table/tbody/index.js +19 -2
  19. package/dist/cjs/Table/tbody/row.js +15 -11
  20. package/dist/cjs/Table/theader/cell.js +7 -1
  21. package/dist/cjs/Table/theader/index.d.ts +5 -5
  22. package/dist/cjs/Table/theader/index.js +41 -27
  23. package/dist/cjs/Table/util/header.d.ts +23 -0
  24. package/dist/cjs/Table/util/header.js +109 -0
  25. package/dist/cjs/style/size.css +4 -0
  26. package/dist/cjs/style/themes.css +1 -1
  27. package/dist/cjs/style/variables.css +5 -1
  28. package/dist/cjs/version.d.ts +1 -1
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/esm/Descriptions/descriptions.js +2 -1
  31. package/dist/esm/Descriptions/interface.d.ts +1 -1
  32. package/dist/esm/Select/demo/size.js +2 -0
  33. package/dist/esm/Select/interface.d.ts +2 -1
  34. package/dist/esm/Selector/style/index.less +8 -0
  35. package/dist/esm/Table/demo/components-override.d.ts +3 -0
  36. package/dist/esm/Table/demo/components-override.js +86 -0
  37. package/dist/esm/Table/demo/grouping.d.ts +3 -0
  38. package/dist/esm/Table/demo/grouping.js +102 -0
  39. package/dist/esm/Table/hooks/useColumns.d.ts +2 -2
  40. package/dist/esm/Table/hooks/useColumns.js +24 -50
  41. package/dist/esm/Table/index.d.ts +1 -1
  42. package/dist/esm/Table/interface.d.ts +59 -8
  43. package/dist/esm/Table/style/index.less +19 -1
  44. package/dist/esm/Table/table.js +5 -7
  45. package/dist/esm/Table/tbody/cell.d.ts +0 -1
  46. package/dist/esm/Table/tbody/cell.js +0 -5
  47. package/dist/esm/Table/tbody/index.js +21 -2
  48. package/dist/esm/Table/tbody/row.js +19 -15
  49. package/dist/esm/Table/theader/cell.js +6 -2
  50. package/dist/esm/Table/theader/index.d.ts +5 -5
  51. package/dist/esm/Table/theader/index.js +48 -35
  52. package/dist/esm/Table/util/header.d.ts +23 -0
  53. package/dist/esm/Table/util/header.js +107 -0
  54. package/dist/esm/style/size.css +4 -0
  55. package/dist/esm/style/themes.css +1 -1
  56. package/dist/esm/style/variables.css +5 -1
  57. package/dist/esm/version.d.ts +1 -1
  58. package/dist/esm/version.js +1 -1
  59. package/dist/umd/yee-c.min.css +2 -2
  60. package/dist/umd/yee-c.min.js +1 -1
  61. package/package.json +1 -1
  62. package/src/Descriptions/descriptions.tsx +4 -1
  63. package/src/Descriptions/interface.ts +7 -1
  64. package/src/Select/demo/size.tsx +2 -0
  65. package/src/Select/interface.ts +3 -1
  66. package/src/Selector/style/index.less +8 -0
  67. package/src/Table/demo/components-override.tsx +49 -0
  68. package/src/Table/demo/grouping.tsx +104 -0
  69. package/src/Table/hooks/useColumns.ts +29 -46
  70. package/src/Table/index.en-US.md +31 -3
  71. package/src/Table/index.ts +4 -0
  72. package/src/Table/index.zh-CN.md +30 -2
  73. package/src/Table/interface.ts +66 -8
  74. package/src/Table/style/index.less +19 -1
  75. package/src/Table/table.tsx +5 -7
  76. package/src/Table/tbody/cell.tsx +0 -6
  77. package/src/Table/tbody/index.tsx +21 -2
  78. package/src/Table/tbody/row.tsx +25 -14
  79. package/src/Table/theader/cell.tsx +4 -0
  80. package/src/Table/theader/index.tsx +61 -42
  81. package/src/Table/util/header.ts +111 -0
  82. package/src/style/size.css +4 -0
  83. package/src/version.ts +1 -1
@@ -249,7 +249,14 @@ var Descriptions = import_react.default.forwardRef(
249
249
  });
250
250
  return elements;
251
251
  };
252
- return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({}, rest), { className: cls, style, ref }), renderHeader(), /* @__PURE__ */ import_react.default.createElement("table", { className: `${prefixCls}-table` }, /* @__PURE__ */ import_react.default.createElement("tbody", null, renderRows())));
252
+ return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({}, rest), { className: cls, style, ref }), renderHeader(), /* @__PURE__ */ import_react.default.createElement(
253
+ "table",
254
+ {
255
+ className: (0, import_clsx.default)(`${prefixCls}-table`, classNames == null ? void 0 : classNames.table),
256
+ style: styles == null ? void 0 : styles.table
257
+ },
258
+ /* @__PURE__ */ import_react.default.createElement("tbody", null, renderRows())
259
+ ));
253
260
  }
254
261
  );
255
262
  Descriptions.displayName = "Descriptions";
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { DataAttributeProps } from '../utils/types';
3
- export type SemanticDOM = 'header' | 'title' | 'extra' | 'label' | 'content';
3
+ export type SemanticDOM = 'header' | 'title' | 'extra' | 'label' | 'content' | 'table';
4
4
  export interface DescriptionsItem {
5
5
  key?: React.Key;
6
6
  label?: React.ReactNode;
@@ -47,6 +47,7 @@ var size_default = () => {
47
47
  value,
48
48
  onChange: (val) => setValue(val),
49
49
  options,
50
+ size: "small",
50
51
  style: { width: 200 },
51
52
  placeholder: "Small Size"
52
53
  }
@@ -65,6 +66,7 @@ var size_default = () => {
65
66
  value,
66
67
  onChange: (val) => setValue(val),
67
68
  options,
69
+ size: "large",
68
70
  style: { width: 200 },
69
71
  placeholder: "Large Size"
70
72
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { SelectorProps } from '../Selector';
2
3
  import type { DataAttributeProps } from '../utils/types';
3
4
  export type Option = {
4
5
  /**
@@ -22,7 +23,7 @@ export type Option = {
22
23
  */
23
24
  [prop: string]: any;
24
25
  };
25
- export interface SelectProps extends DataAttributeProps {
26
+ export interface SelectProps extends DataAttributeProps, Pick<SelectorProps, 'size'> {
26
27
  /**
27
28
  * Custom class name prefix
28
29
  * */
@@ -45,6 +45,14 @@
45
45
  padding-right: 16px;
46
46
  }
47
47
 
48
+ &@{pls}-small {
49
+ height: var(--yee-selector-small-height);
50
+ }
51
+
52
+ &@{pls}-large {
53
+ height: var(--yee-selector-large-height);
54
+ }
55
+
48
56
  &:focus-within,
49
57
  &:focus {
50
58
  @{pls}-input-wrapper {
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: () => React.JSX.Element;
3
+ export default _default;
@@ -0,0 +1,54 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Table/demo/components-override.tsx
30
+ var components_override_exports = {};
31
+ __export(components_override_exports, {
32
+ default: () => components_override_default
33
+ });
34
+ module.exports = __toCommonJS(components_override_exports);
35
+ var import_yee_c = require("../..");
36
+ var import_react = __toESM(require("react"));
37
+ var CustomTbody = (props) => /* @__PURE__ */ import_react.default.createElement("tbody", { className: props.className, "data-custom-tbody": true }, props.children);
38
+ var CustomRow = ({ record, index, columns, rowKey }) => /* @__PURE__ */ import_react.default.createElement("tr", { "data-row-key": rowKey, style: { background: index % 2 === 0 ? "#f8fafc" : void 0 } }, /* @__PURE__ */ import_react.default.createElement("td", { style: { width: 40, textAlign: "center", color: "#2563eb", fontWeight: 700 } }, index + 1), columns.map((col) => /* @__PURE__ */ import_react.default.createElement("td", { key: String(col.key) }, record[col.dataIndex || ""])));
39
+ var components_override_default = () => {
40
+ const columns = [
41
+ { title: "Name", dataIndex: "name", key: "name" },
42
+ { title: "Age", dataIndex: "age", key: "age" },
43
+ { title: "Address", dataIndex: "address", key: "address" }
44
+ ];
45
+ const dataSource = [
46
+ { key: "1", name: "John Brown", age: 32, address: "New York No. 1 Lake Park" },
47
+ { key: "2", name: "Jim Green", age: 42, address: "London No. 1 Lake Park" },
48
+ { key: "3", name: "Joe Black", age: 32, address: "Sidney No. 1 Lake Park" }
49
+ ];
50
+ const components = {
51
+ body: { tbody: CustomTbody, row: CustomRow }
52
+ };
53
+ return /* @__PURE__ */ import_react.default.createElement(import_yee_c.Table, { columns, dataSource, components });
54
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: () => React.JSX.Element;
3
+ export default _default;
@@ -0,0 +1,129 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Table/demo/grouping.tsx
30
+ var grouping_exports = {};
31
+ __export(grouping_exports, {
32
+ default: () => grouping_default
33
+ });
34
+ module.exports = __toCommonJS(grouping_exports);
35
+ var import_yee_c = require("../..");
36
+ var import_react = __toESM(require("react"));
37
+ var grouping_default = () => {
38
+ const [selectedRowKeys, setSelectedRowKeys] = (0, import_react.useState)([]);
39
+ const columns = [
40
+ {
41
+ title: "Name",
42
+ dataIndex: "name",
43
+ key: "name",
44
+ fixed: "left",
45
+ width: 120,
46
+ sorter: true
47
+ },
48
+ {
49
+ title: "Info",
50
+ key: "info",
51
+ children: [
52
+ { title: "Age", dataIndex: "age", key: "age", width: 100, sorter: true },
53
+ {
54
+ title: "Address",
55
+ dataIndex: "address",
56
+ key: "address",
57
+ width: 200
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ title: "Company",
63
+ key: "company",
64
+ children: [
65
+ {
66
+ title: "Name",
67
+ dataIndex: "companyName",
68
+ key: "companyName",
69
+ width: 180
70
+ },
71
+ {
72
+ title: "Address",
73
+ dataIndex: "companyAddress",
74
+ key: "companyAddress",
75
+ width: 220
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ title: "Action",
81
+ key: "action",
82
+ fixed: "right",
83
+ width: 100,
84
+ render: (record) => /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => console.log(record) }, "Edit")
85
+ }
86
+ ];
87
+ const dataSource = [
88
+ {
89
+ key: "1",
90
+ name: "John Brown",
91
+ age: 32,
92
+ address: "New York No. 1 Lake Park",
93
+ companyName: "Acme Inc.",
94
+ companyAddress: "NY Office"
95
+ },
96
+ {
97
+ key: "2",
98
+ name: "Jim Green",
99
+ age: 42,
100
+ address: "London No. 1 Lake Park",
101
+ companyName: "Globex",
102
+ companyAddress: "London Office"
103
+ },
104
+ {
105
+ key: "3",
106
+ name: "Joe Black",
107
+ age: 28,
108
+ address: "Sidney No. 1 Lake Park",
109
+ companyName: "Initech",
110
+ companyAddress: "Sidney Office"
111
+ }
112
+ ];
113
+ const rowSelection = {
114
+ type: "checkbox",
115
+ selectedRowKeys,
116
+ onChange: (keys) => setSelectedRowKeys(keys)
117
+ };
118
+ return /* @__PURE__ */ import_react.default.createElement(
119
+ import_yee_c.Table,
120
+ {
121
+ columns,
122
+ dataSource,
123
+ rowKey: "key",
124
+ rowSelection,
125
+ bordered: true,
126
+ scroll: { x: 1200 }
127
+ }
128
+ );
129
+ };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ColumnProps, ExpandableType, RowSelectionType } from '../interface';
2
+ import type { ColumnProps, ExpandableType, RowSelectionType } from '../interface';
3
3
  export default function useColumns({ children, columns, rowSelection, expandable, }: {
4
4
  children?: React.ReactElement<ColumnProps> | React.ReactElement<ColumnProps>[];
5
5
  columns: ColumnProps[];
@@ -7,5 +7,5 @@ export default function useColumns({ children, columns, rowSelection, expandable
7
7
  expandable?: ExpandableType;
8
8
  }): {
9
9
  wrapedColumns: any;
10
- columns: ColumnProps[];
10
+ headerRows: any;
11
11
  };
@@ -1,8 +1,6 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
6
  var __getProtoOf = Object.getPrototypeOf;
@@ -20,7 +18,6 @@ var __spreadValues = (a, b) => {
20
18
  }
21
19
  return a;
22
20
  };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
21
  var __export = (target, all) => {
25
22
  for (var name in all)
26
23
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -53,6 +50,7 @@ var import_react = __toESM(require("react"));
53
50
  var import_useDeepCompareMemo = __toESM(require("../../hooks/useDeepCompareMemo"));
54
51
  var import_deepClone = __toESM(require("../../utils/deepClone"));
55
52
  var import_util = require("../util");
53
+ var import_header = require("../util/header");
56
54
  function useColumns({
57
55
  children,
58
56
  columns,
@@ -61,48 +59,28 @@ function useColumns({
61
59
  }) {
62
60
  const shouldRenderSelection = !!rowSelection;
63
61
  const shouldRenderExpand = !!expandable;
64
- const getColumnsFromChild = (children2) => {
65
- const columns2 = [];
66
- import_react.default.Children.forEach(children2, (child) => {
62
+ const getColumnsFromChild = (childs) => {
63
+ const cols = [];
64
+ import_react.default.Children.forEach(childs, (child) => {
67
65
  if (child) {
68
- columns2.push(__spreadValues({}, child.props));
66
+ cols.push(__spreadValues({}, child.props));
69
67
  }
70
68
  });
71
- return columns2.length ? columns2 : null;
69
+ return cols.length ? cols : null;
72
70
  };
73
71
  const childColumns = (0, import_react.useMemo)(() => {
74
72
  return children ? getColumnsFromChild(children) : null;
75
73
  }, [children]);
76
- const wrapColumns = (columns2) => {
77
- let result = (0, import_deepClone.default)(columns2);
78
- if (rowSelection) {
79
- const { index = 1 } = rowSelection;
80
- const loc = index - 1;
81
- result.splice(loc, 0, __spreadProps(__spreadValues({
82
- width: 50
83
- }, rowSelection), {
84
- key: "YEE_SELECTION_COL"
85
- }));
86
- }
87
- if (expandable) {
88
- const { index = 1, visible = true } = expandable;
89
- const loc = index ? index - 1 : rowSelection ? 1 : 0;
90
- if (visible !== false) {
91
- result.splice(loc, 0, __spreadProps(__spreadValues({
92
- width: 50
93
- }, expandable), {
94
- key: "YEE_EXPAND_COL"
95
- }));
96
- }
97
- }
98
- result = (0, import_util.handleColumns)(result);
99
- return result;
100
- };
101
- const mergedColumns = (0, import_useDeepCompareMemo.default)(() => {
102
- return wrapColumns(childColumns || columns || []);
74
+ const { wrapedColumns, headerRows } = (0, import_useDeepCompareMemo.default)(() => {
75
+ const base = (0, import_deepClone.default)(childColumns || columns || []) || [];
76
+ const tree = (0, import_header.injectSelectionExpand)(base, rowSelection, expandable);
77
+ const leaves = (0, import_header.flattenLeafColumns)(tree);
78
+ const wraped = (0, import_util.handleColumns)(leaves);
79
+ const rows = (0, import_header.parseHeaderRows)(tree);
80
+ return { wrapedColumns: wraped, headerRows: rows };
103
81
  }, [childColumns, columns, shouldRenderSelection, shouldRenderExpand]);
104
82
  return {
105
- wrapedColumns: mergedColumns,
106
- columns: childColumns || columns
83
+ wrapedColumns,
84
+ headerRows
107
85
  };
108
86
  }
@@ -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
- * Callback function for custom cell content
237
+ * Sub-columns for header grouping (multi-level header). Use cell `render` for custom cell content.
230
238
  */
231
- children?: (record: Record<string, any>, rowIndex: number) => React.ReactNode;
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?: Partial<Record<SemanticType, React.ReactNode>>;
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?: Partial<Record<SemanticType, React.ReactNode>>;
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, #fff);
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
 
@@ -149,7 +149,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
149
149
  const allKeys = (0, import_react.useMemo)(() => {
150
150
  return Array.isArray(dataSource) ? dataSource.map((item) => getRowKey(item)) : [];
151
151
  }, [dataSource, rowKey, getRowKey]);
152
- const { wrapedColumns, columns } = (0, import_useColumns.default)({
152
+ const { wrapedColumns, headerRows } = (0, import_useColumns.default)({
153
153
  children,
154
154
  columns: propColumns,
155
155
  expandable,
@@ -162,7 +162,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
162
162
  data: sortedData,
163
163
  sorters,
164
164
  onSort
165
- } = (0, import_useSorter.default)({ data: filteredData, columns });
165
+ } = (0, import_useSorter.default)({ data: filteredData, columns: wrapedColumns });
166
166
  const { pageData, current, pageSize, pagination } = (0, import_usePagination.default)({
167
167
  data: sortedData,
168
168
  pagination: propPagination,
@@ -185,7 +185,6 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
185
185
  const {
186
186
  selectedRowKeys,
187
187
  checkedAll,
188
- pageDataRowKeys,
189
188
  onCheckAll,
190
189
  onChange: onSelectionChange
191
190
  } = (0, import_useSelection.default)({ pageData, dataSource, getRowKey, rowSelection, allKeys });
@@ -237,7 +236,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
237
236
  prefixCls,
238
237
  header,
239
238
  download,
240
- columns,
239
+ columns: wrapedColumns,
241
240
  pageData,
242
241
  dataSource
243
242
  }
@@ -251,8 +250,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
251
250
  return /* @__PURE__ */ import_react.default.createElement(
252
251
  import_theader.default,
253
252
  __spreadProps(__spreadValues({}, ths), {
254
- columns: wrapedColumns,
255
- pageDataRowKeys,
253
+ headerRows,
256
254
  checkedAll,
257
255
  sorters,
258
256
  onSort,
@@ -297,7 +295,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
297
295
  {
298
296
  value: {
299
297
  prefixCls,
300
- columns,
298
+ columns: wrapedColumns,
301
299
  classNames,
302
300
  styles,
303
301
  components,
@@ -7,7 +7,6 @@ export interface BodyCellProps {
7
7
  fixedToLeft?: number;
8
8
  current: number;
9
9
  pageSize: number;
10
- children?: (record: Record<string, any>, index: number) => React.ReactNode;
11
10
  }
12
11
  declare const TableCell: React.FC<BodyCellProps>;
13
12
  export default TableCell;
@@ -66,7 +66,6 @@ var TableCell = (props) => {
66
66
  className,
67
67
  styles,
68
68
  classNames,
69
- children,
70
69
  onCell,
71
70
  render
72
71
  } = column;
@@ -75,9 +74,6 @@ var TableCell = (props) => {
75
74
  if (render) {
76
75
  return typeof render === "function" ? render(record, rowIndex) : render;
77
76
  }
78
- if (typeof children === "function") {
79
- return children(record, rowIndex);
80
- }
81
77
  return /* @__PURE__ */ React.createElement(
82
78
  "div",
83
79
  {
@@ -67,19 +67,36 @@ var import_table = require("../table");
67
67
  var import_lazy_row = __toESM(require("./lazy-row"));
68
68
  var import_row = __toESM(require("./row"));
69
69
  var TableBody = (props) => {
70
+ var _b, _c, _d;
70
71
  const _a = props, { columns, pageData, lazyLoad } = _a, rest = __objRest(_a, ["columns", "pageData", "lazyLoad"]);
71
- const { prefixCls } = import_react.default.useContext(import_table.TableCtx);
72
+ const { prefixCls, components, rowKey } = import_react.default.useContext(import_table.TableCtx);
72
73
  const { locale } = (0, import_locale.useLocale)();
73
74
  const { table: tableLocale } = locale;
74
75
  const empty = /* @__PURE__ */ import_react.default.createElement("tbody", { className: `${prefixCls}-tbody` }, /* @__PURE__ */ import_react.default.createElement("tr", { className: `${prefixCls}-no-record` }, /* @__PURE__ */ import_react.default.createElement("td", { colSpan: 999 }, tableLocale.emptyText)));
75
76
  const dataLength = pageData.length;
76
77
  if (dataLength === 0)
77
78
  return empty;
79
+ const BodyWrapper = (_c = (_b = components == null ? void 0 : components.body) == null ? void 0 : _b.tbody) != null ? _c : "tbody";
80
+ const RowRenderer = (_d = components == null ? void 0 : components.body) == null ? void 0 : _d.row;
81
+ const resolveRowKey = (record) => typeof rowKey === "function" ? rowKey(record) : record[rowKey];
78
82
  const getRenderRows = () => {
79
83
  if (lazyLoad) {
80
84
  return /* @__PURE__ */ import_react.default.createElement(import_lazy_row.default, __spreadProps(__spreadValues({}, rest), { pageData, columns }));
81
85
  }
82
86
  return pageData.map((record, index) => {
87
+ if (RowRenderer) {
88
+ const rk = resolveRowKey(record);
89
+ return /* @__PURE__ */ import_react.default.createElement(
90
+ RowRenderer,
91
+ {
92
+ key: rk != null ? rk : index,
93
+ record,
94
+ index,
95
+ columns,
96
+ rowKey: rk
97
+ }
98
+ );
99
+ }
83
100
  return /* @__PURE__ */ import_react.default.createElement(
84
101
  import_row.default,
85
102
  __spreadProps(__spreadValues({}, rest), {
@@ -91,7 +108,7 @@ var TableBody = (props) => {
91
108
  );
92
109
  });
93
110
  };
94
- const tbody = /* @__PURE__ */ import_react.default.createElement("tbody", { className: `${prefixCls}-tbody` }, getRenderRows());
111
+ const tbody = /* @__PURE__ */ import_react.default.createElement(BodyWrapper, { className: `${prefixCls}-tbody` }, getRenderRows());
95
112
  return tbody;
96
113
  };
97
114
  var tbody_default = TableBody;