@zhenliang/sheet 0.0.1

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/core/config.js +13 -0
  4. package/dist/core/editor/cascaderEditor/index.js +63 -0
  5. package/dist/core/editor/cascaderEditor/index.less +24 -0
  6. package/dist/core/editor/dateEditor/index.js +42 -0
  7. package/dist/core/editor/dateEditor/index.less +7 -0
  8. package/dist/core/editor/numberEditor/index.js +25 -0
  9. package/dist/core/editor/numberEditor/index.less +17 -0
  10. package/dist/core/editor/selectEditor/index.js +44 -0
  11. package/dist/core/editor/selectEditor/index.less +41 -0
  12. package/dist/core/reducers/index.js +36 -0
  13. package/dist/core/reducers/keyboardReducer.js +91 -0
  14. package/dist/core/reducers/mouseReducer.js +151 -0
  15. package/dist/core/reducers/sideEffectReducer.js +324 -0
  16. package/dist/core/reducers/stateReducer.js +140 -0
  17. package/dist/core/sheet/Cell.js +160 -0
  18. package/dist/core/sheet/DataEditor.js +21 -0
  19. package/dist/core/sheet/DefaultCell.js +31 -0
  20. package/dist/core/sheet/DefaultRow.js +25 -0
  21. package/dist/core/sheet/DefaultRowMapper.js +15 -0
  22. package/dist/core/sheet/DefaultShell.js +12 -0
  23. package/dist/core/sheet/Event.js +17 -0
  24. package/dist/core/sheet/ValueViewer.js +9 -0
  25. package/dist/core/sheet/index.js +201 -0
  26. package/dist/core/sheet/index.less +261 -0
  27. package/dist/core/sheet/useCellEvent.js +22 -0
  28. package/dist/core/sheet/useContextMenu.js +86 -0
  29. package/dist/core/sheet/useKeyBoardEvent.js +44 -0
  30. package/dist/core/sheet/useMouseEvent.js +298 -0
  31. package/dist/core/sheet/useVirtualList.js +74 -0
  32. package/dist/core/sheet/var.less +41 -0
  33. package/dist/core/shell/draggableShell/index.js +182 -0
  34. package/dist/core/shell/draggableShell/index.less +16 -0
  35. package/dist/core/shell/resizeShell.js +57 -0
  36. package/dist/core/shell/tableShell.js +105 -0
  37. package/dist/core/table/index.js +311 -0
  38. package/dist/core/table/useGroupConfig.js +32 -0
  39. package/dist/core/table/useRowSelection.js +24 -0
  40. package/dist/core/table/util.js +29 -0
  41. package/dist/core/util.js +363 -0
  42. package/dist/core/viewer/checkViewer/index.js +23 -0
  43. package/dist/core/viewer/groupViewer/index.js +28 -0
  44. package/dist/example/basic.js +120 -0
  45. package/dist/example/draggable.js +0 -0
  46. package/dist/example/ellipsis.js +63 -0
  47. package/dist/example/fixed.js +88 -0
  48. package/dist/example/group.js +84 -0
  49. package/dist/example/index.less +5 -0
  50. package/dist/example/selection.js +85 -0
  51. package/dist/example/sheet.js +356 -0
  52. package/dist/hooks/index.js +6 -0
  53. package/dist/hooks/useEventBus.js +17 -0
  54. package/dist/hooks/useKeyboard.js +108 -0
  55. package/dist/hooks/useMiddlewareReducer.js +47 -0
  56. package/dist/hooks/useMouse.js +52 -0
  57. package/dist/hooks/useSetState.js +27 -0
  58. package/dist/hooks/useSheetEvent.js +5 -0
  59. package/dist/index.js +3 -0
  60. package/dist/standardUtils/index.js +32 -0
  61. package/dist/typings/index.d.ts +1 -0
  62. package/dist/typings/sheet.d.ts +209 -0
  63. package/dist/typings/table.js +0 -0
  64. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) fizz.zhou@ap.jll.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # zsheet
