@lemon-fe/components 1.4.28-alpha.3 → 1.4.28

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.
@@ -118,7 +118,7 @@ export default function FieldModal(props) {
118
118
  summaryType: 1,
119
119
  decimalPlaces: 2,
120
120
  groupId: undefined,
121
- dataFormatType: 'number'
121
+ dataFormatType: supportSelectDataFormat ? 'number' : undefined
122
122
  });
123
123
  }
124
124
  } else {
@@ -128,7 +128,7 @@ export default function FieldModal(props) {
128
128
  expression: formatExpression(openProp.expression),
129
129
  decimalPlaces: (_openProp$decimalPlac = openProp.decimalPlaces) !== null && _openProp$decimalPlac !== void 0 ? _openProp$decimalPlac : 2,
130
130
  groupId: openProp.groupId,
131
- dataFormatType: (_openProp$dataFormatT = openProp.dataFormatType) !== null && _openProp$dataFormatT !== void 0 ? _openProp$dataFormatT : 'number'
131
+ dataFormatType: supportSelectDataFormat ? (_openProp$dataFormatT = openProp.dataFormatType) !== null && _openProp$dataFormatT !== void 0 ? _openProp$dataFormatT : 'number' : undefined
132
132
  }));
133
133
  }
134
134
  } else {
@@ -224,7 +224,12 @@ export default function CustomColumnPanel(params) {
224
224
  save = _useRequest.run,
225
225
  loading = _useRequest.loading;
226
226
  useEffect(function () {
227
+ var mounted = true;
227
228
  var handler = function handler(e) {
229
+ // 出现了组件卸载后事件还是触发的问题,应该是ag-grid内部时机的问题;
230
+ if (!mounted) {
231
+ return;
232
+ }
228
233
  if ((e.type === 'columnMoved' || e.type === 'columnResized') && !e.finished) {
229
234
  return;
230
235
  }
@@ -240,6 +245,7 @@ export default function CustomColumnPanel(params) {
240
245
  api.addEventListener('columnValueChanged', handler);
241
246
  api.addEventListener('newColumnsLoaded', handler);
242
247
  return function () {
248
+ mounted = false;
243
249
  api.removeEventListener('columnVisible', handler);
244
250
  api.removeEventListener('columnMoved', handler);
245
251
  api.removeEventListener('columnPinned', handler);
@@ -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" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "virtual" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -780,6 +780,17 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
780
780
  this.dataSource = [];
781
781
  this.api.setRowData([]);
782
782
  this.api.setColumnDefs([]);
783
+ this.api.destroy();
784
+ var context = this.api.__getContext();
785
+ var gridOptionsService = context.getBean('gridOptionsService');
786
+ for (var field in gridOptionsService.gridOptions) {
787
+ delete gridOptionsService.gridOptions[field];
788
+ }
789
+ var userComponentFactory = context.getBean('userComponentFactory');
790
+ userComponentFactory.frameworkComponentWrapper.parent = null;
791
+ var eventService = context.getBean('eventService');
792
+ eventService.allAsyncListeners.clear();
793
+ eventService.globalAsyncListeners.clear();
783
794
  this.api = new GridApi();
784
795
  this.columnApi = new ColumnApi();
785
796
  }
@@ -1306,15 +1317,23 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1306
1317
  }
1307
1318
  if (params.value !== undefined && params.value !== null) {
1308
1319
  var val = params.value;
1309
- if (typeof val === 'number' || BigNumber.isBigNumber(val)) {
1310
- if (field.dataFormatType === 'percentage' && expressionSuffix !== '%') {
1320
+ if (field.dataFormatType === 'percentage' && expressionSuffix !== '%') {
1321
+ var bn = new BigNumber(toNumber(val));
1322
+ if (!bn.isNaN() && bn.isFinite()) {
1311
1323
  var _field$decimalPlaces;
1312
- val = new BigNumber(val).multipliedBy(100).toFixed((_field$decimalPlaces = field.decimalPlaces) !== null && _field$decimalPlaces !== void 0 ? _field$decimalPlaces : 2);
1324
+ val = bn.multipliedBy(100).toFixed((_field$decimalPlaces = field.decimalPlaces) !== null && _field$decimalPlaces !== void 0 ? _field$decimalPlaces : 2);
1313
1325
  return "".concat(val, "%").concat(expressionSuffix);
1314
- } else {
1326
+ }
1327
+ } else if (field.dataFormatType === 'number') {
1328
+ var _bn = new BigNumber(toNumber(val));
1329
+ if (!_bn.isNaN() && _bn.isFinite()) {
1315
1330
  var _field$decimalPlaces2;
1316
- val = new BigNumber(val).toFixed((_field$decimalPlaces2 = field.decimalPlaces) !== null && _field$decimalPlaces2 !== void 0 ? _field$decimalPlaces2 : 2);
1331
+ val = _bn.toFixed((_field$decimalPlaces2 = field.decimalPlaces) !== null && _field$decimalPlaces2 !== void 0 ? _field$decimalPlaces2 : 2);
1317
1332
  }
1333
+ } else if (typeof val === 'number' || BigNumber.isBigNumber(val)) {
1334
+ var _field$decimalPlaces3;
1335
+ //调整未加任何配置时保持原逻辑
1336
+ val = new BigNumber(val).toFixed((_field$decimalPlaces3 = field.decimalPlaces) !== null && _field$decimalPlaces3 !== void 0 ? _field$decimalPlaces3 : 2);
1318
1337
  }
1319
1338
  return "".concat(val).concat(expressionSuffix);
1320
1339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.28-alpha.3",
3
+ "version": "1.4.28",
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": "fc120ab90b363e45be5b8b4445b21e84ab2e79b2"
61
+ "gitHead": "8569d6f611b682d2b0213d7ada70f43b23ad7933"
62
62
  }