@formisch/qwik 0.9.5 → 0.10.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/README.md +2 -2
- package/dist/index.d.ts +10 -8
- package/dist/index.qwik.js +15 -3
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -28,9 +28,9 @@ const LoginSchema = v.object({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
export default component$(() => {
|
|
31
|
-
const loginForm = useForm$({
|
|
31
|
+
const loginForm = useForm$(() => ({
|
|
32
32
|
schema: LoginSchema,
|
|
33
|
-
});
|
|
33
|
+
}));
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<Form of={loginForm} onSubmit$={(output, event) => console.log(output)}>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { JSXOutput, NoSerialize, PropsOf, QRL, ReadonlySignal } from "@qwik.dev/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _qwik_dev_core_internal0 from "@qwik.dev/core/internal";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/core/dist/index.qwik.d.ts
|
|
6
6
|
|
|
@@ -989,7 +989,7 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
989
989
|
*
|
|
990
990
|
* @returns The UI of the field to be rendered.
|
|
991
991
|
*/
|
|
992
|
-
declare const Field: <TSchema extends Schema, TFieldPath extends RequiredPath>(props:
|
|
992
|
+
declare const Field: <TSchema extends Schema, TFieldPath extends RequiredPath>(props: _qwik_dev_core_internal0.PublicProps<FieldProps<TSchema, TFieldPath>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal0.DevJSX) => JSXOutput;
|
|
993
993
|
//#endregion
|
|
994
994
|
//#region src/components/FieldArray/FieldArray.d.ts
|
|
995
995
|
/**
|
|
@@ -1017,7 +1017,7 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
|
|
|
1017
1017
|
*
|
|
1018
1018
|
* @returns The UI of the field array to be rendered.
|
|
1019
1019
|
*/
|
|
1020
|
-
declare const FieldArray: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(props:
|
|
1020
|
+
declare const FieldArray: <TSchema extends Schema, TFieldArrayPath extends RequiredPath>(props: _qwik_dev_core_internal0.PublicProps<FieldArrayProps<TSchema, TFieldArrayPath>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal0.DevJSX) => JSXOutput;
|
|
1021
1021
|
//#endregion
|
|
1022
1022
|
//#region src/components/Form/Form.d.ts
|
|
1023
1023
|
/**
|
|
@@ -1031,7 +1031,7 @@ type FormProps<TSchema extends Schema = Schema> = Omit<PropsOf<'form'>, 'onSubmi
|
|
|
1031
1031
|
/**
|
|
1032
1032
|
* The submit handler called when the form is submitted and validation succeeds.
|
|
1033
1033
|
*/
|
|
1034
|
-
readonly onSubmit$: QRL<
|
|
1034
|
+
readonly onSubmit$: QRL<SubmitEventHandler<TSchema>>;
|
|
1035
1035
|
};
|
|
1036
1036
|
/**
|
|
1037
1037
|
* Form component that manages form submission and applies internal state.
|
|
@@ -1039,7 +1039,7 @@ type FormProps<TSchema extends Schema = Schema> = Omit<PropsOf<'form'>, 'onSubmi
|
|
|
1039
1039
|
*
|
|
1040
1040
|
* @returns The a native form element.
|
|
1041
1041
|
*/
|
|
1042
|
-
declare const Form: <TSchema extends Schema>(props:
|
|
1042
|
+
declare const Form: <TSchema extends Schema>(props: _qwik_dev_core_internal0.PublicProps<FormProps<TSchema>>, key: string | null, flags: number, dev?: _qwik_dev_core_internal0.DevJSX) => JSXOutput;
|
|
1043
1043
|
//#endregion
|
|
1044
1044
|
//#region src/hooks/useField/useField.d.ts
|
|
1045
1045
|
/**
|
|
@@ -1086,17 +1086,19 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
|
|
|
1086
1086
|
* Creates a reactive form store from a form configuration. The form store
|
|
1087
1087
|
* manages form state and provides reactive properties.
|
|
1088
1088
|
*
|
|
1089
|
-
* @param configQrl The QRL containing the form configuration.
|
|
1089
|
+
* @param configQrl The QRL containing a function that returns the form configuration.
|
|
1090
1090
|
*
|
|
1091
1091
|
* @returns The form store with reactive properties.
|
|
1092
1092
|
*/
|
|
1093
|
-
declare function useFormQrl<TSchema extends Schema>(configQrl: QRL<FormConfig<TSchema>>): FormStore<TSchema>;
|
|
1093
|
+
declare function useFormQrl<TSchema extends Schema>(configQrl: QRL<() => FormConfig<TSchema>>): FormStore<TSchema>;
|
|
1094
1094
|
/**
|
|
1095
1095
|
* Creates a reactive form store from a form configuration. The form store
|
|
1096
1096
|
* manages form state and provides reactive properties.
|
|
1097
1097
|
*
|
|
1098
|
+
* @param configFn A function that returns the form configuration.
|
|
1099
|
+
*
|
|
1098
1100
|
* @returns The form store with reactive properties.
|
|
1099
1101
|
*/
|
|
1100
|
-
declare const useForm$: <TSchema extends Schema>(qrl: FormConfig<TSchema>) => FormStore<TSchema>;
|
|
1102
|
+
declare const useForm$: <TSchema extends Schema>(qrl: () => FormConfig<TSchema>) => FormStore<TSchema>;
|
|
1101
1103
|
//#endregion
|
|
1102
1104
|
export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, 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$, useFormQrl, validate };
|
package/dist/index.qwik.js
CHANGED
|
@@ -568,6 +568,7 @@ function focus(form, config) {
|
|
|
568
568
|
function getAllErrors(form) {
|
|
569
569
|
let allErrors = null;
|
|
570
570
|
walkFieldStore(form[INTERNAL], (internalFieldStore) => {
|
|
571
|
+
if (internalFieldStore.kind === "array") internalFieldStore.items.value;
|
|
571
572
|
const errors = internalFieldStore.errors.value;
|
|
572
573
|
if (errors) if (allErrors) allErrors.push(...errors);
|
|
573
574
|
else allErrors = [...errors];
|
|
@@ -620,7 +621,15 @@ function insert(form, config) {
|
|
|
620
621
|
const newItems = [...items];
|
|
621
622
|
newItems.splice(insertIndex, 0, createId());
|
|
622
623
|
internalArrayStore.items.value = newItems;
|
|
623
|
-
for (let index = items.length; index > insertIndex; index--)
|
|
624
|
+
for (let index = items.length; index > insertIndex; index--) {
|
|
625
|
+
if (!internalArrayStore.children[index]) {
|
|
626
|
+
const path = JSON.parse(internalArrayStore.name);
|
|
627
|
+
internalArrayStore.children[index] = {};
|
|
628
|
+
path.push(index);
|
|
629
|
+
initializeFieldStore(internalArrayStore.children[index], internalArrayStore.schema.item, void 0, path);
|
|
630
|
+
}
|
|
631
|
+
copyItemState(internalArrayStore.children[index - 1], internalArrayStore.children[index]);
|
|
632
|
+
}
|
|
624
633
|
if (!internalArrayStore.children[insertIndex]) {
|
|
625
634
|
const path = JSON.parse(internalArrayStore.name);
|
|
626
635
|
internalArrayStore.children[insertIndex] = {};
|
|
@@ -899,12 +908,13 @@ function useResolvedQrl(qrl) {
|
|
|
899
908
|
//#region src/hooks/useForm$/useForm$.ts
|
|
900
909
|
/* @__NO_SIDE_EFFECTS__ */
|
|
901
910
|
function useFormQrl(configQrl) {
|
|
902
|
-
const
|
|
911
|
+
const configFn = useResolvedQrl(configQrl);
|
|
912
|
+
const config = configFn();
|
|
903
913
|
const form = useConstant(() => {
|
|
904
914
|
const internalFormStore = createFormStore({
|
|
905
915
|
...config,
|
|
906
916
|
schema: JSON.parse(JSON.stringify(config.schema))
|
|
907
|
-
}, $(async (input) => v.safeParseAsync((await configQrl.resolve()).schema, input)));
|
|
917
|
+
}, $(async (input) => v.safeParseAsync((await configQrl.resolve())().schema, input)));
|
|
908
918
|
return {
|
|
909
919
|
[INTERNAL]: internalFormStore,
|
|
910
920
|
isSubmitting: internalFormStore.isSubmitting,
|
|
@@ -926,6 +936,8 @@ function useFormQrl(configQrl) {
|
|
|
926
936
|
* Creates a reactive form store from a form configuration. The form store
|
|
927
937
|
* manages form state and provides reactive properties.
|
|
928
938
|
*
|
|
939
|
+
* @param configFn A function that returns the form configuration.
|
|
940
|
+
*
|
|
929
941
|
* @returns The form store with reactive properties.
|
|
930
942
|
*/
|
|
931
943
|
const useForm$ = implicit$FirstArg(useFormQrl);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formisch/qwik",
|
|
3
3
|
"description": "The modular and type-safe form library for Qwik",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fabian Hiller",
|
|
7
7
|
"homepage": "https://formisch.dev",
|
|
@@ -35,7 +35,18 @@
|
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
37
37
|
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
|
|
41
|
+
"lint.fix": "eslint \"src/**/*.ts*\" --fix",
|
|
42
|
+
"format": "prettier --write ./src",
|
|
43
|
+
"format.check": "prettier --check ./src",
|
|
44
|
+
"qwik": "qwik"
|
|
45
|
+
},
|
|
38
46
|
"devDependencies": {
|
|
47
|
+
"@formisch/core": "workspace:*",
|
|
48
|
+
"@formisch/eslint-config": "workspace:*",
|
|
49
|
+
"@formisch/methods": "workspace:*",
|
|
39
50
|
"@qwik.dev/core": "2.0.0-beta.5",
|
|
40
51
|
"@types/node": "24.0.13",
|
|
41
52
|
"eslint": "9.31.0",
|
|
@@ -46,10 +57,7 @@
|
|
|
46
57
|
"typescript": "5.8.3",
|
|
47
58
|
"valibot": "^1.2.0",
|
|
48
59
|
"vite": "7.0.4",
|
|
49
|
-
"vite-tsconfig-paths": "^5.1.4"
|
|
50
|
-
"@formisch/eslint-config": "0.1.0",
|
|
51
|
-
"@formisch/core": "0.6.3",
|
|
52
|
-
"@formisch/methods": "0.7.0"
|
|
60
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
53
61
|
},
|
|
54
62
|
"peerDependencies": {
|
|
55
63
|
"@qwik.dev/core": ">=2",
|
|
@@ -60,13 +68,5 @@
|
|
|
60
68
|
"typescript": {
|
|
61
69
|
"optional": true
|
|
62
70
|
}
|
|
63
|
-
},
|
|
64
|
-
"scripts": {
|
|
65
|
-
"build": "tsdown",
|
|
66
|
-
"lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
|
|
67
|
-
"lint.fix": "eslint \"src/**/*.ts*\" --fix",
|
|
68
|
-
"format": "prettier --write ./src",
|
|
69
|
-
"format.check": "prettier --check ./src",
|
|
70
|
-
"qwik": "qwik"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|