@hi-ui/schema-editable-table 4.0.0-experimental.1

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 (284) hide show
  1. package/README.md +11 -0
  2. package/lib/cjs/body/index.js +110 -0
  3. package/lib/cjs/body/wrapper.js +132 -0
  4. package/lib/cjs/cell/aggregated.js +76 -0
  5. package/lib/cjs/cell/dependency.js +97 -0
  6. package/lib/cjs/cell/editing.js +89 -0
  7. package/lib/cjs/cell/footer.js +64 -0
  8. package/lib/cjs/cell/header.js +76 -0
  9. package/lib/cjs/cell/index.js +204 -0
  10. package/lib/cjs/const.js +35 -0
  11. package/lib/cjs/container/base.js +39 -0
  12. package/lib/cjs/container/bottom.js +86 -0
  13. package/lib/cjs/container/col-group.js +98 -0
  14. package/lib/cjs/container/column-virtual.js +53 -0
  15. package/lib/cjs/container/ctx.js +32 -0
  16. package/lib/cjs/container/full-virtual.js +61 -0
  17. package/lib/cjs/container/hooks.js +102 -0
  18. package/lib/cjs/container/index.js +69 -0
  19. package/lib/cjs/container/row-virtual.js +50 -0
  20. package/lib/cjs/container/wrapper.js +97 -0
  21. package/lib/cjs/ctx.js +32 -0
  22. package/lib/cjs/features/_overrides/aggregated.js +44 -0
  23. package/lib/cjs/features/_overrides/getter.js +61 -0
  24. package/lib/cjs/features/_overrides/grouping.js +40 -0
  25. package/lib/cjs/features/_overrides/overrides.js +43 -0
  26. package/lib/cjs/features/_overrides/row-selection.js +140 -0
  27. package/lib/cjs/features/async-data/getter.js +150 -0
  28. package/lib/cjs/features/async-data/normal.js +145 -0
  29. package/lib/cjs/features/async-data/use-data-fetcher.js +40 -0
  30. package/lib/cjs/features/async-data/use-reset-data.js +91 -0
  31. package/lib/cjs/features/column-grouping/get-grouping-config.js +27 -0
  32. package/lib/cjs/features/column-grouping/use-opts.js +42 -0
  33. package/lib/cjs/features/column-state.js +57 -0
  34. package/lib/cjs/features/filter/bridge.js +114 -0
  35. package/lib/cjs/features/filter/filter-fns/date.js +34 -0
  36. package/lib/cjs/features/filter/filter-fns/index.js +23 -0
  37. package/lib/cjs/features/filter/get-filter-config.js +61 -0
  38. package/lib/cjs/features/filter/index.js +29 -0
  39. package/lib/cjs/features/filter/use-opts.js +88 -0
  40. package/lib/cjs/features/header-actions/components/column-collapsing.js +74 -0
  41. package/lib/cjs/features/header-actions/get-actions.js +77 -0
  42. package/lib/cjs/features/pagination/component.js +89 -0
  43. package/lib/cjs/features/pagination/use-opts.js +98 -0
  44. package/lib/cjs/features/pagination/use-state.js +44 -0
  45. package/lib/cjs/features/row-controller.js +265 -0
  46. package/lib/cjs/features/row-edit/actions.js +65 -0
  47. package/lib/cjs/features/row-edit/hooks.js +29 -0
  48. package/lib/cjs/features/row-expanding/use-opts.js +39 -0
  49. package/lib/cjs/features/row-expanding/wrapper.js +74 -0
  50. package/lib/cjs/features/row-operation/buttons.js +91 -0
  51. package/lib/cjs/features/row-operation/cell.js +43 -0
  52. package/lib/cjs/features/row-operation/index.js +21 -0
  53. package/lib/cjs/features/row-operation/wrapper.js +114 -0
  54. package/lib/cjs/features/row-selection/cell.js +114 -0
  55. package/lib/cjs/features/row-selection/const.js +16 -0
  56. package/lib/cjs/features/row-selection/hooks/index.js +29 -0
  57. package/lib/cjs/features/row-selection/hooks/use-click-select.js +70 -0
  58. package/lib/cjs/features/row-selection/hooks/use-opts.js +120 -0
  59. package/lib/cjs/features/row-selection/hooks/use-set-selected-row-keys.js +48 -0
  60. package/lib/cjs/features/row-selection/hooks/use-sync-hover-style.js +86 -0
  61. package/lib/cjs/features/row-selection/indicator.js +173 -0
  62. package/lib/cjs/features/row-selection/wrapper.js +119 -0
  63. package/lib/cjs/features/setting-bridge.js +56 -0
  64. package/lib/cjs/features/sorter/bridge.js +65 -0
  65. package/lib/cjs/features/sorter/get-sorter-config.js +46 -0
  66. package/lib/cjs/features/sorter/index.js +29 -0
  67. package/lib/cjs/features/sorter/use-opts.js +81 -0
  68. package/lib/cjs/field-bridge/bridge.js +104 -0
  69. package/lib/cjs/field-bridge/index.js +58 -0
  70. package/lib/cjs/field-bridge/toolbar.js +53 -0
  71. package/lib/cjs/footer/index.js +99 -0
  72. package/lib/cjs/footer/use-first-cell-patch.js +42 -0
  73. package/lib/cjs/header/index.js +134 -0
  74. package/lib/cjs/header/validate.js +69 -0
  75. package/lib/cjs/hooks/use-get-fields-value.js +62 -0
  76. package/lib/cjs/hooks/use-global-actions.js +65 -0
  77. package/lib/cjs/hooks/use-global-static.js +158 -0
  78. package/lib/cjs/hooks/use-initial-render.js +30 -0
  79. package/lib/cjs/hooks/use-inner-ctx.js +105 -0
  80. package/lib/cjs/hooks/use-props.js +108 -0
  81. package/lib/cjs/hooks/use-table-columns.js +76 -0
  82. package/lib/cjs/hooks/use-table-meta.js +57 -0
  83. package/lib/cjs/hooks/use-update.js +57 -0
  84. package/lib/cjs/index.js +66 -0
  85. package/lib/cjs/index.scss.js +18 -0
  86. package/lib/cjs/table.js +263 -0
  87. package/lib/cjs/utils/cls.js +19 -0
  88. package/lib/cjs/utils/fixed.js +53 -0
  89. package/lib/cjs/utils/grouping.js +42 -0
  90. package/lib/cjs/utils/state-merge.js +43 -0
  91. package/lib/esm/body/index.js +98 -0
  92. package/lib/esm/body/wrapper.js +120 -0
  93. package/lib/esm/cell/aggregated.js +64 -0
  94. package/lib/esm/cell/dependency.js +90 -0
  95. package/lib/esm/cell/editing.js +76 -0
  96. package/lib/esm/cell/footer.js +52 -0
  97. package/lib/esm/cell/header.js +63 -0
  98. package/lib/esm/cell/index.js +192 -0
  99. package/lib/esm/const.js +24 -0
  100. package/lib/esm/container/base.js +27 -0
  101. package/lib/esm/container/bottom.js +74 -0
  102. package/lib/esm/container/col-group.js +85 -0
  103. package/lib/esm/container/column-virtual.js +41 -0
  104. package/lib/esm/container/ctx.js +19 -0
  105. package/lib/esm/container/full-virtual.js +49 -0
  106. package/lib/esm/container/hooks.js +95 -0
  107. package/lib/esm/container/index.js +57 -0
  108. package/lib/esm/container/row-virtual.js +38 -0
  109. package/lib/esm/container/wrapper.js +83 -0
  110. package/lib/esm/ctx.js +17 -0
  111. package/lib/esm/features/_overrides/aggregated.js +39 -0
  112. package/lib/esm/features/_overrides/getter.js +56 -0
  113. package/lib/esm/features/_overrides/grouping.js +35 -0
  114. package/lib/esm/features/_overrides/overrides.js +38 -0
  115. package/lib/esm/features/_overrides/row-selection.js +135 -0
  116. package/lib/esm/features/async-data/getter.js +143 -0
  117. package/lib/esm/features/async-data/normal.js +133 -0
  118. package/lib/esm/features/async-data/use-data-fetcher.js +34 -0
  119. package/lib/esm/features/async-data/use-reset-data.js +79 -0
  120. package/lib/esm/features/column-grouping/get-grouping-config.js +22 -0
  121. package/lib/esm/features/column-grouping/use-opts.js +36 -0
  122. package/lib/esm/features/column-state.js +51 -0
  123. package/lib/esm/features/filter/bridge.js +102 -0
  124. package/lib/esm/features/filter/filter-fns/date.js +28 -0
  125. package/lib/esm/features/filter/filter-fns/index.js +18 -0
  126. package/lib/esm/features/filter/get-filter-config.js +56 -0
  127. package/lib/esm/features/filter/index.js +24 -0
  128. package/lib/esm/features/filter/use-opts.js +82 -0
  129. package/lib/esm/features/header-actions/components/column-collapsing.js +62 -0
  130. package/lib/esm/features/header-actions/get-actions.js +65 -0
  131. package/lib/esm/features/pagination/component.js +77 -0
  132. package/lib/esm/features/pagination/use-opts.js +91 -0
  133. package/lib/esm/features/pagination/use-state.js +39 -0
  134. package/lib/esm/features/row-controller.js +253 -0
  135. package/lib/esm/features/row-edit/actions.js +53 -0
  136. package/lib/esm/features/row-edit/hooks.js +24 -0
  137. package/lib/esm/features/row-expanding/use-opts.js +33 -0
  138. package/lib/esm/features/row-expanding/wrapper.js +62 -0
  139. package/lib/esm/features/row-operation/buttons.js +79 -0
  140. package/lib/esm/features/row-operation/cell.js +31 -0
  141. package/lib/esm/features/row-operation/index.js +16 -0
  142. package/lib/esm/features/row-operation/wrapper.js +100 -0
  143. package/lib/esm/features/row-selection/cell.js +101 -0
  144. package/lib/esm/features/row-selection/const.js +11 -0
  145. package/lib/esm/features/row-selection/hooks/index.js +24 -0
  146. package/lib/esm/features/row-selection/hooks/use-click-select.js +65 -0
  147. package/lib/esm/features/row-selection/hooks/use-opts.js +114 -0
  148. package/lib/esm/features/row-selection/hooks/use-set-selected-row-keys.js +43 -0
  149. package/lib/esm/features/row-selection/hooks/use-sync-hover-style.js +81 -0
  150. package/lib/esm/features/row-selection/indicator.js +159 -0
  151. package/lib/esm/features/row-selection/wrapper.js +107 -0
  152. package/lib/esm/features/setting-bridge.js +50 -0
  153. package/lib/esm/features/sorter/bridge.js +53 -0
  154. package/lib/esm/features/sorter/get-sorter-config.js +41 -0
  155. package/lib/esm/features/sorter/index.js +24 -0
  156. package/lib/esm/features/sorter/use-opts.js +75 -0
  157. package/lib/esm/field-bridge/bridge.js +92 -0
  158. package/lib/esm/field-bridge/index.js +44 -0
  159. package/lib/esm/field-bridge/toolbar.js +41 -0
  160. package/lib/esm/footer/index.js +87 -0
  161. package/lib/esm/footer/use-first-cell-patch.js +37 -0
  162. package/lib/esm/header/index.js +121 -0
  163. package/lib/esm/header/validate.js +64 -0
  164. package/lib/esm/hooks/use-get-fields-value.js +56 -0
  165. package/lib/esm/hooks/use-global-actions.js +60 -0
  166. package/lib/esm/hooks/use-global-static.js +152 -0
  167. package/lib/esm/hooks/use-initial-render.js +18 -0
  168. package/lib/esm/hooks/use-inner-ctx.js +100 -0
  169. package/lib/esm/hooks/use-props.js +102 -0
  170. package/lib/esm/hooks/use-table-columns.js +70 -0
  171. package/lib/esm/hooks/use-table-meta.js +51 -0
  172. package/lib/esm/hooks/use-update.js +52 -0
  173. package/lib/esm/index.js +38 -0
  174. package/lib/esm/index.scss.js +13 -0
  175. package/lib/esm/table.js +251 -0
  176. package/lib/esm/utils/cls.js +13 -0
  177. package/lib/esm/utils/fixed.js +48 -0
  178. package/lib/esm/utils/grouping.js +36 -0
  179. package/lib/esm/utils/state-merge.js +37 -0
  180. package/lib/types/body/index.d.ts +14 -0
  181. package/lib/types/body/wrapper.d.ts +18 -0
  182. package/lib/types/cell/aggregated.d.ts +35 -0
  183. package/lib/types/cell/custom.d.ts +19 -0
  184. package/lib/types/cell/dependency.d.ts +47 -0
  185. package/lib/types/cell/editing.d.ts +8 -0
  186. package/lib/types/cell/footer.d.ts +5 -0
  187. package/lib/types/cell/header.d.ts +5 -0
  188. package/lib/types/cell/index.d.ts +6 -0
  189. package/lib/types/const.d.ts +11 -0
  190. package/lib/types/container/base.d.ts +2 -0
  191. package/lib/types/container/bottom.d.ts +20 -0
  192. package/lib/types/container/col-group.d.ts +11 -0
  193. package/lib/types/container/column-virtual.d.ts +7 -0
  194. package/lib/types/container/ctx.d.ts +23 -0
  195. package/lib/types/container/full-virtual.d.ts +8 -0
  196. package/lib/types/container/hooks.d.ts +13 -0
  197. package/lib/types/container/index.d.ts +17 -0
  198. package/lib/types/container/row-virtual.d.ts +7 -0
  199. package/lib/types/container/type.d.ts +17 -0
  200. package/lib/types/container/wrapper.d.ts +12 -0
  201. package/lib/types/ctx.d.ts +41 -0
  202. package/lib/types/features/_overrides/aggregated.d.ts +2 -0
  203. package/lib/types/features/_overrides/getter.d.ts +2 -0
  204. package/lib/types/features/_overrides/grouping.d.ts +7 -0
  205. package/lib/types/features/_overrides/index.d.ts +5 -0
  206. package/lib/types/features/_overrides/overrides.d.ts +2 -0
  207. package/lib/types/features/_overrides/row-selection.d.ts +2 -0
  208. package/lib/types/features/async-data/getter.d.ts +9 -0
  209. package/lib/types/features/async-data/group.d.ts +1 -0
  210. package/lib/types/features/async-data/index.d.ts +6 -0
  211. package/lib/types/features/async-data/normal.d.ts +48 -0
  212. package/lib/types/features/async-data/type.d.ts +22 -0
  213. package/lib/types/features/async-data/use-data-fetcher.d.ts +22 -0
  214. package/lib/types/features/async-data/use-reset-data.d.ts +14 -0
  215. package/lib/types/features/column-grouping/get-grouping-config.d.ts +2 -0
  216. package/lib/types/features/column-grouping/index.d.ts +3 -0
  217. package/lib/types/features/column-grouping/use-opts.d.ts +12 -0
  218. package/lib/types/features/column-state.d.ts +15 -0
  219. package/lib/types/features/filter/bridge.d.ts +9 -0
  220. package/lib/types/features/filter/filter-fns/date.d.ts +6 -0
  221. package/lib/types/features/filter/filter-fns/index.d.ts +6 -0
  222. package/lib/types/features/filter/get-filter-config.d.ts +4 -0
  223. package/lib/types/features/filter/index.d.ts +8 -0
  224. package/lib/types/features/filter/use-opts.d.ts +62 -0
  225. package/lib/types/features/header-actions/components/column-collapsing.d.ts +4 -0
  226. package/lib/types/features/header-actions/get-actions.d.ts +13 -0
  227. package/lib/types/features/header-actions/index.d.ts +3 -0
  228. package/lib/types/features/header-actions/type.d.ts +20 -0
  229. package/lib/types/features/pagination/component.d.ts +15 -0
  230. package/lib/types/features/pagination/index.d.ts +4 -0
  231. package/lib/types/features/pagination/use-opts.d.ts +14 -0
  232. package/lib/types/features/pagination/use-state.d.ts +11 -0
  233. package/lib/types/features/row-controller.d.ts +101 -0
  234. package/lib/types/features/row-edit/actions.d.ts +12 -0
  235. package/lib/types/features/row-edit/hooks.d.ts +1 -0
  236. package/lib/types/features/row-edit/index.d.ts +2 -0
  237. package/lib/types/features/row-expanding/index.d.ts +3 -0
  238. package/lib/types/features/row-expanding/use-opts.d.ts +12 -0
  239. package/lib/types/features/row-expanding/wrapper.d.ts +11 -0
  240. package/lib/types/features/row-operation/buttons.d.ts +41 -0
  241. package/lib/types/features/row-operation/cell.d.ts +6 -0
  242. package/lib/types/features/row-operation/index.d.ts +18 -0
  243. package/lib/types/features/row-operation/wrapper.d.ts +3 -0
  244. package/lib/types/features/row-selection/cell.d.ts +62 -0
  245. package/lib/types/features/row-selection/const.d.ts +1 -0
  246. package/lib/types/features/row-selection/hooks/index.d.ts +6 -0
  247. package/lib/types/features/row-selection/hooks/use-click-select.d.ts +1 -0
  248. package/lib/types/features/row-selection/hooks/use-opts.d.ts +15 -0
  249. package/lib/types/features/row-selection/hooks/use-set-selected-row-keys.d.ts +9 -0
  250. package/lib/types/features/row-selection/hooks/use-sync-hover-style.d.ts +5 -0
  251. package/lib/types/features/row-selection/index.d.ts +7 -0
  252. package/lib/types/features/row-selection/indicator.d.ts +8 -0
  253. package/lib/types/features/row-selection/wrapper.d.ts +9 -0
  254. package/lib/types/features/setting-bridge.d.ts +14 -0
  255. package/lib/types/features/sorter/bridge.d.ts +8 -0
  256. package/lib/types/features/sorter/get-sorter-config.d.ts +7 -0
  257. package/lib/types/features/sorter/index.d.ts +8 -0
  258. package/lib/types/features/sorter/use-opts.d.ts +71 -0
  259. package/lib/types/field-bridge/bridge.d.ts +18 -0
  260. package/lib/types/field-bridge/index.d.ts +11 -0
  261. package/lib/types/field-bridge/toolbar.d.ts +9 -0
  262. package/lib/types/footer/index.d.ts +6 -0
  263. package/lib/types/footer/use-first-cell-patch.d.ts +1 -0
  264. package/lib/types/header/index.d.ts +17 -0
  265. package/lib/types/header/validate.d.ts +10 -0
  266. package/lib/types/hooks/use-get-fields-value.d.ts +14 -0
  267. package/lib/types/hooks/use-global-actions.d.ts +24 -0
  268. package/lib/types/hooks/use-global-static.d.ts +83 -0
  269. package/lib/types/hooks/use-initial-render.d.ts +1 -0
  270. package/lib/types/hooks/use-inner-ctx.d.ts +12 -0
  271. package/lib/types/hooks/use-props.d.ts +109 -0
  272. package/lib/types/hooks/use-table-columns.d.ts +11 -0
  273. package/lib/types/hooks/use-table-meta.d.ts +15 -0
  274. package/lib/types/hooks/use-update.d.ts +11 -0
  275. package/lib/types/index.d.ts +32 -0
  276. package/lib/types/table.d.ts +152 -0
  277. package/lib/types/utils/cls.d.ts +4 -0
  278. package/lib/types/utils/fixed.d.ts +11 -0
  279. package/lib/types/utils/grouping.d.ts +6 -0
  280. package/lib/types/utils/index.d.ts +5 -0
  281. package/lib/types/utils/meta.d.ts +8 -0
  282. package/lib/types/utils/state-merge.d.ts +14 -0
  283. package/package.json +90 -0
  284. package/type.d.ts +143 -0
