iglooform 3.2.4 → 3.2.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 (70) 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/element/index.js +1 -1
  54. package/es/form/elements.d.ts +1 -2
  55. package/es/form/elements.js +3 -23
  56. package/es/types.d.ts +187 -0
  57. package/es/utils/form-utils.d.ts +1 -1
  58. package/es/utils/form-utils.js +25 -17
  59. package/lib/confirmation/style/index.d.ts +1 -0
  60. package/lib/form/element/index.js +1 -1
  61. package/lib/form/elements.d.ts +1 -2
  62. package/lib/form/elements.js +3 -22
  63. package/lib/types.d.ts +187 -0
  64. package/lib/utils/form-utils.d.ts +1 -1
  65. package/lib/utils/form-utils.js +26 -18
  66. package/package.json +1 -1
  67. package/es/hooks/useWrapperOnChangeForAutomaticCalc.d.ts +0 -5
  68. package/es/hooks/useWrapperOnChangeForAutomaticCalc.js +0 -26
  69. package/lib/hooks/useWrapperOnChangeForAutomaticCalc.d.ts +0 -5
  70. package/lib/hooks/useWrapperOnChangeForAutomaticCalc.js +0 -34
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.testAssert = exports.getRuleValidation = exports.calcShouldRender = exports.calcSelectValue = exports.calcNamePath = exports.calcFormItemProps = exports.calcDisabled = exports.calcCopyValue = exports.calcAutomaticCalculate = exports.calcAddableSectionAssertField = void 0;
7
+ exports.testAssert = exports.getRuleValidation = exports.calcShouldRender = exports.calcSelectValue = exports.calcNamePath = exports.calcFormItemProps = exports.calcDisabled = exports.calcCopyValue = exports.calcAddableSectionAssertField = exports.automaticCalculate = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _invariant = _interopRequireDefault(require("invariant"));
10
10
  var _typography = _interopRequireDefault(require("../typography"));
@@ -330,6 +330,9 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
330
330
  };
331
331
  })));
332
332
  }
