@zat-design/sisyphus-react 3.7.1-beta.2 → 3.7.1-beta.3

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.
@@ -441,36 +441,25 @@ var Render = function Render(props) {
441
441
  children: child
442
442
  });
443
443
  }
444
- var orgFormItem = _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, filterFormItemKey)), {}, {
444
+ return _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, filterFormItemKey)), {}, {
445
445
  // @ts-ignore
446
446
  _internalItemRender: internalItemRender,
447
447
  className: _className,
448
448
  children: child
449
449
  }));
450
- var formItem = orgFormItem;
451
- // 当存在shouldUpdate时捕获所有form变更(防止表单onchange设置form值时无法更新的问题)
452
- if (_otherFormItemProps.shouldUpdate) {
453
- formItem =
454
- // 空标签防止气泡不显示
455
- _jsx(_Fragment, {
456
- children: _jsx(_Form.Item, {
457
- shouldUpdate: _otherFormItemProps.shouldUpdate,
458
- noStyle: true,
459
- children: function children() {
460
- return _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, filterFormItemKey)), {}, {
461
- // @ts-ignore
462
- _internalItemRender: internalItemRender,
463
- className: _className,
464
- children: child
465
- }));
466
- }
467
- })
468
- });
469
- }
470
- return formItem;
471
450
  };
472
451
  var FormItem = _jsxs(_Fragment, {
473
- children: [renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
452
+ children: [_otherFormItemProps.shouldUpdate ?
453
+ // 空标签防止气泡不显示
454
+ _jsx(_Fragment, {
455
+ children: _jsx(_Form.Item, {
456
+ shouldUpdate: _otherFormItemProps.shouldUpdate,
457
+ noStyle: true,
458
+ children: function children() {
459
+ return renderItem();
460
+ }
461
+ })
462
+ }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
474
463
  return _jsx(_Form.Item, {
475
464
  hidden: true,
476
465
  name: name,
@@ -5,6 +5,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
5
5
  import React from 'react';
6
6
  import { isBoolean, isFunction, union, isString } from 'lodash';
7
7
  import Render from './Render';
8
+ import { getDefaultProps } from '../../utils/getDefaultProps';
8
9
  import * as componentMap from '../index';
9
10
  import { isSelect } from '../../utils';
10
11
  import { FieldProvider } from '../../utils/useFieldProps';
@@ -76,8 +77,9 @@ var RenderFields = function RenderFields(props) {
76
77
  otherFormItemProps = _objectWithoutProperties(column, _excluded);
77
78
  var component = column.component;
78
79
  var _isView = typeof column.isView === 'boolean' ? column.isView : isView;
80
+ var defaultProps = getDefaultProps(column);
79
81
  // 允许formItem的属性放在column最外层 并优先级高于 formItemProps 内部参数
80
- var _formItemProps = _objectSpread(_objectSpread(_objectSpread({}, formItemProps), otherFormItemProps), {}, {
82
+ var _formItemProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultProps), formItemProps), otherFormItemProps), {}, {
81
83
  required: columnRequired !== null && columnRequired !== void 0 ? columnRequired : required,
82
84
  clearNotShow: clearNotShow
83
85
  });
@@ -0,0 +1 @@
1
+ export declare const getDefaultProps: (props: any) => any;
@@ -0,0 +1,31 @@
1
+ import { get, isEqual } from 'lodash';
2
+ var defaultPropsMap = {
3
+ ProSelect: function ProSelect(props) {
4
+ var fieldProps = props.fieldProps,
5
+ name = props.name,
6
+ namePath = props.namePath;
7
+ var _ref = fieldProps || {},
8
+ filterInList = _ref.filterInList;
9
+ var defaultProps = {};
10
+ // formList场景传入列表过滤时
11
+ if (filterInList && namePath && name) {
12
+ var _listName = namePath.slice(0, -1);
13
+ var _namePath = name.slice(1);
14
+ defaultProps.shouldUpdate = function (preValues, curValues) {
15
+ var preListValue = get(preValues, _listName).map(function (item) {
16
+ return get(item, _namePath);
17
+ });
18
+ var curListValue = get(curValues, _listName).map(function (item) {
19
+ return get(item, _namePath);
20
+ });
21
+ return !isEqual(preListValue, curListValue);
22
+ };
23
+ }
24
+ return defaultProps;
25
+ }
26
+ };
27
+ export var getDefaultProps = function getDefaultProps(props) {
28
+ var _defaultPropsMap$type;
29
+ var type = props.type;
30
+ return (_defaultPropsMap$type = defaultPropsMap[type]) === null || _defaultPropsMap$type === void 0 ? void 0 : _defaultPropsMap$type.call(defaultPropsMap, props);
31
+ };
@@ -441,36 +441,25 @@ var Render = function Render(props) {
441
441
  children: child
442
442
  });
443
443
  }
444
- var orgFormItem = (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(_otherFormItemProps, filterFormItemKey)), {}, {
444
+ return (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(_otherFormItemProps, filterFormItemKey)), {}, {
445
445
  // @ts-ignore
446
446
  _internalItemRender: internalItemRender,
447
447
  className: _className,
448
448
  children: child
449
449
  }));
450
- var formItem = orgFormItem;
451
- // 当存在shouldUpdate时捕获所有form变更(防止表单onchange设置form值时无法更新的问题)
452
- if (_otherFormItemProps.shouldUpdate) {
453
- formItem =
454
- // 空标签防止气泡不显示
455
- (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
456
- children: (0, _jsxRuntime.jsx)(_antd.Form.Item, {
457
- shouldUpdate: _otherFormItemProps.shouldUpdate,
458
- noStyle: true,
459
- children: function children() {
460
- return (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(_otherFormItemProps, filterFormItemKey)), {}, {
461
- // @ts-ignore
462
- _internalItemRender: internalItemRender,
463
- className: _className,
464
- children: child
465
- }));
466
- }
467
- })
468
- });
469
- }
470
- return formItem;
471
450
  };
