@zat-design/sisyphus-react 3.12.0 → 3.12.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.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 西西弗组件库预览地址
2
+
3
+ [西西弗组件库预览地址](https://procomponents.zhongan.io/)
4
+
1
5
  ## 快速上手
2
6
 
3
7
  西西弗基于 antd@4 版本开发
@@ -41,8 +41,8 @@ var ProAction = function ProAction(props) {
41
41
  var length = config.length;
42
42
  var _onActionRun = /*#__PURE__*/function () {
43
43
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currentIndex, array) {
44
- var _actionProps$useReque, _options$onSuccess, _newServicesArray$cur, _newServicesArray$cur2, _newServicesArray$cur3, _actionProps$onAction, _actionProps$continue;
45
- var actionProps, newServicesArray, _ref2, service, options, transformResponse, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, _newServicesArray$cur6, list, errorTitle, isContinue;
44
+ var _actionProps$useReque, _options$defaultParam, _options$onSuccess, _newServicesArray$cur, _newServicesArray$cur2, _newServicesArray$cur3, _actionProps$onAction, _actionProps$continue;
45
+ var actionProps, newServicesArray, _ref2, service, options, transformResponse, params, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, _newServicesArray$cur6, list, errorTitle, isContinue;
46
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
47
  while (1) switch (_context.prev = _context.next) {
48
48
  case 0:
@@ -67,34 +67,35 @@ var ProAction = function ProAction(props) {
67
67
  service = _ref2.service;
68
68
  options = _ref2.options;
69
69
  transformResponse = _ref2.transformResponse;
70
- _context.next = 14;
71
- return service === null || service === void 0 ? void 0 : service(options === null || options === void 0 ? void 0 : options.defaultParams);
72
- case 14:
70
+ params = Array.isArray(options === null || options === void 0 ? void 0 : options.defaultParams) ? options === null || options === void 0 ? void 0 : (_options$defaultParam = options.defaultParams) === null || _options$defaultParam === void 0 ? void 0 : _options$defaultParam[0] : (options === null || options === void 0 ? void 0 : options.defaultParams) || {};
71
+ _context.next = 15;
72
+ return service === null || service === void 0 ? void 0 : service(params);
73
+ case 15:
73
74
  _context.t1 = _context.sent;
74
75
  if (_context.t1) {
75
- _context.next = 17;
76
+ _context.next = 18;
76
77
  break;
77
78
  }
78
79
  _context.t1 = {};
79
- case 17:
80
+ case 18:
80
81
  res = _context.t1;
81
82
  if (!(transformResponse && isFunction(transformResponse))) {
82
- _context.next = 25;
83
+ _context.next = 26;
83
84
  break;
84
85
  }
85
- _context.next = 21;
86
+ _context.next = 22;
86
87
  return transformResponse(res);
87
- case 21:
88
+ case 22:
88
89
  data = _context.sent;
89
90
  newServicesArray[currentIndex] = data;
90
- _context.next = 26;
91
+ _context.next = 27;
91
92
  break;
92
- case 25:
93
+ case 26:
93
94
  if (res.status === 200) {
94
95
  newServicesArray[currentIndex] = res.data;
95
96
  }
96
- case 26:
97
- options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, newServicesArray[currentIndex], options === null || options === void 0 ? void 0 : options.defaultParams);
97
+ case 27:
98
+ options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, newServicesArray[currentIndex], params);
98
99
  if (!service) {
99
100
  newServicesArray[currentIndex] = null;
100
101
  }
@@ -105,7 +106,7 @@ var ProAction = function ProAction(props) {
105
106
  open: open
106
107
  });
107
108
  if (!open) {
108
- _context.next = 36;
109
+ _context.next = 37;
109
110
  break;
110
111
  }
111
112
  list = ((_newServicesArray$cur4 = newServicesArray[currentIndex]) === null || _newServicesArray$cur4 === void 0 ? void 0 : (_newServicesArray$cur5 = _newServicesArray$cur4.list) === null || _newServicesArray$cur5 === void 0 ? void 0 : _newServicesArray$cur5.join('\n')) || [];
@@ -118,23 +119,23 @@ var ProAction = function ProAction(props) {
118
119
  loading: false
119
120
  });
120
121
  return _context.abrupt("return");
121
- case 36:
122
- _context.next = 38;
122
+ case 37:
123
+ _context.next = 39;
123
124
  return actionProps === null || actionProps === void 0 ? void 0 : (_actionProps$onAction = actionProps.onAction) === null || _actionProps$onAction === void 0 ? void 0 : _actionProps$onAction.call(actionProps, newServicesArray[currentIndex - 1], newServicesArray, currentIndex);
124
- case 38:
125
- _context.next = 40;
125
+ case 39:
126
+ _context.next = 41;
126
127
  return actionProps === null || actionProps === void 0 ? void 0 : (_actionProps$continue = actionProps.continue) === null || _actionProps$continue === void 0 ? void 0 : _actionProps$continue.call(actionProps, newServicesArray[currentIndex - 1], newServicesArray);
127
- case 40:
128
+ case 41:
128
129
  isContinue = _context.sent;
129
130
  if (!(isContinue === false)) {
130
- _context.next = 44;
131
+ _context.next = 45;
131
132
  break;
132
133
  }
133
134
  setState({
134
135
  loading: false
135
136
  });
136
137
  return _context.abrupt("return", false);
137
- case 44:
138
+ case 45:
138
139
  if (currentIndex + 1 < length) {
139
140
  _onActionRun(currentIndex + 1, newServicesArray);
140
141
  } else {
@@ -142,7 +143,7 @@ var ProAction = function ProAction(props) {
142
143
  loading: false
143
144
  });
144
145
  }
145
- case 45:
146
+ case 46:
146
147
  case "end":
147
148
  return _context.stop();
148
149
  }
@@ -101,7 +101,7 @@ var ProDrawer = function ProDrawer(_ref) {
101
101
  }, _callee);
102
102
  })), [onCancel, modalRef.current, ref.current]);
103
103
  var handleFinish = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
