@sheinx/hooks 3.6.5-beta.9 → 3.6.5
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.d.ts +2 -2
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +16 -17
- package/esm/components/use-form/use-form.d.ts +2 -2
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +16 -17
- package/package.json +1 -1
@@ -14,7 +14,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
14
14
|
names?: string[];
|
15
15
|
}) => void;
|
16
16
|
getValue: (name?: string) => unknown;
|
17
|
-
submit: (withValidate?: boolean) => void;
|
17
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
18
18
|
reset: () => void;
|
19
19
|
setError: (name: string, e: Error | undefined) => void;
|
20
20
|
getErrors: () => ObjectType<Error | undefined>;
|
@@ -34,7 +34,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
34
34
|
names?: string[];
|
35
35
|
}) => void;
|
36
36
|
getValue: (name?: string) => unknown;
|
37
|
-
submit: (withValidate?: boolean) => void;
|
37
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
38
38
|
reset: () => void;
|
39
39
|
setError: (name: string, e: Error | undefined) => void;
|
40
40
|
getErrors: () => ObjectType<Error | undefined>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAgSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BApKd,MAAM;oCA0OD,OAAO;;
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAgSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BApKd,MAAM;oCA0OD,OAAO,aAAoB,MAAM,IAAI;;6BAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArMxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCAwQvB,MAAM,WAAW,gBAAgB;gCAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCA5IpD,MAAM,0BAAyB,qBAAqB;;;;;;oBA2EjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BApKd,MAAM;gCA0OD,OAAO,aAAoB,MAAM,IAAI;;yBAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArMxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCAwQvB,MAAM,WAAW,gBAAgB;4BAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BA5IpD,MAAM,0BAAyB,qBAAqB;;CAkb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -47,7 +47,8 @@ var useForm = function useForm(props) {
|
|
47
47
|
size = props.size,
|
48
48
|
colon = props.colon,
|
49
49
|
formName = props.name,
|
50
|
-
scrollParent = props.scrollParent
|
50
|
+
scrollParent = props.scrollParent,
|
51
|
+
isControl = props.isControl;
|
51
52
|
var deepSetOptions = {
|
52
53
|
removeUndefined: removeUndefined,
|
53
54
|
forceSet: true
|
@@ -368,6 +369,7 @@ var useForm = function useForm(props) {
|
|
368
369
|
});
|
369
370
|
var submit = (0, _usePersistFn.default)(function () {
|
370
371
|
var withValidate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
372
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
371
373
|
if (disabled) return;
|
372
374
|
if (context.submitLock) {
|
373
375
|
return;
|
@@ -385,32 +387,29 @@ var useForm = function useForm(props) {
|
|
385
387
|
while (1) switch (_context.prev = _context.next) {
|
386
388
|
case 0:
|
387
389
|
if (withValidate) {
|
388
|
-
_context.next =
|
390
|
+
_context.next = 4;
|
389
391
|
break;
|
390
392
|
}
|
391
393
|
(_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (_context$value = context.value) !== null && _context$value !== void 0 ? _context$value : {});
|
394
|
+
callback === null || callback === void 0 || callback();
|
392
395
|
return _context.abrupt("return");
|
393
|
-
case
|
394
|
-
_context.next =
|
396
|
+
case 4:
|
397
|
+
_context.next = 6;
|
395
398
|
return validateFields(undefined, {
|
396
399
|
ignoreBind: true
|
397
400
|
}).catch(function (e) {
|
398
401
|
return e;
|
399
402
|
});
|
400
|
-
case
|
403
|
+
case 6:
|
401
404
|
result = _context.sent;
|
402
|
-
if (
|
403
|
-
|
404
|
-
|
405
|
+
if (result === true) {
|
406
|
+
(_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (_context$value2 = context.value) !== null && _context$value2 !== void 0 ? _context$value2 : {});
|
407
|
+
if (activeEl) activeEl.focus();
|
408
|
+
} else {
|
409
|
+
handleSubmitError(result);
|
405
410
|
}
|
406
|
-
|
407
|
-
|
408
|
-
_context.next = 13;
|
409
|
-
break;
|
410
|
-
case 11:
|
411
|
-
handleSubmitError(result);
|
412
|
-
return _context.abrupt("return");
|
413
|
-
case 13:
|
411
|
+
callback === null || callback === void 0 || callback();
|
412
|
+
case 9:
|
414
413
|
case "end":
|
415
414
|
return _context.stop();
|
416
415
|
}
|
@@ -613,7 +612,7 @@ var useForm = function useForm(props) {
|
|
613
612
|
context.removeLock = false;
|
614
613
|
// 内部 onChange 改的 value, 不需要更新
|
615
614
|
if (props.value === context.value) {
|
616
|
-
|
615
|
+
if (!isControl) update();
|
617
616
|
return;
|
618
617
|
}
|
619
618
|
if (initValidate && !context.resetTime) {
|
@@ -14,7 +14,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
14
14
|
names?: string[];
|
15
15
|
}) => void;
|
16
16
|
getValue: (name?: string) => unknown;
|
17
|
-
submit: (withValidate?: boolean) => void;
|
17
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
18
18
|
reset: () => void;
|
19
19
|
setError: (name: string, e: Error | undefined) => void;
|
20
20
|
getErrors: () => ObjectType<Error | undefined>;
|
@@ -34,7 +34,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
34
34
|
names?: string[];
|
35
35
|
}) => void;
|
36
36
|
getValue: (name?: string) => unknown;
|
37
|
-
submit: (withValidate?: boolean) => void;
|
37
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
38
38
|
reset: () => void;
|
39
39
|
setError: (name: string, e: Error | undefined) => void;
|
40
40
|
getErrors: () => ObjectType<Error | undefined>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAgSC;gBA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
39
39
|
colon = props.colon,
|
40
40
|
formName = props.name,
|
41
|
-
scrollParent = props.scrollParent
|
41
|
+
scrollParent = props.scrollParent,
|
42
|
+
isControl = props.isControl;
|
42
43
|
var deepSetOptions = {
|
43
44
|
removeUndefined: removeUndefined,
|
44
45
|
forceSet: true
|
@@ -359,6 +360,7 @@ var useForm = function useForm(props) {
|
|
359
360
|
});
|
360
361
|
var submit = usePersistFn(function () {
|
361
362
|
var withValidate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
363
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
362
364
|
if (disabled) return;
|
363
365
|
if (context.submitLock) {
|
364
366
|
return;
|
@@ -376,32 +378,29 @@ var useForm = function useForm(props) {
|
|
376
378
|
while (1) switch (_context.prev = _context.next) {
|
377
379
|
case 0:
|
378
380
|
if (withValidate) {
|
379
|
-
_context.next =
|
381
|
+
_context.next = 4;
|
380
382
|
break;
|
381
383
|
}
|
382
384
|
(_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (_context$value = context.value) !== null && _context$value !== void 0 ? _context$value : {});
|
385
|
+
callback === null || callback === void 0 || callback();
|
383
386
|
return _context.abrupt("return");
|
384
|
-
case
|
385
|
-
_context.next =
|
387
|
+
case 4:
|
388
|
+
_context.next = 6;
|
386
389
|
return validateFields(undefined, {
|
387
390
|
ignoreBind: true
|
388
391
|
}).catch(function (e) {
|
389
392
|
return e;
|
390
393
|
});
|
391
|
-
case
|
394
|
+
case 6:
|
392
395
|
result = _context.sent;
|
393
|
-
if (
|
394
|
-
|
395
|
-
|
396
|
+
if (result === true) {
|
397
|
+
(_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (_context$value2 = context.value) !== null && _context$value2 !== void 0 ? _context$value2 : {});
|
398
|
+
if (activeEl) activeEl.focus();
|
399
|
+
} else {
|
400
|
+
handleSubmitError(result);
|
396
401
|
}
|
397
|
-
|
398
|
-
|
399
|
-
_context.next = 13;
|
400
|
-
break;
|
401
|
-
case 11:
|
402
|
-
handleSubmitError(result);
|
403
|
-
return _context.abrupt("return");
|
404
|
-
case 13:
|
402
|
+
callback === null || callback === void 0 || callback();
|
403
|
+
case 9:
|
405
404
|
case "end":
|
406
405
|
return _context.stop();
|
407
406
|
}
|
@@ -604,7 +603,7 @@ var useForm = function useForm(props) {
|
|
604
603
|
context.removeLock = false;
|
605
604
|
// 内部 onChange 改的 value, 不需要更新
|
606
605
|
if (props.value === context.value) {
|
607
|
-
|
606
|
+
if (!isControl) update();
|
608
607
|
return;
|
609
608
|
}
|
610
609
|
if (initValidate && !context.resetTime) {
|