@zat-design/sisyphus-react 3.6.11 → 3.7.0-beta.1

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.
@@ -91,6 +91,9 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
91
91
  // 忽略清洗的 codes
92
92
  ignoreCodes = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.ignoreCodes) || [];
93
93
  Object.keys(response).forEach(function (key) {
94
+ if (!response[key] || !Array.isArray(response[key])) {
95
+ return;
96
+ }
94
97
  var options = _toConsumableArray(response[key]) || [];
95
98
  if (ignoreCodes.includes(key)) {
96
99
  response[key] = options;
@@ -74,7 +74,7 @@ export function cacheFieldNames(fieldNames, dataSource) {
74
74
  });
75
75
  // 递归去对数据进行清洗
76
76
  if (children && Array.isArray(dataSource[children])) {
77
- result[children] = dataSource[children].map(function (item) {
77
+ result.children = dataSource[children].map(function (item) {
78
78
  return cacheFieldNames(fieldNames, item);
79
79
  });
80
80
  }
@@ -4,12 +4,14 @@ import "antd/es/space/style";
4
4
  import _Space from "antd/es/space";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- import { useMemo } from 'react';
7
+ import React, { useMemo } from 'react';
8
8
  import { isFunction } from 'lodash';
9
9
  import classNames from 'classnames';
10
10
  import ActionButton from './ActionButton';
11
11
  import RenderFields from '../../../render/RenderFields';
12
12
  import ProCollapse from '../../../../../ProLayout/components/ProCollapse';
13
+ import { memoWith } from '../utils';
14
+ var MemoRenderFields = /*#__PURE__*/React.memo(RenderFields, memoWith);
13
15
  var BlockFields = function BlockFields(props) {
14
16
  var title = props.title,
15
17
  mode = props.mode,
@@ -66,7 +68,7 @@ var BlockFields = function BlockFields(props) {
66
68
  }),
67
69
  children: _jsx(_Row, {
68
70
  gutter: 24,
69
- children: _jsx(RenderFields, {
71
+ children: _jsx(MemoRenderFields, {
70
72
  columns: columns,
71
73
  form: form,
72
74
  colProps: colProps,
@@ -3,12 +3,15 @@ import _Row from "antd/es/row";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ import React from 'react';
6
7
  import classNames from 'classnames';
7
8
  import { useSortable } from '@dnd-kit/sortable';
8
9
  import { CSS } from '@dnd-kit/utilities';
9
10
  import ProIcon from '../../../../../ProIcon';
10
11
  import ActionButton from './ActionButton';
11
12
  import RenderFields from '../../../render/RenderFields';
13
+ import { memoWith } from '../utils';
14
+ var MemoRenderFields = /*#__PURE__*/React.memo(RenderFields, memoWith);
12
15
  var LineFields = function LineFields(props) {
13
16
  var mode = props.mode,
14
17
  index = props.index,
@@ -62,7 +65,7 @@ var LineFields = function LineFields(props) {
62
65
  })
63
66
  })), _jsx(_Row, {
64
67
  gutter: isLess ? 0 : 24,
65
- children: _jsx(RenderFields, {
68
+ children: _jsx(MemoRenderFields, {
66
69
  columns: columns,
67
70
  form: form,
68
71
  colProps: colProps,
@@ -9,3 +9,4 @@ export declare const namesPathTransform: ({ names, prefixNamePath, type, }: {
9
9
  prefixNamePath: any[];
10
10
  type: string;
11
11
  }) => string;
12
+ export declare const memoWith: (pre: any, next: any) => boolean;
@@ -1,3 +1,5 @@
1
+ import { isEqualWith, isFunction } from 'lodash';
2
+ import React from 'react';
1
3
  /**
2
4
  * namesPath生产 [['list', 0, 'min'], ['list', 0, 'max']] => list_0_min-list_0_max
3
5
  * @param names name的集合
@@ -17,4 +19,15 @@ export var namesPathTransform = function namesPathTransform(_ref) {
17
19
  return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
18
20
  return Array.isArray(name) ? name.join('_') : name;
19
21
  }).join('-');
22
+ };
23
+ // 比较memo
24
+ export var memoWith = function memoWith(pre, next) {
25
+ return isEqualWith(pre, next, function (objValue, othValue) {
26
+ if ( /*#__PURE__*/React.isValidElement(objValue) && /*#__PURE__*/React.isValidElement(othValue)) {
27
+ return true;
28
+ }
29
+ if (isFunction(objValue) && isFunction(othValue)) {
30
+ return true;
31
+ }
32
+ });
20
33
  };
@@ -98,6 +98,9 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
98
98
  // 忽略清洗的 codes
99
99
  ignoreCodes = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.ignoreCodes) || [];
100
100
  Object.keys(response).forEach(function (key) {
101
+ if (!response[key] || !Array.isArray(response[key])) {
102
+ return;
103
+ }
101
104
  var options = (0, _toConsumableArray2.default)(response[key]) || [];
102
105
  if (ignoreCodes.includes(key)) {
103
106
  response[key] = options;
@@ -87,7 +87,7 @@ function cacheFieldNames(fieldNames, dataSource) {
87
87
  });
88
88
  // 递归去对数据进行清洗
89
89
  if (children && Array.isArray(dataSource[children])) {
90
- result[children] = dataSource[children].map(function (item) {
90
+ result.children = dataSource[children].map(function (item) {
91
91
  return cacheFieldNames(fieldNames, item);
92
92
  });
93
93
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
@@ -8,12 +9,14 @@ exports.default = void 0;
8
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _jsxRuntime = require("react/jsx-runtime");
10
11
  var _antd = require("antd");
11
- var _react = require("react");
12
+ var _react = _interopRequireWildcard(require("react"));
12
13
  var _lodash = require("lodash");
13
14
  var _classnames = _interopRequireDefault(require("classnames"));
14
15
  var _ActionButton = _interopRequireDefault(require("./ActionButton"));
15
16
  var _RenderFields = _interopRequireDefault(require("../../../render/RenderFields"));
16
17
  var _ProCollapse = _interopRequireDefault(require("../../../../../ProLayout/components/ProCollapse"));
18
+ var _utils = require("../utils");
19
+ var MemoRenderFields = /*#__PURE__*/_react.default.memo(_RenderFields.default, _utils.memoWith);
17
20
  var BlockFields = function BlockFields(props) {
18
21
  var title = props.title,
19
22
  mode = props.mode,
@@ -70,7 +73,7 @@ var BlockFields = function BlockFields(props) {
70
73
  }),
71
74
  children: (0, _jsxRuntime.jsx)(_antd.Row, {
72
75
  gutter: 24,
73
- children: (0, _jsxRuntime.jsx)(_RenderFields.default, {
76
+ children: (0, _jsxRuntime.jsx)(MemoRenderFields, {
74
77
  columns: columns,
75
78
  form: form,
76
79
  colProps: colProps,
@@ -9,12 +9,15 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var _antd = require("antd");
12
+ var _react = _interopRequireDefault(require("react"));
12
13
  var _classnames = _interopRequireDefault(require("classnames"));
13
14
  var _sortable = require("@dnd-kit/sortable");
14
15
  var _utilities = require("@dnd-kit/utilities");
15
16
  var _ProIcon = _interopRequireDefault(require("../../../../../ProIcon"));
16
17
  var _ActionButton = _interopRequireDefault(require("./ActionButton"));
17
18
  var _RenderFields = _interopRequireDefault(require("../../../render/RenderFields"));
19
+ var _utils = require("../utils");
20
+ var MemoRenderFields = /*#__PURE__*/_react.default.memo(_RenderFields.default, _utils.memoWith);
18
21
  var LineFields = function LineFields(props) {
19
22
  var mode = props.mode,
20
23
  index = props.index,
@@ -68,7 +71,7 @@ var LineFields = function LineFields(props) {
68
71
  })
69
72
  })), (0, _jsxRuntime.jsx)(_antd.Row, {
70
73
  gutter: isLess ? 0 : 24,
71
- children: (0, _jsxRuntime.jsx)(_RenderFields.default, {
74
+ children: (0, _jsxRuntime.jsx)(MemoRenderFields, {
72
75
  columns: columns,
73
76
  form: form,
74
77
  colProps: colProps,
@@ -9,3 +9,4 @@ export declare const namesPathTransform: ({ names, prefixNamePath, type, }: {
9
9
  prefixNamePath: any[];
10
10
  type: string;
11
11
  }) => string;
12
+ export declare const memoWith: (pre: any, next: any) => boolean;
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.namesPathTransform = void 0;
7
+ exports.namesPathTransform = exports.memoWith = void 0;
8
+ var _lodash = require("lodash");
9
+ var _react = _interopRequireDefault(require("react"));
7
10
  /**
8
11
  * namesPath生产 [['list', 0, 'min'], ['list', 0, 'max']] => list_0_min-list_0_max
9
12
  * @param names name的集合
@@ -23,4 +26,15 @@ var namesPathTransform = exports.namesPathTransform = function namesPathTransfor
23
26
  return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
24
27
  return Array.isArray(name) ? name.join('_') : name;
25
28
  }).join('-');
29
+ };
30
+ // 比较memo
31
+ var memoWith = exports.memoWith = function memoWith(pre, next) {
32
+ return (0, _lodash.isEqualWith)(pre, next, function (objValue, othValue) {
33
+ if ( /*#__PURE__*/_react.default.isValidElement(objValue) && /*#__PURE__*/_react.default.isValidElement(othValue)) {
34
+ return true;
35
+ }
36
+ if ((0, _lodash.isFunction)(objValue) && (0, _lodash.isFunction)(othValue)) {
37
+ return true;
38
+ }
39
+ });
26
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.11",
3
+ "version": "3.7.0-beta.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",