@zhenliang/sheet 0.1.7-3.beta.0 → 0.1.7-3.beta.10

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 (87) hide show
  1. package/dist/core/editor/cascaderEditor/index.js +2 -2
  2. package/dist/core/editor/dateEditor/index.js +2 -2
  3. package/dist/core/editor/numberEditor/index.js +2 -2
  4. package/dist/core/editor/selectEditor/index.js +4 -4
  5. package/dist/core/reducers/keyboardReducer.js +2 -1
  6. package/dist/core/reducers/mouseReducer.js +3 -2
  7. package/dist/core/reducers/sideEffectReducer.js +3 -3
  8. package/dist/core/sheet/Cell.d.ts +1 -1
  9. package/dist/core/sheet/Cell.js +3 -3
  10. package/dist/core/sheet/Control.d.ts +1 -1
  11. package/dist/core/sheet/Control.js +2 -2
  12. package/dist/core/sheet/DataEditor.js +2 -2
  13. package/dist/core/sheet/DefaultCell.js +1 -1
  14. package/dist/core/sheet/DefaultRow.js +2 -2
  15. package/dist/core/sheet/DefaultRowMapper.js +4 -4
  16. package/dist/core/sheet/DefaultShell.js +1 -1
  17. package/dist/core/sheet/Event.d.ts +1 -1
  18. package/dist/core/sheet/Event.js +1 -1
  19. package/dist/core/sheet/Menu.d.ts +1 -1
  20. package/dist/core/sheet/Menu.js +3 -3
  21. package/dist/core/sheet/Remark.d.ts +9 -0
  22. package/dist/core/sheet/Remark.js +32 -0
  23. package/dist/core/sheet/ValueViewer.js +1 -1
  24. package/dist/core/sheet/index.js +52 -14
  25. package/dist/core/sheet/index.less +34 -0
  26. package/dist/core/sheet/searchInput.d.ts +1 -1
  27. package/dist/core/sheet/searchInput.js +3 -3
  28. package/dist/core/sheet/useCellEvent.js +1 -1
  29. package/dist/core/sheet/useContextMenu.js +4 -4
  30. package/dist/core/sheet/useMouseEvent.js +1 -1
  31. package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
  32. package/dist/core/sheet/useRemarkContainer.js +121 -0
  33. package/dist/core/sheet/useSearchInput.js +1 -1
  34. package/dist/core/sheet/useSelectVisible.js +1 -1
  35. package/dist/core/sheet/useVirtualList.js +2 -2
  36. package/dist/core/shell/draggableShell/index.d.ts +1 -1
  37. package/dist/core/shell/draggableShell/index.js +10 -5
  38. package/dist/core/shell/tableShell.d.ts +2 -2
  39. package/dist/core/shell/tableShell.js +11 -155
  40. package/dist/core/table/addButton.d.ts +1 -2
  41. package/dist/core/table/addButton.js +3 -4
  42. package/dist/core/table/events.d.ts +1 -1
  43. package/dist/core/table/events.js +3 -3
  44. package/dist/core/table/index.d.ts +1 -0
  45. package/dist/core/table/index.js +164 -12
  46. package/dist/core/table/index.less +19 -0
  47. package/dist/core/table/remarkEvent.d.ts +5 -0
  48. package/dist/core/table/remarkEvent.js +9 -0
  49. package/dist/core/table/useGroupConfig.d.ts +1 -1
  50. package/dist/core/table/useGroupConfig.js +7 -5
  51. package/dist/core/table/useRowSelection.d.ts +1 -1
  52. package/dist/core/table/useRowSelection.js +7 -4
  53. package/dist/core/viewer/btnViewer/index.js +3 -3
  54. package/dist/core/viewer/cascaderViewer/index.js +2 -2
  55. package/dist/core/viewer/checkViewer/index.js +2 -2
  56. package/dist/core/viewer/editViewer/index.js +3 -3
  57. package/dist/core/viewer/groupViewer/index.js +2 -2
  58. package/dist/core/viewer/selectorViewer/index.js +1 -1
  59. package/dist/core/viewer/switchViewer/index.js +2 -2
  60. package/dist/example/antComponent.d.ts +1 -1
  61. package/dist/example/antComponent.js +2 -2
  62. package/dist/example/basic.d.ts +1 -1
  63. package/dist/example/basic.js +4 -4
  64. package/dist/example/ellipsis.d.ts +1 -1
  65. package/dist/example/ellipsis.js +2 -2
  66. package/dist/example/fixed.d.ts +1 -1
  67. package/dist/example/fixed.js +2 -2
  68. package/dist/example/group.js +2 -2
  69. package/dist/example/selection.d.ts +1 -1
  70. package/dist/example/selection.js +2 -2
  71. package/dist/example/sheet.d.ts +1 -1
  72. package/dist/example/sheet.js +3 -3
  73. package/dist/example/valuationAnalyze.js +356 -13
  74. package/dist/hooks/useEventBus.js +1 -1
  75. package/dist/hooks/useGroupConfig.d.ts +1 -1
  76. package/dist/hooks/useGroupConfig.js +2 -2
  77. package/dist/hooks/useKeyboard.js +1 -1
  78. package/dist/hooks/useMiddlewareReducer.js +1 -1
  79. package/dist/hooks/useMouse.js +1 -1
  80. package/dist/hooks/useSetState.js +1 -1
  81. package/dist/hooks/useSheetEvent.d.ts +1 -1
  82. package/dist/hooks/useSheetEvent.js +2 -2
  83. package/dist/hooks/useWidthConfig.d.ts +1 -1
  84. package/dist/hooks/useWidthConfig.js +2 -2
  85. package/dist/type/sheet.d.ts +8 -1
  86. package/dist/type/sheetTable.d.ts +15 -2
  87. package/package.json +4 -1
