@zhenliang/sheet 0.1.92-beta.0 → 0.1.92-beta.5
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/dist/core/editor/numberEditor/index.js +25 -7
- package/dist/core/editor/numberEditor/index.less +9 -4
- package/dist/core/reducers/keyboardReducer.js +10 -7
- package/dist/core/sheet/Cell.js +2 -1
- package/dist/core/table/useRowSelection.d.ts +1 -1
- package/dist/type/sheet.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,16 +8,24 @@ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("
|
|
|
8
8
|
import { formatPrecision } from "../../../standardUtils";
|
|
9
9
|
import { InputNumber as AntInputNumber, Input } from 'antd';
|
|
10
10
|
import 'antd/es/input-number/style/index.css';
|
|
11
|
-
import { isNil } from 'lodash';
|
|
11
|
+
import { head, isNil } from 'lodash';
|
|
12
12
|
import { evaluate } from 'mathjs';
|
|
13
13
|
import { useCallback, useEffect, useRef } from 'react';
|
|
14
14
|
import "./index.less";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
var formulaString = function formulaString(value, currentValue, precision, max, min, isEdit) {
|
|
17
17
|
var curNumber = currentValue !== null && currentValue !== void 0 ? currentValue : 0;
|
|
18
|
-
var
|
|
18
|
+
var headStr = head(String(value).trim());
|
|
19
|
+
var formula = String(value).replace('=', '');
|
|
20
|
+
var hasAdjacent = /\d+[xX]|[xX]+\d+/g.test(formula);
|
|
19
21
|
try {
|
|
20
|
-
|
|
22
|
+
if (isNaN(value) && headStr !== '=' || hasAdjacent) {
|
|
23
|
+
throw false;
|
|
24
|
+
}
|
|
25
|
+
var result = evaluate(formula, {
|
|
26
|
+
x: curNumber,
|
|
27
|
+
X: curNumber
|
|
28
|
+
});
|
|
21
29
|
if (max && result > max) {
|
|
22
30
|
result = max;
|
|
23
31
|
} else if (min && result < min) {
|
|
@@ -64,7 +72,8 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
64
72
|
var NumberEditor = function NumberEditor(props) {
|
|
65
73
|
var _ref3;
|
|
66
74
|
var value = props.value,
|
|
67
|
-
onChange = props.onChange
|
|
75
|
+
onChange = props.onChange,
|
|
76
|
+
isEditing = props.isEditing;
|
|
68
77
|
var inputNumberRef = useRef(null);
|
|
69
78
|
var _ref2 = getExtraProps ? getExtraProps(props) : extraProps !== null && extraProps !== void 0 ? extraProps : {},
|
|
70
79
|
inputArgs = Object.assign({}, (_objectDestructuringEmpty(_ref2), _ref2));
|
|
@@ -72,9 +81,17 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
72
81
|
onChange(!isNil(value) ? value : null);
|
|
73
82
|
}, [onChange]);
|
|
74
83
|
useEffect(function () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
if (isEditing) {
|
|
85
|
+
var _inputNumberRef$curre2;
|
|
86
|
+
inputNumberRef === null || inputNumberRef === void 0 || (_inputNumberRef$curre2 = inputNumberRef.current) === null || _inputNumberRef$curre2 === void 0 || _inputNumberRef$curre2.focus();
|
|
87
|
+
}
|
|
88
|
+
}, [isEditing]);
|
|
89
|
+
var reFocus = useCallback(function () {
|
|
90
|
+
if (isEditing) {
|
|
91
|
+
var _inputNumberRef$curre3;
|
|
92
|
+
inputNumberRef === null || inputNumberRef === void 0 || (_inputNumberRef$curre3 = inputNumberRef.current) === null || _inputNumberRef$curre3 === void 0 || _inputNumberRef$curre3.focus();
|
|
93
|
+
}
|
|
94
|
+
}, [isEditing]);
|
|
78
95
|
return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
|
|
79
96
|
ref: inputNumberRef
|
|
80
97
|
}, inputArgs), {}, {
|
|
@@ -82,6 +99,7 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
82
99
|
onMouseDown: function onMouseDown(e) {
|
|
83
100
|
return e.stopPropagation();
|
|
84
101
|
},
|
|
102
|
+
onBlur: reFocus,
|
|
85
103
|
value: (_ref3 = value) !== null && _ref3 !== void 0 ? _ref3 : '',
|
|
86
104
|
onChange: function onChange(e) {
|
|
87
105
|
handleChange(e.target.value);
|
|
@@ -9,20 +9,25 @@
|
|
|
9
9
|
text-align: inherit !important;
|
|
10
10
|
padding-left: 0;
|
|
11
11
|
|
|
12
|
-
.ant-input-
|
|
12
|
+
.ant-input-wrapper {
|
|
13
13
|
text-align: inherit !important;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.ant-input
|
|
16
|
+
.ant-input {
|
|
17
17
|
text-align: inherit !important;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.ant-input-
|
|
20
|
+
.ant-input-wrapper > input {
|
|
21
21
|
padding: 0;
|
|
22
22
|
height: 38px;
|
|
23
|
+
border: none;
|
|
24
|
+
outline: none;
|
|
25
|
+
box-shadow: none;
|
|
26
|
+
background: transparent;
|
|
27
|
+
font-size: 12px;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
.ant-input-
|
|
30
|
+
.ant-input-group-addon {
|
|
26
31
|
background: transparent;
|
|
27
32
|
border: none;
|
|
28
33
|
padding: 0;
|
|
@@ -30,8 +30,17 @@ export var keyboardReducer = {
|
|
|
30
30
|
minCol++;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
+
var lastEditing = state.lastEditing;
|
|
34
|
+
if (state.editing) {
|
|
35
|
+
lastEditing = _objectSpread(_objectSpread({}, state.editing), {}, {
|
|
36
|
+
confirm: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
33
39
|
if (newRow > maxRow || newRow < 0 || newCol > maxCol || newCol < minCol) {
|
|
34
|
-
return state
|
|
40
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
|
+
editing: undefined,
|
|
42
|
+
lastEditing: lastEditing
|
|
43
|
+
});
|
|
35
44
|
}
|
|
36
45
|
// 跟随滚动
|
|
37
46
|
if (optCol !== 0) {
|
|
@@ -56,12 +65,6 @@ export var keyboardReducer = {
|
|
|
56
65
|
row: newRow,
|
|
57
66
|
col: newCol
|
|
58
67
|
};
|
|
59
|
-
var lastEditing = state.lastEditing;
|
|
60
|
-
if (state.editing) {
|
|
61
|
-
lastEditing = _objectSpread(_objectSpread({}, state.editing), {}, {
|
|
62
|
-
confirm: true
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
68
|
var isOut = isNil(currentPos.row);
|
|
66
69
|
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
67
70
|
start: isOut ? undefined : currentPos,
|
package/dist/core/sheet/Cell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SheetTableType } from "../..";
|
|
2
2
|
export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: SheetTableType.TableRowSelection, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
|
|
3
|
-
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "
|
|
3
|
+
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "dataSource" | "rowKey" | "showRemark" | "rowSelection"> & {
|
|
4
4
|
checked: boolean[];
|
|
5
5
|
}) => any[][];
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export type CellEditorProps = {
|
|
|
51
51
|
cell?: Cell;
|
|
52
52
|
onChange: (value: unknown) => void;
|
|
53
53
|
onConfirm: (value: unknown) => void;
|
|
54
|
+
isEditing?: boolean;
|
|
54
55
|
} & CellViewerProps;
|
|
55
56
|
export type CellEditor = React.FC<CellEditorProps> & {
|
|
56
57
|
checker?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => boolean;
|