es-grid-template 1.8.71 → 1.8.73

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 (251) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/grid-component/type.d.ts +1 -3
  3. package/es/group-component/ColumnsChoose.d.ts +13 -0
  4. package/es/group-component/ColumnsChoose.js +211 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  6. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  7. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  8. package/es/group-component/ColumnsGroup/index.js +1 -0
  9. package/es/group-component/ContextMenu.d.ts +19 -0
  10. package/es/group-component/ContextMenu.js +74 -0
  11. package/es/group-component/InternalTable.d.ts +8 -0
  12. package/es/group-component/InternalTable.js +224 -0
  13. package/es/group-component/TableContainer.d.ts +49 -0
  14. package/es/group-component/TableContainer.js +375 -0
  15. package/es/group-component/TableContainerEdit.d.ts +48 -0
  16. package/es/group-component/TableContainerEdit.js +2068 -0
  17. package/es/group-component/body/EditableCell.d.ts +16 -0
  18. package/es/group-component/body/EditableCell.js +1066 -0
  19. package/es/group-component/body/TableBody.d.ts +14 -0
  20. package/es/group-component/body/TableBody.js +82 -0
  21. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  22. package/es/group-component/body/TableBodyCell.js +587 -0
  23. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  24. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  25. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  26. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  27. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  28. package/es/group-component/body/TableBodyRow.js +199 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  30. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  31. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  32. package/es/group-component/components/ControlCheckbox.js +84 -0
  33. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  34. package/es/group-component/components/EditForm/EditForm.js +394 -0
  35. package/es/group-component/components/EditForm/index.d.ts +1 -0
  36. package/es/group-component/components/EditForm/index.js +1 -0
  37. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  38. package/es/group-component/components/InputControl/InputControl.js +118 -0
  39. package/es/group-component/components/InputControl/index.d.ts +1 -0
  40. package/es/group-component/components/InputControl/index.js +1 -0
  41. package/es/group-component/components/async-select/index.d.ts +11 -0
  42. package/es/group-component/components/async-select/index.js +38 -0
  43. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  44. package/es/group-component/components/async-table-select/index.js +40 -0
  45. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  46. package/es/group-component/components/checkbox-control/index.js +40 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  48. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  50. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  51. package/es/group-component/components/command/Command.d.ts +10 -0
  52. package/es/group-component/components/command/Command.js +35 -0
  53. package/es/group-component/components/number/index.d.ts +12 -0
  54. package/es/group-component/components/number/index.js +42 -0
  55. package/es/group-component/components/number-range/index.d.ts +13 -0
  56. package/es/group-component/components/number-range/index.js +79 -0
  57. package/es/group-component/features/operator.d.ts +24 -0
  58. package/es/group-component/features/operator.js +62 -0
  59. package/es/group-component/footer/TableFooter.d.ts +7 -0
  60. package/es/group-component/footer/TableFooter.js +34 -0
  61. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  62. package/es/group-component/footer/TableFooterCell.js +66 -0
  63. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  64. package/es/group-component/footer/TableFooterRow.js +30 -0
  65. package/es/group-component/header/TableHead.d.ts +15 -0
  66. package/es/group-component/header/TableHead.js +98 -0
  67. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  68. package/es/group-component/header/TableHeadCell.js +310 -0
  69. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  70. package/es/group-component/header/TableHeadCell2.js +321 -0
  71. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  72. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  73. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  74. package/es/group-component/header/TableHeadRow.js +52 -0
  75. package/es/group-component/header/renderFilter.d.ts +20 -0
  76. package/es/group-component/header/renderFilter.js +291 -0
  77. package/es/group-component/hook/convert.d.ts +1 -0
  78. package/es/group-component/hook/convert.js +28 -0
  79. package/es/group-component/hook/useColumns.d.ts +28 -0
  80. package/es/group-component/hook/useColumns.js +306 -0
  81. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  82. package/es/group-component/hook/useFilterOperator.js +33 -0
  83. package/es/group-component/hook/utils.d.ts +220 -0
  84. package/es/group-component/hook/utils.js +2340 -0
  85. package/es/group-component/index.d.ts +2 -0
  86. package/es/group-component/index.js +2 -0
  87. package/es/group-component/style.d.ts +22 -0
  88. package/es/group-component/style.js +48 -0
  89. package/es/group-component/style.scss +1438 -0
  90. package/es/group-component/table/Grid.d.ts +33 -0
  91. package/es/group-component/table/Grid.js +439 -0
  92. package/es/group-component/table/TableWrapper.d.ts +33 -0
  93. package/es/group-component/table/TableWrapper.js +250 -0
  94. package/es/group-component/useContext.d.ts +100 -0
  95. package/es/group-component/useContext.js +21 -0
  96. package/es/table-component/InternalTable.js +9 -2
  97. package/es/table-component/TableContainer.d.ts +1 -0
  98. package/es/table-component/TableContainer.js +6 -2
  99. package/es/table-component/TableContainerEdit.d.ts +1 -0
  100. package/es/table-component/TableContainerEdit.js +4 -2
  101. package/es/table-component/body/TableBodyCell.js +49 -40
  102. package/es/table-component/body/TableBodyCellEdit.js +9 -6
  103. package/es/table-component/body/TableBodyRow.js +4 -1
  104. package/es/table-component/header/TableHeadCell2.js +39 -3
  105. package/es/table-component/hook/utils.d.ts +1 -0
  106. package/es/table-component/hook/utils.js +15 -7
  107. package/es/table-component/style.js +1 -1
  108. package/es/table-component/table/Grid.d.ts +1 -0
  109. package/es/table-component/table/Grid.js +10 -3
  110. package/es/table-component/useContext.d.ts +6 -0
  111. package/es/table-component/useContext.js +2 -1
  112. package/es/table-virtuoso/InternalTable.js +2 -2
  113. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  114. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  115. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  116. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  117. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  118. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  119. package/es/table-virtuoso/hook/utils.js +29 -0
  120. package/es/table-virtuoso/style.js +3 -1
  121. package/es/table-virtuoso/table/Grid.js +2 -2
  122. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  123. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  124. package/es/table-virtuoso/useContext.d.ts +6 -3
  125. package/es/table-virtuoso/useContext.js +18 -0
  126. package/lib/grid-component/TempTable.js +2 -1
  127. package/lib/grid-component/type.d.ts +1 -3
  128. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  129. package/lib/group-component/ColumnsChoose.js +221 -0
  130. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  131. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  132. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  133. package/lib/group-component/ColumnsGroup/index.js +16 -0
  134. package/lib/group-component/ContextMenu.d.ts +19 -0
  135. package/lib/group-component/ContextMenu.js +83 -0
  136. package/lib/group-component/InternalTable.d.ts +8 -0
  137. package/lib/group-component/InternalTable.js +233 -0
  138. package/lib/group-component/TableContainer.d.ts +49 -0
  139. package/lib/group-component/TableContainer.js +382 -0
  140. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  141. package/lib/group-component/TableContainerEdit.js +2075 -0
  142. package/lib/group-component/body/EditableCell.d.ts +16 -0
  143. package/lib/group-component/body/EditableCell.js +1075 -0
  144. package/lib/group-component/body/TableBody.d.ts +14 -0
  145. package/lib/group-component/body/TableBody.js +91 -0
  146. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  147. package/lib/group-component/body/TableBodyCell.js +595 -0
  148. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  149. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  150. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  151. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  152. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  153. package/lib/group-component/body/TableBodyRow.js +206 -0
  154. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  155. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  156. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  157. package/lib/group-component/components/ControlCheckbox.js +92 -0
  158. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  159. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  160. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  161. package/lib/group-component/components/EditForm/index.js +16 -0
  162. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  163. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  164. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  165. package/lib/group-component/components/InputControl/index.js +16 -0
  166. package/lib/group-component/components/async-select/index.d.ts +11 -0
  167. package/lib/group-component/components/async-select/index.js +47 -0
  168. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  169. package/lib/group-component/components/async-table-select/index.js +49 -0
  170. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  171. package/lib/group-component/components/checkbox-control/index.js +48 -0
  172. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  173. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  174. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  175. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  176. package/lib/group-component/components/command/Command.d.ts +10 -0
  177. package/lib/group-component/components/command/Command.js +44 -0
  178. package/lib/group-component/components/number/index.d.ts +12 -0
  179. package/lib/group-component/components/number/index.js +50 -0
  180. package/lib/group-component/components/number-range/index.d.ts +13 -0
  181. package/lib/group-component/components/number-range/index.js +87 -0
  182. package/lib/group-component/features/operator.d.ts +24 -0
  183. package/lib/group-component/features/operator.js +67 -0
  184. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  185. package/lib/group-component/footer/TableFooter.js +44 -0
  186. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  187. package/lib/group-component/footer/TableFooterCell.js +75 -0
  188. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  189. package/lib/group-component/footer/TableFooterRow.js +37 -0
  190. package/lib/group-component/header/TableHead.d.ts +15 -0
  191. package/lib/group-component/header/TableHead.js +107 -0
  192. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  193. package/lib/group-component/header/TableHeadCell.js +319 -0
  194. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  195. package/lib/group-component/header/TableHeadCell2.js +330 -0
  196. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  197. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  198. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  199. package/lib/group-component/header/TableHeadRow.js +59 -0
  200. package/lib/group-component/header/renderFilter.d.ts +20 -0
  201. package/lib/group-component/header/renderFilter.js +301 -0
  202. package/lib/group-component/hook/convert.d.ts +1 -0
  203. package/lib/group-component/hook/convert.js +34 -0
  204. package/lib/group-component/hook/useColumns.d.ts +28 -0
  205. package/lib/group-component/hook/useColumns.js +318 -0
  206. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  207. package/lib/group-component/hook/useFilterOperator.js +40 -0
  208. package/lib/group-component/hook/utils.d.ts +220 -0
  209. package/lib/group-component/hook/utils.js +2468 -0
  210. package/lib/group-component/index.d.ts +2 -0
  211. package/lib/group-component/index.js +9 -0
  212. package/lib/group-component/style.d.ts +22 -0
  213. package/lib/group-component/style.js +55 -0
  214. package/lib/group-component/style.scss +1438 -0
  215. package/lib/group-component/table/Grid.d.ts +33 -0
  216. package/lib/group-component/table/Grid.js +444 -0
  217. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  218. package/lib/group-component/table/TableWrapper.js +259 -0
  219. package/lib/group-component/useContext.d.ts +100 -0
  220. package/lib/group-component/useContext.js +27 -0
  221. package/lib/table-component/InternalTable.js +9 -2
  222. package/lib/table-component/TableContainer.d.ts +1 -0
  223. package/lib/table-component/TableContainer.js +6 -2
  224. package/lib/table-component/TableContainerEdit.d.ts +1 -0
  225. package/lib/table-component/TableContainerEdit.js +4 -2
  226. package/lib/table-component/body/TableBodyCell.js +49 -40
  227. package/lib/table-component/body/TableBodyCellEdit.js +9 -6
  228. package/lib/table-component/body/TableBodyRow.js +4 -1
  229. package/lib/table-component/header/TableHeadCell2.js +38 -2
  230. package/lib/table-component/hook/utils.d.ts +1 -0
  231. package/lib/table-component/hook/utils.js +16 -7
  232. package/lib/table-component/style.js +1 -1
  233. package/lib/table-component/table/Grid.d.ts +1 -0
  234. package/lib/table-component/table/Grid.js +10 -3
  235. package/lib/table-component/useContext.d.ts +6 -0
  236. package/lib/table-component/useContext.js +2 -1
  237. package/lib/table-virtuoso/InternalTable.js +2 -2
  238. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  239. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  240. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  241. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  242. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  243. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  244. package/lib/table-virtuoso/hook/utils.js +32 -1
  245. package/lib/table-virtuoso/style.js +3 -1
  246. package/lib/table-virtuoso/table/Grid.js +2 -2
  247. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  248. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  249. package/lib/table-virtuoso/useContext.d.ts +6 -3
  250. package/lib/table-virtuoso/useContext.js +18 -0
  251. package/package.json +1 -1
