@formisch/qwik 0.7.3 → 0.8.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 CHANGED
@@ -868,6 +868,10 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
868
868
  * Whether the field is valid according to the schema.
869
869
  */
870
870
  readonly isValid: ReadonlySignal<boolean>;
871
+ /**
872
+ * Sets the field input value programmatically.
873
+ */
874
+ readonly onInput: QRL<(value: PartialValues<PathValue<v.InferInput<TSchema>, TFieldPath>>) => void>;
871
875
  /**
872
876
  * The props to spread onto the field element for integration.
873
877
  */
@@ -1031,6 +1035,9 @@ interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends Req
1031
1035
  /**
1032
1036
  * Creates a reactive field store of a specific field within a form store.
1033
1037
  *
1038
+ * @param form The form store instance.
1039
+ * @param config The field configuration.
1040
+ *
1034
1041
  * @returns The field store with reactive properties and element props.
1035
1042
  */
1036
1043
  declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: FormStore<TSchema>, config: UseFieldConfig<TSchema, TFieldPath>): FieldStore<TSchema, TFieldPath>;
@@ -1048,6 +1055,9 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
1048
1055
  /**
1049
1056
  * Creates a reactive field array store of a specific field array within a form store.
1050
1057
  *
1058
+ * @param form The form store instance.
1059
+ * @param config The field array configuration.
1060
+ *
1051
1061
  * @returns The field array store with reactive properties for array management.
1052
1062
  */
1053
1063
  declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: FormStore<TSchema>, config: UseFieldArrayConfig<TSchema, TFieldArrayPath>): FieldArrayStore<TSchema, TFieldArrayPath>;
@@ -1057,6 +1067,8 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
1057
1067
  * Creates a reactive form store from a form configuration. The form store
1058
1068
  * manages form state and provides reactive properties.
1059
1069
  *
1070
+ * @param configQrl The QRL containing the form configuration.
1071
+ *
1060
1072
  * @returns The form store with reactive properties.
1061
1073
  */
1062
1074
  declare function useFormQrl<TSchema extends Schema>(configQrl: QRL<FormConfig<TSchema>>): FormStore<TSchema>;
@@ -41,7 +41,7 @@ function batch(fn) {
41
41
  function initializeFieldStore(internalFieldStore, schema, initialInput, path, nullish = false) {
42
42
  if (framework === "qwik" && schema.type === "lazy" || schema.type === "object_with_rest" || schema.type === "record" || schema.type === "tuple_with_rest" || schema.type === "promise") throw new Error(`"${schema.type}" schema is not supported`);
43
43
  else if (schema.type === "lazy") initializeFieldStore(internalFieldStore, schema.getter(void 0), initialInput, path);
44
- else if (schema.type === "exact_optional" || schema.type === "nullable" || schema.type === "nullish" || schema.type === "optional" || schema.type === "undefinedable") initializeFieldStore(internalFieldStore, schema.wrapped, initialInput ?? v.getDefault(schema), path, true);
44
+ else if (schema.type === "exact_optional" || schema.type === "nullable" || schema.type === "nullish" || schema.type === "optional" || schema.type === "undefinedable") initializeFieldStore(internalFieldStore, schema.wrapped, initialInput === void 0 ? v.getDefault(schema) : initialInput, path, true);
45
45
  else if (schema.type === "non_nullable" || schema.type === "non_nullish" || schema.type === "non_optional") initializeFieldStore(internalFieldStore, schema.wrapped, initialInput, path);
46
46
  else if (schema.type === "intersect" || schema.type === "union" || schema.type === "variant") for (const schemaOption of schema.options) initializeFieldStore(internalFieldStore, schemaOption, initialInput, path);
47
47
  else {
@@ -65,7 +65,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
65
65
  initializeFieldStore(internalFieldStore.children[index], schema.item, initialInput[index], path);
66
66
  path.pop();
67
67
  }
68
- } else for (let index = 0; index < schema.items; index++) {
68
+ } else for (let index = 0; index < schema.items.length; index++) {
69
69
  internalFieldStore.children[index] = {};
70
70
  path.push(index);
71
71
  initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput?.[index], path);
@@ -378,7 +378,7 @@ function setNestedInput(internalFieldStore, input) {
378
378
  }
379
379
  for (let index = 0; index < arrayInput.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
380
380
  internalFieldStore.input.value = input == null ? input : true;
381
- internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== items.length;
381
+ internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== internalFieldStore.items.value.length;
382
382
  } else if (internalFieldStore.kind === "object") {
383
383
  for (const key in internalFieldStore.children) setNestedInput(internalFieldStore.children[key], input?.[key]);
384
384
  internalFieldStore.input.value = input == null ? input : true;
@@ -829,6 +829,10 @@ function useField(form, config) {
829
829
  isTouched: createComputed$(() => getFieldBool(internalFieldStore.value, "isTouched")),
830
830
  isDirty: createComputed$(() => getFieldBool(internalFieldStore.value, "isDirty")),
831
831
  isValid: createComputed$(() => !getFieldBool(internalFieldStore.value, "errors")),
832
+ onInput: $((value) => {
833
+ setFieldInput(internalFormStore, pathSignal.value, value);
834
+ validateIfRequired(internalFormStore, internalFieldStore.value, "input");
835
+ }),
832
836
  props: {
833
837
  get name() {
834
838
  return internalFieldStore.value.name;
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.7.3",
4
+ "version": "0.8.0",
5
5
  "license": "MIT",
6
6
  "author": "Fabian Hiller",
7
7
  "homepage": "https://formisch.dev",
@@ -36,7 +36,6 @@
36
36
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@eslint/js": "^9.31.0",
40
39
  "@qwik.dev/core": "2.0.0-beta.5",
41
40
  "@types/node": "24.0.13",
42
41
  "eslint": "9.31.0",
@@ -45,12 +44,12 @@
45
44
  "prettier": "3.6.2",
46
45
  "tsdown": "0.12.9",
47
46
  "typescript": "5.8.3",
48
- "typescript-eslint": "8.36.0",
49
47
  "valibot": "^1.2.0",
50
48
  "vite": "7.0.4",
51
49
  "vite-tsconfig-paths": "^5.1.4",
52
- "@formisch/core": "0.4.4",
53
- "@formisch/methods": "0.5.2"
50
+ "@formisch/core": "0.5.0",
51
+ "@formisch/eslint-config": "0.1.0",
52
+ "@formisch/methods": "0.6.0"
54
53
  },
55
54
  "peerDependencies": {
56
55
  "@qwik.dev/core": ">=2",