@@ -18,14 +18,14 @@ import { MinusCircleOutlined, PlusCircleOutlined } from '@ant-design/icons';
18
18
  import { Sheet } from "./..";
19
19
  import { Tooltip } from 'antd';
20
20
  import { cloneDeep, isNil, random, range } from 'lodash';
21
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "../../node_modules/@types/react";
21
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
22
  import { SheetEvent } from "../core/sheet/Event";
23
23
  import { DraggableShell } from "../core/shell/draggableShell";
24
24
  import { changeGroupConfig } from "../core/util";
25
25
  import { useSheetEvent } from "../hooks";
26
26
  import "./index.less";
27
- import { jsx as _jsx } from "../../node_modules/@types/react/jsx-runtime";
28
- import { jsxs as _jsxs } from "../../node_modules/@types/react/jsx-runtime";
27
+ import { jsx as _jsx } from "react/jsx-runtime";
28
+ import { jsxs as _jsxs } from "react/jsx-runtime";
29
29
  var ExcelIndexCell = function ExcelIndexCell(_ref) {
30
30
  var value = _ref.value,
31
31
  row = _ref.row,
@@ -1,16 +1,28 @@
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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); }
1
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
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."); }
3
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); }
4
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; }
5
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; } }
6
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ /* eslint-disable react-hooks/rules-of-hooks */
7
18
  import { getNumberEditor, getSelectEditor, Table } from "./..";
8
- import { Button } from 'antd';
9
- import { isNil } from 'lodash';
10
- import { useCallback, useState } from "../../node_modules/@types/react";
19
+ import { Button, Input, Select } from 'antd';
20
+ import { isNil, uniq } from 'lodash';
21
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
22
  import { SwitchViewer } from "../core/viewer";
12
23
  import { SheetType } from "../type";
13
- import { jsx as _jsx } from "../../node_modules/@types/react/jsx-runtime";
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
26
  var RateValueInput = getNumberEditor({
15
27
  addonAfter: '%',
16
28
  min: 0,
@@ -26,6 +38,64 @@ var RateViewer = function RateViewer(props) {
26
38
  children: value ? value + '%' : '-'
27
39
  });
28
40
  };