@@ -0,0 +1,140 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var schemaUtils = require('@hi-ui/schema-utils');
16
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
17
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
18
+ if (it) return (it = it.call(o)).next.bind(it);
19
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
20
+ if (it) o = it;
21
+ var i = 0;
22
+ return function () {
23
+ if (i >= o.length) return {
24
+ done: true
25
+ };
26
+ return {
27
+ done: false,
28
+ value: o[i++]
29
+ };
30
+ };
31
+ }
32
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
33
+ }
34
+ function _unsupportedIterableToArray(o, minLen) {
35
+ if (!o) return;
36
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
37
+ var n = Object.prototype.toString.call(o).slice(8, -1);
38
+ if (n === "Object" && o.constructor) n = o.constructor.name;
39
+ if (n === "Map" || n === "Set") return Array.from(o);
40
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
41
+ }
42
+ function _arrayLikeToArray(arr, len) {
43
+ if (len == null || len > arr.length) len = arr.length;
44
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
45
+ arr2[i] = arr[i];
46
+ }
47
+ return arr2;
48
+ }
49
+ var CustomRowSelectionFeature = {
50
+ createTable: function createTable(table) {
51
+ table.$rowSelectionCache = {
52
+ selectedRows: [],
53
+ selectedRowKeys: [],
54
+ selectedRowEntries: []
55
+ };
56
+ table.$selectedRowsCache = new Map();
57
+ table.$getRowSelection = function $getRowSelection(state) {
58
+ var newState = state || table.getState().rowSelection;
59
+ // 如果 state 为空,则说明不是在变更时调用的,直接返回缓存
60
+ if (!state) return table.$rowSelectionCache;
61
+ var innerRef = table.$getInnerRef();
62
+ var allRows = innerRef.current.subscription.getValue();
63
+ var preserveSelectedRows = getEnablePreserveSelectedRows();
64
+ var selectedRowKeys = [];
65
+ var selectedRows = [];
66
+ var selectedRowEntries = [];
67
+ for (var _i = 0, _Object$entries = Object.entries(newState); _i < _Object$entries.length; _i++) {
68
+ var _Object$entries$_i = _Object$entries[_i],
69
+ rowId = _Object$entries$_i[0],
70
+ selected = _Object$entries$_i[1];
71
+ if (!selected) continue; // selected 应该不可能为 false,此处保留用作保险
72
+ selectedRowKeys.push(rowId);
73
+ try {
74
+ var row = table.getRow(rowId);
75
+ var rowData = allRows[row.index];
76
+ selectedRows.push(rowData);
77
+ selectedRowEntries.push([rowId, rowData]);
78
+ } catch (error) {
79
+ // 走到这里,说明 getRow 执行失败了
80
+ if (preserveSelectedRows) {
81
+ var _rowData = table.$selectedRowsCache.get(rowId);
82
+ if (_rowData) {
83
+ selectedRows.push(_rowData);
84
+ selectedRowEntries.push([rowId, _rowData]);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ var selection = {
90
+ selectedRows: selectedRows,
91
+ selectedRowKeys: selectedRowKeys,
92
+ selectedRowEntries: selectedRowEntries
93
+ };
94
+ table.$rowSelectionCache = selection;
95
+ return selection;
96
+ };
97
+ table.$updateSelectedRowsCache = function $updateSelectedRowsCache(entries) {
98
+ var preserveSelectedRows = getEnablePreserveSelectedRows();
99
+ // 仅在开启 preserveSelectedRows 时才更新缓存
100
+ if (preserveSelectedRows) {
101
+ for (var _iterator = _createForOfIteratorHelperLoose(entries), _step; !(_step = _iterator()).done;) {
102
+ var _step$value = _step.value,
103
+ _rowId = _step$value[0],
104
+ rowData = _step$value[1];
105
+ table.$selectedRowsCache.set(_rowId, rowData);
106
+ }
107
+ // 清除已经取消选择的行的缓存记录
108
+ var innerRef = table.$getInnerRef();
109
+ var rowSelectionState = innerRef.current.rowSelectionState;
110
+ var stateValue = rowSelectionState.getValue();
111
+ for (var rowId in stateValue) {
112
+ if (stateValue[rowId] === false) {
113
+ table.$selectedRowsCache["delete"](rowId);
114
+ }
115
+ }
116
+ }
117
+ };
118
+ function getEnablePreserveSelectedRows() {
119
+ var _a;
120
+ var innerRef = table.$getInnerRef();
121
+ return (_a = innerRef.current.propsRef.current.rowSelection) === null || _a === void 0 ? void 0 : _a.preserveSelectedRows;
122
+ }
123
+ },
124
+ createRow: function createRow(row) {
125
+ row.$afterToggleSelected = function afterToggleSelected() {
126
+ var parentRows = row.getParentRows();
127
+ // 父行不会很多,所以直接反序后遍历
128
+ parentRows.toReversed().forEach(function (parentRow) {
129
+ // 使用微任务调度则是因为,状态的变更稍微有一点点延迟,会拿不到实时的状态
130
+ schemaUtils.Schedular.nextMicro(function () {
131
+ var isParentSelected = parentRow.getIsAllSubRowsSelected();
132
+ parentRow.toggleSelected(isParentSelected, {
133
+ selectChildren: false
134
+ });
135
+ });
136
+ });
137
+ };
138
+ }
139
+ };
140
+ exports.CustomRowSelectionFeature = CustomRowSelectionFeature;
@@ -0,0 +1,150 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+ Object.defineProperty(exports, '__esModule', {
14
+ value: true
15
+ });
16
+ var React = require('react');
17
+ var ahooks = require('ahooks');
18
+ var lodashEs = require('lodash-es');
19
+ var schemaHooks = require('@hi-ui/schema-hooks');
20
+ var ctx = require('../../ctx.js');
21
+
22
+ // 单纯只是为了包装一下 useAsyncData
23
+ // ~~避免在 Table 最顶层调用时频繁触发重渲染~~
24
+ // NOTE 上述目的没有达到,暂时先留着吧,指不定后面又有新用途了
25
+ function AsyncDataGetter() {
26
+ var ctx$1 = ctx.useEditableSchemaTableCtx();
27
+ var innerRef = schemaHooks.useReadonlyRef(function () {
28
+ return ctx$1;
29
+ });
30
+ useAsyncData({
31
+ innerRef: innerRef
32
+ });
33
+ return null;
34
+ }
35
+ function useAsyncData(ctx) {
36
+ var innerRef = ctx.innerRef;
37
+ var globalStaticRef = innerRef.current.globalStaticRef;
38
+ var enableAsyncData = globalStaticRef.current.enableAsyncData;
39
+ // 分页/筛选状态变更时,table会自动触发重渲染,此处不必单独监听
40
+ var _innerRef$current = innerRef.current,
41
+ filterState = _innerRef$current.filterState,
42
+ sorterState = _innerRef$current.sorterState,
43
+ paginationState = _innerRef$current.paginationState;
44
+ // 异步数据源需要监听的状态
45
+ var _paginationState$getV = paginationState.getValue(),
46
+ pageSize = _paginationState$getV.pageSize,
47
+ pageIndex = _paginationState$getV.pageIndex;
48
+ // 如果启用了远程筛选,则使用筛选状态,否则不监听 filters 变化
49
+ var filters = filterState.getValue();
50
+ var effectiveFilters = globalStaticRef.current.enableRemoteFilter ? filters : undefined;
51
+ var hasFilterChanged = schemaHooks.useDeepCompareFlag([effectiveFilters]);
52
+ var sorters = sorterState.getValue();
53
+ // 如果启用了远程排序,则使用排序状态,否则不监听 sorters 变化
54
+ var effectiveSorters = globalStaticRef.current.enableRemoteSorter ? sorters : undefined;
55
+ var hasSorterChanged = schemaHooks.useDeepCompareFlag([effectiveSorters]);
56
+ // 标记是否初次挂载
57
+ var isFirstMountRef = schemaHooks.useIsFirstMount();
58
+ var _useDebounceFn = ahooks.useDebounceFn(function fetchData() {
59
+ var _a;
60
+ // 内部主动设置的分页状态,不请求数据
61
+ // 内部主动设置的分页状态,不请求数据
62
+ var fromCustomPagination = innerRef.current.table.getState().pagination.$fromCustom;
63
+ if (fromCustomPagination) return;
64
+ // 启用 blockInitialRequest 时,初次挂载时不请求数据
65
+ // 启用 blockInitialRequest 时,初次挂载时不请求数据
66
+ var propsRef = innerRef.current.propsRef;
67
+ var blockInitialRequest = (_a = propsRef.current.asyncData) === null || _a === void 0 ? void 0 : _a.blockInitialRequest;
68
+ if (isFirstMountRef.current && blockInitialRequest) return;
69
+ // 真实请求逻辑
70
+ // 真实请求逻辑
71
+ if (enableAsyncData) {
72
+ var globalActionsRef = innerRef.current.globalActionsRef;
73
+ globalActionsRef.current.updateDataSource();
74
+ }
75
+ },
76
+ // 16 毫秒内的变更仅触发一次请求
77
+ // 以达到短时间内多次状态变更的批处理效果
78
+ {
79
+ wait: 16
80
+ }),
81
+ fetchData = _useDebounceFn.run;
82
+ React.useEffect(function () {
83
+ fetchData();
84
+ }, [fetchData,
85
+ // 不会触发重渲染
86
+ isFirstMountRef, enableAsyncData, innerRef,
87
+ // 以下为触发请求接口的值
88
+ pageSize, pageIndex, hasFilterChanged, hasSorterChanged]);
89
+ }
90
+ function validateResData(data) {
91
+ // 空值检查
92
+ if (lodashEs.isNil(data)) {
93
+ console.warn('EditTable useAsyncData: 主数据不能为空');
94
+ return false;
95
+ }
96
+ // 对象类型检查
97
+ if (_typeof(data) !== 'object' || Array.isArray(data)) {
98
+ console.warn('EditTable useAsyncData: useAsyncData: 主数据必须是对象类型');
99
+ return false;
100
+ }
101
+ var pass = true;
102
+ var res = data;
103
+ // 必要字段存在性检查
104
+ if (!('list' in res)) {
105
+ console.warn('EditTable useAsyncData: 主数据缺少必要字段: list');
106
+ pass = false;
107
+ }
108
+ if (!('total' in res)) {
109
+ console.warn('EditTable useAsyncData: 主数据缺少必要字段: total');
110
+ pass = false;
111
+ }
112
+ if (!('pageSize' in res)) {
113
+ console.warn('EditTable useAsyncData: 主数据缺少必要字段: pageSize');
114
+ pass = false;
115
+ }
116
+ if (!('current' in res)) {
117
+ console.warn('EditTable useAsyncData: 主数据缺少必要字段: current');
118
+ pass = false;
119
+ }
120
+ // 分阶段检查,本阶段未通过,不再检查剩余项目
121
+ if (!pass) return false;
122
+ // 字段类型检查
123
+ if (!Array.isArray(res.list)) {
124
+ console.warn('EditTable useAsyncData: list字段必须是数组类型');
125
+ pass = false;
126
+ }
127
+ if (typeof res.total !== 'number') {
128
+ console.warn('EditTable useAsyncData: total字段必须是数字类型');
129
+ pass = false;
130
+ }
131
+ if (typeof res.pageSize !== 'number') {
132
+ console.warn('EditTable useAsyncData: pageSize字段必须是数字类型');
133
+ pass = false;
134
+ }
135
+ if (typeof res.current !== 'number') {
136
+ console.warn('EditTable useAsyncData: current字段必须是数字类型');
137
+ pass = false;
138
+ }
139
+ // list数组内容检查
140
+ if (res.list.some(function (item) {
141
+ return lodashEs.isNil(item) || _typeof(item) !== 'object' || Array.isArray(item);
142
+ })) {
143
+ console.warn('EditTable useAsyncData: list数组的每一项必须是对象类型');
144
+ pass = false;
145
+ }
146
+ return pass;
147
+ }
148
+ exports.AsyncDataGetter = AsyncDataGetter;
149
+ exports.useAsyncData = useAsyncData;
150
+ exports.validateResData = validateResData;
@@ -0,0 +1,145 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+ Object.defineProperty(exports, '__esModule', {
14
+ value: true
15
+ });
16
+ var _regeneratorRuntime = require('@babel/runtime/regenerator');
17
+ var tslib = require('tslib');
18
+ var React = require('react');
19
+ var schemaUtils = require('@hi-ui/schema-utils');
20
+ var getter = require('./getter.js');
21
+ function _interopDefaultCompat(e) {
22
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
23
+ 'default': e
24
+ };
25
+ }
26
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultCompat(_regeneratorRuntime);
27
+ function useGetDataSource(ctx) {
28
+ var innerRef = ctx.innerRef;
29
+ var getDataSource = React.useCallback(function getDataSource(customParams) {
30
+ return tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
31
+ var _a, _innerRef$current, table, globalStaticRef, propsRef, enableAsyncData, _ref, dataSourceFn, dftData, _table$getState, _table$getState$pagin, pageIndex, pageSize, sorting, columnFilters, params, enablePagination, enableRemoteFilter, enableRemoteSorter, pipeParams, beforeRequest, finalParams;
32
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
33
+ while (1) {
34
+ switch (_context.prev = _context.next) {
35
+ case 0:
36
+ _innerRef$current = innerRef.current, table = _innerRef$current.table, globalStaticRef = _innerRef$current.globalStaticRef, propsRef = _innerRef$current.propsRef;
37
+ enableAsyncData = globalStaticRef.current.enableAsyncData;
38
+ _ref = propsRef.current.asyncData || {}, dataSourceFn = _ref.request;
39
+ dftData = {
40
+ list: [],
41
+ total: 0,
42
+ pageSize: 0,
43
+ current: 0
44
+ };
45
+ if (!(!enableAsyncData || !dataSourceFn)) {
46
+ _context.next = 6;
47
+ break;
48
+ }
49
+ return _context.abrupt("return", dftData);
50
+ case 6:
51
+ _table$getState = table.getState(), _table$getState$pagin = _table$getState.pagination, pageIndex = _table$getState$pagin.pageIndex, pageSize = _table$getState$pagin.pageSize, sorting = _table$getState.sorting, columnFilters = _table$getState.columnFilters;
52
+ params = {}; // 分页
53
+ // 其实只要启用异步数据源,基本上一定会有分页
54
+ // 还是判断一下吧,就当是用来收窄类型
55
+ enablePagination = globalStaticRef.current.enablePagination;
56
+ if (enablePagination) {
57
+ params.pagination = {
58
+ current: pageIndex + 1,
59
+ pageSize: pageSize
60
+ };
61
+ }
62
+ // 筛选
63
+ enableRemoteFilter = globalStaticRef.current.enableRemoteFilter;
64
+ if (enableRemoteFilter) params.filters = columnFilters;
65
+ // 排序
66
+ enableRemoteSorter = globalStaticRef.current.enableRemoteSorter;
67
+ if (enableRemoteSorter) params.sorters = sorting;
68
+ // 若有传入 customParams,则使用 customParams 处理 params
69
+ pipeParams = schemaUtils.getPipeGetterValue(params, customParams); // 使用 beforeRequest 处理 pipeParams
70
+ beforeRequest = ((_a = propsRef.current.asyncData) === null || _a === void 0 ? void 0 : _a.beforeRequest) || function (params) {
71
+ return params;
72
+ };
73
+ _context.next = 18;
74
+ return beforeRequest(pipeParams);
75
+ case 18:
76
+ finalParams = _context.sent;
77
+ if (finalParams) {
78
+ _context.next = 21;
79
+ break;
80
+ }
81
+ return _context.abrupt("return", dftData);
82
+ case 21:
83
+ return _context.abrupt("return", dataSourceFn(finalParams));
84
+ case 22:
85
+ case "end":
86
+ return _context.stop();
87
+ }
88
+ }
89
+ }, _callee);
90
+ }));
91
+ }, [innerRef]);
92
+ var updateDataSource = React.useCallback(function updateDataSource(params) {
93
+ return tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
94
+ var _a, data, _innerRef$current2, propsRef, globalStaticRef, enableDataValidate, enablePagination, _innerRef$current3, subscription, paginationState, table, _data$pageSize, dataPageSize, _data$current, current, _data$total, rowCount, pageIndex, nextState;
95
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
96
+ while (1) {
97
+ switch (_context2.prev = _context2.next) {
98
+ case 0:
99
+ _context2.next = 2;
100
+ return getDataSource(params);
101
+ case 2:
102
+ data = _context2.sent;
103
+ if (data) {
104
+ _context2.next = 5;
105
+ break;
106
+ }
107
+ return _context2.abrupt("return");
108
+ case 5:
109
+ _innerRef$current2 = innerRef.current, propsRef = _innerRef$current2.propsRef, globalStaticRef = _innerRef$current2.globalStaticRef; // 如果启用了数据完整性验证,并且启用了分页,则验证数据
110
+ enableDataValidate = (_a = propsRef.current.asyncData) === null || _a === void 0 ? void 0 : _a.enableDataValidate;
111
+ enablePagination = globalStaticRef.current.enablePagination;
112
+ if (enableDataValidate && enablePagination) getter.validateResData(data);
113
+ _innerRef$current3 = innerRef.current, subscription = _innerRef$current3.subscription, paginationState = _innerRef$current3.paginationState, table = _innerRef$current3.table; // 表格数据直接更新到主数据订阅
114
+ subscription.setValue(data.list);
115
+ // 如果启用了分页,则更新分页状态
116
+ if (enablePagination) {
117
+ _data$pageSize = data.pageSize, dataPageSize = _data$pageSize === void 0 ? 10 : _data$pageSize, _data$current = data.current, current = _data$current === void 0 ? 1 : _data$current, _data$total = data.total, rowCount = _data$total === void 0 ? 0 : _data$total;
118
+ pageIndex = current - 1;
119
+ nextState = {
120
+ pageIndex: pageIndex,
121
+ pageSize: dataPageSize,
122
+ rowCount: rowCount
123
+ }; // 更新分页状态订阅
124
+ paginationState.setValue(nextState);
125
+ // 最后更新 table 分页状态 // 不触发 onPaginationChange
126
+ table.setState(function (state) {
127
+ return Object.assign(Object.assign({}, state), {
128
+ pagination: nextState
129
+ });
130
+ });
131
+ }
132
+ case 12:
133
+ case "end":
134
+ return _context2.stop();
135
+ }
136
+ }
137
+ }, _callee2);
138
+ }));
139
+ }, [getDataSource, innerRef]);
140
+ return {
141
+ getDataSource: getDataSource,
142
+ updateDataSource: updateDataSource
143
+ };
144
+ }
145
+ exports.useGetDataSource = useGetDataSource;
@@ -0,0 +1,40 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var tslib = require('tslib');
16
+ var schemaUtils = require('@hi-ui/schema-utils');
17
+ var ahooks = require('ahooks');
18
+
19
+ /**
20
+ * 定义的可编辑表的异步数据请求方法
21
+ * @desc 默认需要手动调用 fetchData 方法
22
+ * @desc 本质是 ahooks 的 useRequest 方法
23
+ */
24
+ function useDataFetcher(getter, extraOpts) {
25
+ var _a = ahooks.useRequest(getter, schemaUtils.mergeValues({
26
+ manual: true
27
+ }, extraOpts)),
28
+ runAsync = _a.runAsync,
29
+ rest = tslib.__rest(_a, ["runAsync"]);
30
+ return Object.assign(Object.assign({}, rest), {
31
+ runAsync: runAsync,
32
+ fetchData: runAsync
33
+ });
34
+ }
35
+ /** 定义表格异步数据请求方法 */
36
+ function defineDataFetcher(getter) {
37
+ return getter;
38
+ }
39
+ exports.defineDataFetcher = defineDataFetcher;
40
+ exports.useDataFetcher = useDataFetcher;
@@ -0,0 +1,91 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+ Object.defineProperty(exports, '__esModule', {
14
+ value: true
15
+ });
16
+ var _regeneratorRuntime = require('@babel/runtime/regenerator');
17
+ var tslib = require('tslib');
18
+ var React = require('react');
19
+ var schemaUtils = require('@hi-ui/schema-utils');
20
+ function _interopDefaultCompat(e) {
21
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
22
+ 'default': e
23
+ };
24
+ }
25
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultCompat(_regeneratorRuntime);
26
+ function useResetDataSource(ctx) {
27
+ var innerRef = ctx.innerRef;
28
+ var resetDataSource = React.useCallback(function resetDataSource(opts) {
29
+ return tslib.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
30
+ var _a, _innerRef$current, table, globalStaticRef, propsRef, enableAsyncData, prevState, _innerRef$current2, filterState, sorterState, paginationState;
31
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
32
+ while (1) {
33
+ switch (_context.prev = _context.next) {
34
+ case 0:
35
+ _innerRef$current = innerRef.current, table = _innerRef$current.table, globalStaticRef = _innerRef$current.globalStaticRef, propsRef = _innerRef$current.propsRef;
36
+ enableAsyncData = globalStaticRef.current.enableAsyncData;
37
+ if (enableAsyncData) {
38
+ _context.next = 4;
39
+ break;
40
+ }
41
+ return _context.abrupt("return");
42
+ case 4:
43
+ prevState = table.getState();
44
+ _innerRef$current2 = innerRef.current, filterState = _innerRef$current2.filterState, sorterState = _innerRef$current2.sorterState, paginationState = _innerRef$current2.paginationState; // 先重置内部订阅
45
+ filterState.setValue(function (prev) {
46
+ return prev.length > 0 ? [] : prev;
47
+ });
48
+ sorterState.setValue(function (prev) {
49
+ return prev.length > 0 ? [] : prev;
50
+ });
51
+ paginationState.mergeValue({
52
+ pageIndex: 0,
53
+ pageSize: (_a = propsRef.current.pagination) === null || _a === void 0 ? void 0 : _a.pageSize
54
+ });
55
+ // 再更新表格状态
56
+ table.setState(function (state) {
57
+ return Object.assign(Object.assign({}, state), {
58
+ columnFilters: filterState.getValue(),
59
+ sorting: sorterState.getValue(),
60
+ pagination: paginationState.getValue()
61
+ });
62
+ });
63
+ // 有任意一个状态变更,均可触发请求(只触发一次)
64
+ // 方式是通过暂存的 prevState 来判断前后是否发生变化
65
+ schemaUtils.Schedular.nextMicro(function () {
66
+ var _a;
67
+ if (prevState.pagination.pageIndex !== 0) {
68
+ return table.setPageIndex(paginationState.getValue().pageIndex);
69
+ }
70
+ if (prevState.pagination.pageSize !== ((_a = propsRef.current.pagination) === null || _a === void 0 ? void 0 : _a.pageSize)) {
71
+ return table.setPageSize(paginationState.getValue().pageSize);
72
+ }
73
+ if (prevState.columnFilters.length > 0) {
74
+ return table.setColumnFilters(filterState.getValue());
75
+ }
76
+ // 启用强制请求时,无论是否有变化都请求一次
77
+ if (opts === null || opts === void 0 ? void 0 : opts.forceRequest) {
78
+ innerRef.current.globalActionsRef.current.updateDataSource();
79
+ }
80
+ });
81
+ case 11:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }
86
+ }, _callee);
87
+ }));
88
+ }, [innerRef]);
89
+ return resetDataSource;
90
+ }
91
+ exports.useResetDataSource = useResetDataSource;
@@ -0,0 +1,27 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var schemaUtils = require('@hi-ui/schema-utils');
16
+ function getGroupingConfig(field) {
17
+ var _a;
18
+ var groupingConfig = (_a = field.control) === null || _a === void 0 ? void 0 : _a.grouping;
19
+ if (!groupingConfig) return undefined;
20
+ var config = schemaUtils.getBoolConfig(groupingConfig, {
21
+ aggregationFn: 'count'
22
+ }, {
23
+ mergeDft: true
24
+ });
25
+ return config;
26
+ }
27
+ exports.getGroupingConfig = getGroupingConfig;
@@ -0,0 +1,42 @@
1
+ /** @LICENSE
2
+ * @hi-ui/schema-editable-table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var reactTable = require('@tanstack/react-table');
16
+ function useRowGroupedOpts(ctx) {
17
+ return getRowGroupedOptions(ctx);
18
+ }
19
+ /**
20
+ * 获取列分组配置选项
21
+ */
22
+ function getRowGroupedOptions(ctx) {
23
+ var enableRowGrouping = ctx.staticOptsRef.current.enableRowGrouping;
24
+ if (!enableRowGrouping) {
25
+ return {
26
+ enableGrouping: false,
27
+ onGroupingChange: function onGroupingChange() {
28
+ // empty onGroupingChange
29
+ // 起到即使主动设置 grouping 状态,也会被直接忽略的作用
30
+ }
31
+ };
32
+ }
33
+ return {
34
+ enableGrouping: true,
35
+ groupedColumnMode: false,
36
+ getGroupedRowModel: reactTable.getGroupedRowModel(),
37
+ autoResetExpanded: false // 数据变化时保持分组的展开状态
38
+ };
39
+ }
40
+
41
+ exports.getRowGroupedOptions = getRowGroupedOptions;
42
+ exports.useRowGroupedOpts = useRowGroupedOpts;