@manafishrov/ui 1.2.13 → 1.3.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/components/form/AutoSubmit.d.ts +5 -0
- package/dist/components/form/AutoSubmit.js +21 -0
- package/dist/components/form/AutoSubmit.js.map +1 -0
- package/dist/components/form/Form.d.ts +99 -84
- package/dist/components/form/Form.js +62 -40
- package/dist/components/form/Form.js.map +1 -1
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/index.js +30 -27
- package/dist/components/form/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/AutoSubmit.tsx +38 -0
- package/src/components/form/Form.tsx +29 -1
- package/src/components/form/index.ts +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createEffect as n, onCleanup as s } from "solid-js";
|
|
2
|
+
import { useFormContext as m } from "./context.js";
|
|
3
|
+
const i = 300, h = (o) => {
|
|
4
|
+
const t = m(), r = t.useStore((e) => e.values), u = t.useStore((e) => e.isTouched);
|
|
5
|
+
return n(() => {
|
|
6
|
+
if (r(), !u())
|
|
7
|
+
return;
|
|
8
|
+
const e = setTimeout(() => {
|
|
9
|
+
t.handleSubmit().catch((c) => {
|
|
10
|
+
throw c;
|
|
11
|
+
});
|
|
12
|
+
}, Math.max(0, o.debounce ?? i));
|
|
13
|
+
s(() => {
|
|
14
|
+
clearTimeout(e);
|
|
15
|
+
});
|
|
16
|
+
}), [];
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
h as AutoSubmit
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=AutoSubmit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoSubmit.js","sources":["../../../src/components/form/AutoSubmit.tsx"],"sourcesContent":["import { createEffect, onCleanup, type Component } from 'solid-js';\n\nimport { useFormContext } from './context';\n\nconst DEFAULT_DEBOUNCE_MS = 300;\n\nexport type AutoSubmitProps = {\n debounce?: number;\n};\n\nexport const AutoSubmit: Component<AutoSubmitProps> = (props) => {\n const form = useFormContext();\n const values = form.useStore((state) => state.values);\n const isTouched = form.useStore((state) => state.isTouched);\n\n createEffect(() => {\n values();\n\n if (!isTouched()) {\n return;\n }\n\n const debounceTimer = setTimeout(\n () => {\n form.handleSubmit().catch((error: unknown) => {\n throw error;\n });\n },\n Math.max(0, props.debounce ?? DEFAULT_DEBOUNCE_MS),\n );\n\n onCleanup(() => {\n clearTimeout(debounceTimer);\n });\n });\n\n return <></>;\n};\n"],"names":["DEFAULT_DEBOUNCE_MS","AutoSubmit","props","form","useFormContext","values","useStore","state","isTouched","createEffect","debounceTimer","setTimeout","handleSubmit","catch","error","Math","max","debounce","onCleanup","clearTimeout"],"mappings":";;AAIA,MAAMA,IAAsB,KAMfC,IAA0CC,CAAAA,MAAU;AAC/D,QAAMC,IAAOC,EAAAA,GACPC,IAASF,EAAKG,SAAUC,CAAAA,MAAUA,EAAMF,MAAM,GAC9CG,IAAYL,EAAKG,SAAUC,CAAAA,MAAUA,EAAMC,SAAS;AAE1DC,SAAAA,EAAa,MAAM;AAGjB,QAFAJ,EAAAA,GAEI,CAACG;AACH;AAGF,UAAME,IAAgBC,WACpB,MAAM;AACJR,MAAAA,EAAKS,aAAAA,EAAeC,MAAM,CAACC,MAAmB;AAC5C,cAAMA;AAAAA,MACR,CAAC;AAAA,IACH,GACAC,KAAKC,IAAI,GAAGd,EAAMe,YAAYjB,CAAmB,CACnD;AAEAkB,IAAAA,EAAU,MAAM;AACdC,mBAAaT,CAAa;AAAA,IAC5B,CAAC;AAAA,EACH,CAAC,GAED,CAAA;AACF;"}
|
|
@@ -1,102 +1,117 @@
|
|
|
1
|
+
import { Component, ComponentProps } from 'solid-js';
|
|
2
|
+
export type FormProps = Omit<ComponentProps<'form'>, 'onSubmit'>;
|
|
3
|
+
export declare const Form: Component<FormProps>;
|
|
1
4
|
export declare const useAppForm: <TFormData, TOnMount extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChange extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta>(props: import('solid-js').Accessor<import('@tanstack/solid-form').FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>>) => import('@tanstack/solid-form').AppFieldExtendedSolidFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
2
|
-
readonly CheckboxField:
|
|
3
|
-
readonly ComboboxField:
|
|
4
|
-
readonly DatePickerField:
|
|
5
|
-
readonly NumberInputField:
|
|
6
|
-
readonly PasswordInputField:
|
|
7
|
-
readonly PinInputField:
|
|
8
|
-
readonly RadioGroupField:
|
|
9
|
-
readonly SelectField:
|
|
10
|
-
readonly SliderField:
|
|
11
|
-
readonly SwitchField:
|
|
12
|
-
readonly TagsInputField:
|
|
13
|
-
readonly TextInputField:
|
|
14
|
-
readonly TextareaField:
|
|
5
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
6
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
7
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
8
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
9
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
10
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
11
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
12
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
13
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
14
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
15
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
16
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
17
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
15
18
|
}, {
|
|
16
|
-
readonly
|
|
19
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
20
|
+
readonly Form: Component<FormProps>;
|
|
21
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
17
22
|
}>, withForm: <TFormData, TOnMount extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChange extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta, TRenderProps extends Record<string, unknown> = {}>({ render, props, }: import('@tanstack/solid-form').WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
18
|
-
readonly CheckboxField:
|
|
19
|
-
readonly ComboboxField:
|
|
20
|
-
readonly DatePickerField:
|
|
21
|
-
readonly NumberInputField:
|
|
22
|
-
readonly PasswordInputField:
|
|
23
|
-
readonly PinInputField:
|
|
24
|
-
readonly RadioGroupField:
|
|
25
|
-
readonly SelectField:
|
|
26
|
-
readonly SliderField:
|
|
27
|
-
readonly SwitchField:
|
|
28
|
-
readonly TagsInputField:
|
|
29
|
-
readonly TextInputField:
|
|
30
|
-
readonly TextareaField:
|
|
23
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
24
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
25
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
26
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
27
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
28
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
29
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
30
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
31
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
32
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
33
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
34
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
35
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
31
36
|
}, {
|
|
32
|
-
readonly
|
|
37
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
38
|
+
readonly Form: Component<FormProps>;
|
|
39
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
33
40
|
}, TRenderProps>) => (props: import('solid-js').ParentProps<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
34
41
|
form: import('@tanstack/solid-form').AppFieldExtendedSolidFormApi<[unknown] extends [TFormData] ? any : TFormData, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
35
|
-
readonly CheckboxField:
|
|
36
|
-
readonly ComboboxField:
|
|
37
|
-
readonly DatePickerField:
|
|
38
|
-
readonly NumberInputField:
|
|
39
|
-
readonly PasswordInputField:
|
|
40
|
-
readonly PinInputField:
|
|
41
|
-
readonly RadioGroupField:
|
|
42
|
-
readonly SelectField:
|
|
43
|
-
readonly SliderField:
|
|
44
|
-
readonly SwitchField:
|
|
45
|
-
readonly TagsInputField:
|
|
46
|
-
readonly TextInputField:
|
|
47
|
-
readonly TextareaField:
|
|
42
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
43
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
44
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
45
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
46
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
47
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
48
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
49
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
50
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
51
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
52
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
53
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
54
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
48
55
|
}, {
|
|
49
|
-
readonly
|
|
56
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
57
|
+
readonly Form: Component<FormProps>;
|
|
58
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
50
59
|
}>;
|
|
51
60
|
}>) => import('solid-js').JSXElement, withFieldGroup: <TFieldGroupData, TSubmitMeta, TRenderProps extends Record<string, unknown> = {}>({ render, props, defaultValues, }: import('@tanstack/solid-form').WithFieldGroupProps<TFieldGroupData, {
|
|
52
|
-
readonly CheckboxField:
|
|
53
|
-
readonly ComboboxField:
|
|
54
|
-
readonly DatePickerField:
|
|
55
|
-
readonly NumberInputField:
|
|
56
|
-
readonly PasswordInputField:
|
|
57
|
-
readonly PinInputField:
|
|
58
|
-
readonly RadioGroupField:
|
|
59
|
-
readonly SelectField:
|
|
60
|
-
readonly SliderField:
|
|
61
|
-
readonly SwitchField:
|
|
62
|
-
readonly TagsInputField:
|
|
63
|
-
readonly TextInputField:
|
|
64
|
-
readonly TextareaField:
|
|
61
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
62
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
63
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
64
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
65
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
66
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
67
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
68
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
69
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
70
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
71
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
72
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
73
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
65
74
|
}, {
|
|
66
|
-
readonly
|
|
75
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
76
|
+
readonly Form: Component<FormProps>;
|
|
77
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
67
78
|
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import('@tanstack/solid-form').DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import('@tanstack/solid-form').FieldsMap<TFormData, TFieldGroupData>, TOnMount extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChange extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import('@tanstack/solid-form').FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import('@tanstack/solid-form').FormAsyncValidateOrFn<TFormData> | undefined, TFormSubmitMeta>(params: import('solid-js').ParentProps<NoInfer<TRenderProps> & {
|
|
68
79
|
form: import('@tanstack/solid-form').AppFieldExtendedSolidFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
69
|
-
readonly CheckboxField:
|
|
70
|
-
readonly ComboboxField:
|
|
71
|
-
readonly DatePickerField:
|
|
72
|
-
readonly NumberInputField:
|
|
73
|
-
readonly PasswordInputField:
|
|
74
|
-
readonly PinInputField:
|
|
75
|
-
readonly RadioGroupField:
|
|
76
|
-
readonly SelectField:
|
|
77
|
-
readonly SliderField:
|
|
78
|
-
readonly SwitchField:
|
|
79
|
-
readonly TagsInputField:
|
|
80
|
-
readonly TextInputField:
|
|
81
|
-
readonly TextareaField:
|
|
80
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
81
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
82
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
83
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
84
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
85
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
86
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
87
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
88
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
89
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
90
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
91
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
92
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
82
93
|
}, {
|
|
83
|
-
readonly
|
|
94
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
95
|
+
readonly Form: Component<FormProps>;
|
|
96
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
84
97
|
}> | import('@tanstack/solid-form').AppFieldExtendedSolidFieldGroupApi<unknown, TFormData, string | import('@tanstack/solid-form').FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
85
|
-
readonly CheckboxField:
|
|
86
|
-
readonly ComboboxField:
|
|
87
|
-
readonly DatePickerField:
|
|
88
|
-
readonly NumberInputField:
|
|
89
|
-
readonly PasswordInputField:
|
|
90
|
-
readonly PinInputField:
|
|
91
|
-
readonly RadioGroupField:
|
|
92
|
-
readonly SelectField:
|
|
93
|
-
readonly SliderField:
|
|
94
|
-
readonly SwitchField:
|
|
95
|
-
readonly TagsInputField:
|
|
96
|
-
readonly TextInputField:
|
|
97
|
-
readonly TextareaField:
|
|
98
|
+
readonly CheckboxField: Component<import('./CheckboxField').CheckboxFieldProps>;
|
|
99
|
+
readonly ComboboxField: Component<import('./ComboboxField').ComboboxFieldProps>;
|
|
100
|
+
readonly DatePickerField: Component<import('./DatePickerField').DatePickerFieldProps>;
|
|
101
|
+
readonly NumberInputField: Component<import('./NumberInputField').NumberInputFieldProps>;
|
|
102
|
+
readonly PasswordInputField: Component<import('./PasswordInputField').PasswordInputFieldProps>;
|
|
103
|
+
readonly PinInputField: Component<import('./PinInputField').PinInputFieldProps>;
|
|
104
|
+
readonly RadioGroupField: Component<import('./RadioGroupField').RadioGroupFieldProps>;
|
|
105
|
+
readonly SelectField: Component<import('./SelectField').SelectFieldProps>;
|
|
106
|
+
readonly SliderField: Component<import('./SliderField').SliderFieldProps>;
|
|
107
|
+
readonly SwitchField: Component<import('./SwitchField').SwitchFieldProps>;
|
|
108
|
+
readonly TagsInputField: Component<import('./TagsInputField').TagsInputFieldProps>;
|
|
109
|
+
readonly TextInputField: Component<import('./TextInputField').TextInputFieldProps>;
|
|
110
|
+
readonly TextareaField: Component<import('./TextareaField').TextareaFieldProps>;
|
|
98
111
|
}, {
|
|
99
|
-
readonly
|
|
112
|
+
readonly AutoSubmit: Component<import('./AutoSubmit').AutoSubmitProps>;
|
|
113
|
+
readonly Form: Component<FormProps>;
|
|
114
|
+
readonly SubmitButton: Component<import('./SubmitButton').SubmitButtonProps>;
|
|
100
115
|
}>;
|
|
101
116
|
fields: TFields;
|
|
102
117
|
}>) => import('solid-js').JSXElement;
|
|
@@ -1,48 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { spread as l, mergeProps as f, insert as n, template as s } from "solid-js/web";
|
|
2
|
+
import { createFormHook as d } from "@tanstack/solid-form";
|
|
3
|
+
import { splitProps as a } from "solid-js";
|
|
4
|
+
import { cn as u } from "../../node_modules/.bun/tailwind-variants@3.2.2_7ac958b541464b98/node_modules/tailwind-variants/dist/index.js";
|
|
5
|
+
import { AutoSubmit as c } from "./AutoSubmit.js";
|
|
6
|
+
import { CheckboxField as F } from "./CheckboxField.js";
|
|
7
|
+
import { ComboboxField as h } from "./ComboboxField.js";
|
|
8
|
+
import { useFormContext as x, fieldContext as b, formContext as C } from "./context.js";
|
|
9
|
+
import { DatePickerField as P } from "./DatePickerField.js";
|
|
10
|
+
import { NumberInputField as S } from "./NumberInputField.js";
|
|
11
|
+
import { PasswordInputField as w } from "./PasswordInputField.js";
|
|
12
|
+
import { PinInputField as I } from "./PinInputField.js";
|
|
13
|
+
import { RadioGroupField as g } from "./RadioGroupField.js";
|
|
14
|
+
import { SelectField as v } from "./SelectField.js";
|
|
15
|
+
import { SliderField as k } from "./SliderField.js";
|
|
16
|
+
import { SubmitButton as T } from "./SubmitButton.js";
|
|
17
|
+
import { SwitchField as A } from "./SwitchField.js";
|
|
18
|
+
import { TagsInputField as D } from "./TagsInputField.js";
|
|
19
|
+
import { TextareaField as G } from "./TextareaField.js";
|
|
20
|
+
import { TextInputField as _ } from "./TextInputField.js";
|
|
21
|
+
var $ = /* @__PURE__ */ s("<form>");
|
|
22
|
+
const y = (e) => {
|
|
23
|
+
const m = x(), [r, i] = a(e, ["children", "class"]);
|
|
24
|
+
return (() => {
|
|
25
|
+
var o = $();
|
|
26
|
+
return o.addEventListener("submit", (t) => {
|
|
27
|
+
t.preventDefault(), t.stopPropagation(), m.handleSubmit().catch((p) => {
|
|
28
|
+
throw p;
|
|
29
|
+
});
|
|
30
|
+
}), l(o, f({
|
|
31
|
+
get class() {
|
|
32
|
+
return u("space-y-6 relative", r.class);
|
|
33
|
+
}
|
|
34
|
+
}, i), !1, !0), n(o, () => r.children), o;
|
|
35
|
+
})();
|
|
36
|
+
}, {
|
|
37
|
+
useAppForm: oo,
|
|
38
|
+
withForm: ro,
|
|
39
|
+
withFieldGroup: to
|
|
40
|
+
} = d({
|
|
41
|
+
formContext: C,
|
|
42
|
+
fieldContext: b,
|
|
24
43
|
fieldComponents: {
|
|
25
|
-
CheckboxField:
|
|
26
|
-
ComboboxField:
|
|
27
|
-
DatePickerField:
|
|
28
|
-
NumberInputField:
|
|
29
|
-
PasswordInputField:
|
|
30
|
-
PinInputField:
|
|
31
|
-
RadioGroupField:
|
|
32
|
-
SelectField:
|
|
33
|
-
SliderField:
|
|
34
|
-
SwitchField:
|
|
35
|
-
TagsInputField:
|
|
36
|
-
TextInputField:
|
|
37
|
-
TextareaField:
|
|
44
|
+
CheckboxField: F,
|
|
45
|
+
ComboboxField: h,
|
|
46
|
+
DatePickerField: P,
|
|
47
|
+
NumberInputField: S,
|
|
48
|
+
PasswordInputField: w,
|
|
49
|
+
PinInputField: I,
|
|
50
|
+
RadioGroupField: g,
|
|
51
|
+
SelectField: v,
|
|
52
|
+
SliderField: k,
|
|
53
|
+
SwitchField: A,
|
|
54
|
+
TagsInputField: D,
|
|
55
|
+
TextInputField: _,
|
|
56
|
+
TextareaField: G
|
|
38
57
|
},
|
|
39
58
|
formComponents: {
|
|
40
|
-
|
|
59
|
+
AutoSubmit: c,
|
|
60
|
+
Form: y,
|
|
61
|
+
SubmitButton: T
|
|
41
62
|
}
|
|
42
63
|
});
|
|
43
64
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
y as Form,
|
|
66
|
+
oo as useAppForm,
|
|
67
|
+
to as withFieldGroup,
|
|
68
|
+
ro as withForm
|
|
47
69
|
};
|
|
48
70
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../src/components/form/Form.tsx"],"sourcesContent":["import { createFormHook } from '@tanstack/solid-form';\n\nimport { CheckboxField } from './CheckboxField';\nimport { ComboboxField } from './ComboboxField';\nimport { formContext,
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../src/components/form/Form.tsx"],"sourcesContent":["import { createFormHook } from '@tanstack/solid-form';\nimport { splitProps, type Component, type ComponentProps } from 'solid-js';\nimport { cn } from 'tailwind-variants';\n\nimport { AutoSubmit } from './AutoSubmit';\nimport { CheckboxField } from './CheckboxField';\nimport { ComboboxField } from './ComboboxField';\nimport { fieldContext, formContext, useFormContext } from './context';\nimport { DatePickerField } from './DatePickerField';\nimport { NumberInputField } from './NumberInputField';\nimport { PasswordInputField } from './PasswordInputField';\nimport { PinInputField } from './PinInputField';\nimport { RadioGroupField } from './RadioGroupField';\nimport { SelectField } from './SelectField';\nimport { SliderField } from './SliderField';\nimport { SubmitButton } from './SubmitButton';\nimport { SwitchField } from './SwitchField';\nimport { TagsInputField } from './TagsInputField';\nimport { TextareaField } from './TextareaField';\nimport { TextInputField } from './TextInputField';\n\nexport type FormProps = Omit<ComponentProps<'form'>, 'onSubmit'>;\n\nexport const Form: Component<FormProps> = (props) => {\n const form = useFormContext();\n const [local, formProps] = splitProps(props, ['children', 'class']);\n\n return (\n <form\n class={cn('space-y-6 relative', local.class)}\n onSubmit={(submitEvent) => {\n submitEvent.preventDefault();\n submitEvent.stopPropagation();\n form.handleSubmit().catch((error: unknown) => {\n throw error;\n });\n }}\n {...formProps}\n >\n {local.children}\n </form>\n );\n};\n\nexport const { useAppForm, withForm, withFieldGroup } = createFormHook({\n formContext,\n fieldContext,\n fieldComponents: {\n CheckboxField,\n ComboboxField,\n DatePickerField,\n NumberInputField,\n PasswordInputField,\n PinInputField,\n RadioGroupField,\n SelectField,\n SliderField,\n SwitchField,\n TagsInputField,\n TextInputField,\n TextareaField,\n },\n formComponents: {\n AutoSubmit,\n Form,\n SubmitButton,\n },\n});\n"],"names":["Form","props","form","useFormContext","local","formProps","splitProps","_el$","_tmpl$","addEventListener","submitEvent","preventDefault","stopPropagation","handleSubmit","catch","error","_$spread","_$mergeProps","cn","class","_$insert","children","useAppForm","withForm","withFieldGroup","createFormHook","formContext","fieldContext","fieldComponents","CheckboxField","ComboboxField","DatePickerField","NumberInputField","PasswordInputField","PinInputField","RadioGroupField","SelectField","SliderField","SwitchField","TagsInputField","TextInputField","TextareaField","formComponents","AutoSubmit","SubmitButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBO,MAAMA,IAA8BC,CAAAA,MAAU;AACnD,QAAMC,IAAOC,EAAAA,GACP,CAACC,GAAOC,CAAS,IAAIC,EAAWL,GAAO,CAAC,YAAY,OAAO,CAAC;AAElE,UAAA,MAAA;AAAA,QAAAM,IAAAC,EAAAA;AAAAD,WAAAA,EAAAE,iBAAA,UAGeC,CAAAA,MAAgB;AACzBA,MAAAA,EAAYC,eAAAA,GACZD,EAAYE,gBAAAA,GACZV,EAAKW,aAAAA,EAAeC,MAAM,CAACC,MAAmB;AAC5C,cAAMA;AAAAA,MACR,CAAC;AAAA,IACH,CAAC,GAAAC,EAAAT,GAAAU,EAAA;AAAA,MAAA,IAAA,QAAA;AAAA,eAPMC,EAAG,sBAAsBd,EAAMe,KAAK;AAAA,MAAC;AAAA,IAAA,GAQxCd,CAAS,GAAA,IAAA,EAAA,GAAAe,EAAAb,GAAA,MAEZH,EAAMiB,QAAQ,GAAAd;AAAAA,EAAA,GAAA;AAGrB,GAEa;AAAA,EAAEe,YAAAA;AAAAA,EAAYC,UAAAA;AAAAA,EAAUC,gBAAAA;AAAe,IAAIC,EAAe;AAAA,EACrEC,aAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAC,iBAAiB;AAAA,IACfC,eAAAA;AAAAA,IACAC,eAAAA;AAAAA,IACAC,iBAAAA;AAAAA,IACAC,kBAAAA;AAAAA,IACAC,oBAAAA;AAAAA,IACAC,eAAAA;AAAAA,IACAC,iBAAAA;AAAAA,IACAC,aAAAA;AAAAA,IACAC,aAAAA;AAAAA,IACAC,aAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,eAAAA;AAAAA,EAAAA;AAAAA,EAEFC,gBAAgB;AAAA,IACdC,YAAAA;AAAAA,IACA3C,MAAAA;AAAAA,IACA4C,cAAAA;AAAAA,EAAAA;AAEJ,CAAC;"}
|
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fieldContext as x, formContext as
|
|
3
|
-
import { TextInputField as
|
|
4
|
-
import { TextareaField as
|
|
1
|
+
import { Form as r, useAppForm as t, withFieldGroup as m, withForm as p } from "./Form.js";
|
|
2
|
+
import { fieldContext as x, formContext as d, useFieldContext as f, useFormContext as F } from "./context.js";
|
|
3
|
+
import { TextInputField as u } from "./TextInputField.js";
|
|
4
|
+
import { TextareaField as a } from "./TextareaField.js";
|
|
5
5
|
import { NumberInputField as s } from "./NumberInputField.js";
|
|
6
|
-
import { PasswordInputField as
|
|
6
|
+
import { PasswordInputField as I } from "./PasswordInputField.js";
|
|
7
7
|
import { PinInputField as c } from "./PinInputField.js";
|
|
8
8
|
import { SelectField as w } from "./SelectField.js";
|
|
9
|
-
import { CheckboxField as
|
|
10
|
-
import { SwitchField as
|
|
9
|
+
import { CheckboxField as T } from "./CheckboxField.js";
|
|
10
|
+
import { SwitchField as A } from "./SwitchField.js";
|
|
11
11
|
import { RadioGroupField as g } from "./RadioGroupField.js";
|
|
12
|
-
import { SliderField as
|
|
13
|
-
import { DatePickerField as
|
|
14
|
-
import { ComboboxField as
|
|
15
|
-
import { TagsInputField as
|
|
16
|
-
import { SubmitButton as
|
|
12
|
+
import { SliderField as D } from "./SliderField.js";
|
|
13
|
+
import { DatePickerField as R } from "./DatePickerField.js";
|
|
14
|
+
import { ComboboxField as q } from "./ComboboxField.js";
|
|
15
|
+
import { TagsInputField as y } from "./TagsInputField.js";
|
|
16
|
+
import { SubmitButton as E } from "./SubmitButton.js";
|
|
17
|
+
import { AutoSubmit as J } from "./AutoSubmit.js";
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
J as AutoSubmit,
|
|
20
|
+
T as CheckboxField,
|
|
21
|
+
q as ComboboxField,
|
|
22
|
+
R as DatePickerField,
|
|
23
|
+
r as Form,
|
|
21
24
|
s as NumberInputField,
|
|
22
|
-
|
|
25
|
+
I as PasswordInputField,
|
|
23
26
|
c as PinInputField,
|
|
24
27
|
g as RadioGroupField,
|
|
25
28
|
w as SelectField,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
D as SliderField,
|
|
30
|
+
E as SubmitButton,
|
|
31
|
+
A as SwitchField,
|
|
32
|
+
y as TagsInputField,
|
|
33
|
+
u as TextInputField,
|
|
34
|
+
a as TextareaField,
|
|
32
35
|
x as fieldContext,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
d as formContext,
|
|
37
|
+
t as useAppForm,
|
|
38
|
+
f as useFieldContext,
|
|
39
|
+
F as useFormContext,
|
|
40
|
+
m as withFieldGroup,
|
|
38
41
|
p as withForm
|
|
39
42
|
};
|
|
40
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createEffect, onCleanup, type Component } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
import { useFormContext } from './context';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_DEBOUNCE_MS = 300;
|
|
6
|
+
|
|
7
|
+
export type AutoSubmitProps = {
|
|
8
|
+
debounce?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const AutoSubmit: Component<AutoSubmitProps> = (props) => {
|
|
12
|
+
const form = useFormContext();
|
|
13
|
+
const values = form.useStore((state) => state.values);
|
|
14
|
+
const isTouched = form.useStore((state) => state.isTouched);
|
|
15
|
+
|
|
16
|
+
createEffect(() => {
|
|
17
|
+
values();
|
|
18
|
+
|
|
19
|
+
if (!isTouched()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const debounceTimer = setTimeout(
|
|
24
|
+
() => {
|
|
25
|
+
form.handleSubmit().catch((error: unknown) => {
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
Math.max(0, props.debounce ?? DEFAULT_DEBOUNCE_MS),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
onCleanup(() => {
|
|
33
|
+
clearTimeout(debounceTimer);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return <></>;
|
|
38
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createFormHook } from '@tanstack/solid-form';
|
|
2
|
+
import { splitProps, type Component, type ComponentProps } from 'solid-js';
|
|
3
|
+
import { cn } from 'tailwind-variants';
|
|
2
4
|
|
|
5
|
+
import { AutoSubmit } from './AutoSubmit';
|
|
3
6
|
import { CheckboxField } from './CheckboxField';
|
|
4
7
|
import { ComboboxField } from './ComboboxField';
|
|
5
|
-
import { formContext,
|
|
8
|
+
import { fieldContext, formContext, useFormContext } from './context';
|
|
6
9
|
import { DatePickerField } from './DatePickerField';
|
|
7
10
|
import { NumberInputField } from './NumberInputField';
|
|
8
11
|
import { PasswordInputField } from './PasswordInputField';
|
|
@@ -16,6 +19,29 @@ import { TagsInputField } from './TagsInputField';
|
|
|
16
19
|
import { TextareaField } from './TextareaField';
|
|
17
20
|
import { TextInputField } from './TextInputField';
|
|
18
21
|
|
|
22
|
+
export type FormProps = Omit<ComponentProps<'form'>, 'onSubmit'>;
|
|
23
|
+
|
|
24
|
+
export const Form: Component<FormProps> = (props) => {
|
|
25
|
+
const form = useFormContext();
|
|
26
|
+
const [local, formProps] = splitProps(props, ['children', 'class']);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<form
|
|
30
|
+
class={cn('space-y-6 relative', local.class)}
|
|
31
|
+
onSubmit={(submitEvent) => {
|
|
32
|
+
submitEvent.preventDefault();
|
|
33
|
+
submitEvent.stopPropagation();
|
|
34
|
+
form.handleSubmit().catch((error: unknown) => {
|
|
35
|
+
throw error;
|
|
36
|
+
});
|
|
37
|
+
}}
|
|
38
|
+
{...formProps}
|
|
39
|
+
>
|
|
40
|
+
{local.children}
|
|
41
|
+
</form>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
19
45
|
export const { useAppForm, withForm, withFieldGroup } = createFormHook({
|
|
20
46
|
formContext,
|
|
21
47
|
fieldContext,
|
|
@@ -35,6 +61,8 @@ export const { useAppForm, withForm, withFieldGroup } = createFormHook({
|
|
|
35
61
|
TextareaField,
|
|
36
62
|
},
|
|
37
63
|
formComponents: {
|
|
64
|
+
AutoSubmit,
|
|
65
|
+
Form,
|
|
38
66
|
SubmitButton,
|
|
39
67
|
},
|
|
40
68
|
});
|