es-grid-template 1.8.87 → 1.8.88

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 (271) hide show
  1. package/es/ali-table/Grid.d.ts +15 -0
  2. package/es/ali-table/Grid.js +331 -0
  3. package/es/ali-table/InternalTable.d.ts +5 -0
  4. package/es/ali-table/InternalTable.js +274 -0
  5. package/es/ali-table/assets/WebsiteBaseTable.d.ts +4 -0
  6. package/es/ali-table/assets/WebsiteBaseTable.js +18 -0
  7. package/es/ali-table/base-table/ColumnResizer.js +133 -0
  8. package/es/ali-table/base-table/calculations.d.ts +3 -0
  9. package/es/ali-table/base-table/calculations.js +274 -0
  10. package/es/ali-table/base-table/colgroup.d.ts +5 -0
  11. package/es/ali-table/base-table/colgroup.js +21 -0
  12. package/es/ali-table/base-table/empty.d.ts +12 -0
  13. package/es/ali-table/base-table/empty.js +36 -0
  14. package/es/ali-table/base-table/header.d.ts +5 -0
  15. package/es/ali-table/base-table/header.js +255 -0
  16. package/es/ali-table/base-table/helpers/SpanManager.d.ts +14 -0
  17. package/es/ali-table/base-table/helpers/SpanManager.js +30 -0
  18. package/es/ali-table/base-table/helpers/TableDOMUtils.d.ts +16 -0
  19. package/es/ali-table/base-table/helpers/TableDOMUtils.js +93 -0
  20. package/es/ali-table/base-table/helpers/getRichVisibleRectsStream.d.ts +23 -0
  21. package/es/ali-table/base-table/helpers/getRichVisibleRectsStream.js +185 -0
  22. package/es/ali-table/base-table/helpers/rowHeightManager.d.ts +7 -0
  23. package/es/ali-table/base-table/helpers/rowHeightManager.js +137 -0
  24. package/es/ali-table/base-table/html-table.d.ts +20 -0
  25. package/es/ali-table/base-table/html-table.js +224 -0
  26. package/es/ali-table/base-table/interfaces.d.ts +54 -0
  27. package/es/ali-table/base-table/interfaces.js +1 -0
  28. package/es/ali-table/base-table/loading.d.ts +14 -0
  29. package/es/ali-table/base-table/loading.js +29 -0
  30. package/es/ali-table/base-table/renderFilter.d.ts +21 -0
  31. package/es/ali-table/base-table/renderFilter.js +306 -0
  32. package/es/ali-table/base-table/styles.d.ts +82 -0
  33. package/es/ali-table/base-table/styles.js +51 -0
  34. package/es/ali-table/base-table/styles.scss +19 -0
  35. package/es/ali-table/base-table/table.d.ts +181 -0
  36. package/es/ali-table/base-table/table.js +521 -0
  37. package/es/ali-table/base-table/utils.d.ts +24 -0
  38. package/es/ali-table/base-table/utils.js +157 -0
  39. package/es/ali-table/common-views.d.ts +25 -0
  40. package/es/ali-table/common-views.js +65 -0
  41. package/es/ali-table/index.d.ts +2 -0
  42. package/es/ali-table/index.js +2 -0
  43. package/es/ali-table/interfaces.d.ts +97 -0
  44. package/es/ali-table/interfaces.js +1 -0
  45. package/es/ali-table/internals.d.ts +17 -0
  46. package/es/ali-table/internals.js +76 -0
  47. package/es/ali-table/pipeline/features/ColumnsChoose.d.ts +14 -0
  48. package/es/ali-table/pipeline/features/ColumnsChoose.js +184 -0
  49. package/es/ali-table/pipeline/features/autoRowSpan.d.ts +2 -0
  50. package/es/ali-table/pipeline/features/autoRowSpan.js +59 -0
  51. package/es/ali-table/pipeline/features/buildTree.d.ts +2 -0
  52. package/es/ali-table/pipeline/features/buildTree.js +4 -0
  53. package/es/ali-table/pipeline/features/columnCustom.d.ts +50 -0
  54. package/es/ali-table/pipeline/features/columnCustom.js +595 -0
  55. package/es/ali-table/pipeline/features/columnHover.d.ts +12 -0
  56. package/es/ali-table/pipeline/features/columnHover.js +43 -0
  57. package/es/ali-table/pipeline/features/columnRangeHover.d.ts +15 -0
  58. package/es/ali-table/pipeline/features/columnRangeHover.js +75 -0
  59. package/es/ali-table/pipeline/features/hiddenColumns.d.ts +6 -0
  60. package/es/ali-table/pipeline/features/hiddenColumns.js +19 -0
  61. package/es/ali-table/pipeline/features/index.d.ts +25 -0
  62. package/es/ali-table/pipeline/features/index.js +14 -0
  63. package/es/ali-table/pipeline/features/multiSelect.d.ts +27 -0
  64. package/es/ali-table/pipeline/features/multiSelect.js +164 -0
  65. package/es/ali-table/pipeline/features/pagination.d.ts +6 -0
  66. package/es/ali-table/pipeline/features/pagination.js +33 -0
  67. package/es/ali-table/pipeline/features/rowDetail.d.ts +28 -0
  68. package/es/ali-table/pipeline/features/rowDetail.js +160 -0
  69. package/es/ali-table/pipeline/features/rowGrouping.d.ts +14 -0
  70. package/es/ali-table/pipeline/features/rowGrouping.js +149 -0
  71. package/es/ali-table/pipeline/features/singleSelect.d.ts +23 -0
  72. package/es/ali-table/pipeline/features/singleSelect.js +106 -0
  73. package/es/ali-table/pipeline/features/tips.d.ts +2 -0
  74. package/es/ali-table/pipeline/features/tips.js +51 -0
  75. package/es/ali-table/pipeline/features/treeMode.d.ts +20 -0
  76. package/es/ali-table/pipeline/features/treeMode.js +187 -0
  77. package/es/ali-table/pipeline/features/treeSelect.d.ts +40 -0
  78. package/es/ali-table/pipeline/features/treeSelect.js +300 -0
  79. package/es/ali-table/pipeline/index.d.ts +3 -0
  80. package/es/ali-table/pipeline/index.js +3 -0
  81. package/es/ali-table/pipeline/pipeline.d.ts +78 -0
  82. package/es/ali-table/pipeline/pipeline.js +177 -0
  83. package/es/ali-table/useContext.d.ts +43 -0
  84. package/es/ali-table/useContext.js +13 -0
  85. package/es/ali-table/utils/applyTransforms.d.ts +6 -0
  86. package/es/ali-table/utils/applyTransforms.js +7 -0
  87. package/es/ali-table/utils/buildTree.d.ts +37 -0
  88. package/es/ali-table/utils/buildTree.js +71 -0
  89. package/es/ali-table/utils/collectNodes.d.ts +9 -0
  90. package/es/ali-table/utils/collectNodes.js +34 -0
  91. package/es/ali-table/utils/convertColumnsChoose.d.ts +5 -0
  92. package/es/ali-table/utils/convertColumnsChoose.js +97 -0
  93. package/es/ali-table/utils/exportTableAsExcel.d.ts +4 -0
  94. package/es/ali-table/utils/exportTableAsExcel.js +132 -0
  95. package/es/ali-table/utils/getTreeDepth.d.ts +3 -0
  96. package/es/ali-table/utils/getTreeDepth.js +17 -0
  97. package/es/ali-table/utils/groupBy.d.ts +1 -0
  98. package/es/ali-table/utils/groupBy.js +11 -0
  99. package/es/ali-table/utils/groupBy2.d.ts +1 -0
  100. package/es/ali-table/utils/groupBy2.js +12 -0
  101. package/es/ali-table/utils/index.d.ts +14 -0
  102. package/es/ali-table/utils/index.js +14 -0
  103. package/es/ali-table/utils/isLeafNode.d.ts +2 -0
  104. package/es/ali-table/utils/isLeafNode.js +3 -0
  105. package/es/ali-table/utils/layeredSort.d.ts +6 -0
  106. package/es/ali-table/utils/layeredSort.js +22 -0
  107. package/es/ali-table/utils/makeRecursiveMapper.d.ts +9 -0
  108. package/es/ali-table/utils/makeRecursiveMapper.js +46 -0
  109. package/es/ali-table/utils/mergeCellProps.d.ts +9 -0
  110. package/es/ali-table/utils/mergeCellProps.js +53 -0
  111. package/es/ali-table/utils/others.d.ts +11 -0
  112. package/es/ali-table/utils/others.js +27 -0
  113. package/es/ali-table/utils/proto.d.ts +21 -0
  114. package/es/ali-table/utils/proto.js +67 -0
  115. package/es/ali-table/utils/selected.d.ts +40 -0
  116. package/es/ali-table/utils/selected.js +1037 -0
  117. package/es/ali-table/utils/smartCompare.d.ts +9 -0
  118. package/es/ali-table/utils/smartCompare.js +45 -0
  119. package/es/ali-table/utils/traverseColumn.d.ts +11 -0
  120. package/es/ali-table/utils/traverseColumn.js +61 -0
  121. package/es/ali-table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
  122. package/es/ali-table/utils/tree-data-helpers/StrictTreeDataHelper.js +97 -0
  123. package/es/ali-table/utils/tree-data-helpers/TreeDataHelper.d.ts +25 -0
  124. package/es/ali-table/utils/tree-data-helpers/TreeDataHelper.js +217 -0
  125. package/es/grid-component/hooks/constant.d.ts +1 -0
  126. package/es/grid-component/hooks/constant.js +2 -1
  127. package/es/grid-component/type.d.ts +31 -12
  128. package/es/group-component/TableContainerEdit.js +2 -6
  129. package/es/group-component/hook/utils.d.ts +11 -9
  130. package/es/index.d.ts +1 -1
  131. package/es/index.js +1 -1
  132. package/es/table-component/TableContainerEdit.js +2 -6
  133. package/es/table-component/header/TableHeadCell2.js +1 -1
  134. package/es/table-component/hook/utils.d.ts +4 -2
  135. package/es/table-component/hook/utils.js +61 -1
  136. package/lib/ali-table/Grid.d.ts +15 -0
  137. package/lib/ali-table/Grid.js +341 -0
  138. package/lib/ali-table/InternalTable.d.ts +5 -0
  139. package/lib/ali-table/InternalTable.js +283 -0
  140. package/lib/ali-table/assets/WebsiteBaseTable.d.ts +4 -0
  141. package/lib/ali-table/assets/WebsiteBaseTable.js +25 -0
  142. package/lib/ali-table/base-table/ColumnResizer.js +140 -0
  143. package/lib/ali-table/base-table/calculations.d.ts +3 -0
  144. package/lib/ali-table/base-table/calculations.js +280 -0
  145. package/lib/ali-table/base-table/colgroup.d.ts +5 -0
  146. package/lib/ali-table/base-table/colgroup.js +28 -0
  147. package/lib/ali-table/base-table/empty.d.ts +12 -0
  148. package/lib/ali-table/base-table/empty.js +43 -0
  149. package/lib/ali-table/base-table/header.d.ts +5 -0
  150. package/lib/ali-table/base-table/header.js +262 -0
  151. package/lib/ali-table/base-table/helpers/SpanManager.d.ts +14 -0
  152. package/lib/ali-table/base-table/helpers/SpanManager.js +37 -0
  153. package/lib/ali-table/base-table/helpers/TableDOMUtils.d.ts +16 -0
  154. package/lib/ali-table/base-table/helpers/TableDOMUtils.js +99 -0
  155. package/lib/ali-table/base-table/helpers/getRichVisibleRectsStream.d.ts +23 -0
  156. package/lib/ali-table/base-table/helpers/getRichVisibleRectsStream.js +194 -0
  157. package/lib/ali-table/base-table/helpers/rowHeightManager.d.ts +7 -0
  158. package/lib/ali-table/base-table/helpers/rowHeightManager.js +144 -0
  159. package/lib/ali-table/base-table/html-table.d.ts +20 -0
  160. package/lib/ali-table/base-table/html-table.js +231 -0
  161. package/lib/ali-table/base-table/interfaces.d.ts +54 -0
  162. package/lib/ali-table/base-table/interfaces.js +5 -0
  163. package/lib/ali-table/base-table/loading.d.ts +14 -0
  164. package/lib/ali-table/base-table/loading.js +36 -0
  165. package/lib/ali-table/base-table/renderFilter.d.ts +21 -0
  166. package/lib/ali-table/base-table/renderFilter.js +316 -0
  167. package/lib/ali-table/base-table/styles.d.ts +82 -0
  168. package/lib/ali-table/base-table/styles.js +59 -0
  169. package/lib/ali-table/base-table/styles.scss +19 -0
  170. package/lib/ali-table/base-table/table.d.ts +181 -0
  171. package/lib/ali-table/base-table/table.js +531 -0
  172. package/lib/ali-table/base-table/utils.d.ts +24 -0
  173. package/lib/ali-table/base-table/utils.js +170 -0
  174. package/lib/ali-table/common-views.d.ts +25 -0
  175. package/lib/ali-table/common-views.js +72 -0
  176. package/lib/ali-table/index.d.ts +2 -0
  177. package/lib/ali-table/index.js +9 -0
  178. package/lib/ali-table/interfaces.d.ts +97 -0
  179. package/lib/ali-table/interfaces.js +5 -0
  180. package/lib/ali-table/internals.d.ts +17 -0
  181. package/lib/ali-table/internals.js +82 -0
  182. package/lib/ali-table/pipeline/features/ColumnsChoose.d.ts +14 -0
  183. package/lib/ali-table/pipeline/features/ColumnsChoose.js +194 -0
  184. package/lib/ali-table/pipeline/features/autoRowSpan.d.ts +2 -0
  185. package/lib/ali-table/pipeline/features/autoRowSpan.js +65 -0
  186. package/lib/ali-table/pipeline/features/buildTree.d.ts +2 -0
  187. package/lib/ali-table/pipeline/features/buildTree.js +10 -0
  188. package/lib/ali-table/pipeline/features/columnCustom.d.ts +50 -0
  189. package/lib/ali-table/pipeline/features/columnCustom.js +602 -0
  190. package/lib/ali-table/pipeline/features/columnHover.d.ts +12 -0
  191. package/lib/ali-table/pipeline/features/columnHover.js +49 -0
  192. package/lib/ali-table/pipeline/features/columnRangeHover.d.ts +15 -0
  193. package/lib/ali-table/pipeline/features/columnRangeHover.js +81 -0
  194. package/lib/ali-table/pipeline/features/hiddenColumns.d.ts +6 -0
  195. package/lib/ali-table/pipeline/features/hiddenColumns.js +25 -0
  196. package/lib/ali-table/pipeline/features/index.d.ts +25 -0
  197. package/lib/ali-table/pipeline/features/index.js +109 -0
  198. package/lib/ali-table/pipeline/features/multiSelect.d.ts +27 -0
  199. package/lib/ali-table/pipeline/features/multiSelect.js +171 -0
  200. package/lib/ali-table/pipeline/features/pagination.d.ts +6 -0
  201. package/lib/ali-table/pipeline/features/pagination.js +39 -0
  202. package/lib/ali-table/pipeline/features/rowDetail.d.ts +28 -0
  203. package/lib/ali-table/pipeline/features/rowDetail.js +167 -0
  204. package/lib/ali-table/pipeline/features/rowGrouping.d.ts +14 -0
  205. package/lib/ali-table/pipeline/features/rowGrouping.js +156 -0
  206. package/lib/ali-table/pipeline/features/singleSelect.d.ts +23 -0
  207. package/lib/ali-table/pipeline/features/singleSelect.js +113 -0
  208. package/lib/ali-table/pipeline/features/tips.d.ts +2 -0
  209. package/lib/ali-table/pipeline/features/tips.js +58 -0
  210. package/lib/ali-table/pipeline/features/treeMode.d.ts +20 -0
  211. package/lib/ali-table/pipeline/features/treeMode.js +195 -0
  212. package/lib/ali-table/pipeline/features/treeSelect.d.ts +40 -0
  213. package/lib/ali-table/pipeline/features/treeSelect.js +299 -0
  214. package/lib/ali-table/pipeline/index.d.ts +3 -0
  215. package/lib/ali-table/pipeline/index.js +23 -0
  216. package/lib/ali-table/pipeline/pipeline.d.ts +78 -0
  217. package/lib/ali-table/pipeline/pipeline.js +185 -0
  218. package/lib/ali-table/useContext.d.ts +43 -0
  219. package/lib/ali-table/useContext.js +19 -0
  220. package/lib/ali-table/utils/applyTransforms.d.ts +6 -0
  221. package/lib/ali-table/utils/applyTransforms.js +13 -0
  222. package/lib/ali-table/utils/buildTree.d.ts +37 -0
  223. package/lib/ali-table/utils/buildTree.js +77 -0
  224. package/lib/ali-table/utils/collectNodes.d.ts +9 -0
  225. package/lib/ali-table/utils/collectNodes.js +40 -0
  226. package/lib/ali-table/utils/convertColumnsChoose.d.ts +5 -0
  227. package/lib/ali-table/utils/convertColumnsChoose.js +105 -0
  228. package/lib/ali-table/utils/exportTableAsExcel.d.ts +4 -0
  229. package/lib/ali-table/utils/exportTableAsExcel.js +139 -0
  230. package/lib/ali-table/utils/getTreeDepth.d.ts +3 -0
  231. package/lib/ali-table/utils/getTreeDepth.js +23 -0
  232. package/lib/ali-table/utils/groupBy.d.ts +1 -0
  233. package/lib/ali-table/utils/groupBy.js +17 -0
  234. package/lib/ali-table/utils/groupBy2.d.ts +1 -0
  235. package/lib/ali-table/utils/groupBy2.js +18 -0
  236. package/lib/ali-table/utils/index.d.ts +14 -0
  237. package/lib/ali-table/utils/index.js +104 -0
  238. package/lib/ali-table/utils/isLeafNode.d.ts +2 -0
  239. package/lib/ali-table/utils/isLeafNode.js +9 -0
  240. package/lib/ali-table/utils/layeredSort.d.ts +6 -0
  241. package/lib/ali-table/utils/layeredSort.js +29 -0
  242. package/lib/ali-table/utils/makeRecursiveMapper.d.ts +9 -0
  243. package/lib/ali-table/utils/makeRecursiveMapper.js +53 -0
  244. package/lib/ali-table/utils/mergeCellProps.d.ts +9 -0
  245. package/lib/ali-table/utils/mergeCellProps.js +60 -0
  246. package/lib/ali-table/utils/others.d.ts +11 -0
  247. package/lib/ali-table/utils/others.js +36 -0
  248. package/lib/ali-table/utils/proto.d.ts +21 -0
  249. package/lib/ali-table/utils/proto.js +73 -0
  250. package/lib/ali-table/utils/selected.d.ts +40 -0
  251. package/lib/ali-table/utils/selected.js +1069 -0
  252. package/lib/ali-table/utils/smartCompare.d.ts +9 -0
  253. package/lib/ali-table/utils/smartCompare.js +51 -0
  254. package/lib/ali-table/utils/traverseColumn.d.ts +11 -0
  255. package/lib/ali-table/utils/traverseColumn.js +68 -0
  256. package/lib/ali-table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
  257. package/lib/ali-table/utils/tree-data-helpers/StrictTreeDataHelper.js +105 -0
  258. package/lib/ali-table/utils/tree-data-helpers/TreeDataHelper.d.ts +25 -0
  259. package/lib/ali-table/utils/tree-data-helpers/TreeDataHelper.js +225 -0
  260. package/lib/grid-component/hooks/constant.d.ts +1 -0
  261. package/lib/grid-component/hooks/constant.js +3 -2
  262. package/lib/grid-component/type.d.ts +31 -12
  263. package/lib/group-component/TableContainerEdit.js +2 -6
  264. package/lib/group-component/hook/utils.d.ts +3 -1
  265. package/lib/index.d.ts +1 -1
  266. package/lib/index.js +2 -2
  267. package/lib/table-component/TableContainerEdit.js +2 -6
  268. package/lib/table-component/header/TableHeadCell2.js +1 -1
  269. package/lib/table-component/hook/utils.d.ts +4 -2
  270. package/lib/table-component/hook/utils.js +62 -1
  271. package/package.json +4 -1
