@formisch/vue 0.1.0 → 0.2.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/LICENSE.md +9 -0
- package/README.md +18 -1
- package/dist/index.d.ts +25 -25
- package/dist/index.js +18 -16
- package/package.json +13 -13
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Fabian Hiller
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Formisch is a schema-based, headless form library for Vue. It manages form state and validation. It is type-safe, fast by default and its bundle size is small due to its modular design. Try it out in our [playground](https://stackblitz.com/edit/formisch-playground-vue)!
|
|
4
4
|
|
|
5
|
+
Formisch is also available for [Preact][formisch-preact], [Qwik][formisch-qwik], [SolidJS][formisch-solid] and [Svelte][formisch-svelte].
|
|
6
|
+
|
|
5
7
|
## Highlights
|
|
6
8
|
|
|
7
9
|
- Small bundle size starting at 2.5 kB
|
|
@@ -17,7 +19,7 @@ Every form starts with the `useForm` composable. It initializes your form's stor
|
|
|
17
19
|
|
|
18
20
|
```vue
|
|
19
21
|
<script setup lang="ts">
|
|
20
|
-
import { Field, Form,
|
|
22
|
+
import { Field, Form, useForm } from '@formisch/vue';
|
|
21
23
|
import * as v from 'valibot';
|
|
22
24
|
|
|
23
25
|
const LoginSchema = v.object({
|
|
@@ -49,6 +51,16 @@ const loginForm = useForm({ schema: LoginSchema });
|
|
|
49
51
|
|
|
50
52
|
In addition, Formisch offers several functions (we call them "methods") that can be used to read and manipulate the form state. These include `focus`, `getErrors`, `getAllErrors`, `getInput`, `insert`, `move`, `remove`, `replace`, `reset`, `setErrors`, `setInput`, `submit`, `swap` and `validate`. These methods allow you to control the form programmatically.
|
|
51
53
|
|
|
54
|
+
## Comparison
|
|
55
|
+
|
|
56
|
+
What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built. The result is a small bundle size and native performance for any UI update. This feature, along with a few others, distinguishes Formisch from other form libraries. My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms.
|
|
57
|
+
|
|
58
|
+
## Partners
|
|
59
|
+
|
|
60
|
+
Thanks to our partners who support the development! [Join them](https://github.com/sponsors/fabian-hiller) and contribute to the sustainability of open source software!
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
52
64
|
## Feedback
|
|
53
65
|
|
|
54
66
|
Find a bug or have an idea how to improve the library? Please fill out an [issue](https://github.com/fabian-hiller/formisch/issues/new). Together we can make forms even better!
|
|
@@ -56,3 +68,8 @@ Find a bug or have an idea how to improve the library? Please fill out an [issue
|
|
|
56
68
|
## License
|
|
57
69
|
|
|
58
70
|
This project is available free of charge and licensed under the [MIT license](https://github.com/fabian-hiller/formisch/blob/main/LICENSE.md).
|
|
71
|
+
|
|
72
|
+
[formisch-preact]: https://github.com/fabian-hiller/formisch/tree/main/frameworks/preact
|
|
73
|
+
[formisch-qwik]: https://github.com/fabian-hiller/formisch/tree/main/frameworks/qwik
|
|
74
|
+
[formisch-solid]: https://github.com/fabian-hiller/formisch/tree/main/frameworks/solid
|
|
75
|
+
[formisch-svelte]: https://github.com/fabian-hiller/formisch/tree/main/frameworks/svelte
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue5 from "vue";
|
|
3
3
|
import { ComponentPublicInstance, MaybeRefOrGetter, ShallowRef as Signal } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/core/dist/index.vue.d.ts
|
|
@@ -93,7 +93,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
|
|
|
93
93
|
interface BaseFormStore<TSchema extends Schema = Schema> {
|
|
94
94
|
[INTERNAL]: InternalFormStore<TSchema>;
|
|
95
95
|
}
|
|
96
|
-
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<
|
|
96
|
+
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/types/path.d.ts
|
|
99
99
|
/**
|
|
@@ -123,16 +123,16 @@ type MergeUnion<T> = { [K in KeyOf<T>]: T extends Record<K, infer V> ? V : never
|
|
|
123
123
|
/**
|
|
124
124
|
* Lazily evaluate only the first valid path segment based on the given value.
|
|
125
125
|
*/
|
|
126
|
-
type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends KeyOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<MergeUnion<TValue>[TFirstKey]
|
|
126
|
+
type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends KeyOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOf<TValue>> extends false ? readonly [...TValidPath, KeyOf<TValue>] : TValidPath;
|
|
127
127
|
/**
|
|
128
128
|
* Returns the path if valid, otherwise the first possible valid path based on
|
|
129
129
|
* the given value.
|
|
130
130
|
*/
|
|
131
|
-
type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<TValue
|
|
131
|
+
type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
|
|
132
132
|
/**
|
|
133
133
|
* Extracts the value type at the given path.
|
|
134
134
|
*/
|
|
135
|
-
type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<TValue
|
|
135
|
+
type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<Required<TValue>> ? PathValue<MergeUnion<Required<TValue>>[TKey], TRest> : unknown : TValue;
|
|
136
136
|
/**
|
|
137
137
|
* Checks if a value is an array or contains one.
|
|
138
138
|
*/
|
|
@@ -140,16 +140,16 @@ type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends
|
|
|
140
140
|
/**
|
|
141
141
|
* Extracts the exact keys of a tuple, array or object that contain arrays.
|
|
142
142
|
*/
|
|
143
|
-
type KeyOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<TValue[TKey]
|
|
143
|
+
type KeyOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TIndex : never : never }[number] : TValue extends Record<string, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TKey : never }[keyof TValue] & PathKey : never;
|
|
144
144
|
/**
|
|
145
145
|
* Lazily evaluate only the first valid array path segment based on the given value.
|
|
146
146
|
*/
|
|
147
|
-
type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, KeyOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends KeyOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<MergeUnion<TValue>[TFirstKey]
|
|
147
|
+
type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, KeyOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends KeyOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOfArrayPath<TValue>> extends false ? readonly [...TValidPath, KeyOfArrayPath<TValue>] : never;
|
|
148
148
|
/**
|
|
149
149
|
* Returns the path if valid, otherwise the first possible valid array path based on
|
|
150
150
|
* the given value.
|
|
151
151
|
*/
|
|
152
|
-
type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<TValue
|
|
152
|
+
type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
|
|
153
153
|
//#endregion
|
|
154
154
|
//#region src/array/copyItemState/copyItemState.d.ts
|
|
155
155
|
/**
|
|
@@ -289,8 +289,8 @@ declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>,
|
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/types/field.d.ts
|
|
291
291
|
/**
|
|
292
|
-
* Value type of the field element props.
|
|
293
|
-
*/
|
|
292
|
+
* Value type of the field element props.
|
|
293
|
+
*/
|
|
294
294
|
interface FieldElementProps {
|
|
295
295
|
readonly name: string;
|
|
296
296
|
readonly autofocus: boolean;
|
|
@@ -300,8 +300,8 @@ interface FieldElementProps {
|
|
|
300
300
|
readonly onBlur: (event: FocusEvent) => void;
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
|
-
* Value type of the field store.
|
|
304
|
-
*/
|
|
303
|
+
* Value type of the field store.
|
|
304
|
+
*/
|
|
305
305
|
interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
|
|
306
306
|
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
307
307
|
get input(): PartialValues<PathValue<v.InferInput<TSchema>, TFieldPath>>;
|
|
@@ -313,8 +313,8 @@ interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
313
313
|
readonly props: FieldElementProps;
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
|
-
* Value type of the field array store.
|
|
317
|
-
*/
|
|
316
|
+
* Value type of the field array store.
|
|
317
|
+
*/
|
|
318
318
|
interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
|
|
319
319
|
readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
|
|
320
320
|
readonly items: string[];
|
|
@@ -344,14 +344,14 @@ interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends Require
|
|
|
344
344
|
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
345
345
|
}
|
|
346
346
|
declare const _default: <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<{
|
|
347
|
-
props: __VLS_PrettifyLocal$2<Pick<Partial<{}> & Omit<{} &
|
|
348
|
-
expose(exposed:
|
|
347
|
+
props: __VLS_PrettifyLocal$2<Pick<Partial<{}> & Omit<{} & vue5.VNodeProps & vue5.AllowedComponentProps & vue5.ComponentCustomProps, never>, never> & FieldProps<TSchema, TFieldPath> & {}> & vue5.PublicProps;
|
|
348
|
+
expose(exposed: vue5.ShallowUnwrapRef<{}>): void;
|
|
349
349
|
attrs: any;
|
|
350
350
|
slots: {
|
|
351
351
|
default(props: FieldStore<TSchema, TFieldPath>): any;
|
|
352
352
|
};
|
|
353
353
|
emit: {};
|
|
354
|
-
}>) =>
|
|
354
|
+
}>) => vue5.VNode & {
|
|
355
355
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
356
356
|
};
|
|
357
357
|
type __VLS_PrettifyLocal$2<T> = { [K in keyof T as K]: T[K] } & {};
|
|
@@ -365,32 +365,32 @@ interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath exten
|
|
|
365
365
|
readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
|
|
366
366
|
}
|
|
367
367
|
declare const _default$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<{
|
|
368
|
-
props: __VLS_PrettifyLocal$1<Pick<Partial<{}> & Omit<{} &
|
|
369
|
-
expose(exposed:
|
|
368
|
+
props: __VLS_PrettifyLocal$1<Pick<Partial<{}> & Omit<{} & vue5.VNodeProps & vue5.AllowedComponentProps & vue5.ComponentCustomProps, never>, never> & FieldArrayProps<TSchema, TFieldArrayPath> & {}> & vue5.PublicProps;
|
|
369
|
+
expose(exposed: vue5.ShallowUnwrapRef<{}>): void;
|
|
370
370
|
attrs: any;
|
|
371
371
|
slots: {
|
|
372
372
|
default(props: FieldArrayStore<TSchema, TFieldArrayPath>): any;
|
|
373
373
|
};
|
|
374
374
|
emit: {};
|
|
375
|
-
}>) =>
|
|
375
|
+
}>) => vue5.VNode & {
|
|
376
376
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
377
377
|
};
|
|
378
378
|
type __VLS_PrettifyLocal$1<T> = { [K in keyof T as K]: T[K] } & {};
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/components/Form/Form.vue.d.ts
|
|
381
|
-
|
|
381
|
+
interface FormProps<TSchema extends Schema = Schema> {
|
|
382
382
|
of: FormStore<TSchema>;
|
|
383
383
|
onSubmit: SubmitHandler<TSchema>;
|
|
384
|
-
}
|
|
384
|
+
}
|
|
385
385
|
declare const _default$2: <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<{
|
|
386
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} &
|
|
387
|
-
expose(exposed:
|
|
386
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & vue5.VNodeProps & vue5.AllowedComponentProps & vue5.ComponentCustomProps, never>, never> & FormProps<TSchema> & {}> & vue5.PublicProps;
|
|
387
|
+
expose(exposed: vue5.ShallowUnwrapRef<{}>): void;
|
|
388
388
|
attrs: any;
|
|
389
389
|
slots: {
|
|
390
390
|
default?: (props: {}) => any;
|
|
391
391
|
};
|
|
392
392
|
emit: {};
|
|
393
|
-
}>) =>
|
|
393
|
+
}>) => vue5.VNode & {
|
|
394
394
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
395
395
|
};
|
|
396
396
|
type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K] } & {};
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path) {
|
|
|
41
41
|
} else for (let index = 0; index < schema.items; index++) {
|
|
42
42
|
internalFieldStore.children[index] = {};
|
|
43
43
|
path.push(index);
|
|
44
|
-
initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput
|
|
44
|
+
initializeFieldStore(internalFieldStore.children[index], schema.items[index], initialInput?.[index], path);
|
|
45
45
|
path.pop();
|
|
46
46
|
}
|
|
47
47
|
const initialItems = internalFieldStore.children.map(createId);
|
|
@@ -59,7 +59,7 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path) {
|
|
|
59
59
|
for (const key in schema.entries) {
|
|
60
60
|
internalFieldStore.children[key] = {};
|
|
61
61
|
path.push(key);
|
|
62
|
-
initializeFieldStore(internalFieldStore.children[key], schema.entries[key], initialInput
|
|
62
|
+
initializeFieldStore(internalFieldStore.children[key], schema.entries[key], initialInput?.[key], path);
|
|
63
63
|
path.pop();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -253,23 +253,24 @@ function setFieldBool(internalFieldStore, type, bool) {
|
|
|
253
253
|
function setFieldInput(internalFieldStore, input) {
|
|
254
254
|
batch(() => {
|
|
255
255
|
if (internalFieldStore.kind === "array") {
|
|
256
|
+
const arrayInput = input ?? [];
|
|
256
257
|
const items = untrack(() => internalFieldStore.items.value);
|
|
257
|
-
if (
|
|
258
|
-
else if (
|
|
259
|
-
if (
|
|
258
|
+
if (arrayInput.length < items.length) internalFieldStore.items.value = items.slice(0, arrayInput.length);
|
|
259
|
+
else if (arrayInput.length > items.length) {
|
|
260
|
+
if (arrayInput.length > internalFieldStore.children.length) {
|
|
260
261
|
const path = JSON.parse(internalFieldStore.name);
|
|
261
|
-
for (let index = internalFieldStore.children.length; index <
|
|
262
|
+
for (let index = internalFieldStore.children.length; index < arrayInput.length; index++) {
|
|
262
263
|
internalFieldStore.children[index] = {};
|
|
263
264
|
path.push(index);
|
|
264
|
-
initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item,
|
|
265
|
+
initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, arrayInput[index], path);
|
|
265
266
|
path.pop();
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
|
-
internalFieldStore.items.value = [...items, ...
|
|
269
|
+
internalFieldStore.items.value = [...items, ...arrayInput.slice(items.length).map(createId)];
|
|
269
270
|
}
|
|
270
|
-
for (let index = 0; index < items.length; index++) setFieldInput(internalFieldStore.children[index],
|
|
271
|
+
for (let index = 0; index < items.length; index++) setFieldInput(internalFieldStore.children[index], arrayInput[index]);
|
|
271
272
|
internalFieldStore.isDirty.value = untrack(() => internalFieldStore.startItems.value).length !== items.length;
|
|
272
|
-
} else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) setFieldInput(internalFieldStore.children[key], input[key]);
|
|
273
|
+
} else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) setFieldInput(internalFieldStore.children[key], input?.[key]);
|
|
273
274
|
else {
|
|
274
275
|
internalFieldStore.input.value = input;
|
|
275
276
|
internalFieldStore.isTouched.value = true;
|
|
@@ -281,17 +282,18 @@ function setFieldInput(internalFieldStore, input) {
|
|
|
281
282
|
function setInitialFieldInput(internalFieldStore, initialInput) {
|
|
282
283
|
batch(() => {
|
|
283
284
|
if (internalFieldStore.kind === "array") {
|
|
284
|
-
|
|
285
|
+
const initialArrayInput = initialInput ?? [];
|
|
286
|
+
if (initialArrayInput.length > internalFieldStore.children.length) {
|
|
285
287
|
const path = JSON.parse(internalFieldStore.name);
|
|
286
|
-
for (let index = internalFieldStore.children.length; index <
|
|
288
|
+
for (let index = internalFieldStore.children.length; index < initialArrayInput.length; index++) {
|
|
287
289
|
internalFieldStore.children[index] = {};
|
|
288
290
|
path.push(index);
|
|
289
|
-
initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item,
|
|
291
|
+
initializeFieldStore(internalFieldStore.children[index], internalFieldStore.schema.item, initialArrayInput[index], path);
|
|
290
292
|
path.pop();
|
|
291
293
|
}
|
|
292
294
|
}
|
|
293
|
-
internalFieldStore.initialItems.value =
|
|
294
|
-
for (let index = 0; index < internalFieldStore.children.length; index++) setInitialFieldInput(internalFieldStore.children[index],
|
|
295
|
+
internalFieldStore.initialItems.value = initialArrayInput.map(createId);
|
|
296
|
+
for (let index = 0; index < internalFieldStore.children.length; index++) setInitialFieldInput(internalFieldStore.children[index], initialArrayInput[index]);
|
|
295
297
|
} else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) setInitialFieldInput(internalFieldStore.children[key], initialInput?.[key]);
|
|
296
298
|
else internalFieldStore.initialInput.value = initialInput;
|
|
297
299
|
});
|
|
@@ -613,7 +615,7 @@ function useFieldArray(form, config) {
|
|
|
613
615
|
//#endregion
|
|
614
616
|
//#region src/composables/useForm/useForm.ts
|
|
615
617
|
function useForm(config) {
|
|
616
|
-
const internalFormStore = createFormStore(config,
|
|
618
|
+
const internalFormStore = createFormStore(config, (input) => v.safeParseAsync(config.schema, input));
|
|
617
619
|
onBeforeMount(async () => {
|
|
618
620
|
if (config.validate === "initial") await validateFormInput(internalFormStore);
|
|
619
621
|
});
|
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.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fabian Hiller",
|
|
7
7
|
"homepage": "https://formisch.dev",
|
|
@@ -32,17 +32,7 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "tsdown",
|
|
37
|
-
"lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
|
|
38
|
-
"lint.fix": "eslint \"src/**/*.ts*\" --fix",
|
|
39
|
-
"format": "prettier --write ./src",
|
|
40
|
-
"format.check": "prettier --check ./src",
|
|
41
|
-
"vite": "vite"
|
|
42
|
-
},
|
|
43
35
|
"devDependencies": {
|
|
44
|
-
"@formisch/core": "workspace:*",
|
|
45
|
-
"@formisch/methods": "workspace:*",
|
|
46
36
|
"@types/node": "^24.1.0",
|
|
47
37
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
48
38
|
"eslint": "^9.32.0",
|
|
@@ -52,7 +42,9 @@
|
|
|
52
42
|
"unplugin-vue": "^7.0.0",
|
|
53
43
|
"valibot": "^1.1.0",
|
|
54
44
|
"vue": "^3.5.18",
|
|
55
|
-
"vue-tsc": "^3.0.4"
|
|
45
|
+
"vue-tsc": "^3.0.4",
|
|
46
|
+
"@formisch/core": "0.3.1",
|
|
47
|
+
"@formisch/methods": "0.2.0"
|
|
56
48
|
},
|
|
57
49
|
"peerDependencies": {
|
|
58
50
|
"typescript": ">=5",
|
|
@@ -63,5 +55,13 @@
|
|
|
63
55
|
"typescript": {
|
|
64
56
|
"optional": true
|
|
65
57
|
}
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsdown",
|
|
61
|
+
"lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
|
|
62
|
+
"lint.fix": "eslint \"src/**/*.ts*\" --fix",
|
|
63
|
+
"format": "prettier --write ./src",
|
|
64
|
+
"format.check": "prettier --check ./src",
|
|
65
|
+
"vite": "vite"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|