472
451
  var FormItem = (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
473
- children: [renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
452
+ children: [_otherFormItemProps.shouldUpdate ?
453
+ // 空标签防止气泡不显示
454
+ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
455
+ children: (0, _jsxRuntime.jsx)(_antd.Form.Item, {
456
+ shouldUpdate: _otherFormItemProps.shouldUpdate,
457
+ noStyle: true,
458
+ children: function children() {
459
+ return renderItem();
460
+ }
461
+ })
462
+ }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
474
463
  return (0, _jsxRuntime.jsx)(_antd.Form.Item, {
475
464
  hidden: true,
476
465
  name: name,
@@ -12,6 +12,7 @@ var _jsxRuntime = require("react/jsx-runtime");
12
12
  var _react = _interopRequireDefault(require("react"));
13
13
  var _lodash = require("lodash");
14
14
  var _Render = _interopRequireDefault(require("./Render"));
15
+ var _getDefaultProps = require("../../utils/getDefaultProps");
15
16
  var componentMap = _interopRequireWildcard(require("../index"));
16
17
  var _utils = require("../../utils");
17
18
  var _useFieldProps = require("../../utils/useFieldProps");
@@ -84,8 +85,9 @@ var RenderFields = function RenderFields(props) {
84
85
  otherFormItemProps = (0, _objectWithoutProperties2.default)(column, _excluded);
85
86
  var component = column.component;
86
87
  var _isView = typeof column.isView === 'boolean' ? column.isView : isView;
88
+ var defaultProps = (0, _getDefaultProps.getDefaultProps)(column);
87
89
  // 允许formItem的属性放在column最外层 并优先级高于 formItemProps 内部参数
88
- var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, formItemProps), otherFormItemProps), {}, {
90
+ var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultProps), formItemProps), otherFormItemProps), {}, {
89
91
  required: columnRequired !== null && columnRequired !== void 0 ? columnRequired : required,
90
92
  clearNotShow: clearNotShow
91
93
  });
@@ -0,0 +1 @@
1
+ export declare const getDefaultProps: (props: any) => any;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDefaultProps = void 0;
7
+ var _lodash = require("lodash");
8
+ var defaultPropsMap = {
9
+ ProSelect: function ProSelect(props) {
10
+ var fieldProps = props.fieldProps,
11
+ name = props.name,
12
+ namePath = props.namePath;
13
+ var _ref = fieldProps || {},
14
+ filterInList = _ref.filterInList;
15
+ var defaultProps = {};
16
+ // formList场景传入列表过滤时
17
+ if (filterInList && namePath && name) {
18
+ var _listName = namePath.slice(0, -1);
19
+ var _namePath = name.slice(1);
20
+ defaultProps.shouldUpdate = function (preValues, curValues) {
21
+ var preListValue = (0, _lodash.get)(preValues, _listName).map(function (item) {
22
+ return (0, _lodash.get)(item, _namePath);
23
+ });
24
+ var curListValue = (0, _lodash.get)(curValues, _listName).map(function (item) {
25
+ return (0, _lodash.get)(item, _namePath);
26
+ });
27
+ return !(0, _lodash.isEqual)(preListValue, curListValue);
28
+ };
29
+ }
30
+ return defaultProps;
31
+ }
32
+ };
33
+ var getDefaultProps = exports.getDefaultProps = function getDefaultProps(props) {
34
+ var _defaultPropsMap$type;
35
+ var type = props.type;
36
+ return (_defaultPropsMap$type = defaultPropsMap[type]) === null || _defaultPropsMap$type === void 0 ? void 0 : _defaultPropsMap$type.call(defaultPropsMap, props);
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.7.1-beta.2",
3
+ "version": "3.7.1-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",