@@ -0,0 +1,15 @@
1
+ import type { TablePipeline } from "./pipeline";
2
+ import type { Dispatch, SetStateAction } from "react";
3
+ import React from "react";
4
+ import './base-table/styles.scss';
5
+ import type { TableProps } from "../table-component";
6
+ import type { BaseTable } from "./base-table/table";
7
+ declare const Grid: React.ForwardRefExoticComponent<TableProps & {
8
+ isFullScreen: boolean;
9
+ setIsFullScreen: Dispatch<SetStateAction<boolean>>;
10
+ pipeline: TablePipeline;
11
+ originData: any[];
12
+ originColumns: any[];
13
+ setVisibleKeys: Dispatch<SetStateAction<any>>;
14
+ } & React.RefAttributes<BaseTable>>;
15
+ export default Grid;
@@ -0,0 +1,331 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { WebsiteBaseTable } from "./assets/WebsiteBaseTable";
3
+ import { useLocale } from "rc-master-ui/es/locale";
4
+ import React, { useContext } from "react";
5
+ import { Tooltip } from "react-tooltip";
6
+ // @ts-ignore
7
+ import "./base-table/styles.scss";
8
+ import { Toolbar } from 'rc-master-ui';
9
+ import classNames from "classnames";
10
+ import Pagination from "rc-master-ui/es/pagination";
11
+ import { Maximize, Minimize } from "becoxy-icons";
12
+ import { numericFormatter } from "react-numeric-component";
13
+ import { pageSizeOptions } from "../grid-component/hooks";
14
+ import ContextMenu from "../table-component/ContextMenu";
15
+ import { TableContext } from "./useContext";
16
+ import { ColumnsChoose } from "./pipeline/features/ColumnsChoose";
17
+ // const Grid = (props: GridProps) => {
18
+ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
19
+ const {
20
+ id,
21
+ t,
22
+ isFullScreen,
23
+ setIsFullScreen,
24
+ className: tableClassNames,
25
+ title,
26
+ showToolbar,
27
+ toolbarItems,
28
+ pagination,
29
+ infiniteScroll,
30
+ dataSource,
31
+ originData,
32
+ format,
33
+ locale,
34
+ fullScreen,
35
+ actionTemplate,
36
+ theme,
37
+ height,
38
+ minHeight,
39
+ pipeline,
40
+ contextMenuItems: propContextMenuItems,
41
+ contextMenuHidden,
42
+ contextMenuOpen,
43
+ recordDoubleClick,
44
+ contextMenuClick,
45
+ commandClick,
46
+ onRowStyles,
47
+ showColumnChoose,
48
+ originColumns,
49
+ columns,
50
+ groupColumns,
51
+ setVisibleKeys,
52
+ footerDataSource,
53
+ loading
54
+
55
+ // onRowFooterStyles,
56
+ // onRowHeaderStyles
57
+ } = props;
58
+ const prefix = 'ui-rc';
59
+ const stateKeyPager = 'pagination';
60
+ const [tableLocal] = useLocale('Table');
61
+ const [paginationLocal] = useLocale('Pagination');
62
+ const menuRef = React.useRef(null);
63
+ const {
64
+ windowSize
65
+ } = useContext(TableContext);
66
+ const [menuVisible, setMenuVisible] = React.useState(false);
67
+ const [selectedRowData, setSelectedRowData] = React.useState(undefined);
68
+ const [position, setPosition] = React.useState({
69
+ x: 0,
70
+ y: 0,
71
+ viewportWidth: windowSize.innerWidth,
72
+ viewportHeight: windowSize.innerHeight
73
+ });
74
+ const contextMenuItems = React.useMemo(() => {
75
+ if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
76
+ const hiddenItems = contextMenuHidden({
77
+ rowInfo: {
78
+ rowData: selectedRowData.rowData
79
+ },
80
+ field: selectedRowData.field
81
+ });
82
+ return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
83
+ }
84
+ if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
85
+ return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
86
+ }
87
+ return propContextMenuItems;
88
+ }, [propContextMenuItems, contextMenuHidden, selectedRowData]);
89
+ const onResizeEnd = () => {};
90
+ const onContextMenu = args => event => {
91
+ event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
92
+
93
+ setSelectedRowData(args);
94
+ contextMenuOpen?.({
95
+ rowInfo: {
96
+ rowData: args.rowData
97
+ },
98
+ field: args.field,
99
+ event
100
+ });
101
+
102
+ // Đợi DOM cập nhật và lấy kích thước menu
103
+ setTimeout(() => {
104
+ setMenuVisible(true);
105
+ const menuElement = menuRef.current; // Lấy menu từ DOM
106
+ const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
107
+ // const menuHeight = menuElement?.offsetHeight // Mặc định 450px nếu chưa render
108
+
109
+ // Điều chỉnh vị trí menu
110
+ let x = event.clientX;
111
+ let y = event.pageY;
112
+ const pageY = event.pageY;
113
+ if (x + menuWidth > windowSize.innerWidth) {
114
+ x = x - menuWidth - 10; // Cách cạnh phải 10px
115
+ }
116
+ if (pageY > windowSize.innerHeight) {
117
+ y = windowSize.innerHeight;
118
+ }
119
+ setPosition(prevState => ({
120
+ ...prevState,
121
+ x,
122
+ y
123
+ }));
124
+ }, 100);
125
+ };
126
+ React.useEffect(() => {
127
+ const handleClickOutside = event => {
128
+ const element = event.target;
129
+ const containerContextMenu = document.querySelector(".popup-context-menu");
130
+ const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
131
+ if (isInsideContainerContext) {
132
+ return;
133
+ } else {
134
+ setMenuVisible(false);
135
+ }
136
+ };
137
+ document.addEventListener('mousedown', handleClickOutside);
138
+ return () => {
139
+ document.removeEventListener('mousedown', handleClickOutside);
140
+ };
141
+ }, []);
142
+ const triggerChangeColumns = (nextColumn, _, nextVisibleKeys) => {
143
+ setVisibleKeys(nextVisibleKeys);
144
+ };
145
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
146
+ className: classNames(`${prefix}-grid ${tableClassNames}`, {
147
+ [`${prefix}-grid-light`]: !theme || theme.theme === 'light',
148
+ [`${prefix}-grid-dark`]: theme?.theme === 'dark'
149
+ }),
150
+ style: {
151
+ height: height ?? 700,
152
+ minHeight,
153
+ display: 'flex',
154
+ flexDirection: 'column'
155
+ }
156
+ }, (showToolbar !== false || fullScreen !== false || title) && /*#__PURE__*/React.createElement("div", {
157
+ className: classNames(`${prefix}-grid-top-toolbar`, {})
158
+ }, /*#__PURE__*/React.createElement("div", {
159
+ style: {
160
+ display: 'flex',
161
+ justifyContent: 'space-between',
162
+ alignItems: 'center'
163
+ }
164
+ }, /*#__PURE__*/React.createElement("div", {
165
+ style: {
166
+ flex: 1,
167
+ overflow: 'hidden'
168
+ }
169
+ }, /*#__PURE__*/React.createElement(Toolbar, {
170
+ items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
171
+ mode: 'scroll'
172
+ })), /*#__PURE__*/React.createElement("div", {
173
+ style: {
174
+ display: 'flex',
175
+ justifyContent: 'space-between',
176
+ alignItems: 'center',
177
+ gap: '.25rem'
178
+ }
179
+ }, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/React.createElement(Pagination, _extends({
180
+ showSizeChanger: true,
181
+ responsive: true,
182
+ size: 'small',
183
+ rootClassName: 'top-pagination',
184
+ showTotal: (totalItems, range) =>
185
+ // @ts-ignore
186
+ `${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
187
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
188
+ fontSize: 16,
189
+ onClick: () => {
190
+ setIsFullScreen(!isFullScreen);
191
+ },
192
+ "data-tooltip-id": `${id}-tooltip-content`,
193
+ "data-tooltip-content": locale?.table?.minimized || tableLocal?.minimized || 'Minimized'
194
+ }) : /*#__PURE__*/React.createElement(Maximize, {
195
+ fontSize: 16,
196
+ onClick: () => {
197
+ setIsFullScreen(!isFullScreen);
198
+ },
199
+ "data-tooltip-id": `${id}-tooltip-content`,
200
+ "data-tooltip-content": locale?.table?.fullScreen || tableLocal?.fullScreen || 'Full screen'
201
+ })), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
202
+ id: id ?? '',
203
+ locale: locale,
204
+ tableLocal: tableLocal,
205
+ columns: columns,
206
+ originColumns: originColumns,
207
+ t: t,
208
+ columnsGroup: groupColumns,
209
+ triggerChangeColumns: triggerChangeColumns
210
+ }))), /*#__PURE__*/React.createElement("div", {
211
+ style: {
212
+ textAlign: 'center'
213
+ }
214
+ }, typeof title === 'function' ? title?.(dataSource) : title)), /*#__PURE__*/React.createElement(WebsiteBaseTable, _extends({
215
+ ref: ref,
216
+ id: id,
217
+ commandClick: commandClick,
218
+ isLoading: loading,
219
+ useVirtual: {
220
+ header: false,
221
+ vertical: true,
222
+ horizontal: true
223
+ },
224
+ hasStickyScroll: true,
225
+ isStickyFooter: true,
226
+ isStickyHeader: true,
227
+ stickyBottom: 0,
228
+ stickyTop: 0,
229
+ defaultColumnWidth: 100,
230
+ originData: originData,
231
+ format: format
232
+
233
+ // estimatedRowHeight={50}
234
+ ,
235
+ useOuterBorder: true
236
+ // style={{ height: 700, overflow: 'auto' }}
237
+ ,
238
+ style: minHeight ? {
239
+ flex: 1,
240
+ overflow: 'auto'
241
+ } : {
242
+ overflow: 'auto'
243
+ }
244
+
245
+ // columnResizeMode={'onChange'}
246
+ ,
247
+ onResizeEnd: onResizeEnd
248
+ }, pipeline.getProps(), {
249
+ getRowProps: (row, rowIndex) => {
250
+ const prevRowProps = pipeline.getProps().getRowProps?.(row, rowIndex);
251
+ const rowStyle = onRowStyles ? typeof onRowStyles === 'function' ? onRowStyles(row) : onRowStyles : undefined;
252
+ return {
253
+ ...prevRowProps,
254
+ className: classNames(``, {
255
+ [`${prefix}-grid-row-parent`]: row.children && row.children.length > 0 || Array.isArray(row.children)
256
+ }),
257
+ style: {
258
+ ...prevRowProps?.style,
259
+ ...rowStyle
260
+ },
261
+ onContextMenu: e => {
262
+ if (contextMenuItems && contextMenuItems.length) {
263
+ const cell = e.target.closest('[data-col-key]');
264
+ const colKey = cell?.getAttribute('data-col-key');
265
+ onContextMenu?.({
266
+ rowData: row,
267
+ field: colKey
268
+ })(e);
269
+ }
270
+ },
271
+ onDoubleClick: e => {
272
+ recordDoubleClick?.({
273
+ e,
274
+ rowData: row,
275
+ rowIndex: rowIndex
276
+ });
277
+ }
278
+ };
279
+ },
280
+ footerDataSource: footerDataSource
281
+ })), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination, _extends({
282
+ pageSizeOptions: pageSizeOptions,
283
+ rootClassName: 'pagination-template',
284
+ showSizeChanger: true,
285
+ size: 'small',
286
+ total: pagination.total,
287
+ pageSize: pagination.onChange ? pagination.pageSize : pipeline.getStateAtKey(stateKeyPager)?.pageSize ?? pageSizeOptions[0],
288
+ showTotal: (totalItems, range) => `${numericFormatter((range[0] ?? 0).toString(), {
289
+ thousandSeparator: '.'
290
+ })}-${numericFormatter((range[1] ?? 0).toString(), {
291
+ thousandSeparator: '.'
292
+ })} / ${numericFormatter((totalItems ?? 0).toString(), {
293
+ thousandSeparator: '.'
294
+ })} ${pagination?.locale?.items || paginationLocal?.items || ''}`,
295
+ current: pagination.onChange ? pagination.currentPage : pipeline.getStateAtKey(stateKeyPager)?.currentPage
296
+ }, pagination, {
297
+ onChange: (page, pageSize1) => {
298
+ if (pagination.onChange) {
299
+ pagination.onChange(page, pageSize1);
300
+ } else {
301
+ pipeline.setStateAtKey(stateKeyPager, {
302
+ currentPage: page,
303
+ pageSize: pageSize1
304
+ });
305
+ }
306
+ },
307
+ responsive: true
308
+ }))), /*#__PURE__*/React.createElement(Tooltip, {
309
+ id: `${id}-tooltip-content`,
310
+ style: {
311
+ zIndex: 1999,
312
+ maxWidth: 450
313
+ },
314
+ delayShow: 100
315
+ }), /*#__PURE__*/React.createElement(Tooltip, {
316
+ id: `${id}-tooltip-error`,
317
+ style: {
318
+ zIndex: 1999,
319
+ maxWidth: 450
320
+ }
321
+ }), menuVisible && /*#__PURE__*/React.createElement(ContextMenu, {
322
+ open: menuVisible,
323
+ pos: position,
324
+ setOpen: setMenuVisible,
325
+ menuRef: menuRef,
326
+ contextMenuItems: contextMenuItems,
327
+ contextMenuClick: contextMenuClick,
328
+ rowData: selectedRowData
329
+ }));
330
+ });
331
+ export default Grid;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import './base-table/styles.scss';
3
+ import type { TableProps } from "../table-component";
4
+ declare const InternalTable: <RecordType extends object>(props: TableProps<RecordType>) => React.JSX.Element;
5
+ export default InternalTable;
@@ -0,0 +1,274 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { features, useTablePipeline } from "./pipeline";
3
+ import * as fusion from '@alifd/next';
4
+ import { useLocale } from "rc-master-ui/es/locale";
5
+ import { faker } from "@faker-js/faker";
6
+ import React from "react";
7
+ import "./base-table/styles.scss";
8
+ import { addRowIdArray, filterDataByColumns, groupArrayByColumns, isTreeArray, sortByType, sumFields } from "../table-component/hook/utils";
9
+ import { CustomProvider, ConfigProvider } from 'rc-master-ui';
10
+ import { getLocale, getLocales } from "../locale/useLocale";
11
+ import { TableContext } from "./useContext";
12
+ import Grid from "./Grid";
13
+ import { Modal } from "antd";
14
+ import { getParentKeysLarge, getRowsByKeysKeepTreeOrder } from "./utils/selected";
15
+ // import { collectNodes } from "./utils"
16
+ // import { filterColumnsByField } from "./utils/convertColumnsChoose"
17
+
18
+ const InternalTable = props => {
19
+ const {
20
+ t,
21
+ columns: propColumns,
22
+ dataSource,
23
+ allowFiltering,
24
+ allowSortering,
25
+ groupAble,
26
+ groupColumns,
27
+ groupSetting,
28
+ lang,
29
+ pagination,
30
+ locale,
31
+ fullScreenTitle,
32
+ wrapSettings,
33
+ ignoreAccents,
34
+ rowSelected,
35
+ selectionSettings,
36
+ expandable,
37
+ sortMultiple,
38
+ onFilter,
39
+ onSorter,
40
+ footerDataSource,
41
+ summary,
42
+ ...rest
43
+ } = props;
44
+ const prefix = 'ui-rc';
45
+ const rowKey = 'rowId';
46
+ const childrenKey = 'children';
47
+ const [tableLocal] = useLocale('Table');
48
+ const id = React.useMemo(() => {
49
+ return faker.string.alpha(20);
50
+ }, []);
51
+ const language = React.useMemo(() => {
52
+ return getLocale(lang);
53
+ }, [lang]);
54
+ const languages = React.useMemo(() => {
55
+ return getLocales(lang);
56
+ }, [lang]);
57
+ const getWindowSize = () => {
58
+ const {
59
+ innerWidth,
60
+ innerHeight
61
+ } = window;
62
+ return {
63
+ innerWidth,
64
+ innerHeight
65
+ };
66
+ };
67
+ const [windowSize, setWindowSize] = React.useState(getWindowSize());
68
+ React.useEffect(() => {
69
+ const handleWindowResize = () => {
70
+ setWindowSize(getWindowSize());
71
+ };
72
+ document.addEventListener('resize', handleWindowResize);
73
+ return () => {
74
+ document.removeEventListener('resize', handleWindowResize);
75
+ };
76
+ }, []);
77
+ const isDataTree = React.useMemo(() => {
78
+ return isTreeArray(dataSource);
79
+ }, [dataSource]);
80
+ const [visibleKeys, setVisibleKeys] = React.useState(undefined);
81
+ const [filterState, setFilterState] = React.useState(undefined);
82
+ const [sortState, setSortState] = React.useState(undefined);
83
+ const columns = React.useMemo(() => {
84
+ return sortByType(propColumns);
85
+ }, [propColumns]);
86
+ const convertData = React.useMemo(() => {
87
+ if (groupAble && groupSetting && groupSetting.client !== false) {
88
+ return groupArrayByColumns(dataSource, groupColumns);
89
+ }
90
+ return addRowIdArray(dataSource);
91
+ }, [dataSource, groupAble, groupColumns, groupSetting]);
92
+ const mergedData = React.useMemo(() => {
93
+ if (sortState || filterState) {
94
+ return filterDataByColumns(convertData, filterState ?? [], sortState ?? [], [], ignoreAccents);
95
+ }
96
+ return convertData;
97
+ }, [convertData, filterState, ignoreAccents, sortState]);
98
+ const footerData = React.useMemo(() => {
99
+ if (!summary) {
100
+ return undefined;
101
+ }
102
+ if (footerDataSource) {
103
+ return footerDataSource;
104
+ }
105
+ const a = sumFields(columns, dataSource, childrenKey);
106
+ return [a];
107
+ }, [columns, dataSource, footerDataSource, summary]);
108
+ const expandAllKeys = React.useMemo(() => {
109
+ if (expandable?.defaultExpandAllRows && isDataTree) {
110
+ return getParentKeysLarge(convertData, rowKey, childrenKey);
111
+ }
112
+ return undefined;
113
+ }, [expandable?.defaultExpandAllRows, convertData, isDataTree]);
114
+ const [isFullScreen, setIsFullScreen] = React.useState(false);
115
+ const pipeline = useTablePipeline({
116
+ components: fusion
117
+ }).input({
118
+ dataSource: mergedData,
119
+ columns
120
+ }).primaryKey(rowKey)
121
+ // .mapDataSource((dta) => collectNodes(dta, 'pre'))
122
+ .snapshot('flat').use(features.hiddenColumns({
123
+ columns,
124
+ visibleKeys
125
+ })).use(features.treeSelect({
126
+ tree: mergedData,
127
+ value: selectionSettings?.selectedRowKeys,
128
+ defaultValue: selectionSettings?.defaultSelectedRowKeys,
129
+ // rootKey: selectionSettings?.hideSelectAll,
130
+ rootKey: selectionSettings?.hideSelectAll || selectionSettings?.type === 'single' ? undefined : 'root',
131
+ // rootKey: 'root',
132
+ checkStrictly: selectionSettings?.checkStrictly,
133
+ // checkStrictly: true,
134
+ checkedStrategy: isDataTree ? selectionSettings?.checkedStrategy : 'all',
135
+ // checkedStrategy: 'parent',
136
+
137
+ mode: selectionSettings?.mode,
138
+ type: selectionSettings?.type,
139
+ highlightRowWhenSelected: true,
140
+ isDisabled(row) {
141
+ return !!selectionSettings?.getCheckboxProps?.(row)?.disabled;
142
+ },
143
+ checkboxColumn: {
144
+ lock: true
145
+ },
146
+ clickArea: selectionSettings?.checkboxOnly ? 'checkbox' : 'row',
147
+ // clickArea: 'row',
148
+ onChange: (nextValue, rowData, type) => {
149
+ const rs = getRowsByKeysKeepTreeOrder(nextValue, mergedData ?? [], rowKey);
150
+ rowSelected?.({
151
+ type,
152
+ rowData,
153
+ selected: rs
154
+ });
155
+ }
156
+
157
+ // clickArea: 'checkbox'
158
+ })).use(features.treeMode({
159
+ clickArea: 'icon',
160
+ stopClickEventPropagation: true,
161
+ expandIconColumnIndex: expandable?.expandIconColumnIndex,
162
+ defaultOpenKeys: expandAllKeys ?? expandable?.defaultExpandedRowKeys
163
+ })).use(features.columnCustom({
164
+ id,
165
+ t,
166
+ columns,
167
+ mode: sortMultiple !== false ? 'multiple' : 'single',
168
+ dataSource: mergedData,
169
+ columnResizeMode: 'onChange',
170
+ disableUserSelectWhenResizing: true,
171
+ allowFiltering,
172
+ allowSortering,
173
+ tableLocal,
174
+ locale,
175
+ prefix,
176
+ wrapSettings,
177
+ ignoreAccents,
178
+ currentPage: pagination ? pagination?.currentPage : undefined,
179
+ pageSize: pagination ? pagination?.pageSize : undefined,
180
+ onFilter(val) {
181
+ // const rs =
182
+
183
+ if (onFilter) {
184
+ onFilter(val);
185
+ } else {
186
+ setFilterState(val);
187
+ }
188
+ },
189
+ onSorter(val) {
190
+ if (onSorter) {
191
+ onSorter(val);
192
+ } else {
193
+ setSortState(val);
194
+ }
195
+ }
196
+ })).use(features.paginationFeature({
197
+ pagination
198
+ }));
199
+
200
+ // const onResizeEnd = (args: any[]) => {
201
+
202
+ // }
203
+
204
+ return /*#__PURE__*/React.createElement(ConfigProvider, {
205
+ locale: language
206
+ }, /*#__PURE__*/React.createElement(CustomProvider, {
207
+ locale: languages
208
+ }, /*#__PURE__*/React.createElement(TableContext.Provider, {
209
+ value: {
210
+ prefix,
211
+ id,
212
+ rowKey,
213
+ dataSource: mergedData,
214
+ originData: convertData,
215
+ windowSize,
216
+ lang,
217
+ locale
218
+ }
219
+ }, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
220
+ id: id,
221
+ isFullScreen: isFullScreen,
222
+ pagination: pagination,
223
+ setIsFullScreen: setIsFullScreen,
224
+ pipeline: pipeline
225
+ }, pipeline.getProps(), {
226
+ originData: convertData,
227
+ originColumns: columns,
228
+ groupColumns: groupColumns,
229
+ setVisibleKeys: setVisibleKeys,
230
+ footerDataSource: footerData
231
+ })), /*#__PURE__*/React.createElement(Modal, {
232
+ open: isFullScreen,
233
+ footer: null,
234
+ centered: true,
235
+ closable: true,
236
+ width: '100%',
237
+ style: {
238
+ maxWidth: '100%',
239
+ height: '100%'
240
+ },
241
+ onCancel: () => setIsFullScreen(false),
242
+ styles: {
243
+ content: {
244
+ height: '100vh',
245
+ borderRadius: 0,
246
+ padding: '15px 10px'
247
+ },
248
+ wrapper: {
249
+ zIndex: 1050
250
+ }
251
+ },
252
+ title: /*#__PURE__*/React.createElement("div", {
253
+ style: {
254
+ minHeight: 24
255
+ }
256
+ }, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
257
+ destroyOnClose: true
258
+ }, /*#__PURE__*/React.createElement("div", {
259
+ style: {}
260
+ }, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
261
+ id: id,
262
+ isFullScreen: isFullScreen,
263
+ setIsFullScreen: setIsFullScreen,
264
+ pipeline: pipeline,
265
+ pagination: pagination
266
+ }, pipeline.getProps(), {
267
+ originData: convertData,
268
+ originColumns: columns,
269
+ groupColumns: groupColumns,
270
+ setVisibleKeys: setVisibleKeys,
271
+ footerDataSource: footerData
272
+ })))))));
273
+ };
274
+ export default InternalTable;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { BaseTableProps } from '../base-table/table';
3
+ import { BaseTable } from '../base-table/table';
4
+ export declare const WebsiteBaseTable: React.ForwardRefExoticComponent<BaseTableProps & React.RefAttributes<BaseTable>>;
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import cx from 'classnames';
3
+ import React from 'react';
4
+ import styled from 'styled-components';
5
+ import { BaseTable } from "../base-table/table";
6
+ const DarkSupportBaseTable = styled(BaseTable).withConfig({
7
+ displayName: "DarkSupportBaseTable",
8
+ componentId: "es-grid-template__sc-4ltmbz-0"
9
+ })(["", ";&.dark{--bgcolor:#333;--header-bgcolor:#45494f;--hover-bgcolor:#46484a;--header-hover-bgcolor:#606164;--highlight-bgcolor:#191a1b;--header-highlight-bgcolor:#191a1b;--color:#dadde1;--header-color:#dadde1;--lock-shadow:rgb(37 37 37 / 0.5) 0 0 6px 2px;--border-color:#3c4045;}"], props => props.css);
10
+ export const WebsiteBaseTable = /*#__PURE__*/React.forwardRef((props, ref) => {
11
+ const isDarkTheme = false;
12
+ return /*#__PURE__*/React.createElement(DarkSupportBaseTable, _extends({
13
+ ref: ref,
14
+ className: cx({
15
+ dark: isDarkTheme
16
+ }, props.className)
17
+ }, props));
18
+ });