333
+ if (enableAutomaticCalc) {
334
+ automaticCalculate(name, parentName, automaticCalcCode, form);
335
+ }
333
336
  return {
334
337
  colProps: {
335
338
  span: extraFullRow && fullRow === undefined || fullRow || extraHalfRow && halfRow === undefined || halfRow ? 24 : span || extraSpan || 12,
@@ -393,9 +396,9 @@ var calcDisabled = function calcDisabled(disabled, form, disabledCode, name, par
393
396
  var fn = eval(disabledCode);
394
397
  if (typeof fn === 'function') {
395
398
  try {
396
- var _value = form.getFieldValue(name);
399
+ var value = form.getFieldValue(name);
397
400
  var values = form.getFieldsValue(true);
398
- return fn(_value, values, {
401
+ return fn(value, values, {
399
402
  moment: _dayjs.default,
400
403
  get: _lodash.get
401
404
  }, {
@@ -462,12 +465,12 @@ var calcSelectValue = function calcSelectValue(selectValue, form) {
462
465
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
463
466
  var select = _step2.value;
464
467
  var assert = select.assert,
465
- _value2 = select.value,
468
+ value = select.value,
466
469
  disabled = select.disabled;
467
470
  if (testAssert(form, assert)) {
468
471
  return {
469
472
  selected: true,
470
- value: _value2,
473
+ value: value,
471
474
  disabled: disabled
472
475
  };
473
476
  }
@@ -510,9 +513,9 @@ var calcShouldRender = function calcShouldRender(name, parentName) {
510
513
  var fn = eval(shouldRenderCode);
511
514
  if (typeof fn === 'function') {
512
515
  try {
513
- var _value3 = form.getFieldValue(name);
516
+ var value = form.getFieldValue(name);
514
517
  var values = form.getFieldsValue(true);
515
- return fn(_value3, values, {
518
+ return fn(value, values, {
516
519
  moment: _dayjs.default,
517
520
  get: _lodash.get
518
521
  }, {
@@ -540,28 +543,33 @@ var calcShouldRender = function calcShouldRender(name, parentName) {
540
543
  return true;
541
544
  };
542
545
  exports.calcShouldRender = calcShouldRender;
543
- var calcAutomaticCalculate = function calcAutomaticCalculate(name, parentName, automaticCalcCode, form, onChange) {
544
- if (!form) return undefined;
545
- if (automaticCalcCode) {
546
+ var automaticCalculate = function automaticCalculate(name, parentName, automaticCalcCode, form) {
547
+ if (form && automaticCalcCode) {
546
548
  var calcValue = undefined;
547
- var fn = eval(automaticCalcCode);
548
- if (typeof fn === 'function') {
549
- try {
550
- var _value4 = form.getFieldValue(name);
549
+ try {
550
+ var fn = eval(automaticCalcCode);
551
+ if (typeof fn === 'function') {
552
+ var value = form.getFieldValue(name);
551
553
  var values = form.getFieldsValue(true);
552
- calcValue = fn(_value4, values, {
554
+ calcValue = fn(value, values, {
553
555
  moment: _dayjs.default,
554
556
  get: _lodash.get
555
557
  }, {
556
558
  name: name,
557
559
  parentName: parentName
558
560
  });
559
- } catch (_unused4) {}
561
+ }
562
+ } catch (_unused4) {}
563
+ if (form && !(0, _lodash.isEqual)(form === null || form === void 0 ? void 0 : form.getFieldValue(name), calcValue)) {
564
+ form.setFields([{
565
+ name: name,
566
+ value: calcValue
567
+ }]);
568
+ form.validateFields([name]);
560
569
  }
561
- onChange === null || onChange === void 0 ? void 0 : onChange(calcValue, true);
562
570
  }
563
571
  };
564
- exports.calcAutomaticCalculate = calcAutomaticCalculate;
572
+ exports.automaticCalculate = automaticCalculate;
565
573
  var getRuleValidation = /*#__PURE__*/function () {
566
574
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, rule, values) {
567
575
  var lang,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",
@@ -1,5 +0,0 @@
1
- import { FormItemConfig } from '../types';
2
- import { NamePath } from 'antd/es/form/interface';
3
- type UseWrapperOnChangeForAutomaticCalcHook = (config: FormItemConfig, parentName: NamePath, onChange: any) => (value: any, automaticCalc?: boolean) => void;
4
- declare const useWrapperOnChangeForAutomaticCalc: UseWrapperOnChangeForAutomaticCalcHook;
5
- export default useWrapperOnChangeForAutomaticCalc;
@@ -1,26 +0,0 @@
1
- import { useUpdateEffect } from '@umijs/hooks';
2
- import { useContext } from 'react';
3
- import { isEqual } from 'lodash';
4
- import { calcAutomaticCalculate } from "../utils/form-utils";
5
- import formContext from "../form-context";
6
- var useWrapperOnChangeForAutomaticCalc = function useWrapperOnChangeForAutomaticCalc(config, parentName, onChange) {
7
- var _useContext = useContext(formContext),
8
- form = _useContext.form;
9
- var name = config.name,
10
- enableAutomaticCalc = config.enableAutomaticCalc,
11
- automaticCalcCode = config.automaticCalcCode;
12
- var handleOnChange = function handleOnChange(value) {
13
- var automaticCalc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
14
- if (automaticCalc && isEqual(form === null || form === void 0 ? void 0 : form.getFieldValue(name), value)) {
15
- return;
16
- }
17
- onChange(value);
18
- };
19
- useUpdateEffect(function () {
20
- if (form && enableAutomaticCalc && automaticCalcCode) {
21
- calcAutomaticCalculate(name, parentName, automaticCalcCode, form, handleOnChange);
22
- }
23
- });
24
- return handleOnChange;
25
- };
26
- export default useWrapperOnChangeForAutomaticCalc;
@@ -1,5 +0,0 @@
1
- import { FormItemConfig } from '../types';
2
- import { NamePath } from 'antd/es/form/interface';
3
- type UseWrapperOnChangeForAutomaticCalcHook = (config: FormItemConfig, parentName: NamePath, onChange: any) => (value: any, automaticCalc?: boolean) => void;
4
- declare const useWrapperOnChangeForAutomaticCalc: UseWrapperOnChangeForAutomaticCalcHook;
5
- export default useWrapperOnChangeForAutomaticCalc;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _hooks = require("@umijs/hooks");
8
- var _react = require("react");
9
- var _lodash = require("lodash");
10
- var _formUtils = require("../utils/form-utils");
11
- var _formContext = _interopRequireDefault(require("../form-context"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- var useWrapperOnChangeForAutomaticCalc = function useWrapperOnChangeForAutomaticCalc(config, parentName, onChange) {
14
- var _useContext = (0, _react.useContext)(_formContext.default),
15
- form = _useContext.form;
16
- var name = config.name,
17
- enableAutomaticCalc = config.enableAutomaticCalc,
18
- automaticCalcCode = config.automaticCalcCode;
19
- var handleOnChange = function handleOnChange(value) {
20
- var automaticCalc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21
- if (automaticCalc && (0, _lodash.isEqual)(form === null || form === void 0 ? void 0 : form.getFieldValue(name), value)) {
22
- return;
23
- }
24
- onChange(value);
25
- };
26
- (0, _hooks.useUpdateEffect)(function () {
27
- if (form && enableAutomaticCalc && automaticCalcCode) {
28
- (0, _formUtils.calcAutomaticCalculate)(name, parentName, automaticCalcCode, form, handleOnChange);
29
- }
30
- });
31
- return handleOnChange;
32
- };
33
- var _default = useWrapperOnChangeForAutomaticCalc;
34
- exports.default = _default;