iglooform 2.3.15 → 2.3.19

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.
Files changed (45) hide show
  1. package/es/admin-upload/modal.js +1 -1
  2. package/es/admin-upload/style/index.less +1 -0
  3. package/es/form/element/index.js +37 -7
  4. package/es/form/login/index.js +1 -1
  5. package/es/form/page/index.js +1 -1
  6. package/es/form/pages/index.js +6 -4
  7. package/es/form/section/index.d.ts +3 -0
  8. package/es/form/section/index.js +8 -3
  9. package/es/form/step/index.js +1 -1
  10. package/es/form/steps/index.js +5 -4
  11. package/es/free-form/element/index.d.ts +0 -1
  12. package/es/free-form/element/index.js +32 -5
  13. package/es/free-form/page/index.js +1 -1
  14. package/es/input/phone-number.js +6 -1
  15. package/es/select/attached-select.d.ts +1 -0
  16. package/es/select/attached-select.js +8 -1
  17. package/es/types.d.ts +2 -0
  18. package/es/utils/form-methods.js +1 -1
  19. package/es/{form/utils.d.ts → utils/form-utils.d.ts} +1 -0
  20. package/es/{form/utils.js → utils/form-utils.js} +11 -1
  21. package/lib/admin-upload/modal.js +1 -1
  22. package/lib/admin-upload/style/index.less +1 -0
  23. package/lib/form/element/index.js +38 -8
  24. package/lib/form/login/index.js +2 -2
  25. package/lib/form/page/index.js +2 -2
  26. package/lib/form/pages/index.js +8 -6
  27. package/lib/form/section/index.d.ts +3 -0
  28. package/lib/form/section/index.js +10 -5
  29. package/lib/form/step/index.js +2 -2
  30. package/lib/form/steps/index.js +7 -6
  31. package/lib/free-form/element/index.d.ts +0 -1
  32. package/lib/free-form/element/index.js +33 -6
  33. package/lib/free-form/page/index.js +2 -2
  34. package/lib/input/phone-number.js +6 -1
  35. package/lib/select/attached-select.d.ts +1 -0
  36. package/lib/select/attached-select.js +8 -1
  37. package/lib/types.d.ts +2 -0
  38. package/lib/utils/form-methods.js +1 -1
  39. package/lib/{form/utils.d.ts → utils/form-utils.d.ts} +1 -0
  40. package/lib/{form/utils.js → utils/form-utils.js} +11 -1
  41. package/package.json +1 -1
  42. package/es/free-form/utils.d.ts +0 -73
  43. package/es/free-form/utils.js +0 -370
  44. package/lib/free-form/utils.d.ts +0 -73
  45. package/lib/free-form/utils.js +0 -403
