@formisch/vue 0.6.5 → 0.7.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/index.d.ts +26 -11
- package/dist/index.js +3 -3
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue0 from "vue";
|
|
3
3
|
import { ComponentPublicInstance, MaybeRefOrGetter, ShallowRef as Signal } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/core/dist/index.vue.d.ts
|
|
@@ -282,7 +282,11 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
|
|
|
282
282
|
/**
|
|
283
283
|
* Submit handler type.
|
|
284
284
|
*/
|
|
285
|
-
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema
|
|
285
|
+
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
|
|
286
|
+
/**
|
|
287
|
+
* Submit event handler type.
|
|
288
|
+
*/
|
|
289
|
+
type SubmitEventHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
|
|
286
290
|
//#endregion
|
|
287
291
|
//#region src/types/path.d.ts
|
|
288
292
|
/**
|
|
@@ -467,6 +471,17 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
|
|
|
467
471
|
//#endregion
|
|
468
472
|
//#region src/handleSubmit/handleSubmit.d.ts
|
|
469
473
|
/**
|
|
474
|
+
* Creates a submit event handler for the form that validates the form input,
|
|
475
|
+
* and calls the provided handler if validation succeeds. This is designed to
|
|
476
|
+
* be used with the form's onsubmit event.
|
|
477
|
+
*
|
|
478
|
+
* @param form The form store to handle submission for.
|
|
479
|
+
* @param handler The submit handler function called with validated output if validation succeeds.
|
|
480
|
+
*
|
|
481
|
+
* @returns A submit event handler function to attach to the form element.
|
|
482
|
+
*/
|
|
483
|
+
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
|
|
484
|
+
/**
|
|
470
485
|
* Creates a submit event handler for the form that prevents default browser
|
|
471
486
|
* submission, validates the form input, and calls the provided handler if
|
|
472
487
|
* validation succeeds. This is designed to be used with the form's onsubmit event.
|
|
@@ -476,7 +491,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
|
|
|
476
491
|
*
|
|
477
492
|
* @returns A submit event handler function to attach to the form element.
|
|
478
493
|
*/
|
|
479
|
-
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler:
|
|
494
|
+
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: SubmitEvent) => Promise<void>;
|
|
480
495
|
//#endregion
|
|
481
496
|
//#region src/insert/insert.d.ts
|
|
482
497
|
/**
|
|
@@ -940,14 +955,14 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
940
955
|
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
941
956
|
}
|
|
942
957
|
declare const __VLS_export$2: <TSchema extends Schema, TFieldPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
943
|
-
props: __VLS_PrettifyLocal$2<FieldProps<TSchema, TFieldPath>> &
|
|
958
|
+
props: __VLS_PrettifyLocal$2<FieldProps<TSchema, TFieldPath>> & vue0.PublicProps;
|
|
944
959
|
expose: (exposed: {}) => void;
|
|
945
960
|
attrs: any;
|
|
946
961
|
slots: {
|
|
947
962
|
default(props: FieldStore<TSchema, TFieldPath>): any;
|
|
948
963
|
};
|
|
949
964
|
emit: {};
|
|
950
|
-
}>) =>
|
|
965
|
+
}>) => vue0.VNode & {
|
|
951
966
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
952
967
|
};
|
|
953
968
|
declare const _default: typeof __VLS_export$2;
|
|
@@ -968,14 +983,14 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
|
|
|
968
983
|
readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
|
|
969
984
|
}
|
|
970
985
|
declare const __VLS_export$1: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
971
|
-
props: __VLS_PrettifyLocal$1<FieldArrayProps<TSchema, TFieldArrayPath>> &
|
|
986
|
+
props: __VLS_PrettifyLocal$1<FieldArrayProps<TSchema, TFieldArrayPath>> & vue0.PublicProps;
|
|
972
987
|
expose: (exposed: {}) => void;
|
|
973
988
|
attrs: any;
|
|
974
989
|
slots: {
|
|
975
990
|
default(props: FieldArrayStore<TSchema, TFieldArrayPath>): any;
|
|
976
991
|
};
|
|
977
992
|
emit: {};
|
|
978
|
-
}>) =>
|
|
993
|
+
}>) => vue0.VNode & {
|
|
979
994
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
980
995
|
};
|
|
981
996
|
declare const _default$1: typeof __VLS_export$1;
|
|
@@ -993,17 +1008,17 @@ interface FormProps<TSchema extends Schema = Schema> {
|
|
|
993
1008
|
/**
|
|
994
1009
|
* The submit handler called when the form is submitted and validation succeeds.
|
|
995
1010
|
*/
|
|
996
|
-
onSubmit: SubmitHandler<TSchema>;
|
|
1011
|
+
onSubmit: SubmitHandler<TSchema> | SubmitEventHandler<TSchema>;
|
|
997
1012
|
}
|
|
998
1013
|
declare const __VLS_export: <TSchema extends Schema = Schema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
999
|
-
props: __VLS_PrettifyLocal<FormProps<TSchema>> &
|
|
1014
|
+
props: __VLS_PrettifyLocal<FormProps<TSchema>> & vue0.PublicProps;
|
|
1000
1015
|
expose: (exposed: {}) => void;
|
|
1001
1016
|
attrs: any;
|
|
1002
1017
|
slots: {
|
|
1003
1018
|
default?: (props: {}) => any;
|
|
1004
1019
|
};
|
|
1005
1020
|
emit: {};
|
|
1006
|
-
}>) =>
|
|
1021
|
+
}>) => vue0.VNode & {
|
|
1007
1022
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
1008
1023
|
};
|
|
1009
1024
|
declare const _default$2: typeof __VLS_export;
|
|
@@ -1060,4 +1075,4 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
|
|
|
1060
1075
|
*/
|
|
1061
1076
|
declare function useForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
|
|
1062
1077
|
//#endregion
|
|
1063
|
-
export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
|
|
1078
|
+
export { type DeepPartial, _default as Field, _default$1 as FieldArray, FieldArrayStore, type FieldElement, FieldElementProps, FieldStore, FocusFieldConfig, _default$2 as Form, type FormConfig, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
|
|
|
75
75
|
initializeFieldStore(internalFieldStore.children[index], schema.item, initialInput[index], path);
|
|
76
76
|
path.pop();
|
|
77
77
|
}
|
|
78
|
-
} else for (let index = 0; index < schema.items; index++) {
|
|
78
|
+
} else for (let index = 0; index < schema.items.length; index++) {
|
|
79
79
|
internalFieldStore.children[index] = {};
|
|
80
80
|
path.push(index);
|
|
81
81
|
initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput?.[index], path);
|
|
@@ -361,7 +361,7 @@ function setNestedInput(internalFieldStore, input) {
|
|
|
361
361
|
}
|
|
362
362
|
for (let index = 0; index < arrayInput.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
|
|
363
363
|
internalFieldStore.input.value = input == null ? input : true;
|
|
364
|
-
internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== items.length;
|
|
364
|
+
internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== internalFieldStore.items.value.length;
|
|
365
365
|
} else if (internalFieldStore.kind === "object") {
|
|
366
366
|
for (const key in internalFieldStore.children) setNestedInput(internalFieldStore.children[key], input?.[key]);
|
|
367
367
|
internalFieldStore.input.value = input == null ? input : true;
|
|
@@ -568,7 +568,7 @@ function getInput(form, config) {
|
|
|
568
568
|
/* @__NO_SIDE_EFFECTS__ */
|
|
569
569
|
function handleSubmit(form, handler) {
|
|
570
570
|
return async (event) => {
|
|
571
|
-
event
|
|
571
|
+
event?.preventDefault();
|
|
572
572
|
const internalFormStore = form[INTERNAL];
|
|
573
573
|
internalFormStore.isSubmitted.value = true;
|
|
574
574
|
internalFormStore.isSubmitting.value = true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formisch/vue",
|
|
3
3
|
"description": "The modular and type-safe form library for Vue",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fabian Hiller",
|
|
7
7
|
"homepage": "https://formisch.dev",
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
"valibot": "^1.2.0",
|
|
44
44
|
"vue": "^3.5.18",
|
|
45
45
|
"vue-tsc": "^3.0.4",
|
|
46
|
-
"@formisch/
|
|
47
|
-
"@formisch/
|
|
46
|
+
"@formisch/eslint-config": "0.1.0",
|
|
47
|
+
"@formisch/core": "0.6.0",
|
|
48
|
+
"@formisch/methods": "0.7.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"typescript": ">=5",
|