mobx-react-hook-form 1.0.11 → 1.0.12
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/mobx-form/mobx-form.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Disposable } from 'disposer-util';
|
|
2
2
|
import { FormState, UseFormProps, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
import { WithAbortController } from 'with-abort-controller';
|
|
4
3
|
import type { AnyObject, Maybe } from 'yammies/utils/types';
|
|
5
4
|
import { ConnectedMobxForm, MobxFormParams } from './mobx-form.types';
|
|
6
|
-
export declare class MobxForm<TFieldValues extends AnyObject, TContext = any>
|
|
5
|
+
export declare class MobxForm<TFieldValues extends AnyObject, TContext = any> implements Disposable {
|
|
6
|
+
protected abortController: AbortController;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Real react-hook-form params
|
|
9
9
|
* Needed to connect real react-hook-form to this mobx wrapper
|
|
10
10
|
*/
|
|
11
11
|
params: UseFormProps<TFieldValues, TContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-form.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mobx-form.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAUhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEtE,qBAAa,QAAQ,CAAC,YAAY,SAAS,SA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GED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { LinkedAbortController } from 'linked-abort-controller';
|
|
1
2
|
import noop from 'lodash-es/noop';
|
|
2
3
|
import { action, makeObservable, observable, reaction, runInAction, } from 'mobx';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
export class MobxForm {
|
|
5
|
+
abortController;
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Real react-hook-form params
|
|
7
8
|
* Needed to connect real react-hook-form to this mobx wrapper
|
|
8
9
|
*/
|
|
9
10
|
params;
|
|
@@ -26,11 +27,11 @@ export class MobxForm extends WithAbortController {
|
|
|
26
27
|
constructor({
|
|
27
28
|
// eslint-disable-next-line sonarjs/deprecation
|
|
28
29
|
disposer, abortSignal, onSubmit, onSubmitFailed, onReset, getParams, ...params }) {
|
|
29
|
-
|
|
30
|
+
this.abortController = new LinkedAbortController(abortSignal);
|
|
30
31
|
if (disposer) {
|
|
31
32
|
disposer.add(() => this.dispose());
|
|
32
33
|
}
|
|
33
|
-
this.
|
|
34
|
+
this.abortController.signal.addEventListener('abort', () => {
|
|
34
35
|
this.form = null;
|
|
35
36
|
this.data = null;
|
|
36
37
|
});
|
|
@@ -62,8 +63,10 @@ export class MobxForm extends WithAbortController {
|
|
|
62
63
|
updateParams: action.bound,
|
|
63
64
|
});
|
|
64
65
|
if (getParams) {
|
|
65
|
-
reaction(getParams, (params) =>
|
|
66
|
-
|
|
66
|
+
reaction(getParams, (params) => {
|
|
67
|
+
this.updateParams(params);
|
|
68
|
+
}, {
|
|
69
|
+
signal: this.abortController.signal,
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -99,7 +102,7 @@ export class MobxForm extends WithAbortController {
|
|
|
99
102
|
this.data = formResult.getValues();
|
|
100
103
|
});
|
|
101
104
|
});
|
|
102
|
-
this.
|
|
105
|
+
this.abortController.signal.addEventListener('abort', formWatchSubscription.unsubscribe);
|
|
103
106
|
}
|
|
104
107
|
return {
|
|
105
108
|
...formResult,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-react-hook-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "js2me",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"disposer-util": "^1.0.11",
|
|
16
|
-
"
|
|
16
|
+
"linked-abort-controller": "^1.0.1",
|
|
17
17
|
"lodash-es": "^4.17.21",
|
|
18
18
|
"yammies": "^2.0.8"
|
|
19
19
|
},
|