@zhenliang/sheet 0.1.19 → 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.
- package/changes.md +45 -0
- package/package.json +1 -1
- package/dist/core/config.d.ts +0 -13
- package/dist/core/config.js +0 -13
- package/dist/core/editor/cascaderEditor/index.d.ts +0 -5
- package/dist/core/editor/cascaderEditor/index.js +0 -54
- package/dist/core/editor/cascaderEditor/index.less +0 -28
- package/dist/core/editor/dateEditor/index.d.ts +0 -5
- package/dist/core/editor/dateEditor/index.js +0 -55
- package/dist/core/editor/dateEditor/index.less +0 -11
- package/dist/core/editor/index.d.ts +0 -4
- package/dist/core/editor/index.js +0 -4
- package/dist/core/editor/numberEditor/index.d.ts +0 -8
- package/dist/core/editor/numberEditor/index.js +0 -107
- package/dist/core/editor/numberEditor/index.less +0 -30
- package/dist/core/editor/selectEditor/index.d.ts +0 -6
- package/dist/core/editor/selectEditor/index.js +0 -96
- package/dist/core/editor/selectEditor/index.less +0 -43
- package/dist/core/reducers/index.d.ts +0 -9
- package/dist/core/reducers/index.js +0 -38
- package/dist/core/reducers/keyboardReducer.d.ts +0 -2
- package/dist/core/reducers/keyboardReducer.js +0 -93
- package/dist/core/reducers/mouseReducer.d.ts +0 -2
- package/dist/core/reducers/mouseReducer.js +0 -164
- package/dist/core/reducers/sideEffectReducer.d.ts +0 -4
- package/dist/core/reducers/sideEffectReducer.js +0 -376
- package/dist/core/reducers/stateReducer.d.ts +0 -2
- package/dist/core/reducers/stateReducer.js +0 -174
- package/dist/core/sheet/Cell.d.ts +0 -4
- package/dist/core/sheet/Cell.js +0 -181
- package/dist/core/sheet/DataEditor.d.ts +0 -3
- package/dist/core/sheet/DataEditor.js +0 -24
- package/dist/core/sheet/DefaultCell.d.ts +0 -11
- package/dist/core/sheet/DefaultCell.js +0 -31
- package/dist/core/sheet/DefaultRow.d.ts +0 -12
- package/dist/core/sheet/DefaultRow.js +0 -28
- package/dist/core/sheet/DefaultRowMapper.d.ts +0 -8
- package/dist/core/sheet/DefaultRowMapper.js +0 -15
- package/dist/core/sheet/DefaultShell.d.ts +0 -8
- package/dist/core/sheet/DefaultShell.js +0 -12
- package/dist/core/sheet/Event.d.ts +0 -5
- package/dist/core/sheet/Event.js +0 -17
- package/dist/core/sheet/ValueViewer.d.ts +0 -3
- package/dist/core/sheet/ValueViewer.js +0 -9
- package/dist/core/sheet/index.d.ts +0 -5
- package/dist/core/sheet/index.js +0 -265
- package/dist/core/sheet/index.less +0 -307
- package/dist/core/sheet/useCellEvent.d.ts +0 -3
- package/dist/core/sheet/useCellEvent.js +0 -22
- package/dist/core/sheet/useContextMenu.d.ts +0 -21
- package/dist/core/sheet/useContextMenu.js +0 -86
- package/dist/core/sheet/useKeyBoardEvent.d.ts +0 -3
- package/dist/core/sheet/useKeyBoardEvent.js +0 -66
- package/dist/core/sheet/useMouseEvent.d.ts +0 -3
- package/dist/core/sheet/useMouseEvent.js +0 -298
- package/dist/core/sheet/useSelectVisible.d.ts +0 -2
- package/dist/core/sheet/useSelectVisible.js +0 -57
- package/dist/core/sheet/useVirtualList.d.ts +0 -7
- package/dist/core/sheet/useVirtualList.js +0 -103
- package/dist/core/sheet/var.less +0 -41
- package/dist/core/shell/draggableShell/index.d.ts +0 -5
- package/dist/core/shell/draggableShell/index.js +0 -197
- package/dist/core/shell/draggableShell/index.less +0 -16
- package/dist/core/shell/tableShell.d.ts +0 -5
- package/dist/core/shell/tableShell.js +0 -109
- package/dist/core/table/events.d.ts +0 -15
- package/dist/core/table/events.js +0 -95
- package/dist/core/table/index.d.ts +0 -4
- package/dist/core/table/index.js +0 -313
- package/dist/core/table/useGroupConfig.d.ts +0 -2
- package/dist/core/table/useGroupConfig.js +0 -65
- package/dist/core/table/useRowSelection.d.ts +0 -2
- package/dist/core/table/useRowSelection.js +0 -24
- package/dist/core/table/util.d.ts +0 -8
- package/dist/core/table/util.js +0 -29
- package/dist/core/util.d.ts +0 -59
- package/dist/core/util.js +0 -490
- package/dist/core/viewer/btnViewer/index.d.ts +0 -2
- package/dist/core/viewer/btnViewer/index.js +0 -37
- package/dist/core/viewer/cascaderViewer/index.d.ts +0 -2
- package/dist/core/viewer/cascaderViewer/index.js +0 -11
- package/dist/core/viewer/checkViewer/index.d.ts +0 -2
- package/dist/core/viewer/checkViewer/index.js +0 -23
- package/dist/core/viewer/editViewer/index.d.ts +0 -2
- package/dist/core/viewer/editViewer/index.js +0 -31
- package/dist/core/viewer/groupViewer/index.d.ts +0 -2
- package/dist/core/viewer/groupViewer/index.js +0 -34
- package/dist/core/viewer/index.d.ts +0 -7
- package/dist/core/viewer/index.js +0 -7
- package/dist/core/viewer/selectorViewer/index.d.ts +0 -2
- package/dist/core/viewer/selectorViewer/index.js +0 -16
- package/dist/core/viewer/switchViewer/index.d.ts +0 -2
- package/dist/core/viewer/switchViewer/index.js +0 -22
- package/dist/example/antComponent.d.ts +0 -3
- package/dist/example/antComponent.js +0 -314
- package/dist/example/basic.d.ts +0 -4
- package/dist/example/basic.js +0 -121
- package/dist/example/ellipsis.d.ts +0 -3
- package/dist/example/ellipsis.js +0 -64
- package/dist/example/fixed.d.ts +0 -3
- package/dist/example/fixed.js +0 -89
- package/dist/example/group.d.ts +0 -3
- package/dist/example/group.js +0 -123
- package/dist/example/index.less +0 -5
- package/dist/example/selection.d.ts +0 -4
- package/dist/example/selection.js +0 -86
- package/dist/example/sheet.d.ts +0 -4
- package/dist/example/sheet.js +0 -393
- package/dist/example/valuationAnalyze.d.ts +0 -2
- package/dist/example/valuationAnalyze.js +0 -227
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.js +0 -7
- package/dist/hooks/useEventBus.d.ts +0 -3
- package/dist/hooks/useEventBus.js +0 -17
- package/dist/hooks/useKeyboard.d.ts +0 -18
- package/dist/hooks/useKeyboard.js +0 -108
- package/dist/hooks/useMiddlewareReducer.d.ts +0 -12
- package/dist/hooks/useMiddlewareReducer.js +0 -47
- package/dist/hooks/useMouse.d.ts +0 -11
- package/dist/hooks/useMouse.js +0 -68
- package/dist/hooks/useSetState.d.ts +0 -2
- package/dist/hooks/useSetState.js +0 -27
- package/dist/hooks/useSheetEvent.d.ts +0 -5
- package/dist/hooks/useSheetEvent.js +0 -5
- package/dist/hooks/useWidthConfig.d.ts +0 -4
- package/dist/hooks/useWidthConfig.js +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/standardUtils/index.d.ts +0 -9
- package/dist/standardUtils/index.js +0 -32
- package/dist/type/index.d.ts +0 -2
- package/dist/type/index.js +0 -4
- package/dist/type/sheet.d.ts +0 -205
- package/dist/type/sheet.js +0 -9
- package/dist/type/sheetTable.d.ts +0 -89
- package/dist/type/sheetTable.js +0 -1
- 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,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,376 +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 copyData = cellIndex.reduce(function (left, _ref3) {
|
|
140
|
-
var _ref3$row = _ref3.row,
|
|
141
|
-
row = _ref3$row === void 0 ? 0 : _ref3$row,
|
|
142
|
-
_ref3$col = _ref3.col,
|
|
143
|
-
col = _ref3$col === void 0 ? 0 : _ref3$col;
|
|
144
|
-
var currentRow = left.currentRow,
|
|
145
|
-
value = left.value;
|
|
146
|
-
if (groupMap.get(row)) {
|
|
147
|
-
var _groupMap$get, _groupMap$get2;
|
|
148
|
-
// 如果是分组的子行并且是合并的状态
|
|
149
|
-
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)) {
|
|
150
|
-
return {
|
|
151
|
-
currentRow: row,
|
|
152
|
-
value: "".concat(value)
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 复制到剪贴板的时候执行 formatter
|
|
158
|
-
var _data$row$col = data[row][col],
|
|
159
|
-
dataValue = _data$row$col.value,
|
|
160
|
-
dataEditor = _data$row$col.dataEditor,
|
|
161
|
-
record = _data$row$col.record;
|
|
162
|
-
var _ref4 = dataEditor || {},
|
|
163
|
-
dataFormatter = _ref4.formatter;
|
|
164
|
-
var formattedValue = dataFormatter ? dataFormatter(dataValue, record) : dataValue;
|
|
165
|
-
if (isNil(dataValue)) {
|
|
166
|
-
formattedValue = ' ';
|
|
167
|
-
}
|
|
168
|
-
if (currentRow === -1) {
|
|
169
|
-
return {
|
|
170
|
-
currentRow: row,
|
|
171
|
-
value: formattedValue
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
var currentValue = "".concat(value).concat(currentRow === row ? '\t' : '\n', " ").concat(formattedValue);
|
|
175
|
-
return {
|
|
176
|
-
currentRow: row,
|
|
177
|
-
value: currentValue
|
|
178
|
-
};
|
|
179
|
-
}, {
|
|
180
|
-
currentRow: -1,
|
|
181
|
-
value: ''
|
|
182
|
-
});
|
|
183
|
-
var text = copyData.value;
|
|
184
|
-
stringToClipboardData(text, cellIndex.length);
|
|
185
|
-
},
|
|
186
|
-
paste: function paste(dispatch, getState) {
|
|
187
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
188
|
-
var _extChanges$;
|
|
189
|
-
var _getState8, start, end, cellChangeHandler, history, _getState8$freePaste, freePaste, data, groupConfig, pasteData, changeInfo, changes, extChanges, legalChanges, lastRow, lastIndex, legalExtChanges, newHistory;
|
|
190
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
191
|
-
while (1) switch (_context.prev = _context.next) {
|
|
192
|
-
case 0:
|
|
193
|
-
_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;
|
|
194
|
-
if (!(!start || !end)) {
|
|
195
|
-
_context.next = 3;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
return _context.abrupt("return");
|
|
199
|
-
case 3:
|
|
200
|
-
_context.next = 5;
|
|
201
|
-
return clipboardDataToString();
|
|
202
|
-
case 5:
|
|
203
|
-
pasteData = _context.sent;
|
|
204
|
-
changeInfo = formatDataToCell(_objectSpread(_objectSpread({}, pick(getState(), ['data', 'start', 'end', 'editing'])), {}, {
|
|
205
|
-
pasteData: pasteData,
|
|
206
|
-
groupConfig: groupConfig,
|
|
207
|
-
freePaste: freePaste
|
|
208
|
-
}));
|
|
209
|
-
if (changeInfo) {
|
|
210
|
-
_context.next = 9;
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
return _context.abrupt("return");
|
|
214
|
-
case 9:
|
|
215
|
-
changes = changeInfo.changes, extChanges = changeInfo.extChanges;
|
|
216
|
-
legalChanges = changes.filter(function (_ref5) {
|
|
217
|
-
var row = _ref5.row,
|
|
218
|
-
col = _ref5.col,
|
|
219
|
-
value = _ref5.value;
|
|
220
|
-
var editor = data[row][col].dataEditor;
|
|
221
|
-
if (editor && editor.checker) {
|
|
222
|
-
return editor.checker(value, data[row][col].record);
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
|
-
}).map(function (_ref6) {
|
|
226
|
-
var _data$row$col2, _editor$parser;
|
|
227
|
-
var row = _ref6.row,
|
|
228
|
-
col = _ref6.col,
|
|
229
|
-
value = _ref6.value;
|
|
230
|
-
var editor = data[row][col].dataEditor;
|
|
231
|
-
return {
|
|
232
|
-
row: row,
|
|
233
|
-
col: col,
|
|
234
|
-
id: (_data$row$col2 = data[row][col]) === null || _data$row$col2 === void 0 ? void 0 : _data$row$col2.id,
|
|
235
|
-
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
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
lastRow = extChanges === null || extChanges === void 0 ? void 0 : (_extChanges$ = extChanges[0]) === null || _extChanges$ === void 0 ? void 0 : _extChanges$.row;
|
|
239
|
-
lastIndex = 1;
|
|
240
|
-
legalExtChanges = extChanges === null || extChanges === void 0 ? void 0 : extChanges.filter(function (_ref7) {
|
|
241
|
-
var value = _ref7.value,
|
|
242
|
-
col = _ref7.col;
|
|
243
|
-
var editor = data[0][col].dataEditor;
|
|
244
|
-
if (editor && editor.checker) {
|
|
245
|
-
return editor.checker(value);
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}).map(function (_ref8) {
|
|
249
|
-
var _editor$parser2;
|
|
250
|
-
var row = _ref8.row,
|
|
251
|
-
col = _ref8.col,
|
|
252
|
-
value = _ref8.value;
|
|
253
|
-
var editor = data[0][col].dataEditor;
|
|
254
|
-
if (lastRow !== row) {
|
|
255
|
-
lastRow = row;
|
|
256
|
-
lastIndex++;
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
row: row,
|
|
260
|
-
col: col,
|
|
261
|
-
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,
|
|
262
|
-
id: -lastIndex
|
|
263
|
-
};
|
|
264
|
-
});
|
|
265
|
-
newHistory = _toConsumableArray(history || []);
|
|
266
|
-
newHistory.push({
|
|
267
|
-
changes: legalChanges.map(function (item) {
|
|
268
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
269
|
-
value: data[item.row][item.col].value
|
|
270
|
-
});
|
|
271
|
-
}),
|
|
272
|
-
type: 'Paste'
|
|
273
|
-
});
|
|
274
|
-
dispatch({
|
|
275
|
-
type: 'changes',
|
|
276
|
-
payload: {
|
|
277
|
-
start: pick(legalChanges[0], ['row', 'col']),
|
|
278
|
-
history: newHistory,
|
|
279
|
-
end: pick(legalChanges[legalChanges.length - 1], ['row', 'col']),
|
|
280
|
-
lastSelected: {
|
|
281
|
-
start: start,
|
|
282
|
-
end: end
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
cellChangeHandler && cellChangeHandler(legalChanges, freePaste ? legalExtChanges : []);
|
|
287
|
-
case 18:
|
|
288
|
-
case "end":
|
|
289
|
-
return _context.stop();
|
|
290
|
-
}
|
|
291
|
-
}, _callee);
|
|
292
|
-
}))();
|
|
293
|
-
},
|
|
294
|
-
delete: function _delete(dispatch, getState) {
|
|
295
|
-
var _getState9 = getState(),
|
|
296
|
-
cellChangeHandler = _getState9.cellChangeHandler,
|
|
297
|
-
start = _getState9.start,
|
|
298
|
-
end = _getState9.end,
|
|
299
|
-
data = _getState9.data,
|
|
300
|
-
history = _getState9.history,
|
|
301
|
-
groupConfig = _getState9.groupConfig,
|
|
302
|
-
editing = _getState9.editing;
|
|
303
|
-
if (editing) return;
|
|
304
|
-
var groupMap = groupConfigToGroupMap(groupConfig);
|
|
305
|
-
var cellIndex = flatRowColIndex(start, end);
|
|
306
|
-
var changes = cellIndex.filter(function (item) {
|
|
307
|
-
var _data$item$row;
|
|
308
|
-
return !(data !== null && data !== void 0 && (_data$item$row = data[item.row]) !== null && _data$item$row !== void 0 && _data$item$row[item.col].readonly);
|
|
309
|
-
}).filter(
|
|
310
|
-
// 过滤掉分组的子行并且是关闭的状态
|
|
311
|
-
function (item) {
|
|
312
|
-
var _groupMap$get3, _groupMap$get4;
|
|
313
|
-
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));
|
|
314
|
-
}).map(function (item) {
|
|
315
|
-
var _data$item$row2, _data$item$row3;
|
|
316
|
-
return {
|
|
317
|
-
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],
|
|
318
|
-
row: item.row,
|
|
319
|
-
col: item.col,
|
|
320
|
-
value: null,
|
|
321
|
-
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
|
|
322
|
-
};
|
|
323
|
-
});
|
|
324
|
-
var newHistory = _toConsumableArray(history || []);
|
|
325
|
-
newHistory.push({
|
|
326
|
-
changes: changes.map(function (item) {
|
|
327
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
328
|
-
value: data[item.row][item.col].value
|
|
329
|
-
});
|
|
330
|
-
}),
|
|
331
|
-
type: 'Delete'
|
|
332
|
-
});
|
|
333
|
-
dispatch({
|
|
334
|
-
type: 'changes',
|
|
335
|
-
payload: {
|
|
336
|
-
history: newHistory
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
cellChangeHandler && cellChangeHandler(changes);
|
|
340
|
-
},
|
|
341
|
-
reverse: function reverse(dispatch, getState) {
|
|
342
|
-
var _getState10 = getState(),
|
|
343
|
-
start = _getState10.start,
|
|
344
|
-
end = _getState10.end,
|
|
345
|
-
history = _getState10.history,
|
|
346
|
-
cellChangeHandler = _getState10.cellChangeHandler,
|
|
347
|
-
eventBus = _getState10.eventBus;
|
|
348
|
-
if (!(history !== null && history !== void 0 && history.length)) return;
|
|
349
|
-
var changeHistory = _toConsumableArray(history);
|
|
350
|
-
var change = changeHistory.pop();
|
|
351
|
-
var type = change.type;
|
|
352
|
-
if (!['Edit', 'Paste', 'Delete'].includes(type)) {
|
|
353
|
-
eventBus.emit('reverse', change);
|
|
354
|
-
dispatch({
|
|
355
|
-
type: 'changes',
|
|
356
|
-
payload: {
|
|
357
|
-
history: changeHistory
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
cellChangeHandler && cellChangeHandler(change.changes);
|
|
363
|
-
dispatch({
|
|
364
|
-
type: 'changes',
|
|
365
|
-
payload: {
|
|
366
|
-
start: pick(head(change.changes), ['row', 'col']),
|
|
367
|
-
end: pick(last(change.changes), ['row', 'col']),
|
|
368
|
-
lastSelected: {
|
|
369
|
-
start: start,
|
|
370
|
-
end: end
|
|
371
|
-
},
|
|
372
|
-
history: changeHistory
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
};
|