@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
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@hi-ui/schema-editable-table`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const schemaEditableTable = require('@hi-ui/schema-editable-table');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,110 @@
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 ctx = require('../ctx.js');
19
+ require('../container/index.js');
20
+ var cls = require('../utils/cls.js');
21
+ var wrapper = require('./wrapper.js');
22
+ var ctx$1 = require('../container/ctx.js');
23
+ function _interopDefaultCompat(e) {
24
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
25
+ 'default': e
26
+ };
27
+ }
28
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
29
+ var BodyRow = /*#__PURE__*/React__default["default"].memo(function BodyRow(props) {
30
+ var _a, _b, _c, _d, _e;
31
+ var row = props.row;
32
+ var _useTableContainer = ctx$1.useTableContainer(),
33
+ virtualize = _useTableContainer.virtualize;
34
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
35
+ propsRef = _useEditableSchemaTab.propsRef;
36
+ var realCells = row.getVisibleCells();
37
+ var rowStyle = (_a = props.getRowStyle) === null || _a === void 0 ? void 0 : _a.call(props, row.original, {
38
+ row: row
39
+ });
40
+ var leftCells = row.getLeftVisibleCells();
41
+ var rightCells = row.getRightVisibleCells();
42
+ var centerCells = row.getCenterVisibleCells();
43
+ ahooks.useMount(function () {
44
+ var _a, _b, _c;
45
+ (_c = (_b = (_a = propsRef.current) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.rowMounted) === null || _c === void 0 ? void 0 : _c.call(_b, {
46
+ row: row
47
+ });
48
+ });
49
+ return /*#__PURE__*/React__default["default"].createElement("tr", {
50
+ // tr
51
+ key: row.id,
52
+ style: rowStyle,
53
+ className: cls.cls('body-row'),
54
+ "data-index": row.index,
55
+ "data-id": row.id
56
+ }, leftCells.map(function (cell) {
57
+ return /*#__PURE__*/React__default["default"].createElement(wrapper.BodyCellWrapper, {
58
+ key: cell.id,
59
+ cell: cell,
60
+ fixed: true
61
+ });
62
+ }), ((_c = (_b = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _b === void 0 ? void 0 : _b.left) !== null && _c !== void 0 ? _c : 0) > 0 && /*#__PURE__*/React__default["default"].createElement("td", null), ((virtualize === null || virtualize === void 0 ? void 0 : virtualize.columns) || centerCells).map(function (cellOrVirtual) {
63
+ var cell = 'index' in cellOrVirtual ? realCells[cellOrVirtual.index] : cellOrVirtual;
64
+ // 固定列不参与中间部分渲染
65
+ if (cell.column.getIsPinned()) return null;
66
+ return /*#__PURE__*/React__default["default"].createElement(wrapper.BodyCellWrapper, {
67
+ key: cell.id,
68
+ cell: cell
69
+ });
70
+ }), ((_e = (_d = virtualize === null || virtualize === void 0 ? void 0 : virtualize.colPadding) === null || _d === void 0 ? void 0 : _d.right) !== null && _e !== void 0 ? _e : 0) > 0 && /*#__PURE__*/React__default["default"].createElement("td", null), rightCells.map(function (cell) {
71
+ return /*#__PURE__*/React__default["default"].createElement(wrapper.BodyCellWrapper, {
72
+ key: cell.id,
73
+ cell: cell,
74
+ fixed: true
75
+ });
76
+ }));
77
+ });
78
+ var Body = /*#__PURE__*/React__default["default"].memo(function Body(props) {
79
+ var _a, _b, _c, _d, _e, _f, _g, _h;
80
+ var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
81
+ table = _useEditableSchemaTab2.table;
82
+ var _useTableContainer2 = ctx$1.useTableContainer(),
83
+ virtualize = _useTableContainer2.virtualize;
84
+ var _table$getRowModel = table.getRowModel(),
85
+ realRows = _table$getRowModel.rows;
86
+ return /*#__PURE__*/React__default["default"].createElement("tbody", {
87
+ className: cls.cls('body', props.className)
88
+ }, ((_b = (_a = virtualize === null || virtualize === void 0 ? void 0 : virtualize.rowPadding) === null || _a === void 0 ? void 0 : _a.top) !== null && _b !== void 0 ? _b : 0) > 0 && ( /*#__PURE__*/React__default["default"].createElement("tr", {
89
+ className: cls.cls('body-row', 'virtual-spacer', 'virtual-spacer-top')
90
+ }, /*#__PURE__*/React__default["default"].createElement("td", {
91
+ style: {
92
+ height: (_d = (_c = virtualize === null || virtualize === void 0 ? void 0 : virtualize.rowPadding) === null || _c === void 0 ? void 0 : _c.top) !== null && _d !== void 0 ? _d : 0
93
+ }
94
+ }))), ((virtualize === null || virtualize === void 0 ? void 0 : virtualize.rows) || realRows).map(function (rowOrVirtual) {
95
+ var row = 'id' in rowOrVirtual ? rowOrVirtual : realRows[rowOrVirtual.index];
96
+ if (!row) return null;
97
+ return /*#__PURE__*/React__default["default"].createElement(BodyRow, {
98
+ key: row.id,
99
+ row: row,
100
+ getRowStyle: props.getRowStyle
101
+ });
102
+ }), ((_f = (_e = virtualize === null || virtualize === void 0 ? void 0 : virtualize.rowPadding) === null || _e === void 0 ? void 0 : _e.bottom) !== null && _f !== void 0 ? _f : 0) > 0 && ( /*#__PURE__*/React__default["default"].createElement("tr", {
103
+ className: cls.cls('body-row', 'virtual-spacer', 'virtual-spacer-bottom')
104
+ }, /*#__PURE__*/React__default["default"].createElement("td", {
105
+ style: {
106
+ height: (_h = (_g = virtualize === null || virtualize === void 0 ? void 0 : virtualize.rowPadding) === null || _g === void 0 ? void 0 : _g.bottom) !== null && _h !== void 0 ? _h : 0
107
+ }
108
+ }))));
109
+ });
110
+ exports["default"] = Body;
@@ -0,0 +1,132 @@
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 ctx = require('../ctx.js');
21
+ var wrapper = require('../features/row-expanding/wrapper.js');
22
+ var fixed = require('../utils/fixed.js');
23
+ var cls = require('../utils/cls.js');
24
+ function _interopDefaultCompat(e) {
25
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
26
+ 'default': e
27
+ };
28
+ }
29
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
30
+
31
+ // NOTE 此处注释:适配【行展开功能】时留
32
+ // 识别到此处包装器如果打开 memo,会导致【外部命令式设置行展开状态】时,icon 的状态会展示错误
33
+ // 原因在于,此处包装器会隔离外部设置状态后引发的重渲染,导致下面的 RowExpandingWrapper 无法重渲染
34
+ // 最初增加 memo 的目的是提升渲染性能,此处移除时经评估和实测后并不会引起突出的损耗
35
+ // 因此决定暂时移除 memo,后续如果引起问题再重新考虑使用订阅的方式触发下层组件重渲染
36
+ // export const BodyCellWrapper2 = React.memo(function BodyCellWrapper(props) {
37
+ // return <>留一个占位</>
38
+ // })
39
+ function BodyCellWrapper(props) {
40
+ var _a, _b, _c;
41
+ var cell = props.cell;
42
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
43
+ globalStaticRef = _useEditableSchemaTab.globalStaticRef;
44
+ // 开启 fixed 时才去获取固定单元格的样式
45
+ var fixed$1 = props.fixed ? fixed.getFixedStyles(cell.column, {
46
+ globalStaticRef: globalStaticRef
47
+ }) : {};
48
+ var fixedClassName = (fixed$1.className || []).map(function (c) {
49
+ return "cell--" + c;
50
+ });
51
+ var renderCase = useRenderCase();
52
+ var renderCaseMap = {
53
+ basic: BasicEl,
54
+ expanding: ExpandingEl,
55
+ grouping: GroupingEl
56
+ };
57
+ var CaseEl = renderCaseMap[renderCase];
58
+ // 获取动态属性
59
+ var dynamicAttrs = (_b = (_a = cell.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.bodyCell) === null || _b === void 0 ? void 0 : _b.call(_a, {
60
+ cell: cell,
61
+ row: cell.row,
62
+ rowData: cell.row.$getRealtimeRowData() || {},
63
+ renderCase: renderCase
64
+ });
65
+ var style = schemaUtils.mergeValues(fixed$1.style, dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.style);
66
+ var textAlign = (_c = cell.column.columnDef.meta) === null || _c === void 0 ? void 0 : _c.align;
67
+ return /*#__PURE__*/React__default["default"].createElement("td", Object.assign({}, dynamicAttrs, {
68
+ className: classname.cx(cls.cls.apply(void 0, ['body-cell'].concat(fixedClassName)), dynamicAttrs === null || dynamicAttrs === void 0 ? void 0 : dynamicAttrs.className),
69
+ style: style,
70
+ "data-text-align": textAlign,
71
+ "data-id": cell.id
72
+ }), /*#__PURE__*/React__default["default"].createElement(CaseEl, {
73
+ renderCase: renderCase,
74
+ cell: cell,
75
+ textAlign: textAlign
76
+ }));
77
+ }
78
+ function useRenderCase() {
79
+ var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
80
+ globalStaticRef = _useEditableSchemaTab2.globalStaticRef;
81
+ var _globalStaticRef$curr = globalStaticRef.current,
82
+ enableRowExpanding = _globalStaticRef$curr.enableRowExpanding,
83
+ enableRowGrouping = _globalStaticRef$curr.enableRowGrouping;
84
+ if (enableRowGrouping) return 'grouping';
85
+ if (enableRowExpanding) return 'expanding';
86
+ return 'basic';
87
+ }
88
+ // 普通基本元素
89
+ function BasicEl(props) {
90
+ var cell = props.cell;
91
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()));
92
+ }
93
+ // 可展开元素
94
+ function ExpandingEl(props) {
95
+ var cell = props.cell,
96
+ textAlign = props.textAlign;
97
+ return /*#__PURE__*/React__default["default"].createElement(wrapper.RowExpandingWrapper, {
98
+ renderCase: props.renderCase,
99
+ cell: cell,
100
+ textAlign: textAlign
101
+ }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()));
102
+ }
103
+ function GroupingEl(props) {
104
+ var cell = props.cell,
105
+ textAlign = props.textAlign;
106
+ var cellIndex = cell.column.getIndex();
107
+ /** 是否聚合单元格 */
108
+ var isAggregated = cell.getIsAggregated();
109
+ /** 是否无效的聚合单元格 */
110
+ // || undefined 是为了放在data-*属性上时 false 时不会显示
111
+ var isInvalidAggregatedCell = isAggregated && cellIndex !== 0 || undefined;
112
+ /** 是否分组单元格 */
113
+ var isGrouped = cell.getIsGrouped();
114
+ // 当前行时分组行,且当前单元格是 placeholder 单元格,则不渲染
115
+ /** 是否当前行是分组行 */
116
+ var isRowGrouped = cell.row.getIsGrouped();
117
+ /** 是否当前单元格是 placeholder 单元格 */
118
+ var isPlaceholder = cell.getIsPlaceholder();
119
+ var hideRealEl =
120
+ // 无效的聚合单元格
121
+ isInvalidAggregatedCell ||
122
+ // 分组单元格
123
+ isGrouped ||
124
+ // 当前行是分组行,且当前单元格是 placeholder 单元格
125
+ isRowGrouped && isPlaceholder;
126
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, hideRealEl ? null : ( /*#__PURE__*/React__default["default"].createElement(wrapper.RowExpandingWrapper, {
127
+ renderCase: props.renderCase,
128
+ cell: cell,
129
+ textAlign: textAlign
130
+ }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()))));
131
+ }
132
+ exports.BodyCellWrapper = BodyCellWrapper;
@@ -0,0 +1,76 @@
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 tag = require('@hi-ui/tag');
19
+ var schemaFields = require('@hi-ui/schema-fields');
20
+ var ctx = require('../ctx.js');
21
+ var _const = require('../const.js');
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
+ var AggregatedCell = /*#__PURE__*/React__default["default"].memo(function AggregatedCell(props) {
29
+ var _a;
30
+ var row = props.row;
31
+ var groupingValue = row.groupingValue,
32
+ groupingColumnId = row.groupingColumnId;
33
+ var _useEditTableCtx = ctx.useEditableSchemaTableCtx(),
34
+ propsRef = _useEditTableCtx.propsRef;
35
+ // TODO 待增加自定义颜色配置传入
36
+ var color = React.useMemo(function () {
37
+ var name = schemaFields.ColorEnumPreset[lodashEs.random(0, schemaFields.ColorEnumPreset.length - 1)];
38
+ return schemaFields.colorPreset[name];
39
+ }, []);
40
+ // 如果groupingColumnId为空,则无法显示
41
+ if (lodashEs.isNil(groupingColumnId)) return null;
42
+ // 处理空值情况,识别特殊标记__EMPTY_VALUE__
43
+ var displayValue = groupingValue === _const.EMPTY_VALUE ? '空值' : groupingValue;
44
+ // 当前被分组的列,经聚合函数处理后的值
45
+ var groupingColumnAggregatedValue = row.$getAggregatedValue(groupingColumnId);
46
+ var dftEl = /*#__PURE__*/React__default["default"].createElement("span", {
47
+ "data-grouping-column-id": groupingColumnId,
48
+ className: "flex-center",
49
+ style: {
50
+ gap: 4
51
+ }
52
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement(tag.Tag, {
53
+ color: color.fore,
54
+ background: color.back
55
+ }, displayValue)), /*#__PURE__*/React__default["default"].createElement("span", {
56
+ style: {
57
+ fontSize: 12
58
+ }
59
+ }, "\u5171 ", groupingColumnAggregatedValue, " \u6761"));
60
+ // 自定义【有效聚合单元格】渲染逻辑
61
+ if ((_a = propsRef.current.customCell) === null || _a === void 0 ? void 0 : _a.renderAggregatedCell) {
62
+ return propsRef.current.customCell.renderAggregatedCell(Object.assign(Object.assign({}, props), {
63
+ groupingValue: groupingValue,
64
+ groupingColumnId: groupingColumnId,
65
+ groupingColumnAggregatedValue: groupingColumnAggregatedValue,
66
+ displayValue: displayValue,
67
+ dftEl: dftEl,
68
+ color: color
69
+ }));
70
+ }
71
+ return dftEl;
72
+ }
73
+ // propsAreEqual暂时置空
74
+ );
75
+
76
+ exports["default"] = AggregatedCell;
@@ -0,0 +1,97 @@
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 tslib = require('tslib');
17
+ var schemaUtils = require('@hi-ui/schema-utils');
18
+ var schemaFields = require('@hi-ui/schema-fields');
19
+ var schemaForm = require('@hi-ui/schema-form');
20
+ function execCellDepsProcess(ctx) {
21
+ // 直接先处理值依赖
22
+ execCellValueDepFn(ctx);
23
+ // 再处理 Props 依赖
24
+ execCellPropsDepFn(ctx);
25
+ }
26
+ /**
27
+ * 处理表格单元格中的值依赖逻辑
28
+ */
29
+ function execCellValueDepFn(ctx) {
30
+ var _rowIndex, _tableValue$mergeSile;
31
+ var fieldProps = ctx.fieldProps;
32
+ var field = fieldProps.field;
33
+ // 检查字段是否有依赖配置
34
+ if (!field.dependency) return; // 没有配置依赖,直接退出
35
+ var _field$dependency = field.dependency,
36
+ deps = _field$dependency.deps,
37
+ depValueFn = _field$dependency.value;
38
+ if (!deps.length || !depValueFn) return; // 没有依赖或依赖函数,直接退出
39
+ var rowIndex = ctx.rowIndex,
40
+ changedDepValues = ctx.changedDepValues;
41
+ var currentDepValues = changedDepValues[rowIndex];
42
+ // 依赖值不存在,直接退出
43
+ if (!currentDepValues) return;
44
+ // 检查依赖的字段是否存在于当前变更的值上
45
+ // NOTE 此处仅检测了第一层的属性,暂时不支持嵌套属性的情况
46
+ var hasChanged = deps.some(function (name) {
47
+ return name in (currentDepValues || {});
48
+ });
49
+ // 依赖字段变更,才需要执行 depValueFn
50
+ if (!hasChanged) return;
51
+ var rowData = ctx.rowData,
52
+ dataKey = ctx.dataKey,
53
+ changedFieldNames = ctx.changedFieldNames,
54
+ tableValue = ctx.tableValue;
55
+ var nextValue = depValueFn(currentDepValues, {
56
+ allValues: rowData,
57
+ changedDepKeys: changedFieldNames || [],
58
+ rowIndex: rowIndex,
59
+ dataKey: dataKey,
60
+ formRef: {
61
+ current: null
62
+ },
63
+ // TODO 待更新实现
64
+ batchUpdate: schemaFields.BatchDepUpdate.update
65
+ });
66
+ var finalValue = schemaFields.BatchDepUpdate.getValues(dataKey, nextValue);
67
+ var _a = finalValue,
68
+ _b = dataKey,
69
+ fieldValue = _a[_b],
70
+ restDepValues = tslib.__rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
71
+ // 关键赋值
72
+ fieldProps.value = fieldValue;
73
+ fieldProps.ctx.formBinding.value = fieldValue;
74
+ // 还要合并到 TableValue 上,但是不再触发订阅
75
+ tableValue.mergeSilently((_tableValue$mergeSile = {}, _tableValue$mergeSile[rowIndex] = (_rowIndex = {}, _rowIndex[dataKey] = nextValue, _rowIndex), _tableValue$mergeSile));
76
+ // 存在批量更新的值时,一并写到 TableValue 上,并且触发订阅
77
+ schemaUtils.Schedular.nextMicro(function () {
78
+ var _tableValue$mergeValu;
79
+ tableValue.mergeValue((_tableValue$mergeValu = {}, _tableValue$mergeValu[rowIndex] = restDepValues, _tableValue$mergeValu));
80
+ });
81
+ }
82
+ /**
83
+ * 处理表格单元格中的 Props 依赖逻辑
84
+ */
85
+ function execCellPropsDepFn(ctx) {
86
+ var nextField = schemaForm.generateDepPropsField(ctx.fieldProps.field, {
87
+ formRef: {},
88
+ depValues: ctx.changedDepValues[ctx.rowIndex],
89
+ changedDepKeys: ctx.changedFieldNames || [],
90
+ allValues: ctx.rowData
91
+ });
92
+ ctx.fieldProps.field = nextField;
93
+ ctx.fieldProps.ctx.field = nextField;
94
+ }
95
+ exports.execCellDepsProcess = execCellDepsProcess;
96
+ exports.execCellPropsDepFn = execCellPropsDepFn;
97
+ exports.execCellValueDepFn = execCellValueDepFn;
@@ -0,0 +1,89 @@
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 schemaUtils = require('@hi-ui/schema-utils');
20
+ var ctx = require('../ctx.js');
21
+ function _interopDefaultCompat(e) {
22
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
23
+ 'default': e
24
+ };
25
+ }
26
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
27
+ function useEditingCellFormBinding(props) {
28
+ var _a;
29
+ var getValue = props.getValue,
30
+ index = props.row.index,
31
+ id = props.column.id,
32
+ table = props.table;
33
+ var _useEditTableCtx = ctx.useEditableSchemaTableCtx(),
34
+ globalStaticRef = _useEditTableCtx.globalStaticRef;
35
+ var enableRowEdit = globalStaticRef.current.enableRowEdit;
36
+ var initialValue = getValue();
37
+ var valueRef = React__default["default"].useRef(initialValue);
38
+ valueRef.current = (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.getCellValue(index, id);
39
+ var forceUpdate = ahooks.useUpdate();
40
+ var updateValue = ahooks.useMemoizedFn(function (nextValue) {
41
+ var _a;
42
+ (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.updateData(index, id, nextValue);
43
+ // 行编辑模式下,强制更新
44
+ if (enableRowEdit) forceUpdate();
45
+ }
46
+ // 移除了此处的防抖函数,原因有2
47
+ // 1. useDebounceFn 内部会在组件卸载时取消,导致 updateValue 失效,无法更新值
48
+ // 2. 大部分内置组件已在更上游处理防抖逻辑,此处没有必要再额外处理了
49
+ );
50
+
51
+ var handleChange = function handleChange(eventOrValue) {
52
+ var nextValue = normalizeValueFromChange(eventOrValue);
53
+ valueRef.current = nextValue;
54
+ updateValue(nextValue);
55
+ };
56
+ var handleBlur = function handleBlur() {
57
+ // 行编辑模式下,失焦时保持激活状态,不更新值
58
+ if (enableRowEdit) return;
59
+ // 延迟一小会儿再更新值
60
+ schemaUtils.Schedular.nextMicro(function () {
61
+ updateValue(valueRef.current);
62
+ });
63
+ };
64
+ return {
65
+ // NOTE 此处value已被废弃,会在外部由真实的值覆盖
66
+ value: valueRef.current,
67
+ onChange: handleChange,
68
+ onBlur: handleBlur,
69
+ invalid: undefined
70
+ };
71
+ }
72
+ // fork from https://github.com/XiaoMi/hiui/blob/master/packages/ui/form/src/use-form.ts#L303
73
+ function normalizeValueFromChange(eventOrValue) {
74
+ if (!lodashEs.isObjectLike(eventOrValue) || !eventOrValue.target) {
75
+ return eventOrValue;
76
+ }
77
+ var event = eventOrValue;
78
+ // @see https://reactjs.org/docs/events.html#event-pooling
79
+ if (lodashEs.isFunction(event.persist)) {
80
+ event.persist();
81
+ }
82
+ var target = event.target || event.currentTarget;
83
+ // 待验证 // 待支持更多类型
84
+ if (target.type === 'checkbox') return target.checked;
85
+ if (target.type === 'radio') return target.checked;
86
+ return target.value;
87
+ }
88
+ exports.normalizeValueFromChange = normalizeValueFromChange;
89
+ exports.useEditingCellFormBinding = useEditingCellFormBinding;
@@ -0,0 +1,64 @@
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 tslib = require('tslib');
17
+ var React = require('react');
18
+ var lodashEs = require('lodash-es');
19
+ var useSubscription = require('@hi-ui/use-subscription');
20
+ var schemaUtils = require('@hi-ui/schema-utils');
21
+ var ctx = require('../ctx.js');
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
+ var FooterCell = /*#__PURE__*/React__default["default"].memo(function FooterCell(props) {
29
+ var _NumberUtil$chain;
30
+ var _a;
31
+ var field = (_a = props.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.field;
32
+ var _b = ctx.useEditableSchemaTableCtx(),
33
+ table = _b.table,
34
+ subscription = _b.subscription,
35
+ globalStaticRef = _b.globalStaticRef,
36
+ restCtx = tslib.__rest(_b, ["table", "subscription", "globalStaticRef"]);
37
+ var invalidField = !field;
38
+ var isNotNumber = (field === null || field === void 0 ? void 0 : field.valueType) !== 'number';
39
+ var isNotAvailable = invalidField || isNotNumber;
40
+ // 用于在任意字段变更时触发重渲染,因此不关心返回结果
41
+ useSubscription.useSubscribeList(subscription, undefined, {
42
+ // field 不存在或者字段类型不是 number 时,不创建订阅
43
+ skipSubscribe: isNotAvailable
44
+ });
45
+ // 有效字段,且开启了筛选,则订阅筛选状态
46
+ // 不关心实际的筛选结果,仅用来触发更新
47
+ var filterState = globalStaticRef.current.enableFilter && !isNotAvailable ? restCtx.filterState : useSubscription.NOOP_SUBSCRIPTION;
48
+ useSubscription.useSubscribe(filterState, undefined);
49
+ // 首列固定展示 // TODO 待支持动态首列配置
50
+ var colIndex = props.column.getIndex();
51
+ var _enableRowSelection = globalStaticRef.current.enableRowSelection;
52
+ if (colIndex === 0 && !_enableRowSelection) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "\u5408\u8BA1");
53
+ if (isNotAvailable) return null;
54
+ var tableData = subscription.getValue();
55
+ var filteredRows = table.getFilteredRowModel().flatRows;
56
+ var fieldData = filteredRows.map(function (row) {
57
+ return lodashEs.get(tableData, [row.index, field.dataIndex]);
58
+ });
59
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, (_NumberUtil$chain = schemaUtils.NumberUtil.chain(0)).add.apply(_NumberUtil$chain, fieldData).format(2));
60
+ }
61
+ // propsAreEqual暂时置空
62
+ );
63
+
64
+ exports["default"] = FooterCell;
@@ -0,0 +1,76 @@
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 EllipsisTooltip = require('@hi-ui/ellipsis-tooltip');
18
+ var ctx = require('../ctx.js');
19
+ var cls = require('../utils/cls.js');
20
+ var _const = require('../const.js');
21
+ require('lodash-es');
22
+ var getActions = require('../features/header-actions/get-actions.js');
23
+ function _interopDefaultCompat(e) {
24
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
25
+ 'default': e
26
+ };
27
+ }
28
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
29
+ var EllipsisTooltip__default = /*#__PURE__*/_interopDefaultCompat(EllipsisTooltip);
30
+ var HeaderCell = /*#__PURE__*/React__default["default"].memo(function HeaderCell(props) {
31
+ var _a, _b, _c, _d, _e;
32
+ var column = props.column,
33
+ table = props.table;
34
+ var field = (_a = props.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.field;
35
+ var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
36
+ globalStaticRef = _useEditableSchemaTab.globalStaticRef;
37
+ var invalidField = !field;
38
+ if (invalidField) return null;
39
+ // 文本对齐
40
+ var textAlign = (_b = props.column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.align;
41
+ // 系统列仅包含展示功能
42
+ if (_const.isSystemCol(column.id)) {
43
+ return /*#__PURE__*/React__default["default"].createElement("div", {
44
+ className: cls.cls('header-cell-content'),
45
+ "data-text-align": textAlign
46
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
47
+ className: cls.cls('header-cell-content-title')
48
+ }, field.title));
49
+ }
50
+ // 表头操作
51
+ var actions = getActions.getHeaderActions({
52
+ column: column,
53
+ table: table,
54
+ field: field,
55
+ globalStaticRef: globalStaticRef
56
+ });
57
+ var hoverOnly = ((_d = (_c = field.control) === null || _c === void 0 ? void 0 : _c.hoverOnly) !== null && _d !== void 0 ? _d : globalStaticRef.current.enableHeaderActionHoverOnly) || undefined;
58
+ return /*#__PURE__*/React__default["default"].createElement("div", {
59
+ className: cls.cls('header-cell-content'),
60
+ "data-text-align": textAlign,
61
+ "data-has-children": field.children ? true : undefined,
62
+ "data-has-filter": (actions === null || actions === void 0 ? void 0 : actions.filterAvailable) || undefined,
63
+ "data-has-sorter": (actions === null || actions === void 0 ? void 0 : actions.sorterAvailable) || undefined,
64
+ "data-actions-count": (actions === null || actions === void 0 ? void 0 : actions.elements.length) || undefined,
65
+ "data-is-required": (_e = field.control) === null || _e === void 0 ? void 0 : _e.required,
66
+ "data-hover-only": hoverOnly
67
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
68
+ className: cls.cls('header-cell-content-title')
69
+ }, /*#__PURE__*/React__default["default"].createElement(EllipsisTooltip__default["default"], null, field.title)), /*#__PURE__*/React__default["default"].createElement("span", {
70
+ className: cls.cls('header-cell-content-actions')
71
+ }, actions === null || actions === void 0 ? void 0 : actions.elements));
72
+ }
73
+ // propsAreEqual暂时置空
74
+ );
75
+
76
+ exports["default"] = HeaderCell;