@sheinx/hooks 3.4.4-beta.8 → 3.4.4-fix.1
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/cjs/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/cjs/common/use-input-able/use-Input-able.js +6 -7
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +30 -11
- package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.js +7 -8
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +30 -11
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAuE3F"}
|
|
@@ -45,19 +45,18 @@ function useInputAble(props) {
|
|
|
45
45
|
var render = (0, _useRender.useRender)(syncValue);
|
|
46
46
|
var shouldUseState = delay || !control;
|
|
47
47
|
var value = shouldUseState ? stateValue : valuePo;
|
|
48
|
-
(0, _react.
|
|
49
|
-
if (context.timer) {
|
|
50
|
-
clearTimeout(context.timer);
|
|
51
|
-
context.timer = null;
|
|
52
|
-
}
|
|
48
|
+
(0, _react.useLayoutEffect)(function () {
|
|
53
49
|
if (delay && control && props.value !== stateValue) {
|
|
54
50
|
changeStateValue(props.value);
|
|
51
|
+
} else if (context.timer) {
|
|
52
|
+
clearTimeout(context.timer);
|
|
53
|
+
context.timer = null;
|
|
55
54
|
}
|
|
56
55
|
}, [props.value, delay, control]);
|
|
57
56
|
var forceDelayChange = (0, _usePersistFn.default)(function () {
|
|
58
|
-
if (context.
|
|
57
|
+
if (context.delayChange) context.delayChange();
|
|
58
|
+
if (context.timer) {
|
|
59
59
|
clearTimeout(context.timer);
|
|
60
|
-
context.delayChange();
|
|
61
60
|
context.timer = null;
|
|
62
61
|
context.delayChange = null;
|
|
63
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;
|
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA2IpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
|
|
@@ -97,18 +97,37 @@ function useFormControl(props) {
|
|
|
97
97
|
var errors = arguments.length > 1 ? arguments[1] : undefined;
|
|
98
98
|
var severErrors = arguments.length > 2 ? arguments[2] : undefined;
|
|
99
99
|
if (!name) return;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
if ((0, _is.isArray)(name)) {
|
|
101
|
+
var _value = getValue(name, formValue);
|
|
102
|
+
var _error = getError(name, errors, severErrors);
|
|
103
|
+
if (_error !== errorState) {
|
|
104
|
+
setErrorState(_error);
|
|
105
|
+
}
|
|
106
|
+
// format defaultValue
|
|
107
|
+
var dv = (0, _is.isArray)(defaultValue) ? defaultValue : [];
|
|
108
|
+
var nextValue = [];
|
|
109
|
+
name.forEach(function (n, index) {
|
|
110
|
+
if (_value[index] === undefined && dv[index] !== undefined) {
|
|
111
|
+
nextValue[index] = dv[index];
|
|
112
|
+
} else {
|
|
113
|
+
nextValue[index] = _value[index];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
setValueState(nextValue);
|
|
117
|
+
} else {
|
|
118
|
+
var _value2 = getValue(name, formValue);
|
|
119
|
+
var _error2 = getError(name, errors, severErrors);
|
|
120
|
+
if (_error2 !== errorState) {
|
|
121
|
+
setErrorState(_error2);
|
|
122
|
+
}
|
|
123
|
+
if (!(0, _shallowEqual.shallowEqual)(_value2, latestInfo.valueState)) {
|
|
124
|
+
if (_value2 === undefined && defaultValue !== undefined) {
|
|
125
|
+
setValueState(defaultValue);
|
|
126
|
+
} else {
|
|
127
|
+
setValueState(_value2);
|
|
128
|
+
}
|
|
129
|
+
latestInfo.valueState = _value2;
|
|
110
130
|
}
|
|
111
|
-
latestInfo.valueState = value;
|
|
112
131
|
}
|
|
113
132
|
});
|
|
114
133
|
var validateFiled = (0, _usePersistFn.default)(function (name, v, formV) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EAuE3F"}
|
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import {
|
|
7
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
8
8
|
import { isFunc } from "../../utils/is";
|
|
9
9
|
import { shallowEqual } from "../../utils/shallow-equal";
|
|
10
10
|
import usePersistFn from "../use-persist-fn";
|
|
@@ -38,19 +38,18 @@ export default function useInputAble(props) {
|
|
|
38
38
|
var render = useRender(syncValue);
|
|
39
39
|
var shouldUseState = delay || !control;
|
|
40
40
|
var value = shouldUseState ? stateValue : valuePo;
|
|
41
|
-
|
|
42
|
-
if (context.timer) {
|
|
43
|
-
clearTimeout(context.timer);
|
|
44
|
-
context.timer = null;
|
|
45
|
-
}
|
|
41
|
+
useLayoutEffect(function () {
|
|
46
42
|
if (delay && control && props.value !== stateValue) {
|
|
47
43
|
changeStateValue(props.value);
|
|
44
|
+
} else if (context.timer) {
|
|
45
|
+
clearTimeout(context.timer);
|
|
46
|
+
context.timer = null;
|
|
48
47
|
}
|
|
49
48
|
}, [props.value, delay, control]);
|
|
50
49
|
var forceDelayChange = usePersistFn(function () {
|
|
51
|
-
if (context.
|
|
50
|
+
if (context.delayChange) context.delayChange();
|
|
51
|
+
if (context.timer) {
|
|
52
52
|
clearTimeout(context.timer);
|
|
53
|
-
context.delayChange();
|
|
54
53
|
context.timer = null;
|
|
55
54
|
context.delayChange = null;
|
|
56
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;
|
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA2IpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
|
|
@@ -88,18 +88,37 @@ export default function useFormControl(props) {
|
|
|
88
88
|
var errors = arguments.length > 1 ? arguments[1] : undefined;
|
|
89
89
|
var severErrors = arguments.length > 2 ? arguments[2] : undefined;
|
|
90
90
|
if (!name) return;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
if (isArray(name)) {
|
|
92
|
+
var _value = getValue(name, formValue);
|
|
93
|
+
var _error = getError(name, errors, severErrors);
|
|
94
|
+
if (_error !== errorState) {
|
|
95
|
+
setErrorState(_error);
|
|
96
|
+
}
|
|
97
|
+
// format defaultValue
|
|
98
|
+
var dv = isArray(defaultValue) ? defaultValue : [];
|
|
99
|
+
var nextValue = [];
|
|
100
|
+
name.forEach(function (n, index) {
|
|
101
|
+
if (_value[index] === undefined && dv[index] !== undefined) {
|
|
102
|
+
nextValue[index] = dv[index];
|
|
103
|
+
} else {
|
|
104
|
+
nextValue[index] = _value[index];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
setValueState(nextValue);
|
|
108
|
+
} else {
|
|
109
|
+
var _value2 = getValue(name, formValue);
|
|
110
|
+
var _error2 = getError(name, errors, severErrors);
|
|
111
|
+
if (_error2 !== errorState) {
|
|
112
|
+
setErrorState(_error2);
|
|
113
|
+
}
|
|
114
|
+
if (!shallowEqual(_value2, latestInfo.valueState)) {
|
|
115
|
+
if (_value2 === undefined && defaultValue !== undefined) {
|
|
116
|
+
setValueState(defaultValue);
|
|
117
|
+
} else {
|
|
118
|
+
setValueState(_value2);
|
|
119
|
+
}
|
|
120
|
+
latestInfo.valueState = _value2;
|
|
101
121
|
}
|
|
102
|
-
latestInfo.valueState = value;
|
|
103
122
|
}
|
|
104
123
|
});
|
|
105
124
|
var validateFiled = usePersistFn(function (name, v, formV) {
|