es-grid-template 1.8.71 → 1.8.72

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