@zhenliang/sheet 0.1.22 → 0.1.24

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 (200) hide show
  1. package/dist/core/config.d.ts +13 -0
  2. package/dist/core/config.d.ts.map +1 -0
  3. package/dist/core/config.js +13 -0
  4. package/dist/core/editor/cascaderEditor/index.d.ts +5 -0
  5. package/dist/core/editor/cascaderEditor/index.d.ts.map +1 -0
  6. package/dist/core/editor/cascaderEditor/index.js +53 -0
  7. package/dist/core/editor/cascaderEditor/index.less +32 -0
  8. package/dist/core/editor/dateEditor/index.d.ts +5 -0
  9. package/dist/core/editor/dateEditor/index.d.ts.map +1 -0
  10. package/dist/core/editor/dateEditor/index.js +56 -0
  11. package/dist/core/editor/dateEditor/index.less +18 -0
  12. package/dist/core/editor/index.d.ts +4 -0
  13. package/dist/core/editor/index.d.ts.map +1 -0
  14. package/dist/core/editor/index.js +4 -0
  15. package/dist/core/editor/numberEditor/index.d.ts +8 -0
  16. package/dist/core/editor/numberEditor/index.d.ts.map +1 -0
  17. package/dist/core/editor/numberEditor/index.js +107 -0
  18. package/dist/core/editor/numberEditor/index.less +30 -0
  19. package/dist/core/editor/selectEditor/index.d.ts +6 -0
  20. package/dist/core/editor/selectEditor/index.d.ts.map +1 -0
  21. package/dist/core/editor/selectEditor/index.js +96 -0
  22. package/dist/core/editor/selectEditor/index.less +48 -0
  23. package/dist/core/reducers/index.d.ts +9 -0
  24. package/dist/core/reducers/index.d.ts.map +1 -0
  25. package/dist/core/reducers/index.js +38 -0
  26. package/dist/core/reducers/keyboardReducer.d.ts +2 -0
  27. package/dist/core/reducers/keyboardReducer.d.ts.map +1 -0
  28. package/dist/core/reducers/keyboardReducer.js +93 -0
  29. package/dist/core/reducers/mouseReducer.d.ts +2 -0
  30. package/dist/core/reducers/mouseReducer.d.ts.map +1 -0
  31. package/dist/core/reducers/mouseReducer.js +164 -0
  32. package/dist/core/reducers/sideEffectReducer.d.ts +4 -0
  33. package/dist/core/reducers/sideEffectReducer.d.ts.map +1 -0
  34. package/dist/core/reducers/sideEffectReducer.js +378 -0
  35. package/dist/core/reducers/stateReducer.d.ts +2 -0
  36. package/dist/core/reducers/stateReducer.d.ts.map +1 -0
  37. package/dist/core/reducers/stateReducer.js +174 -0
  38. package/dist/core/sheet/Cell.d.ts +4 -0
  39. package/dist/core/sheet/Cell.d.ts.map +1 -0
  40. package/dist/core/sheet/Cell.js +181 -0
  41. package/dist/core/sheet/DataEditor.d.ts +3 -0
  42. package/dist/core/sheet/DataEditor.d.ts.map +1 -0
  43. package/dist/core/sheet/DataEditor.js +24 -0
  44. package/dist/core/sheet/DefaultCell.d.ts +12 -0
  45. package/dist/core/sheet/DefaultCell.d.ts.map +1 -0
  46. package/dist/core/sheet/DefaultCell.js +31 -0
  47. package/dist/core/sheet/DefaultRow.d.ts +12 -0
  48. package/dist/core/sheet/DefaultRow.d.ts.map +1 -0
  49. package/dist/core/sheet/DefaultRow.js +28 -0
  50. package/dist/core/sheet/DefaultRowMapper.d.ts +8 -0
  51. package/dist/core/sheet/DefaultRowMapper.d.ts.map +1 -0
  52. package/dist/core/sheet/DefaultRowMapper.js +18 -0
  53. package/dist/core/sheet/DefaultShell.d.ts +8 -0
  54. package/dist/core/sheet/DefaultShell.d.ts.map +1 -0
  55. package/dist/core/sheet/DefaultShell.js +12 -0
  56. package/dist/core/sheet/Event.d.ts +5 -0
  57. package/dist/core/sheet/Event.d.ts.map +1 -0
  58. package/dist/core/sheet/Event.js +17 -0
  59. package/dist/core/sheet/ValueViewer.d.ts +3 -0
  60. package/dist/core/sheet/ValueViewer.d.ts.map +1 -0
  61. package/dist/core/sheet/ValueViewer.js +9 -0
  62. package/dist/core/sheet/index.d.ts +5 -0
  63. package/dist/core/sheet/index.d.ts.map +1 -0
  64. package/dist/core/sheet/index.js +262 -0
  65. package/dist/core/sheet/index.less +307 -0
  66. package/dist/core/sheet/useCellEvent.d.ts +3 -0
  67. package/dist/core/sheet/useCellEvent.d.ts.map +1 -0
  68. package/dist/core/sheet/useCellEvent.js +22 -0
  69. package/dist/core/sheet/useContextMenu.d.ts +21 -0
  70. package/dist/core/sheet/useContextMenu.d.ts.map +1 -0
  71. package/dist/core/sheet/useContextMenu.js +86 -0
  72. package/dist/core/sheet/useKeyBoardEvent.d.ts +3 -0
  73. package/dist/core/sheet/useKeyBoardEvent.d.ts.map +1 -0
  74. package/dist/core/sheet/useKeyBoardEvent.js +66 -0
  75. package/dist/core/sheet/useMouseEvent.d.ts +3 -0
  76. package/dist/core/sheet/useMouseEvent.d.ts.map +1 -0
  77. package/dist/core/sheet/useMouseEvent.js +298 -0
  78. package/dist/core/sheet/useSelectVisible.d.ts +2 -0
  79. package/dist/core/sheet/useSelectVisible.d.ts.map +1 -0
  80. package/dist/core/sheet/useSelectVisible.js +57 -0
  81. package/dist/core/sheet/useVirtualList.d.ts +7 -0
  82. package/dist/core/sheet/useVirtualList.d.ts.map +1 -0
  83. package/dist/core/sheet/useVirtualList.js +103 -0
  84. package/dist/core/sheet/var.less +41 -0
  85. package/dist/core/shell/draggableShell/index.d.ts +6 -0
  86. package/dist/core/shell/draggableShell/index.d.ts.map +1 -0
  87. package/dist/core/shell/draggableShell/index.js +197 -0
  88. package/dist/core/shell/draggableShell/index.less +16 -0
  89. package/dist/core/shell/tableShell.d.ts +6 -0
  90. package/dist/core/shell/tableShell.d.ts.map +1 -0
  91. package/dist/core/shell/tableShell.js +109 -0
  92. package/dist/core/table/events.d.ts +15 -0
  93. package/dist/core/table/events.d.ts.map +1 -0
  94. package/dist/core/table/events.js +95 -0
  95. package/dist/core/table/index.d.ts +4 -0
  96. package/dist/core/table/index.d.ts.map +1 -0
  97. package/dist/core/table/index.js +313 -0
  98. package/dist/core/table/useGroupConfig.d.ts +2 -0
  99. package/dist/core/table/useGroupConfig.d.ts.map +1 -0
  100. package/dist/core/table/useGroupConfig.js +65 -0
  101. package/dist/core/table/useRowSelection.d.ts +2 -0
  102. package/dist/core/table/useRowSelection.d.ts.map +1 -0
  103. package/dist/core/table/useRowSelection.js +24 -0
  104. package/dist/core/table/util.d.ts +8 -0
  105. package/dist/core/table/util.d.ts.map +1 -0
  106. package/dist/core/table/util.js +29 -0
  107. package/dist/core/util.d.ts +58 -0
  108. package/dist/core/util.d.ts.map +1 -0
  109. package/dist/core/util.js +457 -0
  110. package/dist/core/viewer/btnViewer/index.d.ts +2 -0
  111. package/dist/core/viewer/btnViewer/index.d.ts.map +1 -0
  112. package/dist/core/viewer/btnViewer/index.js +37 -0
  113. package/dist/core/viewer/cascaderViewer/index.d.ts +2 -0
  114. package/dist/core/viewer/cascaderViewer/index.d.ts.map +1 -0
  115. package/dist/core/viewer/cascaderViewer/index.js +16 -0
  116. package/dist/core/viewer/checkViewer/index.d.ts +2 -0
  117. package/dist/core/viewer/checkViewer/index.d.ts.map +1 -0
  118. package/dist/core/viewer/checkViewer/index.js +23 -0
  119. package/dist/core/viewer/editViewer/index.d.ts +2 -0
  120. package/dist/core/viewer/editViewer/index.d.ts.map +1 -0
  121. package/dist/core/viewer/editViewer/index.js +32 -0
  122. package/dist/core/viewer/groupViewer/index.d.ts +2 -0
  123. package/dist/core/viewer/groupViewer/index.d.ts.map +1 -0
  124. package/dist/core/viewer/groupViewer/index.js +38 -0
  125. package/dist/core/viewer/index.d.ts +7 -0
  126. package/dist/core/viewer/index.d.ts.map +1 -0
  127. package/dist/core/viewer/index.js +7 -0
  128. package/dist/core/viewer/selectorViewer/index.d.ts +2 -0
  129. package/dist/core/viewer/selectorViewer/index.d.ts.map +1 -0
  130. package/dist/core/viewer/selectorViewer/index.js +16 -0
  131. package/dist/core/viewer/switchViewer/index.d.ts +2 -0
  132. package/dist/core/viewer/switchViewer/index.d.ts.map +1 -0
  133. package/dist/core/viewer/switchViewer/index.js +22 -0
  134. package/dist/example/antComponent.d.ts +3 -0
  135. package/dist/example/antComponent.d.ts.map +1 -0
  136. package/dist/example/antComponent.js +313 -0
  137. package/dist/example/basic.d.ts +4 -0
  138. package/dist/example/basic.d.ts.map +1 -0
  139. package/dist/example/basic.js +121 -0
  140. package/dist/example/ellipsis.d.ts +3 -0
  141. package/dist/example/ellipsis.d.ts.map +1 -0
  142. package/dist/example/ellipsis.js +64 -0
  143. package/dist/example/fixed.d.ts +3 -0
  144. package/dist/example/fixed.d.ts.map +1 -0
  145. package/dist/example/fixed.js +89 -0
  146. package/dist/example/group.d.ts +3 -0
  147. package/dist/example/group.d.ts.map +1 -0
  148. package/dist/example/group.js +123 -0
  149. package/dist/example/index.less +5 -0
  150. package/dist/example/selection.d.ts +4 -0
  151. package/dist/example/selection.d.ts.map +1 -0
  152. package/dist/example/selection.js +86 -0
  153. package/dist/example/sheet.d.ts +4 -0
  154. package/dist/example/sheet.d.ts.map +1 -0
  155. package/dist/example/sheet.js +397 -0
  156. package/dist/example/valuationAnalyze.d.ts +3 -0
  157. package/dist/example/valuationAnalyze.d.ts.map +1 -0
  158. package/dist/example/valuationAnalyze.js +227 -0
  159. package/dist/hooks/index.d.ts +8 -0
  160. package/dist/hooks/index.d.ts.map +1 -0
  161. package/dist/hooks/index.js +7 -0
  162. package/dist/hooks/useEventBus.d.ts +4 -0
  163. package/dist/hooks/useEventBus.d.ts.map +1 -0
  164. package/dist/hooks/useEventBus.js +17 -0
  165. package/dist/hooks/useKeyboard.d.ts +18 -0
  166. package/dist/hooks/useKeyboard.d.ts.map +1 -0
  167. package/dist/hooks/useKeyboard.js +108 -0
  168. package/dist/hooks/useMiddlewareReducer.d.ts +12 -0
  169. package/dist/hooks/useMiddlewareReducer.d.ts.map +1 -0
  170. package/dist/hooks/useMiddlewareReducer.js +47 -0
  171. package/dist/hooks/useMouse.d.ts +11 -0
  172. package/dist/hooks/useMouse.d.ts.map +1 -0
  173. package/dist/hooks/useMouse.js +68 -0
  174. package/dist/hooks/useSetState.d.ts +2 -0
  175. package/dist/hooks/useSetState.d.ts.map +1 -0
  176. package/dist/hooks/useSetState.js +27 -0
  177. package/dist/hooks/useSheetEvent.d.ts +5 -0
  178. package/dist/hooks/useSheetEvent.d.ts.map +1 -0
  179. package/dist/hooks/useSheetEvent.js +5 -0
  180. package/dist/hooks/useWidthConfig.d.ts +4 -0
  181. package/dist/hooks/useWidthConfig.d.ts.map +1 -0
  182. package/dist/hooks/useWidthConfig.js +5 -0
  183. package/dist/index.d.ts +8 -0
  184. package/dist/index.d.ts.map +1 -0
  185. package/dist/index.js +8 -0
  186. package/dist/standardUtils/index.d.ts +9 -0
  187. package/dist/standardUtils/index.d.ts.map +1 -0
  188. package/dist/standardUtils/index.js +32 -0
  189. package/dist/type/index.d.ts +2 -0
  190. package/dist/type/index.d.ts.map +1 -0
  191. package/dist/type/index.js +4 -0
  192. package/dist/type/sheet.d.ts +205 -0
  193. package/dist/type/sheet.d.ts.map +1 -0
  194. package/dist/type/sheet.js +9 -0
  195. package/dist/type/sheetTable.d.ts +89 -0
  196. package/dist/type/sheetTable.d.ts.map +1 -0
  197. package/dist/type/sheetTable.js +1 -0
  198. package/dist/typings/index.d.ts +1 -0
  199. package/package.json +1 -1
  200. package/changes.md +0 -45