@@ -71,7 +71,7 @@ var Import = function Import(_ref) {
71
71
  customRequest: function customRequest() {},
72
72
  action: function action(file) {
73
73
  var dataSourceId = currentSource;
74
- setSource(undefined);
74
+ Array.isArray(dataSource) && setSource(undefined);
75
75
  return onUpload(file, dataSourceId);
76
76
  }
77
77
  }, {
@@ -139,6 +139,7 @@
139
139
  .igloo-admin-upload-dragger-switch {
140
140
  min-width: 224px;
141
141
  margin-top: 16px;
142
+ text-align: left;
142
143
  }
143
144
 
144
145
  .igloo-admin-upload-dargger-title {
@@ -19,6 +19,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
22
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23
+
24
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
25
+
26
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27
+
28
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
29
+
30
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
+
22
32
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
33
 
24
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -34,7 +44,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
44
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
35
45
  import { useContext, useEffect, useRef, useReducer } from 'react';
36
46
  import { CloseCircleFilled } from '@ant-design/icons';
37
- import { calcFormItemProps } from '../utils';
47
+ import { calcFormItemProps } from '../../utils/form-utils';
38
48
  import Section from '../section';
39
49
  import useComponent from '../elements';
40
50
  import FormContext from '../context';
@@ -52,7 +62,7 @@ var Element = function Element(_ref) {
52
62
  setShowStepButton = _ref.setShowStepButton;
53
63
  var type = config.type,
54
64
  label = config.label,
55
- render = config.render;
65
+ previewLabel = config.previewLabel;
56
66
 
57
67
  var _useContext = useContext(FormContext),
58
68
  form = _useContext.form,
@@ -72,9 +82,17 @@ var Element = function Element(_ref) {
72
82
  copyValue = config.copyValue,
73
83
  selectValue = config.selectValue,
74
84
  shouldRender = config.shouldRender,
75
- dependField = config.dependField;
85
+ dependField = config.dependField,
86
+ getOptions = config.getOptions,
87
+ subscribedFields = config.subscribedFields,
88
+ disabled = config.disabled,
89
+ extraLabel = config.extraLabel;
76
90
  var dependentField = dependencies || [];
77
91
 
92
+ if (Array.isArray(subscribedFields)) {
93
+ dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
94
+ }
95
+
78
96
  if (asserts && asserts.length) {
79
97
  asserts.forEach(function (_ref2) {
80
98
  var field = _ref2.field;
@@ -93,7 +111,7 @@ var Element = function Element(_ref) {
93
111
  });
94
112
  }
95
113
 
96
- if (shouldRender) {
114
+ if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
97
115
  dependentField.push('SUBSCRIBE_ALL');
98
116
  }
99
117
 
@@ -101,6 +119,15 @@ var Element = function Element(_ref) {
101
119
  dependentField.push(dependField);
102
120
  }
103
121
 
122
+ if (Array.isArray(disabled)) {
123
+ disabled.forEach(function (_ref4) {
124
+ var field = _ref4.field;
125
+ return dependentField.push(field);
126
+ });
127
+ } else if (_typeof(disabled) === 'object') {
128
+ dependentField.push(disabled.field);
129
+ }
130
+
104
131
  registerDependencies(dependentField, dispatch);
105
132
  }, []);
106
133
  invariant(type !== 'Pages' && type !== 'Page', "".concat(type, " should not be inner form item"));
@@ -116,7 +143,10 @@ var Element = function Element(_ref) {
116
143
  if (type === 'Section') {
117
144
  return _jsx(Section, {
118
145
  parentName: parentName,
119
- config: config
146
+ config: config,
147
+ preview: preview,
148
+ disabled: disabled,
149
+ setShowStepButton: setShowStepButton
120
150
  }, void 0);
121
151
  }
122
152
 
@@ -246,14 +276,14 @@ var Element = function Element(_ref) {
246
276
  xs: 0
247
277
  }
248
278
  }, {
249
- children: [label && _jsx(_Col, Object.assign({
279
+ children: [(previewLabel || label) && _jsx(_Col, Object.assign({
250
280
  span: 12,
251
281
  md: 12,
252
282
  sm: 24,
253
283
  xs: 24,
254
284
  className: "igloo-element-preview-label"
255
285
  }, {
256
- children: label
286
+ children: previewLabel || label
257
287
  }), void 0), _jsxs(_Col, Object.assign({
258
288
  span: label ? 12 : 24,
259
289
  md: label ? 12 : 24,
@@ -9,7 +9,7 @@ import _Col from "antd/es/col";
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  import { useContext } from 'react';
11
11
  import Element from '../element';
12
- import { calcNamePath } from '../utils';
12
+ import { calcNamePath } from '../../utils/form-utils';
13
13
  import FormContext from '../context';
14
14
  import { LocaleContext } from '../../locale';
15
15
  import './style/index.less';
@@ -21,7 +21,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
21
  import { useContext, useEffect, useReducer } from 'react';
22
22
  import Button from '../../button';
23
23
  import Element from '../element';
24
- import { calcNamePath } from '../utils';
24
+ import { calcNamePath } from '../../utils/form-utils';
25
25
  import FormContext from '../context';
26
26
  import { LocaleContext } from '../../locale';
27
27
  import './style/index.less';
@@ -23,7 +23,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
23
  import { useState, useContext, useReducer, useEffect } from 'react';
24
24
  import Button from '../../button';
25
25
  import Page from '../page';
26
- import { calcNamePath } from '../utils';
26
+ import { calcNamePath } from '../../utils/form-utils';
27
27
  import FormContext from '../context';
28
28
  import { LocaleContext } from '../../locale';
29
29
  import './style/index.less';
@@ -34,8 +34,10 @@ var useBreakpoint = _Grid.useBreakpoint;
34
34
  var Pages = function Pages(_ref) {
35
35
  var name = _ref.name,
36
36
  parentName = _ref.parentName,
37
- _ref$config$elements = _ref.config.elements,
38
- elements = _ref$config$elements === void 0 ? [] : _ref$config$elements;
37
+ _ref$config = _ref.config,
38
+ _ref$config$elements = _ref$config.elements,
39
+ elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
40
+ subscribedFields = _ref$config.subscribedFields;
39
41
 
40
42
  var _useState = useState(0),
41
43
  _useState2 = _slicedToArray(_useState, 2),
@@ -70,7 +72,7 @@ var Pages = function Pages(_ref) {
70
72
  });
71
73
 
72
74
  if (subscribe) {
73
- registerDependencies('SUBSCRIBE_ALL', dispatch);
75
+ Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
74
76
  }
75
77
  }, []);
76
78
 
@@ -6,6 +6,9 @@ export interface SectionProps {
6
6
  parentName?: FormItemName;
7
7
  formItemProps?: FormItemProps;
8
8
  config: FormItemConfig;
9
+ preview?: boolean;
10
+ disabled?: boolean;
11
+ setShowStepButton?: (showButton: boolean) => void;
9
12
  }
10
13
  declare const Section: FC<SectionProps>;
11
14
  export default Section;
@@ -18,7 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  import { useContext } from 'react';
19
19
  import Element from '../element';
20
20
  import FormContext from '../context';
21
- import { calcNamePath, calcFormItemProps } from '../utils';
21
+ import { calcNamePath, calcFormItemProps } from '../../utils/form-utils';
22
22
  import Typography from '../../typography';
23
23
  import './style/index.less';
24
24
 
@@ -35,7 +35,10 @@ var Section = function Section(_ref) {
35
35
  contentProps = _ref$config$contentPr === void 0 ? {} : _ref$config$contentPr,
36
36
  _ref$config$style = _ref$config.style,
37
37
  style = _ref$config$style === void 0 ? {} : _ref$config$style,
38
- rest = _objectWithoutProperties(_ref$config, _excluded);
38
+ rest = _objectWithoutProperties(_ref$config, _excluded),
39
+ preview = _ref.preview,
40
+ disabled = _ref.disabled,
41
+ setShowStepButton = _ref.setShowStepButton;
39
42
 
40
43
  var _useContext = useContext(FormContext),
41
44
  form = _useContext.form,
@@ -84,7 +87,9 @@ var Section = function Section(_ref) {
84
87
  return _jsx(Element, {
85
88
  parentName: namePath,
86
89
  config: child,
87
- disabled: elementProps.disabled
90
+ disabled: elementProps.disabled || disabled,
91
+ preview: preview,
92
+ setShowStepButton: setShowStepButton
88
93
  }, index);
89
94
  })
90
95
  }), void 0)
@@ -24,7 +24,7 @@ import { useContext, useState, useRef, useEffect } from 'react';
24
24
  import { LocaleContext } from '../../locale';
25
25
  import Button from '../../button';
26
26
  import Element from '../element';
27
- import { calcNamePath } from '../utils';
27
+ import { calcNamePath } from '../../utils/form-utils';
28
28
  import FormContext from '../context';
29
29
  import './style/index.less';
30
30
  var useBreakpoint = _Grid.useBreakpoint;
@@ -17,7 +17,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  import { useState, useContext, useEffect, useReducer } from 'react';
19
19
  import Step from '../step';
20
- import { calcNamePath } from '../utils';
20
+ import { calcNamePath } from '../../utils/form-utils';
21
21
  import FormContext from '../context';
22
22
  import './style/index.less';
23
23
  import invariant from 'invariant';
@@ -29,7 +29,8 @@ var Steps = function Steps(_ref) {
29
29
  _ref$config$elements = _ref$config.elements,
30
30
  elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
31
31
  _ref$config$showLastI = _ref$config.showLastIndex,
32
- showLastIndex = _ref$config$showLastI === void 0 ? true : _ref$config$showLastI;
32
+ showLastIndex = _ref$config$showLastI === void 0 ? true : _ref$config$showLastI,
33
+ subscribedFields = _ref$config.subscribedFields;
33
34
 
34
35
  var _useState = useState(0),
35
36
  _useState2 = _slicedToArray(_useState, 2),
@@ -65,11 +66,11 @@ var Steps = function Steps(_ref) {
65
66
  });
66
67
 
67
68
  if (subscribe) {
68
- registerDependencies('SUBSCRIBE_ALL', dispatch);
69
+ Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
69
70
  }
70
71
  }, []);
71
72
  var renderElements = elements.filter(function (step) {
72
- step.key = step.name || step.key || Math.random();
73
+ step.key = step.name || step.key;
73
74
  return typeof step.shouldRender !== 'function' || step.shouldRender(form);
74
75
  });
75
76
 
@@ -4,7 +4,6 @@ import './style/index.less';
4
4
  interface ElementProps extends FormItemConfig {
5
5
  parentName?: FormItemName;
6
6
  preview?: boolean;
7
- disabled?: boolean;
8
7
  setShowStepButton?: (showButton: boolean) => void;
9
8
  }
10
9
  declare const Element: FC<ElementProps>;
@@ -18,6 +18,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
18
18
 
19
19
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
20
 
21
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22
+
23
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
24
+
25
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
+
27
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
28
+
29
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
30
+
21
31
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
32
 
23
33
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -33,7 +43,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
43
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
34
44
  import { useContext, useEffect, useRef, useReducer, isValidElement, cloneElement, useMemo } from 'react';
35
45
  import { CloseCircleFilled } from '@ant-design/icons';
36
- import { calcFormItemProps } from '../utils';
46
+ import { calcFormItemProps } from '../../utils/form-utils';
37
47
  import FormContext from '../context';
38
48
  import omit from 'omit.js';
39
49
  import classNames from 'classnames';
@@ -43,6 +53,7 @@ var useBreakpoint = _Grid.useBreakpoint;
43
53
  var Element = function Element(props) {
44
54
  var parentName = props.parentName,
45
55
  label = props.label,
56
+ previewLabel = props.previewLabel,
46
57
  preview = props.preview,
47
58
  disabled = props.disabled,
48
59
  children = props.children;
@@ -65,9 +76,16 @@ var Element = function Element(props) {
65
76
  copyValue = props.copyValue,
66
77
  selectValue = props.selectValue,
67
78
  shouldRender = props.shouldRender,
68
- dependField = props.dependField;
79
+ dependField = props.dependField,
80
+ getOptions = props.getOptions,
81
+ subscribedFields = props.subscribedFields,
82
+ extraLabel = props.extraLabel;
69
83
  var dependentField = dependencies || [];
70
84
 
85
+ if (Array.isArray(subscribedFields)) {
86
+ dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
87
+ }
88
+
71
89
  if (asserts && asserts.length) {
72
90
  asserts.forEach(function (_ref) {
73
91
  var field = _ref.field;
@@ -86,7 +104,7 @@ var Element = function Element(props) {
86
104
  });
87
105
  }
88
106
 
89
- if (shouldRender) {
107
+ if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
90
108
  dependentField.push('SUBSCRIBE_ALL');
91
109
  }
92
110
 
@@ -94,6 +112,15 @@ var Element = function Element(props) {
94
112
  dependentField.push(dependField);
95
113
  }
96
114
 
115
+ if (Array.isArray(disabled)) {
116
+ disabled.forEach(function (_ref3) {
117
+ var field = _ref3.field;
118
+ return dependentField.push(field);
119
+ });
120
+ } else if (_typeof(disabled) === 'object') {
121
+ dependentField.push(disabled.field);
122
+ }
123
+
97
124
  registerDependencies(dependentField, dispatch);
98
125
  }, []);
99
126
  var extraConfig = useMemo(function () {
@@ -215,14 +242,14 @@ var Element = function Element(props) {
215
242
  xs: 0
216
243
  }
217
244
  }, {
218
- children: [label && _jsx(_Col, Object.assign({
245
+ children: [(previewLabel || label) && _jsx(_Col, Object.assign({
219
246
  span: 12,
220
247
  md: 12,
221
248
  sm: 24,
222
249
  xs: 24,
223
250
  className: "igloo-element-preview-label"
224
251
  }, {
225
- children: label
252
+ children: previewLabel || label
226
253
  }), void 0), _jsxs(_Col, Object.assign({
227
254
  span: label ? 12 : 24,
228
255
  md: label ? 12 : 24,
@@ -24,7 +24,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
25
  import { useContext, useEffect, cloneElement, isValidElement, useMemo, useReducer } from 'react';
26
26
  import Button from '../../button';
27
- import { calcNamePath } from '../utils';
27
+ import { calcNamePath } from '../../utils/form-utils';
28
28
  import FormContext from '../context';
29
29
  import { LocaleContext } from '../../locale';
30
30
  import Typography from '../../typography';
@@ -110,7 +110,12 @@ PhoneNumber.formItemPropsHandler = function (_ref2) {
110
110
  id: 'Numbers only, please omit " " or "-".'
111
111
  }));
112
112
  }
113
- }]
113
+ }],
114
+ previewFormater: function previewFormater(_ref3) {
115
+ var areaCode = _ref3.areaCode,
116
+ phoneNumber = _ref3.phoneNumber;
117
+ return "".concat(areaCode).concat(phoneNumber);
118
+ }
114
119
  };
115
120
  };
116
121
 
@@ -6,6 +6,7 @@ export declare const Option: import("rc-select/lib/Option").OptionFC, OptGroup:
6
6
  declare type Props = SelectProps<SelectValue> & IglooComponentProps & {
7
7
  getOptions?: (form: FormInstance) => any[];
8
8
  multiple?: boolean;
9
+ clearWhenOptionsUpdated?: boolean;
9
10
  };
10
11
  declare type OptionType = typeof Option;
11
12
  declare type OptGroupType = typeof OptGroup;
@@ -1,6 +1,6 @@
1
1
  import "antd/es/select/style";
2
2
  import _Select from "antd/es/select";
3
- var _excluded = ["options", "getOptions", "value", "className", "placeholder", "onDropdownVisibleChange", "children", "showSearch", "filterOption", "optionFilterProp", "multiple"];
3
+ var _excluded = ["options", "getOptions", "value", "className", "placeholder", "onDropdownVisibleChange", "children", "showSearch", "filterOption", "optionFilterProp", "multiple", "clearWhenOptionsUpdated"];
4
4
 
5
5
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
6
 
@@ -54,6 +54,8 @@ var IglooSelect = function IglooSelect(_ref) {
54
54
  filterOption = _ref.filterOption,
55
55
  optionFilterProp = _ref.optionFilterProp,
56
56
  multiple = _ref.multiple,
57
+ _ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
58
+ clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
57
59
  rest = _objectWithoutProperties(_ref, _excluded);
58
60
 
59
61
  var _useContext = useContext(LocaleContext),
@@ -127,6 +129,11 @@ var IglooSelect = function IglooSelect(_ref) {
127
129
  if (updateOptions) {
128
130
  setOriginOptions(options);
129
131
  setDisplay(options);
132
+ var setFieldValue = rest.setFieldValue;
133
+
134
+ if (clearWhenOptionsUpdated) {
135
+ typeof setFieldValue === 'function' && setFieldValue();
136
+ }
130
137
  }
131
138
  }, [options]);
132
139
  useEffect(function () {
package/es/types.d.ts CHANGED
@@ -86,12 +86,14 @@ export interface FormItemExtraConfig extends FormItemProps {
86
86
  disableEditButton?: boolean;
87
87
  hidePreviewDivider?: boolean;
88
88
  valueFormater?: (value: any) => any;
89
+ subscribedFields?: FormItemName[];
89
90
  [key: string]: any;
90
91
  }
91
92
  export interface FormItemConfig extends FormItemExtraConfig {
92
93
  type?: string;
93
94
  name?: NamePath;
94
95
  label?: string | React.ReactNode;
96
+ previewLabel?: string | React.ReactNode;
95
97
  labelProps?: any;
96
98
  contentProps?: any;
97
99
  }
@@ -1 +1 @@
1
- export default ['containerRef', 'setFieldError', 'setFieldValue', 'setShowStepButton', 'locales', 'getFormInstance', 'hideWhenPreview', 'validateField'];
1
+ export default ['containerRef', 'setFieldError', 'setFieldValue', 'setShowStepButton', 'locales', 'getFormInstance', 'hideWhenPreview', 'validateField', 'subscribedFields'];
@@ -35,6 +35,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
35
35
  };
36
36
  normalize: ((value: any, prevValue: any, allValues: import("rc-field-form/lib/interface").Store) => any) | undefined;
37
37
  rules: import("rc-field-form/lib/interface").Rule[];
38
+ validateTrigger: string[];
38
39
  label: JSX.Element | null;
39
40
  getValueFromEvent: ((...args: import("rc-field-form/lib/interface").EventArgs) => any) | undefined;
40
41
  getValueProps: ((value: any) => object) | undefined;
@@ -1,4 +1,4 @@
1
- var _excluded = ["type", "name", "required", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater"],
1
+ var _excluded = ["type", "name", "required", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "previewLabel", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater"],
2
2
  _excluded2 = ["initialValue", "normalize", "rules", "extra", "help", "getValueFromEvent", "span", "valuePropName", "fullRow", "halfRow", "messageVariables", "requiredMessage", "previewFormater", "valueFormater", "required", "requiredMark", "className"];
3
3
 
4
4
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -111,6 +111,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
111
111
  extra = config.extra,
112
112
  help = config.help,
113
113
  label = config.label,
114
+ previewLabel = config.previewLabel,
114
115
  extraLabel = config.extraLabel,
115
116
  copyValue = config.copyValue,
116
117
  selectValue = config.selectValue,
@@ -169,6 +170,14 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
169
170
  rules.push.apply(rules, _toConsumableArray(extraRules));
170
171
  }
171
172
 
173
+ var validateTriggers = ['onChange'];
174
+ rules.forEach(function (_ref) {
175
+ var validateTrigger = _ref.validateTrigger;
176
+
177
+ if (validateTrigger) {
178
+ Array.isArray(validateTrigger) ? validateTriggers.push.apply(validateTriggers, _toConsumableArray(validateTrigger)) : validateTriggers.push(validateTrigger);
179
+ }
180
+ });
172
181
  var isRequired = required || rules.find(function (rule) {
173
182
  return rule.required;
174
183
  });
@@ -196,6 +205,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
196
205
  selectedValue: selectedValue,
197
206
  normalize: normalize || extraNormalize,
198
207
  rules: rules,
208
+ validateTrigger: _toConsumableArray(new Set(validateTriggers)),
199
209
  label: label ? _jsxs("div", Object.assign({
200
210
  className: "igloo-form-label"
201
211
  }, {
@@ -88,7 +88,7 @@ var Import = function Import(_ref) {
88
88
  customRequest: function customRequest() {},
89
89
  action: function action(file) {
90
90
  var dataSourceId = currentSource;
91
- setSource(undefined);
91
+ Array.isArray(dataSource) && setSource(undefined);
92
92
  return onUpload(file, dataSourceId);
93
93
  }
94
94
  }, {
@@ -139,6 +139,7 @@
139
139
  .igloo-admin-upload-dragger-switch {
140
140
  min-width: 224px;
141
141
  margin-top: 16px;
142
+ text-align: left;
142
143
  }
143
144
 
144
145
  .igloo-admin-upload-dargger-title {
@@ -27,7 +27,7 @@ var _react = require("react");
27
27
 
28
28
  var _icons = require("@ant-design/icons");
29
29
 
30
- var _utils = require("../utils");
30
+ var _formUtils = require("../../utils/form-utils");
31
31
 
32
32
  var _section = _interopRequireDefault(require("../section"));
33
33
 
@@ -58,6 +58,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
58
58
 
59
59
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
60
60
 
61
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
62
+
63
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
64
+
65
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
66
+
67
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
68
+
69
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
70
+
61
71
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
62
72
 
63
73
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -80,7 +90,7 @@ var Element = function Element(_ref) {
80
90
  setShowStepButton = _ref.setShowStepButton;
81
91
  var type = config.type,
82
92
  label = config.label,
83
- render = config.render;
93
+ previewLabel = config.previewLabel;
84
94
 
85
95
  var _useContext = (0, _react.useContext)(_context.default),
86
96
  form = _useContext.form,
@@ -100,9 +110,17 @@ var Element = function Element(_ref) {
100
110
  copyValue = config.copyValue,
101
111
  selectValue = config.selectValue,
102
112
  shouldRender = config.shouldRender,
103
- dependField = config.dependField;
113
+ dependField = config.dependField,
114
+ getOptions = config.getOptions,
115
+ subscribedFields = config.subscribedFields,
116
+ disabled = config.disabled,
117
+ extraLabel = config.extraLabel;
104
118
  var dependentField = dependencies || [];
105
119
 
120
+ if (Array.isArray(subscribedFields)) {
121
+ dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
122
+ }
123
+
106
124
  if (asserts && asserts.length) {
107
125
  asserts.forEach(function (_ref2) {
108
126
  var field = _ref2.field;
@@ -121,7 +139,7 @@ var Element = function Element(_ref) {
121
139
  });
122
140
  }
123
141
 
124
- if (shouldRender) {
142
+ if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
125
143
  dependentField.push('SUBSCRIBE_ALL');
126
144
  }
127
145
 
@@ -129,6 +147,15 @@ var Element = function Element(_ref) {
129
147
  dependentField.push(dependField);
130
148
  }
131
149
 
150
+ if (Array.isArray(disabled)) {
151
+ disabled.forEach(function (_ref4) {
152
+ var field = _ref4.field;
153
+ return dependentField.push(field);
154
+ });
155
+ } else if (_typeof(disabled) === 'object') {
156
+ dependentField.push(disabled.field);
157
+ }
158
+
132
159
  registerDependencies(dependentField, dispatch);
133
160
  }, []);
134
161
  (0, _invariant.default)(type !== 'Pages' && type !== 'Page', "".concat(type, " should not be inner form item"));
@@ -144,11 +171,14 @@ var Element = function Element(_ref) {
144
171
  if (type === 'Section') {
145
172
  return (0, _jsxRuntime.jsx)(_section.default, {
146
173
  parentName: parentName,
147
- config: config
174
+ config: config,
175
+ preview: preview,
176
+ disabled: disabled,
177
+ setShowStepButton: setShowStepButton
148
178
  }, void 0);
149
179
  }
150
180
 
151
- var _calcFormItemProps = (0, _utils.calcFormItemProps)(config, _objectSpread(_objectSpread({}, extraConfig), {}, {
181
+ var _calcFormItemProps = (0, _formUtils.calcFormItemProps)(config, _objectSpread(_objectSpread({}, extraConfig), {}, {
152
182
  requiredMark: requiredMark
153
183
  }), form, parentName),
154
184
  colProps = _calcFormItemProps.colProps,
@@ -274,14 +304,14 @@ var Element = function Element(_ref) {
274
304
  xs: 0
275
305
  }
276
306
  }, {
277
- children: [label && (0, _jsxRuntime.jsx)(_col.default, Object.assign({
307
+ children: [(previewLabel || label) && (0, _jsxRuntime.jsx)(_col.default, Object.assign({
278
308
  span: 12,
279
309
  md: 12,
280
310
  sm: 24,
281
311
  xs: 24,
282
312
  className: "igloo-element-preview-label"
283
313
  }, {
284
- children: label
314
+ children: previewLabel || label
285
315
  }), void 0), (0, _jsxRuntime.jsxs)(_col.default, Object.assign({
286
316
  span: label ? 12 : 24,
287
317
  md: label ? 12 : 24,
@@ -27,7 +27,7 @@ var _react = require("react");
27
27
 
28
28
  var _element = _interopRequireDefault(require("../element"));
29
29
 
30
- var _utils = require("../utils");
30
+ var _formUtils = require("../../utils/form-utils");
31
31
 
32
32
  var _context = _interopRequireDefault(require("../context"));
33
33
 
@@ -69,7 +69,7 @@ var Login = function Login(_ref) {
69
69
  }, {
70
70
  children: elements.map(function (child, index) {
71
71
  return (0, _jsxRuntime.jsx)(_element.default, {
72
- parentName: (0, _utils.calcNamePath)(parentName, name),
72
+ parentName: (0, _formUtils.calcNamePath)(parentName, name),
73
73
  config: child
74
74
  }, index);
75
75
  })