104
- var values, _error$errorFields, _error$errorFields$;
104
+ var values;
105
105
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
106
106
  while (1) switch (_context2.prev = _context2.next) {
107
107
  case 0:
@@ -160,7 +160,17 @@ var ProDrawer = function ProDrawer(_ref) {
160
160
  case 26:
161
161
  _context2.prev = 26;
162
162
  _context2.t4 = _context2["catch"](0);
163
- form.scrollToField(_context2.t4 === null || _context2.t4 === void 0 ? void 0 : (_error$errorFields = _context2.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name);
163
+ /** 使用setTimeout确保DOM已经更新,错误标记已经渲染 */
164
+ setTimeout(function () {
165
+ var _ref$current, _error$errorFields;
166
+ var errorElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('[class*="form-item-has-error"]');
167
+ if (errorElement && (_context2.t4 === null || _context2.t4 === void 0 ? void 0 : (_error$errorFields = _context2.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
168
+ errorElement.scrollIntoView({
169
+ behavior: 'smooth',
170
+ block: 'center'
171
+ });
172
+ }
173
+ }, 100);
164
174
  case 29:
165
175
  _context2.prev = 29;
166
176
  toggleLoading(false);
@@ -54,7 +54,7 @@ var ProModal = function ProModal(_ref) {
54
54
  'pro-modal-footer-shadow': height >= 450
55
55
  }]);
56
56
  var handleFinish = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
57
- var values, _error$errorFields, _error$errorFields$;
57
+ var values;
58
58
  return _regeneratorRuntime().wrap(function _callee$(_context) {
59
59
  while (1) switch (_context.prev = _context.next) {
60
60
  case 0:
@@ -113,7 +113,17 @@ var ProModal = function ProModal(_ref) {
113
113
  case 26:
114
114
  _context.prev = 26;
115
115
  _context.t4 = _context["catch"](0);
116
- form.scrollToField(_context.t4 === null || _context.t4 === void 0 ? void 0 : (_error$errorFields = _context.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name);
116
+ /** 使用setTimeout确保DOM已经更新,错误标记已经渲染 */
117
+ setTimeout(function () {
118
+ var _ref$current2, _error$errorFields;
119
+ var errorElement = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelector('[class*="form-item-has-error"]');
120
+ if (errorElement && (_context.t4 === null || _context.t4 === void 0 ? void 0 : (_error$errorFields = _context.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
121
+ errorElement.scrollIntoView({
122
+ behavior: 'smooth',
123
+ block: 'center'
124
+ });
125
+ }
126
+ }, 100);
117
127
  case 29:
118
128
  _context.prev = 29;
119
129
  toggleLoading(false);
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd/es/form/Form';
3
+ export declare const useProDrawerFormContext: () => any;
3
4
  declare const ProDrawerForm: React.ForwardRefExoticComponent<import("./propsType").ProDrawerFormPropsType & React.RefAttributes<FormInstance<any>>>;
4
5
  export default ProDrawerForm;
@@ -1,12 +1,16 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  var _locale$ProDrawerForm3;
4
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
5
- import { forwardRef, useImperativeHandle, useMemo } from 'react';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { createContext, forwardRef, useContext, useImperativeHandle, useMemo } from 'react';
6
6
  import { ProDrawer, ProModal } from './components';
7
7
  import ProForm from '../ProForm';
8
8
  import { transformBySize } from './utils';
9
9
  import locale from '../locale';
10
+ var ProDrawerFormContext = /*#__PURE__*/createContext(null);
11
+ export var useProDrawerFormContext = function useProDrawerFormContext() {
12
+ return useContext(ProDrawerFormContext);
13
+ };
10
14
  var ProDrawerForm = /*#__PURE__*/forwardRef(function (props, ref) {
11
15
  var _okText, _locale$ProDrawerForm, _locale$ProDrawerForm2;
12
16
  var visible = props.visible,
@@ -51,7 +55,10 @@ var ProDrawerForm = /*#__PURE__*/forwardRef(function (props, ref) {
51
55
  Modal: ProModal
52
56
  }[showType];
53
57
  }, [showType]);
54
- return _jsx(_Fragment, {
58
+ return _jsx(ProDrawerFormContext.Provider, {
59
+ value: {
60
+ source: 'ProDrawerForm'
61
+ },
55
62
  children: visible ? _jsx(Com, _objectSpread(_objectSpread({}, props), {}, {
56
63
  isView: isView,
57
64
  visible: visible,
@@ -45,7 +45,7 @@ export declare const onDelete: ({ name, form, virtualKey, selectedRowKeys, }: {
45
45
  selectedRowKeys: Key[];
46
46
  }) => void;
47
47
  /**
48
- * 获取最终的disabled, 两张模式【子级优先,全局优先
48
+ * 获取最终的disabled, 两种模式【子级优先,全局优先】
49
49
  * 全局优先:globalControl为true时,全局控制
50
50
  * 子级优先:globalControl为false时,子级控制
51
51
  * @param params 禁用参数
@@ -106,7 +106,7 @@ export var onDelete = function onDelete(_ref) {
106
106
  }
107
107
  };
108
108
  /**
109
- * 获取最终的disabled, 两张模式【子级优先,全局优先
109
+ * 获取最终的disabled, 两种模式【子级优先,全局优先】
110
110
  * 全局优先:globalControl为true时,全局控制
111
111
  * 子级优先:globalControl为false时,子级控制
112
112
  * @param params 禁用参数
@@ -154,6 +154,18 @@ export var getDisabled = function getDisabled(_ref2) {
154
154
  if (rowDisabled === 'empty') {
155
155
  return false;
156
156
  }
157
+ // 日期范围选择器和数字范围选择器
158
+ if (['RangePicker', 'ProNumberRange', 'Group'].includes(column.type)) {
159
+ if (Array.isArray(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled)) {
160
+ return columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled;
161
+ }
162
+ if (Array.isArray(column === null || column === void 0 ? void 0 : column.disabled)) {
163
+ return column.disabled;
164
+ }
165
+ if (isFunction(column === null || column === void 0 ? void 0 : column.disabled)) {
166
+ return column === null || column === void 0 ? void 0 : column.disabled.apply(column, _toConsumableArray(params));
167
+ }
168
+ }
157
169
  // 当表单含有diabled属性时,优先使用表单的disabled
158
170
  if (isFunction(rowDisabled) && noColumnDisabled()) {
159
171
  return rowDisabled(params[1]);
@@ -182,11 +194,11 @@ export var getDisabled = function getDisabled(_ref2) {
182
194
  */
183
195
  export var handleScrollToError = function handleScrollToError() {
184
196
  setTimeout(function () {
185
- var errorDom = document.querySelector('.ant-form-item-has-error');
197
+ var errorDom = document.querySelector('[class*="form-item-has-error"]');
186
198
  if (errorDom) {
187
- var tableBody = errorDom.closest('.ant-table-content') || errorDom.closest('.ant-table-body');
188
- var tableCell = errorDom.closest('.ant-table-cell');
189
- var tableRow = errorDom.closest('.ant-table-row');
199
+ var tableBody = errorDom.closest('[class*="table-content"]') || errorDom.closest('[class*="table-body"]');
200
+ var tableCell = errorDom.closest('[class*="table-cell"]');
201
+ var tableRow = errorDom.closest('[class*="table-row"]');
190
202
  if (tableBody && tableCell) {
191
203
  var previousSibling = tableCell.previousElementSibling;
192
204
  var childOffsetLeft = 0;
@@ -27,6 +27,19 @@ var Input = function Input(props) {
27
27
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
28
28
  var initialConfig = useProConfig('Input');
29
29
  if (isView) {
30
+ if ((desensitization === null || desensitization === void 0 ? void 0 : desensitization.length) && (props === null || props === void 0 ? void 0 : props.disabled)) {
31
+ var isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
32
+ if (isDesensit === 'ON') {
33
+ if (typeof rest.value === 'number') {
34
+ var _rest$value, _rest$value$toString;
35
+ rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value = rest.value) === null || _rest$value === void 0 ? void 0 : (_rest$value$toString = _rest$value.toString) === null || _rest$value$toString === void 0 ? void 0 : _rest$value$toString.call(_rest$value);
36
+ }
37
+ return _jsx(Container, {
38
+ viewEmpty: viewEmpty,
39
+ children: maskStringRangeWithRegex(rest.value, desensitization)
40
+ });
41
+ }
42
+ }
30
43
  return _jsx(Container, {
31
44
  viewEmpty: viewEmpty,
32
45
  children: rest.value
@@ -39,11 +52,11 @@ var Input = function Input(props) {
39
52
  }, omit(initialConfig, ['trim'])), rest));
40
53
  // 仅查看模式下进行数据脱敏
41
54
  if ((desensitization === null || desensitization === void 0 ? void 0 : desensitization.length) && (props === null || props === void 0 ? void 0 : props.disabled)) {
42
- var isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
43
- if (isDesensit === 'ON') {
55
+ var _isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
56
+ if (_isDesensit === 'ON') {
44
57
  if (typeof rest.value === 'number') {
45
- var _rest$value, _rest$value$toString;
46
- rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value = rest.value) === null || _rest$value === void 0 ? void 0 : (_rest$value$toString = _rest$value.toString) === null || _rest$value$toString === void 0 ? void 0 : _rest$value$toString.call(_rest$value);
58
+ var _rest$value2, _rest$value2$toString;
59
+ rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value2 = rest.value) === null || _rest$value2 === void 0 ? void 0 : (_rest$value2$toString = _rest$value2.toString) === null || _rest$value2$toString === void 0 ? void 0 : _rest$value2$toString.call(_rest$value2);
47
60
  }
48
61
  return /*#__PURE__*/React.cloneElement(ComInput, _objectSpread(_objectSpread(_objectSpread({
49
62
  allowClear: true,
@@ -15,7 +15,7 @@ import { createElement as _createElement } from "react";
15
15
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
16
16
  import { isFunction, omit } from 'lodash';
17
17
  import { useMemo } from 'react';
18
- import { CopyOutlined, DownSquareOutlined, PlusSquareOutlined, UpSquareOutlined } from '@ant-design/icons';
18
+ import { CopyOutlined, PlusSquareOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
19
19
  import ProIcon from '../../../../../ProIcon';
20
20
  import locale from '../../../../../locale';
21
21
  var filterKeys = ['actionType'];
@@ -40,7 +40,7 @@ var getDefaultActions = function getDefaultActions(mode) {
40
40
  var remove = operation.remove;
41
41
  remove(index);
42
42
  },
43
- label: "".concat(locale.ProForm.formListActions[1]),
43
+ label: locale.ProForm.formListActions[1],
44
44
  icon: mode === 'less' ? _jsx(ProIcon, {
45
45
  type: "solid-close",
46
46
  className: "single-delete",
@@ -58,7 +58,7 @@ var getDefaultActions = function getDefaultActions(mode) {
58
58
  var add = operation.add;
59
59
  add(record, index + 1);
60
60
  },
61
- label: "".concat(locale.ProForm.formListActions[2]),
61
+ label: locale.ProForm.formListActions[2],
62
62
  icon: _jsx(CopyOutlined, {})
63
63
  },
64
64
  moveUp: {
@@ -69,8 +69,8 @@ var getDefaultActions = function getDefaultActions(mode) {
69
69
  var move = operation.move;
70
70
  move(index, index - 1);
71
71
  },
72
- label: "".concat(locale.ProForm.formListActions[3]),
73
- icon: _jsx(UpSquareOutlined, {})
72
+ label: locale.ProForm.formListActions[3],
73
+ icon: _jsx(ArrowUpOutlined, {})
74
74
  },
75
75
  moveDown: {
76
76
  onClick: function onClick(record, _ref5) {
@@ -80,8 +80,8 @@ var getDefaultActions = function getDefaultActions(mode) {
80
80
  var move = operation.move;
81
81
  move(index, index + 1);
82
82
  },
83
- label: "".concat(locale.ProForm.formListActions[4]),
84
- icon: _jsx(DownSquareOutlined, {})
83
+ label: locale.ProForm.formListActions[4],
84
+ icon: _jsx(ArrowDownOutlined, {})
85
85
  }
86
86
  };
87
87
  if (mode === 'block') {
@@ -20,6 +20,7 @@ import { isObject, merge, omit } from 'lodash';
20
20
  import { FormFooter, InputRange, ProAddress, ProCascader, ProCertNo, ProCertValidity, ProCombination, ProModalSelect, ProNumberRange, ProRangeBox, ProTimeLimit, transferAddressInfoToRegion, ProUpload, ProTreeModal, ProTree, EnumSelect } from './components';
21
21
  import RenderFields from './components/render/RenderFields';
22
22
  import { useProConfig } from '../ProConfigProvider';
23
+ import { useProDrawerFormContext } from '../ProDrawerForm';
23
24
  import { getLayout, splitNameStr, useControlled, initialValuesToNames, filterInternalFields } from './utils/index';
24
25
  import { useForm } from './utils/useForm';
25
26
  import { useFieldProps } from './utils/useFieldProps';
@@ -27,7 +28,7 @@ import locale from '../locale';
27
28
  import useWatch from './utils/useWatch';
28
29
  import FormsProvider, { useContextForms, useForms } from '../FormsProvider';
29
30
  var ProForm = function ProForm(props, ref) {
30
- var _localStorage, _ref;
31
+ var _localStorage, _ref2;
31
32
  var _props$mode = props.mode,
32
33
  mode = _props$mode === void 0 ? 'search' : _props$mode,
33
34
  span = props.span,
@@ -73,10 +74,15 @@ var ProForm = function ProForm(props, ref) {
73
74
  desensitizationKey = _props$desensitizatio === void 0 ? 'zat-design-pro-component-desensitization' : _props$desensitizatio,
74
75
  otherProps = _objectWithoutProperties(props, _excluded);
75
76
  var config = useProConfig('ProForm');
77
+ // source: 用于区分是哪个组件调用,用于错误提示
78
+ var _ref = useProDrawerFormContext() || {},
79
+ _ref$source = _ref.source,
80
+ source = _ref$source === void 0 ? '' : _ref$source;
76
81
  var _useForm = useForm(originForm, {
77
82
  scrollToError: scrollToError,
78
83
  optimize: optimize,
79
- formKey: formKey
84
+ formKey: formKey,
85
+ source: source || 'ProForm'
80
86
  }),
81
87
  _useForm2 = _slicedToArray(_useForm, 1),
82
88
  form = _useForm2[0];
@@ -214,7 +220,7 @@ var ProForm = function ProForm(props, ref) {
214
220
  className: cls,
215
221
  form: form
216
222
  }, formProps), omit(config, ['isDiffAll'])), otherProps), {}, {
217
- labelAlign: (_ref = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref !== void 0 ? _ref : 'left',
223
+ labelAlign: (_ref2 = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref2 !== void 0 ? _ref2 : 'left',
218
224
  onValuesChange: handleValuesChange,
219
225
  onFinish: handleFinish,
220
226
  initialValues: _initialValues,
@@ -12,5 +12,6 @@ export interface FormInstanceOption {
12
12
  scrollToError?: boolean;
13
13
  optimize?: boolean;
14
14
  formKey?: string;
15
+ source?: string;
15
16
  }
16
17
  export declare const useForm: <T>(originForm?: ModifiedFormInstance<T> | FormInstanceOption, options?: FormInstanceOption) => [ModifiedFormInstance<T>];
@@ -20,7 +20,8 @@ export var useForm = function useForm(originForm, options) {
20
20
  _ref$scrollToError = _ref.scrollToError,
21
21
  scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError,
22
22
  optimize = _ref.optimize,
23
- formKey = _ref.formKey;
23
+ formKey = _ref.formKey,
24
+ source = _ref.source;
24
25
  // formKey全局共享逻辑
25
26
  var forms = useContext(FormsContext);
26
27
  var _Form$useForm = _Form.useForm(forms[formKey] || _originForm),
@@ -114,7 +115,7 @@ export var useForm = function useForm(originForm, options) {
114
115
  case 18:
115
116
  _context.prev = 18;
116
117
  _context.t0 = _context["catch"](0);
117
- if (scrollToError && (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
118
+ if (scrollToError && (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length) && source === 'ProForm') {
118
119
  form.scrollToField((_error$errorFields$ = _context.t0.errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
119
120
  block: 'center',
120
121
  behavior: 'smooth'
@@ -23,7 +23,7 @@ import { getSelectList } from './utils';
23
23
  import './index.less';
24
24
  var Option = _Select.Option;
25
25
  export var ProSelect = function ProSelect(props, ref) {
26
- var _selectProps$showCode, _useRequest$options, _locale$ProSelect;
26
+ var _selectProps$showCode, _useRequest$options3, _locale$ProSelect;
27
27
  var _ref = useProConfig('ProSelect') || {},
28
28
  _ref$fieldNames = _ref.fieldNames,
29
29
  proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
@@ -102,9 +102,12 @@ export var ProSelect = function ProSelect(props, ref) {
102
102
  }
103
103
  return data;
104
104
  }, []);
105
- var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread({
105
+ var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread(_objectSpread({
106
106
  manual: true,
107
+ debounceWait: 300
108
+ }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
107
109
  onSuccess: function onSuccess(data) {
110
+ var _useRequest$options, _useRequest$options$o, _useRequest$options2;
108
111
  if (transformResponse && typeof transformResponse === 'function') {
109
112
  var responseData = transformResponse(data);
110
113
  setSelectList(responseData);
@@ -112,10 +115,11 @@ export var ProSelect = function ProSelect(props, ref) {
112
115
  // 接口写死了,无法复用
113
116
  updateDataSource ? updateDataSource(data, setSelectList) : defaultOnSuccessFun(data);
114
117
  }
115
- },
116
- debounceWait: 300
117
- }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
118
- var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
118
+ // 执行传入onSuccess
119
+ useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : (_useRequest$options$o = _useRequest$options.onSuccess) === null || _useRequest$options$o === void 0 ? void 0 : _useRequest$options$o.call(_useRequest$options, data, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams);
120
+ }
121
+ }));
122
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options3 = useRequest.options) === null || _useRequest$options3 === void 0 ? void 0 : _useRequest$options3.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
119
123
  var getValueObject = function getValueObject(input) {
120
124
  if (Array.isArray(input) && input.length) {
121
125
  var resArr = [];
@@ -141,9 +145,9 @@ export var ProSelect = function ProSelect(props, ref) {
141
145
  setSelectList(dataSource);
142
146
  }, [dataSource]);
143
147
  useDeepCompareEffect(function () {
144
- var _useRequest$options2;
148
+ var _useRequest$options4;
145
149
  // 设置cacheKey后使用缓存的数据
146
- if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey)) {
150
+ if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options4 = useRequest.options) === null || _useRequest$options4 === void 0 ? void 0 : _useRequest$options4.cacheKey)) {
147
151
  if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
148
152
  setSelectList(cacheList);
149
153
  }
@@ -45,8 +45,8 @@ var ProAction = function ProAction(props) {
45
45
  var length = config.length;
46
46
  var _onActionRun = /*#__PURE__*/function () {
47
47
  var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(currentIndex, array) {
48
- var _actionProps$useReque, _options$onSuccess, _newServicesArray$cur, _newServicesArray$cur2, _newServicesArray$cur3, _actionProps$onAction, _actionProps$continue;
49
- var actionProps, newServicesArray, _ref2, service, options, transformResponse, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, _newServicesArray$cur6, list, errorTitle, isContinue;
48
+ var _actionProps$useReque, _options$defaultParam, _options$onSuccess, _newServicesArray$cur, _newServicesArray$cur2, _newServicesArray$cur3, _actionProps$onAction, _actionProps$continue;
49
+ var actionProps, newServicesArray, _ref2, service, options, transformResponse, params, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, _newServicesArray$cur6, list, errorTitle, isContinue;
50
50
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
@@ -71,34 +71,35 @@ var ProAction = function ProAction(props) {
71
71
  service = _ref2.service;
72
72
  options = _ref2.options;
73
73
  transformResponse = _ref2.transformResponse;
74
- _context.next = 14;
75
- return service === null || service === void 0 ? void 0 : service(options === null || options === void 0 ? void 0 : options.defaultParams);
76
- case 14:
74
+ params = Array.isArray(options === null || options === void 0 ? void 0 : options.defaultParams) ? options === null || options === void 0 ? void 0 : (_options$defaultParam = options.defaultParams) === null || _options$defaultParam === void 0 ? void 0 : _options$defaultParam[0] : (options === null || options === void 0 ? void 0 : options.defaultParams) || {};
75
+ _context.next = 15;
76
+ return service === null || service === void 0 ? void 0 : service(params);
77
+ case 15:
77
78
  _context.t1 = _context.sent;
78
79
  if (_context.t1) {
79
- _context.next = 17;
80
+ _context.next = 18;
80
81
  break;
81
82
  }
82
83
  _context.t1 = {};
83
- case 17:
84
+ case 18:
84
85
  res = _context.t1;
85
86
  if (!(transformResponse && (0, _lodash.isFunction)(transformResponse))) {
86
- _context.next = 25;
87
+ _context.next = 26;
87
88
  break;
88
89
  }
89
- _context.next = 21;
90
+ _context.next = 22;
90
91
  return transformResponse(res);
91
- case 21:
92
+ case 22:
92
93
  data = _context.sent;
93
94
  newServicesArray[currentIndex] = data;
94
- _context.next = 26;
95
+ _context.next = 27;
95
96
  break;
96
- case 25:
97
+ case 26:
97
98
  if (res.status === 200) {
98
99
  newServicesArray[currentIndex] = res.data;
99
100
  }
100
- case 26:
101
- options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, newServicesArray[currentIndex], options === null || options === void 0 ? void 0 : options.defaultParams);
101
+ case 27:
102
+ options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, newServicesArray[currentIndex], params);
102
103
  if (!service) {
103
104
  newServicesArray[currentIndex] = null;
104
105
  }
@@ -109,7 +110,7 @@ var ProAction = function ProAction(props) {
109
110
  open: open
110
111
  });
111
112
  if (!open) {
112
- _context.next = 36;
113
+ _context.next = 37;
113
114
  break;
114
115
  }
115
116
  list = ((_newServicesArray$cur4 = newServicesArray[currentIndex]) === null || _newServicesArray$cur4 === void 0 ? void 0 : (_newServicesArray$cur5 = _newServicesArray$cur4.list) === null || _newServicesArray$cur5 === void 0 ? void 0 : _newServicesArray$cur5.join('\n')) || [];
@@ -122,23 +123,23 @@ var ProAction = function ProAction(props) {
122
123
  loading: false
123
124
  });
124
125
  return _context.abrupt("return");
125
- case 36:
126
- _context.next = 38;
126
+ case 37:
127
+ _context.next = 39;
127
128
  return actionProps === null || actionProps === void 0 ? void 0 : (_actionProps$onAction = actionProps.onAction) === null || _actionProps$onAction === void 0 ? void 0 : _actionProps$onAction.call(actionProps, newServicesArray[currentIndex - 1], newServicesArray, currentIndex);
128
- case 38:
129
- _context.next = 40;
129
+ case 39:
130
+ _context.next = 41;
130
131
  return actionProps === null || actionProps === void 0 ? void 0 : (_actionProps$continue = actionProps.continue) === null || _actionProps$continue === void 0 ? void 0 : _actionProps$continue.call(actionProps, newServicesArray[currentIndex - 1], newServicesArray);
131
- case 40:
132
+ case 41:
132
133
  isContinue = _context.sent;
133
134
  if (!(isContinue === false)) {
134
- _context.next = 44;
135
+ _context.next = 45;
135
136
  break;
136
137
  }
137
138
  setState({
138
139
  loading: false
139
140
  });
140
141
  return _context.abrupt("return", false);
141
- case 44:
142
+ case 45:
142
143
  if (currentIndex + 1 < length) {
143
144
  _onActionRun(currentIndex + 1, newServicesArray);
144
145
  } else {
@@ -146,7 +147,7 @@ var ProAction = function ProAction(props) {
146
147
  loading: false
147
148
  });
148
149
  }
149
- case 45:
150
+ case 46:
150
151
  case "end":
151
152
  return _context.stop();
152
153
  }
@@ -104,7 +104,7 @@ var ProDrawer = function ProDrawer(_ref) {
104
104
  }, _callee);
105
105
  })), [onCancel, modalRef.current, ref.current]);
106
106
  var handleFinish = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
107
- var values, _error$errorFields, _error$errorFields$;
107
+ var values;
108
108
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
109
109
  while (1) switch (_context2.prev = _context2.next) {
110
110
  case 0:
@@ -163,7 +163,17 @@ var ProDrawer = function ProDrawer(_ref) {
163
163
  case 26:
164
164
  _context2.prev = 26;
165
165
  _context2.t4 = _context2["catch"](0);
166
- form.scrollToField(_context2.t4 === null || _context2.t4 === void 0 ? void 0 : (_error$errorFields = _context2.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name);
166
+ /** 使用setTimeout确保DOM已经更新,错误标记已经渲染 */
167
+ setTimeout(function () {
168
+ var _ref$current, _error$errorFields;
169
+ var errorElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('[class*="form-item-has-error"]');
170
+ if (errorElement && (_context2.t4 === null || _context2.t4 === void 0 ? void 0 : (_error$errorFields = _context2.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
171
+ errorElement.scrollIntoView({
172
+ behavior: 'smooth',
173
+ block: 'center'
174
+ });
175
+ }
176
+ }, 100);
167
177
  case 29:
168
178
  _context2.prev = 29;
169
179
  toggleLoading(false);
@@ -57,7 +57,7 @@ var ProModal = function ProModal(_ref) {
57
57
  'pro-modal-footer-shadow': height >= 450
58
58
  }]);
59
59
  var handleFinish = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
60
- var values, _error$errorFields, _error$errorFields$;
60
+ var values;
61
61
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
62
62
  while (1) switch (_context.prev = _context.next) {
63
63
  case 0:
@@ -116,7 +116,17 @@ var ProModal = function ProModal(_ref) {
116
116
  case 26:
117
117
  _context.prev = 26;
118
118
  _context.t4 = _context["catch"](0);
119
- form.scrollToField(_context.t4 === null || _context.t4 === void 0 ? void 0 : (_error$errorFields = _context.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : (_error$errorFields$ = _error$errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name);
119
+ /** 使用setTimeout确保DOM已经更新,错误标记已经渲染 */
120
+ setTimeout(function () {
121
+ var _ref$current2, _error$errorFields;
122
+ var errorElement = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelector('[class*="form-item-has-error"]');
123
+ if (errorElement && (_context.t4 === null || _context.t4 === void 0 ? void 0 : (_error$errorFields = _context.t4.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
124
+ errorElement.scrollIntoView({
125
+ behavior: 'smooth',
126
+ block: 'center'
127
+ });
128
+ }
129
+ }, 100);
120
130
  case 29:
121
131
  _context.prev = 29;
122
132
  toggleLoading(false);
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd/es/form/Form';
3
+ export declare const useProDrawerFormContext: () => any;
3
4
  declare const ProDrawerForm: React.ForwardRefExoticComponent<import("./propsType").ProDrawerFormPropsType & React.RefAttributes<FormInstance<any>>>;
4
5
  export default ProDrawerForm;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.useProDrawerFormContext = exports.default = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
@@ -14,6 +14,10 @@ var _ProForm = _interopRequireDefault(require("../ProForm"));
14
14
  var _utils = require("./utils");
15
15
  var _locale = _interopRequireDefault(require("../locale"));
16
16
  var _locale$ProDrawerForm3;
17
+ var ProDrawerFormContext = /*#__PURE__*/(0, _react.createContext)(null);
18
+ var useProDrawerFormContext = exports.useProDrawerFormContext = function useProDrawerFormContext() {
19
+ return (0, _react.useContext)(ProDrawerFormContext);
20
+ };
17
21
  var ProDrawerForm = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
18
22
  var _okText, _locale$ProDrawerForm, _locale$ProDrawerForm2;
19
23
  var visible = props.visible,
@@ -58,7 +62,10 @@ var ProDrawerForm = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
58
62
  Modal: _components.ProModal
59
63
  }[showType];
60
64
  }, [showType]);
61
- return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
65
+ return (0, _jsxRuntime.jsx)(ProDrawerFormContext.Provider, {
66
+ value: {
67
+ source: 'ProDrawerForm'
68
+ },
62
69
  children: visible ? (0, _jsxRuntime.jsx)(Com, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
63
70
  isView: isView,
64
71
  visible: visible,
@@ -45,7 +45,7 @@ export declare const onDelete: ({ name, form, virtualKey, selectedRowKeys, }: {
45
45
  selectedRowKeys: Key[];
46
46
  }) => void;
47
47
  /**
48
- * 获取最终的disabled, 两张模式【子级优先,全局优先
48
+ * 获取最终的disabled, 两种模式【子级优先,全局优先】
49
49
  * 全局优先:globalControl为true时,全局控制
50
50
  * 子级优先:globalControl为false时,子级控制
51
51
  * @param params 禁用参数
@@ -115,7 +115,7 @@ var onDelete = exports.onDelete = function onDelete(_ref) {
115
115
  }
116
116
  };
117
117
  /**
118
- * 获取最终的disabled, 两张模式【子级优先,全局优先
118
+ * 获取最终的disabled, 两种模式【子级优先,全局优先】
119
119
  * 全局优先:globalControl为true时,全局控制
120
120
  * 子级优先:globalControl为false时,子级控制
121
121
  * @param params 禁用参数
@@ -163,6 +163,18 @@ var getDisabled = exports.getDisabled = function getDisabled(_ref2) {
163
163
  if (rowDisabled === 'empty') {
164
164
  return false;
165
165
  }
166
+ // 日期范围选择器和数字范围选择器
167
+ if (['RangePicker', 'ProNumberRange', 'Group'].includes(column.type)) {
168
+ if (Array.isArray(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled)) {
169
+ return columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled;
170
+ }
171
+ if (Array.isArray(column === null || column === void 0 ? void 0 : column.disabled)) {
172
+ return column.disabled;
173
+ }
174
+ if ((0, _lodash.isFunction)(column === null || column === void 0 ? void 0 : column.disabled)) {
175
+ return column === null || column === void 0 ? void 0 : column.disabled.apply(column, (0, _toConsumableArray2.default)(params));
176
+ }
177
+ }
166
178
  // 当表单含有diabled属性时,优先使用表单的disabled
167
179
  if ((0, _lodash.isFunction)(rowDisabled) && noColumnDisabled()) {
168
180
  return rowDisabled(params[1]);
@@ -191,11 +203,11 @@ var getDisabled = exports.getDisabled = function getDisabled(_ref2) {
191
203
  */
192
204
  var handleScrollToError = exports.handleScrollToError = function handleScrollToError() {
193
205
  setTimeout(function () {
194
- var errorDom = document.querySelector('.ant-form-item-has-error');
206
+ var errorDom = document.querySelector('[class*="form-item-has-error"]');
195
207
  if (errorDom) {
196
- var tableBody = errorDom.closest('.ant-table-content') || errorDom.closest('.ant-table-body');
197
- var tableCell = errorDom.closest('.ant-table-cell');
198
- var tableRow = errorDom.closest('.ant-table-row');
208
+ var tableBody = errorDom.closest('[class*="table-content"]') || errorDom.closest('[class*="table-body"]');
209
+ var tableCell = errorDom.closest('[class*="table-cell"]');
210
+ var tableRow = errorDom.closest('[class*="table-row"]');
199
211
  if (tableBody && tableCell) {
200
212
  var previousSibling = tableCell.previousElementSibling;
201
213
  var childOffsetLeft = 0;
@@ -33,6 +33,19 @@ var Input = function Input(props) {
33
33
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
34
34
  var initialConfig = (0, _ProConfigProvider.useProConfig)('Input');
35
35
  if (isView) {
36
+ if ((desensitization === null || desensitization === void 0 ? void 0 : desensitization.length) && (props === null || props === void 0 ? void 0 : props.disabled)) {
37
+ var isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
38
+ if (isDesensit === 'ON') {
39
+ if (typeof rest.value === 'number') {
40
+ var _rest$value, _rest$value$toString;
41
+ rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value = rest.value) === null || _rest$value === void 0 ? void 0 : (_rest$value$toString = _rest$value.toString) === null || _rest$value$toString === void 0 ? void 0 : _rest$value$toString.call(_rest$value);
42
+ }
43
+ return (0, _jsxRuntime.jsx)(_Container.default, {
44
+ viewEmpty: viewEmpty,
45
+ children: (0, _valueType.maskStringRangeWithRegex)(rest.value, desensitization)
46
+ });
47
+ }
48
+ }
36
49
  return (0, _jsxRuntime.jsx)(_Container.default, {
37
50
  viewEmpty: viewEmpty,
38
51
  children: rest.value
@@ -45,11 +58,11 @@ var Input = function Input(props) {
45
58
  }, (0, _lodash.omit)(initialConfig, ['trim'])), rest));
46
59
  // 仅查看模式下进行数据脱敏
47
60
  if ((desensitization === null || desensitization === void 0 ? void 0 : desensitization.length) && (props === null || props === void 0 ? void 0 : props.disabled)) {
48
- var isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
49
- if (isDesensit === 'ON') {
61
+ var _isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
62
+ if (_isDesensit === 'ON') {
50
63
  if (typeof rest.value === 'number') {
51
- var _rest$value, _rest$value$toString;
52
- rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value = rest.value) === null || _rest$value === void 0 ? void 0 : (_rest$value$toString = _rest$value.toString) === null || _rest$value$toString === void 0 ? void 0 : _rest$value$toString.call(_rest$value);
64
+ var _rest$value2, _rest$value2$toString;
65
+ rest.value = rest === null || rest === void 0 ? void 0 : (_rest$value2 = rest.value) === null || _rest$value2 === void 0 ? void 0 : (_rest$value2$toString = _rest$value2.toString) === null || _rest$value2$toString === void 0 ? void 0 : _rest$value2$toString.call(_rest$value2);
53
66
  }
54
67
  return /*#__PURE__*/_react.default.cloneElement(ComInput, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
55
68
  allowClear: true,
@@ -41,7 +41,7 @@ var getDefaultActions = function getDefaultActions(mode) {
41
41
  var remove = operation.remove;
42
42
  remove(index);
43
43
  },
44
- label: "".concat(_locale.default.ProForm.formListActions[1]),
44
+ label: _locale.default.ProForm.formListActions[1],
45
45
  icon: mode === 'less' ? (0, _jsxRuntime.jsx)(_ProIcon.default, {
46
46
  type: "solid-close",
47
47
  className: "single-delete",
@@ -59,7 +59,7 @@ var getDefaultActions = function getDefaultActions(mode) {
59
59
  var add = operation.add;
60
60
  add(record, index + 1);
61
61
  },
62
- label: "".concat(_locale.default.ProForm.formListActions[2]),
62
+ label: _locale.default.ProForm.formListActions[2],
63
63
  icon: (0, _jsxRuntime.jsx)(_icons.CopyOutlined, {})
64
64
  },
65
65
  moveUp: {
@@ -70,8 +70,8 @@ var getDefaultActions = function getDefaultActions(mode) {
70
70
  var move = operation.move;
71
71
  move(index, index - 1);
72
72
  },
73
- label: "".concat(_locale.default.ProForm.formListActions[3]),
74
- icon: (0, _jsxRuntime.jsx)(_icons.UpSquareOutlined, {})
73
+ label: _locale.default.ProForm.formListActions[3],
74
+ icon: (0, _jsxRuntime.jsx)(_icons.ArrowUpOutlined, {})
75
75
  },
76
76
  moveDown: {
77
77
  onClick: function onClick(record, _ref5) {
@@ -81,8 +81,8 @@ var getDefaultActions = function getDefaultActions(mode) {
81
81
  var move = operation.move;
82
82
  move(index, index + 1);
83
83
  },
84
- label: "".concat(_locale.default.ProForm.formListActions[4]),
85
- icon: (0, _jsxRuntime.jsx)(_icons.DownSquareOutlined, {})
84
+ label: _locale.default.ProForm.formListActions[4],
85
+ icon: (0, _jsxRuntime.jsx)(_icons.ArrowDownOutlined, {})
86
86
  }
87
87
  };
88
88
  if (mode === 'block') {
@@ -20,6 +20,7 @@ var _lodash = require("lodash");
20
20
  var _components = require("./components");
21
21
  var _RenderFields = _interopRequireDefault(require("./components/render/RenderFields"));
22
22
  var _ProConfigProvider = require("../ProConfigProvider");
23
+ var _ProDrawerForm = require("../ProDrawerForm");
23
24
  var _index = require("./utils/index");
24
25
  var _useForm3 = require("./utils/useForm");
25
26
  var _useFieldProps = require("./utils/useFieldProps");
@@ -28,7 +29,7 @@ var _useWatch = _interopRequireDefault(require("./utils/useWatch"));
28
29
  var _FormsProvider = _interopRequireWildcard(require("../FormsProvider"));
29
30
  var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "diffConfig", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "formKey", "globalControl", "scrollToError", "optimize", "desensitizationKey"];
30
31
  var ProForm = function ProForm(props, ref) {
31
- var _localStorage, _ref;
32
+ var _localStorage, _ref2;
32
33
  var _props$mode = props.mode,
33
34
  mode = _props$mode === void 0 ? 'search' : _props$mode,
34
35
  span = props.span,
@@ -74,10 +75,15 @@ var ProForm = function ProForm(props, ref) {
74
75
  desensitizationKey = _props$desensitizatio === void 0 ? 'zat-design-pro-component-desensitization' : _props$desensitizatio,
75
76
  otherProps = (0, _objectWithoutProperties2.default)(props, _excluded);
76
77
  var config = (0, _ProConfigProvider.useProConfig)('ProForm');
78
+ // source: 用于区分是哪个组件调用,用于错误提示
79
+ var _ref = (0, _ProDrawerForm.useProDrawerFormContext)() || {},
80
+ _ref$source = _ref.source,
81
+ source = _ref$source === void 0 ? '' : _ref$source;
77
82
  var _useForm = (0, _useForm3.useForm)(originForm, {
78
83
  scrollToError: scrollToError,
79
84
  optimize: optimize,
80
- formKey: formKey
85
+ formKey: formKey,
86
+ source: source || 'ProForm'
81
87
  }),
82
88
  _useForm2 = (0, _slicedToArray2.default)(_useForm, 1),
83
89
  form = _useForm2[0];
@@ -215,7 +221,7 @@ var ProForm = function ProForm(props, ref) {
215
221
  className: cls,
216
222
  form: form
217
223
  }, formProps), (0, _lodash.omit)(config, ['isDiffAll'])), otherProps), {}, {
218
- labelAlign: (_ref = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref !== void 0 ? _ref : 'left',
224
+ labelAlign: (_ref2 = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref2 !== void 0 ? _ref2 : 'left',
219
225
  onValuesChange: handleValuesChange,
220
226
  onFinish: handleFinish,
221
227
  initialValues: _initialValues,
@@ -12,5 +12,6 @@ export interface FormInstanceOption {
12
12
  scrollToError?: boolean;
13
13
  optimize?: boolean;
14
14
  formKey?: string;
15
+ source?: string;
15
16
  }
16
17
  export declare const useForm: <T>(originForm?: ModifiedFormInstance<T> | FormInstanceOption, options?: FormInstanceOption) => [ModifiedFormInstance<T>];
@@ -26,7 +26,8 @@ var useForm = exports.useForm = function useForm(originForm, options) {
26
26
  _ref$scrollToError = _ref.scrollToError,
27
27
  scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError,
28
28
  optimize = _ref.optimize,
29
- formKey = _ref.formKey;
29
+ formKey = _ref.formKey,
30
+ source = _ref.source;
30
31
  // formKey全局共享逻辑
31
32
  var forms = (0, _react.useContext)(_FormsProvider.FormsContext);
32
33
  var _Form$useForm = _antd.Form.useForm(forms[formKey] || _originForm),
@@ -120,7 +121,7 @@ var useForm = exports.useForm = function useForm(originForm, options) {
120
121
  case 18:
121
122
  _context.prev = 18;
122
123
  _context.t0 = _context["catch"](0);
123
- if (scrollToError && (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
124
+ if (scrollToError && (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length) && source === 'ProForm') {
124
125
  form.scrollToField((_error$errorFields$ = _context.t0.errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
125
126
  block: 'center',
126
127
  behavior: 'smooth'
@@ -24,7 +24,7 @@ require("./index.less");
24
24
  var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
25
25
  var Option = _antd.Select.Option;
26
26
  var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
27
- var _selectProps$showCode, _useRequest$options, _locale$ProSelect;
27
+ var _selectProps$showCode, _useRequest$options3, _locale$ProSelect;
28
28
  var _ref = (0, _ProConfigProvider.useProConfig)('ProSelect') || {},
29
29
  _ref$fieldNames = _ref.fieldNames,
30
30
  proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
@@ -103,9 +103,12 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
103
103
  }
104
104
  return data;
105
105
  }, []);
106
- var fetchFunction = (0, _ahooks.useRequest)(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, (0, _objectSpread2.default)({
106
+ var fetchFunction = (0, _ahooks.useRequest)(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, (0, _objectSpread2.default)((0, _objectSpread2.default)({
107
107
  manual: true,
108
+ debounceWait: 300
109
+ }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
108
110
  onSuccess: function onSuccess(data) {
111
+ var _useRequest$options, _useRequest$options$o, _useRequest$options2;
109
112
  if (transformResponse && typeof transformResponse === 'function') {
110
113
  var responseData = transformResponse(data);
111
114
  setSelectList(responseData);
@@ -113,10 +116,11 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
113
116
  // 接口写死了,无法复用
114
117
  updateDataSource ? updateDataSource(data, setSelectList) : defaultOnSuccessFun(data);
115
118
  }
116
- },
117
- debounceWait: 300
118
- }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
119
- var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
119
+ // 执行传入onSuccess
120
+ useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : (_useRequest$options$o = _useRequest$options.onSuccess) === null || _useRequest$options$o === void 0 ? void 0 : _useRequest$options$o.call(_useRequest$options, data, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams);
121
+ }
122
+ }));
123
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options3 = useRequest.options) === null || _useRequest$options3 === void 0 ? void 0 : _useRequest$options3.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
120
124
  var getValueObject = function getValueObject(input) {
121
125
  if (Array.isArray(input) && input.length) {
122
126
  var resArr = [];
@@ -142,9 +146,9 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
142
146
  setSelectList(dataSource);
143
147
  }, [dataSource]);
144
148
  (0, _ahooks.useDeepCompareEffect)(function () {
145
- var _useRequest$options2;
149
+ var _useRequest$options4;
146
150
  // 设置cacheKey后使用缓存的数据
147
- if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey)) {
151
+ if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options4 = useRequest.options) === null || _useRequest$options4 === void 0 ? void 0 : _useRequest$options4.cacheKey)) {
148
152
  if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
149
153
  setSelectList(cacheList);
150
154
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
7
  "typings": "lib/index.d.ts",
8
+ "homepage": "https://procomponents.zhongan.io/",
8
9
  "scripts": {
9
10
  "analyze": "ANALYZE=1 dumi build",
10
11
  "build": "npm run build-lib && npm run build-es && npm run build-dist",