@@ -0,0 +1,567 @@
1
+ import { flexRender } from "@tanstack/react-table";
2
+ import Space from "rc-master-ui/es/space";
3
+ import Command from "../components/command/Command";
4
+ import ReactDOMServer from 'react-dom/server';
5
+ import { getCommonPinningStyles } from "../hook/utils";
6
+ import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
7
+ import classNames from "classnames";
8
+ import React from "react";
9
+ import { TableContext } from "../useContext";
10
+ // import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
11
+ import { toggleRowSelection } from "../hook/useColumns";
12
+ import { checkDecimalSeparator, checkThousandSeparator, getFormat } from "../../table-component/hook/utils";
13
+ import { sumByField } from "../../grid-component/hooks";
14
+ import { numericFormatter } from "react-numeric-component";
15
+ const renderCellIndex = props => {
16
+ const {
17
+ parrents,
18
+ cell,
19
+ pagination
20
+ } = props;
21
+ if (parrents && parrents.length > 0) {
22
+ return /*#__PURE__*/React.createElement("span", {
23
+ className: "ui-rc_cell-content"
24
+ }, parrents.map(pr => {
25
+ return `${pr.index + 1}.`;
26
+ }), cell.row.index + 1);
27
+ }
28
+ if (pagination && pagination.onChange) {
29
+ return /*#__PURE__*/React.createElement("span", {
30
+ className: "ui-rc_cell-content"
31
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
32
+ }
33
+ return /*#__PURE__*/React.createElement("span", {
34
+ className: "ui-rc_cell-content"
35
+ }, cell.row.index + 1);
36
+ };
37
+ const renderCommand = args => {
38
+ const {
39
+ cell,
40
+ commandClick,
41
+ id,
42
+ data
43
+ } = args;
44
+ const col = cell.column.columnDef.meta ?? {};
45
+ const record = cell.row.original;
46
+
47
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
48
+
49
+ const commands = col.commandItems ? col.commandItems.map(it => {
50
+ return {
51
+ ...it,
52
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
53
+ };
54
+ }) : [];
55
+ return /*#__PURE__*/React.createElement("div", {
56
+ className: "ui-rc_cell-content"
57
+ }, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
58
+ return /*#__PURE__*/React.createElement(Command, {
59
+ id: id,
60
+ key: item.id,
61
+ item: item,
62
+ record: record,
63
+ onClick: () => {
64
+ commandClick?.({
65
+ id: item.id,
66
+ // rowId: getRowKey(record, index) as any,
67
+ rowId: record.rowId,
68
+ rowData: record,
69
+ index: cell.row.index,
70
+ rows: [...data]
71
+ });
72
+ }
73
+ });
74
+ })));
75
+ };
76
+ const renderSelection = args => {
77
+ const {
78
+ row
79
+ } = args.cell;
80
+ const {
81
+ cell,
82
+ expandIconColumnIndex,
83
+ isDataTree,
84
+ expanded,
85
+ setExpanded
86
+ } = args;
87
+ const {
88
+ selectionSettings,
89
+ setIsSelectionChange,
90
+ isSelectionChange
91
+ } = args;
92
+ const checked = selectionSettings?.checkStrictly ? row.getIsSelected() : row.getIsSelected() || row.getIsAllSubRowsSelected();
93
+ const indeterminate = selectionSettings?.type === 'single' || selectionSettings?.checkStrictly ? false : row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' || row.getIsSomeSelected();
94
+ return /*#__PURE__*/React.createElement("div", {
95
+ style: {}
96
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
97
+ className: "ui-rc-table-row-expand-trigger",
98
+ style: {
99
+ paddingLeft: `${cell.row.depth * 25}px`
100
+ }
101
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
102
+ // onClick: row.getToggleExpandedHandler(),
103
+ onClick: e => {
104
+ e.stopPropagation();
105
+ const keys = Object.keys(expanded);
106
+ // @ts-ignore
107
+ const tmp = {
108
+ ...expanded
109
+ };
110
+ if (keys.includes(cell.row.id)) {
111
+ delete tmp[cell.row.id];
112
+ setExpanded(tmp);
113
+ } else {
114
+ setExpanded(old => ({
115
+ ...old,
116
+ [cell.row.id]: true
117
+ }));
118
+ }
119
+ },
120
+ style: {
121
+ cursor: "pointer"
122
+ },
123
+ className: "ui-rc-table-row-expand"
124
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
125
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
126
+ }) : /*#__PURE__*/React.createElement("span", {
127
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
128
+ })) : /*#__PURE__*/React.createElement("span", {
129
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
130
+ }))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
131
+ checked: checked,
132
+ indeterminate: indeterminate,
133
+ onChange: e => {
134
+ toggleRowSelection({
135
+ e,
136
+ cell,
137
+ setIsSelectionChange,
138
+ isSelectionChange,
139
+ selectionSettings
140
+ });
141
+ },
142
+ disabled: !row.getCanSelect()
143
+ })));
144
+ };
145
+ const TableBodyCell = props => {
146
+ const {
147
+ cell,
148
+ commandClick,
149
+ // tableId,
150
+ table,
151
+ isEditing,
152
+ row,
153
+ colSpan
154
+ // rowSpan
155
+ } = props;
156
+ const {
157
+ id,
158
+ prefix,
159
+ focusedCell,
160
+ setFocusedCell,
161
+ // endCell,
162
+ // startCell,
163
+ originData,
164
+ expanded,
165
+ setExpanded,
166
+ expandable,
167
+ isDataTree,
168
+ setIsSelectionChange,
169
+ isSelectionChange,
170
+ selectionSettings,
171
+ wrapSettings,
172
+ pagination,
173
+ setIsSelecting,
174
+ setIsPasting,
175
+ setEndCell,
176
+ setStartCell,
177
+ setRangeState,
178
+ setEditingKey,
179
+ format
180
+ // dataSource
181
+ } = React.useContext(TableContext);
182
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
183
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
184
+ const record = cell.row.original;
185
+ const columnMeta = cell.column.columnDef.meta ?? {};
186
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
187
+ const originCol = cell.column.columnDef.meta ?? {};
188
+
189
+ // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
190
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
191
+ value: cell.getValue(),
192
+ record
193
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
194
+ const allRows = table.getRowModel().flatRows;
195
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
196
+ const colIndex = cell.column.getIndex();
197
+ const isPinned = cell.column.getIsPinned();
198
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
199
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
200
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
201
+ const parrents = cell.row.getParentRows();
202
+ if (cell.column.id === "#") {
203
+ return /*#__PURE__*/React.createElement("div", {
204
+ key: cell.id,
205
+ className: classNames(`${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
+ ...getCommonPinningStyles(cell.column)
219
+ },
220
+ onClick: e => {
221
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
222
+ toggleRowSelection({
223
+ e,
224
+ cell,
225
+ setIsSelectionChange,
226
+ isSelectionChange,
227
+ selectionSettings
228
+ });
229
+ }
230
+ }
231
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
232
+ className: "ui-rc-table-row-expand-trigger",
233
+ style: {
234
+ paddingLeft: `${cell.row.depth * 25}px`
235
+ }
236
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
237
+ // onClick: row.getToggleExpandedHandler(),
238
+ onClick: e => {
239
+ e.stopPropagation();
240
+ const keys = Object.keys(expanded);
241
+ // @ts-ignore
242
+ const tmp = {
243
+ ...expanded
244
+ };
245
+ if (keys.includes(cell.row.id)) {
246
+ delete tmp[cell.row.id];
247
+ setExpanded(tmp);
248
+ } else {
249
+ setExpanded(old => ({
250
+ ...old,
251
+ [cell.row.id]: true
252
+ }));
253
+ }
254
+ },
255
+ style: {
256
+ cursor: "pointer"
257
+ },
258
+ className: "ui-rc-table-row-expand"
259
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
260
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
261
+ }) : /*#__PURE__*/React.createElement("span", {
262
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
263
+ })) : /*#__PURE__*/React.createElement("span", {
264
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
265
+ }))), renderCellIndex({
266
+ parrents,
267
+ cell,
268
+ pagination
269
+ }));
270
+ }
271
+ if (cell.column.id === "command") {
272
+ return /*#__PURE__*/React.createElement("div", {
273
+ key: cell.id,
274
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-command`, {
275
+ [`${prefix}-grid-cell-ellipsis`]: true,
276
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
277
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
278
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
279
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
280
+ }),
281
+ style: {
282
+ ...cellStyles,
283
+ display: 'flex',
284
+ width: cell.column.getSize(),
285
+ minWidth: cell.column.getSize(),
286
+ ...getCommonPinningStyles(cell.column)
287
+ }
288
+ }, renderCommand({
289
+ cell,
290
+ commandClick,
291
+ id,
292
+ data: originData
293
+ }));
294
+ }
295
+ if (cell.column.id === "selection_column") {
296
+ return /*#__PURE__*/React.createElement("div", {
297
+ key: cell.id,
298
+ className: classNames(`${prefix}-grid-cell ${prefix}-grid-cell-selection`, {
299
+ [`${prefix}-grid-cell-ellipsis`]: true,
300
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
301
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
302
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
303
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
304
+ }),
305
+ style: {
306
+ ...cellStyles,
307
+ display: 'flex',
308
+ minHeight: 36,
309
+ width: cell.column.getSize(),
310
+ minWidth: cell.column.getSize(),
311
+ ...getCommonPinningStyles(cell.column)
312
+ }
313
+ }, /*#__PURE__*/React.createElement("div", {
314
+ className: classNames('ui-rc_cell-content', {})
315
+ }, cell.column.id === "selection_column" && renderSelection({
316
+ cell,
317
+ table,
318
+ selectionSettings,
319
+ setIsSelectionChange,
320
+ expanded,
321
+ isDataTree,
322
+ setExpanded,
323
+ expandIconColumnIndex,
324
+ isSelectionChange
325
+ })));
326
+ }
327
+ if (row.subRows.length > 0 && originCol.sumGroup === true && originCol.type === 'number') {
328
+ const colFormat = typeof originCol.format === 'function' ? originCol.format({}) : originCol.format;
329
+ const cellFormat = getFormat(colFormat, format);
330
+ const thousandSeparator = cellFormat?.thousandSeparator;
331
+ const decimalSeparator = cellFormat?.decimalSeparator;
332
+ const dec = cellFormat?.decimalScale;
333
+ const numericFormatProps = {
334
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
335
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
336
+ allowNegative: cellFormat?.allowNegative ?? true,
337
+ prefix: cellFormat?.prefix,
338
+ suffix: cellFormat?.suffix,
339
+ decimalScale: dec,
340
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
341
+ };
342
+
343
+ // const childrenData = row.subRows.map((it) => it.original)
344
+ const childrenData = record?.children ?? [];
345
+ const sumValue = sumByField(childrenData, cell.column.id);
346
+ const sumValueFormat = numericFormatter(sumValue.toString(), numericFormatProps);
347
+ return /*#__PURE__*/React.createElement("div", {
348
+ key: cell.id,
349
+ className: classNames(`${prefix}-grid-cell`, {
350
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
351
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
352
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
353
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
354
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
355
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
356
+ }),
357
+ style: {
358
+ ...cellStyles,
359
+ display: 'flex',
360
+ userSelect: 'none',
361
+ width: cell.column.getSize(),
362
+ minWidth: cell.column.getSize(),
363
+ ...getCommonPinningStyles(cell.column)
364
+ },
365
+ onClick: e => {
366
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
367
+ toggleRowSelection({
368
+ e,
369
+ cell,
370
+ setIsSelectionChange,
371
+ isSelectionChange,
372
+ selectionSettings
373
+ });
374
+ }
375
+ }
376
+ }, sumValueFormat);
377
+ }
378
+ return /*#__PURE__*/React.createElement("div", {
379
+ key: cell.id,
380
+ ref: el => {
381
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
382
+ el?.focus();
383
+ }
384
+ },
385
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
386
+ "data-col-index": colIndex,
387
+ "data-row-index": rowNumber,
388
+ "data-col-key": cell.column.id
389
+ // data-row-key={cell.row.id}
390
+ ,
391
+ "data-tooltip-id": `${id}-tooltip-content`,
392
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
393
+ // data-tooltip-delay-show={500}
394
+ ,
395
+
396
+ className: classNames(`${prefix}-grid-cell`, {
397
+ // [`${prefix}-grid-cell-ellipsis`]: true,
398
+
399
+ [`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
400
+ [`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
401
+ // [`${prefix}-grid-cell-selected`]: isCellSelected,
402
+
403
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
404
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
405
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
406
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
407
+ }),
408
+ style: {
409
+ ...cellStyles,
410
+ display: 'flex',
411
+ width: cell.column.getSize(),
412
+ minWidth: cell.column.getSize(),
413
+ minHeight: 36,
414
+ gridColumn: `span ${colSpan} / span ${colSpan}`,
415
+ ...getCommonPinningStyles(cell.column)
416
+ },
417
+ onMouseDown: () => {
418
+ // setEditingKey?.('')
419
+ // setEndCell?.(undefined)
420
+ // setStartCell?.(undefined)
421
+ // setFocusedCell?.(undefined)
422
+ // setRangeState?.(undefined)
423
+ },
424
+ onMouseEnter: e => {
425
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
426
+ setIsOpenTooltip(true);
427
+ }
428
+ setIsSelecting?.(false);
429
+ setIsPasting?.(false);
430
+ },
431
+ onKeyDown: e => {
432
+ const flatRows = table.getRowModel().flatRows;
433
+ if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
434
+ const nextIndex = cell.row.index + 1;
435
+ // const nextIndex = rowNumber + 1
436
+
437
+ const nextId = flatRows[nextIndex].id;
438
+ setFocusedCell?.({
439
+ colId: cell.column.id,
440
+ rowId: nextId
441
+ });
442
+ const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
443
+ const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
444
+ if (cellFocus) {
445
+ cellFocus.focus();
446
+ }
447
+ }
448
+ if (e.key === 'ArrowUp' && rowNumber > 0) {
449
+ const prevIndex = cell.row.index - 1;
450
+ const nextId = flatRows[prevIndex].id;
451
+ setFocusedCell?.({
452
+ colId: cell.column.id,
453
+ rowId: nextId
454
+ });
455
+ const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
456
+ const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
457
+ if (cellFocus) {
458
+ cellFocus.focus();
459
+ }
460
+ }
461
+ if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
462
+ toggleRowSelection({
463
+ e,
464
+ cell,
465
+ setIsSelectionChange,
466
+ isSelectionChange,
467
+ selectionSettings
468
+ });
469
+ cell.row.getToggleSelectedHandler()(e);
470
+
471
+ // if (cell.row.getIsSelected()) { // nếu đã chọn
472
+
473
+ // const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== cell.row.id)
474
+
475
+ // setIsSelectionChange({
476
+ // isChange: true,
477
+ // type: 'rowSelected',
478
+ // rowData: cell.row.original,
479
+ // rowsData: aaa ?? []
480
+ // })
481
+
482
+ // } else {
483
+
484
+ // const { rowsData } = isSelectionChange ?? {}
485
+
486
+ // const abc = rowsData && rowsData.length > 0 ? [...rowsData] : []
487
+
488
+ // abc.push(cell.row)
489
+
490
+ // setIsSelectionChange({
491
+ // isChange: true,
492
+ // type: 'rowSelected',
493
+ // rowData: cell.row.original,
494
+ // rowsData: abc
495
+ // })
496
+ // }
497
+ }
498
+ }
499
+
500
+ // onKeyUp={() => {
501
+
502
+ // }}
503
+ ,
504
+
505
+ onClick: e => {
506
+ const selection = window.getSelection();
507
+ const text = selection ? selection.toString() : "";
508
+ if (text.length > 0 || enableClick === false) {} else {
509
+ if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
510
+ toggleRowSelection({
511
+ e,
512
+ cell,
513
+ setIsSelectionChange,
514
+ isSelectionChange,
515
+ selectionSettings
516
+ });
517
+ setFocusedCell?.({
518
+ colId: cell.column.id,
519
+ rowId: cell.row.id
520
+ });
521
+ setEditingKey?.('');
522
+ setEndCell?.(undefined);
523
+ setStartCell?.(undefined);
524
+ // setFocusedCell?.(undefined)
525
+ setRangeState?.(undefined);
526
+ }
527
+ }
528
+ }
529
+ }, /*#__PURE__*/React.createElement("div", {
530
+ className: classNames('ui-rc_cell-content', {})
531
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
532
+ className: "ui-rc-table-row-expand-trigger",
533
+ style: {
534
+ paddingLeft: `${cell.row.depth * 25}px`
535
+ }
536
+ }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
537
+ // onClick: row.getToggleExpandedHandler(),
538
+ onClick: e => {
539
+ e.stopPropagation();
540
+ const keys = Object.keys(expanded);
541
+ // @ts-ignore
542
+ const tmp = {
543
+ ...expanded
544
+ };
545
+ if (keys.includes(cell.row.id)) {
546
+ delete tmp[cell.row.id];
547
+ setExpanded(tmp);
548
+ } else {
549
+ setExpanded(old => ({
550
+ ...old,
551
+ [cell.row.id]: true
552
+ }));
553
+ }
554
+ },
555
+ style: {
556
+ cursor: "pointer"
557
+ },
558
+ className: "ui-rc-table-row-expand"
559
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
560
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
561
+ }) : /*#__PURE__*/React.createElement("span", {
562
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
563
+ })) : /*#__PURE__*/React.createElement("span", {
564
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
565
+ }))), flexRender(cell.column.columnDef.cell, cell.getContext())));
566
+ };
567
+ export default TableBodyCell;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import type { ColumnTable } from "../../grid-component/type";
3
+ type Props = {
4
+ column: ColumnTable;
5
+ record?: any;
6
+ rowIndex: number;
7
+ colIndex: number;
8
+ checkValue: any;
9
+ checked: boolean;
10
+ editAble?: boolean;
11
+ };
12
+ declare const ControlCheckbox: (props: Props) => React.JSX.Element;
13
+ export default ControlCheckbox;
@@ -0,0 +1,84 @@
1
+ import React, { useContext } from "react";
2
+ import { Checkbox } from "rc-master-ui";
3
+ import { TableContext } from "../useContext";
4
+ import { isEditable, isDisable, parseBooleanToValue } from "../hook/utils";
5
+ const ControlCheckbox = props => {
6
+ const {
7
+ column,
8
+ record,
9
+ rowIndex,
10
+ colIndex,
11
+ checkValue,
12
+ editAble,
13
+ checked
14
+ } = props;
15
+ const {
16
+ handleCellChange,
17
+ rowKey
18
+ } = useContext(TableContext);
19
+ const isEdit = React.useMemo(() => {
20
+ return isEditable(column, record);
21
+ }, [column, record]);
22
+
23
+ // const [isHover, setIsHover] = useState(false)
24
+
25
+ const inputNode = value => {
26
+ return /*#__PURE__*/React.createElement(Checkbox, {
27
+ checked: Boolean(value),
28
+ defaultChecked: Boolean(checked)
29
+ // style={{ textAlign: column.align ?? 'left' }}
30
+ ,
31
+ onChange: val => {
32
+ const newVal = typeof checkValue === "number" ? parseBooleanToValue(val.target.checked, typeof value) : val.target.checked;
33
+
34
+ // onChange(newVal)
35
+
36
+ const key = record[rowKey];
37
+ // const formState = getValues()
38
+
39
+ handleCellChange?.({
40
+ key: key,
41
+ // @ts-ignore
42
+ record: {
43
+ ...record,
44
+ [column.field]: newVal
45
+ },
46
+ option: value,
47
+ prevState: value,
48
+ newState: newVal,
49
+ field: column.field,
50
+ indexCol: colIndex,
51
+ indexRow: rowIndex,
52
+ type: 'blur'
53
+ });
54
+ },
55
+ disabled: isDisable(column, record) ?? false
56
+ });
57
+ };
58
+ return /*#__PURE__*/React.createElement("div", {
59
+ // onMouseEnter={() => {
60
+ // setIsHover(true)
61
+ // }}
62
+ //
63
+ // onMouseLeave={() => {
64
+ // setIsHover(false)
65
+ // }}
66
+ style: {
67
+ display: 'flex',
68
+ alignItems: 'center',
69
+ justifyContent: column.align ?? 'center',
70
+ paddingInline: 5,
71
+ height: '100%',
72
+ width: '100%'
73
+ }
74
+ }, editAble && isEdit !== false ? inputNode(checkValue) : /*#__PURE__*/React.createElement(Checkbox, {
75
+ checked: checked,
76
+ onChange: e => {
77
+ e.preventDefault();
78
+ },
79
+ style: {
80
+ textAlign: column.align ?? 'left'
81
+ }
82
+ }));
83
+ };
84
+ export default ControlCheckbox;
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ type Props = {
3
+ id?: string;
4
+ externalClick?: any;
5
+ menuPortalTarget?: any;
6
+ value: any;
7
+ onChange: (props: any) => void;
8
+ filterKey?: string;
9
+ customRender?: any;
10
+ filterHeaderKey?: string;
11
+ placeholder?: string;
12
+ invalid?: any;
13
+ menuHeight?: number;
14
+ menuWidth?: number;
15
+ classNamePrefix?: string;
16
+ cellFocus?: boolean;
17
+ t?: any;
18
+ column: any;
19
+ fieldKey?: any;
20
+ rowData: any;
21
+ indexRow: any;
22
+ template?: any;
23
+ onKeyDown?: (event: any) => void;
24
+ };
25
+ export declare const SelectStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
26
+ export declare const EditForm: (props: Props) => React.JSX.Element;
27
+ export {};