@lemon-fe/components 1.1.1 → 1.1.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.d.ts +1 -0
- package/es/data-grid/index.js +14 -4
- package/es/select-view/index.d.ts +15 -1
- package/es/select-view/index.js +7 -3
- package/package.json +2 -2
package/es/data-grid/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
19
19
|
private searchRef;
|
|
20
20
|
private prevFocusedCell;
|
|
21
21
|
private fields;
|
|
22
|
+
private fieldSuffix;
|
|
22
23
|
static contextType?: React.Context<any> | undefined;
|
|
23
24
|
static defaultProps: Partial<DataGridProps<any>>;
|
|
24
25
|
static SummaryFlag: symbol;
|
package/es/data-grid/index.js
CHANGED
|
@@ -150,6 +150,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
150
150
|
_defineProperty(_assertThisInitialized(_this), "searchRef", /*#__PURE__*/createRef());
|
|
151
151
|
_defineProperty(_assertThisInitialized(_this), "prevFocusedCell", null);
|
|
152
152
|
_defineProperty(_assertThisInitialized(_this), "fields", []);
|
|
153
|
+
_defineProperty(_assertThisInitialized(_this), "fieldSuffix", /(%)$/);
|
|
153
154
|
_defineProperty(_assertThisInitialized(_this), "getFieldsSummary", memoizeOne(function (dataSource, fields) {
|
|
154
155
|
var summaryField = fields.filter(function (field) {
|
|
155
156
|
return field.summary;
|
|
@@ -188,7 +189,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
188
189
|
if (summary[field.id] === undefined) {
|
|
189
190
|
summary[field.id] = new BigNumber(0);
|
|
190
191
|
}
|
|
191
|
-
summary[field.id] = summary[field.id].plus(value);
|
|
192
|
+
summary[field.id] = summary[field.id].plus(typeof value === 'string' ? value.replace(_this.fieldSuffix, '') : value);
|
|
192
193
|
});
|
|
193
194
|
});
|
|
194
195
|
return summary;
|
|
@@ -991,12 +992,14 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
991
992
|
if (suppressFieldValueGetter) {
|
|
992
993
|
fieldCol.field = field.id;
|
|
993
994
|
} else {
|
|
995
|
+
var _this5$fieldSuffix$ex;
|
|
994
996
|
/**
|
|
995
997
|
* 预校验是否可以进行四则运算,可能会有边界情况没考虑到
|
|
996
998
|
*/
|
|
997
999
|
var scopeMap = {};
|
|
998
1000
|
var reg = /\$\{([^{}]+)\}/g;
|
|
999
|
-
var
|
|
1001
|
+
var expressionSuffix = ((_this5$fieldSuffix$ex = _this5.fieldSuffix.exec(field.expression)) === null || _this5$fieldSuffix$ex === void 0 ? void 0 : _this5$fieldSuffix$ex[1]) || '';
|
|
1002
|
+
var expression = field.expression.replace(_this5.fieldSuffix, '').replace(reg, function (match, p1) {
|
|
1000
1003
|
if (p1) {
|
|
1001
1004
|
var mapKey = "a".concat(Object.keys(scopeMap).length);
|
|
1002
1005
|
scopeMap[mapKey] = p1;
|
|
@@ -1066,7 +1069,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1066
1069
|
return null;
|
|
1067
1070
|
}
|
|
1068
1071
|
} else {
|
|
1069
|
-
return field.expression.replace(reg, function (match, p1) {
|
|
1072
|
+
return field.expression.replace(_this5.fieldSuffix, '').replace(reg, function (match, p1) {
|
|
1070
1073
|
if (p1) {
|
|
1071
1074
|
return getValue(p1) || '';
|
|
1072
1075
|
}
|
|
@@ -1077,9 +1080,16 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1077
1080
|
return null;
|
|
1078
1081
|
};
|
|
1079
1082
|
fieldCol.valueFormatter = function (params) {
|
|
1080
|
-
if (
|
|
1083
|
+
if (typeof params.value === 'number' && (Number.isNaN(params.value) || !Number.isFinite(params.value)) || BigNumber.isBigNumber(params.value) && (params.value.isNaN() || !params.value.isFinite())) {
|
|
1081
1084
|
return '-';
|
|
1082
1085
|
}
|
|
1086
|
+
if (params.value !== undefined && params.value !== null) {
|
|
1087
|
+
var val = params.value;
|
|
1088
|
+
if (typeof val === 'number' || BigNumber.isBigNumber(val)) {
|
|
1089
|
+
val = new BigNumber(val).dp(2);
|
|
1090
|
+
}
|
|
1091
|
+
return "".concat(val).concat(expressionSuffix);
|
|
1092
|
+
}
|
|
1083
1093
|
return params.value;
|
|
1084
1094
|
};
|
|
1085
1095
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties, ReactElement } from 'react';
|
|
2
|
-
import type { ColType, DataGridProps, PaginationType, SortType } from '../data-grid/typings';
|
|
2
|
+
import type { ColType, CustomColumnData, DataGridProps, PaginationType, SortType } from '../data-grid/typings';
|
|
3
3
|
import type { FilterProps } from '../filter/typings';
|
|
4
|
+
import type { SideBarDef } from '@ag-grid-community/core';
|
|
4
5
|
interface Props<RecordType, ParamsType extends Record<string, any>> extends Pick<DataGridProps<RecordType>, 'defaultColDef' | 'rowHeight' | 'cellDisplayFlex' | 'isRowSelectable'> {
|
|
5
6
|
value?: RecordType[];
|
|
6
7
|
onChange?: (value: RecordType[], rowDoubleClicked?: boolean) => void;
|
|
@@ -58,6 +59,19 @@ interface Props<RecordType, ParamsType extends Record<string, any>> extends Pick
|
|
|
58
59
|
checkSearchParams?: (params: ParamsType) => boolean;
|
|
59
60
|
loading?: boolean;
|
|
60
61
|
readOnly?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* @description 表格控制栏 Specifies the side bar components.
|
|
64
|
+
*/
|
|
65
|
+
sideBar?: SideBarDef | string | string[] | boolean | null;
|
|
66
|
+
/**
|
|
67
|
+
* @description 自定义列保存
|
|
68
|
+
* suppressFieldValueGetter 自定义列是否计算
|
|
69
|
+
*/
|
|
70
|
+
customColumnPanelStorage?: {
|
|
71
|
+
suppressFieldValueGetter?: boolean;
|
|
72
|
+
set: (data: CustomColumnData) => Promise<void> | void;
|
|
73
|
+
get: () => Promise<CustomColumnData | null | undefined> | CustomColumnData | null | undefined;
|
|
74
|
+
};
|
|
61
75
|
}
|
|
62
76
|
export default function SelectView<RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: Props<RecordType, ParamsType>): JSX.Element;
|
|
63
77
|
export {};
|
package/es/select-view/index.js
CHANGED
|
@@ -15,11 +15,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
15
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
16
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
import { Spin, Tabs } from 'antd';
|
|
18
19
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
19
20
|
import DataGrid from "../data-grid";
|
|
20
21
|
import Filter from "../filter";
|
|
21
22
|
import { prefixClassName } from "../utils";
|
|
22
|
-
import { Spin, Tabs } from 'antd';
|
|
23
23
|
import { get } from 'lodash';
|
|
24
24
|
export default function SelectView(props) {
|
|
25
25
|
var emptyValue = useMemo(function () {
|
|
@@ -45,7 +45,9 @@ export default function SelectView(props) {
|
|
|
45
45
|
rowHeight = props.rowHeight,
|
|
46
46
|
cellDisplayFlex = props.cellDisplayFlex,
|
|
47
47
|
isRowSelectable = props.isRowSelectable,
|
|
48
|
-
checkSearchParams = props.checkSearchParams
|
|
48
|
+
checkSearchParams = props.checkSearchParams,
|
|
49
|
+
sideBar = props.sideBar,
|
|
50
|
+
customColumnPanelStorage = props.customColumnPanelStorage;
|
|
49
51
|
var prefix = prefixClassName("select-view");
|
|
50
52
|
var _useState = useState(value || emptyValue),
|
|
51
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -200,6 +202,7 @@ export default function SelectView(props) {
|
|
|
200
202
|
handleChangeData([node.id], [node.data], true);
|
|
201
203
|
}
|
|
202
204
|
},
|
|
205
|
+
sideBar: sideBar,
|
|
203
206
|
rowHeight: rowHeight,
|
|
204
207
|
defaultColDef: defaultColDef,
|
|
205
208
|
cellDisplayFlex: cellDisplayFlex,
|
|
@@ -208,7 +211,8 @@ export default function SelectView(props) {
|
|
|
208
211
|
columns: columns,
|
|
209
212
|
onLoading: setLoading,
|
|
210
213
|
fetch: request,
|
|
211
|
-
pagination: pagination
|
|
214
|
+
pagination: pagination,
|
|
215
|
+
customColumnPanelStorage: customColumnPanelStorage
|
|
212
216
|
}))));
|
|
213
217
|
};
|
|
214
218
|
var renderSelected = function renderSelected() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"registry": "https://registry.npmjs.org"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "53c287f2fc2ebd1251b38ac587eab8f648f73c85"
|
|
66
66
|
}
|