@sheinx/hooks 3.4.4-beta.8 → 3.4.4
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/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/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-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-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) {
|