@formisch/solid 0.1.0 → 0.1.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/README.md CHANGED
@@ -57,7 +57,7 @@ export default function LoginPage() {
57
57
  }
58
58
  ```
59
59
 
60
- In addition, Formisch offers several functions (we call them "methods") that can be used to manipulate the form state. These include `reset`, `setInput`, and `setErrors`. These methods allow you to control the form programmatically.
60
+ 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.
61
61
 
62
62
  ## Feedback
63
63
 
package/dist/index.d.ts CHANGED
@@ -1,102 +1,393 @@
1
- export * from '@formisch/methods/solid';
2
- import { Schema, RequiredPath, ValidPath, PartialValues, PathValue, FieldElement, ValidArrayPath, BaseFormStore, SubmitHandler, FormConfig } from '@formisch/core/solid';
3
- import { JSX } from 'solid-js';
4
- import * as v from 'valibot';
1
+ import * as v from "valibot";
2
+ import { JSX } from "solid-js";
5
3
 
4
+ //#region ../../packages/core/dist/index.solid.d.ts
5
+ //#region src/types/schema.d.ts
6
+ type Schema = v.GenericSchema | v.GenericSchemaAsync;
7
+ //#endregion
8
+ //#region src/types/signal.d.ts
9
+ interface Signal<T> {
10
+ value: T;
11
+ }
12
+ //#endregion
13
+ //#region src/types/field.d.ts
14
+ /**
15
+ * Value type of the field element.
16
+ */
17
+ type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
18
+ interface InternalBaseStore {
19
+ kind: "array" | "object" | "value";
20
+ name: string;
21
+ schema: Schema;
22
+ elements: FieldElement[];
23
+ errors: Signal<[string, ...string[]] | null>;
24
+ }
25
+ interface InternalArrayStore extends InternalBaseStore {
26
+ kind: "array";
27
+ children: InternalFieldStore[];
28
+ initialItems: Signal<string[]>;
29
+ startItems: Signal<string[]>;
30
+ items: Signal<string[]>;
31
+ isTouched: Signal<boolean>;
32
+ isDirty: Signal<boolean>;
33
+ }
34
+ interface InternalObjectStore extends InternalBaseStore {
35
+ kind: "object";
36
+ children: Record<string, InternalFieldStore>;
37
+ }
38
+ interface InternalValueStore extends InternalBaseStore {
39
+ kind: "value";
40
+ initialInput: Signal<unknown>;
41
+ startInput: Signal<unknown>;
42
+ input: Signal<unknown>;
43
+ isTouched: Signal<boolean>;
44
+ isDirty: Signal<boolean>;
45
+ }
46
+ type InternalFieldStore = InternalArrayStore | InternalObjectStore | InternalValueStore;
47
+ //#endregion
48
+ //#region src/values.d.ts
49
+ declare const INTERNAL: "~internal";
50
+ //#endregion
51
+ //#region src/types/utils.d.ts
52
+ /**
53
+ * Checks if a type is `any`.
54
+ */
55
+ type IsAny<Type> = 0 extends 1 & Type ? true : false;
56
+ /**
57
+ * Checks if a type is `never`.
58
+ */
59
+ type IsNever<Type> = [Type] extends [never] ? true : false;
60
+ /**
61
+ * Constructs a type that is maybe a promise.
62
+ */
63
+ type MaybePromise<TValue> = TValue | Promise<TValue>;
64
+ /**
65
+ * Makes all properties deeply optional.
66
+ */
67
+ type DeepPartial<TValue> = TValue extends readonly unknown[] ? number extends TValue["length"] ? TValue : { [Key in keyof TValue]?: DeepPartial<TValue[Key]> | undefined } : TValue extends Record<PropertyKey, unknown> ? { [Key in keyof TValue]?: DeepPartial<TValue[Key]> | undefined } : TValue | undefined;
68
+ /**
69
+ * Makes all value properties optional.
70
+ */
71
+ type PartialValues<TValue> = TValue extends readonly unknown[] ? number extends TValue["length"] ? TValue : { [Key in keyof TValue]: PartialValues<TValue[Key]> } : TValue extends Record<PropertyKey, unknown> ? { [Key in keyof TValue]: PartialValues<TValue[Key]> } : TValue | undefined;
72
+ //#endregion
73
+ //#region src/types/form.d.ts
74
+ /**
75
+ * Value type of the validation mode.
76
+ */
77
+ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submit";
78
+ interface FormConfig<TSchema extends Schema = Schema> {
79
+ readonly schema: TSchema;
80
+ readonly initialInput?: DeepPartial<v.InferInput<TSchema>> | undefined;
81
+ readonly validateOn?: ValidationMode | undefined;
82
+ readonly revalidateOn?: Exclude<ValidationMode, "initial"> | undefined;
83
+ }
84
+ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
85
+ element?: HTMLFormElement;
86
+ validators: number;
87
+ validateOn: ValidationMode;
88
+ revalidateOn: Exclude<ValidationMode, "initial">;
89
+ validate: (input: unknown) => Promise<v.SafeParseResult<TSchema>>;
90
+ isSubmitting: Signal<boolean>;
91
+ isSubmitted: Signal<boolean>;
92
+ isValidating: Signal<boolean>;
93
+ }
94
+ interface BaseFormStore<TSchema extends Schema = Schema> {
95
+ [INTERNAL]: InternalFormStore<TSchema>;
96
+ }
97
+ type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<void>;
98
+ //#endregion
99
+ //#region src/types/path.d.ts
100
+ /**
101
+ * Path key type.
102
+ */
103
+ type PathKey = string | number;
104
+ /**
105
+ * Path type.
106
+ */
107
+ type Path = readonly PathKey[];
108
+ /**
109
+ * Required path type.
110
+ */
111
+ type RequiredPath = readonly [PathKey, ...Path];
112
+ /**
113
+ * Extracts the exact keys of a tuple, array or object.
114
+ */
115
+ type KeyOf<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly unknown[] ? number extends TValue["length"] ? number : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? TIndex : never }[number] : TValue extends Record<string, unknown> ? keyof TValue & PathKey : never;
116
+ /**
117
+ * Merges array and object unions into a single object.
118
+ *
119
+ * Hint: This is necessary to make any property accessible. By default,
120
+ * properties that do not exist in all union options are not accessible
121
+ * and result in "any" when accessed.
122
+ */
123
+ type MergeUnion<T> = { [K in KeyOf<T>]: T extends Record<K, infer V> ? V : never };
124
+ /**
125
+ * Lazily evaluate only the first valid path segment based on the given value.
126
+ */
127
+ 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], TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOf<TValue>> extends false ? readonly [...TValidPath, KeyOf<TValue>] : TValidPath;
6
128
  /**
7
- * Value type of the field element props.
8
- */
129
+ * Returns the path if valid, otherwise the first possible valid path based on
130
+ * the given value.
131
+ */
132
+ type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<TValue, TPath> ? TPath : LazyPath<TValue, TPath>;
133
+ /**
134
+ * Extracts the value type at the given path.
135
+ */
136
+ type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<TValue> ? PathValue<MergeUnion<TValue>[TKey], TRest> : unknown : TValue;
137
+ /**
138
+ * Checks if a value is an array or contains one.
139
+ */
140
+ type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends readonly unknown[] ? true : TValue extends Record<string, unknown> ? true extends { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> }[keyof TValue] ? true : false : false;
141
+ /**
142
+ * Extracts the exact keys of a tuple, array or object that contain arrays.
143
+ */
144
+ 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]> extends true ? TIndex : never : never }[number] : TValue extends Record<string, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> extends true ? TKey : never }[keyof TValue] & PathKey : never;
145
+ /**
146
+ * Lazily evaluate only the first valid array path segment based on the given value.
147
+ */
148
+ 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], TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOfArrayPath<TValue>> extends false ? readonly [...TValidPath, KeyOfArrayPath<TValue>] : never;
149
+ /**
150
+ * Returns the path if valid, otherwise the first possible valid array path based on
151
+ * the given value.
152
+ */
153
+ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<TValue, TPath> ? TPath : LazyArrayPath<TValue, TPath>;
154
+ //#endregion
155
+ //#region src/array/copyItemState/copyItemState.d.ts
156
+ /**
157
+ * Copies the deeply nested state (signal values) from one array item to another.
158
+ * This includes the `isTouched`, `isDirty`, `startInput`, `input`, `startItems`, and `items` properties.
159
+ * Recursively walks through the field stores and copies all signal values.
160
+ *
161
+ * @param internalArrayStore - The field store of the array (not the array item)
162
+ * @param fromIndex - The source index to copy from
163
+ * @param toIndex - The destination index to copy to
164
+ */
165
+ //#endregion
166
+ //#region ../../packages/methods/dist/index.solid.d.ts
167
+ //#region src/focus/focus.d.ts
168
+ interface FocusFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
169
+ readonly form: BaseFormStore<TSchema>;
170
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
171
+ }
172
+ declare function focus<TSchema extends Schema, TFieldPath extends RequiredPath>(config: FocusFieldConfig<TSchema, TFieldPath>): void;
173
+ //#endregion
174
+ //#region src/getAllErrors/getAllErrors.d.ts
175
+ declare function getAllErrors(form: BaseFormStore): [string, ...string[]] | null;
176
+ //#endregion
177
+ //#region src/getErrors/getErrors.d.ts
178
+ interface GetFormErrorsConfig {
179
+ readonly path?: undefined;
180
+ }
181
+ interface GetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
182
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
183
+ }
184
+ declare function getErrors<TSchema extends Schema>(form: BaseFormStore<TSchema>): [string, ...string[]] | null;
185
+ declare function getErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldErrorsConfig<TSchema, TFieldPath> : GetFormErrorsConfig): [string, ...string[]] | null;
186
+ //#endregion
187
+ //#region src/getInput/getInput.d.ts
188
+ interface GetFormInputConfig {
189
+ readonly path?: undefined;
190
+ }
191
+ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
192
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
193
+ }
194
+ declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
195
+ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
196
+ //#endregion
197
+ //#region src/insert/insert.d.ts
198
+ interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
199
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
200
+ readonly at?: number | undefined;
201
+ readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, [...TFieldArrayPath, number]>> | undefined;
202
+ }
203
+ declare function insert<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: InsertConfig<TSchema, TFieldArrayPath>): void;
204
+ //#endregion
205
+ //#region src/move/move.d.ts
206
+ interface MoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
207
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
208
+ readonly from: number;
209
+ readonly to: number;
210
+ }
211
+ declare function move<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: MoveConfig<TSchema, TFieldArrayPath>): void;
212
+ //#endregion
213
+ //#region src/remove/remove.d.ts
214
+ interface RemoveConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
215
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
216
+ readonly at: number;
217
+ }
218
+ declare function remove<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: RemoveConfig<TSchema, TFieldArrayPath>): void;
219
+ //#endregion
220
+ //#region src/replace/replace.d.ts
221
+ interface ReplaceConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
222
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
223
+ readonly at: number;
224
+ readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, [...TFieldArrayPath, number]>> | undefined;
225
+ }
226
+ declare function replace<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: ReplaceConfig<TSchema, TFieldArrayPath>): void;
227
+ //#endregion
228
+ //#region src/reset/reset.d.ts
229
+ interface ResetBaseConfig {
230
+ readonly keepInput?: boolean | undefined;
231
+ readonly keepTouched?: boolean | undefined;
232
+ readonly keepErrors?: boolean | undefined;
233
+ }
234
+ interface ResetFormConfig<TSchema extends Schema> extends ResetBaseConfig {
235
+ readonly path?: undefined;
236
+ readonly initialInput?: DeepPartial<v.InferInput<TSchema>> | undefined;
237
+ readonly keepSubmitCount?: boolean | undefined;
238
+ readonly keepSubmitted?: boolean | undefined;
239
+ }
240
+ interface ResetFieldConfig<TSchema extends Schema, TFieldPath extends RequiredPath> extends ResetBaseConfig {
241
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
242
+ readonly initialInput?: DeepPartial<PathValue<v.InferInput<TSchema>, TFieldPath>>;
243
+ }
244
+ declare function reset(form: BaseFormStore): void;
245
+ declare function reset<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? ResetFieldConfig<TSchema, TFieldPath> : ResetFormConfig<TSchema>): void;
246
+ //#endregion
247
+ //#region src/setErrors/setErrors.d.ts
248
+ interface SetFormErrorsConfig {
249
+ readonly path?: undefined;
250
+ readonly errors: [string, ...string[]] | null;
251
+ }
252
+ interface SetFieldErrorsConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
253
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
254
+ readonly errors: [string, ...string[]] | null;
255
+ }
256
+ declare function setErrors<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldErrorsConfig<TSchema, TFieldPath> : SetFormErrorsConfig): void;
257
+ //#endregion
258
+ //#region src/setInput/setInput.d.ts
259
+ interface SetFormInputConfig<TSchema extends Schema> {
260
+ readonly path?: undefined;
261
+ readonly input: v.InferInput<TSchema>;
262
+ }
263
+ interface SetFieldInputConfig<TSchema extends Schema, TFieldPath extends RequiredPath> {
264
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
265
+ readonly input: PathValue<v.InferInput<TSchema>, TFieldPath>;
266
+ }
267
+ declare function setInput<TSchema extends Schema>(form: BaseFormStore<TSchema>, config: SetFormInputConfig<TSchema>): void;
268
+ declare function setInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? SetFieldInputConfig<TSchema, TFieldPath> : SetFormInputConfig<TSchema>): void;
269
+ //#endregion
270
+ //#region src/submit/submit.d.ts
271
+ declare function submit(form: BaseFormStore): void;
272
+ //#endregion
273
+ //#region src/swap/swap.d.ts
274
+ interface SwapConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
275
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
276
+ readonly at: number;
277
+ readonly and: number;
278
+ }
279
+ declare function swap<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: BaseFormStore<TSchema>, config: SwapConfig<TSchema, TFieldArrayPath>): void;
280
+ //#endregion
281
+ //#region src/validate/validate.d.ts
282
+ interface ValidateFormConfig {
283
+ readonly shouldFocus?: boolean | undefined;
284
+ }
285
+ declare function validate<TSchema extends Schema>(form: BaseFormStore<TSchema>, config?: ValidateFormConfig): Promise<v.SafeParseResult<TSchema>>;
286
+ //#endregion
287
+ //#endregion
288
+ //#region src/types/field.d.ts
289
+ /**
290
+ * Value type of the field element props.
291
+ */
9
292
  interface FieldElementProps {
10
- readonly name: string;
11
- readonly autofocus: boolean;
12
- readonly ref: (element: FieldElement) => void;
13
- readonly onFocus: JSX.EventHandler<FieldElement, FocusEvent>;
14
- readonly onInput: JSX.EventHandler<FieldElement, InputEvent>;
15
- readonly onChange: JSX.EventHandler<FieldElement, Event>;
16
- readonly onBlur: JSX.EventHandler<FieldElement, FocusEvent>;
293
+ readonly name: string;
294
+ readonly autofocus: boolean;
295
+ readonly ref: (element: FieldElement) => void;
296
+ readonly onFocus: JSX.EventHandler<FieldElement, FocusEvent>;
297
+ readonly onInput: JSX.EventHandler<FieldElement, InputEvent>;
298
+ readonly onChange: JSX.EventHandler<FieldElement, Event>;
299
+ readonly onBlur: JSX.EventHandler<FieldElement, FocusEvent>;
17
300
  }
18
301
  /**
19
- * Value type of the field store.
20
- */
302
+ * Value type of the field store.
303
+ */
21
304
  interface FieldStore<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
22
- readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
23
- readonly input: PartialValues<PathValue<v.InferInput<TSchema>, TFieldPath>>;
24
- readonly errors: [string, ...string[]] | null;
25
- readonly isTouched: boolean;
26
- readonly isDirty: boolean;
27
- readonly isValid: boolean;
28
- readonly props: FieldElementProps;
305
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
306
+ readonly input: PartialValues<PathValue<v.InferInput<TSchema>, TFieldPath>>;
307
+ readonly errors: [string, ...string[]] | null;
308
+ readonly isTouched: boolean;
309
+ readonly isDirty: boolean;
310
+ readonly isValid: boolean;
311
+ readonly props: FieldElementProps;
29
312
  }
30
313
  /**
31
- * Value type of the field array store.
32
- */
314
+ * Value type of the field array store.
315
+ */
33
316
  interface FieldArrayStore<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
34
- readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
35
- readonly items: string[];
36
- readonly errors: [string, ...string[]] | null;
37
- readonly isTouched: boolean;
38
- readonly isDirty: boolean;
39
- readonly isValid: boolean;
317
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
318
+ readonly items: string[];
319
+ readonly errors: [string, ...string[]] | null;
320
+ readonly isTouched: boolean;
321
+ readonly isDirty: boolean;
322
+ readonly isValid: boolean;
40
323
  }
41
-
324
+ //#endregion
325
+ //#region src/types/form.d.ts
42
326
  interface FormStore<TSchema extends Schema = Schema> extends BaseFormStore<TSchema> {
43
- readonly isSubmitting: boolean;
44
- readonly isSubmitted: boolean;
45
- readonly isValidating: boolean;
46
- readonly isTouched: boolean;
47
- readonly isDirty: boolean;
48
- readonly isValid: boolean;
49
- readonly errors: [string, ...string[]] | null;
327
+ readonly isSubmitting: boolean;
328
+ readonly isSubmitted: boolean;
329
+ readonly isValidating: boolean;
330
+ readonly isTouched: boolean;
331
+ readonly isDirty: boolean;
332
+ readonly isValid: boolean;
333
+ readonly errors: [string, ...string[]] | null;
50
334
  }
51
-
335
+ //#endregion
336
+ //#region src/types/utils.d.ts
52
337
  /**
53
- * Constructs a type that is maybe a getter function.
54
- */
338
+ * Constructs a type that is maybe a getter function.
339
+ */
55
340
  type MaybeGetter<TValue> = TValue | (() => TValue);
56
-
341
+ //#endregion
342
+ //#region src/components/Field/Field.d.ts
57
343
  /**
58
- * Properties of the `Field` component.
59
- */
344
+ * Properties of the `Field` component.
345
+ */
60
346
  interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
61
- readonly of: FormStore<TSchema>;
62
- readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
63
- readonly render: (store: FieldStore<TSchema, TFieldPath>) => JSX.Element;
347
+ readonly of: FormStore<TSchema>;
348
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
349
+ readonly render: (store: FieldStore<TSchema, TFieldPath>) => JSX.Element;
64
350
  }
65
351
  /**
66
- * Headless form field that provides reactive properties and state.
67
- */
352
+ * Headless form field that provides reactive properties and state.
353
+ */
68
354
  declare function Field<TSchema extends Schema, TFieldPath extends RequiredPath>(props: FieldProps<TSchema, TFieldPath>): JSX.Element;
69
-
355
+ //#endregion
356
+ //#region src/components/FieldArray/FieldArray.d.ts
70
357
  /**
71
- * Properties of the `FieldArray` component.
72
- */
358
+ * Properties of the `FieldArray` component.
359
+ */
73
360
  interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
74
- readonly of: FormStore<TSchema>;
75
- readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
76
- readonly render: (store: FieldArrayStore<TSchema, TFieldArrayPath>) => JSX.Element;
361
+ readonly of: FormStore<TSchema>;
362
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
363
+ readonly render: (store: FieldArrayStore<TSchema, TFieldArrayPath>) => JSX.Element;
77
364
  }
78
365
  /**
79
- * Headless field array that provides reactive properties and state.
80
- */
366
+ * Headless field array that provides reactive properties and state.
367
+ */
81
368
  declare function FieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(props: FieldArrayProps<TSchema, TFieldArrayPath>): JSX.Element;
82
-
83
- type FormProps<TSchema extends Schema = Schema> = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> & {
84
- of: FormStore<TSchema>;
85
- children: JSX.Element;
86
- onSubmit: SubmitHandler<TSchema>;
369
+ //#endregion
370
+ //#region src/components/Form/Form.d.ts
371
+ type FormProps<TSchema extends Schema = Schema> = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "onSubmit"> & {
372
+ of: FormStore<TSchema>;
373
+ children: JSX.Element;
374
+ onSubmit: SubmitHandler<TSchema>;
87
375
  };
88
376
  declare function Form<TSchema extends Schema>(props: FormProps<TSchema>): JSX.Element;
89
-
377
+ //#endregion
378
+ //#region src/primitives/createForm/createForm.d.ts
90
379
  declare function createForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
91
-
380
+ //#endregion
381
+ //#region src/primitives/useField/useField.d.ts
92
382
  interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
93
- readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
383
+ readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
94
384
  }
95
385
  declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
96
-
386
+ //#endregion
387
+ //#region src/primitives/useFieldArray/useFieldArray.d.ts
97
388
  interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
98
- readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
389
+ readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
99
390
  }
100
391
  declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
101
-
102
- export { Field, FieldArray, type FieldArrayProps, type FieldArrayStore, type FieldElementProps, type FieldProps, type FieldStore, Form, type FormProps, type FormStore, type MaybeGetter, type UseFieldArrayConfig, type UseFieldConfig, createForm, useField, useFieldArray };
392
+ //#endregion
393
+ export { Field, FieldArray, FieldArrayProps, FieldArrayStore, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MaybeGetter, MoveConfig, RemoveConfig, ReplaceConfig, ResetFieldConfig, ResetFormConfig, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, SwapConfig, UseFieldArrayConfig, UseFieldConfig, ValidateFormConfig, createForm, focus, getAllErrors, getErrors, getInput, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formisch/solid",
3
3
  "description": "The modular and type-safe form library for SolidJS",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "license": "MIT",
6
6
  "author": "Fabian Hiller",
7
7
  "homepage": "https://formisch.dev",
@@ -53,7 +53,7 @@
53
53
  "lint.fix": "eslint \"src/**/*.ts*\" --fix",
54
54
  "format": "prettier --write ./src",
55
55
  "format.check": "prettier --check ./src",
56
- "build": "tsup"
56
+ "build": "tsup && tsdown"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "^9.31.0",