mobx-react-hook-form 5.1.4 → 5.2.1
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 +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/mobx-form/deep-observable-struct.d.ts +1 -1
- package/mobx-form/deep-observable-struct.d.ts.map +1 -1
- package/mobx-form/deep-observable-struct.js +11 -6
- package/mobx-form/mobx-form.d.ts +3 -3
- package/mobx-form/mobx-form.d.ts.map +1 -1
- package/mobx-form/mobx-form.js +19 -8
- package/mobx-form/mobx-form.types.d.ts +1 -1
- package/mobx-form/mobx-form.types.d.ts.map +1 -1
- package/package.json +19 -6
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx-form/deep-observable-struct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx-form/deep-observable-struct.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBAAa,oBAAoB,CAAC,KAAK,SAAS,SAAS;IACvD,IAAI,EAAE,KAAK,CAAC;gBAEA,IAAI,EAAE,KAAK;IASvB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;CAoD5B"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
/* eslint-disable no-prototype-builtins */
|
|
3
|
-
/* eslint-disable sonarjs/cognitive-complexity */
|
|
4
1
|
import { action, makeObservable, observable } from 'mobx';
|
|
5
2
|
import { typeGuard } from 'yummies/type-guard';
|
|
6
3
|
export class DeepObservableStruct {
|
|
@@ -18,10 +15,13 @@ export class DeepObservableStruct {
|
|
|
18
15
|
this.data,
|
|
19
16
|
newData,
|
|
20
17
|
]);
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
let currentIndex = 0;
|
|
19
|
+
let stackLength = stack.length;
|
|
20
|
+
while (currentIndex < stackLength) {
|
|
21
|
+
const [key, currObservableData, newData] = stack[currentIndex];
|
|
23
22
|
const newValue = newData[key];
|
|
24
23
|
const currValue = currObservableData[key];
|
|
24
|
+
currentIndex++;
|
|
25
25
|
if (key in newData) {
|
|
26
26
|
if (typeGuard.isObject(newValue) && typeGuard.isObject(currValue)) {
|
|
27
27
|
const newValueKeys = Object.keys(newValue);
|
|
@@ -31,7 +31,12 @@ export class DeepObservableStruct {
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
newValueKeys.forEach((childKey) => {
|
|
34
|
-
stack.push([
|
|
34
|
+
const length = stack.push([
|
|
35
|
+
childKey,
|
|
36
|
+
currObservableData[key],
|
|
37
|
+
newValue,
|
|
38
|
+
]);
|
|
39
|
+
stackLength = length;
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
else if (newValue !== currValue) {
|
package/mobx-form/mobx-form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSyntheticEvent } from 'react';
|
|
2
|
-
import { Control, createFormControl, DeepMap, DeepPartial, DefaultValues, FieldErrors, FieldPath, FieldPathValue, FieldValues, FormState, SetValueConfig, UseFormClearErrors, UseFormRegister, UseFormReset, UseFormResetField, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormTrigger, UseFormUnregister } from 'react-hook-form';
|
|
3
|
-
import { FormParams } from './mobx-form.types.js';
|
|
1
|
+
import type { BaseSyntheticEvent } from 'react';
|
|
2
|
+
import { type Control, createFormControl, type DeepMap, type DeepPartial, type DefaultValues, type FieldErrors, type FieldPath, type FieldPathValue, type FieldValues, type FormState, type SetValueConfig, type UseFormClearErrors, type UseFormRegister, type UseFormReset, type UseFormResetField, type UseFormSetError, type UseFormSetFocus, type UseFormSetValue, type UseFormTrigger, type UseFormUnregister } from 'react-hook-form';
|
|
3
|
+
import type { FormParams } from './mobx-form.types.js';
|
|
4
4
|
type FormFullState<TFieldValues extends FieldValues> = FormState<TFieldValues> & {
|
|
5
5
|
values: TFieldValues;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-form.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mobx-form.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,KAAK,OAAO,EACZ,iBAAiB,EACjB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,KAAK,aAAa,CAAC,YAAY,SAAS,WAAW,IACjD,SAAS,CAAC,YAAY,CAAC,GAAG;IACxB,MAAM,EAAE,YAAY,CAAC;CAC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AAC,CAAC,CAAC,EAAE,kBAAkB;IAK5B,OAAO,CAAC,eAAe;IAwBvB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5C,OAAO,CAAC,4BAA4B,CAKlC;IAEF,OAAO,CAAC,uBAAuB,CAQ7B;IAEF,OAAO,IAAI,IAAI;CAIhB;AAED;;GAEG;AACH,qBAAa,QAAQ,CACnB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,CACjC,SAAQ,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC;CAAG"}
|
package/mobx-form/mobx-form.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
1
|
import { LinkedAbortController } from 'linked-abort-controller';
|
|
3
2
|
import { action, isObservableObject, makeObservable, observable, toJS, } from 'mobx';
|
|
4
3
|
import { createFormControl, get, set, } from 'react-hook-form';
|
|
@@ -388,13 +387,25 @@ export class Form {
|
|
|
388
387
|
*/
|
|
389
388
|
submit(e) {
|
|
390
389
|
return new Promise((resolve, reject) => {
|
|
391
|
-
this.originalForm
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
390
|
+
if (this.originalForm) {
|
|
391
|
+
this.originalForm.handleSubmit(async (data, event) => {
|
|
392
|
+
await this.config.onSubmit?.(data, event);
|
|
393
|
+
resolve(data);
|
|
394
|
+
}, async (errors, event) => {
|
|
395
|
+
await this.config.onSubmitFailed?.(errors, event);
|
|
396
|
+
reject(errors);
|
|
397
|
+
})(e);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
const emptyData = {};
|
|
401
|
+
const result = this.config.onSubmit?.(emptyData);
|
|
402
|
+
if (result instanceof Promise) {
|
|
403
|
+
return result.then(() => resolve(emptyData));
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
return Promise.resolve(emptyData);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
398
409
|
});
|
|
399
410
|
}
|
|
400
411
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepPartial, FieldValues, SubmitErrorHandler, SubmitHandler, UseFormProps } from 'react-hook-form';
|
|
1
|
+
import type { DeepPartial, FieldValues, SubmitErrorHandler, SubmitHandler, UseFormProps } from 'react-hook-form';
|
|
2
2
|
import type { Form } from './mobx-form.js';
|
|
3
3
|
export type AnyForm = Form<any, any, any>;
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-form.types.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mobx-form.types.d.ts","sourceRoot":"","sources":["../../src/mobx-form/mobx-form.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,UAAU,CACzB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,CACjC,SAAQ,IAAI,CACV,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACxD,eAAe,CAChB;IACD;;OAEG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1C;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC7C;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAClD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,IAC/B,UAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AAE3D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,OAAO,IAAI,OAAO,CAC7D,CAAC,CAAC,QAAQ,CAAC,EACX,SAAS,GAAG,IAAI,CACjB,CAAC;AAEF,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,CAC1E,GAAG,EACH,GAAG,EACH,MAAM,kBAAkB,CACzB,GACG,kBAAkB,GAClB,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-react-hook-form",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -27,14 +27,17 @@
|
|
|
27
27
|
"yummies": "^4.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"js2me-eslint-config": "^1.0.7",
|
|
30
|
+
"@biomejs/biome": "2.1.4",
|
|
31
|
+
"commitfmt": "^1.0.4",
|
|
33
32
|
"js2me-exports-post-build-script": "^3.0.2",
|
|
33
|
+
"jsdom": "^26.1.0",
|
|
34
|
+
"@vitejs/plugin-react-swc": "^3.9.0",
|
|
35
|
+
"@vitest/coverage-istanbul": "^3.1.2",
|
|
34
36
|
"lefthook": "^1.11.13",
|
|
35
37
|
"nodemon": "^3.1.10",
|
|
36
38
|
"rimraf": "^6.0.1",
|
|
37
|
-
"typescript": "^5.8.3"
|
|
39
|
+
"typescript": "^5.8.3",
|
|
40
|
+
"vitest": "^3.1.2"
|
|
38
41
|
},
|
|
39
42
|
"exports": {
|
|
40
43
|
"./components/controller": {
|
|
@@ -52,6 +55,11 @@
|
|
|
52
55
|
"default": "./index.js",
|
|
53
56
|
"types": "./index.d.ts"
|
|
54
57
|
},
|
|
58
|
+
"./mobx-form/deep-observable-struct.test": {
|
|
59
|
+
"import": "./mobx-form/deep-observable-struct.test.js",
|
|
60
|
+
"default": "./mobx-form/deep-observable-struct.test.js",
|
|
61
|
+
"types": "./mobx-form/deep-observable-struct.test.d.ts"
|
|
62
|
+
},
|
|
55
63
|
"./mobx-form/deep-observable-struct": {
|
|
56
64
|
"import": "./mobx-form/deep-observable-struct.js",
|
|
57
65
|
"default": "./mobx-form/deep-observable-struct.js",
|
|
@@ -76,7 +84,9 @@
|
|
|
76
84
|
"typings": "./index.d.ts",
|
|
77
85
|
"scripts": {
|
|
78
86
|
"clean": "rimraf dist",
|
|
79
|
-
"check": "
|
|
87
|
+
"lint:check": "pnpm exec biome check --write --no-errors-on-unmatched --files-ignore-unknown=true",
|
|
88
|
+
"ts:check": "tsc --noEmit",
|
|
89
|
+
"check": "npm run lint:check && npm run ts:check",
|
|
80
90
|
"prebuild": "npm run clean && npm run check",
|
|
81
91
|
"build": "tsc && node ./post-build.mjs",
|
|
82
92
|
"build:watch": "npm run build && nodemon --delay 0.5 --watch src --ext ts,tsx --exec \"tsc && node ./post-build.mjs\"",
|
|
@@ -85,6 +95,9 @@
|
|
|
85
95
|
"pub:patch": "PUBLISH=true PUBLISH_VERSION=patch pnpm run build",
|
|
86
96
|
"pub:minor": "PUBLISH=true PUBLISH_VERSION=minor pnpm run build",
|
|
87
97
|
"pub:major": "PUBLISH=true PUBLISH_VERSION=major pnpm run build",
|
|
98
|
+
"test": "vitest run --config vitest.config.ts",
|
|
99
|
+
"test:watch": "vitest watch --config vitest.config.ts",
|
|
100
|
+
"test:coverage": "vitest run --config vitest.config.ts --coverage",
|
|
88
101
|
"pub:patch:next": "PUBLISH=true PUBLISH_VERSION=patch PUBLISH_TAG=next PUBLISH_FORCE=true pnpm run build",
|
|
89
102
|
"dev:install-hooks": "if [ -z \"$CI\" ]; then lefthook install; fi"
|
|
90
103
|
}
|