@zhenliang/sheet 0.1.20 → 0.1.22

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 (137) hide show
  1. package/changes.md +45 -0
  2. package/package.json +1 -1
  3. package/dist/core/config.d.ts +0 -13
  4. package/dist/core/config.js +0 -13
  5. package/dist/core/editor/cascaderEditor/index.d.ts +0 -5
  6. package/dist/core/editor/cascaderEditor/index.js +0 -54
  7. package/dist/core/editor/cascaderEditor/index.less +0 -28
  8. package/dist/core/editor/dateEditor/index.d.ts +0 -5
  9. package/dist/core/editor/dateEditor/index.js +0 -55
  10. package/dist/core/editor/dateEditor/index.less +0 -11
  11. package/dist/core/editor/index.d.ts +0 -4
  12. package/dist/core/editor/index.js +0 -4
  13. package/dist/core/editor/numberEditor/index.d.ts +0 -8
  14. package/dist/core/editor/numberEditor/index.js +0 -107
  15. package/dist/core/editor/numberEditor/index.less +0 -30
  16. package/dist/core/editor/selectEditor/index.d.ts +0 -6
  17. package/dist/core/editor/selectEditor/index.js +0 -96
  18. package/dist/core/editor/selectEditor/index.less +0 -43
  19. package/dist/core/reducers/index.d.ts +0 -9
  20. package/dist/core/reducers/index.js +0 -38
  21. package/dist/core/reducers/keyboardReducer.d.ts +0 -2
  22. package/dist/core/reducers/keyboardReducer.js +0 -93
  23. package/dist/core/reducers/mouseReducer.d.ts +0 -2
  24. package/dist/core/reducers/mouseReducer.js +0 -164
  25. package/dist/core/reducers/sideEffectReducer.d.ts +0 -4
  26. package/dist/core/reducers/sideEffectReducer.js +0 -378
  27. package/dist/core/reducers/stateReducer.d.ts +0 -2
  28. package/dist/core/reducers/stateReducer.js +0 -174
  29. package/dist/core/sheet/Cell.d.ts +0 -4
  30. package/dist/core/sheet/Cell.js +0 -181
  31. package/dist/core/sheet/DataEditor.d.ts +0 -3
  32. package/dist/core/sheet/DataEditor.js +0 -24
  33. package/dist/core/sheet/DefaultCell.d.ts +0 -11
  34. package/dist/core/sheet/DefaultCell.js +0 -31
  35. package/dist/core/sheet/DefaultRow.d.ts +0 -12
  36. package/dist/core/sheet/DefaultRow.js +0 -28
  37. package/dist/core/sheet/DefaultRowMapper.d.ts +0 -8
  38. package/dist/core/sheet/DefaultRowMapper.js +0 -15
  39. package/dist/core/sheet/DefaultShell.d.ts +0 -8
  40. package/dist/core/sheet/DefaultShell.js +0 -12
  41. package/dist/core/sheet/Event.d.ts +0 -5
  42. package/dist/core/sheet/Event.js +0 -17
  43. package/dist/core/sheet/ValueViewer.d.ts +0 -3
  44. package/dist/core/sheet/ValueViewer.js +0 -9
  45. package/dist/core/sheet/index.d.ts +0 -5
  46. package/dist/core/sheet/index.js +0 -265
  47. package/dist/core/sheet/index.less +0 -307
  48. package/dist/core/sheet/useCellEvent.d.ts +0 -3
  49. package/dist/core/sheet/useCellEvent.js +0 -22
  50. package/dist/core/sheet/useContextMenu.d.ts +0 -21
  51. package/dist/core/sheet/useContextMenu.js +0 -86
  52. package/dist/core/sheet/useKeyBoardEvent.d.ts +0 -3
  53. package/dist/core/sheet/useKeyBoardEvent.js +0 -66
  54. package/dist/core/sheet/useMouseEvent.d.ts +0 -3
  55. package/dist/core/sheet/useMouseEvent.js +0 -298
  56. package/dist/core/sheet/useSelectVisible.d.ts +0 -2
  57. package/dist/core/sheet/useSelectVisible.js +0 -57
  58. package/dist/core/sheet/useVirtualList.d.ts +0 -7
  59. package/dist/core/sheet/useVirtualList.js +0 -103
  60. package/dist/core/sheet/var.less +0 -41
  61. package/dist/core/shell/draggableShell/index.d.ts +0 -5
  62. package/dist/core/shell/draggableShell/index.js +0 -197
  63. package/dist/core/shell/draggableShell/index.less +0 -16
  64. package/dist/core/shell/tableShell.d.ts +0 -5
  65. package/dist/core/shell/tableShell.js +0 -109
  66. package/dist/core/table/events.d.ts +0 -15
  67. package/dist/core/table/events.js +0 -95
  68. package/dist/core/table/index.d.ts +0 -4
  69. package/dist/core/table/index.js +0 -313
  70. package/dist/core/table/useGroupConfig.d.ts +0 -2
  71. package/dist/core/table/useGroupConfig.js +0 -65
  72. package/dist/core/table/useRowSelection.d.ts +0 -2
  73. package/dist/core/table/useRowSelection.js +0 -24
  74. package/dist/core/table/util.d.ts +0 -8
  75. package/dist/core/table/util.js +0 -29
  76. package/dist/core/util.d.ts +0 -59
  77. package/dist/core/util.js +0 -490
  78. package/dist/core/viewer/btnViewer/index.d.ts +0 -2
  79. package/dist/core/viewer/btnViewer/index.js +0 -37
  80. package/dist/core/viewer/cascaderViewer/index.d.ts +0 -2
  81. package/dist/core/viewer/cascaderViewer/index.js +0 -11
  82. package/dist/core/viewer/checkViewer/index.d.ts +0 -2
  83. package/dist/core/viewer/checkViewer/index.js +0 -23
  84. package/dist/core/viewer/editViewer/index.d.ts +0 -2
  85. package/dist/core/viewer/editViewer/index.js +0 -31
  86. package/dist/core/viewer/groupViewer/index.d.ts +0 -2
  87. package/dist/core/viewer/groupViewer/index.js +0 -34
  88. package/dist/core/viewer/index.d.ts +0 -7
  89. package/dist/core/viewer/index.js +0 -7
  90. package/dist/core/viewer/selectorViewer/index.d.ts +0 -2
  91. package/dist/core/viewer/selectorViewer/index.js +0 -16
  92. package/dist/core/viewer/switchViewer/index.d.ts +0 -2
  93. package/dist/core/viewer/switchViewer/index.js +0 -22
  94. package/dist/example/antComponent.d.ts +0 -3
  95. package/dist/example/antComponent.js +0 -314
  96. package/dist/example/basic.d.ts +0 -4
  97. package/dist/example/basic.js +0 -121
  98. package/dist/example/ellipsis.d.ts +0 -3
  99. package/dist/example/ellipsis.js +0 -64
  100. package/dist/example/fixed.d.ts +0 -3
  101. package/dist/example/fixed.js +0 -89
  102. package/dist/example/group.d.ts +0 -3
  103. package/dist/example/group.js +0 -123
  104. package/dist/example/index.less +0 -5
  105. package/dist/example/selection.d.ts +0 -4
  106. package/dist/example/selection.js +0 -86
  107. package/dist/example/sheet.d.ts +0 -4
  108. package/dist/example/sheet.js +0 -393
  109. package/dist/example/valuationAnalyze.d.ts +0 -2
  110. package/dist/example/valuationAnalyze.js +0 -227
  111. package/dist/hooks/index.d.ts +0 -8
  112. package/dist/hooks/index.js +0 -7
  113. package/dist/hooks/useEventBus.d.ts +0 -4
  114. package/dist/hooks/useEventBus.js +0 -17
  115. package/dist/hooks/useKeyboard.d.ts +0 -18
  116. package/dist/hooks/useKeyboard.js +0 -108
  117. package/dist/hooks/useMiddlewareReducer.d.ts +0 -12
  118. package/dist/hooks/useMiddlewareReducer.js +0 -47
  119. package/dist/hooks/useMouse.d.ts +0 -11
  120. package/dist/hooks/useMouse.js +0 -68
  121. package/dist/hooks/useSetState.d.ts +0 -2
  122. package/dist/hooks/useSetState.js +0 -27
  123. package/dist/hooks/useSheetEvent.d.ts +0 -5
  124. package/dist/hooks/useSheetEvent.js +0 -5
  125. package/dist/hooks/useWidthConfig.d.ts +0 -4
  126. package/dist/hooks/useWidthConfig.js +0 -5
  127. package/dist/index.d.ts +0 -8
  128. package/dist/index.js +0 -8
  129. package/dist/standardUtils/index.d.ts +0 -9
  130. package/dist/standardUtils/index.js +0 -32
  131. package/dist/type/index.d.ts +0 -2
  132. package/dist/type/index.js +0 -4
  133. package/dist/type/sheet.d.ts +0 -205
  134. package/dist/type/sheet.js +0 -9
  135. package/dist/type/sheetTable.d.ts +0 -89
  136. package/dist/type/sheetTable.js +0 -1
  137. package/dist/typings/index.d.ts +0 -1
