@manafishrov/ui 1.3.1 → 1.3.3
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/ComboboxField.d.ts +4 -2
- package/dist/components/form/ComboboxField.js +33 -32
- package/dist/components/form/ComboboxField.js.map +1 -1
- package/dist/components/form/DatePickerField.d.ts +5 -2
- package/dist/components/form/DatePickerField.js +25 -24
- package/dist/components/form/DatePickerField.js.map +1 -1
- package/dist/components/form/NumberInputField.d.ts +4 -2
- package/dist/components/form/NumberInputField.js +102 -73
- package/dist/components/form/NumberInputField.js.map +1 -1
- package/dist/components/form/SubmitButton.js +12 -9
- package/dist/components/form/SubmitButton.js.map +1 -1
- package/dist/components/form/TagsInputField.d.ts +4 -2
- package/dist/components/form/TagsInputField.js +32 -31
- package/dist/components/form/TagsInputField.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/ComboboxField.tsx +53 -8
- package/src/components/form/DatePickerField.tsx +54 -7
- package/src/components/form/NumberInputField.tsx +147 -39
- package/src/components/form/SubmitButton.tsx +2 -1
- package/src/components/form/TagsInputField.tsx +30 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubmitButton.js","sources":["../../../src/components/form/SubmitButton.tsx"],"sourcesContent":["import type { Component, ComponentProps } from 'solid-js';\n\nimport { Button } from '@/components/Button';\n\nimport { useFormContext } from './context';\n\nexport type SubmitButtonProps = ComponentProps<typeof Button> & {\n loading?: boolean;\n};\n\nexport const SubmitButton: Component<SubmitButtonProps> = (props) => {\n const form = useFormContext();\n const [local, others] = splitProps(props, ['children', 'loading', 'disabled']);\n\n const isLoading = (): boolean =>\n form.state.isSubmitting || form.state.isValidating || (local.loading ?? false);\n\n return (\n <Button\n type='submit'\n loading={isLoading()}\n disabled={local.disabled ?? !form.state.canSubmit}\n {...others}\n >\n {local.children}\n </Button>\n );\n};\n"],"names":["SubmitButton","props","form","useFormContext","local","others","splitProps","isLoading","state","isSubmitting","isValidating","loading","_$createComponent","Button","_$mergeProps","type","disabled","canSubmit","children"],"mappings":";;;;AAUO,MAAMA,IAA8CC,CAAAA,MAAU;AACnE,QAAMC,IAAOC,EAAAA,GACP,CAACC,GAAOC,CAAM,IAAIC,EAAWL,GAAO,CAAC,YAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"SubmitButton.js","sources":["../../../src/components/form/SubmitButton.tsx"],"sourcesContent":["import type { Component, ComponentProps } from 'solid-js';\n\nimport { Button } from '@/components/Button';\n\nimport { useFormContext } from './context';\n\nexport type SubmitButtonProps = ComponentProps<typeof Button> & {\n loading?: boolean;\n};\n\nexport const SubmitButton: Component<SubmitButtonProps> = (props) => {\n const form = useFormContext();\n const [local, others] = splitProps(props, ['children', 'loading', 'disabled', 'class']);\n\n const isLoading = (): boolean =>\n form.state.isSubmitting || form.state.isValidating || (local.loading ?? false);\n\n return (\n <Button\n type='submit'\n loading={isLoading()}\n disabled={local.disabled ?? !form.state.canSubmit}\n class={`min-w-24 ${local.class ?? ''}`}\n {...others}\n >\n {local.children}\n </Button>\n );\n};\n"],"names":["SubmitButton","props","form","useFormContext","local","others","splitProps","isLoading","state","isSubmitting","isValidating","loading","_$createComponent","Button","_$mergeProps","type","disabled","canSubmit","class","children"],"mappings":";;;;AAUO,MAAMA,IAA8CC,CAAAA,MAAU;AACnE,QAAMC,IAAOC,EAAAA,GACP,CAACC,GAAOC,CAAM,IAAIC,EAAWL,GAAO,CAAC,YAAY,WAAW,YAAY,OAAO,CAAC,GAEhFM,IAAYA,MAChBL,EAAKM,MAAMC,gBAAgBP,EAAKM,MAAME,iBAAiBN,EAAMO,WAAW;AAE1E,SAAAC,EACGC,GAAMC,EAAA;AAAA,IACLC,MAAI;AAAA,IAAA,IACJJ,UAAO;AAAA,aAAEJ,EAAAA;AAAAA,IAAW;AAAA,IAAA,IACpBS,WAAQ;AAAA,aAAEZ,EAAMY,YAAY,CAACd,EAAKM,MAAMS;AAAAA,IAAS;AAAA,IAAA,IAAA,QAAA;AAAA,aAC1C,YAAYb,EAAMc,SAAS,EAAE;AAAA,IAAE;AAAA,EAAA,GAClCb,GAAM;AAAA,IAAA,IAAAc,WAAA;AAAA,aAETf,EAAMe;AAAAA,IAAQ;AAAA,EAAA,CAAA,CAAA;AAGrB;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Component, ComponentProps } from 'solid-js';
|
|
2
|
-
import { TagsInputInput } from '../TagsInput';
|
|
3
|
-
|
|
2
|
+
import { TagsInput, TagsInputInput } from '../TagsInput';
|
|
3
|
+
declare const TAGS_INPUT_ROOT_PROPS: readonly ["max", "maxLength", "delimiter", "addOnPaste", "blurBehavior", "validate", "autoFocus", "editable", "allowOverflow", "translations", "ids", "onFocusOutside", "onHighlightChange", "onInputValueChange", "onInteractOutside", "onPointerDownOutside", "onValueInvalid"];
|
|
4
|
+
export type TagsInputFieldProps = ComponentProps<typeof TagsInputInput> & Pick<ComponentProps<typeof TagsInput>, (typeof TAGS_INPUT_ROOT_PROPS)[number]> & {
|
|
4
5
|
label?: string;
|
|
5
6
|
description?: string;
|
|
6
7
|
showClearTrigger?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const TagsInputField: Component<TagsInputFieldProps>;
|
|
10
|
+
export {};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { createComponent as e, mergeProps as
|
|
2
|
-
import { splitProps as i, For as
|
|
3
|
-
import { Field as
|
|
4
|
-
import { TagsInput as
|
|
5
|
-
import { useFieldContext as
|
|
6
|
-
const D = (l) => {
|
|
1
|
+
import { createComponent as e, mergeProps as s, Show as g, memo as d } from "solid-js/web";
|
|
2
|
+
import { splitProps as i, For as h } from "solid-js";
|
|
3
|
+
import { Field as p, FieldLabel as c, FieldContent as I, FieldError as T, FieldDescription as m } from "../Field.js";
|
|
4
|
+
import { TagsInput as C, TagsInputContext as f, TagsInputControl as O, TagsInputItem as P, TagsInputItemPreview as w, TagsInputItemText as b, TagsInputItemDeleteTrigger as F, TagsInputItemInput as v, TagsInputInput as x, TagsInputClearTrigger as y, TagsInputHiddenInput as _ } from "../TagsInput.js";
|
|
5
|
+
import { useFieldContext as S } from "./context.js";
|
|
6
|
+
const D = ["max", "maxLength", "delimiter", "addOnPaste", "blurBehavior", "validate", "autoFocus", "editable", "allowOverflow", "translations", "ids", "onFocusOutside", "onHighlightChange", "onInputValueChange", "onInteractOutside", "onPointerDownOutside", "onValueInvalid"], q = (l) => {
|
|
7
7
|
const [t, r] = i(l, ["children", "showClearTrigger"]);
|
|
8
|
-
return [e(
|
|
9
|
-
children: (a) => e(
|
|
8
|
+
return [e(f, {
|
|
9
|
+
children: (a) => e(O, {
|
|
10
10
|
get children() {
|
|
11
|
-
return [e(
|
|
11
|
+
return [e(h, {
|
|
12
12
|
get each() {
|
|
13
13
|
return a().value;
|
|
14
14
|
},
|
|
15
|
-
children: (n,
|
|
15
|
+
children: (n, o) => e(P, {
|
|
16
16
|
get index() {
|
|
17
|
-
return
|
|
17
|
+
return o();
|
|
18
18
|
},
|
|
19
19
|
value: n,
|
|
20
20
|
get children() {
|
|
21
21
|
return [e(w, {
|
|
22
22
|
get children() {
|
|
23
|
-
return [e(
|
|
23
|
+
return [e(b, {
|
|
24
24
|
children: n
|
|
25
|
-
}), e(
|
|
25
|
+
}), e(F, {})];
|
|
26
26
|
}
|
|
27
|
-
}), e(
|
|
27
|
+
}), e(v, {})];
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
|
-
}), e(
|
|
30
|
+
}), e(x, r), e(g, {
|
|
31
31
|
get when() {
|
|
32
32
|
return t.showClearTrigger !== !1;
|
|
33
33
|
},
|
|
34
34
|
get children() {
|
|
35
|
-
return e(
|
|
35
|
+
return e(y, {});
|
|
36
36
|
}
|
|
37
|
-
}),
|
|
37
|
+
}), d(() => t.children)];
|
|
38
38
|
}
|
|
39
39
|
})
|
|
40
|
-
}), e(
|
|
41
|
-
},
|
|
42
|
-
const t =
|
|
43
|
-
return e(
|
|
40
|
+
}), e(_, {})];
|
|
41
|
+
}, B = ["label", "description", "required", "disabled", "readOnly", "showClearTrigger"], E = (l) => {
|
|
42
|
+
const t = S(), [r, a] = i(l, B), [n, o] = i(a, D);
|
|
43
|
+
return e(p, {
|
|
44
44
|
get invalid() {
|
|
45
45
|
return t().state.meta.errors.length > 0;
|
|
46
46
|
},
|
|
@@ -54,18 +54,18 @@ const D = (l) => {
|
|
|
54
54
|
return r.required ?? !1;
|
|
55
55
|
},
|
|
56
56
|
get children() {
|
|
57
|
-
return [e(
|
|
57
|
+
return [e(c, {
|
|
58
58
|
get children() {
|
|
59
59
|
return r.label;
|
|
60
60
|
}
|
|
61
|
-
}), e(
|
|
61
|
+
}), e(I, {
|
|
62
62
|
get children() {
|
|
63
|
-
return [e(
|
|
63
|
+
return [e(C, s({
|
|
64
64
|
get value() {
|
|
65
65
|
return t().state.value;
|
|
66
66
|
},
|
|
67
|
-
onValueChange: (
|
|
68
|
-
t().handleChange(
|
|
67
|
+
onValueChange: (u) => {
|
|
68
|
+
t().handleChange(u.value);
|
|
69
69
|
},
|
|
70
70
|
onBlur: () => {
|
|
71
71
|
t().handleBlur();
|
|
@@ -78,17 +78,18 @@ const D = (l) => {
|
|
|
78
78
|
},
|
|
79
79
|
get readOnly() {
|
|
80
80
|
return r.readOnly ?? !1;
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
|
+
}, n, {
|
|
82
83
|
get children() {
|
|
83
|
-
return e(
|
|
84
|
+
return e(q, s(o, () => typeof r.showClearTrigger == "boolean" && {
|
|
84
85
|
showClearTrigger: r.showClearTrigger
|
|
85
86
|
}));
|
|
86
87
|
}
|
|
87
|
-
}), e(T, {
|
|
88
|
+
})), e(T, {
|
|
88
89
|
get errors() {
|
|
89
90
|
return t().state.meta.errors;
|
|
90
91
|
}
|
|
91
|
-
}), e(
|
|
92
|
+
}), e(m, {
|
|
92
93
|
get children() {
|
|
93
94
|
return r.description;
|
|
94
95
|
}
|
|
@@ -99,6 +100,6 @@ const D = (l) => {
|
|
|
99
100
|
});
|
|
100
101
|
};
|
|
101
102
|
export {
|
|
102
|
-
|
|
103
|
+
E as TagsInputField
|
|
103
104
|
};
|
|
104
105
|
//# sourceMappingURL=TagsInputField.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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\nconst TAGS_INPUT_ROOT_PROPS = [\n 'max',\n 'maxLength',\n 'delimiter',\n 'addOnPaste',\n 'blurBehavior',\n 'validate',\n 'autoFocus',\n 'editable',\n 'allowOverflow',\n 'translations',\n 'ids',\n 'onFocusOutside',\n 'onHighlightChange',\n 'onInputValueChange',\n 'onInteractOutside',\n 'onPointerDownOutside',\n 'onValueInvalid',\n] as const;\n\nexport type TagsInputFieldProps = ComponentProps<typeof TagsInputInput> &\n Pick<ComponentProps<typeof TagsInput>, (typeof TAGS_INPUT_ROOT_PROPS)[number]> & {\n label?: string;\n description?: string;\n showClearTrigger?: boolean;\n };\n\nconst TagsInputGroup: Component<\n { showClearTrigger?: boolean } & ComponentProps<typeof TagsInputInput>\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 const [rootProps, inputProps] = splitProps(others, TAGS_INPUT_ROOT_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 {...rootProps}\n >\n <TagsInputGroup\n {...inputProps}\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":["TAGS_INPUT_ROOT_PROPS","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","rootProps","inputProps","Field","invalid","state","meta","errors","length","disabled","readOnly","required","FieldLabel","label","FieldContent","TagsInput","_$mergeProps","onValueChange","details","handleChange","onBlur","handleBlur","FieldError","FieldDescription","description"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -15,13 +15,56 @@ import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@
|
|
|
15
15
|
|
|
16
16
|
import { useFieldContext } from './context';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const COMBOBOX_ROOT_PROPS = [
|
|
19
|
+
'placeholder',
|
|
20
|
+
'inputBehavior',
|
|
21
|
+
'openOnChange',
|
|
22
|
+
'openOnClick',
|
|
23
|
+
'openOnKeyPress',
|
|
24
|
+
'closeOnSelect',
|
|
25
|
+
'allowCustomValue',
|
|
26
|
+
'multiple',
|
|
27
|
+
'selectionBehavior',
|
|
28
|
+
'autoFocus',
|
|
29
|
+
'loopFocus',
|
|
30
|
+
'positioning',
|
|
31
|
+
'alwaysSubmitOnEnter',
|
|
32
|
+
'composite',
|
|
33
|
+
'defaultHighlightedValue',
|
|
34
|
+
'defaultInputValue',
|
|
35
|
+
'defaultOpen',
|
|
36
|
+
'defaultValue',
|
|
37
|
+
'disableLayer',
|
|
38
|
+
'highlightedValue',
|
|
39
|
+
'ids',
|
|
40
|
+
'immediate',
|
|
41
|
+
'inputValue',
|
|
42
|
+
'lazyMount',
|
|
43
|
+
'navigate',
|
|
44
|
+
'onExitComplete',
|
|
45
|
+
'onFocusOutside',
|
|
46
|
+
'onHighlightChange',
|
|
47
|
+
'onInputValueChange',
|
|
48
|
+
'onInteractOutside',
|
|
49
|
+
'onOpenChange',
|
|
50
|
+
'onPointerDownOutside',
|
|
51
|
+
'onSelect',
|
|
52
|
+
'open',
|
|
53
|
+
'present',
|
|
54
|
+
'scrollToIndexFn',
|
|
55
|
+
'skipAnimationOnMount',
|
|
56
|
+
'translations',
|
|
57
|
+
'unmountOnExit',
|
|
58
|
+
] as const;
|
|
59
|
+
|
|
60
|
+
export type ComboboxFieldProps = ComponentProps<typeof ComboboxInput> &
|
|
61
|
+
Pick<ComponentProps<typeof Combobox<string>>, (typeof COMBOBOX_ROOT_PROPS)[number]> & {
|
|
62
|
+
collection: ComboboxRootProps<string>['collection'];
|
|
63
|
+
label?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
showTrigger?: boolean;
|
|
66
|
+
showClearTrigger?: boolean;
|
|
67
|
+
} & { class?: string };
|
|
25
68
|
|
|
26
69
|
const ComboboxInputGroup: Component<
|
|
27
70
|
ComponentProps<typeof ComboboxInput> & {
|
|
@@ -64,6 +107,7 @@ const COMBOBOX_FIELD_PROPS = [
|
|
|
64
107
|
export const ComboboxField: Component<ComboboxFieldProps> = (props) => {
|
|
65
108
|
const field = useFieldContext<string[]>();
|
|
66
109
|
const [local, others] = splitProps(props, COMBOBOX_FIELD_PROPS);
|
|
110
|
+
const [rootProps, inputProps] = splitProps(others, COMBOBOX_ROOT_PROPS);
|
|
67
111
|
|
|
68
112
|
return (
|
|
69
113
|
<Field
|
|
@@ -86,11 +130,12 @@ export const ComboboxField: Component<ComboboxFieldProps> = (props) => {
|
|
|
86
130
|
invalid={field().state.meta.errors.length > 0}
|
|
87
131
|
disabled={local.disabled ?? false}
|
|
88
132
|
readOnly={local.readOnly ?? false}
|
|
133
|
+
{...rootProps}
|
|
89
134
|
>
|
|
90
135
|
<ComboboxInputGroup
|
|
91
136
|
showTrigger={local.showTrigger}
|
|
92
137
|
showClearTrigger={local.showClearTrigger}
|
|
93
|
-
{...
|
|
138
|
+
{...inputProps}
|
|
94
139
|
>
|
|
95
140
|
{local.children}
|
|
96
141
|
</ComboboxInputGroup>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatePickerInputProps, DateValue } from '@ark-ui/solid';
|
|
2
|
-
import type { Component } from 'solid-js';
|
|
2
|
+
import type { Component, ComponentProps } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
DatePicker,
|
|
@@ -14,11 +14,56 @@ import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@
|
|
|
14
14
|
|
|
15
15
|
import { useFieldContext } from './context';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const DATE_PICKER_ROOT_PROPS = [
|
|
18
|
+
'min',
|
|
19
|
+
'max',
|
|
20
|
+
'locale',
|
|
21
|
+
'timeZone',
|
|
22
|
+
'format',
|
|
23
|
+
'parse',
|
|
24
|
+
'selectionMode',
|
|
25
|
+
'numOfMonths',
|
|
26
|
+
'fixedWeeks',
|
|
27
|
+
'startOfWeek',
|
|
28
|
+
'showWeekNumbers',
|
|
29
|
+
'outsideDaySelectable',
|
|
30
|
+
'isDateUnavailable',
|
|
31
|
+
'openOnClick',
|
|
32
|
+
'positioning',
|
|
33
|
+
'closeOnSelect',
|
|
34
|
+
'defaultFocusedValue',
|
|
35
|
+
'defaultOpen',
|
|
36
|
+
'defaultValue',
|
|
37
|
+
'defaultView',
|
|
38
|
+
'focusedValue',
|
|
39
|
+
'ids',
|
|
40
|
+
'immediate',
|
|
41
|
+
'inline',
|
|
42
|
+
'lazyMount',
|
|
43
|
+
'maxSelectedDates',
|
|
44
|
+
'maxView',
|
|
45
|
+
'minView',
|
|
46
|
+
'name',
|
|
47
|
+
'onExitComplete',
|
|
48
|
+
'onFocusChange',
|
|
49
|
+
'onOpenChange',
|
|
50
|
+
'onValueChange',
|
|
51
|
+
'onViewChange',
|
|
52
|
+
'onVisibleRangeChange',
|
|
53
|
+
'open',
|
|
54
|
+
'present',
|
|
55
|
+
'skipAnimationOnMount',
|
|
56
|
+
'translations',
|
|
57
|
+
'unmountOnExit',
|
|
58
|
+
'view',
|
|
59
|
+
] as const;
|
|
60
|
+
|
|
61
|
+
export type DatePickerFieldProps = DatePickerInputProps &
|
|
62
|
+
Pick<ComponentProps<typeof DatePicker>, (typeof DATE_PICKER_ROOT_PROPS)[number]> & {
|
|
63
|
+
label?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
showTrigger?: boolean;
|
|
66
|
+
};
|
|
22
67
|
|
|
23
68
|
const DatePickerInputGroup: Component<DatePickerInputProps & { showTrigger?: boolean }> = (
|
|
24
69
|
props,
|
|
@@ -55,6 +100,7 @@ const DATE_PICKER_FIELD_PROPS = [
|
|
|
55
100
|
export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
|
|
56
101
|
const field = useFieldContext<DateValue[]>();
|
|
57
102
|
const [local, others] = splitProps(props, DATE_PICKER_FIELD_PROPS);
|
|
103
|
+
const [rootProps, inputProps] = splitProps(others, DATE_PICKER_ROOT_PROPS);
|
|
58
104
|
|
|
59
105
|
return (
|
|
60
106
|
<Field
|
|
@@ -76,9 +122,10 @@ export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
|
|
|
76
122
|
invalid={field().state.meta.errors.length > 0}
|
|
77
123
|
disabled={local.disabled ?? false}
|
|
78
124
|
readOnly={local.readOnly ?? false}
|
|
125
|
+
{...rootProps}
|
|
79
126
|
>
|
|
80
127
|
<DatePickerInputGroup
|
|
81
|
-
{...
|
|
128
|
+
{...inputProps}
|
|
82
129
|
placeholder={local.placeholder}
|
|
83
130
|
{...(typeof local.showTrigger === 'boolean' && { showTrigger: local.showTrigger })}
|
|
84
131
|
/>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component, ComponentProps } from 'solid-js';
|
|
1
|
+
import type { Component, ComponentProps, JSX } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from '@/components/Field';
|
|
4
4
|
import {
|
|
@@ -10,12 +10,142 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { useFieldContext } from './context';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const NUMBER_INPUT_ROOT_PROPS = [
|
|
14
|
+
'min',
|
|
15
|
+
'max',
|
|
16
|
+
'step',
|
|
17
|
+
'allowMouseWheel',
|
|
18
|
+
'allowOverflow',
|
|
19
|
+
'clampValueOnBlur',
|
|
20
|
+
'formatOptions',
|
|
21
|
+
'inputMode',
|
|
22
|
+
'locale',
|
|
23
|
+
'pattern',
|
|
24
|
+
'spinOnPress',
|
|
25
|
+
'focusInputOnChange',
|
|
26
|
+
'translations',
|
|
27
|
+
'form',
|
|
28
|
+
'name',
|
|
29
|
+
'onValueInvalid',
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
export type NumberInputFieldProps = ComponentProps<typeof NumberInputInput> &
|
|
33
|
+
Pick<ComponentProps<typeof NumberInput>, (typeof NUMBER_INPUT_ROOT_PROPS)[number]> & {
|
|
34
|
+
label?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
showTriggers?: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const toNumberInputValue = (value: number | undefined): string => {
|
|
40
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return String(value);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type NumberInputFieldLocalProps = Pick<
|
|
48
|
+
NumberInputFieldProps,
|
|
49
|
+
'label' | 'description' | 'required' | 'disabled' | 'readOnly' | 'showTriggers'
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
type NumberInputFieldRootProps = Pick<
|
|
53
|
+
NumberInputFieldProps,
|
|
54
|
+
(typeof NUMBER_INPUT_ROOT_PROPS)[number]
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
type RenderNumberInputFieldProps = {
|
|
58
|
+
field: ReturnType<typeof useFieldContext<number>>;
|
|
59
|
+
local: NumberInputFieldLocalProps;
|
|
60
|
+
rootProps: NumberInputFieldRootProps;
|
|
61
|
+
inputProps: Omit<
|
|
62
|
+
NumberInputFieldProps,
|
|
63
|
+
keyof NumberInputFieldLocalProps | keyof NumberInputFieldRootProps
|
|
64
|
+
>;
|
|
65
|
+
inputValue: () => string;
|
|
66
|
+
onValueChange: NonNullable<ComponentProps<typeof NumberInput>['onValueChange']>;
|
|
67
|
+
onValueCommit: NonNullable<ComponentProps<typeof NumberInput>['onValueCommit']>;
|
|
68
|
+
onBlur: () => void;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type NumberInputFieldState = Pick<
|
|
72
|
+
RenderNumberInputFieldProps,
|
|
73
|
+
'inputValue' | 'onValueChange' | 'onValueCommit' | 'onBlur'
|
|
74
|
+
>;
|
|
75
|
+
|
|
76
|
+
const createNumberInputFieldState = (
|
|
77
|
+
field: ReturnType<typeof useFieldContext<number>>,
|
|
78
|
+
): NumberInputFieldState => {
|
|
79
|
+
const [inputValue, setInputValue] = createSignal(toNumberInputValue(field().state.value));
|
|
80
|
+
|
|
81
|
+
createEffect(() => {
|
|
82
|
+
setInputValue(toNumberInputValue(field().state.value));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const onValueChange: NonNullable<ComponentProps<typeof NumberInput>['onValueChange']> = (
|
|
86
|
+
details,
|
|
87
|
+
) => {
|
|
88
|
+
setInputValue(details.value);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const onValueCommit: NonNullable<ComponentProps<typeof NumberInput>['onValueCommit']> = (
|
|
92
|
+
details,
|
|
93
|
+
) => {
|
|
94
|
+
setInputValue(details.value);
|
|
95
|
+
|
|
96
|
+
if (!Number.isFinite(details.valueAsNumber)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
field().handleChange(details.valueAsNumber);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const onBlur = (): void => {
|
|
104
|
+
setInputValue(toNumberInputValue(field().state.value));
|
|
105
|
+
field().handleBlur();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
inputValue,
|
|
110
|
+
onValueChange,
|
|
111
|
+
onValueCommit,
|
|
112
|
+
onBlur,
|
|
113
|
+
};
|
|
17
114
|
};
|
|
18
115
|
|
|
116
|
+
const renderNumberInputField = (props: RenderNumberInputFieldProps): JSX.Element => (
|
|
117
|
+
<Field
|
|
118
|
+
invalid={props.field().state.meta.errors.length > 0}
|
|
119
|
+
required={props.local.required ?? false}
|
|
120
|
+
disabled={props.local.disabled ?? false}
|
|
121
|
+
readOnly={props.local.readOnly ?? false}
|
|
122
|
+
>
|
|
123
|
+
<FieldLabel>{props.local.label}</FieldLabel>
|
|
124
|
+
<FieldContent>
|
|
125
|
+
<NumberInput
|
|
126
|
+
value={props.inputValue()}
|
|
127
|
+
onValueChange={props.onValueChange}
|
|
128
|
+
onValueCommit={props.onValueCommit}
|
|
129
|
+
onBlur={props.onBlur}
|
|
130
|
+
invalid={props.field().state.meta.errors.length > 0}
|
|
131
|
+
disabled={props.local.disabled ?? false}
|
|
132
|
+
readOnly={props.local.readOnly ?? false}
|
|
133
|
+
required={props.local.required ?? false}
|
|
134
|
+
{...props.rootProps}
|
|
135
|
+
>
|
|
136
|
+
<NumberInputControl>
|
|
137
|
+
<NumberInputInput {...props.inputProps} />
|
|
138
|
+
<Show when={props.local.showTriggers !== false}>
|
|
139
|
+
<NumberInputTriggers />
|
|
140
|
+
</Show>
|
|
141
|
+
</NumberInputControl>
|
|
142
|
+
</NumberInput>
|
|
143
|
+
<FieldError errors={props.field().state.meta.errors} />
|
|
144
|
+
<FieldDescription>{props.local.description}</FieldDescription>
|
|
145
|
+
</FieldContent>
|
|
146
|
+
</Field>
|
|
147
|
+
);
|
|
148
|
+
|
|
19
149
|
export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
|
|
20
150
|
const field = useFieldContext<number>();
|
|
21
151
|
const [local, others] = splitProps(props, [
|
|
@@ -26,39 +156,17 @@ export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
|
|
|
26
156
|
'readOnly',
|
|
27
157
|
'showTriggers',
|
|
28
158
|
]);
|
|
159
|
+
const [rootProps, inputProps] = splitProps(others, NUMBER_INPUT_ROOT_PROPS);
|
|
160
|
+
const state = createNumberInputFieldState(field);
|
|
29
161
|
|
|
30
|
-
return (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value={String(field().state.value)}
|
|
41
|
-
onValueChange={(details) => {
|
|
42
|
-
field().handleChange(details.valueAsNumber);
|
|
43
|
-
}}
|
|
44
|
-
onBlur={() => {
|
|
45
|
-
field().handleBlur();
|
|
46
|
-
}}
|
|
47
|
-
invalid={field().state.meta.errors.length > 0}
|
|
48
|
-
disabled={local.disabled ?? false}
|
|
49
|
-
readOnly={local.readOnly ?? false}
|
|
50
|
-
required={local.required ?? false}
|
|
51
|
-
>
|
|
52
|
-
<NumberInputControl>
|
|
53
|
-
<NumberInputInput {...others} />
|
|
54
|
-
<Show when={local.showTriggers !== false}>
|
|
55
|
-
<NumberInputTriggers />
|
|
56
|
-
</Show>
|
|
57
|
-
</NumberInputControl>
|
|
58
|
-
</NumberInput>
|
|
59
|
-
<FieldError errors={field().state.meta.errors} />
|
|
60
|
-
<FieldDescription>{local.description}</FieldDescription>
|
|
61
|
-
</FieldContent>
|
|
62
|
-
</Field>
|
|
63
|
-
);
|
|
162
|
+
return renderNumberInputField({
|
|
163
|
+
field,
|
|
164
|
+
local,
|
|
165
|
+
rootProps,
|
|
166
|
+
inputProps,
|
|
167
|
+
inputValue: state.inputValue,
|
|
168
|
+
onValueChange: state.onValueChange,
|
|
169
|
+
onValueCommit: state.onValueCommit,
|
|
170
|
+
onBlur: state.onBlur,
|
|
171
|
+
});
|
|
64
172
|
};
|
|
@@ -10,7 +10,7 @@ export type SubmitButtonProps = ComponentProps<typeof Button> & {
|
|
|
10
10
|
|
|
11
11
|
export const SubmitButton: Component<SubmitButtonProps> = (props) => {
|
|
12
12
|
const form = useFormContext();
|
|
13
|
-
const [local, others] = splitProps(props, ['children', 'loading', 'disabled']);
|
|
13
|
+
const [local, others] = splitProps(props, ['children', 'loading', 'disabled', 'class']);
|
|
14
14
|
|
|
15
15
|
const isLoading = (): boolean =>
|
|
16
16
|
form.state.isSubmitting || form.state.isValidating || (local.loading ?? false);
|
|
@@ -20,6 +20,7 @@ export const SubmitButton: Component<SubmitButtonProps> = (props) => {
|
|
|
20
20
|
type='submit'
|
|
21
21
|
loading={isLoading()}
|
|
22
22
|
disabled={local.disabled ?? !form.state.canSubmit}
|
|
23
|
+
class={`min-w-24 ${local.class ?? ''}`}
|
|
23
24
|
{...others}
|
|
24
25
|
>
|
|
25
26
|
{local.children}
|
|
@@ -17,14 +17,35 @@ import {
|
|
|
17
17
|
|
|
18
18
|
import { useFieldContext } from './context';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const TAGS_INPUT_ROOT_PROPS = [
|
|
21
|
+
'max',
|
|
22
|
+
'maxLength',
|
|
23
|
+
'delimiter',
|
|
24
|
+
'addOnPaste',
|
|
25
|
+
'blurBehavior',
|
|
26
|
+
'validate',
|
|
27
|
+
'autoFocus',
|
|
28
|
+
'editable',
|
|
29
|
+
'allowOverflow',
|
|
30
|
+
'translations',
|
|
31
|
+
'ids',
|
|
32
|
+
'onFocusOutside',
|
|
33
|
+
'onHighlightChange',
|
|
34
|
+
'onInputValueChange',
|
|
35
|
+
'onInteractOutside',
|
|
36
|
+
'onPointerDownOutside',
|
|
37
|
+
'onValueInvalid',
|
|
38
|
+
] as const;
|
|
39
|
+
|
|
40
|
+
export type TagsInputFieldProps = ComponentProps<typeof TagsInputInput> &
|
|
41
|
+
Pick<ComponentProps<typeof TagsInput>, (typeof TAGS_INPUT_ROOT_PROPS)[number]> & {
|
|
42
|
+
label?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
showClearTrigger?: boolean;
|
|
45
|
+
};
|
|
25
46
|
|
|
26
47
|
const TagsInputGroup: Component<
|
|
27
|
-
|
|
48
|
+
{ showClearTrigger?: boolean } & ComponentProps<typeof TagsInputInput>
|
|
28
49
|
> = (props) => {
|
|
29
50
|
const [local, others] = splitProps(props, ['children', 'showClearTrigger']);
|
|
30
51
|
|
|
@@ -69,6 +90,7 @@ const TAGS_INPUT_FIELD_PROPS = [
|
|
|
69
90
|
export const TagsInputField: Component<TagsInputFieldProps> = (props) => {
|
|
70
91
|
const field = useFieldContext<string[]>();
|
|
71
92
|
const [local, others] = splitProps(props, TAGS_INPUT_FIELD_PROPS);
|
|
93
|
+
const [rootProps, inputProps] = splitProps(others, TAGS_INPUT_ROOT_PROPS);
|
|
72
94
|
|
|
73
95
|
return (
|
|
74
96
|
<Field
|
|
@@ -90,9 +112,10 @@ export const TagsInputField: Component<TagsInputFieldProps> = (props) => {
|
|
|
90
112
|
invalid={field().state.meta.errors.length > 0}
|
|
91
113
|
disabled={local.disabled ?? false}
|
|
92
114
|
readOnly={local.readOnly ?? false}
|
|
115
|
+
{...rootProps}
|
|
93
116
|
>
|
|
94
117
|
<TagsInputGroup
|
|
95
|
-
{...
|
|
118
|
+
{...inputProps}
|
|
96
119
|
{...(typeof local.showClearTrigger === 'boolean' && {
|
|
97
120
|
showClearTrigger: local.showClearTrigger,
|
|
98
121
|
})}
|