@maestro-js/form 1.0.0-alpha.19 → 1.0.0-alpha.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/dist/index.d.ts +2 -3
- package/dist/index.js +3 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,8 +110,7 @@ type ParseFormDataResult<T> = {
|
|
|
110
110
|
};
|
|
111
111
|
interface ParseFormDataOptions<T> {
|
|
112
112
|
handleFile?(file: File, path: string, data: T): Promise<string>;
|
|
113
|
-
|
|
114
|
-
jsonSchemaLibraryOptions?: Record<string, unknown> | undefined;
|
|
113
|
+
libraryOptions?: Record<string, unknown> | undefined;
|
|
115
114
|
}
|
|
116
115
|
declare function parseFormDataClientSide<T>(schema: StandardSchema<T>, formData: FormData, options?: ParseFormDataOptions<T>): ParseFormDataResult<T> & {
|
|
117
116
|
fileEntries: FoundFile[];
|
|
@@ -181,4 +180,4 @@ declare const HeadlessForm: (<As extends React.ElementType = "form">(props: {
|
|
|
181
180
|
composeValidators: typeof composeValidators;
|
|
182
181
|
};
|
|
183
182
|
|
|
184
|
-
export { HeadlessForm, type HeadlessFormProps, type
|
|
183
|
+
export { HeadlessForm, type HeadlessFormProps, type ValidationFunction, type ValidationResult };
|
package/dist/index.js
CHANGED
|
@@ -775,13 +775,10 @@ function formPathsMatch(path1, path2) {
|
|
|
775
775
|
// src/standard-schema-helpers.ts
|
|
776
776
|
function parseFormDataClientSide(schema, formData, options) {
|
|
777
777
|
const formId = formData.get("__formId");
|
|
778
|
-
const jsonSchemaParsed = parseJsonSchemaFormData(
|
|
779
|
-
schema["~standard"].jsonSchema.input({ target: "openapi-3.0", libraryOptions: options?.jsonSchemaLibraryOptions }),
|
|
780
|
-
formData
|
|
781
|
-
);
|
|
778
|
+
const jsonSchemaParsed = parseJsonSchemaFormData(schema["~standard"].jsonSchema.input({ target: "openapi-3.0" }), formData);
|
|
782
779
|
const files = findFiles(jsonSchemaParsed);
|
|
783
780
|
files.forEach((f) => set2(jsonSchemaParsed, f.path.join("."), "https://fakeurlforformuploading.com"));
|
|
784
|
-
const safeParsed = schema["~standard"].validate(jsonSchemaParsed,
|
|
781
|
+
const safeParsed = schema["~standard"].validate(jsonSchemaParsed, options);
|
|
785
782
|
if (isPromise(safeParsed)) {
|
|
786
783
|
throw new Error("Async validation not supported");
|
|
787
784
|
}
|
|
@@ -816,7 +813,7 @@ async function parseFormData(schema, formData, options) {
|
|
|
816
813
|
);
|
|
817
814
|
const obj2 = { ...parsed1.data };
|
|
818
815
|
uploadedFiles.forEach(({ key, value }) => set2(obj2, key, value));
|
|
819
|
-
const safeParsed2 = schema["~standard"].validate(obj2,
|
|
816
|
+
const safeParsed2 = schema["~standard"].validate(obj2, options);
|
|
820
817
|
if (isPromise(safeParsed2)) {
|
|
821
818
|
throw new Error("Async validation not supported");
|
|
822
819
|
}
|