@manafishrov/ui 1.2.12 → 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/ComboboxField.d.ts +5 -3
- package/dist/components/form/ComboboxField.js +62 -63
- package/dist/components/form/ComboboxField.js.map +1 -1
- package/dist/components/form/DatePickerField.d.ts +3 -2
- package/dist/components/form/DatePickerField.js +43 -32
- package/dist/components/form/DatePickerField.js.map +1 -1
- 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/NumberInputField.d.ts +3 -3
- package/dist/components/form/NumberInputField.js +18 -19
- package/dist/components/form/NumberInputField.js.map +1 -1
- package/dist/components/form/PasswordInputField.d.ts +1 -0
- package/dist/components/form/PasswordInputField.js +23 -16
- package/dist/components/form/PasswordInputField.js.map +1 -1
- package/dist/components/form/TagsInputField.d.ts +4 -4
- package/dist/components/form/TagsInputField.js +52 -49
- package/dist/components/form/TagsInputField.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/ComboboxField.tsx +30 -25
- package/src/components/form/DatePickerField.tsx +30 -17
- package/src/components/form/Form.tsx +29 -1
- package/src/components/form/NumberInputField.tsx +5 -6
- package/src/components/form/PasswordInputField.tsx +7 -3
- package/src/components/form/TagsInputField.tsx +43 -32
- package/src/components/form/index.ts +1 -0
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
import { createComponent as e, mergeProps as
|
|
2
|
-
import { splitProps as
|
|
3
|
-
import { Field as
|
|
4
|
-
import { TagsInput as
|
|
5
|
-
import { useFieldContext as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { createComponent as e, mergeProps as o, Show as s, memo as u } from "solid-js/web";
|
|
2
|
+
import { splitProps as i, For as d } from "solid-js";
|
|
3
|
+
import { Field as h, FieldLabel as p, FieldContent as c, FieldError as T, FieldDescription as I } from "../Field.js";
|
|
4
|
+
import { TagsInput as m, TagsInputContext as C, TagsInputControl as f, TagsInputItem as b, TagsInputItemPreview as w, TagsInputItemText as F, TagsInputItemDeleteTrigger as v, TagsInputItemInput as y, TagsInputInput as O, TagsInputClearTrigger as P, TagsInputHiddenInput as x } from "../TagsInput.js";
|
|
5
|
+
import { useFieldContext as q } from "./context.js";
|
|
6
|
+
const D = (l) => {
|
|
7
|
+
const [t, r] = i(l, ["children", "showClearTrigger"]);
|
|
8
|
+
return [e(C, {
|
|
9
|
+
children: (a) => e(f, {
|
|
10
|
+
get children() {
|
|
11
|
+
return [e(d, {
|
|
12
|
+
get each() {
|
|
13
|
+
return a().value;
|
|
14
|
+
},
|
|
15
|
+
children: (n, g) => e(b, {
|
|
16
|
+
get index() {
|
|
17
|
+
return g();
|
|
18
|
+
},
|
|
19
|
+
value: n,
|
|
20
|
+
get children() {
|
|
21
|
+
return [e(w, {
|
|
22
|
+
get children() {
|
|
23
|
+
return [e(F, {
|
|
24
|
+
children: n
|
|
25
|
+
}), e(v, {})];
|
|
26
|
+
}
|
|
27
|
+
}), e(y, {})];
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}), e(O, r), e(s, {
|
|
31
|
+
get when() {
|
|
32
|
+
return t.showClearTrigger !== !1;
|
|
16
33
|
},
|
|
17
|
-
value: r,
|
|
18
34
|
get children() {
|
|
19
|
-
return
|
|
20
|
-
get children() {
|
|
21
|
-
return [e(F, {
|
|
22
|
-
children: r
|
|
23
|
-
}), e(b, {})];
|
|
24
|
-
}
|
|
25
|
-
}), e(C, {})];
|
|
35
|
+
return e(P, {});
|
|
26
36
|
}
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
}), e(P, {})], q = ["label", "description", "required", "disabled", "readOnly", "placeholder"], L = (n) => {
|
|
36
|
-
const t = x(), [r, l] = u(n, q);
|
|
37
|
-
return e(o, {
|
|
37
|
+
}), u(() => t.children)];
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}), e(x, {})];
|
|
41
|
+
}, S = ["label", "description", "required", "disabled", "readOnly", "showClearTrigger"], A = (l) => {
|
|
42
|
+
const t = q(), [r, a] = i(l, S);
|
|
43
|
+
return e(h, {
|
|
38
44
|
get invalid() {
|
|
39
45
|
return t().state.meta.errors.length > 0;
|
|
40
46
|
},
|
|
@@ -48,18 +54,18 @@ const y = (n) => [e(I, {
|
|
|
48
54
|
return r.required ?? !1;
|
|
49
55
|
},
|
|
50
56
|
get children() {
|
|
51
|
-
return [e(
|
|
57
|
+
return [e(p, {
|
|
52
58
|
get children() {
|
|
53
59
|
return r.label;
|
|
54
60
|
}
|
|
55
|
-
}), e(
|
|
61
|
+
}), e(c, {
|
|
56
62
|
get children() {
|
|
57
|
-
return [e(
|
|
63
|
+
return [e(m, {
|
|
58
64
|
get value() {
|
|
59
65
|
return t().state.value;
|
|
60
66
|
},
|
|
61
|
-
onValueChange: (
|
|
62
|
-
t().handleChange(
|
|
67
|
+
onValueChange: (n) => {
|
|
68
|
+
t().handleChange(n.value);
|
|
63
69
|
},
|
|
64
70
|
onBlur: () => {
|
|
65
71
|
t().handleBlur();
|
|
@@ -72,20 +78,17 @@ const y = (n) => [e(I, {
|
|
|
72
78
|
},
|
|
73
79
|
get readOnly() {
|
|
74
80
|
return r.readOnly ?? !1;
|
|
75
|
-
}
|
|
76
|
-
}, l, {
|
|
81
|
+
},
|
|
77
82
|
get children() {
|
|
78
|
-
return e(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
+
return e(D, o(a, () => typeof r.showClearTrigger == "boolean" && {
|
|
84
|
+
showClearTrigger: r.showClearTrigger
|
|
85
|
+
}));
|
|
83
86
|
}
|
|
84
|
-
})
|
|
87
|
+
}), e(T, {
|
|
85
88
|
get errors() {
|
|
86
89
|
return t().state.meta.errors;
|
|
87
90
|
}
|
|
88
|
-
}), e(
|
|
91
|
+
}), e(I, {
|
|
89
92
|
get children() {
|
|
90
93
|
return r.description;
|
|
91
94
|
}
|
|
@@ -96,6 +99,6 @@ const y = (n) => [e(I, {
|
|
|
96
99
|
});
|
|
97
100
|
};
|
|
98
101
|
export {
|
|
99
|
-
|
|
102
|
+
A as TagsInputField
|
|
100
103
|
};
|
|
101
104
|
//# sourceMappingURL=TagsInputField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsInputField.js","sources":["../../../src/components/form/TagsInputField.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"TagsInputField.js","sources":["../../../src/components/form/TagsInputField.tsx"],"sourcesContent":["import { type Component, type ComponentProps, splitProps, For } from 'solid-js';\n\nimport { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@/components/Field';\nimport {\n TagsInput,\n TagsInputClearTrigger,\n TagsInputContext,\n TagsInputControl,\n TagsInputHiddenInput,\n TagsInputInput,\n TagsInputItemInput,\n TagsInputItemPreview,\n TagsInputItemText,\n TagsInputItem,\n TagsInputItemDeleteTrigger,\n} from '@/components/TagsInput';\n\nimport { useFieldContext } from './context';\n\nexport type TagsInputFieldProps = ComponentProps<typeof TagsInputInput> & {\n label?: string;\n description?: string;\n showClearTrigger?: boolean;\n};\n\nconst TagsInputGroup: Component<\n ComponentProps<typeof TagsInputInput> & { showClearTrigger?: boolean }\n> = (props) => {\n const [local, others] = splitProps(props, ['children', 'showClearTrigger']);\n\n return (\n <>\n <TagsInputContext>\n {(context) => (\n <TagsInputControl>\n <For each={context().value}>\n {(value, index) => (\n <TagsInputItem index={index()} value={value}>\n <TagsInputItemPreview>\n <TagsInputItemText>{value}</TagsInputItemText>\n <TagsInputItemDeleteTrigger />\n </TagsInputItemPreview>\n <TagsInputItemInput />\n </TagsInputItem>\n )}\n </For>\n <TagsInputInput {...others} />\n <Show when={local.showClearTrigger !== false}>\n <TagsInputClearTrigger />\n </Show>\n {local.children}\n </TagsInputControl>\n )}\n </TagsInputContext>\n <TagsInputHiddenInput />\n </>\n );\n};\n\nconst TAGS_INPUT_FIELD_PROPS = [\n 'label',\n 'description',\n 'required',\n 'disabled',\n 'readOnly',\n 'showClearTrigger',\n] as const;\n\nexport const TagsInputField: Component<TagsInputFieldProps> = (props) => {\n const field = useFieldContext<string[]>();\n const [local, others] = splitProps(props, TAGS_INPUT_FIELD_PROPS);\n\n return (\n <Field\n invalid={field().state.meta.errors.length > 0}\n disabled={local.disabled ?? false}\n readOnly={local.readOnly ?? false}\n required={local.required ?? false}\n >\n <FieldLabel>{local.label}</FieldLabel>\n <FieldContent>\n <TagsInput\n value={field().state.value}\n onValueChange={(details) => {\n field().handleChange(details.value);\n }}\n onBlur={() => {\n field().handleBlur();\n }}\n invalid={field().state.meta.errors.length > 0}\n disabled={local.disabled ?? false}\n readOnly={local.readOnly ?? false}\n >\n <TagsInputGroup\n {...others}\n {...(typeof local.showClearTrigger === 'boolean' && {\n showClearTrigger: local.showClearTrigger,\n })}\n />\n </TagsInput>\n <FieldError errors={field().state.meta.errors} />\n <FieldDescription>{local.description}</FieldDescription>\n </FieldContent>\n </Field>\n );\n};\n"],"names":["TagsInputGroup","props","local","others","splitProps","_$createComponent","TagsInputContext","children","context","TagsInputControl","For","each","value","index","TagsInputItem","TagsInputItemPreview","TagsInputItemText","TagsInputItemDeleteTrigger","TagsInputItemInput","TagsInputInput","_$Show","when","showClearTrigger","TagsInputClearTrigger","_$memo","TagsInputHiddenInput","TAGS_INPUT_FIELD_PROPS","TagsInputField","field","useFieldContext","Field","invalid","state","meta","errors","length","disabled","readOnly","required","FieldLabel","label","FieldContent","TagsInput","onValueChange","details","handleChange","onBlur","handleBlur","_$mergeProps","FieldError","FieldDescription","description"],"mappings":"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"}
|
|
@@ -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
|
+
};
|
|
@@ -15,34 +15,39 @@ import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@
|
|
|
15
15
|
|
|
16
16
|
import { useFieldContext } from './context';
|
|
17
17
|
|
|
18
|
-
export type ComboboxFieldProps =
|
|
18
|
+
export type ComboboxFieldProps = ComponentProps<typeof ComboboxInput> & {
|
|
19
|
+
collection: ComboboxRootProps<string>['collection'];
|
|
19
20
|
label?: string;
|
|
20
21
|
description?: string;
|
|
21
22
|
showTrigger?: boolean;
|
|
22
|
-
|
|
23
|
+
showClearTrigger?: boolean;
|
|
23
24
|
} & { class?: string };
|
|
24
25
|
|
|
25
26
|
const ComboboxInputGroup: Component<
|
|
26
27
|
ComponentProps<typeof ComboboxInput> & {
|
|
27
28
|
showTrigger?: boolean | undefined;
|
|
28
|
-
|
|
29
|
+
showClearTrigger?: boolean | undefined;
|
|
29
30
|
}
|
|
30
|
-
> = (props) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
> = (props) => {
|
|
32
|
+
const [local, others] = splitProps(props, ['showTrigger', 'showClearTrigger', 'children']);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<ComboboxControl>
|
|
37
|
+
<ComboboxInput {...others} />
|
|
38
|
+
<div class='gap-1 flex items-center'>
|
|
39
|
+
{local.showClearTrigger === true && <ComboboxClearTrigger />}
|
|
40
|
+
{local.showTrigger === true && <ComboboxTrigger />}
|
|
41
|
+
</div>
|
|
42
|
+
</ComboboxControl>
|
|
43
|
+
<ComboboxPositioner>
|
|
44
|
+
<ComboboxContent>
|
|
45
|
+
<ComboboxList>{local.children}</ComboboxList>
|
|
46
|
+
</ComboboxContent>
|
|
47
|
+
</ComboboxPositioner>
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
46
51
|
|
|
47
52
|
const COMBOBOX_FIELD_PROPS = [
|
|
48
53
|
'label',
|
|
@@ -50,9 +55,9 @@ const COMBOBOX_FIELD_PROPS = [
|
|
|
50
55
|
'required',
|
|
51
56
|
'disabled',
|
|
52
57
|
'readOnly',
|
|
53
|
-
'
|
|
58
|
+
'collection',
|
|
54
59
|
'showTrigger',
|
|
55
|
-
'
|
|
60
|
+
'showClearTrigger',
|
|
56
61
|
'children',
|
|
57
62
|
] as const;
|
|
58
63
|
|
|
@@ -69,7 +74,8 @@ export const ComboboxField: Component<ComboboxFieldProps> = (props) => {
|
|
|
69
74
|
>
|
|
70
75
|
<FieldLabel>{local.label}</FieldLabel>
|
|
71
76
|
<FieldContent>
|
|
72
|
-
<Combobox
|
|
77
|
+
<Combobox<string>
|
|
78
|
+
collection={local.collection}
|
|
73
79
|
value={field().state.value}
|
|
74
80
|
onValueChange={(details) => {
|
|
75
81
|
field().handleChange(details.value);
|
|
@@ -80,12 +86,11 @@ export const ComboboxField: Component<ComboboxFieldProps> = (props) => {
|
|
|
80
86
|
invalid={field().state.meta.errors.length > 0}
|
|
81
87
|
disabled={local.disabled ?? false}
|
|
82
88
|
readOnly={local.readOnly ?? false}
|
|
83
|
-
{...others}
|
|
84
89
|
>
|
|
85
90
|
<ComboboxInputGroup
|
|
86
|
-
placeholder={local.placeholder}
|
|
87
91
|
showTrigger={local.showTrigger}
|
|
88
|
-
|
|
92
|
+
showClearTrigger={local.showClearTrigger}
|
|
93
|
+
{...others}
|
|
89
94
|
>
|
|
90
95
|
{local.children}
|
|
91
96
|
</ComboboxInputGroup>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DatePickerInputProps,
|
|
1
|
+
import type { DatePickerInputProps, DateValue } from '@ark-ui/solid';
|
|
2
2
|
import type { Component } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -14,24 +14,33 @@ import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@
|
|
|
14
14
|
|
|
15
15
|
import { useFieldContext } from './context';
|
|
16
16
|
|
|
17
|
-
export type DatePickerFieldProps =
|
|
17
|
+
export type DatePickerFieldProps = DatePickerInputProps & {
|
|
18
18
|
label?: string;
|
|
19
19
|
description?: string;
|
|
20
|
+
showTrigger?: boolean;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const DatePickerInputGroup: Component<DatePickerInputProps> = (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const DatePickerInputGroup: Component<DatePickerInputProps & { showTrigger?: boolean }> = (
|
|
24
|
+
props,
|
|
25
|
+
) => {
|
|
26
|
+
const [local, others] = splitProps(props, ['showTrigger']);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<DatePickerControl>
|
|
31
|
+
<DatePickerInput {...others} />
|
|
32
|
+
<Show when={local.showTrigger !== false}>
|
|
33
|
+
<DatePickerTrigger />
|
|
34
|
+
</Show>
|
|
35
|
+
</DatePickerControl>
|
|
36
|
+
<DatePickerPositioner>
|
|
37
|
+
<DatePickerContent>
|
|
38
|
+
<DatePickerViews />
|
|
39
|
+
</DatePickerContent>
|
|
40
|
+
</DatePickerPositioner>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
35
44
|
|
|
36
45
|
const DATE_PICKER_FIELD_PROPS = [
|
|
37
46
|
'label',
|
|
@@ -40,6 +49,7 @@ const DATE_PICKER_FIELD_PROPS = [
|
|
|
40
49
|
'disabled',
|
|
41
50
|
'readOnly',
|
|
42
51
|
'placeholder',
|
|
52
|
+
'showTrigger',
|
|
43
53
|
] as const;
|
|
44
54
|
|
|
45
55
|
export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
|
|
@@ -66,9 +76,12 @@ export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
|
|
|
66
76
|
invalid={field().state.meta.errors.length > 0}
|
|
67
77
|
disabled={local.disabled ?? false}
|
|
68
78
|
readOnly={local.readOnly ?? false}
|
|
69
|
-
{...others}
|
|
70
79
|
>
|
|
71
|
-
<DatePickerInputGroup
|
|
80
|
+
<DatePickerInputGroup
|
|
81
|
+
{...others}
|
|
82
|
+
placeholder={local.placeholder}
|
|
83
|
+
{...(typeof local.showTrigger === 'boolean' && { showTrigger: local.showTrigger })}
|
|
84
|
+
/>
|
|
72
85
|
</DatePicker>
|
|
73
86
|
<FieldError errors={field().state.meta.errors} />
|
|
74
87
|
<FieldDescription>{local.description}</FieldDescription>
|
|
@@ -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
|
});
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { useFieldContext } from './context';
|
|
12
12
|
|
|
13
|
-
export type NumberInputFieldProps = ComponentProps<typeof
|
|
13
|
+
export type NumberInputFieldProps = ComponentProps<typeof NumberInputInput> & {
|
|
14
14
|
label?: string;
|
|
15
15
|
description?: string;
|
|
16
|
-
|
|
16
|
+
showTriggers?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
|
|
@@ -24,7 +24,7 @@ export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
|
|
|
24
24
|
'required',
|
|
25
25
|
'disabled',
|
|
26
26
|
'readOnly',
|
|
27
|
-
'
|
|
27
|
+
'showTriggers',
|
|
28
28
|
]);
|
|
29
29
|
|
|
30
30
|
return (
|
|
@@ -48,11 +48,10 @@ export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
|
|
|
48
48
|
disabled={local.disabled ?? false}
|
|
49
49
|
readOnly={local.readOnly ?? false}
|
|
50
50
|
required={local.required ?? false}
|
|
51
|
-
{...others}
|
|
52
51
|
>
|
|
53
52
|
<NumberInputControl>
|
|
54
|
-
<NumberInputInput />
|
|
55
|
-
<Show when={local.
|
|
53
|
+
<NumberInputInput {...others} />
|
|
54
|
+
<Show when={local.showTriggers !== false}>
|
|
56
55
|
<NumberInputTriggers />
|
|
57
56
|
</Show>
|
|
58
57
|
</NumberInputControl>
|
|
@@ -14,6 +14,7 @@ import { useFieldContext } from './context';
|
|
|
14
14
|
export type PasswordInputFieldProps = ComponentProps<typeof PasswordInputInput> & {
|
|
15
15
|
label?: string;
|
|
16
16
|
description?: string;
|
|
17
|
+
showVisibilityTrigger?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export const PasswordInputField: Component<PasswordInputFieldProps> = (props) => {
|
|
@@ -24,6 +25,7 @@ export const PasswordInputField: Component<PasswordInputFieldProps> = (props) =>
|
|
|
24
25
|
'required',
|
|
25
26
|
'disabled',
|
|
26
27
|
'readOnly',
|
|
28
|
+
'showVisibilityTrigger',
|
|
27
29
|
]);
|
|
28
30
|
|
|
29
31
|
return (
|
|
@@ -52,9 +54,11 @@ export const PasswordInputField: Component<PasswordInputFieldProps> = (props) =>
|
|
|
52
54
|
}}
|
|
53
55
|
{...others}
|
|
54
56
|
/>
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
57
|
+
<Show when={local.showVisibilityTrigger !== false}>
|
|
58
|
+
<PasswordInputVisibilityTrigger>
|
|
59
|
+
<PasswordInputIndicator />
|
|
60
|
+
</PasswordInputVisibilityTrigger>
|
|
61
|
+
</Show>
|
|
58
62
|
</PasswordInputControl>
|
|
59
63
|
</PasswordInput>
|
|
60
64
|
<FieldError errors={field().state.meta.errors} />
|