es-grid-template 1.8.64 → 1.8.66

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 (222) hide show
  1. package/es/grid-component/TempTable.d.ts +2 -2
  2. package/es/grid-component/TempTable.js +5 -5
  3. package/es/grid-component/hooks/index.js +0 -1
  4. package/es/grid-component/hooks/useLazyKVMap.d.ts +1 -1
  5. package/es/grid-component/hooks/useLazyKVMap.js +0 -4
  6. package/es/grid-component/hooks/utils.d.ts +1 -8
  7. package/es/grid-component/hooks/utils.js +176 -144
  8. package/es/grid-component/index.d.ts +1 -1
  9. package/es/grid-component/index.js +0 -4
  10. package/es/grid-component/styles.scss +1394 -1394
  11. package/es/grid-component/type.d.ts +0 -407
  12. package/es/grid-component/type.js +490 -1
  13. package/es/table-component/type.d.ts +10 -0
  14. package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
  15. package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  16. package/es/table-virtuoso/InternalTable.js +391 -0
  17. package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  18. package/es/table-virtuoso/body/TableBodyCell.js +457 -0
  19. package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  20. package/es/table-virtuoso/body/TableBodyRow.js +112 -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 +12 -0
  41. package/es/table-virtuoso/style.scss +1441 -0
  42. package/es/table-virtuoso/table/Grid.d.ts +37 -0
  43. package/es/table-virtuoso/table/Grid.js +298 -0
  44. package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
  45. package/es/table-virtuoso/table/TableContainer.js +292 -0
  46. package/es/table-virtuoso/table/TableWrapper.d.ts +22 -0
  47. package/es/table-virtuoso/table/TableWrapper.js +161 -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/TempTable.d.ts +2 -2
  53. package/lib/grid-component/TempTable.js +5 -7
  54. package/lib/grid-component/hooks/useLazyKVMap.d.ts +1 -1
  55. package/lib/grid-component/hooks/useLazyKVMap.js +0 -3
  56. package/lib/grid-component/hooks/utils.d.ts +1 -8
  57. package/lib/grid-component/hooks/utils.js +179 -152
  58. package/lib/grid-component/index.d.ts +1 -1
  59. package/lib/grid-component/index.js +0 -3
  60. package/lib/grid-component/styles.scss +1394 -1394
  61. package/lib/grid-component/type.d.ts +0 -407
  62. package/lib/grid-component/type.js +490 -4
  63. package/lib/table-component/type.d.ts +10 -0
  64. package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
  65. package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
  66. package/lib/table-virtuoso/InternalTable.js +400 -0
  67. package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
  68. package/lib/table-virtuoso/body/TableBodyCell.js +464 -0
  69. package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
  70. package/lib/table-virtuoso/body/TableBodyRow.js +119 -0
  71. package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
  72. package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
  73. package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
  74. package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
  75. package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
  76. package/lib/table-virtuoso/header/renderFilter.js +299 -0
  77. package/lib/table-virtuoso/hook/constant.d.ts +73 -0
  78. package/lib/table-virtuoso/hook/constant.js +247 -0
  79. package/lib/table-virtuoso/hook/convert.d.ts +1 -0
  80. package/lib/table-virtuoso/hook/convert.js +34 -0
  81. package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
  82. package/lib/table-virtuoso/hook/useColumns.js +315 -0
  83. package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
  84. package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
  85. package/lib/table-virtuoso/hook/utils.d.ts +159 -0
  86. package/lib/table-virtuoso/hook/utils.js +2389 -0
  87. package/lib/table-virtuoso/index.d.ts +2 -0
  88. package/lib/table-virtuoso/index.js +9 -0
  89. package/lib/table-virtuoso/style.d.ts +22 -0
  90. package/lib/table-virtuoso/style.js +19 -0
  91. package/lib/table-virtuoso/style.scss +1441 -0
  92. package/lib/table-virtuoso/table/Grid.d.ts +37 -0
  93. package/lib/table-virtuoso/table/Grid.js +307 -0
  94. package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
  95. package/lib/table-virtuoso/table/TableContainer.js +300 -0
  96. package/lib/table-virtuoso/table/TableWrapper.d.ts +22 -0
  97. package/lib/table-virtuoso/table/TableWrapper.js +166 -0
  98. package/lib/table-virtuoso/type.d.ts +0 -0
  99. package/lib/table-virtuoso/type.js +786 -0
  100. package/lib/table-virtuoso/useContext.d.ts +97 -0
  101. package/lib/table-virtuoso/useContext.js +27 -0
  102. package/package.json +2 -1
  103. package/es/grid-component/AdvanceFilter.d.ts +0 -14
  104. package/es/grid-component/AdvanceFilter.js +0 -454
  105. package/es/grid-component/CheckboxFilter.d.ts +0 -20
  106. package/es/grid-component/CheckboxFilter.js +0 -244
  107. package/es/grid-component/CheckboxFilter2.d.ts +0 -20
  108. package/es/grid-component/CheckboxFilter2.js +0 -244
  109. package/es/grid-component/ColumnsChoose.d.ts +0 -10
  110. package/es/grid-component/ColumnsChoose.js +0 -230
  111. package/es/grid-component/Command.d.ts +0 -8
  112. package/es/grid-component/Command.js +0 -80
  113. package/es/grid-component/ContextMenu.d.ts +0 -20
  114. package/es/grid-component/ContextMenu.js +0 -130
  115. package/es/grid-component/ConvertColumnTable.d.ts +0 -7
  116. package/es/grid-component/ConvertColumnTable.js +0 -144
  117. package/es/grid-component/EditForm/EditForm.d.ts +0 -27
  118. package/es/grid-component/EditForm/EditForm.js +0 -394
  119. package/es/grid-component/EditForm/index.d.ts +0 -1
  120. package/es/grid-component/EditForm/index.js +0 -1
  121. package/es/grid-component/EditableCell.d.ts +0 -20
  122. package/es/grid-component/EditableCell.js +0 -1030
  123. package/es/grid-component/FilterSearch.d.ts +0 -12
  124. package/es/grid-component/FilterSearch.js +0 -33
  125. package/es/grid-component/GridStyle.d.ts +0 -8
  126. package/es/grid-component/GridStyle.js +0 -5
  127. package/es/grid-component/InternalTable.js +0 -1170
  128. package/es/grid-component/TableGrid.d.ts +0 -21
  129. package/es/grid-component/TableGrid.js +0 -493
  130. package/es/grid-component/async-select/index.d.ts +0 -11
  131. package/es/grid-component/async-select/index.js +0 -38
  132. package/es/grid-component/async-table-select/index.d.ts +0 -11
  133. package/es/grid-component/async-table-select/index.js +0 -40
  134. package/es/grid-component/checkbox-control/index.d.ts +0 -13
  135. package/es/grid-component/checkbox-control/index.js +0 -40
  136. package/es/grid-component/hooks/columns/index.d.ts +0 -10
  137. package/es/grid-component/hooks/columns/index.js +0 -503
  138. package/es/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
  139. package/es/grid-component/hooks/content/ControlCheckbox.js +0 -87
  140. package/es/grid-component/hooks/content/HeaderContent.d.ts +0 -14
  141. package/es/grid-component/hooks/content/HeaderContent.js +0 -44
  142. package/es/grid-component/hooks/content/TooltipContent.d.ts +0 -13
  143. package/es/grid-component/hooks/content/TooltipContent.js +0 -74
  144. package/es/grid-component/hooks/useColumns.d.ts +0 -19
  145. package/es/grid-component/hooks/useColumns.js +0 -317
  146. package/es/grid-component/number/index.d.ts +0 -10
  147. package/es/grid-component/number/index.js +0 -39
  148. package/es/grid-component/number-range/index.d.ts +0 -11
  149. package/es/grid-component/number-range/index.js +0 -63
  150. package/es/grid-component/table/Grid.d.ts +0 -23
  151. package/es/grid-component/table/Grid.js +0 -49
  152. package/es/grid-component/table/GridEdit.d.ts +0 -23
  153. package/es/grid-component/table/GridEdit.js +0 -2726
  154. package/es/grid-component/table/Group.d.ts +0 -21
  155. package/es/grid-component/table/Group.js +0 -195
  156. package/es/grid-component/table/InfiniteTable.d.ts +0 -23
  157. package/es/grid-component/table/InfiniteTable.js +0 -101
  158. package/es/grid-component/useContext.d.ts +0 -34
  159. package/es/grid-component/useContext.js +0 -8
  160. package/lib/grid-component/AdvanceFilter.d.ts +0 -14
  161. package/lib/grid-component/AdvanceFilter.js +0 -463
  162. package/lib/grid-component/CheckboxFilter.d.ts +0 -20
  163. package/lib/grid-component/CheckboxFilter.js +0 -253
  164. package/lib/grid-component/CheckboxFilter2.d.ts +0 -20
  165. package/lib/grid-component/CheckboxFilter2.js +0 -253
  166. package/lib/grid-component/ColumnsChoose.d.ts +0 -10
  167. package/lib/grid-component/ColumnsChoose.js +0 -240
  168. package/lib/grid-component/Command.d.ts +0 -8
  169. package/lib/grid-component/Command.js +0 -88
  170. package/lib/grid-component/ContextMenu.d.ts +0 -20
  171. package/lib/grid-component/ContextMenu.js +0 -140
  172. package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
  173. package/lib/grid-component/ConvertColumnTable.js +0 -153
  174. package/lib/grid-component/EditForm/EditForm.d.ts +0 -27
  175. package/lib/grid-component/EditForm/EditForm.js +0 -404
  176. package/lib/grid-component/EditForm/index.d.ts +0 -1
  177. package/lib/grid-component/EditForm/index.js +0 -16
  178. package/lib/grid-component/EditableCell.d.ts +0 -20
  179. package/lib/grid-component/EditableCell.js +0 -1032
  180. package/lib/grid-component/FilterSearch.d.ts +0 -12
  181. package/lib/grid-component/FilterSearch.js +0 -42
  182. package/lib/grid-component/GridStyle.d.ts +0 -8
  183. package/lib/grid-component/GridStyle.js +0 -12
  184. package/lib/grid-component/InternalTable.js +0 -1178
  185. package/lib/grid-component/TableGrid.d.ts +0 -21
  186. package/lib/grid-component/TableGrid.js +0 -493
  187. package/lib/grid-component/async-select/index.d.ts +0 -11
  188. package/lib/grid-component/async-select/index.js +0 -47
  189. package/lib/grid-component/async-table-select/index.d.ts +0 -11
  190. package/lib/grid-component/async-table-select/index.js +0 -49
  191. package/lib/grid-component/checkbox-control/index.d.ts +0 -13
  192. package/lib/grid-component/checkbox-control/index.js +0 -48
  193. package/lib/grid-component/hooks/columns/index.d.ts +0 -10
  194. package/lib/grid-component/hooks/columns/index.js +0 -518
  195. package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
  196. package/lib/grid-component/hooks/content/ControlCheckbox.js +0 -95
  197. package/lib/grid-component/hooks/content/HeaderContent.d.ts +0 -14
  198. package/lib/grid-component/hooks/content/HeaderContent.js +0 -53
  199. package/lib/grid-component/hooks/content/TooltipContent.d.ts +0 -13
  200. package/lib/grid-component/hooks/content/TooltipContent.js +0 -81
  201. package/lib/grid-component/hooks/useColumns.d.ts +0 -19
  202. package/lib/grid-component/hooks/useColumns.js +0 -328
  203. package/lib/grid-component/number/index.d.ts +0 -10
  204. package/lib/grid-component/number/index.js +0 -47
  205. package/lib/grid-component/number-range/index.d.ts +0 -11
  206. package/lib/grid-component/number-range/index.js +0 -71
  207. package/lib/grid-component/table/Grid.d.ts +0 -23
  208. package/lib/grid-component/table/Grid.js +0 -58
  209. package/lib/grid-component/table/GridEdit.d.ts +0 -23
  210. package/lib/grid-component/table/GridEdit.js +0 -2723
  211. package/lib/grid-component/table/Group.d.ts +0 -21
  212. package/lib/grid-component/table/Group.js +0 -204
  213. package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
  214. package/lib/grid-component/table/InfiniteTable.js +0 -109
  215. package/lib/grid-component/useContext.d.ts +0 -34
  216. package/lib/grid-component/useContext.js +0 -13
  217. /package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
  218. /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
  219. /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
  220. /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
  221. /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
  222. /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