@@ -0,0 +1,41 @@
1
+ .harvest{
2
+ --row-height:40px;
3
+ --cell-font-size:12px;
4
+ --cell-title-font-size:12px;
5
+ --cell-line-height:40px;
6
+ --cell-inner-height:39px;
7
+ --cell-padding-vertical:0;
8
+ --cell-padding-horizontal:5px;
9
+ --cell-border-color: #DDD;
10
+ --cell-background-color:white;
11
+ --cell-title-background-color:#f7f9fc;
12
+ --cell-read-only-background-color:#f7f9fc;
13
+ --cell-hover:white;
14
+ --cell-box-shadow:inset 0 -100px 0 rgba(33, 133, 208, 15%);;
15
+ --cell-fixed-box-shadow-left:inset 10px 0 8px -8px rgba(5, 5, 5,6%);
16
+ --cell-fixed-box-shadow-right:inset -10px 0 8px -8px rgba(5, 5, 5,6%);
17
+ --resizer: #2185d0;
18
+ --color:black;
19
+ --title-color:#999;
20
+ --read-color:#999;
21
+ }
22
+
23
+ .ali-devops{
24
+ --row-height:40px;
25
+ --cell-font-size:14px;
26
+ --cell-line-height:20px;
27
+ --cell-padding-vertical:12px;
28
+ --cell-padding-horizontal:12px;
29
+ --cell-border-color: #e5e5e5;
30
+ --cell-background-color:white;
31
+ --cell-title-background-color:white;
32
+ --cell-read-only-background-color:white;
33
+ --cell-fixed-box-shadow:inset -10px 0 8px -8px rgba(5, 5, 5,6%);
34
+ --cell-hover:#f7f7f7;
35
+ --cell-fixed-box-shadow-left:inset 10px 0 8px -8px rgba(5, 5, 5,6%);
36
+ --cell-fixed-box-shadow-right:inset -10px 0 8px -8px rgba(5, 5, 5,6%);
37
+ --resizer: #1b9aee;
38
+ --color:#262626;
39
+ --title-color:#8c8c8c;
40
+ --read-color:#8c8c8c;
41
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../../type";
3
+ import './index.less';
4
+ export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
5
+ children: React.ReactElement;
6
+ }>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAkB,SAAS,EAAE,sBAA8B;AAMvE,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,cAAc,+EAOxB,UAAU,UAAU;cAET,MAAM,YAAY;EAgN/B,CAAC"}
@@ -0,0 +1,197 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { createElement, useEffect, useMemo, useRef } from 'react';
12
+ import { useSetState, useWidth } from "../../../hooks";
13
+ import { classNames } from "../../util";
14
+ import { CheckViewer } from "../../viewer/checkViewer";
15
+ import { GroupViewer } from "../../viewer/groupViewer";
16
+ import "./index.less";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ import { Fragment as _Fragment } from "react/jsx-runtime";
20
+ export var DraggableShell = function DraggableShell(_ref) {
21
+ var columns = _ref.columns,
22
+ className = _ref.className,
23
+ showGroup = _ref.showGroup,
24
+ showSelect = _ref.showSelect,
25
+ controlProps = _ref.controlProps,
26
+ _ref$controlWidth = _ref.controlWidth,
27
+ controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
28
+ var TableShell = function TableShell(_ref2) {
29
+ var children = _ref2.children;
30
+ var headRef = useRef(null);
31
+ var downRef = useRef(null);
32
+ var _useSetState = useSetState({}),
33
+ _useSetState2 = _slicedToArray(_useSetState, 2),
34
+ _widths = _useSetState2[0],
35
+ _setWidth = _useSetState2[1];
36
+ var _useWidth = useWidth(),
37
+ contextWidths = _useWidth.widths,
38
+ contextSetWidth = _useWidth.onChange;
39
+ var setWidth = contextSetWidth || _setWidth;
40
+ var widths = contextWidths || _widths;
41
+ var hasControl = showGroup || showSelect;
42
+ var thItems = useMemo(function () {
43
+ var ths = [];
44
+ if (hasControl) {
45
+ var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
46
+ ths.push( /*#__PURE__*/_jsxs("th", {
47
+ className: "cell cell-title read-only sheet-control",
48
+ children: [showGroup && /*#__PURE__*/_jsx(GroupViewer, {
49
+ row: -1,
50
+ col: -1,
51
+ value: true,
52
+ record: {
53
+ open: controlProps === null || controlProps === void 0 || (_controlProps$group = controlProps.group) === null || _controlProps$group === void 0 ? void 0 : _controlProps$group.open,
54
+ isHeader: true
55
+ }
56
+ }), showSelect && /*#__PURE__*/_jsx(CheckViewer, {
57
+ row: -1,
58
+ col: -1,
59
+ value: controlProps === null || controlProps === void 0 || (_controlProps$check = controlProps.check) === null || _controlProps$check === void 0 ? void 0 : _controlProps$check.checked,
60
+ record: {
61
+ open: controlProps === null || controlProps === void 0 || (_controlProps$check2 = controlProps.check) === null || _controlProps$check2 === void 0 ? void 0 : _controlProps$check2.checked,
62
+ isHeader: true,
63
+ indeterminate: controlProps === null || controlProps === void 0 || (_controlProps$check3 = controlProps.check) === null || _controlProps$check3 === void 0 ? void 0 : _controlProps$check3.indeterminate
64
+ }
65
+ })]
66
+ }, "-1"));
67
+ }
68
+ columns.forEach(function (item, index) {
69
+ var _item$titleConfig, _item$titleConfig2, _item$titleConfig3, _item$dataIndex, _ref3;
70
+ ((_item$titleConfig = item.titleConfig) === null || _item$titleConfig === void 0 ? void 0 : _item$titleConfig.colSpan) !== 0 && ths.push( /*#__PURE__*/_jsx("th", {
71
+ className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed), (_item$titleConfig2 = item.titleConfig) === null || _item$titleConfig2 === void 0 ? void 0 : _item$titleConfig2.className),
72
+ colSpan: (_item$titleConfig3 = item.titleConfig) === null || _item$titleConfig3 === void 0 ? void 0 : _item$titleConfig3.colSpan,
73
+ style: {
74
+ textAlign: (_ref3 = item.align) !== null && _ref3 !== void 0 ? _ref3 : 'unset',
75
+ left: item.fixed === 'left' ? 0 : 'unset',
76
+ right: item.fixed === 'right' ? 0 : 'unset'
77
+ },
78
+ onMouseDown: function onMouseDown(e) {
79
+ var target = e.target;
80
+ downRef.current = target;
81
+ if (e.nativeEvent.offsetX > target.offsetWidth - 10) {
82
+ downRef.current.mouseDown = true;
83
+ downRef.current.oldX = e.nativeEvent.x;
84
+ downRef.current.oldWidth = downRef.current.offsetWidth;
85
+ } else {
86
+ downRef.current = null;
87
+ }
88
+ },
89
+ onMouseMove: function onMouseMove(e) {
90
+ var target = e.target;
91
+ if (e.nativeEvent.offsetX > target.offsetWidth - 8) {
92
+ target.style.cursor = 'col-resize';
93
+ } else {
94
+ target.style.cursor = 'default';
95
+ }
96
+ //取出暂存的Table Cell
97
+ if (downRef.current === undefined) downRef.current = target;
98
+ //调整宽度
99
+ },
100
+ children: /*#__PURE__*/_jsx("span", {
101
+ className: "value-viewer",
102
+ children: typeof item.title === 'function' ? /*#__PURE__*/createElement(item.title) : item.title
103
+ })
104
+ }, (_item$dataIndex = item.dataIndex) !== null && _item$dataIndex !== void 0 ? _item$dataIndex : index));
105
+ });
106
+ return ths;
107
+ }, [columns]);
108
+ var colItems = useMemo(function () {
109
+ var cols = [];
110
+ if (hasControl) {
111
+ cols.push( /*#__PURE__*/_jsx("col", {
112
+ className: classNames('sheet-control'),
113
+ style: {
114
+ width: controlWidth
115
+ }
116
+ }, "sheet-control"));
117
+ }
118
+ var i = 0;
119
+ columns.forEach(function (item, index) {
120
+ var _item$titleConfig4, _item$dataIndex2;
121
+ var currentWidth = item.width || 'unset';
122
+ if (((_item$titleConfig4 = item.titleConfig) === null || _item$titleConfig4 === void 0 ? void 0 : _item$titleConfig4.colSpan) !== 0) {
123
+ currentWidth = widths[i] || item.width || 'unset';
124
+ i++;
125
+ }
126
+ cols.push( /*#__PURE__*/_jsx("col", {
127
+ className: classNames('cell'),
128
+ style: {
129
+ width: currentWidth
130
+ }
131
+ }, (_item$dataIndex2 = item.dataIndex) !== null && _item$dataIndex2 !== void 0 ? _item$dataIndex2 : index));
132
+ });
133
+ return cols;
134
+ }, [widths, hasControl, columns]);
135
+ useEffect(function () {
136
+ var handleMouseUp = function handleMouseUp() {
137
+ //结束宽度调整
138
+ if (downRef.current) {
139
+ downRef.current.mouseDown = false;
140
+ downRef.current.style.cursor = 'default';
141
+ }
142
+ };
143
+ var handleMouseMove = function handleMouseMove(e) {
144
+ var _downRef$current, _downRef$current2;
145
+ if (!downRef.current || !downRef.current.mouseDown) return;
146
+ if (((_downRef$current = downRef.current) === null || _downRef$current === void 0 ? void 0 : _downRef$current.mouseDown) !== null && ((_downRef$current2 = downRef.current) === null || _downRef$current2 === void 0 ? void 0 : _downRef$current2.mouseDown) === true) {
147
+ var _downRef$current$oldW, _downRef$current$oldX;
148
+ downRef.current.style.cursor = 'default';
149
+ if (((_downRef$current$oldW = downRef.current.oldWidth) !== null && _downRef$current$oldW !== void 0 ? _downRef$current$oldW : 0) + (e.x - ((_downRef$current$oldX = downRef.current.oldX) !== null && _downRef$current$oldX !== void 0 ? _downRef$current$oldX : 0)) > 0) {
150
+ var _downRef$current$oldW2, _downRef$current$oldX2, _headRef$current;
151
+ var newWidth = Math.max(Number(((_downRef$current$oldW2 = downRef.current.oldWidth) !== null && _downRef$current$oldW2 !== void 0 ? _downRef$current$oldW2 : 0) + (e.x - ((_downRef$current$oldX2 = downRef.current.oldX) !== null && _downRef$current$oldX2 !== void 0 ? _downRef$current$oldX2 : 0))), 50);
152
+ var cellList = [].slice.call((_headRef$current = headRef.current) === null || _headRef$current === void 0 ? void 0 : _headRef$current.cells);
153
+ var changeIndex = cellList.indexOf(downRef.current);
154
+ //调整该列中的每个Cell
155
+ var _widths2 = _defineProperty({
156
+ length: columns.length
157
+ }, hasControl ? changeIndex - 1 : changeIndex, newWidth);
158
+ setWidth(_widths2);
159
+ }
160
+ }
161
+ };
162
+ document.addEventListener('mouseup', handleMouseUp);
163
+ document.addEventListener('mousemove', handleMouseMove);
164
+ return function () {
165
+ document.removeEventListener('mouseup', handleMouseUp);
166
+ document.removeEventListener('mousemove', handleMouseMove);
167
+ };
168
+ }, [hasControl]);
169
+ return /*#__PURE__*/_jsxs(_Fragment, {
170
+ children: [/*#__PURE__*/_jsxs("table", {
171
+ className: classNames('header', 'harvest-sheet', className),
172
+ style: {
173
+ position: 'sticky',
174
+ top: 0,
175
+ zIndex: 3
176
+ },
177
+ children: [/*#__PURE__*/_jsx("colgroup", {
178
+ children: colItems
179
+ }), /*#__PURE__*/_jsx("thead", {
180
+ children: /*#__PURE__*/_jsx("tr", {
181
+ ref: headRef,
182
+ children: thItems
183
+ })
184
+ })]
185
+ }, "header"), /*#__PURE__*/_jsxs("table", {
186
+ className: classNames('body', 'harvest-sheet'),
187
+ children: [/*#__PURE__*/_jsx("colgroup", {
188
+ className: "header",
189
+ children: colItems
190
+ }), /*#__PURE__*/_jsx("tbody", {
191
+ children: children
192
+ }, "tbody")]
193
+ }, "body")]
194
+ });
195
+ };
196
+ return TableShell;
197
+ };
@@ -0,0 +1,16 @@
1
+ .left{
2
+ text-align: left;
3
+ }
4
+
5
+ .right{
6
+ text-align: right;
7
+ }
8
+
9
+ .center{
10
+ text-align: center;
11
+ }
12
+
13
+ .sheet-cell-fixed{
14
+ position: sticky;
15
+ z-index: 2;
16
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../type";
3
+ import './draggableShell/index.less';
4
+ export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
5
+ children: React.ReactElement;
6
+ }>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableShell.d.ts","sourceRoot":"","sources":["tableShell.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAkB,SAAS,EAAE,mBAA8B;AAIvE,OAAO,6BAA6B,CAAC;AAErC,eAAO,MAAM,UAAU,+EAOpB,UAAU,UAAU;cAET,MAAM,YAAY;EAwG/B,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { useMemo } from 'react';
2
+ import { classNames } from "../util";
3
+ import { CheckViewer } from "../viewer/checkViewer";
4
+ import { GroupViewer } from "../viewer/groupViewer";
5
+ import "./draggableShell/index.less";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
+ export var TableShell = function TableShell(_ref) {
10
+ var columns = _ref.columns,
11
+ className = _ref.className,
12
+ showGroup = _ref.showGroup,
13
+ showSelect = _ref.showSelect,
14
+ controlProps = _ref.controlProps,
15
+ _ref$controlWidth = _ref.controlWidth,
16
+ controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
17
+ var TableShell = function TableShell(_ref2) {
18
+ var children = _ref2.children;
19
+ var thItems = useMemo(function () {
20
+ var ths = [];
21
+ if (showGroup || showSelect) {
22
+ var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
23
+ ths.push( /*#__PURE__*/_jsxs("th", {
24
+ className: "cell cell-title read-only sheet-control",
25
+ children: [showGroup && /*#__PURE__*/_jsx(GroupViewer, {
26
+ row: -1,
27
+ col: -1,
28
+ value: true,
29
+ record: {
30
+ open: controlProps === null || controlProps === void 0 || (_controlProps$group = controlProps.group) === null || _controlProps$group === void 0 ? void 0 : _controlProps$group.open,
31
+ isHeader: true
32
+ }
33
+ }), showSelect && /*#__PURE__*/_jsx(CheckViewer, {
34
+ row: -1,
35
+ col: -1,
36
+ value: controlProps === null || controlProps === void 0 || (_controlProps$check = controlProps.check) === null || _controlProps$check === void 0 ? void 0 : _controlProps$check.checked,
37
+ record: {
38
+ open: controlProps === null || controlProps === void 0 || (_controlProps$check2 = controlProps.check) === null || _controlProps$check2 === void 0 ? void 0 : _controlProps$check2.checked,
39
+ isHeader: true,
40
+ indeterminate: controlProps === null || controlProps === void 0 || (_controlProps$check3 = controlProps.check) === null || _controlProps$check3 === void 0 ? void 0 : _controlProps$check3.indeterminate
41
+ }
42
+ })]
43
+ }, "-1"));
44
+ }
45
+ columns.forEach(function (item, index) {
46
+ var _item$titleConfig, _item$titleConfig2, _ref3;
47
+ ((_item$titleConfig = item.titleConfig) === null || _item$titleConfig === void 0 ? void 0 : _item$titleConfig.colSpan) !== 0 && ths.push( /*#__PURE__*/_jsx("th", {
48
+ className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed)),
49
+ colSpan: (_item$titleConfig2 = item.titleConfig) === null || _item$titleConfig2 === void 0 ? void 0 : _item$titleConfig2.colSpan,
50
+ style: {
51
+ textAlign: (_ref3 = item.align) !== null && _ref3 !== void 0 ? _ref3 : 'unset',
52
+ left: item.fixed === 'left' ? 0 : 'unset',
53
+ right: item.fixed === 'right' ? 0 : 'unset'
54
+ },
55
+ children: /*#__PURE__*/_jsx("span", {
56
+ className: "value-viewer",
57
+ children: item.title
58
+ })
59
+ }, item.dataIndex || index));
60
+ });
61
+ return ths;
62
+ }, [columns, showGroup || showSelect, controlProps]);
63
+ var colItems = useMemo(function () {
64
+ var cols = [];
65
+ if (showGroup || showSelect) {
66
+ cols.push( /*#__PURE__*/_jsx("col", {
67
+ className: classNames('sheet-control'),
68
+ style: {
69
+ width: controlWidth
70
+ }
71
+ }, "sheet-control"));
72
+ }
73
+ columns.forEach(function (item, index) {
74
+ cols.push( /*#__PURE__*/_jsx("col", {
75
+ className: classNames('cell'),
76
+ style: {
77
+ width: item.width || 'unset'
78
+ }
79
+ }, item.dataIndex || index));
80
+ });
81
+ return cols;
82
+ }, [columns, showGroup || showSelect, controlWidth]);
83
+ return /*#__PURE__*/_jsxs(_Fragment, {
84
+ children: [/*#__PURE__*/_jsxs("table", {
85
+ className: classNames('header', 'harvest-sheet', className),
86
+ style: {
87
+ position: 'sticky',
88
+ top: 0,
89
+ zIndex: 3
90
+ },
91
+ children: [/*#__PURE__*/_jsx("colgroup", {
92
+ children: colItems
93
+ }), /*#__PURE__*/_jsx("thead", {
94
+ children: /*#__PURE__*/_jsx("tr", {
95
+ children: thItems
96
+ })
97
+ })]
98
+ }, "header"), /*#__PURE__*/_jsxs("table", {
99
+ className: classNames('body', 'harvest-sheet'),
100
+ children: [/*#__PURE__*/_jsx("colgroup", {
101
+ children: colItems
102
+ }), /*#__PURE__*/_jsx("tbody", {
103
+ children: children
104
+ }, "tbody")]
105
+ }, "body")]
106
+ });
107
+ };
108
+ return TableShell;
109
+ };
@@ -0,0 +1,15 @@
1
+ import { SheetTableType, SheetType } from "../../type";
2
+ import { FC } from 'react';
3
+ export declare const SelectionEvent: FC<{
4
+ hasChildren: boolean;
5
+ rowSelection?: SheetTableType.TableRowSelection;
6
+ onChange: (value: unknown) => void;
7
+ }>;
8
+ export declare const GroupEvent: FC<{
9
+ hasChildren: boolean;
10
+ rowGroupConfig: SheetType.RowGroupConfig;
11
+ data: SheetType.Cell[][];
12
+ sheetInstance: SheetType.SheetInstance | null;
13
+ onGroupChange: (value: SheetType.RowGroupConfig) => void;
14
+ onGridChange: (value: SheetType.Cell[][]) => void;
15
+ }>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["events.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,mBAA8B;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,cAAc,CAAC,iBAAiB,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAcA,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,SAAS,CAAC,cAAc,CAAC;IACzC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IACzB,aAAa,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9C,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,cAAc,KAAK,IAAI,CAAC;IACzD,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC;CACnD,CA0EA,CAAC"}
@@ -0,0 +1,95 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ import { SheetEvent } from "../sheet/Event";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ export var SelectionEvent = function SelectionEvent(props) {
18
+ var hasChildren = props.hasChildren,
19
+ rowSelection = props.rowSelection,
20
+ onChange = props.onChange;
21
+ if (hasChildren || !rowSelection) return null;
22
+ return /*#__PURE__*/_jsxs(_Fragment, {
23
+ children: [/*#__PURE__*/_jsx(SheetEvent, {
24
+ name: "row-select",
25
+ handler: onChange
26
+ }, "row-select"), /*#__PURE__*/_jsx(SheetEvent, {
27
+ name: "row-select-title",
28
+ handler: onChange
29
+ }, "row-select-title"), ","]
30
+ });
31
+ };
32
+ export var GroupEvent = function GroupEvent(props) {
33
+ var hasChildren = props.hasChildren,
34
+ rowGroupConfig = props.rowGroupConfig,
35
+ data = props.data,
36
+ sheetInstance = props.sheetInstance,
37
+ onGroupChange = props.onGroupChange,
38
+ onGridChange = props.onGridChange;
39
+ if (!hasChildren) return null;
40
+ var _ref = rowGroupConfig || {},
41
+ groups = _ref.groups;
42
+ return /*#__PURE__*/_jsxs(_Fragment, {
43
+ children: [/*#__PURE__*/_jsx(SheetEvent, {
44
+ name: "group-open",
45
+ handler: function handler(e) {
46
+ var _ref2 = e,
47
+ row = _ref2.row;
48
+ var index = groups.findIndex(function (item) {
49
+ return item.groupStart === row;
50
+ });
51
+ if (index >= 0) {
52
+ var groupOpen = _toConsumableArray(rowGroupConfig.groupOpen);
53
+ groupOpen[index] = !rowGroupConfig.groupOpen[index];
54
+ onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
55
+ groupOpen: groupOpen
56
+ }));
57
+ var newGrid = _toConsumableArray(data);
58
+ newGrid[row] = _toConsumableArray(newGrid[row]);
59
+ newGrid[row][0] = _objectSpread(_objectSpread({}, newGrid[row][0]), {}, {
60
+ record: {
61
+ open: !!groupOpen[index]
62
+ }
63
+ });
64
+ onGridChange && onGridChange(newGrid);
65
+ sheetInstance === null || sheetInstance === void 0 || sheetInstance.pushToHistory({
66
+ type: 'Custom',
67
+ changes: [],
68
+ extraInfo: {
69
+ extraType: 'group',
70
+ groupConfig: rowGroupConfig,
71
+ data: data
72
+ }
73
+ });
74
+ }
75
+ }
76
+ }, "group-open"), /*#__PURE__*/_jsx(SheetEvent, {
77
+ name: "group-open-title",
78
+ handler: function handler(value) {
79
+ onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
80
+ groupOpen: Array(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen.length).fill(value),
81
+ defaultOpen: !groups.length ? value : undefined
82
+ }));
83
+ sheetInstance === null || sheetInstance === void 0 || sheetInstance.pushToHistory({
84
+ type: 'Custom',
85
+ changes: [],
86
+ extraInfo: {
87
+ extraType: 'group',
88
+ groupConfig: rowGroupConfig,
89
+ data: data
90
+ }
91
+ });
92
+ }
93
+ }, "group-open-title")]
94
+ });
95
+ };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { SheetTableType } from "../../type";
3
+ declare const Table: React.FC<SheetTableType.TableProps>;
4
+ export default Table;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAa,mBAA8B;AAalE,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CA4T9C,CAAC;AAEF,eAAe,KAAK,CAAC"}