@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,104 @@
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 lodashEs = require('lodash-es');
18
+ var ahooks = require('ahooks');
19
+ var schemaForm = require('@hi-ui/schema-form');
20
+ var schemaUtils = require('@hi-ui/schema-utils');
21
+ require('../container/index.js');
22
+ require('../utils/cls.js');
23
+ require('@hi-ui/classname');
24
+ require('@tanstack/react-table');
25
+ require('@hi-ui/icons');
26
+ require('@hi-ui/schema-hooks');
27
+ require('../cell/index.js');
28
+ var table = require('../table.js');
29
+ require('@tanstack/react-virtual');
30
+ require('@hi-ui/schema-action-trigger');
31
+ require('@hi-ui/pagination');
32
+ require('@hi-ui/use-subscription');
33
+ require('@hi-ui/checkbox');
34
+ require('@hi-ui/radio');
35
+ require('@hi-ui/space');
36
+ require('@hi-ui/switch');
37
+ require('@babel/runtime/regenerator');
38
+ require('tslib');
39
+ require('@hi-ui/schema-table-extensions');
40
+ require('@babel/runtime/helpers/createClass');
41
+ require('immer');
42
+ require('@hi-ui/use-id');
43
+ require('@babel/runtime/helpers/inheritsLoose');
44
+ require('@hi-ui/schema-fields');
45
+ var toolbar = require('./toolbar.js');
46
+ function _interopDefaultCompat(e) {
47
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
48
+ 'default': e
49
+ };
50
+ }
51
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
52
+ function EditTableBridge(props) {
53
+ var _a, _b, _c;
54
+ var wrapperElRef = React.useRef(null);
55
+ var _useSchemaFormCtx = schemaForm.useSchemaFormCtx(),
56
+ formRef = _useSchemaFormCtx.formRef;
57
+ var tableCtxRef = React.useRef(null);
58
+ var _useControllableValue = ahooks.useControllableValue(props),
59
+ values = _useControllableValue[0],
60
+ setValues = _useControllableValue[1];
61
+ // value 变更时,需经过 subscription 主动设置,方可生效
62
+ React.useEffect(function () {
63
+ var _a;
64
+ var complete = !props.doNotCompleteRerender;
65
+ (_a = tableCtxRef.current) === null || _a === void 0 ? void 0 : _a.subscription.setValue(props.value || [], {
66
+ complete: complete
67
+ });
68
+ }, [props.value, tableCtxRef, props.doNotCompleteRerender]);
69
+ var handleValuesChange = function handleValuesChange(changed, allValues) {
70
+ var _a;
71
+ // console.log('handleValuesChange',changed, allValues)
72
+ (_a = props.onValuesChange) === null || _a === void 0 ? void 0 : _a.call(props, changed, allValues);
73
+ setValues(allValues);
74
+ };
75
+ var finalProps = schemaUtils.mergeProps({
76
+ fields: props.fields,
77
+ sticky: true
78
+ }, lodashEs.omit(props, [
79
+ // 移除无关的属性
80
+ 'value', 'defaultValue', 'onChange', 'innerCtxRef', 'catchInnerCtx']));
81
+ // 捕获内部引用
82
+ (_a = props.catchInnerCtx) === null || _a === void 0 ? void 0 : _a.call(props, {
83
+ tableCtx: tableCtxRef.current
84
+ });
85
+ return /*#__PURE__*/React__default["default"].createElement("div", {
86
+ className: "pro-edit-table",
87
+ ref: wrapperElRef
88
+ }, props.toolbar === false ? null : ( /*#__PURE__*/React__default["default"].createElement(toolbar.Toolbar, {
89
+ ctx: {
90
+ tableFields: finalProps.fields,
91
+ tableCtxRef: tableCtxRef,
92
+ fullscreenElRef: wrapperElRef,
93
+ formRef: formRef,
94
+ readonly: props.readonly
95
+ },
96
+ left: (_b = props.toolbar) === null || _b === void 0 ? void 0 : _b.left,
97
+ right: props.actions || ((_c = props.toolbar) === null || _c === void 0 ? void 0 : _c.right)
98
+ })), /*#__PURE__*/React__default["default"].createElement(table.EditableSchemaTable, Object.assign({}, finalProps, {
99
+ defaultValue: values,
100
+ innerCtxRef: tableCtxRef,
101
+ onValuesChange: handleValuesChange
102
+ })));
103
+ }
104
+ exports.EditTableBridge = EditTableBridge;
@@ -0,0 +1,58 @@
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 _inheritsLoose = require('@babel/runtime/helpers/inheritsLoose');
17
+ var React = require('react');
18
+ var schemaFields = require('@hi-ui/schema-fields');
19
+ var bridge = require('./bridge.js');
20
+ function _interopDefaultCompat(e) {
21
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
22
+ 'default': e
23
+ };
24
+ }
25
+ var _inheritsLoose__default = /*#__PURE__*/_interopDefaultCompat(_inheritsLoose);
26
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
27
+ var ProEditTable = /*#__PURE__*/function (_ProField) {
28
+ _inheritsLoose__default["default"](ProEditTable, _ProField);
29
+ function ProEditTable() {
30
+ return _ProField.apply(this, arguments) || this;
31
+ }
32
+ var _proto = ProEditTable.prototype;
33
+ _proto.render = function render(data, ctx) {
34
+ if (data === void 0) {
35
+ data = [];
36
+ }
37
+ var fieldProps = this.getFieldProps({
38
+ fields: []
39
+ }, ctx);
40
+ return /*#__PURE__*/React__default["default"].createElement(bridge.EditTableBridge, Object.assign({}, fieldProps, {
41
+ value: data,
42
+ readonly: true
43
+ }));
44
+ };
45
+ _proto.renderCell = function renderCell() {
46
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null); // 表格不允许嵌套在单元格中
47
+ };
48
+
49
+ _proto.renderFormItem = function renderFormItem(_, ctx) {
50
+ var fieldProps = this.getFieldProps({
51
+ fields: []
52
+ }, ctx);
53
+ return /*#__PURE__*/React__default["default"].createElement(bridge.EditTableBridge, Object.assign({}, fieldProps));
54
+ };
55
+ return ProEditTable;
56
+ }(schemaFields.ProField);
57
+ exports.EditTableBridge = bridge.EditTableBridge;
58
+ exports.ProEditTable = ProEditTable;
@@ -0,0 +1,53 @@
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 schemaForm = require('@hi-ui/schema-form');
18
+ var schemaActionTrigger = require('@hi-ui/schema-action-trigger');
19
+ var useSubscription = require('@hi-ui/use-subscription');
20
+ var schemaHooks = require('@hi-ui/schema-hooks');
21
+ var schemaUtils = require('@hi-ui/schema-utils');
22
+ function _interopDefaultCompat(e) {
23
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
24
+ 'default': e
25
+ };
26
+ }
27
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
28
+ function Toolbar(props) {
29
+ var tableCtxRef = props.ctx.tableCtxRef;
30
+ // 此处用来触发工具栏按钮的更新
31
+ // 严格比较时,使用 tickState 订阅,否则使用 NOOP_SUBSCRIPTION
32
+ var _useSchemaFormCtx = schemaForm.useSchemaFormCtx(),
33
+ propsRef = _useSchemaFormCtx.propsRef,
34
+ tickState = _useSchemaFormCtx.tickState;
35
+ var subscription = propsRef.current.strictValueCompare ? tickState : useSubscription.NOOP_SUBSCRIPTION;
36
+ schemaHooks.useSubscribeTickState(subscription);
37
+ var dftRight = props.ctx.readonly ? [] : [{
38
+ text: '增行',
39
+ onClick: function onClick() {
40
+ var _a;
41
+ (_a = tableCtxRef.current) === null || _a === void 0 ? void 0 : _a.rowActions.addRow({});
42
+ }
43
+ }];
44
+ var getRight = props.right;
45
+ var right = schemaUtils.getGetterValue(getRight, dftRight, [props.ctx]);
46
+ return /*#__PURE__*/React__default["default"].createElement(schemaActionTrigger.TableToolbar, {
47
+ ctx: props.ctx,
48
+ left: props.left,
49
+ right: right,
50
+ className: "pro-edit-table__toolbar"
51
+ });
52
+ }
53
+ exports.Toolbar = Toolbar;
@@ -0,0 +1,99 @@
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 reactTable = require('@tanstack/react-table');
18
+ var ctx = require('../ctx.js');
19
+ require('../container/index.js');
20
+ var fixed = require('../utils/fixed.js');
21
+ var cls = require('../utils/cls.js');
22
+ var index = require('../header/index.js');
23
+ var useFirstCellPatch = require('./use-first-cell-patch.js');
24
+ var ctx$1 = require('../container/ctx.js');
25
+ function _interopDefaultCompat(e) {
26
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
27
+ 'default': e
28
+ };
29
+ }
30
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
31
+ var FooterCellWrapper = /*#__PURE__*/React__default["default"].memo(function FooterCell(props) {
32
+ var _a;
33
+ var footer = props.footer;
34
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
35
+ globalStaticRef = _useEditableSchemaTab.globalStaticRef;
36
+ // 开启 fixed 时才去获取固定单元格的样式
37
+ var fixed$1 = props.fixed ? fixed.getFixedStyles(footer.column, {
38
+ globalStaticRef: globalStaticRef
39
+ }) : {};
40
+ var fixedClassName = (fixed$1.className || []).map(function (c) {
41
+ return "cell--" + c;
42
+ });
43
+ return /*#__PURE__*/React__default["default"].createElement("td", {
44
+ className: cls.cls.apply(void 0, ['footer-cell'].concat(fixedClassName)),
45
+ style: fixed$1.style,
46
+ "data-text-align": (_a = footer.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.align
47
+ }, reactTable.flexRender(footer.column.columnDef.footer, footer.getContext()));
48
+ });
49
+ // 仅渲染一行footer,用来生成摘要(合计)行等
50
+ var Footer = /*#__PURE__*/React__default["default"].memo(function Footer(_ref) {
51
+ var className = _ref.className;
52
+ var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
53
+ table = _useEditableSchemaTab2.table;
54
+ var _useTableContainer = ctx$1.useTableContainer(),
55
+ virtualize = _useTableContainer.virtualize;
56
+ useFirstCellPatch.useFirstCellPatch();
57
+ return /*#__PURE__*/React__default["default"].createElement("tfoot", {
58
+ className: cls.cls('footer', className)
59
+ }, table.getFooterGroups().slice(0, 1) // 第一行就是叶节点
60
+ .map(function (footerGroup) {
61
+ var _a, _b, _c, _d;
62
+ var realFooters = footerGroup.headers;
63
+ var _groupHeaders = index.groupHeaders(realFooters, table),
64
+ leftFooters = _groupHeaders.left,
65
+ rightFooters = _groupHeaders.right,
66
+ centerFooters = _groupHeaders.center;
67
+ return /*#__PURE__*/React__default["default"].createElement("tr", {
68
+ key: footerGroup.id,
69
+ className: cls.cls('footer-row')
70
+ }, leftFooters.map(function (footer) {
71
+ return /*#__PURE__*/React__default["default"].createElement(FooterCellWrapper, {
72
+ key: footer.id,
73
+ footer: footer,
74
+ fixed: true
75
+ });
76
+ }), ((_b = (_a = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) > 0 ? /*#__PURE__*/React__default["default"].createElement("td", null) : null, ((virtualize === null || virtualize === void 0 ? void 0 : virtualize.columns) || centerFooters).map(function (footerOrVirtual) {
77
+ var footer = 'index' in footerOrVirtual ? realFooters[footerOrVirtual.index] : footerOrVirtual;
78
+ if (!footer) return null;
79
+ // 固定列不参与虚拟化
80
+ if (footer.column.getIsPinned()) return null;
81
+ return /*#__PURE__*/React__default["default"].createElement(FooterCellWrapper, {
82
+ key: footer.id,
83
+ footer: footer,
84
+ fixed: true
85
+ });
86
+ }), ((_d = (_c = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _c === void 0 ? void 0 : _c.right) !== null && _d !== void 0 ? _d : 0) > 0 ? /*#__PURE__*/React__default["default"].createElement("td", null) : null, rightFooters.map(function (footer) {
87
+ return /*#__PURE__*/React__default["default"].createElement(FooterCellWrapper, {
88
+ key: footer.id,
89
+ footer: footer,
90
+ fixed: true
91
+ });
92
+ }));
93
+ }));
94
+ }, function () {
95
+ return true;
96
+ } // 始终不由外部触发重渲染
97
+ );
98
+
99
+ exports["default"] = Footer;
@@ -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 React = require('react');
16
+ var ctx = require('../ctx.js');
17
+ var cls = require('../utils/cls.js');
18
+ require('lodash-es');
19
+ require('@tanstack/react-table');
20
+ require('ahooks');
21
+
22
+ // 简而言之,启用行选择时,把 footer 的第一个cell 的文字设置为 '合计'
23
+ // 首列固定展示 // TODO 待支持动态首列配置
24
+ function useFirstCellPatch() {
25
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
26
+ globalStaticRef = _useEditableSchemaTab.globalStaticRef,
27
+ tableContainerRef = _useEditableSchemaTab.tableContainerRef;
28
+ var enableRowSelection = globalStaticRef.current.enableRowSelection;
29
+ React.useEffect(function () {
30
+ if (enableRowSelection) {
31
+ var container = tableContainerRef.current;
32
+ if (container) {
33
+ var selector = "." + cls.cls('footer-wrapper') + " table[data-is-selection] ." + cls.cls('footer-cell');
34
+ var firstCell = container.querySelector(selector);
35
+ if (firstCell) {
36
+ firstCell.innerHTML = '合计';
37
+ }
38
+ }
39
+ }
40
+ }, [enableRowSelection, tableContainerRef]);
41
+ }
42
+ exports.useFirstCellPatch = useFirstCellPatch;
@@ -0,0 +1,134 @@
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 classname = require('@hi-ui/classname');
18
+ var reactTable = require('@tanstack/react-table');
19
+ var schemaUtils = require('@hi-ui/schema-utils');
20
+ var schemaHooks = require('@hi-ui/schema-hooks');
21
+ var ctx = require('../ctx.js');
22
+ require('../container/index.js');
23
+ var fixed = require('../utils/fixed.js');
24
+ var cls = require('../utils/cls.js');
25
+ var validate = require('./validate.js');
26
+ var ctx$1 = require('../container/ctx.js');
27
+ function _interopDefaultCompat(e) {
28
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
29
+ 'default': e
30
+ };
31
+ }
32
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
33
+ var HeaderCellWrapper = /*#__PURE__*/React__default["default"].memo(function HeaderCell(props) {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
35
+ var header = props.header;
36
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
37
+ table = _useEditableSchemaTab.table,
38
+ globalStaticRef = _useEditableSchemaTab.globalStaticRef;
39
+ // 鼠标hover时,增加 data-hovering 状态
40
+ var _useElHovering = schemaHooks.useElHovering(),
41
+ headerCellRef = _useElHovering.elRef;
42
+ var validation = validate.validateHeaderCell(header, table.getHeaderGroups().length);
43
+ if (!validation.isValid) return null;
44
+ // 开启 fixed 时才去获取固定单元格的样式
45
+ var fixed$1 = props.fixed ? fixed.getFixedStyles(header.column, {
46
+ globalStaticRef: globalStaticRef
47
+ }) : {};
48
+ var fixedClassName = (fixed$1.className || []).map(function (c) {
49
+ return "cell--" + c;
50
+ });
51
+ // 获取动态属性
52
+ var dynamicAttrs = (_b = (_a = header.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.headerCell) === null || _b === void 0 ? void 0 : _b.call(_a, {
53
+ header: header
54
+ });
55
+ var style = schemaUtils.mergeValues(fixed$1.style, dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.style);
56
+ return /*#__PURE__*/React__default["default"].createElement("th", Object.assign({}, dynamicAttrs, {
57
+ className: classname.cx(cls.cls.apply(void 0, ['header-cell'].concat(fixedClassName)), dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.className),
58
+ ref: headerCellRef,
59
+ colSpan: (_c = dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.colSpan) !== null && _c !== void 0 ? _c : header.colSpan,
60
+ rowSpan: (_d = dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.rowSpan) !== null && _d !== void 0 ? _d : validation.rowSpan,
61
+ style: style,
62
+ "data-has-children": ((_e = header.column.columnDef.meta) === null || _e === void 0 ? void 0 : _e.field.children) ? true : undefined,
63
+ "data-text-align": (_f = header.column.columnDef.meta) === null || _f === void 0 ? void 0 : _f.align,
64
+ "data-field-name": (_h = (_g = header.column.columnDef.meta) === null || _g === void 0 ? void 0 : _g.field) === null || _h === void 0 ? void 0 : _h._titleText,
65
+ "data-field-key": (_k = (_j = header.column.columnDef.meta) === null || _j === void 0 ? void 0 : _j.field) === null || _k === void 0 ? void 0 : _k.dataIndex
66
+ }), reactTable.flexRender(header.column.columnDef.header, header.getContext()));
67
+ });
68
+ var Header = /*#__PURE__*/React__default["default"].memo(function Header(_ref) {
69
+ var className = _ref.className;
70
+ var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
71
+ table = _useEditableSchemaTab2.table;
72
+ var _useTableContainer = ctx$1.useTableContainer(),
73
+ virtualize = _useTableContainer.virtualize;
74
+ return /*#__PURE__*/React__default["default"].createElement("thead", {
75
+ className: cls.cls('header', className)
76
+ }, table.getHeaderGroups().map(function (headerGroup) {
77
+ var _a, _b, _c, _d;
78
+ var realHeaders = headerGroup.headers;
79
+ var _groupHeaders = groupHeaders(realHeaders, table),
80
+ leftHeaders = _groupHeaders.left,
81
+ rightHeaders = _groupHeaders.right,
82
+ centerHeaders = _groupHeaders.center;
83
+ return /*#__PURE__*/React__default["default"].createElement("tr", {
84
+ key: headerGroup.id,
85
+ className: cls.cls('header-row')
86
+ }, leftHeaders.map(function (header) {
87
+ return /*#__PURE__*/React__default["default"].createElement(HeaderCellWrapper, {
88
+ key: header.id,
89
+ header: header,
90
+ fixed: true
91
+ });
92
+ }), ((_b = (_a = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) > 0 ? /*#__PURE__*/React__default["default"].createElement("th", null) : null, ((virtualize === null || virtualize === void 0 ? void 0 : virtualize.columns) || centerHeaders).map(function (headerOrVirtual) {
93
+ var header = 'index' in headerOrVirtual ? realHeaders[headerOrVirtual.index] : headerOrVirtual;
94
+ if (!header) return null;
95
+ // 固定列不参与虚拟化
96
+ if (header.column.getIsPinned()) return null;
97
+ return /*#__PURE__*/React__default["default"].createElement(HeaderCellWrapper, {
98
+ key: header.id,
99
+ header: header
100
+ });
101
+ }), ((_d = (_c = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _c === void 0 ? void 0 : _c.right) !== null && _d !== void 0 ? _d : 0) > 0 ? /*#__PURE__*/React__default["default"].createElement("th", null) : null, rightHeaders.map(function (header) {
102
+ return /*#__PURE__*/React__default["default"].createElement(HeaderCellWrapper, {
103
+ key: header.id,
104
+ header: header,
105
+ fixed: true
106
+ });
107
+ }));
108
+ }));
109
+ });
110
+ function groupHeaders(headers, table) {
111
+ var leftColumns = table.getLeftVisibleLeafColumns();
112
+ var rightColumns = table.getRightVisibleLeafColumns();
113
+ // 创建一个 Map 记录每列的位置类型
114
+ var columnPositions = new Map();
115
+ // 记录固定列的 id
116
+ leftColumns.forEach(function (col) {
117
+ return columnPositions.set(col.id, 'left');
118
+ });
119
+ rightColumns.forEach(function (col) {
120
+ return columnPositions.set(col.id, 'right');
121
+ });
122
+ // 使用 reduce 一次遍历完成分组
123
+ return headers.reduce(function (groups, header) {
124
+ var position = columnPositions.get(header.column.id) || 'center';
125
+ groups[position].push(header);
126
+ return groups;
127
+ }, {
128
+ left: [],
129
+ center: [],
130
+ right: []
131
+ });
132
+ }
133
+ exports["default"] = Header;
134
+ exports.groupHeaders = groupHeaders;
@@ -0,0 +1,69 @@
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
+ function validateHeaderCell(header, totalHeaderRows) {
16
+ var _a;
17
+ var noParent = header.column.parent === undefined;
18
+ // isCrossCol 判断的准确性待进一步验证,目前实测有效
19
+ // crossCol 是指仅有一个子元素的列 // TODO 进一步细化描述
20
+ var isCrossCol = ((_a = header.subHeaders) === null || _a === void 0 ? void 0 : _a.length) === 1;
21
+ // 占位元素
22
+ if (header.isPlaceholder) {
23
+ // 没有父元素且是交叉列
24
+ if (noParent && isCrossCol) {
25
+ var isFirstRow = header.depth === 1;
26
+ if (isFirstRow) {
27
+ return {
28
+ isValid: true,
29
+ rowSpan: totalHeaderRows,
30
+ type: 'PLACEHOLDER-NO-PARENT'
31
+ };
32
+ }
33
+ }
34
+ // 有父元素且是交叉列
35
+ if (!noParent && isCrossCol) {
36
+ var parent = header.column.parent;
37
+ if (parent && header.depth - parent.depth <= 2) {
38
+ return {
39
+ isValid: true,
40
+ rowSpan: Math.max(1, totalHeaderRows - header.depth + 1),
41
+ type: 'PLACEHOLDER-WITH-PARENT'
42
+ };
43
+ }
44
+ }
45
+ }
46
+ // 正常元素
47
+ else if (noParent) {
48
+ if (header.depth === 1) {
49
+ return {
50
+ isValid: true,
51
+ rowSpan: 1,
52
+ type: 'NORMAL-NO-PARENT'
53
+ };
54
+ }
55
+ } else {
56
+ var _parent = header.column.parent;
57
+ if (_parent && header.depth - _parent.depth <= 2) {
58
+ return {
59
+ isValid: true,
60
+ rowSpan: 1,
61
+ type: 'NORMAL-WITH-PARENT'
62
+ };
63
+ }
64
+ }
65
+ return {
66
+ isValid: false
67
+ };
68
+ }
69
+ exports.validateHeaderCell = validateHeaderCell;
@@ -0,0 +1,62 @@
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 React = require('react');
16
+ var lodashEs = require('lodash-es');
17
+ function useGetFieldsValue(ctx) {
18
+ var innerRef = ctx.innerRef;
19
+ return React.useCallback(function getFieldsValue(opts) {
20
+ if (opts === void 0) {
21
+ opts = {};
22
+ }
23
+ var _innerRef$current = innerRef.current,
24
+ subscription = _innerRef$current.subscription,
25
+ globalStaticRef = _innerRef$current.globalStaticRef;
26
+ var allValues = subscription.getValue();
27
+ var keys = globalStaticRef.current.editableFieldKeys;
28
+ return allValues.map(function (row) {
29
+ var _a;
30
+ var values = lodashEs.pick(row, keys);
31
+ // 额外需要获取的 fields
32
+ if ((_a = opts.extraFields) === null || _a === void 0 ? void 0 : _a.length) {
33
+ opts.extraFields.forEach(function (field) {
34
+ lodashEs.set(values, field, row[field]);
35
+ });
36
+ }
37
+ return values;
38
+ });
39
+ }, [innerRef]);
40
+ }
41
+ function useGetGroupedValues(ctx) {
42
+ var innerRef = ctx.innerRef;
43
+ return React.useCallback(function getGroupedValues() {
44
+ var _innerRef$current2 = innerRef.current,
45
+ subscription = _innerRef$current2.subscription,
46
+ globalStaticRef = _innerRef$current2.globalStaticRef;
47
+ var allValues = subscription.getValue();
48
+ var keys = globalStaticRef.current.editableFieldKeys; // 可编辑字段
49
+ return allValues.map(function (row) {
50
+ var editable = lodashEs.pick(row, keys);
51
+ var readonly = lodashEs.omit(row, keys);
52
+ return {
53
+ editable: editable,
54
+ readonly: readonly
55
+ };
56
+ });
57
+ }, [innerRef] // innerRef
58
+ );
59
+ }
60
+
61
+ exports.useGetFieldsValue = useGetFieldsValue;
62
+ exports.useGetGroupedValues = useGetGroupedValues;