iglooform 3.1.4 → 3.1.6

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 (80) hide show
  1. package/.dumi/tmp/core/defineApp.ts +1 -1
  2. package/.dumi/tmp/core/helmet.ts +1 -1
  3. package/.dumi/tmp/core/history.ts +1 -1
  4. package/.dumi/tmp/core/historyIntelli.ts +1 -1
  5. package/.dumi/tmp/core/plugin.ts +2 -2
  6. package/.dumi/tmp/core/polyfill.ts +197 -197
  7. package/.dumi/tmp/core/route.tsx +33 -33
  8. package/.dumi/tmp/dumi/exports.ts +1 -1
  9. package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
  10. package/.dumi/tmp/dumi/meta/index.ts +33 -33
  11. package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
  12. package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
  13. package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
  14. package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
  15. package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
  16. package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
  17. package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
  18. package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
  19. package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
  20. package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
  21. package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
  22. package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
  23. package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
  24. package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
  25. package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
  26. package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
  27. package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
  28. package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
  29. package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
  30. package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
  31. package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
  32. package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
  33. package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
  34. package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
  35. package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
  36. package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
  37. package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
  38. package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
  39. package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
  40. package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
  41. package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
  42. package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
  43. package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
  44. package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
  45. package/.dumi/tmp/exports.ts +5 -5
  46. package/.dumi/tmp/testBrowser.tsx +3 -3
  47. package/.dumi/tmp/umi.ts +4 -4
  48. package/.idea/iglooform.iml +9 -0
  49. package/.idea/misc.xml +5 -0
  50. package/.idea/modules.xml +8 -0
  51. package/.idea/vcs.xml +6 -0
  52. package/es/confirmation/style/index.d.ts +1 -0
  53. package/es/form/addable-section/index.js +18 -7
  54. package/es/form/element/index.js +3 -2
  55. package/es/form/hsteps/index.js +4 -3
  56. package/es/form/steps/index.js +3 -2
  57. package/es/free-form/addable-section/index.js +33 -10
  58. package/es/free-form/element/index.js +4 -2
  59. package/es/free-form/step/index.js +1 -1
  60. package/es/media/file-icon.d.ts +9 -0
  61. package/es/ocr/micro-blink/style/index.d.ts +1 -0
  62. package/es/types.d.ts +1 -0
  63. package/es/utils/form-utils.d.ts +3 -2
  64. package/es/utils/form-utils.js +84 -16
  65. package/es/utils/option-utils.js +18 -12
  66. package/lib/confirmation/style/index.d.ts +1 -0
  67. package/lib/form/addable-section/index.js +18 -7
  68. package/lib/form/element/index.js +3 -2
  69. package/lib/form/hsteps/index.js +4 -3
  70. package/lib/form/steps/index.js +3 -2
  71. package/lib/free-form/addable-section/index.js +32 -9
  72. package/lib/free-form/element/index.js +4 -2
  73. package/lib/free-form/step/index.js +1 -1
  74. package/lib/media/file-icon.d.ts +9 -0
  75. package/lib/ocr/micro-blink/style/index.d.ts +1 -0
  76. package/lib/types.d.ts +1 -0
  77. package/lib/utils/form-utils.d.ts +3 -2
  78. package/lib/utils/form-utils.js +86 -17
  79. package/lib/utils/option-utils.js +18 -12
  80. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/iglooform.iml" filepath="$PROJECT_DIR$/.idea/iglooform.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -18,7 +18,7 @@ import React, { useReducer, useContext, useCallback } from 'react';
18
18
  import { Col, Divider, Row, Grid } from 'antd';
19
19
  import Element from "../element";
20
20
  import FormContext from "../../form-context";
21
- import { calcNamePath, calcFormItemProps } from "../../utils/form-utils";
21
+ import { calcNamePath, calcFormItemProps, calcAddableSectionAssertField } from "../../utils/form-utils";
22
22
  import Typography from "../../typography";
23
23
  import Button from "../../button";
24
24
  import { LocaleContext } from "../../locale";
@@ -153,25 +153,36 @@ var AddableSection = function AddableSection(_ref) {
153
153
  },
