@lemon-fe/kits 1.0.6 → 1.0.8

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.
@@ -1232,7 +1232,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1232
1232
  })));
1233
1233
  code = mCode;
1234
1234
  } catch (err) {
1235
- console.log('pre check mathmatic expression failed');
1235
+ console.log('pre check mathmatic expression failed:', err.message);
1236
1236
  }
1237
1237
 
1238
1238
  fieldCol.valueGetter = function (params) {
@@ -1273,10 +1273,12 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1273
1273
  if (code) {
1274
1274
  try {
1275
1275
  var scope = Object.fromEntries(Object.entries(scopeMap).map(function (_ref5) {
1276
+ var _getValue;
1277
+
1276
1278
  var _ref6 = _slicedToArray(_ref5, 1),
1277
1279
  k = _ref6[0];
1278
1280
 
1279
- return [k, getValue(scopeMap[k]) || ''];
1281
+ return [k, (_getValue = getValue(scopeMap[k])) !== null && _getValue !== void 0 ? _getValue : ''];
1280
1282
  }));
1281
1283
  return code.evaluate(scope);
1282
1284
  } catch (err) {
@@ -1298,7 +1300,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1298
1300
  };
1299
1301
 
1300
1302
  fieldCol.valueFormatter = function (params) {
1301
- if (Number.isNaN(params.value) || BigNumber.isBigNumber(params.value) && params.value.isNaN()) {
1303
+ if (Number.isNaN(params.value) || !Number.isFinite(params.value) || BigNumber.isBigNumber(params.value) && (params.value.isNaN() || !params.value.isFinite())) {
1302
1304
  return '-';
1303
1305
  }
1304
1306
 
@@ -1629,8 +1631,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1629
1631
  _this9.store.setState({
1630
1632
  errors: errors
1631
1633
  });
1632
- }).catch(function (_ref7) {
1633
- var fields = _ref7.fields;
1634
+ }).catch(function (res) {
1635
+ var fields = res.fields;
1634
1636
  var errors = new Map(_this9.store.getState().errors);
1635
1637
  var error = new Map();
1636
1638
  Object.entries(fields).forEach(function (item) {
@@ -1657,7 +1659,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1657
1659
  switch (_context4.prev = _context4.next) {
1658
1660
  case 0:
1659
1661
  promises = [];
1660
- this.api.forEachNode(function (rowNode) {
1662
+ this.api.forEachNode(function (rowNode, idx) {
1661
1663
  var record = rowNode.data;
1662
1664
 
1663
1665
  if (record === undefined) {
@@ -1671,11 +1673,14 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1671
1673
  if (_this10.validator === null) {
1672
1674
  promises.push(Promise.resolve(true));
1673
1675
  } else {
1674
- promises.push(_this10.validator.validate(record).catch(function (_ref8) {
1675
- var fields = _ref8.fields;
1676
+ promises.push(_this10.validator.validate(record).catch(function (_ref7) {
1677
+ var fields = _ref7.fields;
1676
1678
  return Promise.reject({
1677
1679
  id: rowId,
1678
- fields: fields
1680
+ data: record,
1681
+ fields: fields,
1682
+ node: rowNode,
1683
+ index: idx
1679
1684
  });
1680
1685
  }));
1681
1686
  }
@@ -1690,14 +1695,14 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1690
1695
  failed = [];
1691
1696
  result.forEach(function (item) {
1692
1697
  if (item.status === 'rejected') {
1693
- var _ref9 = item.reason,
1694
- id = _ref9.id,
1695
- fields = _ref9.fields;
1698
+ var _ref8 = item.reason,
1699
+ id = _ref8.id,
1700
+ fields = _ref8.fields;
1696
1701
  var error = new Map();
1697
- Object.entries(fields).forEach(function (_ref10) {
1698
- var _ref11 = _slicedToArray(_ref10, 2),
1699
- field = _ref11[0],
1700
- errs = _ref11[1];
1702
+ Object.entries(fields).forEach(function (_ref9) {
1703
+ var _ref10 = _slicedToArray(_ref9, 2),
1704
+ field = _ref10[0],
1705
+ errs = _ref10[1];
1701
1706
 
1702
1707
  error.set(field, errs.map(function (err) {
1703
1708
  return err.message || "".concat(field, "\u8F93\u5165\u9519\u8BEF");
@@ -1937,8 +1942,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1937
1942
  }
1938
1943
  }], [{
1939
1944
  key: "isSummaryRow",
1940
- value: function isSummaryRow(_ref12) {
1941
- var node = _ref12.node;
1945
+ value: function isSummaryRow(_ref11) {
1946
+ var node = _ref11.node;
1942
1947
 
1943
1948
  if (node && node.data && node.data[DataGrid.SummaryFlag]) {
1944
1949
  return true;
@@ -1,6 +1,6 @@
1
- import type { ColDef, ColGroupDef, EditableCallbackParams, ICellEditorParams, ICellRendererParams, IHeaderParams, AgGridEvent, CheckboxSelectionCallback, ColumnState } from '@ag-grid-community/core';
1
+ import type { ColDef, ColGroupDef, EditableCallbackParams, ICellEditorParams, ICellRendererParams, IHeaderParams, AgGridEvent, CheckboxSelectionCallback, ColumnState, IRowNode } from '@ag-grid-community/core';
2
2
  import type { AgGridReactProps } from '@ag-grid-community/react';
3
- import type { RuleItem } from 'async-validator/dist-types/interface';
3
+ import type { RuleItem, ValidateFieldsError } from 'async-validator/dist-types/interface';
4
4
  import type { ReactElement, ReactNode } from 'react';
5
5
  import type { DateEditorParams } from './cell-editors/Date';
6
6
  import type { NumberEditorParams } from './cell-editors/Number';
@@ -20,6 +20,13 @@ export declare type PathType = string;
20
20
  export declare type ValidateRule<T> = Pick<RuleItem, 'required' | 'message' | 'pattern' | 'min' | 'max' | 'len' | 'type'> & {
21
21
  validator?: (rule: any, val: any, record: T) => void | Promise<void>;
22
22
  };
23
+ export declare type ValidateResult<TData> = {
24
+ id: string;
25
+ node: IRowNode<TData>;
26
+ data: TData;
27
+ index: number;
28
+ fields: ValidateFieldsError;
29
+ }[];
23
30
  interface EditorParamsType<T extends string, K extends Record<string, any>> {
24
31
  type: T;
25
32
  params?: K;
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  declare const PageLoading: React.FC<{
3
3
  tip?: string;
4
+ style?: CSSProperties;
4
5
  }>;
5
6
  export default PageLoading;
@@ -1,11 +1,13 @@
1
- import React from 'react';
2
1
  import { Spin } from 'antd';
2
+ import React from 'react';
3
3
  import { PREFIX_CLS } from "../../constants";
4
4
 
5
5
  var PageLoading = function PageLoading(_ref) {
6
- var tip = _ref.tip;
6
+ var tip = _ref.tip,
7
+ style = _ref.style;
7
8
  return /*#__PURE__*/React.createElement("div", {
8
- className: "".concat(PREFIX_CLS, "-page-loading")
9
+ className: "".concat(PREFIX_CLS, "-page-loading"),
10
+ style: style
9
11
  }, /*#__PURE__*/React.createElement(Spin, {
10
12
  size: "large",
11
13
  tip: tip
@@ -36,7 +36,8 @@ function MicroLayout(props) {
36
36
  routes = _props$routes === void 0 ? [] : _props$routes,
37
37
  authorities = props.authorities,
38
38
  tabs = props.tabs,
39
- active = props.active;
39
+ active = props.active,
40
+ basenameProp = props.basename;
40
41
  var history = useHistory();
41
42
  var auth = useMemo(function () {
42
43
  if (authorities === undefined || authorities === null) {
@@ -46,7 +47,7 @@ function MicroLayout(props) {
46
47
  return new Set(authorities);
47
48
  }, [authorities]);
48
49
  var basename = useMemo(function () {
49
- return window.routerBase;
50
+ return basenameProp || window.routerBase;
50
51
  }, []);
51
52
  var key = (_tabs$active = tabs[active]) === null || _tabs$active === void 0 ? void 0 : _tabs$active.rootPath;
52
53
  var routeTabs = useMemo(function () {
@@ -25,4 +25,8 @@ export interface MicroLayoutProps {
25
25
  * @description 当前active tab
26
26
  */
27
27
  active: number;
28
+ /**
29
+ * @description 路由的basename
30
+ */
31
+ basename?: string;
28
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",