2
+
3
+ zsheet is a excel-like table component write in react
@@ -0,0 +1,13 @@
1
+ export var TAB_KEY = 9;
2
+ export var ENTER_KEY = 13;
3
+ export var ESCAPE_KEY = 27;
4
+ export var LEFT_KEY = 37;
5
+ export var UP_KEY = 38;
6
+ export var RIGHT_KEY = 39;
7
+ export var DOWN_KEY = 40;
8
+ export var DELETE_KEY = 46;
9
+ export var BACKSPACE_KEY = 8;
10
+ export var Z_KEY = 90;
11
+ export var C_KEY = 67;
12
+ export var V_KEY = 86;
13
+ export var X_KEY = 88;
@@ -0,0 +1,63 @@
1
+ import { Cascader } from 'antd';
2
+ import 'antd/es/cascader/style/index.css';
3
+ import { useMemo } from 'react';
4
+ import { optionsTransferToValue } from "../../util";
5
+ import "./index.less";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ var options = [{
8
+ value: 'zhejiang',
9
+ label: 'Zhejiang',
10
+ children: [{
11
+ value: 'hangzhou',
12
+ label: 'Hangzhou',
13
+ children: [{
14
+ value: 'West Lake',
15
+ label: 'West Lake'
16
+ }]
17
+ }]
18
+ }, {
19
+ value: 'jiangsu',
20
+ label: 'Jiangsu',
21
+ children: [{
22
+ value: 'nanjing',
23
+ label: 'Nanjing',
24
+ children: [{
25
+ value: 'Zhong Hua Men',
26
+ label: 'Zhong Hua Men'
27
+ }]
28
+ }]
29
+ }];
30
+ export var CascaderEditor = function CascaderEditor(props) {
31
+ var value = props.value,
32
+ onConfirm = props.onConfirm;
33
+ var val = useMemo(function () {
34
+ return optionsTransferToValue(options, value);
35
+ }, [value, options]);
36
+ var handleChange = function handleChange(opt) {
37
+ console.log(opt);
38
+ onConfirm(opt ? opt[opt.length - 1] : null);
39
+ };
40
+ return /*#__PURE__*/_jsx(Cascader, {
41
+ autoFocus: true,
42
+ open: true,
43
+ className: 'cascader-editor',
44
+ onMouseDown: function onMouseDown(event) {
45
+ event.stopPropagation();
46
+ },
47
+ value: val
48
+ // allowClear={false}
49
+ ,
50
+ displayRender: function displayRender(label) {
51
+ return label[label.length - 1];
52
+ },
53
+ onChange: handleChange
54
+ // onBlur={handleBlur}
55
+ // onKeyDown={handleKeyDown}
56
+ ,
57
+ options: options
58
+ });
59
+ };
60
+ CascaderEditor.checker = function (value) {
61
+ var res = optionsTransferToValue(options, value);
62
+ return res && res.length > 0;
63
+ };
@@ -0,0 +1,24 @@
1
+ .cascader-editor{
2
+ width: 100%;
3
+ padding: 0;
4
+ height: 20px !important;
5
+
6
+
7
+ .ant-select-selector{
8
+ .ant-select-selection-search{
9
+ height: 16px !important;
10
+ }
11
+
12
+ border: none !important;
13
+ background: transparent !important;
14
+ box-shadow: none !important;
15
+ color: #292c33;
16
+ height: 20px !important;
17
+ padding:0 !important;
18
+
19
+ input{
20
+ height: 18px !important;
21
+ }
22
+ }
23
+
24
+ }
@@ -0,0 +1,42 @@
1
+ import { DatePicker } from 'antd';
2
+ import 'antd/es/date-picker/style/index.css';
3
+ import moment from 'moment';
4
+ import { useEffect, useMemo, useRef } from 'react';
5
+ import "./index.less";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export var DateEditor = function DateEditor(props) {
8
+ var value = props.value,
9
+ onChange = props.onChange,
10
+ onConfirm = props.onConfirm;
11
+ var dateRef = useRef(null);
12
+ useEffect(function () {
13
+ var _dateRef$current;
14
+ dateRef === null || dateRef === void 0 ? void 0 : (_dateRef$current = dateRef.current) === null || _dateRef$current === void 0 ? void 0 : _dateRef$current.focus();
15
+ }, []);
16
+ var val = useMemo(function () {
17
+ return value && moment(value);
18
+ }, [value]);
19
+ var handleChange = function handleChange(value) {
20
+ onChange(value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD'));
21
+ onConfirm(value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD'));
22
+ };
23
+ return /*#__PURE__*/_jsx(DatePicker, {
24
+ open: true,
25
+ ref: dateRef,
26
+ className: "date-editor",
27
+ value: val,
28
+ onMouseDown: function onMouseDown(e) {
29
+ return e.stopPropagation();
30
+ },
31
+ onChange: handleChange
32
+ });
33
+ };
34
+ DateEditor.checker = function (value) {
35
+ var reg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;
36
+ return reg.test(value);
37
+ };
38
+ DateEditor.formatter = function (value) {
39
+ var _DateEditor$checker;
40
+ if (!(DateEditor !== null && DateEditor !== void 0 && (_DateEditor$checker = DateEditor.checker) !== null && _DateEditor$checker !== void 0 && _DateEditor$checker.call(DateEditor, value))) return null;
41
+ return value.replace('/', '-').replace('/', '-');
42
+ };
@@ -0,0 +1,7 @@
1
+ .date-editor{
2
+ width:100%;
3
+ border:none !important;
4
+ box-shadow: none !important;
5
+ background: transparent !important;
6
+ height: 20px;
7
+ }
@@ -0,0 +1,25 @@
1
+ import { InputNumber as AntInputNumber } from 'antd';
2
+ import 'antd/es/input-number/style/index.css';
3
+ import { useEffect, useRef } from 'react';
4
+ import "./index.less";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export var NumberEditor = function NumberEditor(props) {
7
+ var value = props.value,
8
+ onChange = props.onChange;
9
+ var inputNumberRef = useRef(null);
10
+ useEffect(function () {
11
+ var _inputNumberRef$curre;
12
+ inputNumberRef === null || inputNumberRef === void 0 ? void 0 : (_inputNumberRef$curre = inputNumberRef.current) === null || _inputNumberRef$curre === void 0 ? void 0 : _inputNumberRef$curre.focus();
13
+ }, []);
14
+ return /*#__PURE__*/_jsx(AntInputNumber, {
15
+ ref: inputNumberRef,
16
+ controls: false,
17
+ className: "number-editor",
18
+ onMouseDown: function onMouseDown(e) {
19
+ return e.stopPropagation();
20
+ },
21
+ value: value,
22
+ addonAfter: "%",
23
+ onChange: onChange
24
+ });
25
+ };
@@ -0,0 +1,17 @@
1
+ .number-editor{
2
+ border: none !important;
3
+ background: transparent !important;
4
+ width:100%;
5
+ height: 38px;
6
+ box-shadow: none !important;
7
+
8
+ .ant-input-number-input-wrap >input{
9
+ padding:0;
10
+ height: 38px;
11
+ }
12
+
13
+ .ant-input-number-group-addon{
14
+ background: transparent;
15
+ border: none;
16
+ }
17
+ }
@@ -0,0 +1,44 @@
1
+ import { Select } from 'antd';
2
+ import 'antd/es/select/style/index.css';
3
+ import "./index.less";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export var GetSelectEditor = function GetSelectEditor(options) {
6
+ var SelectEditor = function SelectEditor(props) {
7
+ var value = props.value,
8
+ onConfirm = props.onConfirm;
9
+ var handleChange = function handleChange(opt) {
10
+ var updateValue = opt === undefined ? null : opt;
11
+ onConfirm(updateValue);
12
+ };
13
+ var handleKeyDown = function handleKeyDown(ev) {
14
+ // record last key pressed so we can handle enter
15
+ if (ev.which === 13 || ev.which === 9) {
16
+ ev.persist();
17
+ }
18
+ };
19
+ return /*#__PURE__*/_jsx(Select, {
20
+ autoFocus: true,
21
+ className: "select-editor",
22
+ defaultOpen: true,
23
+ allowClear: true,
24
+ open: true,
25
+ onMouseDown: function onMouseDown(e) {
26
+ e.stopPropagation();
27
+ },
28
+ value: value,
29
+ onChange: handleChange,
30
+ onKeyDown: handleKeyDown,
31
+ options: options,
32
+ popupClassName: 'excelTablePopupClassName'
33
+ });
34
+ };
35
+ SelectEditor.checker = function (value) {
36
+ return options.some(function (item) {
37
+ return item.value === value;
38
+ }) || options.some(function (item) {
39
+ return item.label === value;
40
+ });
41
+ };
42
+ return SelectEditor;
43
+ };
44
+ export default GetSelectEditor;
@@ -0,0 +1,41 @@
1
+ .select-editor,.ant-select-selector {
2
+ // select style
3
+ width: 100%;
4
+ line-height: 20px;
5
+ height: 20px;
6
+
7
+ .ant-select-selector {
8
+ border: none !important;
9
+ background: transparent !important;
10
+ box-shadow: none !important;
11
+ color: #292c33;
12
+ height: 20px !important;
13
+ padding:0 !important;
14
+ }
15
+
16
+ .ant-select-selection-item {
17
+ color: #292c33;
18
+ font-size: 12px;
19
+ line-height: unset !important;
20
+ }
21
+
22
+ .ant-select-arrow {
23
+ right: 0;
24
+ }
25
+
26
+ .ant-select-clear {
27
+ right: 0;
28
+ box-shadow: inset 0 -100px 0 rgba(33,133,208,15%);
29
+ }
30
+
31
+ .ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
32
+ padding: 0;
33
+ }
34
+
35
+ .ant-select-focused:not(.ant-select-disabled).ant-select:not(.ant-select-customize-input) .ant-select-selector {
36
+ box-shadow: inset 0 -100px 0 rgba(33,133,208,15%);
37
+ }
38
+
39
+
40
+
41
+ }
@@ -0,0 +1,36 @@
1
+ import { keyboardReducer } from "./keyboardReducer";
2
+ import { mouseReducer } from "./mouseReducer";
3
+ import { stateReducer } from "./stateReducer";
4
+ var sheetReducer = function sheetReducer(state, action) {
5
+ switch (action.type) {
6
+ case 'change':
7
+ case 'changes':
8
+ case 'rowMove':
9
+ case 'colMove':
10
+ case 'editFinish':
11
+ case 'pushHistory':
12
+ case 'selectRow':
13
+ case 'clearSelect':
14
+ case 'clearSelectIfNotSingleRow':
15
+ case 'clearEdit':
16
+ return stateReducer[action.type](state, action.payload);
17
+ case 'mouseDown':
18
+ case 'mouseOver':
19
+ case 'mouseUp':
20
+ case 'loseFocus':
21
+ case 'doubleClick':
22
+ case 'mouseLeaveInterval':
23
+ return mouseReducer[action.type](state, action.payload);
24
+ case 'move':
25
+ case 'escape':
26
+ case 'reverse':
27
+ case 'delete':
28
+ case 'enter':
29
+ case 'otherInput':
30
+ return keyboardReducer[action.type](state, action.payload);
31
+ default:
32
+ throw new Error('Unexpected action');
33
+ }
34
+ };
35
+ export default sheetReducer;
36
+ export { sideEffectReducer } from "./sideEffectReducer";
@@ -0,0 +1,91 @@
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));
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 start = state.start,
69
+ end = state.end,
70
+ editing = state.editing;
71
+ if (!start || !end) {
72
+ return state;
73
+ }
74
+ if (!editing) {
75
+ return _objectSpread(_objectSpread({}, state), {}, {
76
+ end: start,
77
+ editing: _objectSpread(_objectSpread({}, start), {}, {
78
+ value: payload
79
+ })
80
+ });
81
+ }
82
+ return keyboardReducer.move(state, {
83
+ row: 1,
84
+ col: 0
85
+ });
86
+ },
87
+ otherInput: function otherInput(state, payload) {
88
+ if (state.editing) return state;
89
+ return keyboardReducer.enter(state, payload);
90
+ }
91
+ };
@@ -0,0 +1,151 @@
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
+ if (data !== null && data !== void 0 && data[row][col].fixed) {
16
+ return _objectSpread({}, state);
17
+ }
18
+ if (shiftKey) {
19
+ return _objectSpread(_objectSpread({}, state), {}, {
20
+ mouseDown: true,
21
+ editing: undefined,
22
+ lastEditing: state.editing,
23
+ start: state.start ? state.start : {
24
+ row: row,
25
+ col: col
26
+ },
27
+ end: {
28
+ row: row,
29
+ col: col
30
+ },
31
+ lastSelected: {
32
+ start: state.start,
33
+ end: state.end
34
+ }
35
+ });
36
+ }
37
+ return _objectSpread(_objectSpread({}, state), {}, {
38
+ mouseDown: true,
39
+ editing: undefined,
40
+ lastEditing: state.editing,
41
+ start: {
42
+ row: row,
43
+ col: col
44
+ },
45
+ end: {
46
+ row: row,
47
+ col: col
48
+ },
49
+ lastSelected: {
50
+ start: state.start,
51
+ end: state.end
52
+ }
53
+ });
54
+ },
55
+ mouseOver: function mouseOver(state, payload) {
56
+ var _ref2 = payload,
57
+ row = _ref2.row,
58
+ col = _ref2.col;
59
+ var data = state.data;
60
+ if (state.mouseDown === false || data !== null && data !== void 0 && data[row][col].readonly) return state;
61
+ return _objectSpread(_objectSpread({}, state), {}, {
62
+ end: {
63
+ row: row,
64
+ col: col
65
+ },
66
+ lastSelected: {
67
+ start: state.start,
68
+ end: state.end
69
+ }
70
+ });
71
+ },
72
+ mouseUp: function mouseUp(state, payload) {
73
+ var _ref3 = payload,
74
+ row = _ref3.row,
75
+ col = _ref3.col;
76
+ var data = state.data;
77
+ if (state.mouseDown === false || data !== null && data !== void 0 && data[row][col].fixed) return state;
78
+ return _objectSpread(_objectSpread({}, state), {}, {
79
+ mouseDown: false,
80
+ end: {
81
+ row: row,
82
+ col: col
83
+ },
84
+ lastSelected: {
85
+ start: state.start,
86
+ end: state.end
87
+ }
88
+ });
89
+ },
90
+ loseFocus: function loseFocus(state) {
91
+ var lastEditing = state.lastEditing;
92
+ if (state.editing) {
93
+ lastEditing = _objectSpread(_objectSpread({}, state.editing), {}, {
94
+ confirm: true
95
+ });
96
+ }
97
+ return _objectSpread(_objectSpread({}, state), {}, {
98
+ start: undefined,
99
+ end: undefined,
100
+ editing: undefined,
101
+ lastEditing: lastEditing,
102
+ lastSelected: {
103
+ start: state.start,
104
+ end: state.end
105
+ }
106
+ });
107
+ },
108
+ doubleClick: function doubleClick(state, payload) {
109
+ var _data$row$col;
110
+ var _ref4 = payload,
111
+ row = _ref4.row,
112
+ col = _ref4.col;
113
+ var data = state.data;
114
+ if (data !== null && data !== void 0 && (_data$row$col = data[row][col]) !== null && _data$row$col !== void 0 && _data$row$col.readonly) {
115
+ return state;
116
+ }
117
+ return _objectSpread(_objectSpread({}, state), {}, {
118
+ mouseDown: false,
119
+ editing: {
120
+ row: row,
121
+ col: col
122
+ },
123
+ start: {
124
+ row: row,
125
+ col: col
126
+ },
127
+ end: {
128
+ row: row,
129
+ col: col
130
+ },
131
+ lastSelected: {
132
+ start: state.start,
133
+ end: state.end
134
+ },
135
+ lastEditing: state.editing
136
+ });
137
+ },
138
+ mouseLeaveInterval: function mouseLeaveInterval(state, payload) {
139
+ var _data$, _data$$end$col;
140
+ var _ref5 = payload,
141
+ end = _ref5.end;
142
+ var data = state.data;
143
+ // fixed 列不选中
144
+ 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) {
145
+ return state;
146
+ }
147
+ return _objectSpread(_objectSpread({}, state), {}, {
148
+ end: end
149
+ });
150
+ }
151
+ };