@zat-design/sisyphus-react 3.8.2-beta.1 → 3.8.2-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.
@@ -155,7 +155,7 @@ var Render = function Render(props) {
155
155
  };
156
156
  }
157
157
  /** 移除多余参数,防止透传给formItem报错 */
158
- var _otherFormItemProps = omit(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow']);
158
+ var _otherFormItemProps = omit(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames']);
159
159
  /**
160
160
  * globalControl 全局控制优先
161
161
  * globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
@@ -182,6 +182,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
182
182
  }) => React.ReactElement<any, any> | string | undefined | null;
183
183
  viewType?: ViewType;
184
184
  colProps?: ColProps;
185
+ /** 依赖刷新字段列表 */
186
+ dependNames?: NamePath[];
185
187
  /**
186
188
  * @description 表单item的props属性
187
189
  * @deprecated 将于下个版本 4.0.0 被弃用
@@ -190,6 +192,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
190
192
  formItemProps?: FormItemProps<Values> & {
191
193
  index?: number;
192
194
  namePath?: NamePath;
195
+ /** 依赖刷新字段列表 */
196
+ dependNames?: NamePath[];
193
197
  };
194
198
  /**
195
199
  * @description 表单props属性
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { useRef, useState } from 'react';
3
- import { isFunction, isEqualWith } from 'lodash';
4
- import { customEqualForFun, equalDependencies } from './index';
3
+ import { isFunction, isEqualWith, get } from 'lodash';
4
+ import { customEqualForFun } from './index';
5
5
  // 代理shouldUpdate事件, 执行函数值的[show, disabled], 当[show, disabled]与上一次值不相同时更新状态
6
6
  var useShouldUpdate = function useShouldUpdate(props) {
7
7
  var show = props.show,
@@ -20,7 +20,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
20
20
  index = formItemProps.index,
21
21
  namePath = formItemProps.namePath,
22
22
  names = formItemProps.names,
23
- dependencies = formItemProps.dependencies;
23
+ dependNames = formItemProps.dependNames;
24
24
  var timerRef = useRef();
25
25
  var needClear = useRef(); // 是否需要执行清值操作
26
26
  var showRef = useRef();
@@ -29,13 +29,14 @@ var useShouldUpdate = function useShouldUpdate(props) {
29
29
  var rulesRef = useRef();
30
30
  var fieldPropsRef = useRef();
31
31
  var originComponentRef = useRef();
32
+ var dependNamesRef = useRef();
32
33
  var newComponent = originComponent || component; // 解决component默认赋值污染问题,需要使用originComponent
33
34
  var _useState = useState({}),
34
35
  _useState2 = _slicedToArray(_useState, 2),
35
36
  reRender = _useState2[1];
36
37
  var values = {};
37
38
  // 不是动态函数直接返回
38
- if (!isFunction(show) && !isFunction(disabled) && !isFunction(required) && !isFunction(rules) && !isFunction(fieldProps) && !isFunction(originComponent)) {
39
+ if (!(dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) && !isFunction(show) && !isFunction(disabled) && !isFunction(required) && !isFunction(rules) && !isFunction(fieldProps) && !isFunction(originComponent)) {
39
40
  return {
40
41
  shouldUpdate: _shouldUpdate,
41
42
  show: show,
@@ -119,9 +120,22 @@ var useShouldUpdate = function useShouldUpdate(props) {
119
120
  } else {
120
121
  fieldPropsRef.current = fieldProps;
121
122
  }
123
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
124
+ dependNamesRef.current = dependNames.map(function (name) {
125
+ return get(values, name);
126
+ });
127
+ }
122
128
  return {
123
129
  shouldUpdate: function shouldUpdate(prevValues, currentValues) {
124
130
  // @ts-ignore formList场景取当前行数据,不取shouldUpdate变更后值
131
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
132
+ var curDependNamesValue = dependNames.map(function (name) {
133
+ return get(currentValues, name);
134
+ });
135
+ var dependNamesChanged = !isEqualWith(dependNamesRef.current, curDependNamesValue, customEqualForFun);
136
+ dependNamesRef.current = curDependNamesValue;
137
+ if (!dependNamesChanged) return false;
138
+ }
125
139
  var _currentValues;
126
140
  if (namePath) {
127
141
  // formList场景values取当前行数据
@@ -182,11 +196,12 @@ var useShouldUpdate = function useShouldUpdate(props) {
182
196
  }
183
197
  var equalRes = isEqualWith(rulesRef.current, _rules, customEqualForFun);
184
198
  var proEqualRes = isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun);
185
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
199
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes
186
200
  // 值变更,需要同步更新函数式的fieldProps
187
201
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
188
202
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
189
- equalDependencies(dependencies, prevValues, _currentValues)) {
203
+ // equalDependencies(dependencies, prevValues, _currentValues)
204
+ ) {
190
205
  showRef.current = _show;
191
206
  disabledRef.current = _disabled;
192
207
  requiredRef.current = _required;
@@ -30,7 +30,7 @@ export var defaultPage = {
30
30
  pageSize: 10
31
31
  };
32
32
  function ProTable(props) {
33
- var _locale$ProTable, _curTableConfig$pathK;
33
+ var _locale$ProTable, _props$scroll, _curTableConfig$pathK;
34
34
  var _ref = useProConfig('globalConfig') || {},
35
35
  configStorage = _ref.storage; // 获取全局缓存位置配置
36
36
  var _ref2 = useProConfig('ProTable') || {},
@@ -58,6 +58,9 @@ function ProTable(props) {
58
58
  restProps = _objectWithoutProperties(props, _excluded);
59
59
  var _props$scrollFollowPa = props.scrollFollowParent,
60
60
  scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
61
+ var _scroll = (_props$scroll = props === null || props === void 0 ? void 0 : props.scroll) !== null && _props$scroll !== void 0 ? _props$scroll : {
62
+ x: 'max-content'
63
+ };
61
64
  var wrapToolTipProps = {
62
65
  getPopupContainer: scrollFollowParent ? function (triggerNode) {
63
66
  return triggerNode.parentNode;
@@ -415,7 +418,8 @@ function ProTable(props) {
415
418
  summary: summary,
416
419
  dataSource: _dataSource
417
420
  },
418
- dataSource: _dataSource
421
+ dataSource: _dataSource,
422
+ scroll: _scroll
419
423
  })), _jsx("span", {
420
424
  className: "pro-table-resizable-line",
421
425
  style: {
@@ -155,7 +155,7 @@ var Render = function Render(props) {
155
155
  };
156
156
  }
157
157
  /** 移除多余参数,防止透传给formItem报错 */
158
- var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow']);
158
+ var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames']);
159
159
  /**
160
160
  * globalControl 全局控制优先
161
161
  * globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
@@ -182,6 +182,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
182
182
  }) => React.ReactElement<any, any> | string | undefined | null;
183
183
  viewType?: ViewType;
184
184
  colProps?: ColProps;
185
+ /** 依赖刷新字段列表 */
186
+ dependNames?: NamePath[];
185
187
  /**
186
188
  * @description 表单item的props属性
187
189
  * @deprecated 将于下个版本 4.0.0 被弃用
@@ -190,6 +192,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
190
192
  formItemProps?: FormItemProps<Values> & {
191
193
  index?: number;
192
194
  namePath?: NamePath;
195
+ /** 依赖刷新字段列表 */
196
+ dependNames?: NamePath[];
193
197
  };
