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.
- package/.dumi/tmp/core/defineApp.ts +1 -1
- package/.dumi/tmp/core/helmet.ts +1 -1
- package/.dumi/tmp/core/history.ts +1 -1
- package/.dumi/tmp/core/historyIntelli.ts +1 -1
- package/.dumi/tmp/core/plugin.ts +2 -2
- package/.dumi/tmp/core/polyfill.ts +197 -197
- package/.dumi/tmp/core/route.tsx +33 -33
- package/.dumi/tmp/dumi/exports.ts +1 -1
- package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
- package/.dumi/tmp/dumi/meta/index.ts +33 -33
- package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
- package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
- package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
- package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
- package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
- package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
- package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
- package/.dumi/tmp/exports.ts +5 -5
- package/.dumi/tmp/testBrowser.tsx +3 -3
- package/.dumi/tmp/umi.ts +4 -4
- package/.idea/iglooform.iml +9 -0
- package/.idea/misc.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/es/confirmation/style/index.d.ts +1 -0
- package/es/form/element/index.js +1 -1
- package/es/form/elements.d.ts +1 -2
- package/es/form/elements.js +3 -23
- package/es/types.d.ts +187 -0
- package/es/utils/form-utils.d.ts +1 -1
- package/es/utils/form-utils.js +25 -17
- package/lib/confirmation/style/index.d.ts +1 -0
- package/lib/form/element/index.js +1 -1
- package/lib/form/elements.d.ts +1 -2
- package/lib/form/elements.js +3 -22
- package/lib/types.d.ts +187 -0
- package/lib/utils/form-utils.d.ts +1 -1
- package/lib/utils/form-utils.js +26 -18
- package/package.json +1 -1
- package/es/hooks/useWrapperOnChangeForAutomaticCalc.d.ts +0 -5
- package/es/hooks/useWrapperOnChangeForAutomaticCalc.js +0 -26
- package/lib/hooks/useWrapperOnChangeForAutomaticCalc.d.ts +0 -5
- package/lib/hooks/useWrapperOnChangeForAutomaticCalc.js +0 -34
package/lib/utils/form-utils.js
CHANGED
|
@@ -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.
|
|
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
|
|
399
|
+
var value = form.getFieldValue(name);
|
|
397
400
|
var values = form.getFieldsValue(true);
|
|
398
|
-
return fn(
|
|
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
|
-
|
|
468
|
+
value = select.value,
|
|
466
469
|
disabled = select.disabled;
|
|
467
470
|
if (testAssert(form, assert)) {
|
|
468
471
|
return {
|
|
469
472
|
selected: true,
|
|
470
|
-
value:
|
|
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
|
|
516
|
+
var value = form.getFieldValue(name);
|
|
514
517
|
var values = form.getFieldsValue(true);
|
|
515
|
-
return fn(
|
|
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
|
|
544
|
-
if (
|
|
545
|
-
if (automaticCalcCode) {
|
|
546
|
+
var automaticCalculate = function automaticCalculate(name, parentName, automaticCalcCode, form) {
|
|
547
|
+
if (form && automaticCalcCode) {
|
|
546
548
|
var calcValue = undefined;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
var
|
|
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(
|
|
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
|
-
}
|
|
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.
|
|
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,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;
|