remix-validated-form 4.0.1-beta.1 → 4.1.0-beta.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/.turbo/turbo-build.log +2 -2
- package/README.md +4 -4
- package/browser/ValidatedForm.d.ts +1 -1
- package/browser/ValidatedForm.js +99 -140
- package/browser/components.d.ts +5 -8
- package/browser/components.js +5 -5
- package/browser/hooks.d.ts +19 -14
- package/browser/hooks.js +36 -40
- package/browser/index.d.ts +1 -1
- package/browser/index.js +1 -0
- package/browser/internal/constants.d.ts +3 -0
- package/browser/internal/constants.js +3 -0
- package/browser/internal/formContext.d.ts +7 -49
- package/browser/internal/formContext.js +1 -1
- package/browser/internal/getInputProps.js +4 -3
- package/browser/internal/hooks.d.ts +23 -0
- package/browser/internal/hooks.js +114 -0
- package/browser/internal/state.d.ts +269 -0
- package/browser/internal/state.js +82 -0
- package/browser/internal/util.d.ts +1 -0
- package/browser/internal/util.js +2 -0
- package/browser/lowLevelHooks.d.ts +0 -0
- package/browser/lowLevelHooks.js +1 -0
- package/browser/server.d.ts +5 -0
- package/browser/server.js +5 -0
- package/browser/userFacingFormContext.d.ts +56 -0
- package/browser/userFacingFormContext.js +40 -0
- package/browser/validation/createValidator.js +4 -0
- package/browser/validation/types.d.ts +3 -0
- package/build/ValidatedForm.d.ts +1 -1
- package/build/ValidatedForm.js +95 -136
- package/build/hooks.d.ts +19 -14
- package/build/hooks.js +38 -46
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -0
- package/build/internal/constants.d.ts +3 -0
- package/build/internal/constants.js +7 -0
- package/build/internal/formContext.d.ts +7 -49
- package/build/internal/formContext.js +2 -2
- package/build/internal/getInputProps.js +7 -3
- package/build/internal/hooks.d.ts +23 -0
- package/build/internal/hooks.js +135 -0
- package/build/internal/state.d.ts +269 -0
- package/build/internal/state.js +92 -0
- package/build/internal/util.d.ts +1 -0
- package/build/internal/util.js +3 -1
- package/build/server.d.ts +5 -0
- package/build/server.js +7 -1
- package/build/userFacingFormContext.d.ts +56 -0
- package/build/userFacingFormContext.js +44 -0
- package/build/validation/createValidator.js +4 -0
- package/build/validation/types.d.ts +3 -0
- package/package.json +3 -1
- package/src/ValidatedForm.tsx +150 -181
- package/src/hooks.ts +69 -55
- package/src/index.ts +1 -1
- package/src/internal/constants.ts +4 -0
- package/src/internal/formContext.ts +8 -49
- package/src/internal/getInputProps.ts +6 -4
- package/src/internal/hooks.ts +200 -0
- package/src/internal/state.ts +210 -0
- package/src/internal/util.ts +4 -0
- package/src/server.ts +16 -0
- package/src/userFacingFormContext.ts +129 -0
- package/src/validation/createValidator.ts +4 -0
- package/src/validation/types.ts +3 -1
@@ -1,4 +1,5 @@
|
|
1
1
|
import { CreateValidatorArg, GenericObject, Validator } from "..";
|
2
|
+
import { FORM_ID_FIELD } from "../internal/constants";
|
2
3
|
import { objectFromPathEntries } from "../internal/flatten";
|
3
4
|
|
4
5
|
const preprocessFormData = (data: GenericObject | FormData): GenericObject => {
|
@@ -28,8 +29,10 @@ export function createValidator<T>(
|
|
28
29
|
error: {
|
29
30
|
fieldErrors: result.error,
|
30
31
|
subaction: data.subaction,
|
32
|
+
formId: data[FORM_ID_FIELD],
|
31
33
|
},
|
32
34
|
submittedData: data,
|
35
|
+
formId: data[FORM_ID_FIELD],
|
33
36
|
};
|
34
37
|
}
|
35
38
|
|
@@ -37,6 +40,7 @@ export function createValidator<T>(
|
|
37
40
|
data: result.data,
|
38
41
|
error: undefined,
|
39
42
|
submittedData: data,
|
43
|
+
formId: data[FORM_ID_FIELD],
|
40
44
|
};
|
41
45
|
},
|
42
46
|
validateField: (data: GenericObject | FormData, field: string) =>
|
package/src/validation/types.ts
CHANGED
@@ -6,16 +6,18 @@ export type GenericObject = { [key: string]: any };
|
|
6
6
|
|
7
7
|
export type ValidatorError = {
|
8
8
|
subaction?: string;
|
9
|
+
formId?: string;
|
9
10
|
fieldErrors: FieldErrors;
|
10
11
|
};
|
11
12
|
|
12
13
|
export type ValidationErrorResponseData = {
|
13
14
|
subaction?: string;
|
15
|
+
formId?: string;
|
14
16
|
fieldErrors: FieldErrors;
|
15
17
|
repopulateFields?: unknown;
|
16
18
|
};
|
17
19
|
|
18
|
-
export type BaseResult = { submittedData: GenericObject };
|
20
|
+
export type BaseResult = { submittedData: GenericObject; formId?: string };
|
19
21
|
export type ErrorResult = BaseResult & {
|
20
22
|
error: ValidatorError;
|
21
23
|
data: undefined;
|