@sheinx/hooks 3.3.0-beta.6 → 3.3.0-beta.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAmK8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCAuDD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCAiI5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBA1CpB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCAuDD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCAiI5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA4P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -11,6 +11,7 @@ var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"
|
|
11
11
|
var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
|
12
12
|
var _attribute = require("../../utils/attribute");
|
13
13
|
var _flat = require("../../utils/flat");
|
14
|
+
var _useDefaultValue = require("../../common/use-default-value");
|
14
15
|
var _immer = require("../../utils/immer");
|
15
16
|
var _utils = require("../../utils");
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -49,6 +50,7 @@ var useForm = function useForm(props) {
|
|
49
50
|
removeUndefined: removeUndefined,
|
50
51
|
forceSet: true
|
51
52
|
};
|
53
|
+
var preValue = (0, _useDefaultValue.usePrevious)(props.value);
|
52
54
|
var formRef = React.useRef();
|
53
55
|
var _React$useRef = React.useRef({
|
54
56
|
defaultValues: {},
|
@@ -419,8 +421,8 @@ var useForm = function useForm(props) {
|
|
419
421
|
var updateValue = function updateValue() {
|
420
422
|
if (props.value !== context.lastValue && props.value !== context.value) {
|
421
423
|
context.value = (0, _utils.deepClone)(props.value) || emptyObj;
|
422
|
-
context.lastValue = props.value;
|
423
424
|
}
|
425
|
+
context.lastValue = props.value;
|
424
426
|
};
|
425
427
|
updateValue();
|
426
428
|
React.useEffect(function () {
|
@@ -443,14 +445,13 @@ var useForm = function useForm(props) {
|
|
443
445
|
if (props.value === context.value) return;
|
444
446
|
if (initValidate && !context.resetTime) {
|
445
447
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
446
|
-
var oldValue = (0, _utils.deepGet)(
|
448
|
+
var oldValue = (0, _utils.deepGet)(preValue || emptyObj, key);
|
447
449
|
var newValue = (0, _utils.deepGet)(context.value || emptyObj, key);
|
448
450
|
return !(0, _utils.shallowEqual)(oldValue, newValue);
|
449
451
|
});
|
450
452
|
validateFields(keys).catch(function () {});
|
451
453
|
}
|
452
454
|
update();
|
453
|
-
context.lastValue = props.value;
|
454
455
|
context.resetTime = 0;
|
455
456
|
}, [props.value]);
|
456
457
|
React.useEffect(function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAmK8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCAuDD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCAiI5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBA1CpB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCAuDD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCAiI5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA4P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -13,6 +13,7 @@ import useLatestObj from "../../common/use-latest-obj";
|
|
13
13
|
import usePersistFn from "../../common/use-persist-fn";
|
14
14
|
import { getDataAttributeName } from "../../utils/attribute";
|
15
15
|
import { insertValue, spliceValue } from "../../utils/flat";
|
16
|
+
import { usePrevious } from "../../common/use-default-value";
|
16
17
|
var globalKey = '__global__&&@@';
|
17
18
|
import { current, produce } from "../../utils/immer";
|
18
19
|
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
|
@@ -40,6 +41,7 @@ var useForm = function useForm(props) {
|
|
40
41
|
removeUndefined: removeUndefined,
|
41
42
|
forceSet: true
|
42
43
|
};
|
44
|
+
var preValue = usePrevious(props.value);
|
43
45
|
var formRef = React.useRef();
|
44
46
|
var _React$useRef = React.useRef({
|
45
47
|
defaultValues: {},
|
@@ -410,8 +412,8 @@ var useForm = function useForm(props) {
|
|
410
412
|
var updateValue = function updateValue() {
|
411
413
|
if (props.value !== context.lastValue && props.value !== context.value) {
|
412
414
|
context.value = deepClone(props.value) || emptyObj;
|
413
|
-
context.lastValue = props.value;
|
414
415
|
}
|
416
|
+
context.lastValue = props.value;
|
415
417
|
};
|
416
418
|
updateValue();
|
417
419
|
React.useEffect(function () {
|
@@ -434,14 +436,13 @@ var useForm = function useForm(props) {
|
|
434
436
|
if (props.value === context.value) return;
|
435
437
|
if (initValidate && !context.resetTime) {
|
436
438
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
437
|
-
var oldValue = deepGet(
|
439
|
+
var oldValue = deepGet(preValue || emptyObj, key);
|
438
440
|
var newValue = deepGet(context.value || emptyObj, key);
|
439
441
|
return !shallowEqual(oldValue, newValue);
|
440
442
|
});
|
441
443
|
validateFields(keys).catch(function () {});
|
442
444
|
}
|
443
445
|
update();
|
444
|
-
context.lastValue = props.value;
|
445
446
|
context.resetTime = 0;
|
446
447
|
}, [props.value]);
|
447
448
|
React.useEffect(function () {
|