@lemon-fe/components 1.4.29 → 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.
- package/es/data-grid/index.js +27 -5
- package/es/select-view/index.d.ts +13 -1
- package/es/select-view/index.js +15 -2
- package/package.json +2 -2
package/es/data-grid/index.js
CHANGED
|
@@ -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(
|
|
100
|
+
return new BigNumber(a).plus(b);
|
|
79
101
|
};
|
|
80
102
|
var subtract = function subtract(a, b) {
|
|
81
|
-
return new BigNumber(
|
|
103
|
+
return new BigNumber(a).minus(b);
|
|
82
104
|
};
|
|
83
105
|
var multiply = function multiply(a, b) {
|
|
84
|
-
return new BigNumber(
|
|
106
|
+
return new BigNumber(a).times(b);
|
|
85
107
|
};
|
|
86
108
|
var divide = function divide(a, b) {
|
|
87
|
-
return new BigNumber(
|
|
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) {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { CSSProperties, ForwardedRef, ReactElement } from 'react';
|
|
2
|
+
import type { CSSProperties, ForwardedRef, ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { type DataGridRef } from '../data-grid';
|
|
4
4
|
import type { ColType, CustomColumnData, DataGridProps, PaginationType, SortType } from '../data-grid/typings';
|
|
5
5
|
import type { FilterProps } from '../filter/typings';
|
|
6
6
|
import type { SideBarDef } from 'ag-grid-community';
|
|
7
|
+
export interface SelectViewBodyOpts<RecordType, ParamsType> {
|
|
8
|
+
loading: boolean;
|
|
9
|
+
setLoading: (loading: boolean) => void;
|
|
10
|
+
params: ParamsType;
|
|
11
|
+
selectedData: RecordType[];
|
|
12
|
+
selectedKeys: string[];
|
|
13
|
+
onSelectChange: (keys: string[] | Set<string>, records: RecordType[], rowDoubleClicked?: boolean) => void;
|
|
14
|
+
}
|
|
7
15
|
export interface SelectViewProps<RecordType, ParamsType> extends Pick<DataGridProps<RecordType>, 'defaultColDef' | 'rowHeight' | 'cellDisplayFlex' | 'isRowSelectable' | 'rowMultiSelectWithClick' | 'suppressRowClickSelection'> {
|
|
8
16
|
value?: RecordType[];
|
|
9
17
|
onChange?: (value: RecordType[], rowDoubleClicked?: boolean) => void;
|
|
@@ -89,6 +97,10 @@ export interface SelectViewProps<RecordType, ParamsType> extends Pick<DataGridPr
|
|
|
89
97
|
* @description 自定义主datagrid
|
|
90
98
|
*/
|
|
91
99
|
customDataGridProps?: DataGridProps<RecordType>;
|
|
100
|
+
/**
|
|
101
|
+
* @description 自定义body区域,支持函数形式获取组件内部状态
|
|
102
|
+
*/
|
|
103
|
+
body?: ReactElement | ((opts: SelectViewBodyOpts<RecordType, ParamsType>) => ReactNode);
|
|
92
104
|
}
|
|
93
105
|
declare function SelectView<RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(originalProps: SelectViewProps<RecordType, ParamsType>, ref?: ForwardedRef<DataGridRef<RecordType>>): JSX.Element;
|
|
94
106
|
declare const _default: <RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: SelectViewProps<RecordType, ParamsType> & {
|
package/es/select-view/index.js
CHANGED
|
@@ -61,7 +61,8 @@ function SelectView(originalProps, ref) {
|
|
|
61
61
|
customColumnPanelStorage = props.customColumnPanelStorage,
|
|
62
62
|
_props$suppressRowCli = props.suppressRowClickSelection,
|
|
63
63
|
suppressRowClickSelection = _props$suppressRowCli === void 0 ? false : _props$suppressRowCli,
|
|
64
|
-
rowMultiSelectWithClick = props.rowMultiSelectWithClick
|
|
64
|
+
rowMultiSelectWithClick = props.rowMultiSelectWithClick,
|
|
65
|
+
bodyProp = props.body;
|
|
65
66
|
var prefix = prefixClassName("select-view");
|
|
66
67
|
var _useState = useState(value || emptyValue),
|
|
67
68
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -218,6 +219,18 @@ function SelectView(originalProps, ref) {
|
|
|
218
219
|
ref.current = val;
|
|
219
220
|
}
|
|
220
221
|
};
|
|
222
|
+
var bodyNode = useMemo(function () {
|
|
223
|
+
if (!bodyProp) return null;
|
|
224
|
+
return typeof bodyProp === 'function' ? bodyProp({
|
|
225
|
+
loading: loading,
|
|
226
|
+
setLoading: setLoading,
|
|
227
|
+
params: cParams,
|
|
228
|
+
selectedData: data,
|
|
229
|
+
selectedKeys: dataKeys,
|
|
230
|
+
onSelectChange: handleChangeData
|
|
231
|
+
}) : bodyProp;
|
|
232
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
233
|
+
}, [bodyProp, loading, cParams, data, dataKeys]);
|
|
221
234
|
var renderList = function renderList() {
|
|
222
235
|
return /*#__PURE__*/React.createElement("div", {
|
|
223
236
|
className: prefix('layout')
|
|
@@ -245,7 +258,7 @@ function SelectView(originalProps, ref) {
|
|
|
245
258
|
className: prefix('head')
|
|
246
259
|
}, headerNode), /*#__PURE__*/React.createElement("div", {
|
|
247
260
|
className: prefix('body')
|
|
248
|
-
}, /*#__PURE__*/React.createElement(DataGrid, _extends({
|
|
261
|
+
}, bodyNode ? bodyNode : /*#__PURE__*/React.createElement(DataGrid, _extends({
|
|
249
262
|
ref: function ref(val) {
|
|
250
263
|
if (!readOnly) {
|
|
251
264
|
initRef(val);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.
|
|
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": "
|
|
61
|
+
"gitHead": "6b53eb5ef11d7b1920b9d35120123d889430d069"
|
|
62
62
|
}
|