@lemon-fe/components 1.5.2 → 1.5.3

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.
@@ -226,10 +226,13 @@ export default function FieldModal(props) {
226
226
  }),
227
227
  allowClear: true
228
228
  })), /*#__PURE__*/React.createElement(Form.Item, {
229
- label: fieldModal.customColumnExpressionText,
229
+ label: /*#__PURE__*/React.createElement("span", null, fieldModal.customColumnExpressionText, /*#__PURE__*/React.createElement(TipMark, {
230
+ infoContent: fieldModal.customColumnExpressionTextTooltip
231
+ })),
230
232
  name: 'expression',
231
233
  rules: [{
232
- required: true
234
+ required: true,
235
+ message: fieldModal.customColumnExpressionTextRequired
233
236
  }]
234
237
  }, /*#__PURE__*/React.createElement(Input.TextArea, {
235
238
  ref: ref,
@@ -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) {
@@ -30,6 +30,8 @@ var locale = {
30
30
  addCustomColumnText: 'Add Custom Column',
31
31
  customColumnNameText: 'Name',
32
32
  customColumnExpressionText: 'Expression',
33
+ customColumnExpressionTextRequired: 'Please enter the custom column expression',
34
+ customColumnExpressionTextTooltip: 'Custom column formula only supports calculation on numeric columns, and only supports calculation with [four arithmetic operations (addition, subtraction, multiplication, division, parentheses), statistical functions (minimum value min, maximum value max, average value AVERAGE), rounding functions (round up ceil, round down floor, round)].',
33
35
  customColumnExpressionPlaceholder: 'Custom Expression length limit of 300',
34
36
  customColumnDecimalPlacesText: 'Decimal places',
35
37
  customColumnParentHeaderText: 'The corresponding superior header',
@@ -27,6 +27,8 @@ var locale = {
27
27
  addCustomColumnText: 'Tambah kolom kustom',
28
28
  customColumnNameText: 'Nama kolom kustom',
29
29
  customColumnExpressionText: 'Rumus kustom',
30
+ customColumnExpressionTextRequired: 'Silakan masukkan rumus kustom',
31
+ customColumnExpressionTextTooltip: 'Rumus kolom kustom hanya mendukung perhitungan pada kolom numerik, dan hanya mendukung perhitungan dengan [empat operasi aritmetika (tambah, kurang, kali, bagi, tanda kurung), fungsi statistik (nilai minimum min, nilai maksimum max, rata-rata AVERAGE), fungsi pembulatan (pembulatan ke atas ceil, pembulatan ke bawah floor, round)].',
30
32
  customColumnExpressionPlaceholder: 'Panjang maksimum rumus kustom adalah 300',
31
33
  customColumnDecimalPlacesText: 'Jumlah desimal',
32
34
  customColumnParentHeaderText: 'Header tabel tingkat atas yang dimilikinya',
@@ -9,6 +9,8 @@ export interface DataGridLocale {
9
9
  addCustomColumnText: string;
10
10
  customColumnNameText: string;
11
11
  customColumnExpressionText: string;
12
+ customColumnExpressionTextRequired: string;
13
+ customColumnExpressionTextTooltip: string;
12
14
  customColumnExpressionPlaceholder: string;
13
15
  customColumnDecimalPlacesText: string;
14
16
  customColumnParentHeaderText: string;
@@ -27,6 +27,8 @@ var locale = {
27
27
  addCustomColumnText: 'Thêm cột tùy chỉnh',
28
28
  customColumnNameText: 'Tên cột tùy chỉnh',
29
29
  customColumnExpressionText: 'Công thức tùy chỉnh',
30
+ customColumnExpressionTextRequired: 'Vui lòng nhập công thức cột tùy chỉnh',
31
+ customColumnExpressionTextTooltip: 'Công thức cột tùy chỉnh chỉ hỗ trợ tính toán trên các cột dữ liệu số, chỉ hỗ trợ các phép tính [bốn phép toán số học (cộng, trừ, nhân, chia, dấu ngoặc), hàm thống kê (giá trị nhỏ nhất min, giá trị lớn nhất max, giá trị trung bình AVERAGE), hàm làm tròn (làm tròn lên ceil, làm tròn xuống floor, round)]',
30
32
  customColumnExpressionPlaceholder: 'Độ dài tối đa của công thức tùy chỉnh là 300',
31
33
  customColumnDecimalPlacesText: 'Số chữ số thập phân',
32
34
  customColumnParentHeaderText: 'Tiêu đề bảng cấp trên mà nó thuộc về',
@@ -27,6 +27,8 @@ var locale = {
27
27
  addCustomColumnText: '添加自定义列',
28
28
  customColumnNameText: '自定义列名',
29
29
  customColumnExpressionText: '自定义公式',
30
+ customColumnExpressionTextRequired: '请输入自定义公式',
31
+ customColumnExpressionTextTooltip: '自定义列公式仅支持对数值列计算,仅支持【四则运算(加减乘除、括号)、统计函数(最小值min, 最大值max、平均值AVERAGE)、四舍五入函数(向上取整ceil, 向下取整floor, round)】计算',
30
32
  customColumnExpressionPlaceholder: '自定义公式长度上限300',
31
33
  customColumnDecimalPlacesText: '小数位数',
32
34
  customColumnParentHeaderText: '所属上级表头',
@@ -27,6 +27,8 @@ var locale = {
27
27
  addCustomColumnText: '添加自定義列',
28
28
  customColumnNameText: '自定義列名',
29
29
  customColumnExpressionText: '自定義公式',
30
+ customColumnExpressionTextRequired: '請輸入自定義公式',
31
+ customColumnExpressionTextTooltip: '自定義公式僅支持數值列計算,僅支持【四則運算(加減乘除、括號)、統計函數(最小值min, 最大值max、平均值AVERAGE)、四捨五入函數(向上取整ceil, 向下取整floor, round)】計算',
30
32
  customColumnExpressionPlaceholder: '自定義公式長度上限300',
31
33
  customColumnDecimalPlacesText: '小數位數',
32
34
  customColumnParentHeaderText: '所屬上級表頭',
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",
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": "4e63726348818cadaa4544aec696136fabaed9a5"
62
62
  }