es-grid-template 1.8.64 → 1.8.65

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 (125) hide show
  1. package/es/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
  2. package/es/grid-component/TempTable.js +2 -2
  3. package/es/grid-component/hooks/utils.d.ts +2 -8
  4. package/es/grid-component/hooks/utils.js +175 -144
  5. package/es/grid-component/index.d.ts +1 -1
  6. package/es/grid-component/index.js +0 -4
  7. package/es/grid-component/type.d.ts +7 -0
  8. package/es/table-component/type.d.ts +8 -0
  9. package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  10. package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.js +232 -0
  11. package/es/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
  12. package/es/table-virtuoso/ColumnsGroup/index.js +1 -0
  13. package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  14. package/es/table-virtuoso/InternalTable.js +413 -0
  15. package/es/table-virtuoso/body/TableBody.d.ts +14 -0
  16. package/es/table-virtuoso/body/TableBody.js +84 -0
  17. package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  18. package/es/table-virtuoso/body/TableBodyCell.js +466 -0
  19. package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  20. package/es/table-virtuoso/body/TableBodyRow.js +116 -0
  21. package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
  22. package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
  23. package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
  24. package/es/table-virtuoso/header/TableHeadCell.js +265 -0
  25. package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
  26. package/es/table-virtuoso/header/renderFilter.js +289 -0
  27. package/es/table-virtuoso/hook/constant.d.ts +73 -0
  28. package/es/table-virtuoso/hook/constant.js +240 -0
  29. package/es/table-virtuoso/hook/convert.d.ts +1 -0
  30. package/es/table-virtuoso/hook/convert.js +28 -0
  31. package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
  32. package/es/table-virtuoso/hook/useColumns.js +302 -0
  33. package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
  34. package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
  35. package/es/table-virtuoso/hook/utils.d.ts +159 -0
  36. package/es/table-virtuoso/hook/utils.js +2263 -0
  37. package/es/table-virtuoso/index.d.ts +2 -0
  38. package/es/table-virtuoso/index.js +2 -0
  39. package/es/table-virtuoso/style.d.ts +22 -0
  40. package/es/table-virtuoso/style.js +11 -0
  41. package/es/table-virtuoso/style.scss +1440 -0
  42. package/es/table-virtuoso/table/Grid.d.ts +37 -0
  43. package/es/table-virtuoso/table/Grid.js +302 -0
  44. package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
  45. package/es/table-virtuoso/table/TableContainer.js +305 -0
  46. package/es/table-virtuoso/table/TableWrapper.d.ts +20 -0
  47. package/es/table-virtuoso/table/TableWrapper.js +158 -0
  48. package/es/table-virtuoso/type.d.ts +0 -0
  49. package/es/table-virtuoso/type.js +785 -0
  50. package/es/table-virtuoso/useContext.d.ts +97 -0
  51. package/es/table-virtuoso/useContext.js +21 -0
  52. package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +4 -1
  53. package/lib/grid-component/TempTable.js +2 -2
  54. package/lib/grid-component/hooks/utils.d.ts +2 -8
  55. package/lib/grid-component/hooks/utils.js +176 -152
  56. package/lib/grid-component/index.d.ts +1 -1
  57. package/lib/grid-component/index.js +0 -3
  58. package/lib/grid-component/type.d.ts +7 -0
  59. package/lib/table-component/type.d.ts +8 -0
  60. package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  61. package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.js +243 -0
  62. package/lib/table-virtuoso/ColumnsGroup/index.d.ts +1 -0
  63. package/lib/table-virtuoso/ColumnsGroup/index.js +16 -0
  64. package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  65. package/lib/table-virtuoso/InternalTable.js +422 -0
  66. package/lib/table-virtuoso/body/TableBody.d.ts +14 -0
  67. package/lib/table-virtuoso/body/TableBody.js +95 -0
  68. package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  69. package/lib/table-virtuoso/body/TableBodyCell.js +473 -0
  70. package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  71. package/lib/table-virtuoso/body/TableBodyRow.js +124 -0
  72. package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
  73. package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
  74. package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
  75. package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
  76. package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
  77. package/lib/table-virtuoso/header/renderFilter.js +299 -0
  78. package/lib/table-virtuoso/hook/constant.d.ts +73 -0
  79. package/lib/table-virtuoso/hook/constant.js +247 -0
  80. package/lib/table-virtuoso/hook/convert.d.ts +1 -0
  81. package/lib/table-virtuoso/hook/convert.js +34 -0
  82. package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
  83. package/lib/table-virtuoso/hook/useColumns.js +315 -0
  84. package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
  85. package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
  86. package/lib/table-virtuoso/hook/utils.d.ts +159 -0
  87. package/lib/table-virtuoso/hook/utils.js +2389 -0
  88. package/lib/table-virtuoso/index.d.ts +2 -0
  89. package/lib/table-virtuoso/index.js +9 -0
  90. package/lib/table-virtuoso/style.d.ts +22 -0
  91. package/lib/table-virtuoso/style.js +18 -0
  92. package/lib/table-virtuoso/style.scss +1440 -0
  93. package/lib/table-virtuoso/table/Grid.d.ts +37 -0
  94. package/lib/table-virtuoso/table/Grid.js +311 -0
  95. package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
  96. package/lib/table-virtuoso/table/TableContainer.js +313 -0
  97. package/lib/table-virtuoso/table/TableWrapper.d.ts +20 -0
  98. package/lib/table-virtuoso/table/TableWrapper.js +164 -0
  99. package/lib/table-virtuoso/type.d.ts +0 -0
  100. package/lib/table-virtuoso/type.js +786 -0
  101. package/lib/table-virtuoso/useContext.d.ts +97 -0
  102. package/lib/table-virtuoso/useContext.js +27 -0
  103. package/package.json +2 -1
  104. package/es/grid-component/ConvertColumnTable.d.ts +0 -7
  105. package/es/grid-component/ConvertColumnTable.js +0 -144
  106. package/es/grid-component/InternalTable.js +0 -1170
  107. package/es/grid-component/table/Grid.d.ts +0 -23
  108. package/es/grid-component/table/Grid.js +0 -49
  109. package/es/grid-component/table/GridEdit.d.ts +0 -23
  110. package/es/grid-component/table/GridEdit.js +0 -2726
  111. package/es/grid-component/table/Group.d.ts +0 -21
  112. package/es/grid-component/table/Group.js +0 -195
  113. package/es/grid-component/table/InfiniteTable.d.ts +0 -23
  114. package/es/grid-component/table/InfiniteTable.js +0 -101
  115. package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
  116. package/lib/grid-component/ConvertColumnTable.js +0 -153
  117. package/lib/grid-component/InternalTable.js +0 -1178
  118. package/lib/grid-component/table/Grid.d.ts +0 -23
  119. package/lib/grid-component/table/Grid.js +0 -58
  120. package/lib/grid-component/table/GridEdit.d.ts +0 -23
  121. package/lib/grid-component/table/GridEdit.js +0 -2723
  122. package/lib/grid-component/table/Group.d.ts +0 -21
  123. package/lib/grid-component/table/Group.js +0 -204
  124. package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
  125. package/lib/grid-component/table/InfiniteTable.js +0 -109
