@formisch/solid 0.1.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/LICENSE.md +9 -0
- package/README.md +68 -0
- package/dist/dev.js +696 -0
- package/dist/dev.jsx +726 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +696 -0
- package/dist/index.jsx +726 -0
- package/package.json +92 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Value type of the field element props.
|
|
8
|
+
*/
|
|
9
|
+
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>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Value type of the field store.
|
|
20
|
+
*/
|
|
21
|
+
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;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Value type of the field array store.
|
|
32
|
+
*/
|
|
33
|
+
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;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
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;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Constructs a type that is maybe a getter function.
|
|
54
|
+
*/
|
|
55
|
+
type MaybeGetter<TValue> = TValue | (() => TValue);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Properties of the `Field` component.
|
|
59
|
+
*/
|
|
60
|
+
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;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Headless form field that provides reactive properties and state.
|
|
67
|
+
*/
|
|
68
|
+
declare function Field<TSchema extends Schema, TFieldPath extends RequiredPath>(props: FieldProps<TSchema, TFieldPath>): JSX.Element;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Properties of the `FieldArray` component.
|
|
72
|
+
*/
|
|
73
|
+
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;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Headless field array that provides reactive properties and state.
|
|
80
|
+
*/
|
|
81
|
+
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>;
|
|
87
|
+
};
|
|
88
|
+
declare function Form<TSchema extends Schema>(props: FormProps<TSchema>): JSX.Element;
|
|
89
|
+
|
|
90
|
+
declare function createForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
|
|
91
|
+
|
|
92
|
+
interface UseFieldConfig<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
|
|
93
|
+
readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
|
|
94
|
+
}
|
|
95
|
+
declare function useField<TSchema extends Schema, TFieldPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldConfig<TSchema, TFieldPath>>): FieldStore<TSchema, TFieldPath>;
|
|
96
|
+
|
|
97
|
+
interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
|
|
98
|
+
readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
|
|
99
|
+
}
|
|
100
|
+
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 };
|