@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,159 @@
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
+ import React, { useRef } from 'react';
11
+ import Space from '@hi-ui/space';
12
+ import Switch from '@hi-ui/switch';
13
+ import { getPaginationRowModel } from '@tanstack/react-table';
14
+ import { useEditableSchemaTableCtx } from '../../ctx.js';
15
+ import { cls } from '../../utils/cls.js';
16
+ import 'lodash-es';
17
+ import 'ahooks';
18
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
19
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
20
+ if (it) return (it = it.call(o)).next.bind(it);
21
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
22
+ if (it) o = it;
23
+ var i = 0;
24
+ return function () {
25
+ if (i >= o.length) return {
26
+ done: true
27
+ };
28
+ return {
29
+ done: false,
30
+ value: o[i++]
31
+ };
32
+ };
33
+ }
34
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _unsupportedIterableToArray(o, minLen) {
37
+ if (!o) return;
38
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
39
+ var n = Object.prototype.toString.call(o).slice(8, -1);
40
+ if (n === "Object" && o.constructor) n = o.constructor.name;
41
+ if (n === "Map" || n === "Set") return Array.from(o);
42
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
43
+ }
44
+ function _arrayLikeToArray(arr, len) {
45
+ if (len == null || len > arr.length) len = arr.length;
46
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
47
+ arr2[i] = arr[i];
48
+ }
49
+ return arr2;
50
+ }
51
+ var dftFormatter = function dftFormatter(selectedCount) {
52
+ return "\u5DF2\u9009 " + selectedCount + " \u9879";
53
+ };
54
+ function RowSelectionIndicator() {
55
+ var _useEditableSchemaTab = useEditableSchemaTableCtx(),
56
+ table = _useEditableSchemaTab.table,
57
+ propsRef = _useEditableSchemaTab.propsRef;
58
+ // 经过性能优化,已移除额外订阅
59
+ // 此时保留,反而会导致本组件重复重渲染
60
+ // 保留此处注释,用以后续调整
61
+ // const { rowSelectionState } = useEditableSchemaTableCtx()
62
+ // useSubscribe(rowSelectionState)
63
+ var selectedCount = table.$getRowSelection().selectedRowKeys.length;
64
+ var _ref = propsRef.current.rowSelection || {},
65
+ _ref$enableIndicator = _ref.enableIndicator,
66
+ enableIndicator = _ref$enableIndicator === void 0 ? {} : _ref$enableIndicator;
67
+ var _enableIndicator$form = enableIndicator.formatter,
68
+ formatter = _enableIndicator$form === void 0 ? dftFormatter : _enableIndicator$form,
69
+ enableOnlyShowSelected = enableIndicator.enableOnlyShowSelected;
70
+ return /*#__PURE__*/React.createElement("div", {
71
+ className: cls('row-selection-indicator')
72
+ }, /*#__PURE__*/React.createElement(Space, {
73
+ wrap: false,
74
+ style: {
75
+ whiteSpace: 'nowrap'
76
+ },
77
+ separator: enableOnlyShowSelected ? /*#__PURE__*/React.createElement("span", {
78
+ style: {
79
+ color: 'rgba(0, 0, 0, 0.06)'
80
+ }
81
+ }, "|") : null
82
+ }, /*#__PURE__*/React.createElement("span", null, formatter(selectedCount)), enableOnlyShowSelected ? /*#__PURE__*/React.createElement(OnlyShowSelected, {
83
+ selectedCount: selectedCount
84
+ }) : null));
85
+ }
86
+ function OnlyShowSelected(_ref2) {
87
+ var selectedCount = _ref2.selectedCount;
88
+ var _useEditableSchemaTab2 = useEditableSchemaTableCtx(),
89
+ table = _useEditableSchemaTab2.table,
90
+ subscription = _useEditableSchemaTab2.subscription,
91
+ setDynamicOpts = _useEditableSchemaTab2.setDynamicOpts;
92
+ var checkedRef = useRef(false);
93
+ // 如果未选中行,且未开启开关,则禁用
94
+ var disabled = selectedCount === 0 && !checkedRef.current;
95
+ var prePaginationState = useRef();
96
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Switch, {
97
+ disabled: disabled,
98
+ content: ['开', '关'],
99
+ onChange: function onChange(checked) {
100
+ checkedRef.current = checked;
101
+ if (checked) {
102
+ var keys = table.$getRowSelection().selectedRowKeys;
103
+ var rowDataList = [];
104
+ for (var _iterator = _createForOfIteratorHelperLoose(keys), _step; !(_step = _iterator()).done;) {
105
+ var rowId = _step.value;
106
+ var data = table.$getRealtimeRowData(rowId) || table.$selectedRowsCache.get(rowId);
107
+ if (data) rowDataList.push(data);
108
+ }
109
+ // 先静默更新内部订阅
110
+ subscription.setValue(rowDataList, {
111
+ silent: true
112
+ });
113
+ // 再更新分页状态
114
+ table.setPagination(function (state) {
115
+ // 暂存分页状态
116
+ prePaginationState.current = state;
117
+ var rowCount = rowDataList.length;
118
+ return Object.assign(Object.assign({}, state), {
119
+ pageIndex: 0,
120
+ rowCount: rowCount,
121
+ $fromCustom: true
122
+ });
123
+ });
124
+ // 最后换成前端分页
125
+ setDynamicOpts({
126
+ manualPagination: false,
127
+ getPaginationRowModel: getPaginationRowModel()
128
+ });
129
+ } else {
130
+ // 先恢复内部订阅
131
+ subscription.setValue(subscription.getPrevValue(), {
132
+ silent: true
133
+ });
134
+ // 再恢复分页状态
135
+ table.setPagination(function (state) {
136
+ var preState = prePaginationState.current;
137
+ // 清空暂存的分页状态
138
+ prePaginationState.current = undefined;
139
+ return Object.assign(Object.assign({}, preState), {
140
+ $fromCustom: false
141
+ });
142
+ });
143
+ // 最后恢复成后端分页
144
+ setDynamicOpts({
145
+ manualPagination: true,
146
+ getPaginationRowModel: undefined
147
+ });
148
+ }
149
+ }
150
+ }), /*#__PURE__*/React.createElement("span", {
151
+ style: {
152
+ position: 'relative',
153
+ top: 1,
154
+ marginLeft: 8,
155
+ userSelect: 'none'
156
+ }
157
+ }, "\u4EC5\u663E\u793A\u5DF2\u9009"));
158
+ }
159
+ export { RowSelectionIndicator };
@@ -0,0 +1,107 @@
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
+ import React from 'react';
11
+ import { cls } from '../../utils/cls.js';
12
+ import { useEditableSchemaTableCtx } from '../../ctx.js';
13
+ import '../../container/index.js';
14
+ import { useSyncHoverStyle } from './hooks/use-sync-hover-style.js';
15
+ import { useClickSelect } from './hooks/use-click-select.js';
16
+ import { SelectionHeaderCell, SelectionBodyCell } from './cell.js';
17
+ import '@hi-ui/use-subscription';
18
+ import 'ahooks';
19
+ import 'lodash-es';
20
+ import '@hi-ui/space';
21
+ import '@hi-ui/switch';
22
+ import '@tanstack/react-table';
23
+ import { useTableContainer } from '../../container/ctx.js';
24
+ function SelectionTable(props) {
25
+ var width = 50;
26
+ return /*#__PURE__*/React.createElement("table", {
27
+ className: cls('mock-selection'),
28
+ "data-is-selection": true
29
+ }, /*#__PURE__*/React.createElement("colgroup", null, /*#__PURE__*/React.createElement("col", {
30
+ style: {
31
+ width: width,
32
+ minWidth: width
33
+ }
34
+ })), props.children);
35
+ }
36
+ function SelectionHeader() {
37
+ return /*#__PURE__*/React.createElement(SelectionTable, null, /*#__PURE__*/React.createElement("thead", {
38
+ className: cls('header'),
39
+ style: {
40
+ height: '100%'
41
+ }
42
+ }, /*#__PURE__*/React.createElement("tr", {
43
+ className: cls('header-row')
44
+ }, /*#__PURE__*/React.createElement("th", {
45
+ className: cls('header-cell'),
46
+ "data-text-align": "center"
47
+ }, /*#__PURE__*/React.createElement(SelectionHeaderCell, null)))));
48
+ }
49
+ function SelectionBody() {
50
+ var _a, _b, _c, _d, _e, _f, _g, _h;
51
+ var _useEditableSchemaTab = useEditableSchemaTableCtx(),
52
+ table = _useEditableSchemaTab.table;
53
+ var _useTableContainer = useTableContainer(),
54
+ virtualize = _useTableContainer.virtualize;
55
+ var _table$getRowModel = table.getRowModel(),
56
+ realRows = _table$getRowModel.rows;
57
+ // 同步表格行的 hover 状态
58
+ useSyncHoverStyle();
59
+ // 点击行选择 // 内部有开关决定是否启用
60
+ useClickSelect();
61
+ return /*#__PURE__*/React.createElement(SelectionTable, null, /*#__PURE__*/React.createElement("tbody", {
62
+ className: cls('body')
63
+ }, ((_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.createElement("tr", {
64
+ className: cls('body-row', 'virtual-spacer', 'virtual-spacer-top')
65
+ }, /*#__PURE__*/React.createElement("td", {
66
+ style: {
67
+ 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
68
+ }
69
+ }))), ((virtualize === null || virtualize === void 0 ? void 0 : virtualize.rows) || realRows).map(function (rowOrVirtual) {
70
+ var row = 'id' in rowOrVirtual ? rowOrVirtual : realRows[rowOrVirtual.index];
71
+ if (!row) return null;
72
+ return /*#__PURE__*/React.createElement("tr", {
73
+ key: row.id,
74
+ className: cls('body-row'),
75
+ "data-index": row.index,
76
+ "data-id": row.id
77
+ }, /*#__PURE__*/React.createElement("td", {
78
+ className: cls('body-cell'),
79
+ "data-text-align": "center"
80
+ }, /*#__PURE__*/React.createElement(SelectionBodyCell, {
81
+ row: row
82
+ })));
83
+ }), ((_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.createElement("tr", {
84
+ className: cls('body-row', 'virtual-spacer', 'virtual-spacer-bottom')
85
+ }, /*#__PURE__*/React.createElement("td", {
86
+ style: {
87
+ 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
88
+ }
89
+ })))));
90
+ }
91
+ // 暂时用不上,预留位置待扩展
92
+ function SelectionFooter() {
93
+ return /*#__PURE__*/React.createElement(SelectionTable, null, /*#__PURE__*/React.createElement("tfoot", {
94
+ className: cls('footer')
95
+ }, /*#__PURE__*/React.createElement("tr", {
96
+ className: cls('footer-row')
97
+ }, /*#__PURE__*/React.createElement("td", {
98
+ className: cls('footer-cell'),
99
+ "data-text-align": "center"
100
+ }))));
101
+ }
102
+ var RowSelection = {
103
+ Header: SelectionHeader,
104
+ Body: SelectionBody,
105
+ Footer: SelectionFooter
106
+ };
107
+ export { RowSelection };
@@ -0,0 +1,50 @@
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
+ import { useMemo } from 'react';
11
+
12
+ /**
13
+ * 将字段配置转换为列设置需要的格式
14
+ */
15
+ function mapFieldsToColumns(fields) {
16
+ return fields.map(function (field) {
17
+ var _a, _b;
18
+ return {
19
+ id: field.dataIndex,
20
+ title: (typeof field.title === 'string' ? field.title : field._titleText) || field.dataIndex,
21
+ fixed: ((_a = field.control) === null || _a === void 0 ? void 0 : _a.fixed) || false,
22
+ hidden: (_b = field.control) === null || _b === void 0 ? void 0 : _b.hidden
23
+ };
24
+ });
25
+ }
26
+ function useTableSetting(props) {
27
+ var columns = useMemo(function () {
28
+ return mapFieldsToColumns(props.fields);
29
+ }, [props.fields]);
30
+ // 处理列设置变更
31
+ var handleSettingChange = function handleSettingChange(result) {
32
+ var _a, _b;
33
+ var table = (_a = props.tableRef.current) === null || _a === void 0 ? void 0 : _a.table;
34
+ if (!table) return;
35
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, result);
36
+ table.setState(function (state) {
37
+ return Object.assign(Object.assign({}, state), {
38
+ columnOrder: result.keys,
39
+ columnPinning: result.grouped.fixed,
40
+ columnVisibility: result.grouped.visibility
41
+ });
42
+ });
43
+ };
44
+ return {
45
+ columns: columns,
46
+ storageKey: props.storageKey,
47
+ onChange: handleSettingChange
48
+ };
49
+ }
50
+ export { mapFieldsToColumns, useTableSetting };
@@ -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
+ import React, { useEffect } from 'react';
11
+ import { TableSorter } from '@hi-ui/schema-table-extensions';
12
+ import { useSubscribe } from '@hi-ui/use-subscription';
13
+ import { getBoolConfig, mergeProps } from '@hi-ui/schema-utils';
14
+ import { useEditableSchemaTableCtx } from '../../ctx.js';
15
+ function TableSorterBridge(props) {
16
+ var _a;
17
+ var column = props.column,
18
+ sorterConfig = props.sorter;
19
+ var _useEditTableCtx = useEditableSchemaTableCtx(),
20
+ sorterState = _useEditTableCtx.sorterState,
21
+ propsRef = _useEditTableCtx.propsRef;
22
+ var _React$useState = React.useState(null),
23
+ direction = _React$useState[0],
24
+ setDirection = _React$useState[1];
25
+ // 列的排序状态会受到全局排序状态的影响
26
+ // 全局变更时,主动触发一次自身的重渲染
27
+ useSubscribe(sorterState);
28
+ // 外部主动设置时自动更新至内部
29
+ var sorterValue = column.getIsSorted();
30
+ useEffect(function () {
31
+ setDirection(sorterValue || null);
32
+ }, [sorterValue]);
33
+ var handleChange = function handleChange(direction) {
34
+ setDirection(direction);
35
+ // 取消排序时,需要主动清除排序状态
36
+ if (direction === null) {
37
+ column.clearSorting();
38
+ return;
39
+ }
40
+ var isDesc = direction === 'desc';
41
+ // toggleSorting 需要手动传入是否降序,是否可多排序
42
+ column.toggleSorting(isDesc, column.getCanMultiSort());
43
+ };
44
+ var fieldTooltipConfig = getBoolConfig(sorterConfig === null || sorterConfig === void 0 ? void 0 : sorterConfig.tooltip, {});
45
+ var propsTooltipConfig = (_a = propsRef.current.sorter) === null || _a === void 0 ? void 0 : _a.tooltip;
46
+ var tooltip = fieldTooltipConfig || propsTooltipConfig ? mergeProps(propsTooltipConfig, fieldTooltipConfig) : undefined;
47
+ return /*#__PURE__*/React.createElement(TableSorter, {
48
+ direction: direction,
49
+ onChange: handleChange,
50
+ tooltip: tooltip
51
+ });
52
+ }
53
+ export { TableSorterBridge };
@@ -0,0 +1,41 @@
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
+ import { getBoolConfig, localCompare } from '@hi-ui/schema-utils';
11
+ function getSorterConfig(field, ctx) {
12
+ var _a;
13
+ var sorterConfig = (_a = field.control) === null || _a === void 0 ? void 0 : _a.sorter;
14
+ if (!sorterConfig) return undefined;
15
+ var propsRef = ctx.propsRef;
16
+ var tableSorterConfig = propsRef.current.sorter;
17
+ var config = getBoolConfig(sorterConfig, {
18
+ sortingFn: 'textLocalCompare'
19
+ }, {
20
+ mergeDft: true
21
+ });
22
+ if (config) {
23
+ // 如果配置为 textLocalCompare,则使用内置的 textLocalCompare 函数
24
+ if (config.sortingFn === 'textLocalCompare') config.sortingFn = textLocalCompare;
25
+ // 如果字段配置了 sortUndefined,则优先使用字段配置的 sortUndefined
26
+ // 否则使用表格配置的 sortUndefined
27
+ config.sortUndefined = config.sortUndefined || (tableSorterConfig === null || tableSorterConfig === void 0 ? void 0 : tableSorterConfig.sortUndefined);
28
+ }
29
+ return config;
30
+ }
31
+ function textLocalCompare(rowA, rowB, columnId) {
32
+ try {
33
+ var a = rowA.getValue(columnId);
34
+ var b = rowB.getValue(columnId);
35
+ return localCompare(a, b);
36
+ } catch (error) {
37
+ console.log('textLocalCompare', error);
38
+ return 0;
39
+ }
40
+ }
41
+ export { getSorterConfig };
@@ -0,0 +1,24 @@
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
+ import { useSubscription } from '@hi-ui/use-subscription';
11
+ import '@tanstack/react-table';
12
+ import '../../utils/cls.js';
13
+ import 'react';
14
+ import 'lodash-es';
15
+ import 'ahooks';
16
+ import '@hi-ui/schema-utils';
17
+ import '@hi-ui/schema-table-extensions';
18
+ function useSorterState() {
19
+ var sorterState = useSubscription([]);
20
+ return {
21
+ sorterState: sorterState
22
+ };
23
+ }
24
+ export { useSorterState };
@@ -0,0 +1,75 @@
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
+ import { getSortedRowModel } from '@tanstack/react-table';
11
+ import '../../utils/cls.js';
12
+ import 'react';
13
+ import 'lodash-es';
14
+ import 'ahooks';
15
+ import { ensureStateFields } from '../../utils/state-merge.js';
16
+ function useSorterOpts(ctx) {
17
+ var innerRef = ctx.innerRef,
18
+ propsRef = ctx.propsRef,
19
+ staticOptsRef = ctx.staticOptsRef;
20
+ return getSorterOptions({
21
+ innerRef: innerRef,
22
+ propsRef: propsRef,
23
+ staticOptsRef: staticOptsRef
24
+ });
25
+ }
26
+ /**
27
+ * 获取表格排序配置选项
28
+ */
29
+ function getSorterOptions(ctx) {
30
+ var _ctx$staticOptsRef$cu = ctx.staticOptsRef.current,
31
+ enableSorter = _ctx$staticOptsRef$cu.enableSorter,
32
+ enableRemoteSorter = _ctx$staticOptsRef$cu.enableRemoteSorter;
33
+ if (!enableSorter) return {};
34
+ var sorterOpts = ctx.propsRef.current.sorter;
35
+ if (!sorterOpts) return {};
36
+ var onSortingChange = function onSortingChange(updater) {
37
+ var _a, _b;
38
+ var innerRef = ctx.innerRef;
39
+ var _innerRef$current = innerRef.current,
40
+ table = _innerRef$current.table,
41
+ propsRef = _innerRef$current.propsRef;
42
+ var state = table.getState().sorting;
43
+ var newState = typeof updater === 'function' ? updater(state) : updater;
44
+ // 先更新内部状态
45
+ table.setState(function (state) {
46
+ return Object.assign(Object.assign({}, state), {
47
+ sorting: newState
48
+ });
49
+ });
50
+ // 再更新订阅
51
+ innerRef.current.sorterState.setValue(newState);
52
+ // 通知外部更新
53
+ var notifyState = ensureStateFields(state, newState, 'desc', undefined);
54
+ (_b = (_a = propsRef.current.sorter) === null || _a === void 0 ? void 0 : _a.onChange) === null || _b === void 0 ? void 0 : _b.call(_a, notifyState, {
55
+ rawState: newState
56
+ });
57
+ };
58
+ if (enableRemoteSorter) {
59
+ return {
60
+ manualSorting: true,
61
+ enableMultiSort: sorterOpts.enableMultiSort,
62
+ maxMultiSortColCount: sorterOpts.maxMultiSortColCount,
63
+ onSortingChange: onSortingChange
64
+ };
65
+ }
66
+ return {
67
+ manualSorting: false,
68
+ enableMultiSort: sorterOpts.enableMultiSort,
69
+ maxMultiSortColCount: sorterOpts.maxMultiSortColCount,
70
+ // 前端排序,使用 getSortedRowModel
71
+ getSortedRowModel: getSortedRowModel(),
72
+ onSortingChange: onSortingChange
73
+ };
74
+ }
75
+ export { getSorterOptions, useSorterOpts };
@@ -0,0 +1,92 @@
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
+ import React, { useRef, useEffect } from 'react';
11
+ import { omit } from 'lodash-es';
12
+ import { useControllableValue } from 'ahooks';
13
+ import { useSchemaFormCtx } from '@hi-ui/schema-form';
14
+ import { mergeProps } from '@hi-ui/schema-utils';
15
+ import '../container/index.js';
16
+ import '../utils/cls.js';
17
+ import '@hi-ui/classname';
18
+ import '@tanstack/react-table';
19
+ import '@hi-ui/icons';
20
+ import '@hi-ui/schema-hooks';
21
+ import '../cell/index.js';
22
+ import { EditableSchemaTable } from '../table.js';
23
+ import '@tanstack/react-virtual';
24
+ import '@hi-ui/schema-action-trigger';
25
+ import '@hi-ui/pagination';
26
+ import '@hi-ui/use-subscription';
27
+ import '@hi-ui/checkbox';
28
+ import '@hi-ui/radio';
29
+ import '@hi-ui/space';
30
+ import '@hi-ui/switch';
31
+ import '@babel/runtime/regenerator';
32
+ import 'tslib';
33
+ import '@hi-ui/schema-table-extensions';
34
+ import '@babel/runtime/helpers/esm/createClass';
35
+ import 'immer';
36
+ import '@hi-ui/use-id';
37
+ import '@babel/runtime/helpers/esm/inheritsLoose';
38
+ import '@hi-ui/schema-fields';
39
+ import { Toolbar } from './toolbar.js';
40
+ function EditTableBridge(props) {
41
+ var _a, _b, _c;
42
+ var wrapperElRef = useRef(null);
43
+ var _useSchemaFormCtx = useSchemaFormCtx(),
44
+ formRef = _useSchemaFormCtx.formRef;
45
+ var tableCtxRef = useRef(null);
46
+ var _useControllableValue = useControllableValue(props),
47
+ values = _useControllableValue[0],
48
+ setValues = _useControllableValue[1];
49
+ // value 变更时,需经过 subscription 主动设置,方可生效
50
+ useEffect(function () {
51
+ var _a;
52
+ var complete = !props.doNotCompleteRerender;
53
+ (_a = tableCtxRef.current) === null || _a === void 0 ? void 0 : _a.subscription.setValue(props.value || [], {
54
+ complete: complete
55
+ });
56
+ }, [props.value, tableCtxRef, props.doNotCompleteRerender]);
57
+ var handleValuesChange = function handleValuesChange(changed, allValues) {
58
+ var _a;
59
+ // console.log('handleValuesChange',changed, allValues)
60
+ (_a = props.onValuesChange) === null || _a === void 0 ? void 0 : _a.call(props, changed, allValues);
61
+ setValues(allValues);
62
+ };
63
+ var finalProps = mergeProps({
64
+ fields: props.fields,
65
+ sticky: true
66
+ }, omit(props, [
67
+ // 移除无关的属性
68
+ 'value', 'defaultValue', 'onChange', 'innerCtxRef', 'catchInnerCtx']));
69
+ // 捕获内部引用
70
+ (_a = props.catchInnerCtx) === null || _a === void 0 ? void 0 : _a.call(props, {
71
+ tableCtx: tableCtxRef.current
72
+ });
73
+ return /*#__PURE__*/React.createElement("div", {
74
+ className: "pro-edit-table",
75
+ ref: wrapperElRef
76
+ }, props.toolbar === false ? null : ( /*#__PURE__*/React.createElement(Toolbar, {
77
+ ctx: {
78
+ tableFields: finalProps.fields,
79
+ tableCtxRef: tableCtxRef,
80
+ fullscreenElRef: wrapperElRef,
81
+ formRef: formRef,
82
+ readonly: props.readonly
83
+ },
84
+ left: (_b = props.toolbar) === null || _b === void 0 ? void 0 : _b.left,
85
+ right: props.actions || ((_c = props.toolbar) === null || _c === void 0 ? void 0 : _c.right)
86
+ })), /*#__PURE__*/React.createElement(EditableSchemaTable, Object.assign({}, finalProps, {
87
+ defaultValue: values,
88
+ innerCtxRef: tableCtxRef,
89
+ onValuesChange: handleValuesChange
90
+ })));
91
+ }
92
+ export { EditTableBridge };
@@ -0,0 +1,44 @@
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
+ import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
11
+ import React from 'react';
12
+ import { ProField } from '@hi-ui/schema-fields';
13
+ import { EditTableBridge } from './bridge.js';
14
+ var ProEditTable = /*#__PURE__*/function (_ProField) {
15
+ _inheritsLoose(ProEditTable, _ProField);
16
+ function ProEditTable() {
17
+ return _ProField.apply(this, arguments) || this;
18
+ }
19
+ var _proto = ProEditTable.prototype;
20
+ _proto.render = function render(data, ctx) {
21
+ if (data === void 0) {
22
+ data = [];
23
+ }
24
+ var fieldProps = this.getFieldProps({
25
+ fields: []
26
+ }, ctx);
27
+ return /*#__PURE__*/React.createElement(EditTableBridge, Object.assign({}, fieldProps, {
28
+ value: data,
29
+ readonly: true
30
+ }));
31
+ };
32
+ _proto.renderCell = function renderCell() {
33
+ return /*#__PURE__*/React.createElement(React.Fragment, null); // 表格不允许嵌套在单元格中
34
+ };
35
+
36
+ _proto.renderFormItem = function renderFormItem(_, ctx) {
37
+ var fieldProps = this.getFieldProps({
38
+ fields: []
39
+ }, ctx);
40
+ return /*#__PURE__*/React.createElement(EditTableBridge, Object.assign({}, fieldProps));
41
+ };
42
+ return ProEditTable;
43
+ }(ProField);
44
+ export { EditTableBridge, ProEditTable };