@lemon-fe/components 1.4.28-alpha.4 → 1.4.29

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" | "virtual" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -780,6 +780,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
780
780
  this.dataSource = [];
781
781
  this.api.setRowData([]);
782
782
  this.api.setColumnDefs([]);
783
+ this.api.destroy();
783
784
  var context = this.api.__getContext();
784
785
  var gridOptionsService = context.getBean('gridOptionsService');
785
786
  for (var field in gridOptionsService.gridOptions) {
@@ -1316,15 +1317,23 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1316
1317
  }
1317
1318
  if (params.value !== undefined && params.value !== null) {
1318
1319
  var val = params.value;
1319
- if (typeof val === 'number' || BigNumber.isBigNumber(val)) {
1320
- if (field.dataFormatType === 'percentage' && expressionSuffix !== '%') {
1320
+ if (field.dataFormatType === 'percentage' && expressionSuffix !== '%') {
1321
+ var bn = new BigNumber(toNumber(val));
1322
+ if (!bn.isNaN() && bn.isFinite()) {
1321
1323
  var _field$decimalPlaces;
1322
- 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);
1323
1325
  return "".concat(val, "%").concat(expressionSuffix);
1324
- } else {
1326
+ }
1327
+ } else if (field.dataFormatType === 'number') {
1328
+ var _bn = new BigNumber(toNumber(val));
1329
+ if (!_bn.isNaN() && _bn.isFinite()) {
1325
1330
  var _field$decimalPlaces2;
1326
- 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);
1327
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);
1328
1337
  }
1329
1338
  return "".concat(val).concat(expressionSuffix);
1330
1339
  }
@@ -491,7 +491,7 @@ function Filter(originalProps) {
491
491
  var handleTabChange = function handleTabChange(index) {
492
492
  if (index !== active) {
493
493
  setActive(index);
494
- var result = _objectSpread(_objectSpread({}, emptyValue), tabs[index].value);
494
+ var result = _objectSpread(_objectSpread(_objectSpread({}, emptyValue), defaultValue), tabs[index].value);
495
495
  form.setFieldsValue(result);
496
496
  handleFinish(form.getFieldsValue(), 'reset');
497
497
  }
@@ -78,7 +78,9 @@ export interface SelectViewProps<RecordType, ParamsType> extends Pick<DataGridPr
78
78
  * @description 表格顶部header区域自定义
79
79
  * @default null
80
80
  */
81
- header?: ReactElement | null;
81
+ header?: ReactElement | ((opts: {
82
+ filter: ReactElement | null;
83
+ }) => ReactElement) | null;
82
84
  /**
83
85
  * @description 自定义已选择datagrid
84
86
  */
@@ -160,10 +160,9 @@ function SelectView(originalProps, ref) {
160
160
  };
161
161
  var headerNode = null;
162
162
  var siderNode = null;
163
+ var filterNode = null;
163
164
  if (filter && filter.data) {
164
- headerNode = /*#__PURE__*/React.createElement(React.Fragment, null, headerProp && /*#__PURE__*/React.createElement("div", {
165
- className: prefix('head-wrapper')
166
- }, headerProp), /*#__PURE__*/React.createElement(Filter, _extends({
165
+ filterNode = /*#__PURE__*/React.createElement(Filter, _extends({
167
166
  simple: true,
168
167
  autoPlaceholder: true,
169
168
  form: filterForm
@@ -172,9 +171,16 @@ function SelectView(originalProps, ref) {
172
171
  onChange: function onChange(val, actionType) {
173
172
  return handleChangeParams(_objectSpread(_objectSpread({}, cParams), val), actionType);
174
173
  }
175
- })));
176
- } else if (headerProp) {
177
- headerNode = headerProp;
174
+ }));
175
+ }
176
+ if (headerProp && typeof headerProp === 'function') {
177
+ headerNode = headerProp({
178
+ filter: filterNode
179
+ });
180
+ } else if (headerProp || filterNode) {
181
+ headerNode = /*#__PURE__*/React.createElement(React.Fragment, null, headerProp && /*#__PURE__*/React.createElement("div", {
182
+ className: prefix('head-wrapper')
183
+ }, headerProp), filterNode);
178
184
  }
179
185
  if (filter && filter.sider) {
180
186
  siderNode = filter.sider({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.28-alpha.4",
3
+ "version": "1.4.29",
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": "afba47f33e6a25504b0c531e3fff638fa6fa7132"
61
+ "gitHead": "dae2c5d9ba0de9059c879c6148a0e0df01ebe0f1"
62
62
  }