@sheinx/hooks 3.4.3 → 3.4.4-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +5 -3
- package/cjs/utils/object.d.ts +1 -0
- package/cjs/utils/object.d.ts.map +1 -1
- package/cjs/utils/object.js +12 -1
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +6 -4
- package/esm/utils/object.d.ts +1 -0
- package/esm/utils/object.d.ts.map +1 -1
- package/esm/utils/object.js +11 -0
- package/package.json +1 -1
@@ -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":";AA0BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAkED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA8I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAnDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAkED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA8I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -205,11 +205,13 @@ var useForm = function useForm(props) {
|
|
205
205
|
}
|
206
206
|
});
|
207
207
|
});
|
208
|
-
|
209
|
-
|
208
|
+
|
209
|
+
// 获取vals的所有key,包括嵌套对象的key
|
210
|
+
var fullKeyPaths = (0, _utils.getAllKeyPaths)(vals);
|
211
|
+
fullKeyPaths.forEach(function (key) {
|
210
212
|
delete context.serverErrors[key];
|
211
213
|
});
|
212
|
-
update(
|
214
|
+
update(fullKeyPaths);
|
213
215
|
});
|
214
216
|
var getErrors = (0, _usePersistFn.default)(function () {
|
215
217
|
return context.errors;
|
package/cjs/utils/object.d.ts
CHANGED
@@ -22,5 +22,6 @@ export declare const deepRemove: (target: ObjectType, path: string) => ObjectTyp
|
|
22
22
|
export declare const deepHas: (target: ObjectType, path: string) => boolean;
|
23
23
|
export declare const entries: (obj: ObjectType) => any[][];
|
24
24
|
export declare const removeProps: <T extends ObjectType, K extends ObjectType>(target: T, remove: K) => Omit<T, keyof K>;
|
25
|
+
export declare const getAllKeyPaths: (obj: ObjectType, parentKey?: string) => string[];
|
25
26
|
export {};
|
26
27
|
//# sourceMappingURL=object.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AASD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,C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wBrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,+DA4BxC;AAED,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,WACV,UAAU,QACZ,MAAM,SACL,GAAG,YACD,cAAc,eAiDxB,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAAW,WAAW,YAyB7E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,QAAQ,MAAM,eA0B1D,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAavD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,UAAU,YAItC,CAAC;AAEF,eAAO,MAAM,WAAW,wFAQvB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,MAAM,KAAQ,MAAM,EAU9E,CAAC"}
|
package/cjs/utils/object.js
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.entries = exports.deepSet = exports.deepRemove = exports.deepMerge = exports.deepHas = exports.deepGet = void 0;
|
6
|
+
exports.getAllKeyPaths = exports.entries = exports.deepSet = exports.deepRemove = exports.deepMerge = exports.deepHas = exports.deepGet = void 0;
|
7
7
|
exports.insertPoint = insertPoint;
|
8
8
|
exports.objectValues = void 0;
|
9
9
|
exports.pathGenerator = pathGenerator;
|
10
10
|
exports.removeProps = void 0;
|
11
11
|
var _is = require("./is");
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
12
13
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
13
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
14
15
|
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; } }
|
@@ -268,4 +269,14 @@ var removeProps = exports.removeProps = function removeProps(target, remove) {
|
|
268
269
|
_iterator5.f();
|
269
270
|
}
|
270
271
|
return a;
|
272
|
+
};
|
273
|
+
var getAllKeyPaths = exports.getAllKeyPaths = function getAllKeyPaths(obj) {
|
274
|
+
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
275
|
+
return Object.keys(obj).reduce(function (keys, key) {
|
276
|
+
var newKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
|
277
|
+
if (Array.isArray(obj[key])) {
|
278
|
+
return keys.concat(newKey);
|
279
|
+
}
|
280
|
+
return keys.concat(obj[key] !== null && _typeof(obj[key]) === 'object' ? getAllKeyPaths(obj[key], newKey) : newKey);
|
281
|
+
}, []);
|
271
282
|
};
|
@@ -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":";AA0BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAkED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA8I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAnDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAkED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA8I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -16,7 +16,7 @@ import { insertValue, spliceValue } from "../../utils/flat";
|
|
16
16
|
import { usePrevious } from "../../common/use-default-value";
|
17
17
|
var globalKey = '__global__&&@@';
|
18
18
|
import { current, produce } from "../../utils/immer";
|
19
|
-
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
|
19
|
+
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone, getAllKeyPaths } from "../../utils";
|
20
20
|
var emptyObj = {};
|
21
21
|
var useForm = function useForm(props) {
|
22
22
|
var _props$defaultValue = props.defaultValue,
|
@@ -196,11 +196,13 @@ var useForm = function useForm(props) {
|
|
196
196
|
}
|
197
197
|
});
|
198
198
|
});
|
199
|
-
|
200
|
-
|
199
|
+
|
200
|
+
// 获取vals的所有key,包括嵌套对象的key
|
201
|
+
var fullKeyPaths = getAllKeyPaths(vals);
|
202
|
+
fullKeyPaths.forEach(function (key) {
|
201
203
|
delete context.serverErrors[key];
|
202
204
|
});
|
203
|
-
update(
|
205
|
+
update(fullKeyPaths);
|
204
206
|
});
|
205
207
|
var getErrors = usePersistFn(function () {
|
206
208
|
return context.errors;
|
package/esm/utils/object.d.ts
CHANGED
@@ -22,5 +22,6 @@ export declare const deepRemove: (target: ObjectType, path: string) => ObjectTyp
|
|
22
22
|
export declare const deepHas: (target: ObjectType, path: string) => boolean;
|
23
23
|
export declare const entries: (obj: ObjectType) => any[][];
|
24
24
|
export declare const removeProps: <T extends ObjectType, K extends ObjectType>(target: T, remove: K) => Omit<T, keyof K>;
|
25
|
+
export declare const getAllKeyPaths: (obj: ObjectType, parentKey?: string) => string[];
|
25
26
|
export {};
|
26
27
|
//# sourceMappingURL=object.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AASD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,QAAS,UAAU,UAG3C,CAAC;AAGF,eAAO,MAAM,SAAS,2CAEZ,UAAU,YACT,WAAW,eAwBrB,CAAC;AAEF,wBAAgB,aAAa,C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AAO,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,WACV,UAAU,QACZ,MAAM,SACL,GAAG,YACD,cAAc,eAiDxB,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAAW,WAAW,YAyB7E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,QAAQ,MAAM,eA0B1D,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAavD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,UAAU,YAItC,CAAC;AAEF,eAAO,MAAM,WAAW,wFAQvB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,MAAM,KAAQ,MAAM,EAU9E,CAAC"}
|
package/esm/utils/object.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
1
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
4
|
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; } }
|
@@ -258,4 +259,14 @@ export var removeProps = function removeProps(target, remove) {
|
|
258
259
|
_iterator5.f();
|
259
260
|
}
|
260
261
|
return a;
|
262
|
+
};
|
263
|
+
export var getAllKeyPaths = function getAllKeyPaths(obj) {
|
264
|
+
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
265
|
+
return Object.keys(obj).reduce(function (keys, key) {
|
266
|
+
var newKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
|
267
|
+
if (Array.isArray(obj[key])) {
|
268
|
+
return keys.concat(newKey);
|
269
|
+
}
|
270
|
+
return keys.concat(obj[key] !== null && _typeof(obj[key]) === 'object' ? getAllKeyPaths(obj[key], newKey) : newKey);
|
271
|
+
}, []);
|
261
272
|
};
|