@@ -0,0 +1,14 @@
1
+ import { type Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../table-component/type";
3
+ import React from "react";
4
+ interface TableBodyProps<T> {
5
+ table: Table<T>;
6
+ tableContainerRef: React.RefObject<HTMLDivElement>;
7
+ commandClick?: (args: CommandClick<T>) => void;
8
+ editAble?: boolean;
9
+ tableId: string;
10
+ showEmptyText?: boolean;
11
+ [key: string]: any;
12
+ }
13
+ declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, showEmptyText, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
14
+ export default TableBody;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _TableBodyRow = _interopRequireDefault(require("./TableBodyRow"));
10
+ var _reactVirtual = require("@tanstack/react-virtual");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _useContext = require("../useContext");
13
+ var _rcMasterUi = require("rc-master-ui");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ // import type { Virtualizer } from "@tanstack/react-virtual";
17
+
18
+ // import type { Dispatch, SetStateAction } from "react";
19
+
20
+ const TableBody = ({
21
+ columnVirtualizer,
22
+ table,
23
+ tableContainerRef,
24
+ virtualPaddingLeft,
25
+ virtualPaddingRight,
26
+ fixedLeftColumns,
27
+ fixedRightColumns,
28
+ tableId,
29
+ showEmptyText,
30
+ ...rest
31
+ }) => {
32
+ const {
33
+ rows
34
+ } = table.getRowModel();
35
+ const {
36
+ editingKey,
37
+ prefix,
38
+ locale
39
+ } = _react.default.useContext(_useContext.TableContext);
40
+
41
+ //dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
42
+ const rowVirtualizer = (0, _reactVirtual.useVirtualizer)({
43
+ count: rows.length,
44
+ estimateSize: () => 36,
45
+ //estimate row height for accurate scrollbar dragging
46
+ getScrollElement: () => tableContainerRef.current,
47
+ //measure dynamic row height, except in firefox because it measures table border height incorrectly
48
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
49
+ overscan: 1
50
+ });
51
+ const virtualRows = rowVirtualizer.getVirtualItems();
52
+ return /*#__PURE__*/_react.default.createElement("div", {
53
+ className: `${prefix}-grid-tbody`,
54
+ style: {
55
+ display: 'grid',
56
+ // height: `${rowVirtualizer.getTotalSize()}px`, //tells scrollbar how big the table is
57
+ height: showEmptyText && rows.length === 0 ? `140px` : `${rowVirtualizer.getTotalSize()}px`,
58
+ //tells scrollbar how big the table is
59
+ position: 'relative' //needed for absolute positioning of rows
60
+ }
61
+ }, showEmptyText && rows.length === 0 ? /*#__PURE__*/_react.default.createElement("tr", {
62
+ style: {
63
+ // transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
64
+ }
65
+ }, /*#__PURE__*/_react.default.createElement("td", {
66
+ // colSpan={30}
67
+ style: {
68
+ position: "sticky",
69
+ left: 0,
70
+ width: tableContainerRef.current?.clientWidth,
71
+ overflow: 'hidden'
72
+ }
73
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Empty, {
74
+ image: _rcMasterUi.Empty.PRESENTED_IMAGE_SIMPLE,
75
+ description: locale?.emptyText
76
+ })))) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null, virtualRows.map(virtualRow => {
77
+ const row = rows[virtualRow.index];
78
+ const isEditing = row.id === editingKey;
79
+ return /*#__PURE__*/_react.default.createElement(_TableBodyRow.default, (0, _extends2.default)({}, rest, {
80
+ table: table,
81
+ tableId: tableId,
82
+ key: row.id,
83
+ row: row,
84
+ columnVirtualizer: columnVirtualizer,
85
+ rowVirtualizer: rowVirtualizer,
86
+ virtualPaddingLeft: virtualPaddingLeft,
87
+ virtualPaddingRight: virtualPaddingRight,
88
+ virtualRow: virtualRow,
89
+ fixedLeftColumns: fixedLeftColumns,
90
+ fixedRightColumns: fixedRightColumns,
91
+ isEditing: isEditing
92
+ }));
93
+ })));
94
+ };
95
+ var _default = exports.default = TableBody;
@@ -0,0 +1,14 @@
1
+ import type { Cell, Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../table-component/type";
3
+ import React from "react";
4
+ import type { VirtualItem } from "@tanstack/react-virtual";
5
+ interface TableBodyCellProps<T> {
6
+ table: Table<T>;
7
+ tableId: string;
8
+ cell: Cell<T, unknown>;
9
+ commandClick?: (args: CommandClick<T>) => void;
10
+ virtualRow: VirtualItem;
11
+ [key: string]: any;
12
+ }
13
+ declare const TableBodyCell: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
14
+ export default TableBodyCell;
@@ -0,0 +1,473 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _reactTable = require("@tanstack/react-table");
9
+ var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
10
+ var _server = _interopRequireDefault(require("react-dom/server"));
11
+ var _utils = require("../hook/utils");
12
+ var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkbox"));
13
+ var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _useContext = require("../useContext");
16
+ var _useColumns = require("../hook/useColumns");
17
+ var _Command = _interopRequireDefault(require("../../table-component/components/command/Command"));
18
+ // import Command from "../components/command/Command";
19
+
20
+ const renderCellIndex = props => {
21
+ const {
22
+ cell,
23
+ pagination
24
+ } = props;
25
+ const parrents = cell.row.getParentRows();
26
+ if (parrents && parrents.length > 0) {
27
+ return /*#__PURE__*/_react.default.createElement("span", {
28
+ className: "ui-rc_cell-content"
29
+ }, parrents.map(pr => {
30
+ return `${pr.index + 1}.`;
31
+ }), cell.row.index + 1);
32
+ }
33
+ if (pagination && pagination.onChange) {
34
+ return /*#__PURE__*/_react.default.createElement("span", {
35
+ className: "ui-rc_cell-content"
36
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
37
+ }
38
+ return /*#__PURE__*/_react.default.createElement("span", {
39
+ className: "ui-rc_cell-content"
40
+ }, cell.row.index + 1);
41
+ };
42
+ const renderCommand = args => {
43
+ const {
44
+ cell,
45
+ commandClick,
46
+ id,
47
+ data
48
+ } = args;
49
+ const col = cell.column.columnDef.meta ?? {};
50
+ const record = cell.row.original;
51
+
52
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
53
+
54
+ const commands = col.commandItems ? col.commandItems.map(it => {
55
+ return {
56
+ ...it,
57
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
58
+ };
59
+ }) : [];
60
+ return /*#__PURE__*/_react.default.createElement("div", {
61
+ className: "ui-rc_cell-content"
62
+ }, /*#__PURE__*/_react.default.createElement(_space.default, null, commands.filter(it => it.visible !== false).map(item => {
63
+ return /*#__PURE__*/_react.default.createElement(_Command.default, {
64
+ id: id,
65
+ key: item.id,
66
+ item: item,
67
+ record: record,
68
+ onClick: () => {
69
+ commandClick?.({
70
+ id: item.id,
71
+ // rowId: getRowKey(record, index) as any,
72
+ rowId: record.rowId,
73
+ rowData: record,
74
+ index: cell.row.index,
75
+ rows: [...data]
76
+ });
77
+ }
78
+ });
79
+ })));
80
+ };
81
+ const renderSelection = args => {
82
+ const {
83
+ row
84
+ } = args.cell;
85
+ const {
86
+ cell,
87
+ expandIconColumnIndex,
88
+ isDataTree,
89
+ expanded,
90
+ setExpanded
91
+ } = args;
92
+ const {
93
+ selectionSettings,
94
+ setIsSelectionChange,
95
+ isSelectionChange
96
+ } = args;
97
+ const checked = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? row.getIsSelected() : row.getIsSelected() || row.getIsAllSubRowsSelected();
98
+ const indeterminate = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? false : row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' || row.getIsSomeSelected();
99
+ return /*#__PURE__*/_react.default.createElement("div", {
100
+ style: {}
101
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
102
+ className: "ui-rc-table-row-expand-trigger",
103
+ style: {
104
+ paddingLeft: `${cell.row.depth * 25}px`
105
+ }
106
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
107
+ // onClick: row.getToggleExpandedHandler(),
108
+ onClick: () => {
109
+ const keys = Object.keys(expanded);
110
+ // @ts-ignore
111
+ const tmp = {
112
+ ...expanded
113
+ };
114
+ if (keys.includes(cell.row.id)) {
115
+ delete tmp[cell.row.id];
116
+ setExpanded(tmp);
117
+ } else {
118
+ setExpanded(old => ({
119
+ ...old,
120
+ [cell.row.id]: true
121
+ }));
122
+ }
123
+ },
124
+ style: {
125
+ cursor: "pointer"
126
+ },
127
+ className: "ui-rc-table-row-expand"
128
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
129
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
130
+ }) : /*#__PURE__*/_react.default.createElement("span", {
131
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
132
+ })) : /*#__PURE__*/_react.default.createElement("span", {
133
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
134
+ }))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
135
+ checked: checked,
136
+ indeterminate: indeterminate,
137
+ onChange: e => {
138
+ (0, _useColumns.toggleRowSelection)({
139
+ e,
140
+ cell,
141
+ setIsSelectionChange,
142
+ isSelectionChange,
143
+ selectionSettings
144
+ });
145
+ },
146
+ disabled: !row.getCanSelect()
147
+ })));
148
+ };
149
+ const TableBodyCell = props => {
150
+ const {
151
+ cell,
152
+ commandClick,
153
+ // tableId,
154
+ table,
155
+ isEditing,
156
+ colSpan,
157
+ groupValue
158
+ } = props;
159
+ const {
160
+ id,
161
+ prefix,
162
+ focusedCell,
163
+ setFocusedCell,
164
+ // endCell,
165
+ // startCell,
166
+ originData,
167
+ expanded,
168
+ setExpanded,
169
+ expandable,
170
+ isDataTree,
171
+ setIsSelectionChange,
172
+ isSelectionChange,
173
+ selectionSettings,
174
+ wrapSettings,
175
+ pagination
176
+ // dataSource
177
+ } = _react.default.useContext(_useContext.TableContext);
178
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
179
+ const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
180
+ const record = cell.row.original;
181
+ const columnMeta = cell.column.columnDef.meta ?? {};
182
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
183
+
184
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
185
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
186
+ value: cell.getValue(),
187
+ record
188
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
189
+ const allRows = table.getRowModel().flatRows;
190
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
191
+ const colIndex = cell.column.getIndex();
192
+ const isPinned = cell.column.getIsPinned();
193
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
194
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
195
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
196
+
197
+ // const firstVisibleNormalColumn = table.getVisibleLeafColumns().filter(col => col.id !== 'selection' && col.id !== '#')[0];
198
+ // const firstVisibleNormalColumn = table.getVisibleLeafColumns().filter(col => col.id !== 'selection' && col.id !== '#')[0];
199
+
200
+ // const parrents = cell.row.getParentRows();
201
+
202
+ if (cell.column.id === "#") {
203
+ return /*#__PURE__*/_react.default.createElement("td", {
204
+ key: cell.id,
205
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
206
+ [`${prefix}-grid-cell-ellipsis`]: true,
207
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
208
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
209
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
210
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
211
+ }),
212
+ style: {
213
+ ...cellStyles,
214
+ // display: 'flex',
215
+ userSelect: 'none',
216
+ width: cell.column.getSize(),
217
+ minWidth: cell.column.getSize(),
218
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
219
+ },
220
+ onClick: e => {
221
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
222
+ (0, _useColumns.toggleRowSelection)({
223
+ e,
224
+ cell,
225
+ setIsSelectionChange,
226
+ isSelectionChange,
227
+ selectionSettings
228
+ });
229
+ }
230
+ }
231
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
232
+ className: "ui-rc-table-row-expand-trigger",
233
+ style: {
234
+ paddingLeft: `${cell.row.depth * 25}px`
235
+ }
236
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
237
+ // onClick: cell.row.getToggleExpandedHandler(),
238
+ onClick: () => {
239
+ const keys = Object.keys(expanded);
240
+ // @ts-ignore
241
+ const tmp = {
242
+ ...expanded
243
+ };
244
+ if (keys.includes(cell.row.id)) {
245
+ delete tmp[cell.row.id];
246
+ setExpanded(tmp);
247
+ } else {
248
+ setExpanded(old => ({
249
+ ...old,
250
+ [cell.row.id]: true
251
+ }));
252
+ }
253
+ },
254
+ style: {
255
+ cursor: "pointer"
256
+ },
257
+ className: "ui-rc-table-row-expand"
258
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
259
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
260
+ }) : /*#__PURE__*/_react.default.createElement("span", {
261
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
262
+ })) : /*#__PURE__*/_react.default.createElement("span", {
263
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
264
+ }))), renderCellIndex({
265
+ cell,
266
+ pagination
267
+ }));
268
+ }
269
+ if (cell.column.id === "command") {
270
+ return /*#__PURE__*/_react.default.createElement("td", {
271
+ key: cell.id,
272
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
273
+ [`${prefix}-grid-cell-ellipsis`]: true,
274
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
275
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
276
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
277
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
278
+ }),
279
+ style: {
280
+ ...cellStyles,
281
+ // display: 'flex',
282
+ width: cell.column.getSize(),
283
+ minWidth: cell.column.getSize(),
284
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
285
+ }
286
+ }, renderCommand({
287
+ cell,
288
+ commandClick,
289
+ id,
290
+ data: originData
291
+ }));
292
+ }
293
+ if (cell.column.id === "selection_column") {
294
+ return /*#__PURE__*/_react.default.createElement("td", {
295
+ key: cell.id,
296
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
297
+ [`${prefix}-grid-cell-ellipsis`]: true,
298
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
299
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
300
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
301
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
302
+ }),
303
+ style: {
304
+ ...cellStyles,
305
+ // display: 'flex',
306
+ minHeight: 36,
307
+ width: cell.column.getSize(),
308
+ minWidth: cell.column.getSize(),
309
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
310
+ }
311
+ }, /*#__PURE__*/_react.default.createElement("div", {
312
+ className: (0, _classnames.default)('ui-rc_cell-content', {})
313
+ }, cell.column.id === "selection_column" && renderSelection({
314
+ cell,
315
+ table,
316
+ selectionSettings,
317
+ setIsSelectionChange,
318
+ expanded,
319
+ isDataTree,
320
+ setExpanded,
321
+ expandIconColumnIndex,
322
+ isSelectionChange
323
+ })));
324
+ }
325
+ return /*#__PURE__*/_react.default.createElement("td", {
326
+ key: cell.id,
327
+ colSpan: colSpan,
328
+ ref: el => {
329
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
330
+ el?.focus();
331
+ }
332
+ },
333
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
334
+ "data-col-index": colIndex,
335
+ "data-row-index": rowNumber,
336
+ "data-col-key": cell.column.id
337
+ // data-row-key={cell.row.id}
338
+ ,
339
+ "data-tooltip-id": `${id}-tooltip-content`,
340
+ "data-tooltip-html": _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tooltipContent))
341
+ // data-tooltip-delay-show={500}
342
+ ,
343
+
344
+ className: (0, _classnames.default)(`${prefix}-grid-cell`, {
345
+ // [`${prefix}-grid-cell-ellipsis`]: true,
346
+
347
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
348
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
349
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
350
+
351
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
352
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
353
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
354
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
355
+ }),
356
+ style: {
357
+ ...cellStyles,
358
+ // display: 'flex',
359
+ width: cell.column.getSize(),
360
+ minWidth: cell.column.getSize(),
361
+ minHeight: 36,
362
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
363
+ },
364
+ onMouseEnter: e => {
365
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
366
+ setIsOpenTooltip(true);
367
+ }
368
+ },
369
+ onKeyDown: e => {
370
+ const flatRows = table.getRowModel().flatRows;
371
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
372
+ const nextIndex = cell.row.index + 1;
373
+ // const nextIndex = rowNumber + 1
374
+
375
+ const nextId = flatRows[nextIndex].id;
376
+ setFocusedCell?.({
377
+ colId: cell.column.id,
378
+ rowId: nextId
379
+ });
380
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
381
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
382
+ if (cellFocus) {
383
+ cellFocus.focus();
384
+ }
385
+ }
386
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
387
+ const prevIndex = cell.row.index - 1;
388
+ const nextId = flatRows[prevIndex].id;
389
+ setFocusedCell?.({
390
+ colId: cell.column.id,
391
+ rowId: nextId
392
+ });
393
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
394
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
395
+ if (cellFocus) {
396
+ cellFocus.focus();
397
+ }
398
+ }
399
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
400
+ (0, _useColumns.toggleRowSelection)({
401
+ e,
402
+ cell,
403
+ setIsSelectionChange,
404
+ isSelectionChange,
405
+ selectionSettings
406
+ });
407
+ cell.row.getToggleSelectedHandler()(e);
408
+ }
409
+ },
410
+ onClick: e => {
411
+ const selection = window.getSelection();
412
+ const text = selection ? selection.toString() : "";
413
+ if (text.length > 0 || enableClick === false) {} else {
414
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
415
+ (0, _useColumns.toggleRowSelection)({
416
+ e,
417
+ cell,
418
+ setIsSelectionChange,
419
+ isSelectionChange,
420
+ selectionSettings
421
+ });
422
+ setFocusedCell?.({
423
+ colId: cell.column.id,
424
+ rowId: cell.row.id
425
+ });
426
+ }
427
+ }
428
+ }
429
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree ? /*#__PURE__*/_react.default.createElement("div", {
430
+ className: (0, _classnames.default)('ui-rc_cell-content', {})
431
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
432
+ className: "ui-rc-table-row-expand-trigger",
433
+ style: {
434
+ paddingLeft: `${cell.row.depth * 25}px`
435
+ }
436
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
437
+ // onClick: cell.row.getToggleExpandedHandler(),
438
+
439
+ // onClick: (e) => {
440
+ // e.stopPropagation()
441
+ // cell.row.toggleExpanded()
442
+ // },
443
+
444
+ onClick: e => {
445
+ e.stopPropagation();
446
+ const keys = Object.keys(expanded);
447
+ // @ts-ignore
448
+ const tmp = {
449
+ ...expanded
450
+ };
451
+ if (keys.includes(cell.row.id)) {
452
+ delete tmp[cell.row.id];
453
+ setExpanded(tmp);
454
+ } else {
455
+ setExpanded(old => ({
456
+ ...old,
457
+ [cell.row.id]: true
458
+ }));
459
+ }
460
+ },
461
+ style: {
462
+ cursor: "pointer"
463
+ },
464
+ className: "ui-rc-table-row-expand"
465
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
466
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
467
+ }) : /*#__PURE__*/_react.default.createElement("span", {
468
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
469
+ })) : /*#__PURE__*/_react.default.createElement("span", {
470
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
471
+ }))), groupValue ? groupValue : (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, groupValue ? groupValue : (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())));
472
+ };
473
+ var _default = exports.default = TableBodyCell;
@@ -0,0 +1,13 @@
1
+ import { type Row, type Table } from "@tanstack/react-table";
2
+ import type { CommandClick } from "../../table-component/type";
3
+ import React from "react";
4
+ interface TableBodyRowProps<T> {
5
+ tableId: string;
6
+ table: Table<T>;
7
+ row: Row<T>;
8
+ commandClick?: (args: CommandClick<T>) => void;
9
+ editAble?: boolean;
10
+ [key: string]: any;
11
+ }
12
+ declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, virtualRow, commandClick, contextMenuItems, onContextMenu, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
13
+ export default TableBodyRow;