41
+ var RemarkRender = function RemarkRender(handleRemark, remarks) {
42
+ var render = function render(value) {
43
+ var _remarks$find;
44
+ var _useState = useState((remarks === null || remarks === void 0 || (_remarks$find = remarks.find(function (r) {
45
+ return r.id === value.id;
46
+ })) === null || _remarks$find === void 0 ? void 0 : _remarks$find.remarks) || []),
47
+ _useState2 = _slicedToArray(_useState, 2),
48
+ rm = _useState2[0],
49
+ setRm = _useState2[1];
50
+ var inputRef = useRef();
51
+ return /*#__PURE__*/_jsxs("div", {
52
+ style: {
53
+ background: 'white'
54
+ },
55
+ children: [/*#__PURE__*/_jsx("div", {
56
+ style: {
57
+ height: 350
58
+ }
59
+ }), /*#__PURE__*/_jsxs("p", {
60
+ children: [" columns:", value.columnKey]
61
+ }), /*#__PURE__*/_jsxs("p", {
62
+ children: [" id:", value.id]
63
+ }), /*#__PURE__*/_jsx("p", {
64
+ children: " bugs --"
65
+ }), /*#__PURE__*/_jsx(Select, {
66
+ onMouseDown: function onMouseDown(e) {
67
+ return e.stopPropagation();
68
+ },
69
+ options: [{
70
+ label: '2',
71
+ value: 3
72
+ }, {
73
+ label: '1',
74
+ value: 2
75
+ }]
76
+ }), rm === null || rm === void 0 ? void 0 : rm.map(function (r) {
77
+ return /*#__PURE__*/_jsx("p", {
78
+ children: r
79
+ }, r);
80
+ }), /*#__PURE__*/_jsx(Input, {
81
+ ref: inputRef,
82
+ autoFocus: true,
83
+ onPressEnter: function onPressEnter(e) {
84
+ setRm(function (s) {
85
+ return uniq([].concat(_toConsumableArray(s), [e.target.value]));
86
+ });
87
+ handleRemark([{
88
+ id: value.id,
89
+ remarks: [value.columnKey]
90
+ }]);
91
+ e.target.value = '';
92
+ inputRef.current.input.value = '';
93
+ }
94
+ })]
95
+ });
96
+ };
97
+ return render;
98
+ };
29
99
  var data = [{
30
100
  id: 2443,
31
101
  draftId: '101601',
@@ -38,7 +108,8 @@ var data = [{
38
108
  gfaUnitPrice: 107350.31545913525,
39
109
  nlaUnitPrice: 90130.38038659678,
40
110
  totalValuation: 1622707368.4802885,
41
- isEnabled: true
111
+ isEnabled: true,
112
+ remarks: ['valuationType', 'vacancyDiscountRate']
42
113
  }, {
43
114
  id: 2444,
44
115
  draftId: '101601',
@@ -51,8 +122,165 @@ var data = [{
51
122
  gfaUnitPrice: 89327.04427210477,
52
123
  nlaUnitPrice: 89327.04427210477,
53
124
  totalValuation: 1429232708.3536763,
125
+ remarks: ['termDiscountRate', 'vacancyDiscountRate'],
54
126
  isEnabled: false
55
- }];
127
+ }, {
128
+ id: 2445,
129
+ draftId: '101601',
130
+ valuationType: 5,
131
+ termDiscountRate: 4.5,
132
+ reversionDiscountRate: 5.5,
133
+ vacancyDiscountRate: 5.5,
134
+ discountRate: null,
135
+ exitCapRate: null,
136
+ gfaUnitPrice: 89327.04427210477,
137
+ nlaUnitPrice: 89327.04427210477,
138
+ totalValuation: 1429232708.3536763,
139
+ remarks: ['reversionDiscountRate', 'vacancyDiscountRate'],
140
+ isEnabled: false
141
+ }, {
142
+ id: 2446,
143
+ draftId: '101601',
144
+ valuationType: 5,
145
+ termDiscountRate: 4.5,
146
+ reversionDiscountRate: 5.5,
147
+ vacancyDiscountRate: 5.5,
148
+ discountRate: null,
149
+ exitCapRate: null,
150
+ gfaUnitPrice: 89327.04427210477,
151
+ nlaUnitPrice: 89327.04427210477,
152
+ totalValuation: 1429232708.3536763,
153
+ remarks: ['vacancyDiscountRate'],
154
+ isEnabled: false
155
+ }, {
156
+ id: 2447,
157
+ draftId: '101601',
158
+ valuationType: 5,
159
+ termDiscountRate: 4.5,
160
+ reversionDiscountRate: 5.5,
161
+ vacancyDiscountRate: 5.5,
162
+ discountRate: null,
163
+ exitCapRate: null,
164
+ gfaUnitPrice: 89327.04427210477,
165
+ nlaUnitPrice: 89327.04427210477,
166
+ totalValuation: 1429232708.3536763,
167
+ remarks: ['discountRate', 'vacancyDiscountRate'],
168
+ isEnabled: false
169
+ }, {
170
+ id: 2448,
171
+ draftId: '101601',
172
+ valuationType: 5,
173
+ termDiscountRate: 4.5,
174
+ reversionDiscountRate: 5.5,
175
+ vacancyDiscountRate: 5.5,
176
+ discountRate: null,
177
+ exitCapRate: null,
178
+ gfaUnitPrice: 89327.04427210477,
179
+ nlaUnitPrice: 89327.04427210477,
180
+ totalValuation: 1429232708.3536763,
181
+ remarks: ['exitCapRate', 'vacancyDiscountRate'],
182
+ isEnabled: false
183
+ }, {
184
+ id: 2449,
185
+ draftId: '101601',
186
+ valuationType: 5,
187
+ termDiscountRate: 4.5,
188
+ reversionDiscountRate: 5.5,
189
+ vacancyDiscountRate: 5.5,
190
+ discountRate: null,
191
+ exitCapRate: null,
192
+ gfaUnitPrice: 89327.04427210477,
193
+ nlaUnitPrice: 89327.04427210477,
194
+ totalValuation: 1429232708.3536763,
195
+ remarks: ['gfaUnitPrice', 'vacancyDiscountRate'],
196
+ isEnabled: false
197
+ }, {
198
+ id: 2450,
199
+ draftId: '101601',
200
+ valuationType: 5,
201
+ termDiscountRate: 4.5,
202
+ reversionDiscountRate: 5.5,
203
+ vacancyDiscountRate: 5.5,
204
+ discountRate: null,
205
+ exitCapRate: null,
206
+ gfaUnitPrice: 89327.04427210477,
207
+ nlaUnitPrice: 89327.04427210477,
208
+ totalValuation: 1429232708.3536763,
209
+ remarks: ['nlaUnitPrice', 'vacancyDiscountRate'],
210
+ isEnabled: false
211
+ }, {
212
+ id: 2451,
213
+ draftId: '101601',
214
+ valuationType: 5,
215
+ termDiscountRate: 4.5,
216
+ reversionDiscountRate: 5.5,
217
+ vacancyDiscountRate: 5.5,
218
+ discountRate: null,
219
+ exitCapRate: null,
220
+ gfaUnitPrice: 89327.04427210477,
221
+ nlaUnitPrice: 89327.04427210477,
222
+ totalValuation: 1429232708.3536763,
223
+ remarks: ['totalValuation', 'vacancyDiscountRate'],
224
+ isEnabled: false
225
+ }, {
226
+ id: 2452,
227
+ draftId: '101601',
228
+ valuationType: 5,
229
+ termDiscountRate: 4.5,
230
+ reversionDiscountRate: 5.5,
231
+ vacancyDiscountRate: 5.5,
232
+ discountRate: null,
233
+ exitCapRate: null,
234
+ gfaUnitPrice: 89327.04427210477,
235
+ nlaUnitPrice: 89327.04427210477,
236
+ totalValuation: 1429232708.3536763,
237
+ remarks: ['termDiscountRate', 'vacancyDiscountRate'],
238
+ isEnabled: false
239
+ }, {
240
+ id: 2453,
241
+ draftId: '101601',
242
+ valuationType: 5,
243
+ termDiscountRate: 4.5,
244
+ reversionDiscountRate: 5.5,
245
+ vacancyDiscountRate: 5.5,
246
+ discountRate: null,
247
+ exitCapRate: null,
248
+ gfaUnitPrice: 89327.04427210477,
249
+ nlaUnitPrice: 89327.04427210477,
250
+ totalValuation: 1429232708.3536763,
251
+ remarks: ['termDiscountRate', 'vacancyDiscountRate'],
252
+ isEnabled: false
253
+ }, {
254
+ id: 2454,
255
+ draftId: '101601',
256
+ valuationType: 5,
257
+ termDiscountRate: 4.5,
258
+ reversionDiscountRate: 5.5,
259
+ vacancyDiscountRate: 5.5,
260
+ discountRate: null,
261
+ exitCapRate: null,
262
+ gfaUnitPrice: 89327.04427210477,
263
+ nlaUnitPrice: 89327.04427210477,
264
+ totalValuation: 1429232708.3536763,
265
+ remarks: ['termDiscountRate', 'vacancyDiscountRate'],
266
+ isEnabled: false
267
+ }].concat(_toConsumableArray(Array(100).fill(0).map(function (item, i) {
268
+ return {
269
+ id: 2455 + i,
270
+ draftId: '101601',
271
+ valuationType: 5,
272
+ termDiscountRate: 4.5,
273
+ reversionDiscountRate: 5.5,
274
+ vacancyDiscountRate: 5.5,
275
+ discountRate: null,
276
+ exitCapRate: null,
277
+ gfaUnitPrice: 89327.04427210477,
278
+ nlaUnitPrice: 89327.04427210477,
279
+ totalValuation: 1429232708.3536763,
280
+ remarks: ['termDiscountRate', 'vacancyDiscountRate'],
281
+ isEnabled: false
282
+ };
283
+ })));
56
284
  var evaluateMethods = [{
57
285
  label: 'DCF',
58
286
  value: 2
@@ -62,9 +290,9 @@ var evaluateMethods = [{
62
290
  }];
63
291
  var EvaSelect = getSelectEditor(evaluateMethods);
64
292
  export default (function () {
65
- var _useState = useState(data),
66
- _useState2 = _slicedToArray(_useState, 1),
67
- state = _useState2[0];
293
+ var _useState3 = useState(data),
294
+ _useState4 = _slicedToArray(_useState3, 1),
295
+ state = _useState4[0];
68
296
  var columns = [{
69
297
  title: '默认使用',
70
298
  dataIndex: 'isEnabled',
@@ -168,6 +396,36 @@ export default (function () {
168
396
  width: 134,
169
397
  editor: ValueInput,
170
398
  readonly: true
399
+ }, {
400
+ title: 'id-1',
401
+ dataIndex: 'id-1',
402
+ width: 134,
403
+ editor: ValueInput,
404
+ readonly: true
405
+ }, {
406
+ title: 'id-2',
407
+ dataIndex: 'id-2',
408
+ width: 134,
409
+ editor: ValueInput,
410
+ readonly: true
411
+ }, {
412
+ title: 'id-3',
413
+ dataIndex: 'id-3',
414
+ width: 134,
415
+ editor: ValueInput,
416
+ readonly: true
417
+ }, {
418
+ title: 'id-4',
419
+ dataIndex: 'id-4',
420
+ width: 134,
421
+ editor: ValueInput,
422
+ readonly: true
423
+ }, {
424
+ title: 'id-5',
425
+ dataIndex: 'id-5',
426
+ width: 134,
427
+ editor: ValueInput,
428
+ readonly: true
171
429
  }, {
172
430
  title: '操作',
173
431
  width: 62,
@@ -217,10 +475,95 @@ export default (function () {
217
475
  // return <div className="value-viewer number-value-viewer" />;
218
476
  // },
219
477
  }];
478
+ var sheetInstance = useRef(null);
220
479
  var handleChange = useCallback(function () {}, [state]);
221
- return /*#__PURE__*/_jsx(Table, {
222
- columns: columns,
223
- dataSource: state,
224
- onChange: handleChange
480
+ useEffect(function () {
481
+ setTimeout(function () {
482
+ var _sheetInstance$curren, _sheetInstance$curren2;
483
+ (_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.zoomTo(1);
484
+ (_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 || _sheetInstance$curren2.select({
485
+ start: {
486
+ row: 1,
487
+ col: 3
488
+ },
489
+ end: {
490
+ row: 1,
491
+ col: 3
492
+ }
493
+ });
494
+ }, 3);
495
+ }, []);
496
+ var _useState5 = useState([]),
497
+ _useState6 = _slicedToArray(_useState5, 2),
498
+ currentRemark = _useState6[0],
499
+ setCurrentRemark = _useState6[1];
500
+ var RenderRemarkSimple = useMemo(function () {
501
+ return RemarkRender(setCurrentRemark, currentRemark);
502
+ }, [currentRemark]);
503
+ var wrapData = useMemo(function () {
504
+ return state.map(function (d) {
505
+ var _currentRemark$find;
506
+ var remarks = currentRemark === null || currentRemark === void 0 || (_currentRemark$find = currentRemark.find(function (r) {
507
+ return r.id === d.id;
508
+ })) === null || _currentRemark$find === void 0 ? void 0 : _currentRemark$find.remarks;
509
+ if (remarks) {
510
+ return _objectSpread(_objectSpread({}, d), {}, {
511
+ remarks: remarks
512
+ });
513
+ }
514
+ return d;
515
+ });
516
+ }, [state, currentRemark]);
517
+ return /*#__PURE__*/_jsxs("div", {
518
+ style: {
519
+ height: '100vh',
520
+ padding: '29vh 0',
521
+ overflow: 'auto',
522
+ background: 'rgba(255,255,0,.2)'
523
+ },
524
+ children: [/*#__PURE__*/_jsx(Table, {
525
+ virtualized: true,
526
+ freeze: true,
527
+ draggable: true,
528
+ sheetInstance: sheetInstance,
529
+ columns: columns,
530
+ showRemark: true,
531
+ remarkRender: RenderRemarkSimple
532
+ // handleAddRemark={handleAddRemark}
533
+ ,
534
+ dataSource: wrapData,
535
+ onChange: handleChange,
536
+ onContextMenu: function onContextMenu() {},
537
+ menuRenderer: function menuRenderer(props) {
538
+ var handleMenu = props.onContextMenu,
539
+ cell = props.cell,
540
+ position = props.position,
541
+ children = props.children;
542
+ if (!cell || !handleMenu || cell.col < 1 || !position) {
543
+ return null;
544
+ }
545
+ return /*#__PURE__*/_jsxs("div", {
546
+ className: "harvest-menu",
547
+ style: _objectSpread(_objectSpread({}, position), {}, {
548
+ background: 'white'
549
+ }),
550
+ children: [children, /*#__PURE__*/_jsx("div", {
551
+ className: "harvest-menu-item",
552
+ children: "\u5411\u4E0B\u586B\u5145"
553
+ }), /*#__PURE__*/_jsx("div", {
554
+ className: "harvest-menu-item",
555
+ children: "\u5411\u53F3\u586B\u5145"
556
+ }), /*#__PURE__*/_jsx("div", {
557
+ className: "harvest-menu-item",
558
+ children: "\u5168\u90E8\u586B\u5145"
559
+ })]
560
+ });
561
+ }
562
+ }), /*#__PURE__*/_jsx("div", {
563
+ style: {
564
+ height: '100vh'
565
+ },
566
+ children: " empty"
567
+ })]
225
568
  });
226
569
  });
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from 'events';
2
- import { useEffect, useRef } from "../../node_modules/@types/react";
2
+ import { useEffect, useRef } from 'react';
3
3
  var useEventBus = function useEventBus() {
4
4
  var eventBus = useRef(new EventEmitter());
5
5
  useEffect(function () {
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { GroupConfigContext } from '../type/sheet';
3
- export declare const GroupContext: import("../../node_modules/@types/react").Context<GroupConfigContext>;
3
+ export declare const GroupContext: import("react").Context<GroupConfigContext>;
4
4
  export declare function useGroup(): GroupConfigContext;
@@ -1,5 +1,5 @@
1
- import { createContext, useContext } from "../../node_modules/@types/react";
2
- export var GroupContext = createContext({});
1
+ import { createContext, useContext } from 'react';
2
+ export var GroupContext = /*#__PURE__*/createContext({});
3
3
  export function useGroup() {
4
4
  return useContext(GroupContext);
5
5
  }
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect } from "../../node_modules/@types/react";
1
+ import { useCallback, useEffect } from 'react';
2
2
  import { A_KEY, BACKSPACE_KEY, C_KEY, DELETE_KEY, DOWN_KEY, ENTER_KEY, ESCAPE_KEY, F_KEY, LEFT_KEY, RIGHT_KEY, TAB_KEY, UP_KEY, V_KEY, X_KEY, Y_KEY, Z_KEY } from "../core/config";
3
3
  import { isInputKey } from "../core/util";
4
4
  var ua = window.navigator.userAgent;
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
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
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
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import * as React from "../../node_modules/@types/react";
7
+ import * as React from 'react';
8
8
  export var useMiddlewareReducer = function useMiddlewareReducer(reducer, initialState) {
9
9
  var middleware = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
10
10
  var _React$useState = React.useState(initialState),
@@ -1,5 +1,5 @@
1
1
  import { debounce } from 'lodash';
2
- import { useCallback, useEffect, useRef } from "../../node_modules/@types/react";
2
+ import { useCallback, useEffect, useRef } from 'react';
3
3
  export var useMouse = function useMouse(handler, listenElement) {
4
4
  var mouseUp = handler.mouseUp,
5
5
  mouseDown = handler.mouseDown,
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  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; }
11
11
  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; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import { useCallback, useState } from "../../node_modules/@types/react";
13
+ import { useCallback, useState } from 'react';
14
14
  var useSetState = function useSetState() {
15
15
  var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
16
  var _useState = useState(initialState),
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="react" />
3
3
  import Events from 'events';
4
- export declare const SheetEventContext: import("../../node_modules/@types/react").Context<Events | undefined>;
4
+ export declare const SheetEventContext: import("react").Context<Events | undefined>;
5
5
  export declare function useSheetEvent(): Events;
@@ -1,5 +1,5 @@
1
- import { createContext, useContext } from "../../node_modules/@types/react";
2
- export var SheetEventContext = createContext(undefined);
1
+ import { createContext, useContext } from 'react';
2
+ export var SheetEventContext = /*#__PURE__*/createContext(undefined);
3
3
  export function useSheetEvent() {
4
4
  return useContext(SheetEventContext);
5
5
  }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { WidthConfigContext } from '../type/sheet';
3
- export declare const WidthContext: import("../../node_modules/@types/react").Context<WidthConfigContext>;
3
+ export declare const WidthContext: import("react").Context<WidthConfigContext>;
4
4
  export declare function useWidth(): WidthConfigContext;
@@ -1,5 +1,5 @@
1
- import { createContext, useContext } from "../../node_modules/@types/react";
2
- export var WidthContext = createContext({});
1
+ import { createContext, useContext } from 'react';
2
+ export var WidthContext = /*#__PURE__*/createContext({});
3
3
  export function useWidth() {
4
4
  return useContext(WidthContext);
5
5
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { EventEmitter } from 'events';
3
- import { CSSProperties } from "../../node_modules/@types/react";
3
+ import { CSSProperties, ReactNode } from 'react';
4
4
  import { SheetTableType, SheetType } from '.';
5
5
  export declare enum CellAlign {
6
6
  left = "left",
@@ -92,6 +92,8 @@ export type MenuRenderProps = {
92
92
  };
93
93
  cell?: CellPosition;
94
94
  onContextMenu?: (event: any) => void;
95
+ children?: ReactNode | ReactNode[];
96
+ target?: any;
95
97
  };
96
98
  export type SheetInstance = {
97
99
  zoomTo: (row?: number) => void;
@@ -118,7 +120,9 @@ export type SheetProps = {
118
120
  backEditStyle?: Partial<CSSProperties>;
119
121
  searchStyle?: Partial<CSSProperties>;
120
122
  sticky?: boolean;
123
+ freeze?: boolean;
121
124
  groupConfig?: RowGroupConfig;
125
+ remarkElement?: ReactNode;
122
126
  onCellsChanged?: CellChangeHandler;
123
127
  menuRenderer?: React.FC<MenuRenderProps>;
124
128
  onContextMenu?: (event: any) => void;
@@ -132,6 +136,7 @@ export type SheetProps = {
132
136
  boldScroll?: boolean;
133
137
  hideColBar?: boolean;
134
138
  showQuickLocationBtn?: boolean;
139
+ showRemark?: boolean;
135
140
  ControlContainer?: React.FC;
136
141
  };
137
142
  export type WidthConfigContext = {
@@ -146,6 +151,7 @@ export type GroupConfigContext = {
146
151
  };
147
152
  export type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
148
153
  className?: string;
154
+ dragable?: boolean;
149
155
  showGroup?: boolean;
150
156
  showSelect?: boolean;
151
157
  controlWidth?: number;
@@ -210,6 +216,7 @@ export type UpdateStateType = {
210
216
  data: Cell[][];
211
217
  mouseDown: boolean;
212
218
  isIndex: boolean;
219
+ freeze: boolean;
213
220
  lastSelected?: {
214
221
  start?: CellPosition;
215
222
  end?: CellPosition;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from "../../node_modules/@types/react";
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
  import { SheetType } from '.';
3
3
  export type refAssertion = {
4
4
  contains?: (target: EventTarget | null) => boolean;
@@ -56,6 +56,15 @@ export type TableGroupConfig = {
56
56
  onChange?: (value: SheetType.RowGroupConfig) => void;
57
57
  };
58
58
  export type EventHandler = (value: any) => void;
59
+ export type RemarkProps = {
60
+ cell: SheetType.CellPosition;
61
+ columnKey: string;
62
+ id?: string | number;
63
+ close: () => void;
64
+ };
65
+ export type TableInstance = {
66
+ goToByTable?: (id: number, columnKey: string) => void;
67
+ } & SheetType.SheetInstance;
59
68
  export type TableProps = {
60
69
  /**
61
70
  * @description 表格类名
@@ -66,7 +75,7 @@ export type TableProps = {
66
75
  * @description sheet的一些定义方法可执行
67
76
  * @default "object"
68
77
  */
69
- sheetInstance?: React.MutableRefObject<SheetType.SheetInstance | null>;
78
+ sheetInstance?: React.MutableRefObject<SheetType.SheetInstance & TableInstance | null>;
70
79
  columns: ColumnProps[];
71
80
  virtualized?: boolean;
72
81
  dataSource: Record<string, unknown>[];
@@ -80,7 +89,11 @@ export type TableProps = {
80
89
  sticky?: boolean;
81
90
  draggable?: boolean;
82
91
  freePaste?: boolean;
92
+ freeze?: boolean;
83
93
  showBackEdit?: boolean;
94
+ showRemark?: boolean;
95
+ remarkRender?: React.FC<RemarkProps>;
96
+ handleAddRemark?: (value: RemarkProps) => void;
84
97
  backEditStyle?: Partial<CSSProperties>;
85
98
  searchStyle?: Partial<CSSProperties>;
86
99
  rowSelection?: TableRowSelection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.73.beta.0",
3
+ "version": "0.1.73.beta.10",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -43,6 +43,9 @@
43
43
  "prettier --parser=typescript --write"
44
44
  ]
45
45
  },
46
+ "resolutions": {
47
+ "@types/react": "17.0.40"
48
+ },
46
49
  "dependencies": {
47
50
  "@ant-design/icons": "^4.6.2",
48
51
  "antd": "^4.24.0",