@easyv/react-components 0.4.4 → 0.4.6
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
-
var _excluded = ["min", "max", "step", "precision", "value", "defaultValue", "prefix", "suffix", "hideControl", "onChange", "onPointMoveStart", "onPointMoveEnd", "onBlur"];
|
|
2
|
+
var _excluded = ["min", "max", "step", "precision", "value", "defaultValue", "prefix", "suffix", "hideControl", "className", "onChange", "onPointMoveStart", "onPointMoveEnd", "onBlur"];
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -34,6 +34,7 @@ var InputNumber = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
34
34
|
prefix = props.prefix,
|
|
35
35
|
suffix = props.suffix,
|
|
36
36
|
hideControl = props.hideControl,
|
|
37
|
+
className = props.className,
|
|
37
38
|
onChange = props.onChange,
|
|
38
39
|
onPointMoveStart = props.onPointMoveStart,
|
|
39
40
|
onPointMoveEnd = props.onPointMoveEnd,
|
|
@@ -150,7 +151,7 @@ var InputNumber = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
150
151
|
return /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
151
152
|
autoSelect: true,
|
|
152
153
|
ref: ref,
|
|
153
|
-
className: "arco-input-number",
|
|
154
|
+
className: classNames("arco-input-number", className),
|
|
154
155
|
onChange: handleChange,
|
|
155
156
|
onBlur: handleBlur,
|
|
156
157
|
value: localValue,
|
package/dist/InputNumber/util.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
export function evaluateExpression(
|
|
1
|
+
export function evaluateExpression(expression) {
|
|
2
|
+
if (typeof expression === 'number') {
|
|
3
|
+
return expression;
|
|
4
|
+
}
|
|
5
|
+
if (typeof expression !== 'string' || !expression.trim()) {
|
|
6
|
+
return NaN;
|
|
7
|
+
}
|
|
8
|
+
var trimmed = expression.trim();
|
|
9
|
+
|
|
10
|
+
// 如果是纯数字字符串,直接返回数值
|
|
11
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
12
|
+
return parseFloat(trimmed);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 检查是否是简单算术表达式(只包含数字、小数点、加减乘除和空格)
|
|
16
|
+
if (!/^[-+*/\d\s.()]+$/.test(trimmed)) {
|
|
17
|
+
return NaN;
|
|
18
|
+
}
|
|
2
19
|
try {
|
|
3
|
-
//
|
|
4
|
-
return +
|
|
20
|
+
// 使用 Function 构造器替代 eval,更安全一些
|
|
21
|
+
var result = new Function('return ' + trimmed)();
|
|
22
|
+
|
|
23
|
+
// 确保结果是数字
|
|
24
|
+
if (typeof result === 'number' && !isNaN(result)) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
return NaN;
|
|
5
28
|
} catch (e) {
|
|
6
29
|
return NaN;
|
|
7
30
|
}
|