@lemon-fe/kits 1.0.3 → 1.0.4-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.
|
@@ -153,7 +153,7 @@ export default function FieldModal(props) {
|
|
|
153
153
|
}, [openProp]);
|
|
154
154
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
155
155
|
title: "",
|
|
156
|
-
width:
|
|
156
|
+
width: 600,
|
|
157
157
|
open: open,
|
|
158
158
|
onCancel: function onCancel() {
|
|
159
159
|
setOpen(false);
|
|
@@ -214,6 +214,8 @@ export default function FieldModal(props) {
|
|
|
214
214
|
}]
|
|
215
215
|
}, /*#__PURE__*/React.createElement(Input.TextArea, {
|
|
216
216
|
ref: ref,
|
|
217
|
+
maxLength: 300,
|
|
218
|
+
showCount: true,
|
|
217
219
|
style: {
|
|
218
220
|
height: 120
|
|
219
221
|
}
|
|
@@ -246,7 +248,9 @@ export default function FieldModal(props) {
|
|
|
246
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
247
249
|
className: prefix('column-panel-modal-field'),
|
|
248
250
|
key: item.id
|
|
249
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
251
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
252
|
+
title: item.title
|
|
253
|
+
}, item.title), /*#__PURE__*/React.createElement("div", {
|
|
250
254
|
className: prefix('column-panel-modal-field-add'),
|
|
251
255
|
onClick: function onClick() {
|
|
252
256
|
handleAddExp(item);
|
|
@@ -52,7 +52,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
52
52
|
Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
53
53
|
Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
54
54
|
Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
55
|
-
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "
|
|
55
|
+
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "allowClear" | "options" | "virtual" | "showSearch" | "listHeight"> & {
|
|
56
56
|
fieldNames?: {
|
|
57
57
|
label: string;
|
|
58
58
|
value: string;
|
|
@@ -72,7 +72,7 @@ import Scheme from 'async-validator';
|
|
|
72
72
|
import BigNumber from 'bignumber.js';
|
|
73
73
|
import classNames from 'classnames';
|
|
74
74
|
import { get, set } from 'lodash';
|
|
75
|
-
import { create, parseDependencies, factory } from 'mathjs';
|
|
75
|
+
import { create, parseDependencies, factory, evaluateDependencies } from 'mathjs';
|
|
76
76
|
import memoizeOne from 'memoize-one';
|
|
77
77
|
import React, { Component, createRef } from 'react';
|
|
78
78
|
import shallowEqual from 'shallowequal';
|
|
@@ -125,6 +125,7 @@ var divide = function divide(a, b) {
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
var _create = create({
|
|
128
|
+
evaluateDependencies: evaluateDependencies,
|
|
128
129
|
parseDependencies: parseDependencies,
|
|
129
130
|
createAdd: factory('add', [], function () {
|
|
130
131
|
return add;
|
|
@@ -139,6 +140,7 @@ var _create = create({
|
|
|
139
140
|
return divide;
|
|
140
141
|
})
|
|
141
142
|
}),
|
|
143
|
+
evaluate = _create.evaluate,
|
|
142
144
|
parse = _create.parse;
|
|
143
145
|
|
|
144
146
|
ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule, InfiniteRowModelModule, ClipboardModule, MenuModule, SideBarModule, ColumnsToolPanelModule, MasterDetailModule], false);
|
|
@@ -1203,17 +1205,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1203
1205
|
};
|
|
1204
1206
|
|
|
1205
1207
|
var result = map(columns);
|
|
1206
|
-
var
|
|
1208
|
+
var suppressFieldValueGetter = !!((_this$props$customCol = this.props.customColumnPanelStorage) !== null && _this$props$customCol !== void 0 && _this$props$customCol.suppressFieldValueGetter);
|
|
1207
1209
|
this.fields.forEach(function (field) {
|
|
1208
|
-
var expression = field.expression.replace(/\$\{([^{}]+)\}/g, function (match, p1) {
|
|
1209
|
-
if (p1) {
|
|
1210
|
-
return p1;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
return match;
|
|
1214
|
-
});
|
|
1215
1210
|
leafColIds.push(field.id);
|
|
1216
|
-
var code = parse(expression).compile();
|
|
1217
1211
|
var fieldCol = {
|
|
1218
1212
|
colId: field.id,
|
|
1219
1213
|
headerName: field.name,
|
|
@@ -1222,9 +1216,36 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1222
1216
|
type: 'rightAligned'
|
|
1223
1217
|
};
|
|
1224
1218
|
|
|
1225
|
-
if (
|
|
1219
|
+
if (suppressFieldValueGetter) {
|
|
1226
1220
|
fieldCol.field = field.id;
|
|
1227
1221
|
} else {
|
|
1222
|
+
/**
|
|
1223
|
+
* 预校验是否可以进行四则运算,可能会有边界情况没考虑到
|
|
1224
|
+
*/
|
|
1225
|
+
var scopeMap = {};
|
|
1226
|
+
var reg = /\$\{([^{}]+)\}/g;
|
|
1227
|
+
var expression = field.expression.replace(reg, function (match, p1) {
|
|
1228
|
+
if (p1) {
|
|
1229
|
+
var mapKey = "a".concat(Object.keys(scopeMap).length);
|
|
1230
|
+
scopeMap[mapKey] = p1;
|
|
1231
|
+
return mapKey;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
return match;
|
|
1235
|
+
});
|
|
1236
|
+
var code = null;
|
|
1237
|
+
|
|
1238
|
+
try {
|
|
1239
|
+
var mCode = parse(expression).compile();
|
|
1240
|
+
mCode.evaluate(Object.fromEntries(Object.entries(scopeMap).map(function (_ref3) {
|
|
1241
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
1242
|
+
k = _ref4[0];
|
|
1243
|
+
|
|
1244
|
+
return [k, 1];
|
|
1245
|
+
})));
|
|
1246
|
+
code = mCode;
|
|
1247
|
+
} catch (_unused) {}
|
|
1248
|
+
|
|
1228
1249
|
fieldCol.valueGetter = function (params) {
|
|
1229
1250
|
var api = params.api,
|
|
1230
1251
|
node = params.node,
|
|
@@ -1239,48 +1260,51 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1239
1260
|
return get(summary, field.id);
|
|
1240
1261
|
}
|
|
1241
1262
|
|
|
1242
|
-
var
|
|
1243
|
-
|
|
1244
|
-
var col = columnApi.getColumn(key);
|
|
1263
|
+
var getValue = function getValue(colId) {
|
|
1264
|
+
var col = columnApi.getColumn(colId);
|
|
1245
1265
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1266
|
+
if (col === null) {
|
|
1267
|
+
return null;
|
|
1268
|
+
}
|
|
1249
1269
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1270
|
+
var colDef = col.getColDef();
|
|
1271
|
+
var value = api.getValue(colId, node);
|
|
1252
1272
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1273
|
+
if (typeof colDef.valueFormatter === 'function') {
|
|
1274
|
+
value = colDef.valueFormatter(_objectSpread(_objectSpread({}, params), {}, {
|
|
1275
|
+
value: value
|
|
1276
|
+
}));
|
|
1277
|
+
}
|
|
1258
1278
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
set: function set() {},
|
|
1262
|
-
has: function has(key) {
|
|
1263
|
-
return columnApi.getColumn(key) !== null;
|
|
1264
|
-
},
|
|
1265
|
-
keys: function keys() {
|
|
1266
|
-
var currentColumns = columnApi.getColumns();
|
|
1267
|
-
|
|
1268
|
-
if (currentColumns === null) {
|
|
1269
|
-
return [];
|
|
1270
|
-
}
|
|
1279
|
+
return value;
|
|
1280
|
+
};
|
|
1271
1281
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1282
|
+
if (code) {
|
|
1283
|
+
try {
|
|
1284
|
+
return code.evaluate({
|
|
1285
|
+
get: function get(p1) {
|
|
1286
|
+
return getValue(scopeMap[p1]);
|
|
1287
|
+
},
|
|
1288
|
+
set: function set() {},
|
|
1289
|
+
has: function has(key) {
|
|
1290
|
+
return columnApi.getColumn(scopeMap[key]) !== null;
|
|
1291
|
+
},
|
|
1292
|
+
keys: function keys() {
|
|
1293
|
+
return Object.keys(scopeMap);
|
|
1294
|
+
}
|
|
1275
1295
|
});
|
|
1296
|
+
} catch (err) {
|
|
1297
|
+
// console.warn('DataGrid field evaluate', err);
|
|
1298
|
+
return null;
|
|
1276
1299
|
}
|
|
1277
|
-
}
|
|
1300
|
+
} else {
|
|
1301
|
+
return field.expression.replace(reg, function (match, p1) {
|
|
1302
|
+
if (p1) {
|
|
1303
|
+
return getValue(p1) || '';
|
|
1304
|
+
}
|
|
1278
1305
|
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
console.warn('DataGrid field evaluate', err);
|
|
1283
|
-
return null;
|
|
1306
|
+
return match;
|
|
1307
|
+
});
|
|
1284
1308
|
}
|
|
1285
1309
|
}
|
|
1286
1310
|
|
|
@@ -1614,8 +1638,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1614
1638
|
_this10.store.setState({
|
|
1615
1639
|
errors: errors
|
|
1616
1640
|
});
|
|
1617
|
-
}).catch(function (
|
|
1618
|
-
var fields =
|
|
1641
|
+
}).catch(function (_ref5) {
|
|
1642
|
+
var fields = _ref5.fields;
|
|
1619
1643
|
var errors = new Map(_this10.store.getState().errors);
|
|
1620
1644
|
var error = new Map();
|
|
1621
1645
|
Object.entries(fields).forEach(function (item) {
|
|
@@ -1656,8 +1680,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1656
1680
|
if (_this11.validator === null) {
|
|
1657
1681
|
promises.push(Promise.resolve(true));
|
|
1658
1682
|
} else {
|
|
1659
|
-
promises.push(_this11.validator.validate(record).catch(function (
|
|
1660
|
-
var fields =
|
|
1683
|
+
promises.push(_this11.validator.validate(record).catch(function (_ref6) {
|
|
1684
|
+
var fields = _ref6.fields;
|
|
1661
1685
|
return Promise.reject({
|
|
1662
1686
|
id: rowId,
|
|
1663
1687
|
fields: fields
|
|
@@ -1675,14 +1699,14 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1675
1699
|
failed = [];
|
|
1676
1700
|
result.forEach(function (item) {
|
|
1677
1701
|
if (item.status === 'rejected') {
|
|
1678
|
-
var
|
|
1679
|
-
id =
|
|
1680
|
-
fields =
|
|
1702
|
+
var _ref7 = item.reason,
|
|
1703
|
+
id = _ref7.id,
|
|
1704
|
+
fields = _ref7.fields;
|
|
1681
1705
|
var error = new Map();
|
|
1682
|
-
Object.entries(fields).forEach(function (
|
|
1683
|
-
var
|
|
1684
|
-
field =
|
|
1685
|
-
errs =
|
|
1706
|
+
Object.entries(fields).forEach(function (_ref8) {
|
|
1707
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
1708
|
+
field = _ref9[0],
|
|
1709
|
+
errs = _ref9[1];
|
|
1686
1710
|
|
|
1687
1711
|
error.set(field, errs.map(function (err) {
|
|
1688
1712
|
return err.message || "".concat(field, "\u8F93\u5165\u9519\u8BEF");
|
|
@@ -1922,8 +1946,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1922
1946
|
}
|
|
1923
1947
|
}], [{
|
|
1924
1948
|
key: "isSummaryRow",
|
|
1925
|
-
value: function isSummaryRow(
|
|
1926
|
-
var node =
|
|
1949
|
+
value: function isSummaryRow(_ref10) {
|
|
1950
|
+
var node = _ref10.node;
|
|
1927
1951
|
|
|
1928
1952
|
if (node && node.data && node.data[DataGrid.SummaryFlag]) {
|
|
1929
1953
|
return true;
|