@lemon-fe/components 1.5.2 → 1.5.3-alpha.0

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,7 +17,7 @@ declare const Editors: {
17
17
  Text: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").TextEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
18
18
  Date: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").DateEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
19
19
  Number: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").NumberEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
20
- Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "showSearch" | "virtual" | "optionFilterProp" | "options" | "listHeight"> & {
20
+ Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -74,17 +74,39 @@ function toNumber(a) {
74
74
  }
75
75
  return a;
76
76
  }
77
+
78
+ /**
79
+ * 用于四则运算的数值转换:(基本按原逻辑)
80
+ * - 字符串以 % 结尾(如 "50%" / "1,234.5%")→ 转为 BigNumber 后除以 100(0.5 / 12.345)
81
+ * - 普通数字字符串 → 去千分位后返回
82
+ * - 非法/NaN 格式 → 保持原值,避免污染整个表达式
83
+ * - 表达式字面量中不允许出现 %(中间的 % 视为取余运算符)
84
+ */
85
+ function toMathNumber(a) {
86
+ if (typeof a === 'string') {
87
+ var normalized = a.replace(/,/g, '');
88
+ if (fieldSuffix.test(normalized)) {
89
+ var bn = new BigNumber(normalized.replace(fieldSuffix, ''));
90
+ if (bn.isNaN() || !bn.isFinite()) {
91
+ return a;
92
+ }
93
+ return bn.div(100);
94
+ }
95
+ return normalized;
96
+ }
97
+ return a;
98
+ }
77
99
  var add = function add(a, b) {
78
- return new BigNumber(toNumber(a)).plus(toNumber(b));
100
+ return new BigNumber(a).plus(b);
79
101
  };
80
102
  var subtract = function subtract(a, b) {
81
- return new BigNumber(toNumber(a)).minus(toNumber(b));
103
+ return new BigNumber(a).minus(b);
82
104
  };
83
105
  var multiply = function multiply(a, b) {
84
- return new BigNumber(toNumber(a)).times(toNumber(b));
106
+ return new BigNumber(a).times(b);
85
107
  };
86
108
  var divide = function divide(a, b) {
87
- return new BigNumber(toNumber(a)).div(toNumber(b));
109
+ return new BigNumber(a).div(b);
88
110
  };
89
111
  var defaultColDef = {
90
112
  resizable: true,
@@ -1293,7 +1315,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1293
1315
  var _getValue;
1294
1316
  var _ref7 = _slicedToArray(_ref6, 1),
1295
1317
  k = _ref7[0];
1296
- return [k, (_getValue = getValue(scopeMap[k])) !== null && _getValue !== void 0 ? _getValue : ''];
1318
+ return [k, toMathNumber((_getValue = getValue(scopeMap[k])) !== null && _getValue !== void 0 ? _getValue : '')];
1297
1319
  }));
1298
1320
  return code.evaluate(scope);
1299
1321
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.5.2",
3
+ "version": "1.5.3-alpha.0",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://registry.npmjs.org"
60
60
  },
61
- "gitHead": "f1d68fc8b34f14b697a46df4c0d2bad9bc698426"
61
+ "gitHead": "6b53eb5ef11d7b1920b9d35120123d889430d069"
62
62
  }