@@ -1,93 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
- import { isNil } from 'lodash';
8
- import { getNextVisibleRow, groupConfigToGroupMap } from "../util";
9
- export var keyboardReducer = {
10
- move: function move(state, payload) {
11
- var _state$start, _state$start2;
12
- var _ref = payload,
13
- row = _ref.row,
14
- col = _ref.col;
15
- var groupConfig = state.groupConfig,
16
- _state$data = state.data,
17
- data = _state$data === void 0 ? [] : _state$data;
18
- var newRow = (((_state$start = state.start) === null || _state$start === void 0 ? void 0 : _state$start.row) || 0) + row;
19
- if (groupConfig) {
20
- newRow = getNextVisibleRow(newRow, data.length, groupConfigToGroupMap(groupConfig), row < 0 ? -1 : 1);
21
- }
22
- var currentPos = {
23
- row: newRow,
24
- col: (((_state$start2 = state.start) === null || _state$start2 === void 0 ? void 0 : _state$start2.col) || 0) + col
25
- };
26
- var lastEditing = state.lastEditing;
27
- if (state.editing) {
28
- lastEditing = _objectSpread(_objectSpread({}, state.editing), {}, {
29
- confirm: true
30
- });
31
- }
32
- if (isNil(currentPos.row)) {
33
- return _objectSpread(_objectSpread({}, state), {}, {
34
- start: undefined,
35
- end: undefined,
36
- lastSelected: {
37
- start: state.start,
38
- end: state.end
39
- },
40
- editing: undefined,
41
- lastEditing: lastEditing
42
- });
43
- }
44
- return _objectSpread(_objectSpread({}, state), {}, {
45
- start: currentPos,
46
- end: currentPos,
47
- lastSelected: {
48
- start: state.start,
49
- end: state.end
50
- },
51
- editing: undefined,
52
- lastEditing: lastEditing
53
- });
54
- },
55
- escape: function escape(state) {
56
- return _objectSpread(_objectSpread({}, state), {}, {
57
- editing: undefined,
58
- lastEditing: state.editing
59
- });
60
- },
61
- reverse: function reverse(state) {
62
- return state;
63
- },
64
- delete: function _delete(state) {
65
- return state;
66
- },
67
- enter: function enter(state, payload) {
68
- var _data$start$row;
69
- var start = state.start,
70
- end = state.end,
71
- editing = state.editing,
72
- data = state.data;
73
- if (!start || !end || data !== null && data !== void 0 && (_data$start$row = data[start.row]) !== null && _data$start$row !== void 0 && _data$start$row[start.col].readonly) {
74
- return state;
75
- }
76
- if (!editing) {
77
- return _objectSpread(_objectSpread({}, state), {}, {
78
- end: start,
79
- editing: _objectSpread(_objectSpread({}, start), {}, {
80
- value: payload
81
- })
82
- });
83
- }
84
- return keyboardReducer.move(state, {
85
- row: 1,
86
- col: 0
87
- });
88
- },
89
- otherInput: function otherInput(state, payload) {
90
- if (state.editing) return state;
91
- return keyboardReducer.enter(state, payload);
92
- }
93
- };
@@ -1,2 +0,0 @@
1
- import { reducerAction } from '.';
2
- export declare const mouseReducer: Record<string, reducerAction>;
@@ -1,164 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
- export var mouseReducer = {
8
- mouseDown: function mouseDown(state, payload) {
9
- var _ref = payload,
10
- _ref$pos = _ref.pos,
11
- row = _ref$pos.row,
12
- col = _ref$pos.col,
13
- shiftKey = _ref.shiftKey;
14
- var data = state.data,
15
- start = state.start,
16
- end = state.end;
17
- if (data !== null && data !== void 0 && data[row][col].fixed) {
18
- return _objectSpread(_objectSpread({}, state), {}, {
19
- start: undefined,
20
- end: undefined,
21
- lastSelected: {
22
- start: start,
23
- end: end
24
- }
25
- });
26
- }
27
- if (shiftKey) {
28
- return _objectSpread(_objectSpread({}, state), {}, {
29
- mouseDown: true,
30
- editing: undefined,
31
- lastEditing: _objectSpread(_objectSpread({}, state.editing), {}, {
32
- confirm: true
33
- }),
34
- start: start ? start : {
35
- row: row,
36
- col: col
37
- },
38
- end: {
39
- row: row,
40
- col: col
41
- },
42
- lastSelected: {
43
- start: start,
44
- end: end
45
- }
46
- });
47
- }
48
- return _objectSpread(_objectSpread({}, state), {}, {
49
- mouseDown: true,
50
- editing: undefined,
51
- lastEditing: _objectSpread(_objectSpread({}, state.editing), {}, {
52
- confirm: true
53
- }),
54
- start: {
55
- row: row,
56
- col: col
57
- },
58
- end: {
59
- row: row,
60
- col: col
61
- },
62
- lastSelected: {
63
- start: start,
64
- end: end
65
- }
66
- });
67
- },
68
- mouseOver: function mouseOver(state, payload) {
69
- var _ref2 = payload,
70
- row = _ref2.row,
71
- col = _ref2.col;
72
- var data = state.data;
73
- if (state.mouseDown === false || data !== null && data !== void 0 && data[row][col].fixed) return state;
74
- return _objectSpread(_objectSpread({}, state), {}, {
75
- end: {
76
- row: row,
77
- col: col
78
- },
79
- lastSelected: {
80
- start: state.start,
81
- end: state.end
82
- }
83
- });
84
- },
85
- mouseUp: function mouseUp(state, payload) {
86
- var _ref3 = payload,
87
- row = _ref3.row,
88
- col = _ref3.col;
89
- var data = state.data;
90
- if (state.mouseDown === false || data !== null && data !== void 0 && data[row][col].fixed) return state;
91
- return _objectSpread(_objectSpread({}, state), {}, {
92
- mouseDown: false,
93
- end: {
94
- row: row,
95
- col: col
96
- },
97
- lastSelected: {
98
- start: state.start,
99
- end: state.end
100
- }
101
- });
102
- },
103
- loseFocus: function loseFocus(state) {
104
- var lastEditing = state.lastEditing;
105
- if (state.editing) {
106
- lastEditing = _objectSpread(_objectSpread({}, state.editing), {}, {
107
- confirm: true
108
- });
109
- }
110
- return _objectSpread(_objectSpread({}, state), {}, {
111
- start: undefined,
112
- end: undefined,
113
- editing: undefined,
114
- lastEditing: lastEditing,
115
- lastSelected: {
116
- start: state.start,
117
- end: state.end
118
- }
119
- });
120
- },
121
- doubleClick: function doubleClick(state, payload) {
122
- var _data$row$col;
123
- var _ref4 = payload,
124
- row = _ref4.row,
125
- col = _ref4.col;
126
- var data = state.data;
127
- if (data !== null && data !== void 0 && (_data$row$col = data[row][col]) !== null && _data$row$col !== void 0 && _data$row$col.readonly) {
128
- return state;
129
- }
130
- return _objectSpread(_objectSpread({}, state), {}, {
131
- mouseDown: false,
132
- editing: {
133
- row: row,
134
- col: col
135
- },
136
- start: {
137
- row: row,
138
- col: col
139
- },
140
- end: {
141
- row: row,
142
- col: col
143
- },
144
- lastSelected: {
145
- start: state.start,
146
- end: state.end
147
- },
148
- lastEditing: state.editing
149
- });
150
- },
151
- mouseLeaveInterval: function mouseLeaveInterval(state, payload) {
152
- var _data$, _data$$end$col;
153
- var _ref5 = payload,
154
- end = _ref5.end;
155
- var data = state.data;
156
- // fixed 列不选中
157
- if (data !== null && data !== void 0 && (_data$ = data[0]) !== null && _data$ !== void 0 && (_data$$end$col = _data$[end.col]) !== null && _data$$end$col !== void 0 && _data$$end$col.fixed) {
158
- return state;
159
- }
160
- return _objectSpread(_objectSpread({}, state), {}, {
161
- end: end
162
- });
163
- }
164
- };
@@ -1,4 +0,0 @@
1
- import type { SheetType } from "../../type";
2
- import { FunctionAction, NormalAction } from '../../hooks';
3
- export declare type asyncActionType = (dispatch: (action: NormalAction | FunctionAction) => void, getState: () => SheetType.UpdateStateType) => void;
4
- export declare const sideEffectReducer: Record<string, asyncActionType>;
@@ -1,378 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
- 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."); }
5
- 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); }
6
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
- 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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- 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); }
14
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
- import { head, isNil, last, pick } from 'lodash';
17
- import { clipboardDataToString, flatRowCol, flatRowColIndex, formatDataToCell, getRowColConfig, groupConfigToGroupMap, stringToClipboardData } from "../util";
18
- export var sideEffectReducer = {
19
- init: function init(dispatch, getState) {
20
- var _getState = getState(),
21
- eventBus = _getState.eventBus;
22
- eventBus.on('cell-change', function (cell) {
23
- dispatch(function () {
24
- var _getState2 = getState(),
25
- cellChangeHandler = _getState2.cellChangeHandler;
26
- dispatch({
27
- type: 'editFinish',
28
- payload: {
29
- cell: cell
30
- }
31
- });
32
- cellChangeHandler && cellChangeHandler([cell]);
33
- });
34
- });
35
- eventBus.on('cell-create', function (_ref) {
36
- var row = _ref.row,
37
- col = _ref.col;
38
- var _getState3 = getState(),
39
- start = _getState3.start,
40
- end = _getState3.end;
41
- var _getRowColConfig = getRowColConfig(start, end),
42
- startRow = _getRowColConfig.startRow,
43
- endRow = _getRowColConfig.endRow,
44
- startCol = _getRowColConfig.startCol,
45
- endCol = _getRowColConfig.endCol;
46
- var isMultiSelected = startRow !== endRow && startCol !== endCol;
47
- var isSelected = row >= startRow && row <= endRow && col >= startCol && col <= endCol;
48
- if (isSelected) {
49
- eventBus.emit("cell-".concat(row, "-").concat(col, "-change"), {
50
- selected: true,
51
- selectedInfo: {
52
- isStart: row === (start === null || start === void 0 ? void 0 : start.row) && col === start.col && isMultiSelected,
53
- isTop: row === startRow,
54
- isBottom: row === endRow,
55
- isLeft: col === startCol,
56
- isRight: col === endCol
57
- }
58
- });
59
- }
60
- });
61
- },
62
- destroy: function destroy(d, getState) {
63
- var _getState4 = getState(),
64
- eventBus = _getState4.eventBus;
65
- eventBus === null || eventBus === void 0 ? void 0 : eventBus.removeAllListeners();
66
- },
67
- emitSelectChange: function emitSelectChange(d, getState) {
68
- var _getState5 = getState(),
69
- eventBus = _getState5.eventBus,
70
- lastSelected = _getState5.lastSelected,
71
- start = _getState5.start,
72
- end = _getState5.end;
73
- var _getRowColConfig2 = getRowColConfig(start, end),
74
- startRow = _getRowColConfig2.startRow,
75
- endRow = _getRowColConfig2.endRow,
76
- startCol = _getRowColConfig2.startCol,
77
- endCol = _getRowColConfig2.endCol;
78
- var selectedCellIndex = flatRowColIndex(start, end);
79
- var selectedCells = flatRowCol(start, end);
80
- var cancelCells = flatRowCol(lastSelected === null || lastSelected === void 0 ? void 0 : lastSelected.start, lastSelected === null || lastSelected === void 0 ? void 0 : lastSelected.end);
81
- cancelCells.forEach(function (cell) {
82
- if (selectedCells.includes(cell)) return;
83
- eventBus.emit("cell-".concat(cell, "-change"), {
84
- selected: false,
85
- selectedInfo: undefined
86
- });
87
- });
88
- selectedCellIndex.forEach(function (_ref2) {
89
- var row = _ref2.row,
90
- col = _ref2.col;
91
- eventBus.emit("cell-".concat(row, "-").concat(col, "-change"), {
92
- selected: true,
93
- selectedInfo: {
94
- isStart: row === (start === null || start === void 0 ? void 0 : start.row) && col === start.col && selectedCellIndex.length !== 1,
95
- isTop: row === startRow,
96
- isBottom: row === endRow,
97
- isLeft: col === startCol,
98
- isRight: col === endCol
99
- }
100
- });
101
- });
102
- },
103
- emitEditChange: function emitEditChange(d, getState) {
104
- var _getState6 = getState(),
105
- editing = _getState6.editing,
106
- lastEditing = _getState6.lastEditing,
107
- eventBus = _getState6.eventBus;
108
- if (!isNil(editing === null || editing === void 0 ? void 0 : editing.col) && !isNil(editing === null || editing === void 0 ? void 0 : editing.row)) {
109
- eventBus.emit("cell-".concat(editing.row, "-").concat(editing.col, "-change"), {
110
- editing: true,
111
- value: editing.value
112
- });
113
- }
114
- if (!isNil(lastEditing === null || lastEditing === void 0 ? void 0 : lastEditing.col) && !isNil(lastEditing === null || lastEditing === void 0 ? void 0 : lastEditing.row)) {
115
- //清空上一个编辑cell的状态
116
- eventBus.emit("cell-".concat(lastEditing.row, "-").concat(lastEditing.col, "-change"), {
117
- editing: false,
118
- confirm: lastEditing === null || lastEditing === void 0 ? void 0 : lastEditing.confirm
119
- });
120
- d({
121
- type: 'changes',
122
- payload: {
123
- lastEditing: undefined
124
- }
125
- });
126
- }
127
- },
128
- copy: function copy(d, getState) {
129
- var _getState7 = getState(),
130
- start = _getState7.start,
131
- end = _getState7.end,
132
- data = _getState7.data,
133
- groupConfig = _getState7.groupConfig;
134
- if (!start || !end) {
135
- return;
136
- }
137
- var cellIndex = flatRowColIndex(start, end);
138
- var groupMap = groupConfigToGroupMap(groupConfig);
139
- var count = 0;
140
- var copyData = cellIndex.reduce(function (left, _ref3) {
141
- var _ref3$row = _ref3.row,
142
- row = _ref3$row === void 0 ? 0 : _ref3$row,
143
- _ref3$col = _ref3.col,
144
- col = _ref3$col === void 0 ? 0 : _ref3$col;
145
- var currentRow = left.currentRow,
146
- value = left.value;
147
- if (groupMap.get(row)) {
148
- var _groupMap$get, _groupMap$get2;
149
- // 如果是分组的子行并且是合并的状态
150
- if (!((_groupMap$get = groupMap.get(row)) !== null && _groupMap$get !== void 0 && _groupMap$get.isStart) && !((_groupMap$get2 = groupMap.get(row)) !== null && _groupMap$get2 !== void 0 && _groupMap$get2.isOpen)) {
151
- return {
152
- currentRow: row,
153
- value: "".concat(value)
154
- };
155
- }
156
- }
157
- count++;
158
-
159
- // 复制到剪贴板的时候执行 formatter
160
- var _data$row$col = data[row][col],
161
- dataValue = _data$row$col.value,
162
- dataEditor = _data$row$col.dataEditor,
163
- record = _data$row$col.record;
164
- var _ref4 = dataEditor || {},
165
- dataFormatter = _ref4.formatter;
166
- var formattedValue = dataFormatter ? dataFormatter(dataValue, record) : dataValue;
167
- if (isNil(dataValue)) {
168
- formattedValue = ' ';
169
- }
170
- if (currentRow === -1) {
171
- return {
172
- currentRow: row,
173
- value: formattedValue
174
- };
175
- }
176
- var currentValue = "".concat(value).concat(currentRow === row ? '\t' : '\n', " ").concat(formattedValue);
177
- return {
178
- currentRow: row,
179
- value: currentValue
180
- };
181
- }, {
182
- currentRow: -1,
183
- value: ''
184
- });
185
- var text = copyData.value;
186
- stringToClipboardData(text, count);
187
- },
188
- paste: function paste(dispatch, getState) {
189
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
190
- var _extChanges$;
191
- var _getState8, start, end, cellChangeHandler, history, _getState8$freePaste, freePaste, data, groupConfig, pasteData, changeInfo, changes, extChanges, legalChanges, lastRow, lastIndex, legalExtChanges, newHistory;
192
- return _regeneratorRuntime().wrap(function _callee$(_context) {
193
- while (1) switch (_context.prev = _context.next) {
194
- case 0:
195
- _getState8 = getState(), start = _getState8.start, end = _getState8.end, cellChangeHandler = _getState8.cellChangeHandler, history = _getState8.history, _getState8$freePaste = _getState8.freePaste, freePaste = _getState8$freePaste === void 0 ? false : _getState8$freePaste, data = _getState8.data, groupConfig = _getState8.groupConfig;
196
- if (!(!start || !end)) {
197
- _context.next = 3;
198
- break;
199
- }
200
- return _context.abrupt("return");
201
- case 3:
202
- _context.next = 5;
203
- return clipboardDataToString();
204
- case 5:
205
- pasteData = _context.sent;
206
- changeInfo = formatDataToCell(_objectSpread(_objectSpread({}, pick(getState(), ['data', 'start', 'end', 'editing'])), {}, {
207
- pasteData: pasteData,
208
- groupConfig: groupConfig,
209
- freePaste: freePaste
210
- }));
211
- if (changeInfo) {
212
- _context.next = 9;
213
- break;
214
- }
215
- return _context.abrupt("return");
216
- case 9:
217
- changes = changeInfo.changes, extChanges = changeInfo.extChanges;
218
- legalChanges = changes.filter(function (_ref5) {
219
- var row = _ref5.row,
220
- col = _ref5.col,
221
- value = _ref5.value;
222
- var editor = data[row][col].dataEditor;
223
- if (editor && editor.checker) {
224
- return editor.checker(value, data[row][col].record);
225
- }
226
- return true;
227
- }).map(function (_ref6) {
228
- var _data$row$col2, _editor$parser;
229
- var row = _ref6.row,
230
- col = _ref6.col,
231
- value = _ref6.value;
232
- var editor = data[row][col].dataEditor;
233
- return {
234
- row: row,
235
- col: col,
236
- id: (_data$row$col2 = data[row][col]) === null || _data$row$col2 === void 0 ? void 0 : _data$row$col2.id,
237
- value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 ? void 0 : (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value, data[row][col].record) : value
238
- };
239
- });
240
- lastRow = extChanges === null || extChanges === void 0 ? void 0 : (_extChanges$ = extChanges[0]) === null || _extChanges$ === void 0 ? void 0 : _extChanges$.row;
241
- lastIndex = 1;
242
- legalExtChanges = extChanges === null || extChanges === void 0 ? void 0 : extChanges.filter(function (_ref7) {
243
- var value = _ref7.value,
244
- col = _ref7.col;
245
- var editor = data[0][col].dataEditor;
246
- if (editor && editor.checker) {
247
- return editor.checker(value);
248
- }
249
- return true;
250
- }).map(function (_ref8) {
251
- var _editor$parser2;
252
- var row = _ref8.row,
253
- col = _ref8.col,
254
- value = _ref8.value;
255
- var editor = data[0][col].dataEditor;
256
- if (lastRow !== row) {
257
- lastRow = row;
258
- lastIndex++;
259
- }
260
- return {
261
- row: row,
262
- col: col,
263
- value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 ? void 0 : (_editor$parser2 = editor.parser) === null || _editor$parser2 === void 0 ? void 0 : _editor$parser2.call(editor, value) : value,
264
- id: -lastIndex
265
- };
266
- });
267
- newHistory = _toConsumableArray(history || []);
268
- newHistory.push({
269
- changes: legalChanges.map(function (item) {
270
- return _objectSpread(_objectSpread({}, item), {}, {
271
- value: data[item.row][item.col].value
272
- });
273
- }),
274
- type: 'Paste'
275
- });
276
- dispatch({
277
- type: 'changes',
278
- payload: {
279
- start: pick(legalChanges[0], ['row', 'col']),
280
- history: newHistory,
281
- end: pick(legalChanges[legalChanges.length - 1], ['row', 'col']),
282
- lastSelected: {
283
- start: start,
284
- end: end
285
- }
286
- }
287
- });
288
- cellChangeHandler && cellChangeHandler(legalChanges, freePaste ? legalExtChanges : []);
289
- case 18:
290
- case "end":
291
- return _context.stop();
292
- }
293
- }, _callee);
294
- }))();
295
- },
296
- delete: function _delete(dispatch, getState) {
297
- var _getState9 = getState(),
298
- cellChangeHandler = _getState9.cellChangeHandler,
299
- start = _getState9.start,
300
- end = _getState9.end,
301
- data = _getState9.data,
302
- history = _getState9.history,
303
- groupConfig = _getState9.groupConfig,
304
- editing = _getState9.editing;
305
- if (editing) return;
306
- var groupMap = groupConfigToGroupMap(groupConfig);
307
- var cellIndex = flatRowColIndex(start, end);
308
- var changes = cellIndex.filter(function (item) {
309
- var _data$item$row;
310
- return !(data !== null && data !== void 0 && (_data$item$row = data[item.row]) !== null && _data$item$row !== void 0 && _data$item$row[item.col].readonly);
311
- }).filter(
312
- // 过滤掉分组的子行并且是关闭的状态
313
- function (item) {
314
- var _groupMap$get3, _groupMap$get4;
315
- return !(groupMap.get(item.row) && !((_groupMap$get3 = groupMap.get(item.row)) !== null && _groupMap$get3 !== void 0 && _groupMap$get3.isStart) && !((_groupMap$get4 = groupMap.get(item.row)) !== null && _groupMap$get4 !== void 0 && _groupMap$get4.isOpen));
316
- }).map(function (item) {
317
- var _data$item$row2, _data$item$row3;
318
- return {
319
- cell: data === null || data === void 0 ? void 0 : (_data$item$row2 = data[item.row]) === null || _data$item$row2 === void 0 ? void 0 : _data$item$row2[item.col],
320
- row: item.row,
321
- col: item.col,
322
- value: null,
323
- id: data === null || data === void 0 ? void 0 : (_data$item$row3 = data[item.row]) === null || _data$item$row3 === void 0 ? void 0 : _data$item$row3[item.col].id
324
- };
325
- });
326
- var newHistory = _toConsumableArray(history || []);
327
- newHistory.push({
328
- changes: changes.map(function (item) {
329
- return _objectSpread(_objectSpread({}, item), {}, {
330
- value: data[item.row][item.col].value
331
- });
332
- }),
333
- type: 'Delete'
334
- });
335
- dispatch({
336
- type: 'changes',
337
- payload: {
338
- history: newHistory
339
- }
340
- });
341
- cellChangeHandler && cellChangeHandler(changes);
342
- },
343
- reverse: function reverse(dispatch, getState) {
344
- var _getState10 = getState(),
345
- start = _getState10.start,
346
- end = _getState10.end,
347
- history = _getState10.history,
348
- cellChangeHandler = _getState10.cellChangeHandler,
349
- eventBus = _getState10.eventBus;
350
- if (!(history !== null && history !== void 0 && history.length)) return;
351
- var changeHistory = _toConsumableArray(history);
352
- var change = changeHistory.pop();
353
- var type = change.type;
354
- if (!['Edit', 'Paste', 'Delete'].includes(type)) {
355
- eventBus.emit('reverse', change);
356
- dispatch({
357
- type: 'changes',
358
- payload: {
359
- history: changeHistory
360
- }
361
- });
362
- return;
363
- }
364
- cellChangeHandler && cellChangeHandler(change.changes);
365
- dispatch({
366
- type: 'changes',
367
- payload: {
368
- start: pick(head(change.changes), ['row', 'col']),
369
- end: pick(last(change.changes), ['row', 'col']),
370
- lastSelected: {
371
- start: start,
372
- end: end
373
- },
374
- history: changeHistory
375
- }
376
- });
377
- }
378
- };
@@ -1,2 +0,0 @@
1
- import { reducerAction } from '.';
2
- export declare const stateReducer: Record<string, reducerAction>;