@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,3 @@
1
+ /// <reference types="react" />
2
+ declare const App: React.FC;
3
+ export default App;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["group.tsx"],"names":[],"mappings":";AAqEA,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAuChB,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -0,0 +1,123 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { cloneDeep } from 'lodash';
8
+ import { useCallback, useState } from 'react';
9
+ import Table from "../core/table";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var columns = [{
12
+ title: 'Name',
13
+ dataIndex: 'name',
14
+ key: 'name'
15
+ }, {
16
+ title: 'Age',
17
+ dataIndex: 'age',
18
+ key: 'age'
19
+ }, {
20
+ title: 'Address',
21
+ readonly: function readonly(value, record, index) {
22
+ // console.log(index);
23
+ return index % 2 === 0;
24
+ },
25
+ dataIndex: 'address',
26
+ key: 'address'
27
+ }, {
28
+ title: 'Action',
29
+ dataIndex: '',
30
+ key: 'x',
31
+ editable: false,
32
+ render: function render() {
33
+ return /*#__PURE__*/_jsx("a", {
34
+ children: "Delete"
35
+ });
36
+ }
37
+ }];
38
+ var data = [{
39
+ key: 1,
40
+ id: 1,
41
+ name: 'John Brown',
42
+ age: 32,
43
+ address: 'New York No. 1 Lake Park',
44
+ children: [{
45
+ id: 11,
46
+ key: '1-1'
47
+ }, {
48
+ id: 12,
49
+ key: '1-2'
50
+ }]
51
+ }, {
52
+ key: 2,
53
+ id: 2,
54
+ name: 'Jim Green',
55
+ age: 42,
56
+ address: 'London No. 1 Lake Park',
57
+ children: [{
58
+ id: 21,
59
+ key: '2-1'
60
+ }, {
61
+ id: 22,
62
+ key: '2-2'
63
+ }]
64
+ }, {
65
+ key: 3,
66
+ id: 3,
67
+ name: 'Not Expandable',
68
+ age: 29,
69
+ address: 'Jiangsu No. 1 Lake Park'
70
+ }, {
71
+ key: 4,
72
+ id: 4,
73
+ name: 'Joe Black',
74
+ age: 32,
75
+ address: 'Sidney No. 1 Lake Park',
76
+ children: [{
77
+ id: 41,
78
+ key: '4-1'
79
+ }, {
80
+ id: 42,
81
+ key: '4-2'
82
+ }]
83
+ }];
84
+ var App = function App() {
85
+ var _useState = useState(data),
86
+ _useState2 = _slicedToArray(_useState, 2),
87
+ state = _useState2[0],
88
+ setState = _useState2[1];
89
+ var handleChange = useCallback(function (changes, extChange) {
90
+ // console.log(extChange);
91
+ var newState = cloneDeep(state);
92
+ changes.forEach(function (change) {
93
+ var row = change.row,
94
+ key = change.key,
95
+ value = change.value;
96
+ newState[row][key] = value;
97
+ });
98
+ setState(newState);
99
+ }, [state]);
100
+ return /*#__PURE__*/_jsx(Table, {
101
+ draggable: true,
102
+ scroll: {
103
+ x: '100%'
104
+ },
105
+ columns: columns,
106
+ showBackEdit: true,
107
+ backEditStyle: {
108
+ marginLeft: '10px',
109
+ bottom: '5px',
110
+ right: '5px'
111
+ }
112
+ // expandable={{
113
+ // expandedRowRender: (record) => (
114
+ // <p style={{ margin: 0 }}>{record.description}</p>
115
+ // ),
116
+ // rowExpandable: (record) => record.name !== 'Not Expandable',
117
+ // }}
118
+ ,
119
+ dataSource: data,
120
+ onChange: handleChange
121
+ });
122
+ };
123
+ export default App;
@@ -0,0 +1,5 @@
1
+ .excel-sheet{
2
+ --row-height:30px;
3
+ --line-height:30px;
4
+ --cell-inner-height: 29px;
5
+ }
@@ -0,0 +1,4 @@
1
+ import 'antd/dist/antd.css';
2
+ import React from 'react';
3
+ declare const App: React.FC;
4
+ export default App;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["selection.tsx"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAgC,MAAM,OAAO,CAAC;AA6CrD,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EA4BhB,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -0,0 +1,86 @@
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
13
+ 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); }
14
+ 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; }
15
+ 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; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import { Table } from "./..";
18
+ import 'antd/dist/antd.css';
19
+ import React, { useCallback, useState } from 'react';
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ var columns = [{
22
+ title: 'Name',
23
+ dataIndex: 'name',
24
+ render: function render(_ref) {
25
+ var value = _ref.value;
26
+ return /*#__PURE__*/_jsx("a", {
27
+ children: value
28
+ });
29
+ }
30
+ }, {
31
+ title: 'Age',
32
+ dataIndex: 'age'
33
+ }, {
34
+ title: 'Address',
35
+ dataIndex: 'address'
36
+ }];
37
+ var data = [{
38
+ key: '1',
39
+ name: 'John Brown',
40
+ age: 32,
41
+ address: 'New York No. 1 Lake Park'
42
+ }, {
43
+ key: '2',
44
+ name: 'Jim Green',
45
+ age: 42,
46
+ address: 'London No. 1 Lake Park'
47
+ }, {
48
+ key: '3',
49
+ name: 'Joe Black',
50
+ age: 32,
51
+ address: 'Sidney No. 1 Lake Park'
52
+ }, {
53
+ key: '4',
54
+ name: 'Disabled User',
55
+ age: 99,
56
+ address: 'Sidney No. 1 Lake Park'
57
+ }];
58
+ var App = function App() {
59
+ var _useState = useState(data),
60
+ _useState2 = _slicedToArray(_useState, 2),
61
+ dataSource = _useState2[0],
62
+ setData = _useState2[1];
63
+ var onChange = useCallback(function (changes) {
64
+ var newData = _toConsumableArray(dataSource);
65
+ changes.forEach(function (_ref2) {
66
+ var row = _ref2.row,
67
+ key = _ref2.key,
68
+ value = _ref2.value;
69
+ newData[row] = _objectSpread(_objectSpread({}, newData[row]), {}, _defineProperty({}, key, key === 'tags' ? value.split(',') : value));
70
+ });
71
+ setData(newData);
72
+ }, [dataSource]);
73
+ var handleRowChange = useCallback(function () {}, []);
74
+ return /*#__PURE__*/_jsx(Table, {
75
+ draggable: true,
76
+ columns: columns,
77
+ rowKey: "key",
78
+ dataSource: dataSource,
79
+ onChange: onChange,
80
+ rowSelection: {
81
+ rowSelected: [],
82
+ onChange: handleRowChange
83
+ }
84
+ });
85
+ };
86
+ export default App;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ declare const BasicSheet: React.FC;
4
+ export default BasicSheet;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["sheet.tsx"],"names":[],"mappings":"AAKA,OAAO,KAMN,MAAM,OAAO,CAAC;AAKf,OAAO,cAAc,CAAC;AAqDtB,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAwUvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,397 @@
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
13
+ 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); }
14
+ 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; }
15
+ 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; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import { MinusCircleOutlined, PlusCircleOutlined } from '@ant-design/icons';
18
+ import { Sheet } from "./..";
19
+ import { Tooltip } from 'antd';
20
+ import { cloneDeep, isNil, random, range } from 'lodash';
21
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
+ import { SheetEvent } from "../core/sheet/Event";
23
+ import { DraggableShell } from "../core/shell/draggableShell";
24
+ import { changeGroupConfig } from "../core/util";
25
+ import { useSheetEvent } from "../hooks";
26
+ import "./index.less";
27
+ import { jsx as _jsx } from "react/jsx-runtime";
28
+ import { jsxs as _jsxs } from "react/jsx-runtime";
29
+ var ExcelIndexCell = function ExcelIndexCell(_ref) {
30
+ var value = _ref.value,
31
+ row = _ref.row,
32
+ record = _ref.record;
33
+ var eventBus = useSheetEvent();
34
+ var handleClick = useCallback(function () {
35
+ eventBus.emit('onCellClick', {
36
+ row: row
37
+ });
38
+ }, []);
39
+ return /*#__PURE__*/_jsxs("span", {
40
+ className: "excel-index-cell",
41
+ onClick: handleClick,
42
+ style: {
43
+ cursor: 'pointer',
44
+ color: record === null || record === void 0 ? void 0 : record.color
45
+ },
46
+ children: [!isNil(record === null || record === void 0 ? void 0 : record.open) ? record !== null && record !== void 0 && record.open ? /*#__PURE__*/_jsx(MinusCircleOutlined, {
47
+ rev: undefined
48
+ }) : /*#__PURE__*/_jsx(Tooltip, {
49
+ overlay: record.groups,
50
+ trigger: ['hover'],
51
+ children: /*#__PURE__*/_jsx(PlusCircleOutlined, {
52
+ rev: undefined
53
+ })
54
+ }) : null, value]
55
+ });
56
+ };
57
+ var grid = range(1, 120).map(function (row, rowIndex) {
58
+ return range(0, 26).map(function (i) {
59
+ return {
60
+ id: String(random(0, 1, true)),
61
+ readonly: i === 0 ? true : false,
62
+ fixed: i === 0 ? 'left' : undefined,
63
+ value: i === 0 ? row : row > 15 || i > 10 ? '' : "".concat(row, "-").concat(i),
64
+ valueViewer: i === 0 ? ExcelIndexCell : undefined,
65
+ record: [1, 7].includes(rowIndex) ? {
66
+ open: true,
67
+ color: 'inherit',
68
+ groups: rowIndex === 1 ? [1, 2, 3, 4, 5] : [7, 8, 9]
69
+ } : undefined,
70
+ align: 'center'
71
+ };
72
+ });
73
+ });
74
+ var BasicSheet = function BasicSheet() {
75
+ var _useState = useState(grid),
76
+ _useState2 = _slicedToArray(_useState, 2),
77
+ state = _useState2[0],
78
+ setState = _useState2[1];
79
+ var sheetInstance = useRef(null);
80
+ var _useState3 = useState({
81
+ groups: [{
82
+ groupStart: 1,
83
+ groupEnd: 5,
84
+ groupName: 'group1'
85
+ }, {
86
+ groupStart: 7,
87
+ groupEnd: 9,
88
+ groupName: 'group2'
89
+ }],
90
+ groupOpen: [true, true]
91
+ }),
92
+ _useState4 = _slicedToArray(_useState3, 2),
93
+ groupConfig = _useState4[0],
94
+ setGroupConfig = _useState4[1];
95
+ var handleNewRow = useCallback(function (index) {
96
+ var _sheetInstance$curren, _sheetInstance$curren2;
97
+ var newGrid = cloneDeep(state);
98
+ var newRow = cloneDeep(newGrid[0]);
99
+ newRow.forEach(function (item) {
100
+ item.value = '';
101
+ item.record = undefined;
102
+ });
103
+ newGrid.splice(index, 0, newRow);
104
+ newGrid.forEach(function (row, index) {
105
+ row[0].value = index + 1;
106
+ });
107
+ (_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.pushToHistory({
108
+ type: 'NewRow',
109
+ changes: [],
110
+ rowInfo: {
111
+ newRow: index + 1
112
+ },
113
+ extraInfo: groupConfig
114
+ });
115
+ var newGroupConfig = changeGroupConfig(groupConfig, {
116
+ add: index
117
+ });
118
+ setState(newGrid);
119
+ setGroupConfig(newGroupConfig);
120
+ (_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 || _sheetInstance$curren2.selectRow(index);
121
+ }, [state, groupConfig]);
122
+ var handleDeleteRow = useCallback(function (index) {
123
+ var _sheetInstance$curren3;
124
+ var newGrid = cloneDeep(state);
125
+ var deleteRow = newGrid.splice(index - 1, 1);
126
+ newGrid.forEach(function (row, index) {
127
+ row[0].value = index + 1;
128
+ });
129
+ var newGroupConfig = changeGroupConfig(groupConfig, {
130
+ remove: index
131
+ });
132
+ (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 || _sheetInstance$curren3.pushToHistory({
133
+ type: 'DeleteRow',
134
+ changes: deleteRow[0].map(function (item, col) {
135
+ return {
136
+ cell: item,
137
+ row: index,
138
+ col: col
139
+ };
140
+ }),
141
+ rowInfo: {
142
+ deleteRow: index
143
+ },
144
+ extraInfo: groupConfig
145
+ });
146
+ setGroupConfig(newGroupConfig);
147
+ setState(newGrid);
148
+ }, [state]);
149
+ var handleReverse = useCallback(function (value) {
150
+ var _ref2 = value,
151
+ type = _ref2.type,
152
+ changes = _ref2.changes,
153
+ rowInfo = _ref2.rowInfo,
154
+ extraInfo = _ref2.extraInfo;
155
+ var newGrid = _toConsumableArray(state);
156
+ if (type === 'NewRow') {
157
+ var _sheetInstance$curren4;
158
+ if (!(rowInfo !== null && rowInfo !== void 0 && rowInfo.newRow) && (rowInfo === null || rowInfo === void 0 ? void 0 : rowInfo.newRow) !== 0) return;
159
+ newGrid.splice(rowInfo.newRow - 1, 1);
160
+ newGrid.forEach(function (row, index) {
161
+ row[0].value = index + 1;
162
+ });
163
+ setState(newGrid);
164
+ setGroupConfig(extraInfo);
165
+ (_sheetInstance$curren4 = sheetInstance.current) === null || _sheetInstance$curren4 === void 0 || _sheetInstance$curren4.selectRow();
166
+ } else if (type === 'DeleteRow') {
167
+ if (!(rowInfo !== null && rowInfo !== void 0 && rowInfo.deleteRow) && (rowInfo === null || rowInfo === void 0 ? void 0 : rowInfo.deleteRow) !== 0) return;
168
+ newGrid.splice(rowInfo.deleteRow - 1, 0, changes.map(function (item) {
169
+ return item.cell;
170
+ }));
171
+ newGrid.forEach(function (row, index) {
172
+ row[0].value = index + 1;
173
+ });
174
+ setState(newGrid);
175
+ setGroupConfig(extraInfo);
176
+ } else if (type === 'Custom') {
177
+ var _ref3 = extraInfo,
178
+ _groupConfig = _ref3.groupConfig,
179
+ extraType = _ref3.extraType,
180
+ lastState = _ref3.state;
181
+ if (extraType === 'group') {
182
+ setGroupConfig(_groupConfig);
183
+ setState(lastState);
184
+ }
185
+ }
186
+ }, [state, groupConfig]);
187
+ var onCellsChanged = useCallback(function (changes, extChanges) {
188
+ var newGrid = cloneDeep(state);
189
+ changes.forEach(function (_ref4) {
190
+ var row = _ref4.row,
191
+ col = _ref4.col,
192
+ value = _ref4.value;
193
+ var newRow = _toConsumableArray(newGrid[row]);
194
+ newRow[col] = _objectSpread(_objectSpread({}, newRow[col]), {}, {
195
+ value: value
196
+ });
197
+ newGrid[row] = newRow;
198
+ });
199
+ extChanges === null || extChanges === void 0 || extChanges.forEach(function (item) {
200
+ var _ref5 = item,
201
+ row = _ref5.row,
202
+ col = _ref5.col,
203
+ value = _ref5.value;
204
+ if (!newGrid[row]) {
205
+ var newRow = cloneDeep(newGrid[0]);
206
+ newRow.forEach(function (item) {
207
+ item.value = '';
208
+ item.record = undefined;
209
+ item.id = String(random(0, 1, true));
210
+ });
211
+ newGrid.push(newRow);
212
+ newGrid.forEach(function (row, index) {
213
+ row[0].value = index + 1;
214
+ });
215
+ // sheetInstance.current?.pushToHistory({
216
+ // type: 'NewRow' as SheetType.OperateType,
217
+ // changes: [],
218
+ // rowInfo: {
219
+ // newRow: index + 1,
220
+ // },
221
+ // extraInfo: groupConfig,
222
+ // });
223
+ // const newRow = Array(newGrid[0].length).map((item, index) => ({
224
+ // id: String(random(0, 1)),
225
+ // row,
226
+ // col: index,
227
+ // value: '',
228
+ // }));
229
+ // newGrid.push(newRow);
230
+ }
231
+
232
+ newGrid[row][col] = _objectSpread(_objectSpread({}, newGrid[row][col]), {}, {
233
+ value: value
234
+ });
235
+ });
236
+ setState(newGrid);
237
+ }, [state]);
238
+ var WrappedTableShell = useMemo(function () {
239
+ return DraggableShell({
240
+ columns: range(26).map(function (i) {
241
+ if (i > 26) return {
242
+ title: String.fromCharCode(64 + i / 26) + String.fromCharCode(64 + i % 26),
243
+ width: 100,
244
+ align: 'center'
245
+ };
246
+ return {
247
+ title: i === 0 ? '' : String.fromCharCode(64 + i),
248
+ fixed: i === 0 ? 'left' : undefined,
249
+ width: i === 0 ? 50 : 80,
250
+ align: 'center'
251
+ };
252
+ }),
253
+ className: 'baseTable'
254
+ });
255
+ }, []);
256
+ var MenuRender = useCallback(function (props) {
257
+ var position = props.position,
258
+ handleMenu = props.onContextMenu,
259
+ cell = props.cell;
260
+ var _ref6 = position || {},
261
+ top = _ref6.top,
262
+ left = _ref6.left;
263
+ if (!cell) return null;
264
+ return /*#__PURE__*/_jsxs("div", {
265
+ className: "harvest-menu",
266
+ style: {
267
+ top: top,
268
+ left: left,
269
+ background: 'white'
270
+ },
271
+ children: [/*#__PURE__*/_jsx("div", {
272
+ className: "harvest-menu-item",
273
+ onClick: function onClick() {
274
+ return handleMenu && handleMenu({
275
+ type: '1',
276
+ row: cell.row + 1
277
+ });
278
+ },
279
+ style: {
280
+ padding: '5px 10px'
281
+ },
282
+ children: "\u5411\u4E0B\u63D2\u5165\u884C"
283
+ }), /*#__PURE__*/_jsxs("div", {
284
+ className: "harvest-menu-item",
285
+ onClick: function onClick() {
286
+ return handleMenu && handleMenu({
287
+ type: '2',
288
+ row: cell.row + 1
289
+ });
290
+ },
291
+ children: ["\u5411\u4E0A\u63D2\u5165\u884C", ' ']
292
+ }), /*#__PURE__*/_jsx("div", {
293
+ className: "harvest-menu-item",
294
+ onClick: function onClick() {
295
+ return handleMenu && handleMenu({
296
+ type: '3',
297
+ row: cell.row + 1
298
+ });
299
+ },
300
+ children: "\u5220\u9664\u884C"
301
+ })]
302
+ });
303
+ }, [handleNewRow]);
304
+ var handleMenuClick = useCallback(function (e) {
305
+ var _ref7 = e,
306
+ type = _ref7.type,
307
+ row = _ref7.row;
308
+ // console.log('click', state.length);
309
+ if (type === '1') {
310
+ handleNewRow(row);
311
+ }
312
+ if (type === '2') {
313
+ handleNewRow(row - 1);
314
+ }
315
+ if (type === '3') {
316
+ handleDeleteRow(row);
317
+ }
318
+ }, [state, groupConfig]);
319
+ useEffect(function () {
320
+ // console.log('rendered', performance.now());
321
+ }, []);
322
+ return /*#__PURE__*/_jsxs(Sheet, {
323
+ sheetInstance: sheetInstance,
324
+ className: "excel-sheet",
325
+ virtualized: true,
326
+ freePaste: true,
327
+ showBackEdit: true,
328
+ data: state,
329
+ groupConfig: groupConfig,
330
+ scroll: {
331
+ x: '100%',
332
+ y: '100vh'
333
+ },
334
+ sheetRenderer: WrappedTableShell,
335
+ menuRenderer: MenuRender,
336
+ onCellsChanged: onCellsChanged,
337
+ onContextMenu: handleMenuClick,
338
+ children: [/*#__PURE__*/_jsx(SheetEvent, {
339
+ name: "onCellClick",
340
+ handler: function handler(e) {
341
+ var _ref8 = e,
342
+ row = _ref8.row;
343
+ var index = groupConfig.groups.findIndex(function (item) {
344
+ return item.groupStart === row;
345
+ });
346
+ if (index >= 0) {
347
+ var _sheetInstance$curren5;
348
+ // console.log('changed');
349
+ var groupOpen = _toConsumableArray(groupConfig.groupOpen);
350
+ groupOpen[index] = !groupConfig.groupOpen[index];
351
+ var newGrid = _toConsumableArray(state);
352
+ newGrid[row] = _toConsumableArray(newGrid[row]);
353
+ newGrid[row][0] = _objectSpread(_objectSpread({}, newGrid[row][0]), {}, {
354
+ record: {
355
+ open: !!groupOpen[index],
356
+ color: groupOpen[index] ? 'inherit' : 'green'
357
+ }
358
+ });
359
+ setGroupConfig(_objectSpread(_objectSpread({}, groupConfig), {}, {
360
+ groupOpen: groupOpen
361
+ }));
362
+ setState(newGrid);
363
+ (_sheetInstance$curren5 = sheetInstance.current) === null || _sheetInstance$curren5 === void 0 || _sheetInstance$curren5.pushToHistory({
364
+ type: 'Custom',
365
+ changes: [],
366
+ extraInfo: {
367
+ extraType: 'group',
368
+ groupConfig: groupConfig,
369
+ state: state
370
+ }
371
+ });
372
+ }
373
+ }
374
+ }), /*#__PURE__*/_jsx(SheetEvent, {
375
+ name: "reverse",
376
+ handler: handleReverse
377
+ }), /*#__PURE__*/_jsxs("div", {
378
+ style: {
379
+ display: 'flex'
380
+ },
381
+ children: [/*#__PURE__*/_jsx("div", {
382
+ onClick: function onClick() {
383
+ var _sheetInstance$curren6;
384
+ (_sheetInstance$curren6 = sheetInstance.current) === null || _sheetInstance$curren6 === void 0 || _sheetInstance$curren6.zoomTo(0);
385
+ },
386
+ children: "\u56DE\u5230\u9876\u90E8"
387
+ }), /*#__PURE__*/_jsx("div", {
388
+ onClick: function onClick() {
389
+ var _sheetInstance$curren7;
390
+ (_sheetInstance$curren7 = sheetInstance.current) === null || _sheetInstance$curren7 === void 0 || _sheetInstance$curren7.zoomTo();
391
+ },
392
+ children: "\u56DE\u5230\u7F16\u8F91\u884C"
393
+ })]
394
+ })]
395
+ });
396
+ };
397
+ export default BasicSheet;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const _default: () => JSX.Element;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valuationAnalyze.d.ts","sourceRoot":"","sources":["valuationAnalyze.tsx"],"names":[],"mappings":";;AAkDA,wBA0JE"}