154
154
  children: /*#__PURE__*/_jsx(Row, {
155
155
  gutter: [32, preview ? 16 : 24],
156
- children: elements.map(function (child, index) {
156
+ children: elements.map(function (child, _index) {
157
157
  var _child = _objectSpread({}, child);
158
158
  if (Array.isArray(child.asserts)) {
159
159
  _child.asserts = child.asserts.map(function (assert) {
160
160
  return _objectSpread(_objectSpread({}, assert), {}, {
161
- field: calcNamePath(parentName, assert.field)
161
+ field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
162
162
  });
163
163
  });
164
164
  }
165
165
  if (Array.isArray(child.requiredAsserts)) {
166
166
  _child.requiredAsserts = child.requiredAsserts.map(function (assert) {
167
167
  return _objectSpread(_objectSpread({}, assert), {}, {
168
- field: calcNamePath(parentName, assert.field)
168
+ field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
169
169
  });
170
170
  });
171
171
  }
172
+ if (Array.isArray(child.disabled)) {
173
+ _child.disabled = child.disabled.map(function (assert) {
174
+ return _objectSpread(_objectSpread({}, assert), {}, {
175
+ field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
176
+ });
177
+ });
178
+ } else if (_typeof(child.disabled) === 'object') {
179
+ _child.disabled = _objectSpread(_objectSpread({}, child.disabled), {}, {
180
+ field: calcAddableSectionAssertField(namePath, child.disabled.field, index, elements)
181
+ });
182
+ }
172
183
  if (Array.isArray(child.dependencies)) {
173
184
  _child.dependencies = child.dependencies.map(function (path) {
174
- return calcNamePath(parentName, path);
185
+ return calcAddableSectionAssertField(namePath, path, index, elements);
175
186
  });
176
187
  }
177
188
  return /*#__PURE__*/_jsx(Element, {
@@ -180,11 +191,11 @@ var AddableSection = function AddableSection(_ref) {
180
191
  disabled: elementProps.disabled || disabled,
181
192
  preview: preview,
182
193
  setShowStepButton: setShowStepButton
183
- }, index);
194
+ }, _index);
184
195
  })
185
196
  })
186
197
  }))]
187
- }, key);
198
+ }, key + index);
188
199
  });
