@zhenliang/sheet 0.1.92-beta.4 → 0.1.92-beta.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.
@@ -17,8 +17,9 @@ var formulaString = function formulaString(value, currentValue, precision, max,
17
17
  var curNumber = currentValue !== null && currentValue !== void 0 ? currentValue : 0;
18
18
  var headStr = head(String(value).trim());
19
19
  var formula = String(value).replace('=', '');
20
+ var hasAdjacent = /\d+[xX]|[xX]+\d+/g.test(formula);
20
21
  try {
21
- if (isNaN(value) && headStr !== '=') {
22
+ if (isNaN(value) && headStr !== '=' || hasAdjacent) {
22
23
  throw false;
23
24
  }
24
25
  var result = evaluate(formula, {
@@ -82,7 +83,6 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
82
83
  useEffect(function () {
83
84
  if (isEditing) {
84
85
  var _inputNumberRef$curre2;
85
- console.log('isEditing', isEditing);
86
86
  inputNumberRef === null || inputNumberRef === void 0 || (_inputNumberRef$curre2 = inputNumberRef.current) === null || _inputNumberRef$curre2 === void 0 || _inputNumberRef$curre2.focus();
87
87
  }
88
88
  }, [isEditing]);
@@ -123,7 +123,7 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
123
123
  return result;
124
124
  };
125
125
  // 粘贴上去的时候触发
126
- NumberEditor.parser = function (value, currentValue) {
126
+ NumberEditor.parser = function (value, record, currentValue) {
127
127
  var _String2;
128
128
  var result = (_String2 = String(value)) === null || _String2 === void 0 ? void 0 : _String2.replace(/,/g, '');
129
129
  result = formulaString(result, currentValue);
@@ -263,7 +263,7 @@ export var sideEffectReducer = {
263
263
  row: row,
264
264
  col: col,
265
265
  id: (_data$row$col2 = data[row][col]) === null || _data$row$col2 === void 0 ? void 0 : _data$row$col2.id,
266
- value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value, data[row][col].value) : value
266
+ value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value, data[row][col].record, data[row][col].value) : value
267
267
  };
268
268
  });
269
269
  lastRow = extChanges === null || extChanges === void 0 || (_extChanges$ = extChanges[0]) === null || _extChanges$ === void 0 ? void 0 : _extChanges$.row;
@@ -290,7 +290,7 @@ export var sideEffectReducer = {
290
290
  return {
291
291
  row: row,
292
292
  col: col,
293
- value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser2 = editor.parser) === null || _editor$parser2 === void 0 ? void 0 : _editor$parser2.call(editor, value, data[row][col].value) : value,
293
+ value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser2 = editor.parser) === null || _editor$parser2 === void 0 ? void 0 : _editor$parser2.call(editor, value, data[row][col].record, data[row][col].value) : value,
294
294
  id: -lastIndex
295
295
  };
296
296
  });
@@ -60,7 +60,7 @@ var Cell = function Cell(props) {
60
60
  } else if (eventInfo.value && eventInfo.editing) {
61
61
  var _cell$dataEditor, _cell$dataEditor2, _cell$dataEditor2$par;
62
62
  // 单元格直接键盘编辑,设置为输入值
63
- setValue((_cell$dataEditor = cell.dataEditor) !== null && _cell$dataEditor !== void 0 && _cell$dataEditor.parser ? cell === null || cell === void 0 || (_cell$dataEditor2 = cell.dataEditor) === null || _cell$dataEditor2 === void 0 || (_cell$dataEditor2$par = _cell$dataEditor2.parser) === null || _cell$dataEditor2$par === void 0 ? void 0 : _cell$dataEditor2$par.call(_cell$dataEditor2, eventInfo.value, valueRef.current) : eventInfo.value);
63
+ setValue((_cell$dataEditor = cell.dataEditor) !== null && _cell$dataEditor !== void 0 && _cell$dataEditor.parser ? cell === null || cell === void 0 || (_cell$dataEditor2 = cell.dataEditor) === null || _cell$dataEditor2 === void 0 || (_cell$dataEditor2$par = _cell$dataEditor2.parser) === null || _cell$dataEditor2$par === void 0 ? void 0 : _cell$dataEditor2$par.call(_cell$dataEditor2, eventInfo.value, cell.record, valueRef.current) : eventInfo.value);
64
64
  }
65
65
  setEventState(eventInfo);
66
66
  };
@@ -56,7 +56,7 @@ export type CellEditorProps = {
56
56
  export type CellEditor = React.FC<CellEditorProps> & {
57
57
  checker?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => boolean;
58
58
  formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
59
- parser?: (value: unknown, currentValue?: unknown) => unknown;
59
+ parser?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => unknown;
60
60
  formula?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => unknown;
61
61
  };
62
62
  export type CellViewer = React.FC<CellViewerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.92-beta.4",
3
+ "version": "0.1.92-beta.6",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",