194
198
  /**
195
199
  * @description 表单props属性
@@ -27,7 +27,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
27
27
  index = formItemProps.index,
28
28
  namePath = formItemProps.namePath,
29
29
  names = formItemProps.names,
30
- dependencies = formItemProps.dependencies;
30
+ dependNames = formItemProps.dependNames;
31
31
  var timerRef = (0, _react.useRef)();
32
32
  var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
33
33
  var showRef = (0, _react.useRef)();
@@ -36,13 +36,14 @@ var useShouldUpdate = function useShouldUpdate(props) {
36
36
  var rulesRef = (0, _react.useRef)();
37
37
  var fieldPropsRef = (0, _react.useRef)();
38
38
  var originComponentRef = (0, _react.useRef)();
39
+ var dependNamesRef = (0, _react.useRef)();
39
40
  var newComponent = originComponent || component; // 解决component默认赋值污染问题,需要使用originComponent
40
41
  var _useState = (0, _react.useState)({}),
41
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
43
  reRender = _useState2[1];
43
44
  var values = {};
44
45
  // 不是动态函数直接返回
45
- if (!(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
46
+ if (!(dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) && !(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
46
47
  return {
47
48
  shouldUpdate: _shouldUpdate,
48
49
  show: show,
@@ -126,9 +127,22 @@ var useShouldUpdate = function useShouldUpdate(props) {
126
127
  } else {
127
128
  fieldPropsRef.current = fieldProps;
128
129
  }
130
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
131
+ dependNamesRef.current = dependNames.map(function (name) {
132
+ return (0, _lodash.get)(values, name);
133
+ });
134
+ }
129
135
  return {
130
136
  shouldUpdate: function shouldUpdate(prevValues, currentValues) {
131
137
  // @ts-ignore formList场景取当前行数据,不取shouldUpdate变更后值
138
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
139
+ var curDependNamesValue = dependNames.map(function (name) {
140
+ return (0, _lodash.get)(currentValues, name);
141
+ });
142
+ var dependNamesChanged = !(0, _lodash.isEqualWith)(dependNamesRef.current, curDependNamesValue, _index.customEqualForFun);
143
+ dependNamesRef.current = curDependNamesValue;
144
+ if (!dependNamesChanged) return false;
145
+ }
132
146
  var _currentValues;
133
147
  if (namePath) {
134
148
  // formList场景values取当前行数据
@@ -189,11 +203,12 @@ var useShouldUpdate = function useShouldUpdate(props) {
189
203
  }
190
204
  var equalRes = (0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun);
191
205
  var proEqualRes = (0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun);
192
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
206
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes
193
207
  // 值变更,需要同步更新函数式的fieldProps
194
208
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
195
209
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
196
- (0, _index.equalDependencies)(dependencies, prevValues, _currentValues)) {
210
+ // equalDependencies(dependencies, prevValues, _currentValues)
211
+ ) {
197
212
  showRef.current = _show;
198
213
  disabledRef.current = _disabled;
199
214
  requiredRef.current = _required;
@@ -37,7 +37,7 @@ var defaultPage = exports.defaultPage = {
37
37
  pageSize: 10
38
38
  };
39
39
  function ProTable(props) {
40
- var _locale$ProTable, _curTableConfig$pathK;
40
+ var _locale$ProTable, _props$scroll, _curTableConfig$pathK;
41
41
  var _ref = (0, _index.useProConfig)('globalConfig') || {},
42
42
  configStorage = _ref.storage; // 获取全局缓存位置配置
43
43
  var _ref2 = (0, _index.useProConfig)('ProTable') || {},
@@ -65,6 +65,9 @@ function ProTable(props) {
65
65
  restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
66
66
  var _props$scrollFollowPa = props.scrollFollowParent,
67
67
  scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
68
+ var _scroll = (_props$scroll = props === null || props === void 0 ? void 0 : props.scroll) !== null && _props$scroll !== void 0 ? _props$scroll : {
69
+ x: 'max-content'
70
+ };
68
71
  var wrapToolTipProps = {
69
72
  getPopupContainer: scrollFollowParent ? function (triggerNode) {
70
73
  return triggerNode.parentNode;
@@ -422,7 +425,8 @@ function ProTable(props) {
422
425
  summary: summary,
423
426
  dataSource: _dataSource
424
427
  },
425
- dataSource: _dataSource
428
+ dataSource: _dataSource,
429
+ scroll: _scroll
426
430
  })), (0, _jsxRuntime.jsx)("span", {
427
431
  className: "pro-table-resizable-line",
428
432
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.8.2-beta.1",
3
+ "version": "3.8.2-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -49,7 +49,8 @@
49
49
  "Android >= 4"
50
50
  ],
51
51
  "resolutions": {
52
- "@types/react": "^17.0.53"
52
+ "@types/react": "^17.0.53",
53
+ "mockjs/commander": "9.2.0"
53
54
  },
54
55
  "dependencies": {
55
56
  "@ant-design/icons": "^4.2.2",
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "kisstkondoros.vscode-codemetrics"
4
- ]
5
- }