189
200
  return /*#__PURE__*/_jsxs("div", {
190
201
  className: "igloo-form-addable-section-container",
@@ -68,7 +68,8 @@ var Element = function Element(_ref) {
68
68
  disabled = config.disabled,
69
69
  extraLabel = config.extraLabel,
70
70
  requiredAsserts = config.requiredAsserts,
71
- shouldRenderCode = config.shouldRenderCode;
71
+ shouldRenderCode = config.shouldRenderCode,
72
+ disabledCode = config.disabledCode;
72
73
  var dependentField = dependencies || [];
73
74
  if (Array.isArray(subscribedFields)) {
74
75
  dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
@@ -94,7 +95,7 @@ var Element = function Element(_ref) {
94
95
  return dependentField.push(assert.field);
95
96
  });
96
97
  }
97
- if ((shouldRender || shouldRenderCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
98
+ if ((shouldRender || shouldRenderCode || disabledCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
98
99
  dependentField.push('SUBSCRIBE_ALL');
99
100
  }
100
101
  if (dependField) {
@@ -76,6 +76,7 @@ var HSteps = function HSteps(_ref) {
76
76
  var _useContext2 = useContext(LocaleContext),
77
77
  formatMessage = _useContext2.formatMessage,
78
78
  currentLang = _useContext2.currentLang;
79
+ var _parentName = calcNamePath(parentName, name);
79
80
  useEffect(function () {
80
81
  var subscribe = elements.some(function (_ref2) {
81
82
  var shouldRender = _ref2.shouldRender,
@@ -111,7 +112,7 @@ var HSteps = function HSteps(_ref) {
111
112
  shouldRenderCode = _ref5.shouldRenderCode;
112
113
  invariant(type === 'Step', 'Child of steps should be Step');
113
114
  invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
114
- return calcShouldRender(calcNamePath(calcNamePath(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
115
+ return calcShouldRender(calcNamePath(_parentName, curName), _parentName, dependencies, asserts, shouldRender, shouldRenderCode, form);
115
116
  });
116
117
  var handleNext = /*#__PURE__*/function () {
117
118
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -270,7 +271,7 @@ var HSteps = function HSteps(_ref) {
270
271
  },
271
272
  children: /*#__PURE__*/_jsx(HStep, {
272
273
  config: renderElements[current],
273
- parentName: calcNamePath(parentName, name),
274
+ parentName: _parentName,
274
275
  index: current,
275
276
  total: withReview ? renderElements.length + 1 : renderElements.length,
276
277
  preview: false,
@@ -300,7 +301,7 @@ var HSteps = function HSteps(_ref) {
300
301
  }), renderElements.map(function (step, index) {
301
302
  return /*#__PURE__*/_jsx(HStep, {
302
303
  config: step,
303
- parentName: calcNamePath(parentName, name),
304
+ parentName: _parentName,
304
305
  index: index,
305
306
  total: withReview ? renderElements.length + 1 : renderElements.length,
306
307
  preview: true,
@@ -53,6 +53,7 @@ var Steps = function Steps(_ref) {
53
53
  registerDependencies = _useContext.registerDependencies;
54
54
  var _useContext2 = useContext(LocaleContext),
55
55
  currentLang = _useContext2.currentLang;
56
+ var _parentName = calcNamePath(parentName, name);
56
57
  useEffect(function () {
57
58
  var subscribe = elements.some(function (_ref2) {
58
59
  var shouldRender = _ref2.shouldRender,
@@ -84,7 +85,7 @@ var Steps = function Steps(_ref) {
84
85
  asserts = _ref5.asserts,
85
86
  shouldRender = _ref5.shouldRender,
86
87
  shouldRenderCode = _ref5.shouldRenderCode;
87
- return calcShouldRender(calcNamePath(calcNamePath(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
88
+ return calcShouldRender(calcNamePath(_parentName, curName), _parentName, dependencies, asserts, shouldRender, shouldRenderCode, form);
88
89
  });
89
90
  var handleNext = /*#__PURE__*/function () {
90
91
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -197,7 +198,7 @@ var Steps = function Steps(_ref) {
197
198
  },
198
199
  children: /*#__PURE__*/_jsx(Step, {
199
200
  config: child,
200
- parentName: calcNamePath(parentName, name),
201
+ parentName: _parentName,
201
202
  index: index,
202
203
  total: renderElements.length,
203
204
  preview: current > index,
@@ -17,7 +17,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  import React, { useReducer, useContext, useEffect, useCallback, cloneElement, isValidElement } from 'react';
18
18
  import { Col, Row } from 'antd';
19
19
  import FormContext from "../../form-context";
20
- import { calcNamePath, calcFormItemProps } from "../../utils/form-utils";
20
+ import { calcNamePath, calcFormItemProps, calcAddableSectionAssertField } from "../../utils/form-utils";
21
21
  import Typography from "../../typography";
22
22
  import Button from "../../button";
23
23
  import { LocaleContext } from "../../locale";
@@ -156,32 +156,44 @@ var AddableSection = function AddableSection(props) {
156
156
  }]);
157
157
  }
158
158
  var transformChildren = function transformChildren(parentName) {
159
+ var index = parentName[parentName.length - 1];
159
160
  if (Array.isArray(children)) {
160
- return children.map(function (c, index) {
161
+ return children.map(function (c, _index) {
161
162
  var _c$type;
162
163
  var _child = _objectSpread({}, c.props);
163
164
  if (Array.isArray(_child.asserts)) {
164
165
  _child.asserts = _child.asserts.map(function (assert) {
165
166
  return _objectSpread(_objectSpread({}, assert), {}, {
166
- field: calcNamePath(parentName, assert.field)
167
+ field: calcAddableSectionAssertField(namePath, assert.field, index, children)
167
168
  });
168
169
  });
169
170
  }
170
171
  if (Array.isArray(_child.requiredAsserts)) {
171
172
  _child.requiredAsserts = _child.requiredAsserts.map(function (assert) {
172
173
  return _objectSpread(_objectSpread({}, assert), {}, {
173
- field: calcNamePath(parentName, assert.field)
174
+ field: calcAddableSectionAssertField(namePath, assert.field, index, children)
174
175
  });
175
176
  });
176
177
  }
178
+ if (Array.isArray(_child.disabled)) {
179
+ _child.disabled = _child.disabled.map(function (assert) {
180
+ return _objectSpread(_objectSpread({}, assert), {}, {
181
+ field: calcAddableSectionAssertField(namePath, assert.field, index, children)
182
+ });
183
+ });
184
+ } else if (_typeof(_child.disabled) === 'object') {
185
+ _child.disabled = _objectSpread(_objectSpread({}, _child.disabled), {}, {
186
+ field: calcAddableSectionAssertField(namePath, _child.disabled.field, index, children)
187
+ });
188
+ }
177
189
  if (Array.isArray(_child.dependencies)) {
178
190
  _child.dependencies = _child.dependencies.map(function (path) {
179
- return calcNamePath(parentName, path);
191
+ return calcAddableSectionAssertField(namePath, path, index, children);
180
192
  });
181
193
  }
182
194
  if (['Igloo_Free_Form_Item', 'Igloo_Free_Form_Section', 'Igloo_Free_Form_AddableSection'].includes(c === null || c === void 0 ? void 0 : (_c$type = c.type) === null || _c$type === void 0 ? void 0 : _c$type.displayName)) {
183
195
  return /*#__PURE__*/cloneElement(c, _objectSpread(_objectSpread({
184
- key: index
196
+ key: _index
185
197
  }, _child), {}, {
186
198
  parentName: parentName,
187
199
  setShowStepButton: setShowStepButton,
@@ -197,20 +209,31 @@ var AddableSection = function AddableSection(props) {
197
209
  if (Array.isArray(_child.asserts)) {
198
210
  _child.asserts = _child.asserts.map(function (assert) {
199
211
  return _objectSpread(_objectSpread({}, assert), {}, {
200
- field: calcNamePath(parentName, assert.field)
212
+ field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
201
213
  });
202
214
  });
203
215
  }
204
216
  if (Array.isArray(_child.requiredAsserts)) {
205
217
  _child.requiredAsserts = _child.requiredAsserts.map(function (assert) {
206
218
  return _objectSpread(_objectSpread({}, assert), {}, {
207
- field: calcNamePath(parentName, assert.field)
219
+ field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
208
220
  });
209
221
  });
210
222
  }
223
+ if (Array.isArray(_child.disabled)) {
224
+ _child.disabled = _child.disabled.map(function (assert) {
225
+ return _objectSpread(_objectSpread({}, assert), {}, {
226
+ field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
227
+ });
228
+ });
229
+ } else if (_typeof(_child.disabled) === 'object') {
230
+ _child.disabled = _objectSpread(_objectSpread({}, _child.disabled), {}, {
231
+ field: calcAddableSectionAssertField(namePath, _child.disabled.field, index, [children])
232
+ });
233
+ }
211
234
  if (Array.isArray(_child.dependencies)) {
212
235
  _child.dependencies = _child.dependencies.map(function (path) {
213
- return calcNamePath(parentName, path);
236
+ return calcAddableSectionAssertField(namePath, path, index, [children]);
214
237
  });
215
238
  }
216
239
  return /*#__PURE__*/cloneElement(children, _objectSpread(_objectSpread({}, _child), {}, {
@@ -266,7 +289,7 @@ var AddableSection = function AddableSection(props) {
266
289
  children: transformChildren(parentName)
267
290
  })
268
291
  }))]
269
- }, key);
292
+ }, key + index);
270
293
  });
271
294
  return /*#__PURE__*/_jsxs("div", {
272
295
  className: "igloo-addable-section-container",
@@ -61,7 +61,9 @@ var Element = function Element(props) {
61
61
  subscribedFields = props.subscribedFields,
62
62
  extraLabel = props.extraLabel,
63
63
  disabled = props.disabled,
64
- requiredAsserts = props.requiredAsserts;
64
+ requiredAsserts = props.requiredAsserts,
65
+ shouldRenderCode = props.shouldRenderCode,
66
+ disabledCode = props.disabledCode;
65
67
  var dependentField = dependencies || [];
66
68
  if (Array.isArray(subscribedFields)) {
67
69
  dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
@@ -87,7 +89,7 @@ var Element = function Element(props) {
87
89
  return dependentField.push(assert.field);
88
90
  });
89
91
  }
90
- if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
92
+ if ((shouldRender || shouldRenderCode || disabledCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
91
93
  dependentField.push('SUBSCRIBE_ALL');
92
94
  }
93
95
  if (dependField) {
@@ -210,7 +210,7 @@ var Step = function Step(_ref) {
210
210
  return _ref3.apply(this, arguments);
211
211
  };
212
212
  }();
213
- if (!calcShouldRender(pName, dependencies, asserts, shouldRender, shouldRenderCode, form)) {
213
+ if (!calcShouldRender(pName, parentName, dependencies, asserts, shouldRender, shouldRenderCode, form)) {
214
214
  return null;
215
215
  }
216
216
  return /*#__PURE__*/_jsxs("div", {
@@ -0,0 +1,9 @@
1
+ import type { FC } from 'react';
2
+ import './style/file-icon.less';
3
+ type Props = {
4
+ type: string;
5
+ onDownloadClick?: () => void;
6
+ disabledDownload?: boolean;
7
+ };
8
+ declare const FileIcon: FC<Props>;
9
+ export default FileIcon;
@@ -0,0 +1 @@
1
+ import './index.less';
package/es/types.d.ts CHANGED
@@ -146,6 +146,7 @@ export interface FormItemExtraConfig extends FormItemProps {
146
146
  idType?: 'KTP' | 'NIK';
147
147
  validationRule?: string;
148
148
  shouldRenderCode?: string;
149
+ disabledCode?: string;
149
150
  [key: string]: any;
150
151
  }
151
152
  export interface FormItemConfig extends FormItemExtraConfig {
@@ -54,7 +54,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
54
54
  display: any;
55
55
  previewFormater: ((value: any, form?: FormInstance<any> | undefined) => any) | undefined;
56
56
  };
57
- export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[], form?: FormInstance) => boolean;
57
+ export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[], form?: FormInstance, disabledCode?: string, name?: FormItemName, parentName?: FormItemName) => any;
58
58
  export declare const calcCopyValue: (copyValue?: FormItemCopyValue, form?: FormInstance) => {
59
59
  copied: boolean;
60
60
  value?: undefined;
@@ -73,5 +73,6 @@ export declare const calcSelectValue: (selectValue?: FormItemSelectValue[], form
73
73
  value: any;
74
74
  disabled: boolean | undefined;
75
75
  };
76
- export declare const calcShouldRender: (name: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
76
+ export declare const calcShouldRender: (name: NamePath, parentName: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
77
77
  export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
78
+ export declare const calcAddableSectionAssertField: (name: any[], field: FormItemAssert['field'], index: number, elements: FormItemConfig[] | React.ReactElement[]) => any;
@@ -1,5 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["type", "name", "required", "requiredAsserts", "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", "antdDependencies", "dateLimitationType", "absoluteRangeEnd", "absoluteRangeStart", "relativeRangeStart", "relativeRangeEnd", "validationCode", "shouldRenderCode"],
2
+ var _excluded = ["type", "name", "required", "requiredAsserts", "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", "antdDependencies", "dateLimitationType", "absoluteRangeEnd", "absoluteRangeStart", "relativeRangeStart", "relativeRangeEnd", "validationCode", "shouldRenderCode", "disabledCode"],
3
3
  _excluded2 = ["initialValue", "normalize", "rules", "extra", "help", "getValueFromEvent", "span", "valuePropName", "fullRow", "halfRow", "messageVariables", "requiredMessage", "previewFormater", "valueFormater", "required", "requiredMark", "className"];
4
4
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
5
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -23,6 +23,7 @@ import invariant from 'invariant';
23
23
  import Typography from "../typography";
24
24
  import FormattedMessage from "../locale/formatted-message";
25
25
  import moment from 'dayjs';
26
+ import { get } from 'lodash';
26
27
  import { jsx as _jsx } from "react/jsx-runtime";
27
28
  import { jsxs as _jsxs } from "react/jsx-runtime";
28
29
  export var calcNamePath = function calcNamePath(parentName, name) {
@@ -171,6 +172,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
171
172
  _config$validationCod = config.validationCode,
172
173
  validationCode = _config$validationCod === void 0 ? [] : _config$validationCod,
173
174
  shouldRenderCode = config.shouldRenderCode,
175
+ disabledCode = config.disabledCode,
174
176
  rest = _objectWithoutProperties(config, _excluded);
175
177
  invariant(nameProp !== undefined || type === 'Divider' || type === 'Section' || type === 'Typography' || type === 'OCR' || !type, "name property is required for form item config (type: ".concat(type, ")"));
176
178
  invariant(!previewFormater || typeof previewFormater === 'function', 'previewFormater property should be a function');
@@ -222,7 +224,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
222
224
  Object.keys(_objectSpread(_objectSpread({}, extraRest), rest)).forEach(function (key) {
223
225
  elementProps[key.replace('element-', '')] = rest[key];
224
226
  });
225
- elementProps.disabled = calcDisabled(disabled, form) || copiedValue.disabled || selectedValue.disabled;
227
+ elementProps.disabled = calcDisabled(disabled, form, disabledCode, name, parentName) || copiedValue.disabled || selectedValue.disabled;
226
228
  if (dateLimitationType) {
227
229
  var rangeStart;
228
230
  var rangeEnd;
@@ -303,8 +305,12 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
303
305
  var fn = eval(code);
304
306
  var formValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
305
307
  var _result2 = fn(value, formValues, {
306
- moment: moment
307
- }, validationCodeExtraParams);
308
+ moment: moment,
309
+ get: get
310
+ }, _objectSpread({
311
+ name: name,
312
+ parentName: parentName
313
+ }, validationCodeExtraParams));
308
314
  return _result2 ? Promise.resolve() : Promise.reject(errorMessage);
309
315
  } catch (_unused) {
310
316
  return Promise.reject(errorMessage);
@@ -366,12 +372,31 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
366
372
  dependencies: antdDependencies
367
373
  },
368
374
  elementProps: elementProps,
369
- display: !ignore && calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
375
+ display: !ignore && calcShouldRender(name, parentName, dependencies, asserts, shouldRender, shouldRenderCode, form),
370
376
  previewFormater: previewFormater || extraPreviewFormater
371
377
  };
372
378
  };
373
- export var calcDisabled = function calcDisabled(disabled, form) {
374
- if (!form || !disabled) return false;
379
+ export var calcDisabled = function calcDisabled(disabled, form, disabledCode, name, parentName) {
380
+ if (!form) return false;
381
+ if (disabledCode) {
382
+ var fn = eval(disabledCode);
383
+ if (typeof fn === 'function') {
384
+ try {
385
+ var value = form.getFieldValue(name);
386
+ var values = form.getFieldsValue(true);
387
+ return fn(value, values, {
388
+ moment: moment,
389
+ get: get
390
+ }, {
391
+ name: name,
392
+ parentName: parentName
393
+ });
394
+ } catch (_unused2) {
395
+ return false;
396
+ }
397
+ }
398
+ }
399
+ if (!disabled) return false;
375
400
  if (typeof disabled === 'boolean') return disabled;
376
401
  if (Array.isArray(disabled)) {
377
402
  var _iterator = _createForOfIteratorHelper(disabled),
@@ -443,12 +468,12 @@ export var calcSelectValue = function calcSelectValue(selectValue, form) {
443
468
  selected: false
444
469
  };
445
470
  };
446
- export var calcShouldRender = function calcShouldRender(name) {
447
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
448
- var asserts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
449
- var shouldRender = arguments.length > 3 ? arguments[3] : undefined;
450
- var shouldRenderCode = arguments.length > 4 ? arguments[4] : undefined;
451
- var form = arguments.length > 5 ? arguments[5] : undefined;
471
+ export var calcShouldRender = function calcShouldRender(name, parentName) {
472
+ var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
473
+ var asserts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
474
+ var shouldRender = arguments.length > 4 ? arguments[4] : undefined;
475
+ var shouldRenderCode = arguments.length > 5 ? arguments[5] : undefined;
476
+ var form = arguments.length > 6 ? arguments[6] : undefined;
452
477
  if (!form) return true;
453
478
  var _iterator3 = _createForOfIteratorHelper(dependencies),
454
479
  _step3;
@@ -474,9 +499,13 @@ export var calcShouldRender = function calcShouldRender(name) {
474
499
  var value = form.getFieldValue(name);
475
500
  var values = form.getFieldsValue(true);
476
501
  return fn(value, values, {
477
- moment: moment
502
+ moment: moment,
503
+ get: get
504
+ }, {
505
+ name: name,
506
+ parentName: parentName
478
507
  });
479
- } catch (_unused2) {
508
+ } catch (_unused3) {
480
509
  return false;
481
510
  }
482
511
  }
@@ -556,4 +585,43 @@ export var getRuleValidation = /*#__PURE__*/function () {
556
585
  return function getRuleValidation(_x, _x2, _x3) {
557
586
  return _ref3.apply(this, arguments);
558
587
  };
559
- }();
588
+ }();
589
+ var isAddableSectionInnerField = function isAddableSectionInnerField(name, field, elements) {
590
+ var start = 0;
591
+ var hit = false;
592
+ while (start < name.length && start < field.length) {
593
+ if (name[start] === field[start]) {
594
+ hit = true;
595
+ start++;
596
+ } else {
597
+ if (hit) return false;
598
+ break;
599
+ }
600
+ }
601
+ if (start === name.length) return true;
602
+ var restField = field.slice(start);
603
+ var _elements = elements;
604
+ var index = 0;
605
+ var isReactElement = elements.some(React.isValidElement);
606
+ while (index < restField.length) {
607
+ var found = _elements.find(function (item) {
608
+ return (isReactElement ? item.props.name : item.name).toString() === restField[index];
609
+ });
610
+ if (!found) return false;
611
+ index++;
612
+ _elements = (isReactElement ? found.props.children : found.elements) || [];
613
+ }
614
+ return true;
615
+ };
616
+
617
+ // 暂时不考虑AddableSection嵌套的场景
618
+ export var calcAddableSectionAssertField = function calcAddableSectionAssertField(name, field, index, elements) {
619
+ var _field = typeof field === 'string' ? field.split('.') : field;
620
+ if (!isAddableSectionInnerField(name, _field, elements)) return field;
621
+ if (!_field.join().startsWith(name.join())) return [].concat(_toConsumableArray(name), [index], _toConsumableArray(_field));
622
+ var _index = _field.findIndex(function (item) {
623
+ return item === name[name.length - 1];
624
+ });
625
+ if (_index === -1) return field;
626
+ return [].concat(_toConsumableArray(name), [index], _toConsumableArray(_field.slice(_index + 1)));
627
+ };
@@ -150,9 +150,15 @@ export function optionsHOC(Component) {
150
150
  return _context.abrupt("return", _options2);
151
151
  case 9:
152
152
  if (!(selectDatasourceApi && datasourceKey)) {
153
- _context.next = 28;
153
+ _context.next = 30;
154
154
  break;
155
155
  }
156
+ if (!(dependField && dependFieldValue === undefined)) {
157
+ _context.next = 12;
158
+ break;
159
+ }
160
+ return _context.abrupt("return", []);
161
+ case 12:
156
162
  query = Array.isArray(dependFieldValue) ? dependFieldValue.map(function (v) {
157
163
  return "parent=".concat(v);
158
164
  }).join('&') : dependFieldValue ? "parent=".concat(dependFieldValue) : '';
@@ -166,28 +172,28 @@ export function optionsHOC(Component) {
166
172
  }).join('&');
167
173
  }
168
174
  api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
169
- _context.prev = 14;
170
- _context.next = 17;
175
+ _context.prev = 16;
176
+ _context.next = 19;
171
177
  return fetch(query ? "".concat(api, "?").concat(query) : api);
172
- case 17:
178
+ case 19:
173
179
  rst = _context.sent;
174
- _context.next = 20;
180
+ _context.next = 22;
175
181
  return rst.json();
176
- case 20:
182
+ case 22:
177
183
  _yield$rst$json = _context.sent;
178
184
  data = _yield$rst$json.data;
179
185
  return _context.abrupt("return", data || []);
180
- case 25:
181
- _context.prev = 25;
182
- _context.t0 = _context["catch"](14);
186
+ case 27:
187
+ _context.prev = 27;
188
+ _context.t0 = _context["catch"](16);
183
189
  return _context.abrupt("return", []);
184
- case 28:
190
+ case 30:
185
191
  return _context.abrupt("return", []);
186
- case 29:
192
+ case 31:
187
193
  case "end":
188
194
  return _context.stop();
189
195
  }
190
- }, _callee, null, [[14, 25]]);
196
+ }, _callee, null, [[16, 27]]);
191
197
  }));
192
198
  return function calcOptions() {
193
199
  return _ref.apply(this, arguments);
@@ -0,0 +1 @@
1
+ import './index.less';