mobx-form 14.0.0 → 14.2.0
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/dist/FormModel.d.ts +8 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/FormModel.d.ts
CHANGED
|
@@ -14,7 +14,13 @@ export type ErrorLike = {
|
|
|
14
14
|
message: string;
|
|
15
15
|
} | Error;
|
|
16
16
|
export type ValidatorResult = boolean | ResultObj | void;
|
|
17
|
-
export type
|
|
17
|
+
export type ValidateFnArgs<T, K> = {
|
|
18
|
+
field: Field<T, K>;
|
|
19
|
+
fields: FormModel<K>["fields"];
|
|
20
|
+
model: FormModel<K>;
|
|
21
|
+
value: Field<T, K>["value"];
|
|
22
|
+
};
|
|
23
|
+
export type ValidateFn<T, K> = (args: ValidateFnArgs<T, K>) => Promise<ValidatorResult> | ValidatorResult;
|
|
18
24
|
export type ResetInteractedFlagType = {
|
|
19
25
|
resetInteractedFlag?: boolean;
|
|
20
26
|
};
|
|
@@ -226,7 +232,7 @@ export declare class FormModel<K> {
|
|
|
226
232
|
/**
|
|
227
233
|
* return the data as plain Javascript object (mobx magic removed from the fields)
|
|
228
234
|
* */
|
|
229
|
-
get serializedData():
|
|
235
|
+
get serializedData(): K;
|
|
230
236
|
/**
|
|
231
237
|
* Creates an instance of FormModel.
|
|
232
238
|
* initialState => an object which keys are the names of the fields and the values the initial values for the form.
|
package/dist/index.cjs
CHANGED
|
@@ -199,7 +199,7 @@ class Field {
|
|
|
199
199
|
if (typeof vfn !== "function") {
|
|
200
200
|
throw new Error("Validator must be a function or a function[]");
|
|
201
201
|
}
|
|
202
|
-
ret = await vfn(this,
|
|
202
|
+
ret = await vfn({ value: this.value, field, fields, model: model2 });
|
|
203
203
|
if (ret === false || ret?.error) {
|
|
204
204
|
return ret;
|
|
205
205
|
}
|
package/dist/index.js
CHANGED
|
@@ -148,7 +148,7 @@ class Field {
|
|
|
148
148
|
if (typeof vfn !== "function") {
|
|
149
149
|
throw new Error("Validator must be a function or a function[]");
|
|
150
150
|
}
|
|
151
|
-
ret = await vfn(this,
|
|
151
|
+
ret = await vfn({ value: this.value, field, fields, model: model2 });
|
|
152
152
|
if (ret === false || ret?.error) {
|
|
153
153
|
return ret;
|
|
154
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-form",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "A simple form helper for mobx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"prepublishOnly": "npm run build",
|
|
27
27
|
"test": "bun test",
|
|
28
28
|
"build": "rm -rf ./dist && bun bun.build.ts && npm run dts",
|
|
29
|
-
"dts": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --outDir dist",
|
|
29
|
+
"dts": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --outDir dist",
|
|
30
30
|
"smoke:test": "bun simple-demo.ts"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|