mobx-react-hook-form 2.1.0 → 2.1.2

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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './mobx-form/index.js';
2
- export * from './hooks/index.js';
3
2
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
package/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export * from './mobx-form/index.js';
2
- export * from './hooks/index.js';
@@ -1,49 +1,34 @@
1
- import { DeepPartial, FormState, SubmitErrorHandler, SubmitHandler, UseFormProps, UseFormReturn } from 'react-hook-form';
2
- import type { AnyObject, Maybe } from 'yummies/utils/types';
3
- import { ConnectedMobxForm, MobxFormParams } from './mobx-form.types.js';
4
- export declare class MobxForm<TFieldValues extends AnyObject, TContext = any, TFieldOutputValues extends AnyObject = TFieldValues> {
1
+ import { createFormControl, FieldValues, FormState, SubmitErrorHandler, SubmitHandler, UseFormProps } from 'react-hook-form';
2
+ import { Maybe } from 'yummies/utils/types';
3
+ import { MobxFormParams } from './mobx-form.types.js';
4
+ export declare class MobxForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> {
5
5
  private config;
6
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
- params: UseFormProps<TFieldValues, TContext>;
12
- protected handleSubmit(...args: Parameters<SubmitHandler<TFieldOutputValues>>): void | Promise<void>;
11
+ params: UseFormProps<TFieldValues, TContext, TTransformedValues>;
12
+ protected handleSubmit(...args: Parameters<SubmitHandler<TTransformedValues>>): void | Promise<void>;
13
13
  protected handleSubmitFailed(...args: Parameters<SubmitErrorHandler<TFieldValues>>): void | Promise<void>;
14
14
  protected handleReset(): void;
15
15
  /**
16
16
  * Original react-hook-form form
17
17
  */
18
- form: Maybe<UseFormReturn<TFieldValues, TContext, TFieldOutputValues>>;
18
+ form: ReturnType<typeof createFormControl<TFieldValues, TContext, TTransformedValues>>;
19
19
  /**
20
20
  * form state received from form.formState
21
21
  */
22
- state: FormState<TFieldValues>;
22
+ state: Maybe<Partial<FormState<TFieldValues>> & {
23
+ values: TFieldValues;
24
+ }>;
23
25
  /**
24
26
  * Raw data received from form.getValues()
25
27
  */
26
- data: Maybe<DeepPartial<TFieldValues>>;
27
- protected isConnected: boolean;
28
- constructor(config: MobxFormParams<TFieldValues, TContext, TFieldOutputValues>);
29
- /**
30
- * Allows to modify real react-hook-form useForm() payload
31
- */
32
- setParams(params: UseFormProps<TFieldValues, TContext>): void;
33
- /**
34
- * Allows to modify real react-hook-form useForm() payload
35
- */
36
- updateParams(params: Partial<UseFormProps<TFieldValues, TContext>>): void;
37
- protected syncForm(formResult: UseFormReturn<TFieldValues, TContext, TFieldOutputValues>, data?: DeepPartial<TFieldValues>): void;
38
- /**
39
- * Needed to connect real react-hook-form to this mobx wrapper
40
- *
41
- * This is used in useMobxForm
42
- */
43
- protected connect(formResult: UseFormReturn<TFieldValues, TContext, TFieldOutputValues>): ConnectedMobxForm<TFieldValues, TContext, TFieldOutputValues>;
44
- /**
45
- * @deprecated use destroy();
46
- */
47
- dispose(): void;
28
+ data: TFieldValues;
29
+ constructor(config: MobxFormParams<TFieldValues, TContext, TTransformedValues>);
30
+ destroy(): void;
31
+ submit: (event?: any) => Promise<void>;
32
+ reset: () => void;
48
33
  }
49
34
  //# sourceMappingURL=mobx-form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mobx-form.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.ts"],"names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,kBAAkB,CAAC,YAAY,CAAC,CAAC,GACpD,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvB,SAAS,CAAC,WAAW;IAKrB;;OAEG;IACH,IAAI,EAAE,UAAU,CACd,OAAO,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CACrE,CAAC;IAEF;;OAEG;IACH,KAAK,EAAE,KAAK,CACV,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG;QACjC,MAAM,EAAE,YAAY,CAAC;KACtB,CACF,CAAC;IAEF;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;gBAGT,MAAM,EAAE,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC;IAgD5E,OAAO,IAAI,IAAI;IAIf,MAAM,GAAU,QAAQ,GAAG,mBAOzB;IAEF,KAAK,aAEH;CACH"}
@@ -1,5 +1,7 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1
2
  import { LinkedAbortController } from 'linked-abort-controller';
2
- import { action, makeObservable, observable, reaction } from 'mobx';
3
+ import { action, makeObservable, observable, runInAction } from 'mobx';
4
+ import { createFormControl, } from 'react-hook-form';
3
5
  export class MobxForm {
4
6
  config;
5
7
  abortController;
@@ -36,106 +38,54 @@ export class MobxForm {
36
38
  * Raw data received from form.getValues()
37
39
  */
38
40
  data;
39
- isConnected = false;
40
41
  constructor(config) {
41
42
  this.config = config;
43
+ this.params = config;
42
44
  this.abortController = new LinkedAbortController(config.abortSignal);
43
- // eslint-disable-next-line sonarjs/deprecation
44
- if (config.disposer) {
45
- // eslint-disable-next-line sonarjs/deprecation
46
- config.disposer.add(() => this.dispose());
47
- }
45
+ this.form = createFormControl(config);
46
+ this.data = this.form.getValues();
47
+ this.state = null;
48
+ this.params = config;
49
+ const subscription = this.form.subscribe({
50
+ callback: (rawFormState) => {
51
+ runInAction(() => {
52
+ if (this.state) {
53
+ Object.assign(this.state, rawFormState);
54
+ }
55
+ else {
56
+ this.state = rawFormState;
57
+ }
58
+ Object.assign(this.data, rawFormState.values);
59
+ });
60
+ },
61
+ });
48
62
  this.abortController.signal.addEventListener('abort', () => {
63
+ subscription();
64
+ // @ts-ignore
49
65
  this.form = null;
66
+ // @ts-ignore
50
67
  this.data = null;
68
+ // @ts-ignore
69
+ this.state = null;
51
70
  });
52
- this.state = {
53
- disabled: false,
54
- errors: {},
55
- isDirty: false,
56
- isLoading: false,
57
- isSubmitSuccessful: false,
58
- isSubmitted: false,
59
- isValid: false,
60
- isValidating: false,
61
- isSubmitting: false,
62
- submitCount: 0,
63
- touchedFields: {},
64
- defaultValues: undefined,
65
- dirtyFields: {},
66
- validatingFields: {},
67
- };
68
- this.params = config;
69
71
  observable.deep(this, 'state');
70
72
  observable.deep(this, 'data');
71
73
  observable.ref(this, 'params');
74
+ observable.ref(this, 'form');
72
75
  action.bound(this, 'setParams');
73
76
  action.bound(this, 'updateParams');
74
77
  action.bound(this, 'syncForm');
75
78
  makeObservable(this);
76
- if (config.getParams) {
77
- reaction(config.getParams, (params) => {
78
- this.updateParams(params);
79
- }, {
80
- signal: this.abortController.signal,
81
- });
82
- }
83
- }
84
- /**
85
- * Allows to modify real react-hook-form useForm() payload
86
- */
87
- setParams(params) {
88
- this.params = params;
89
79
  }
90
- /**
91
- * Allows to modify real react-hook-form useForm() payload
92
- */
93
- updateParams(params) {
94
- this.setParams({ ...this.params, ...params });
95
- }
96
- syncForm(formResult, data = formResult.getValues()) {
97
- this.form = formResult;
98
- this.state = formResult.formState;
99
- this.data = data;
100
- }
101
- /**
102
- * Needed to connect real react-hook-form to this mobx wrapper
103
- *
104
- * This is used in useMobxForm
105
- */
106
- connect(formResult) {
107
- if (!this.isConnected) {
108
- this.isConnected = true;
109
- this.syncForm(formResult);
110
- const formWatchSubscription = formResult.watch((values) => {
111
- this.syncForm(formResult, values);
112
- });
113
- this.abortController.signal.addEventListener('abort', formWatchSubscription.unsubscribe);
114
- }
115
- return {
116
- ...formResult,
117
- onReset: () => this.handleReset(),
118
- onSubmit: formResult.handleSubmit(
119
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
120
- // @ts-expect-error
121
- (...args) => this.handleSubmit(...args), (...args) => this.handleSubmitFailed(...args)),
122
- handleSubmit: (onValid, onInvalid) => {
123
- return formResult.handleSubmit(async (...args) => {
124
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
125
- // @ts-expect-error
126
- await this.handleSubmit(...args);
127
- await onValid(...args);
128
- }, async (...args) => {
129
- await this.handleSubmitFailed(...args);
130
- await onInvalid?.(...args);
131
- });
132
- },
133
- };
134
- }
135
- /**
136
- * @deprecated use destroy();
137
- */
138
- dispose() {
80
+ destroy() {
139
81
  this.abortController.abort();
140
82
  }
83
+ submit = async (event) => {
84
+ if (this.config.onSubmit) {
85
+ await this.form.handleSubmit(this.config.onSubmit, this.config.onSubmitFailed)(event);
86
+ }
87
+ };
88
+ reset = () => {
89
+ this.form.reset();
90
+ };
141
91
  }
@@ -1,16 +1,10 @@
1
- import type { IDisposer } from 'disposer-util';
2
- import { SubmitErrorHandler, SubmitHandler, UseFormProps, UseFormReturn } from 'react-hook-form';
3
- import { AnyObject } from 'yummies/utils/types';
1
+ import { FieldValues, SubmitErrorHandler, SubmitHandler, UseFormProps } from 'react-hook-form';
4
2
  import type { MobxForm } from './mobx-form.js';
3
+ export type AnyMobxForm = MobxForm<any, any, any>;
5
4
  /**
6
5
  * Additional options for {@link MobxForm} constructor
7
6
  */
8
- export interface MobxFormParams<TFieldValues extends AnyObject, TContext = any, TFieldOutputValues extends AnyObject = TFieldValues> extends UseFormProps<TFieldValues, TContext> {
9
- /**
10
- * Disposer for mobx form
11
- * @deprecated use {abortSignal} instead
12
- */
13
- disposer?: IDisposer;
7
+ export interface MobxFormParams<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> extends UseFormProps<TFieldValues, TContext, TTransformedValues> {
14
8
  /**
15
9
  * Abort signal for mobx form
16
10
  */
@@ -18,7 +12,7 @@ export interface MobxFormParams<TFieldValues extends AnyObject, TContext = any,
18
12
  /**
19
13
  * Form submit handler
20
14
  */
21
- onSubmit?: SubmitHandler<TFieldOutputValues>;
15
+ onSubmit?: SubmitHandler<TTransformedValues>;
22
16
  /**
23
17
  * Form submit failed handler
24
18
  */
@@ -27,27 +21,8 @@ export interface MobxFormParams<TFieldValues extends AnyObject, TContext = any,
27
21
  * Form reset handler
28
22
  */
29
23
  onReset?: VoidFunction;
30
- /**
31
- * Dynamic change react-hook-form params, works as reaction
32
- */
33
- getParams?: () => Partial<UseFormProps<TFieldValues, TContext>>;
34
- }
35
- /**
36
- * Interface for a connected Mobx form.
37
- * Extends the properties of react-hook-form's UseFormReturn,
38
- * Adds custom form handlers.
39
- */
40
- export interface ConnectedMobxForm<TFieldValues extends AnyObject, TContext = any, TFieldOutputValues extends AnyObject = TFieldValues> extends UseFormReturn<TFieldValues, TContext, TFieldOutputValues> {
41
- /**
42
- * Handler to reset the form.
43
- */
44
- onReset: VoidFunction;
45
- /**
46
- * Handler to submit the form.
47
- */
48
- onSubmit: VoidFunction;
49
24
  }
50
- export type ExtractFormFieldValues<T extends MobxForm<any, any, any>> = Exclude<T['params']['values'], undefined | null>;
51
- export type ExtractFormContext<T extends MobxForm<any, any, any>> = Exclude<T['params']['context'], undefined | null>;
52
- export type ExtractFormFieldOutputValues<T extends MobxForm<any, any, any>> = T extends MobxForm<any, any, infer TFieldOutputValues> ? TFieldOutputValues : never;
25
+ export type ExtractFormFieldValues<T extends AnyMobxForm> = Exclude<T['params']['values'], undefined | null>;
26
+ export type ExtractFormContext<T extends AnyMobxForm> = Exclude<T['params']['context'], undefined | null>;
27
+ export type ExtractFormFieldOutputValues<T extends AnyMobxForm> = T extends MobxForm<any, any, infer TFieldOutputValues> ? TFieldOutputValues : never;
53
28
  //# sourceMappingURL=mobx-form.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mobx-form.types.d.ts","sourceRoot":"","sources":["../../src/mobx-form/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CAAC;CACxB;AAED,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,WAAW,IAAI,OAAO,CACjE,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EACrB,SAAS,GAAG,IAAI,CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,OAAO,CAC7D,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EACtB,SAAS,GAAG,IAAI,CACjB,CAAC;AAEF,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,WAAW,IAC5D,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC,GAClD,kBAAkB,GAClB,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,20 +1,28 @@
1
1
  {
2
2
  "name": "mobx-react-hook-form",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
7
7
  "author": "js2me",
8
8
  "license": "MIT",
9
+ "bugs": {
10
+ "url": "https://github.com/js2me/mobx-react-hook-form/issues"
11
+ },
12
+ "homepage": "https://github.com/js2me/mobx-react-hook-form",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git://github.com/js2me/mobx-react-hook-form"
16
+ },
9
17
  "peerDependencies": {
10
18
  "mobx": "^6.12.4",
11
19
  "mobx-react-lite": "^4.0.7",
12
20
  "react": "^18.3.1",
13
- "react-hook-form": "^7.55.0"
21
+ "react-hook-form": "^7.56.1"
14
22
  },
15
23
  "dependencies": {
16
24
  "disposer-util": "^2.0.0",
17
- "linked-abort-controller": "^1.0.4",
25
+ "linked-abort-controller": "^1.1.0",
18
26
  "lodash-es": "^4.17.21",
19
27
  "yummies": "^3.0.39"
20
28
  },
@@ -22,21 +30,11 @@
22
30
  "@types/lodash-es": "^4.17.12",
23
31
  "eslint": "^8.57.1",
24
32
  "js2me-eslint-config": "^1.0.7",
25
- "js2me-exports-post-build-script": "^2.0.18",
33
+ "js2me-exports-post-build-script": "^3.0.1",
26
34
  "rimraf": "^6.0.1",
27
35
  "typescript": "^5.8.3"
28
36
  },
29
37
  "exports": {
30
- "./hooks": {
31
- "import": "./hooks/index.js",
32
- "default": "./hooks/index.js",
33
- "types": "./hooks/index.d.ts"
34
- },
35
- "./hooks/use-mobx-form": {
36
- "import": "./hooks/use-mobx-form.js",
37
- "default": "./hooks/use-mobx-form.js",
38
- "types": "./hooks/use-mobx-form.d.ts"
39
- },
40
38
  ".": {
41
39
  "import": "./index.js",
42
40
  "default": "./index.js",
@@ -64,8 +62,11 @@
64
62
  "check": "eslint . --fix",
65
63
  "prebuild": "npm run clean && npm run check",
66
64
  "build": "tsc && node ./post-build.mjs",
65
+ "pub": "PUBLISH=true pnpm run build",
66
+ "pub:next": "PUBLISH=true PUBLISH_TAG=next PUBLISH_FORCE=true pnpm run build",
67
67
  "pub:patch": "PUBLISH=true PUBLISH_VERSION=patch pnpm run build",
68
68
  "pub:minor": "PUBLISH=true PUBLISH_VERSION=minor pnpm run build",
69
- "pub:major": "PUBLISH=true PUBLISH_VERSION=major pnpm run build"
69
+ "pub:major": "PUBLISH=true PUBLISH_VERSION=major pnpm run build",
70
+ "pub:patch:next": "PUBLISH=true PUBLISH_VERSION=patch PUBLISH_TAG=next PUBLISH_FORCE=true pnpm run build"
70
71
  }
71
72
  }
package/hooks/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './use-mobx-form.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
package/hooks/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './use-mobx-form.js';
@@ -1,3 +0,0 @@
1
- import { ConnectedMobxForm, ExtractFormContext, ExtractFormFieldValues, MobxForm } from '../mobx-form/index.js';
2
- export declare const useMobxForm: <T extends MobxForm<any, any, any>>(mobxForm: T) => ConnectedMobxForm<ExtractFormFieldValues<T>, ExtractFormContext<T>>;
3
- //# sourceMappingURL=use-mobx-form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-mobx-form.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobx-form.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3D,UAAU,CAAC,KACV,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAEzB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { useForm } from 'react-hook-form';
2
- export const useMobxForm = (mobxForm) =>
3
- // @ts-expect-error ts(2445)
4
- mobxForm.connect(useForm(mobxForm.params));