@zhenliang/sheet 0.1.25 → 0.1.27

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.
@@ -14,6 +14,10 @@ import { isNil } from 'lodash';
14
14
  import { useCallback, useEffect, useRef } from 'react';
15
15
  import "./index.less";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
+ var isNumeric = function isNumeric(str) {
18
+ // 使用正则表达式匹配数字,包括整数和小数
19
+ return /^-?\d+(\.\d+)?$/.test(str);
20
+ };
17
21
  export var NumberEditor = function NumberEditor(props) {
18
22
  var value = props.value,
19
23
  onChange = props.onChange;
@@ -50,15 +54,19 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
50
54
  if (!value) {
51
55
  return '';
52
56
  }
53
- if (typeof value === 'string') {
57
+ if (!isNumeric("".concat(value))) {
54
58
  return value;
55
59
  }
56
- var hasDecimal = value - Math.floor(value) > 0;
60
+ var hasDecimal = +value - Math.floor(+value) > 0;
57
61
  if (hasDecimal) {
58
62
  return formatPrecision(value, precision);
59
63
  }
60
64
  return String(value);
61
65
  }, []);
66
+ /**
67
+ * 重新声明,后面有需求可以改一下
68
+ */
69
+ var valueParser = valueFormatter;
62
70
  var handleChange = useCallback(function (value) {
63
71
  onChange && onChange(value ? value : null);
64
72
  }, [onChange]);
@@ -66,6 +74,7 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
66
74
  ref: inputNumberRef
67
75
  }, inputArgs), {}, {
68
76
  formatter: valueFormatter,
77
+ parser: valueParser,
69
78
  controls: false,
70
79
  className: "number-editor",
71
80
  onMouseDown: function onMouseDown(e) {
@@ -176,6 +176,6 @@ var Cell = function Cell(props) {
176
176
  });
177
177
  };
178
178
  export default /*#__PURE__*/memo(Cell, function (pre, next) {
179
- var shouldUpdate = pre.col === next.col && pre.row === next.row && pre.cell.value === next.cell.value && pre.cell.dataEditor === next.cell.dataEditor && pre.cell.record === next.cell.record;
179
+ var shouldUpdate = pre.col === next.col && pre.row === next.row && pre.cell.value === next.cell.value && pre.cell.dataEditor === next.cell.dataEditor && pre.cell.className === next.cell.className && pre.cell.record === next.cell.record;
180
180
  return shouldUpdate;
181
181
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",