@@ -0,0 +1,457 @@
1
+ import { flexRender } from "@tanstack/react-table";
2
+ import Space from "rc-master-ui/es/space";
3
+ import ReactDOMServer from 'react-dom/server';
4
+ import { getCommonPinningStyles } from "../hook/utils";
5
+ import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
6
+ import classNames from "classnames";
7
+ import React from "react";
8
+ import { TableContext } from "../useContext";
9
+ import { toggleRowSelection } from "../hook/useColumns";
10
+ import Command from "../../table-component/components/command/Command";
11
+ const renderCellIndex = props => {
12
+ const {
13
+ cell,
14
+ pagination
15
+ } = props;
16
+ const parrents = cell.row.getParentRows();
17
+ if (parrents && parrents.length > 0) {
18
+ return /*#__PURE__*/React.createElement("span", {
19
+ className: "ui-rc_cell-content"
20
+ }, parrents.map(pr => {
21
+ return `${pr.index + 1}.`;
22
+ }), cell.row.index + 1);
23
+ }
24
+ if (pagination && pagination.onChange) {
25
+ return /*#__PURE__*/React.createElement("span", {
26
+ className: "ui-rc_cell-content"
27
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
28
+ }
29
+ return /*#__PURE__*/React.createElement("span", {
30
+ className: "ui-rc_cell-content"
31
+ }, cell.row.index + 1);
32
+ };
33
+ const renderCommand = args => {
34
+ const {
35
+ cell,
36
+ commandClick,
37
+ id,
38
+ data
39
+ } = args;
40
+ const col = cell.column.columnDef.meta ?? {};
41
+ const record = cell.row.original;
42
+
43
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
44
+
45
+ const commands = col.commandItems ? col.commandItems.map(it => {
46
+ return {
47
+ ...it,
48
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
49
+ };
50
+ }) : [];
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ className: "ui-rc_cell-content"
53
+ }, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
54
+ return /*#__PURE__*/React.createElement(Command, {
55
+ id: id,
56
+ key: item.id,
57
+ item: item,
58
+ record: record,
59
+ onClick: () => {
60
+ commandClick?.({
61
+ id: item.id,
62
+ rowId: record.rowId,
63
+ rowData: record,
64
+ index: cell.row.index,
65
+ rows: [...data]
66
+ });
67
+ }
68
+ });
69
+ })));
70
+ };
71
+ const renderSelection = args => {
72
+ const {
73
+ row
74
+ } = args.cell;
75
+ const {
76
+ cell,
77
+ expandIconColumnIndex,
78
+ isDataTree,
79
+ expanded,
80
+ setExpanded
81
+ } = args;
82
+ const {
83
+ selectionSettings,
84
+ setIsSelectionChange,
85
+ isSelectionChange
86
+ } = args;
87
+ const checked = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? row.getIsSelected() : row.getIsSelected() || row.getIsAllSubRowsSelected();
88
+ const indeterminate = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? false : row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' || row.getIsSomeSelected();
89
+ return /*#__PURE__*/React.createElement("div", {
90
+ style: {}
91
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
92
+ className: "ui-rc-table-row-expand-trigger",
93
+ style: {
94
+ paddingLeft: `${cell.row.depth * 25}px`
95
+ }
96
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
97
+ // onClick: row.getToggleExpandedHandler(),
98
+ onClick: () => {
99
+ const keys = Object.keys(expanded);
100
+ // @ts-ignore
101
+ const tmp = {
102
+ ...expanded
103
+ };
104
+ if (keys.includes(cell.row.id)) {
105
+ delete tmp[cell.row.id];
106
+ setExpanded(tmp);
107
+ } else {
108
+ setExpanded(old => ({
109
+ ...old,
110
+ [cell.row.id]: true
111
+ }));
112
+ }
113
+ },
114
+ style: {
115
+ cursor: "pointer"
116
+ },
117
+ className: "ui-rc-table-row-expand"
118
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
119
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
120
+ }) : /*#__PURE__*/React.createElement("span", {
121
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
122
+ })) : /*#__PURE__*/React.createElement("span", {
123
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
124
+ }))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
125
+ checked: checked,
126
+ indeterminate: indeterminate,
127
+ onChange: e => {
128
+ toggleRowSelection({
129
+ e,
130
+ cell,
131
+ setIsSelectionChange,
132
+ isSelectionChange,
133
+ selectionSettings
134
+ });
135
+ },
136
+ disabled: !row.getCanSelect()
137
+ })));
138
+ };
139
+ const TableBodyCell = props => {
140
+ const {
141
+ cell,
142
+ commandClick,
143
+ // tableId,
144
+ table,
145
+ isEditing,
146
+ colSpan,
147
+ groupValue
148
+ } = props;
149
+ const {
150
+ id,
151
+ prefix,
152
+ focusedCell,
153
+ setFocusedCell,
154
+ // endCell,
155
+ // startCell,
156
+ originData,
157
+ expanded,
158
+ setExpanded,
159
+ expandable,
160
+ isDataTree,
161
+ setIsSelectionChange,
162
+ isSelectionChange,
163
+ selectionSettings,
164
+ wrapSettings,
165
+ pagination
166
+ // dataSource
167
+ } = React.useContext(TableContext);
168
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
169
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
170
+ const record = cell.row.original;
171
+ const columnMeta = cell.column.columnDef.meta ?? {};
172
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
173
+
174
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
175
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
176
+ value: cell.getValue(),
177
+ record
178
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
179
+ const allRows = table.getRowModel().flatRows;
180
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
181
+ const colIndex = cell.column.getIndex();
182
+ const isPinned = cell.column.getIsPinned();
183
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
184
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
185
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
186
+ if (cell.column.id === "#") {
187
+ return /*#__PURE__*/React.createElement("td", {
188
+ key: cell.id,
189
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-index`, {
190
+ [`${prefix}-grid-cell-ellipsis`]: true,
191
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
192
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
193
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
194
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
195
+ }),
196
+ style: {
197
+ ...cellStyles,
198
+ // display: 'flex',
199
+ userSelect: 'none',
200
+ width: cell.column.getSize(),
201
+ minWidth: cell.column.getSize(),
202
+ ...getCommonPinningStyles(cell.column)
203
+ },
204
+ onClick: e => {
205
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
206
+ toggleRowSelection({
207
+ e,
208
+ cell,
209
+ setIsSelectionChange,
210
+ isSelectionChange,
211
+ selectionSettings
212
+ });
213
+ }
214
+ }
215
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
216
+ className: "ui-rc-table-row-expand-trigger",
217
+ style: {
218
+ paddingLeft: `${cell.row.depth * 25}px`
219
+ }
220
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
221
+ // onClick: cell.row.getToggleExpandedHandler(),
222
+ onClick: () => {
223
+ const keys = Object.keys(expanded);
224
+ // @ts-ignore
225
+ const tmp = {
226
+ ...expanded
227
+ };
228
+ if (keys.includes(cell.row.id)) {
229
+ delete tmp[cell.row.id];
230
+ setExpanded(tmp);
231
+ } else {
232
+ setExpanded(old => ({
233
+ ...old,
234
+ [cell.row.id]: true
235
+ }));
236
+ }
237
+ },
238
+ style: {
239
+ cursor: "pointer"
240
+ },
241
+ className: "ui-rc-table-row-expand"
242
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
243
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
244
+ }) : /*#__PURE__*/React.createElement("span", {
245
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
246
+ })) : /*#__PURE__*/React.createElement("span", {
247
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
248
+ }))), renderCellIndex({
249
+ cell,
250
+ pagination
251
+ }));
252
+ }
253
+ if (cell.column.id === "command") {
254
+ return /*#__PURE__*/React.createElement("td", {
255
+ key: cell.id,
256
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
257
+ [`${prefix}-grid-cell-ellipsis`]: true,
258
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
259
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
260
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
261
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
262
+ }),
263
+ style: {
264
+ ...cellStyles,
265
+ // display: 'flex',
266
+ width: cell.column.getSize(),
267
+ minWidth: cell.column.getSize(),
268
+ ...getCommonPinningStyles(cell.column)
269
+ }
270
+ }, renderCommand({
271
+ cell,
272
+ commandClick,
273
+ id,
274
+ data: originData
275
+ }));
276
+ }
277
+ if (cell.column.id === "selection_column") {
278
+ return /*#__PURE__*/React.createElement("td", {
279
+ key: cell.id,
280
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
281
+ [`${prefix}-grid-cell-ellipsis`]: true,
282
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
283
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
284
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
285
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
286
+ }),
287
+ style: {
288
+ ...cellStyles,
289
+ // display: 'flex',
290
+ minHeight: 36,
291
+ width: cell.column.getSize(),
292
+ minWidth: cell.column.getSize(),
293
+ ...getCommonPinningStyles(cell.column)
294
+ }
295
+ }, /*#__PURE__*/React.createElement("div", {
296
+ className: classNames('ui-rc_cell-content', {})
297
+ }, cell.column.id === "selection_column" && renderSelection({
298
+ cell,
299
+ table,
300
+ selectionSettings,
301
+ setIsSelectionChange,
302
+ expanded,
303
+ isDataTree,
304
+ setExpanded,
305
+ expandIconColumnIndex,
306
+ isSelectionChange
307
+ })));
308
+ }
309
+ return /*#__PURE__*/React.createElement("td", {
310
+ key: cell.id,
311
+ colSpan: colSpan,
312
+ ref: el => {
313
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
314
+ el?.focus();
315
+ }
316
+ },
317
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
318
+ "data-col-index": colIndex,
319
+ "data-row-index": rowNumber,
320
+ "data-col-key": cell.column.id
321
+ // data-row-key={cell.row.id}
322
+ ,
323
+ "data-tooltip-id": `${id}-tooltip-content`,
324
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
325
+ // data-tooltip-delay-show={500}
326
+ ,
327
+
328
+ className: classNames(`${prefix}-grid-cell`, {
329
+ // [`${prefix}-grid-cell-ellipsis`]: true,
330
+
331
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
332
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
333
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
334
+
335
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
336
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
337
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
338
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
339
+ }),
340
+ style: {
341
+ ...cellStyles,
342
+ // display: 'flex',
343
+ width: cell.column.getSize(),
344
+ minWidth: cell.column.getSize(),
345
+ minHeight: 36,
346
+ ...getCommonPinningStyles(cell.column)
347
+ },
348
+ onMouseEnter: e => {
349
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
350
+ setIsOpenTooltip(true);
351
+ }
352
+ },
353
+ onKeyDown: e => {
354
+ const flatRows = table.getRowModel().flatRows;
355
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
356
+ const nextIndex = cell.row.index + 1;
357
+ // const nextIndex = rowNumber + 1
358
+
359
+ const nextId = flatRows[nextIndex].id;
360
+ setFocusedCell?.({
361
+ colId: cell.column.id,
362
+ rowId: nextId
363
+ });
364
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
365
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
366
+ if (cellFocus) {
367
+ cellFocus.focus();
368
+ }
369
+ }
370
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
371
+ const prevIndex = cell.row.index - 1;
372
+ const nextId = flatRows[prevIndex].id;
373
+ setFocusedCell?.({
374
+ colId: cell.column.id,
375
+ rowId: nextId
376
+ });
377
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
378
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
379
+ if (cellFocus) {
380
+ cellFocus.focus();
381
+ }
382
+ }
383
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
384
+ toggleRowSelection({
385
+ e,
386
+ cell,
387
+ setIsSelectionChange,
388
+ isSelectionChange,
389
+ selectionSettings
390
+ });
391
+ cell.row.getToggleSelectedHandler()(e);
392
+ }
393
+ },
394
+ onClick: e => {
395
+ const selection = window.getSelection();
396
+ const text = selection ? selection.toString() : "";
397
+ if (text.length > 0 || enableClick === false) {} else {
398
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
399
+ toggleRowSelection({
400
+ e,
401
+ cell,
402
+ setIsSelectionChange,
403
+ isSelectionChange,
404
+ selectionSettings
405
+ });
406
+ setFocusedCell?.({
407
+ colId: cell.column.id,
408
+ rowId: cell.row.id
409
+ });
410
+ }
411
+ }
412
+ }
413
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree ? /*#__PURE__*/React.createElement("div", {
414
+ className: classNames('ui-rc_cell-content', {})
415
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
416
+ className: "ui-rc-table-row-expand-trigger",
417
+ style: {
418
+ paddingLeft: `${cell.row.depth * 25}px`
419
+ }
420
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
421
+ // onClick: cell.row.getToggleExpandedHandler(),
422
+
423
+ // onClick: (e) => {
424
+ // e.stopPropagation()
425
+ // cell.row.toggleExpanded()
426
+ // },
427
+
428
+ onClick: e => {
429
+ e.stopPropagation();
430
+ const keys = Object.keys(expanded);
431
+ // @ts-ignore
432
+ const tmp = {
433
+ ...expanded
434
+ };
435
+ if (keys.includes(cell.row.id)) {
436
+ delete tmp[cell.row.id];
437
+ setExpanded(tmp);
438
+ } else {
439
+ setExpanded(old => ({
440
+ ...old,
441
+ [cell.row.id]: true
442
+ }));
443
+ }
444
+ },
445
+ style: {
446
+ cursor: "pointer"
447
+ },
448
+ className: "ui-rc-table-row-expand"
449
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
450
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
451
+ }) : /*#__PURE__*/React.createElement("span", {
452
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
453
+ })) : /*#__PURE__*/React.createElement("span", {
454
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
455
+ }))), groupValue ? groupValue : flexRender(cell.column.columnDef.cell, cell.getContext())) : /*#__PURE__*/React.createElement(React.Fragment, null, groupValue ? groupValue : flexRender(cell.column.columnDef.cell, cell.getContext())));
456
+ };
457
+ export 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;
@@ -0,0 +1,112 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import TableBodyCell from "./TableBodyCell";
3
+ import { flexRender } from "@tanstack/react-table";
4
+ import React from "react";
5
+ import { TableContext } from "../useContext";
6
+ import classNames from "classnames";
7
+ const TableBodyRow = ({
8
+ tableId,
9
+ table,
10
+ row,
11
+ virtualRow,
12
+ commandClick,
13
+ contextMenuItems,
14
+ onContextMenu,
15
+ ...rest
16
+ }) => {
17
+ const {
18
+ prefix,
19
+ recordDoubleClick,
20
+ focusedCell,
21
+ rowClassName,
22
+ onRowStyles,
23
+ groupSetting
24
+ } = React.useContext(TableContext);
25
+ const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
26
+ const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
27
+ const visibleCells = row.getVisibleCells();
28
+ const allCells = row.getAllCells();
29
+ return /*#__PURE__*/React.createElement("tr", _extends({
30
+ key: row.id,
31
+ "data-row-key": row.id
32
+ }, rest, {
33
+ className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
34
+ [`${prefix}-grid-row-selected`]: row.getIsSelected(),
35
+ [`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId,
36
+ [`${prefix}-grid-row-parent`]: row.subRows && row.subRows.length > 0
37
+ }),
38
+ style: {
39
+ ...rowStyles
40
+ },
41
+ onDoubleClick: e => {
42
+ recordDoubleClick?.({
43
+ e,
44
+ rowData: row.original,
45
+ rowIndex: row.index
46
+ });
47
+ },
48
+ onContextMenu: e => {
49
+ if (contextMenuItems && contextMenuItems.length) {
50
+ onContextMenu?.(row.original)(e);
51
+ }
52
+ }
53
+ }), visibleCells.map(cell => {
54
+ const nonGroupColumns = visibleCells.filter(col => col.column.id !== 'selection_column' && col.column.id !== '#');
55
+ const firstNonGroupColumn = nonGroupColumns[0];
56
+
57
+ // const colSpan = row.subRows && cell.column.id === firstNonGroupColumn?.id ? (groupSetting?.groupColumnSpan ?? 2)
58
+ const colSpan = row.subRows && row.subRows.length > 0 && cell.column.id === firstNonGroupColumn?.column.id ? 2 : row.subRows && nonGroupColumns[1].column.id === cell.column.id ? 0 : 1;
59
+ if (row.subRows && row.subRows.length > 0 && colSpan === 0) {
60
+ return null;
61
+ }
62
+
63
+ // if (groupAble && column.field === firstNonGroupColumn?.field && row.subRows) {
64
+ if (cell.column.id === firstNonGroupColumn.column.id && row.subRows && row.subRows.length > 0) {
65
+ const {
66
+ field
67
+ } = row.original ?? {};
68
+ const cellGroup = allCells.find(it => it.column.id === field);
69
+ const headerContext = cellGroup && groupSetting?.showHeaderColumn !== false ? {
70
+ table,
71
+ column: cellGroup.column,
72
+ header: {
73
+ id: cellGroup.column.id,
74
+ column: cellGroup.column,
75
+ depth: 0,
76
+ index: 0,
77
+ subHeaders: []
78
+ }
79
+ } : undefined;
80
+ const cellValue = cellGroup ? cellGroup.getValue() : '';
81
+ const headertext = headerContext && cellGroup ? flexRender(cellGroup.column.columnDef.header, headerContext) : '';
82
+ const cellContent = cellGroup ? flexRender(cellGroup.column.columnDef.cell, cellGroup.getContext()) : '';
83
+ const groupValue = typeof groupSetting?.groupTemplate === 'function' ? groupSetting?.groupTemplate({
84
+ column: cellGroup?.column.columnDef.meta,
85
+ rowData: row.original,
86
+ value: cellValue
87
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, headertext, headertext ? ': ' : '', " ", cellContent);
88
+ return /*#__PURE__*/React.createElement(TableBodyCell, {
89
+ table: table,
90
+ tableId: tableId,
91
+ key: cell.id,
92
+ cell: cell,
93
+ commandClick: commandClick,
94
+ virtualRow: virtualRow,
95
+ isEditing: false,
96
+ colSpan: colSpan ?? 1,
97
+ groupValue: groupValue
98
+ });
99
+ }
100
+ return /*#__PURE__*/React.createElement(TableBodyCell, {
101
+ table: table,
102
+ tableId: tableId,
103
+ key: cell.id,
104
+ cell: cell,
105
+ commandClick: commandClick,
106
+ virtualRow: virtualRow,
107
+ isEditing: false,
108
+ colSpan: colSpan ?? 1
109
+ });
110
+ }));
111
+ };
112
+ export default TableBodyRow;
@@ -0,0 +1,7 @@
1
+ import type { Column } from "@tanstack/react-table";
2
+ import React from "react";
3
+ interface TableFooterCellProps<T> {
4
+ column: Column<T, any>;
5
+ }
6
+ declare const TableFooterCell: <RecordType extends object>({ column }: TableFooterCellProps<RecordType>) => React.JSX.Element;
7
+ export default TableFooterCell;
@@ -0,0 +1,54 @@
1
+ import React, { useContext } from "react";
2
+ import { checkDecimalSeparator, checkThousandSeparator, getCommonPinningStyles, getFormat, isEmpty } from "../hook/utils";
3
+ import { TableContext } from "../useContext";
4
+ import classNames from "classnames";
5
+ import { sumByField } from "../../grid-component/hooks";
6
+ import { numericFormatter } from "react-numeric-component";
7
+ const TableFooterCell = ({
8
+ column
9
+ }) => {
10
+ const {
11
+ prefix,
12
+ format,
13
+ dataSource
14
+ } = useContext(TableContext);
15
+ const col = column.columnDef.meta ?? {};
16
+ const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
17
+ const cellFormat = getFormat(colFormat, format);
18
+ const thousandSeparator = cellFormat?.thousandSeparator;
19
+ const decimalSeparator = cellFormat?.decimalSeparator;
20
+
21
+ // const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
22
+ const dec = cellFormat?.decimalScale;
23
+
24
+ // const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
25
+ const sumValue = col.type === 'number' ? sumByField(dataSource, col?.field) : 0;
26
+ const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
27
+ const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
28
+ const numberValue = Number(value);
29
+ const numericFormatProps = {
30
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
31
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
32
+ allowNegative: cellFormat?.allowNegative ?? false,
33
+ prefix: cellFormat?.prefix,
34
+ suffix: cellFormat?.suffix,
35
+ decimalScale: dec,
36
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
37
+ };
38
+ return /*#__PURE__*/React.createElement("th", {
39
+ className: classNames(`${prefix}-grid-cell`, {
40
+ // [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
41
+ // [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
42
+ // [`${prefix}-grid-cell-text-right`]: true
43
+ })
44
+ // key={column.id}
45
+ ,
46
+ style: {
47
+ // display: 'flex',
48
+ ...getCommonPinningStyles(column),
49
+ minWidth: column?.getSize(),
50
+ height: 40
51
+ }
52
+ }, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : numericFormatter(cellValue, numericFormatProps)) : '');
53
+ };
54
+ export default TableFooterCell;
@@ -0,0 +1,14 @@
1
+ import type { Table } from '@tanstack/react-table';
2
+ import { type Header } from '@tanstack/react-table';
3
+ import React from 'react';
4
+ interface TableHeadCellProps<T> {
5
+ t?: any;
6
+ table: Table<T>;
7
+ header: Header<T, unknown>;
8
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
9
+ colSpan: any;
10
+ rowSpan: any;
11
+ rowIndex: number;
12
+ }
13
+ declare const TableHeadCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
14
+ export default TableHeadCell;