@jakubmazanec/ui 0.1.0-unstable.badffa0 → 0.1.0-unstable.bbcd3f9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/build/components/Button.d.ts +3 -2
- package/build/components/Button.js +5 -1
- package/build/components/Button.js.map +2 -2
- package/build/components/Combobox.d.ts +6 -2
- package/build/components/Combobox.js +43 -3
- package/build/components/Combobox.js.map +2 -2
- package/build/components/Dialog.d.ts +1 -1
- package/build/components/Dialog.js +1 -1
- package/build/components/Dialog.js.map +2 -2
- package/build/components/Fieldset.d.ts +16 -0
- package/build/components/Fieldset.js +14 -0
- package/build/components/Fieldset.js.map +7 -0
- package/build/components/Icon.js +7 -6
- package/build/components/Icon.js.map +2 -2
- package/build/components/Input.js +2 -1
- package/build/components/Input.js.map +2 -2
- package/build/components/Legend.d.ts +10 -0
- package/build/components/Legend.js +10 -0
- package/build/components/Legend.js.map +7 -0
- package/build/components/Listbox.d.ts +9 -1
- package/build/components/Listbox.js +115 -117
- package/build/components/Listbox.js.map +3 -3
- package/build/components/Spinner.d.ts +2 -2
- package/build/components/Spinner.js +2 -8
- package/build/components/Spinner.js.map +2 -2
- package/build/components/Table.d.ts +3 -8
- package/build/components/Table.js +2 -13
- package/build/components/Table.js.map +2 -2
- package/build/components/TableCell.js +1 -1
- package/build/components/TableCell.js.map +2 -2
- package/build/components/TableHeader.js +3 -2
- package/build/components/TableHeader.js.map +2 -2
- package/build/components/TableHeaderCell.js +1 -1
- package/build/components/TableHeaderCell.js.map +2 -2
- package/build/components/TableRow.js +1 -1
- package/build/components/TableRow.js.map +2 -2
- package/build/components/Textarea.d.ts +2 -2
- package/build/components/Textarea.js +6 -5
- package/build/components/Textarea.js.map +2 -2
- package/build/components.d.ts +2 -0
- package/build/components.js +2 -0
- package/build/components.js.map +2 -2
- package/build/development/createTailwindConfig.js +12 -0
- package/build/development/createTailwindConfig.js.map +2 -2
- package/build/styles.css +5 -0
- package/build/styles.css.map +2 -2
- package/build/theme/Theme.d.ts +3 -1
- package/build/theme/defaultTheme.js +45 -27
- package/build/theme/defaultTheme.js.map +2 -2
- package/build/theme/internals/themeContext.d.ts +23 -11
- package/build/theme/internals/useTheme.d.ts +23 -11
- package/package.json +1 -2
- package/source/components/Button.tsx +9 -4
- package/source/components/Combobox.tsx +71 -6
- package/source/components/Dialog.tsx +2 -2
- package/source/components/Fieldset.tsx +26 -0
- package/source/components/Icon.tsx +19 -6
- package/source/components/Input.tsx +3 -1
- package/source/components/Legend.tsx +18 -0
- package/source/components/Listbox.tsx +197 -204
- package/source/components/Spinner.tsx +2 -10
- package/source/components/Table.tsx +3 -16
- package/source/components/TableCell.tsx +1 -1
- package/source/components/TableHeader.tsx +2 -4
- package/source/components/TableHeaderCell.tsx +1 -1
- package/source/components/TableRow.tsx +1 -1
- package/source/components/Textarea.tsx +7 -5
- package/source/components.ts +2 -0
- package/source/development/createTailwindConfig.ts +12 -0
- package/source/styles.css +6 -0
- package/source/theme/Theme.ts +4 -0
- package/source/theme/defaultTheme.ts +44 -23
package/README.md
CHANGED
|
@@ -24,12 +24,17 @@ It cannot be required from a CommonJS module.
|
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
⚠️ This is an incomplete package! Expect a lot of breaking changes before the version 1.0.0 release.
|
|
28
|
+
|
|
29
|
+
Opinionated, pre-styled, but customizable component library based on React, Headless UI, Tailwind
|
|
30
|
+
CSS and Conform, made for very fast UI creation.
|
|
28
31
|
|
|
29
32
|
## Documentation
|
|
30
33
|
|
|
31
34
|
See [API reference](./docs) for auto-generated documentation.
|
|
32
35
|
|
|
36
|
+
See [Storybook](https://www.chromatic.com/library?appId=666f2dc8033dde8c47f6a278) for preview.
|
|
37
|
+
|
|
33
38
|
## Contributing
|
|
34
39
|
|
|
35
40
|
If you want to contribute, see [CONTRIBUTING](./CONTRIBUTING.md) for details.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ButtonProps as HeadlessButtonProps } from '@headlessui/react';
|
|
1
2
|
import { type ComponentPropsWithoutRef, type ElementType, type Ref } from 'react';
|
|
2
3
|
import { type ComponentProps } from '../theme/internals.js';
|
|
3
4
|
export declare const useButtonTheme: ((themeProps: {
|
|
@@ -19,6 +20,7 @@ export type ButtonProps<T extends ElementType> = ComponentProps<typeof useButton
|
|
|
19
20
|
submit?: boolean | undefined;
|
|
20
21
|
autoFocus?: boolean | undefined;
|
|
21
22
|
className?: string | undefined;
|
|
23
|
+
children?: HeadlessButtonProps['children'] | undefined;
|
|
22
24
|
};
|
|
23
25
|
export declare const Button: <T extends ElementType = "button">(props: Partial<import("@jakubmazanec/ts-utils").Writable<{
|
|
24
26
|
readonly variant: "text" | "solid" | "outline";
|
|
@@ -29,8 +31,7 @@ export declare const Button: <T extends ElementType = "button">(props: Partial<i
|
|
|
29
31
|
submit?: boolean | undefined;
|
|
30
32
|
autoFocus?: boolean | undefined;
|
|
31
33
|
className?: string | undefined;
|
|
32
|
-
|
|
33
|
-
children?: import("react").ReactNode;
|
|
34
|
+
children?: HeadlessButtonProps['children'] | undefined;
|
|
34
35
|
} & {
|
|
35
36
|
ref?: Ref<HTMLElement> | undefined;
|
|
36
37
|
}) => import("react").ReactNode;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { createComponentTheme } from "../theme/internals.js";
|
|
10
10
|
import { Icon } from "./Icon.js";
|
|
11
11
|
import { forwardRef } from "./internals.js";
|
|
12
|
+
import { Spinner } from "./Spinner.js";
|
|
12
13
|
export const useButtonTheme = createComponentTheme("Button", {
|
|
13
14
|
variants: {
|
|
14
15
|
variant: ["solid", "outline", "text"],
|
|
@@ -42,8 +43,11 @@ export const Button = forwardRef(
|
|
|
42
43
|
if (submit) {
|
|
43
44
|
props.type = "submit";
|
|
44
45
|
}
|
|
46
|
+
if (typeof children === "function") {
|
|
47
|
+
return /* @__PURE__ */ jsx(HeadlessButton, { ...props, children });
|
|
48
|
+
}
|
|
45
49
|
let enhancedChildren = Children.map(children, (child) => {
|
|
46
|
-
if (isValidElement(child) && child.type === Icon) {
|
|
50
|
+
if (isValidElement(child) && (child.type === Icon || child.type === Spinner)) {
|
|
47
51
|
return cloneElement(child, { "data-icon": "" });
|
|
48
52
|
}
|
|
49
53
|
return child;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import {Button as HeadlessButton} from '@headlessui/react';\nimport {\n Children,\n cloneElement,\n type ComponentPropsWithoutRef,\n type ElementType,\n isValidElement,\n type
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import {Button as HeadlessButton, type ButtonProps as HeadlessButtonProps} from '@headlessui/react';\nimport {\n Children,\n cloneElement,\n type ComponentPropsWithoutRef,\n type ElementType,\n isValidElement,\n type Ref,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {Icon} from './Icon.js';\nimport {forwardRef} from './internals.js';\nimport {Spinner} from './Spinner.js';\n\nexport const useButtonTheme = createComponentTheme('Button', {\n variants: {\n variant: ['solid', 'outline', 'text'],\n size: ['small', 'medium', 'large'],\n disabled: [true, false],\n },\n});\n\nconst BUTTON_ELEMENT = 'button';\n\nexport type ButtonProps<T extends ElementType> = ComponentProps<typeof useButtonTheme> &\n ComponentPropsWithoutRef<T> & {\n as?: T | undefined;\n submit?: boolean | undefined;\n autoFocus?: boolean | undefined;\n className?: string | undefined;\n children?: HeadlessButtonProps['children'] | undefined; // sadly, we cannot use `T`'s children type, because Headless UI always, if `children` is function, calls it with its own render props documented here: https://headlessui.com/react/button#using-render-props\n };\n\nexport const Button = forwardRef(\n <T extends ElementType = typeof BUTTON_ELEMENT>(\n {\n variant = 'solid',\n size = 'medium',\n disabled = false,\n as = BUTTON_ELEMENT as T,\n submit = false,\n className,\n children,\n ...rest\n }: ButtonProps<T>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useButtonTheme({variant, size, disabled});\n\n let props: Record<string, unknown> = {\n as,\n ref,\n className: theme(null, className),\n disabled,\n ...rest,\n };\n\n if (as === BUTTON_ELEMENT) {\n props.type = 'button';\n }\n\n if (submit) {\n props.type = 'submit';\n }\n\n if (typeof children === 'function') {\n return <HeadlessButton {...props}>{children}</HeadlessButton>;\n }\n\n let enhancedChildren = Children.map(children, (child) => {\n if (isValidElement(child) && (child.type === Icon || child.type === Spinner)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n return cloneElement<any>(child, {'data-icon': ''});\n }\n\n return child;\n });\n\n return <HeadlessButton {...props}>{enhancedChildren}</HeadlessButton>;\n },\n);\n"],
|
|
5
|
+
"mappings": ";AAmEa;AAnEb,SAAQ,UAAU,sBAA8D;AAChF;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,OAEK;AAEP,SAA6B,4BAA2B;AACxD,SAAQ,YAAW;AACnB,SAAQ,kBAAiB;AACzB,SAAQ,eAAc;AAEf,aAAM,iBAAiB,qBAAqB,UAAU;AAAA,EAC3D,UAAU;AAAA,IACR,SAAS,CAAC,SAAS,WAAW,MAAM;AAAA,IACpC,MAAM,CAAC,SAAS,UAAU,OAAO;AAAA,IACjC,UAAU,CAAC,MAAM,KAAK;AAAA,EACxB;AACF,CAAC;AAED,MAAM,iBAAiB;AAWhB,aAAM,SAAS;AAAA,EACpB,CACE;AAAA,IACE,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,QAAQ,eAAe,EAAC,SAAS,MAAM,SAAQ,CAAC;AAEpD,QAAI,QAAiC;AAAA,MACnC;AAAA,MACA;AAAA,MACA,WAAW,MAAM,MAAM,SAAS;AAAA,MAChC;AAAA,MACA,GAAG;AAAA,IACL;AAEA,QAAI,OAAO,gBAAgB;AACzB,YAAM,OAAO;AAAA,IACf;AAEA,QAAI,QAAQ;AACV,YAAM,OAAO;AAAA,IACf;AAEA,QAAI,OAAO,aAAa,YAAY;AAClC,aAAO,oBAAC,kBAAgB,GAAG,OAAQ,UAAS;AAAA,IAC9C;AAEA,QAAI,mBAAmB,SAAS,IAAI,UAAU,CAAC,UAAU;AACvD,UAAI,eAAe,KAAK,MAAM,MAAM,SAAS,QAAQ,MAAM,SAAS,UAAU;AAE5E,eAAO,aAAkB,OAAO,EAAC,aAAa,GAAE,CAAC;AAAA,MACnD;AAEA,aAAO;AAAA,IACT,CAAC;AAED,WAAO,oBAAC,kBAAgB,GAAG,OAAQ,4BAAiB;AAAA,EACtD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,9 +30,11 @@ export type ComboboxProps<T extends ElementType, V extends boolean | number | st
|
|
|
30
30
|
items?: Array<ComboboxItem<V>> | undefined;
|
|
31
31
|
placeholder?: string;
|
|
32
32
|
immediate?: boolean | undefined;
|
|
33
|
+
virtual?: boolean | undefined;
|
|
34
|
+
customValue?: boolean | undefined;
|
|
33
35
|
name?: string | undefined;
|
|
34
36
|
className?: string;
|
|
35
|
-
onChange?: (selectedValue: V) => void;
|
|
37
|
+
onChange?: (selectedValue: V | undefined) => void;
|
|
36
38
|
} | {
|
|
37
39
|
as?: T | undefined;
|
|
38
40
|
value?: V[] | undefined;
|
|
@@ -41,9 +43,11 @@ export type ComboboxProps<T extends ElementType, V extends boolean | number | st
|
|
|
41
43
|
items?: Array<ComboboxItem<V>> | undefined;
|
|
42
44
|
placeholder?: string;
|
|
43
45
|
immediate?: boolean | undefined;
|
|
46
|
+
virtual?: boolean | undefined;
|
|
47
|
+
customValue?: boolean | undefined;
|
|
44
48
|
name?: string | undefined;
|
|
45
49
|
className?: string;
|
|
46
|
-
onChange?: (selectedValue: V[]) => void;
|
|
50
|
+
onChange?: (selectedValue: V[] | undefined) => void;
|
|
47
51
|
})>;
|
|
48
52
|
export declare const Combobox: <T extends ElementType = import("react").ExoticComponent<{
|
|
49
53
|
children?: import("react").ReactNode;
|
|
@@ -35,6 +35,8 @@ export const Combobox = forwardRef(
|
|
|
35
35
|
items,
|
|
36
36
|
placeholder,
|
|
37
37
|
immediate = true,
|
|
38
|
+
virtual = false,
|
|
39
|
+
customValue = false,
|
|
38
40
|
name,
|
|
39
41
|
className,
|
|
40
42
|
onChange,
|
|
@@ -51,9 +53,33 @@ export const Combobox = forwardRef(
|
|
|
51
53
|
if (selectedValue) {
|
|
52
54
|
onChange?.(selectedValue.value);
|
|
53
55
|
}
|
|
56
|
+
if (selectedValue === null) {
|
|
57
|
+
onChange?.(void 0);
|
|
58
|
+
}
|
|
54
59
|
},
|
|
55
60
|
[onChange]
|
|
56
61
|
);
|
|
62
|
+
let displayValue = useCallback(
|
|
63
|
+
(option) => {
|
|
64
|
+
if (items) {
|
|
65
|
+
let selectedItem = items.find((item) => item.value === option);
|
|
66
|
+
if (selectedItem) {
|
|
67
|
+
return selectedItem.label;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return option;
|
|
71
|
+
},
|
|
72
|
+
[items]
|
|
73
|
+
);
|
|
74
|
+
let handleQueryChange = useCallback((event) => {
|
|
75
|
+
setQuery(event.target.value);
|
|
76
|
+
}, []);
|
|
77
|
+
if (virtual && !items) {
|
|
78
|
+
throw new Error("Combobox requires `items` prop in virtual scrolling mode!");
|
|
79
|
+
}
|
|
80
|
+
if (virtual && customValue) {
|
|
81
|
+
throw new Error("Combobox doesn't support `customValue` prop in virtual scrolling mode!");
|
|
82
|
+
}
|
|
57
83
|
if (items && children) {
|
|
58
84
|
throw new Error("Combobox accepts only either `items` prop, or children!");
|
|
59
85
|
}
|
|
@@ -70,6 +96,7 @@ export const Combobox = forwardRef(
|
|
|
70
96
|
as,
|
|
71
97
|
ref,
|
|
72
98
|
name: field?.name ?? fieldName ?? name,
|
|
99
|
+
value,
|
|
73
100
|
defaultValue,
|
|
74
101
|
multiple,
|
|
75
102
|
disabled,
|
|
@@ -79,6 +106,11 @@ export const Combobox = forwardRef(
|
|
|
79
106
|
onChange: handleChange,
|
|
80
107
|
...rest
|
|
81
108
|
};
|
|
109
|
+
if (virtual) {
|
|
110
|
+
props.virtual = {
|
|
111
|
+
options: filteredItems?.map((item) => item.value) ?? []
|
|
112
|
+
};
|
|
113
|
+
}
|
|
82
114
|
return /* @__PURE__ */ jsxs(HeadlessCombobox, { ...props, children: [
|
|
83
115
|
/* @__PURE__ */ jsxs("div", { className: theme.root(null, className), children: [
|
|
84
116
|
/* @__PURE__ */ jsx(
|
|
@@ -86,13 +118,21 @@ export const Combobox = forwardRef(
|
|
|
86
118
|
{
|
|
87
119
|
className: theme.input(null, className),
|
|
88
120
|
size: 1,
|
|
89
|
-
|
|
121
|
+
displayValue,
|
|
122
|
+
onChange: handleQueryChange
|
|
90
123
|
}
|
|
91
124
|
),
|
|
92
125
|
/* @__PURE__ */ jsx(HeadlessComboboxButton, { className: theme.icon(), children: /* @__PURE__ */ jsx(Icon, { size: "small", children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) }) })
|
|
93
126
|
] }),
|
|
94
|
-
filteredItems
|
|
95
|
-
|
|
127
|
+
virtual && filteredItems ? /* @__PURE__ */ jsx(HeadlessComboboxOptions, { className: theme.options(), anchor: "bottom start", children: ({ option }) => /* @__PURE__ */ jsx(ComboboxOption, { value: option, children: items?.find((item) => item.value === option)?.label }) }) : null,
|
|
128
|
+
!virtual && filteredItems ? /* @__PURE__ */ jsxs(HeadlessComboboxOptions, { className: theme.options(), anchor: "bottom start", children: [
|
|
129
|
+
customValue && query.length ? /* @__PURE__ */ jsx(ComboboxOption, { value: query, children: query }, query) : null,
|
|
130
|
+
filteredItems.map((item) => /* @__PURE__ */ jsx(ComboboxOption, { value: item.value, children: item.label }, String(item.value)))
|
|
131
|
+
] }) : null,
|
|
132
|
+
!filteredItems && Array.isArray(filteredChildren) ? /* @__PURE__ */ jsxs(HeadlessComboboxOptions, { className: theme.options(), anchor: "bottom start", children: [
|
|
133
|
+
customValue && query.length ? /* @__PURE__ */ jsx(ComboboxOption, { value: query, children: query }) : null,
|
|
134
|
+
filteredChildren
|
|
135
|
+
] }) : null
|
|
96
136
|
] });
|
|
97
137
|
}
|
|
98
138
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/Combobox.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["// TODO: fix somehow\n/* eslint-disable complexity -- TODO */\nimport {\n Combobox as HeadlessCombobox,\n ComboboxButton as HeadlessComboboxButton,\n ComboboxInput as HeadlessComboboxInput,\n ComboboxOptions as HeadlessComboboxOptions,\n type ComboboxProps as HeadlessComboboxProps,\n} from '@headlessui/react';\nimport {ChevronDownIcon} from '@heroicons/react/24/outline';\nimport {\n type ChangeEvent,\n Children,\n type ComponentPropsWithoutRef,\n type ElementType,\n Fragment,\n type PropsWithChildren,\n type Ref,\n useCallback,\n useState,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {ComboboxOption} from './ComboboxOption.js';\nimport {Icon} from './Icon.js';\nimport {forwardRef, useFormId} from './internals.js';\nimport {useField} from './useField.js';\nimport {useFieldName} from './useFieldName.js';\n\nexport const useComboboxTheme = createComponentTheme('Combobox', {\n variants: {disabled: [true, false], invalid: [true, false]},\n elements: ['root', 'input', 'icon', 'options'],\n});\n\nconst COMBOBOX_ELEMENT = Fragment;\n\nexport type ComboboxItem<V> = {\n value: V;\n label: string;\n};\n\nexport type ComboboxProps<\n T extends ElementType,\n V extends boolean | number | string,\n> = PropsWithChildren<\n ComponentProps<typeof useComboboxTheme> &\n ComponentPropsWithoutRef<T> &\n (\n | {\n as?: T | undefined;\n value?: V | undefined;\n defaultValue?: V | undefined;\n multiple?: false | undefined;\n items?: Array<ComboboxItem<V>> | undefined;\n placeholder?: string;\n immediate?: boolean | undefined;\n virtual?: boolean | undefined;\n customValue?: boolean | undefined;\n name?: string | undefined;\n className?: string;\n onChange?: (selectedValue: V | undefined) => void;\n }\n | {\n as?: T | undefined;\n value?: V[] | undefined;\n defaultValue?: V[] | undefined;\n multiple: true;\n items?: Array<ComboboxItem<V>> | undefined;\n placeholder?: string;\n immediate?: boolean | undefined;\n virtual?: boolean | undefined;\n customValue?: boolean | undefined;\n name?: string | undefined;\n className?: string;\n onChange?: (selectedValue: V[] | undefined) => void;\n }\n )\n>;\n\nexport const Combobox = forwardRef(\n <T extends ElementType = typeof COMBOBOX_ELEMENT, V extends boolean | number | string = string>(\n {\n disabled = false,\n invalid = false,\n as = COMBOBOX_ELEMENT as unknown as T,\n value,\n defaultValue,\n multiple,\n items,\n placeholder,\n immediate = true,\n virtual = false,\n customValue = false,\n name,\n className,\n onChange,\n children,\n ...rest\n }: ComboboxProps<T, V>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useComboboxTheme({disabled, invalid});\n let formId = useFormId();\n let field = useField();\n let fieldName = useFieldName();\n let [query, setQuery] = useState('');\n\n let handleChange = useCallback(\n (selectedValue: ComboboxItem<V> | null) => {\n if (selectedValue) {\n onChange?.(selectedValue.value as V & V[]);\n }\n\n if (selectedValue === null) {\n onChange?.(undefined);\n }\n },\n [onChange],\n );\n\n let displayValue = useCallback(\n (option: string) => {\n if (items) {\n let selectedItem = items.find((item) => item.value === option);\n\n if (selectedItem) {\n return selectedItem.label;\n }\n }\n\n return option;\n },\n [items],\n );\n\n let handleQueryChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {\n setQuery(event.target.value);\n }, []);\n\n if (virtual && !items) {\n throw new Error('Combobox requires `items` prop in virtual scrolling mode!');\n }\n\n if (virtual && customValue) {\n throw new Error(\"Combobox doesn't support `customValue` prop in virtual scrolling mode!\");\n }\n\n if (items && children) {\n throw new Error('Combobox accepts only either `items` prop, or children!');\n }\n\n let filteredItems =\n query ?\n items?.filter((item) =>\n item.label\n .toLowerCase()\n .replace(/\\s+/g, '')\n .includes(query.toLowerCase().replace(/\\s+/g, '')),\n )\n : items;\n let filteredChildren =\n query ?\n Children.toArray(children).filter((child) => {\n if (\n typeof child === 'object' &&\n 'props' in child &&\n typeof child.props === 'object' &&\n typeof (child.props as {children?: unknown[] | string}).children === 'string' &&\n (child.props as {children: string}).children\n .toLowerCase()\n .replace(/\\s+/g, '')\n .includes(query.toLowerCase().replace(/\\s+/g, ''))\n ) {\n return true;\n }\n\n return false;\n })\n : children;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n let props: HeadlessComboboxProps<any, any, any> = {\n as,\n ref,\n name: field?.name ?? fieldName ?? name,\n value,\n defaultValue,\n multiple,\n disabled,\n // invalid,\n immediate,\n form: formId,\n onChange: handleChange,\n ...rest,\n };\n\n if (virtual) {\n props.virtual = {\n options: filteredItems?.map((item) => item.value) ?? [],\n };\n }\n\n return (\n <HeadlessCombobox {...props}>\n <div className={theme.root(null, className)}>\n <HeadlessComboboxInput\n className={theme.input(null, className)}\n size={1} // so the input default width without styling is small\n displayValue={displayValue}\n onChange={handleQueryChange}\n />\n <HeadlessComboboxButton className={theme.icon()}>\n <Icon size=\"small\">\n <ChevronDownIcon />\n </Icon>\n </HeadlessComboboxButton>\n </div>\n\n {virtual && filteredItems ?\n <HeadlessComboboxOptions className={theme.options()} anchor=\"bottom start\">\n {({option}: {option: V}) => (\n <ComboboxOption value={option}>\n {items?.find((item) => item.value === option)?.label}\n </ComboboxOption>\n )}\n </HeadlessComboboxOptions>\n : null}\n\n {!virtual && filteredItems ?\n <HeadlessComboboxOptions className={theme.options()} anchor=\"bottom start\">\n {customValue && query.length ?\n <ComboboxOption key={query} value={query}>\n {query}\n </ComboboxOption>\n : null}\n {filteredItems.map((item) => (\n <ComboboxOption key={String(item.value)} value={item.value}>\n {item.label}\n </ComboboxOption>\n ))}\n </HeadlessComboboxOptions>\n : null}\n\n {!filteredItems && Array.isArray(filteredChildren) ?\n <HeadlessComboboxOptions className={theme.options()} anchor=\"bottom start\">\n {customValue && query.length ?\n <ComboboxOption value={query}>{query}</ComboboxOption>\n : null}\n {filteredChildren}\n </HeadlessComboboxOptions>\n : null}\n </HeadlessCombobox>\n );\n },\n);\n"],
|
|
5
|
+
"mappings": ";AA2MQ,SACE,KADF;AAzMR;AAAA,EACE,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,OAEd;AACP,SAAQ,uBAAsB;AAC9B;AAAA,EAEE;AAAA,EAGA;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AAEP,SAA6B,4BAA2B;AACxD,SAAQ,sBAAqB;AAC7B,SAAQ,YAAW;AACnB,SAAQ,YAAY,iBAAgB;AACpC,SAAQ,gBAAe;AACvB,SAAQ,oBAAmB;AAEpB,aAAM,mBAAmB,qBAAqB,YAAY;AAAA,EAC/D,UAAU,EAAC,UAAU,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,KAAK,EAAC;AAAA,EAC1D,UAAU,CAAC,QAAQ,SAAS,QAAQ,SAAS;AAC/C,CAAC;AAED,MAAM,mBAAmB;AA6ClB,aAAM,WAAW;AAAA,EACtB,CACE;AAAA,IACE,WAAW;AAAA,IACX,UAAU;AAAA,IACV,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,QAAQ,iBAAiB,EAAC,UAAU,QAAO,CAAC;AAChD,QAAI,SAAS,UAAU;AACvB,QAAI,QAAQ,SAAS;AACrB,QAAI,YAAY,aAAa;AAC7B,QAAI,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AAEnC,QAAI,eAAe;AAAA,MACjB,CAAC,kB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,gBACzD;AAAA,uBAAe,MAAM,SACpB,oBAAC,kBAAe,OAAO,OAAQ,iBAAM,IACrC;AAAA,QACD;AAAA,SACH,IACA;AAAA,OACJ;AAAA,EAEJ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export declare const useDialogTheme: (() => {
|
|
|
12
12
|
export type DialogProps = PropsWithChildren<ComponentProps<typeof useDialogTheme> & {
|
|
13
13
|
open: boolean;
|
|
14
14
|
className?: string;
|
|
15
|
-
onClose
|
|
15
|
+
onClose?: () => void;
|
|
16
16
|
enableBackdropClick?: boolean;
|
|
17
17
|
}>;
|
|
18
18
|
export declare function Dialog({ open, className, onClose, children, enableBackdropClick }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,7 +10,7 @@ export function Dialog({ open, className, onClose, children, enableBackdropClick
|
|
|
10
10
|
let theme = useDialogTheme();
|
|
11
11
|
let handleBackdropClick = useCallback(() => {
|
|
12
12
|
if (enableBackdropClick) {
|
|
13
|
-
onClose();
|
|
13
|
+
onClose?.();
|
|
14
14
|
}
|
|
15
15
|
}, [enableBackdropClick, onClose]);
|
|
16
16
|
return /* @__PURE__ */ jsxs(HeadlessDialog, { open, onClose: handleBackdropClick, children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/Dialog.tsx"],
|
|
4
|
-
"sourcesContent": ["import {Dialog as HeadlessDialog} from '@headlessui/react';\nimport {type PropsWithChildren, useCallback} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\n\nexport const useDialogTheme = createComponentTheme('Dialog', {\n elements: ['root', 'backdrop'],\n});\n\nexport type DialogProps = PropsWithChildren<\n ComponentProps<typeof useDialogTheme> & {\n open: boolean;\n className?: string;\n onClose
|
|
5
|
-
"mappings": ";AA4BI,SACE,KADF;AA5BJ,SAAQ,UAAU,sBAAqB;AACvC,SAAgC,mBAAkB;AAElD,SAA6B,4BAA2B;AAEjD,aAAM,iBAAiB,qBAAqB,UAAU;AAAA,EAC3D,UAAU,CAAC,QAAQ,UAAU;AAC/B,CAAC;AAWM,gBAAS,OAAO,EAAC,MAAM,WAAW,SAAS,UAAU,oBAAmB,GAAgB;AAC7F,MAAI,QAAQ,eAAe;AAE3B,MAAI,sBAAsB,YAAY,MAAM;AAC1C,QAAI,qBAAqB;AACvB,
|
|
4
|
+
"sourcesContent": ["import {Dialog as HeadlessDialog} from '@headlessui/react';\nimport {type PropsWithChildren, useCallback} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\n\nexport const useDialogTheme = createComponentTheme('Dialog', {\n elements: ['root', 'backdrop'],\n});\n\nexport type DialogProps = PropsWithChildren<\n ComponentProps<typeof useDialogTheme> & {\n open: boolean;\n className?: string;\n onClose?: () => void;\n enableBackdropClick?: boolean;\n }\n>;\n\nexport function Dialog({open, className, onClose, children, enableBackdropClick}: DialogProps) {\n let theme = useDialogTheme();\n\n let handleBackdropClick = useCallback(() => {\n if (enableBackdropClick) {\n onClose?.();\n }\n }, [enableBackdropClick, onClose]);\n\n return (\n <HeadlessDialog open={open} onClose={handleBackdropClick}>\n <div className={theme.backdrop('fixed inset-0')} aria-hidden=\"true\" />\n <div className={theme.root('fixed inset-0', className)}>{children}</div>\n </HeadlessDialog>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AA4BI,SACE,KADF;AA5BJ,SAAQ,UAAU,sBAAqB;AACvC,SAAgC,mBAAkB;AAElD,SAA6B,4BAA2B;AAEjD,aAAM,iBAAiB,qBAAqB,UAAU;AAAA,EAC3D,UAAU,CAAC,QAAQ,UAAU;AAC/B,CAAC;AAWM,gBAAS,OAAO,EAAC,MAAM,WAAW,SAAS,UAAU,oBAAmB,GAAgB;AAC7F,MAAI,QAAQ,eAAe;AAE3B,MAAI,sBAAsB,YAAY,MAAM;AAC1C,QAAI,qBAAqB;AACvB,gBAAU;AAAA,IACZ;AAAA,EACF,GAAG,CAAC,qBAAqB,OAAO,CAAC;AAEjC,SACE,qBAAC,kBAAe,MAAY,SAAS,qBACnC;AAAA,wBAAC,SAAI,WAAW,MAAM,SAAS,eAAe,GAAG,eAAY,QAAO;AAAA,IACpE,oBAAC,SAAI,WAAW,MAAM,KAAK,iBAAiB,SAAS,GAAI,UAAS;AAAA,KACpE;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type ComponentProps } from '../theme/internals.js';
|
|
3
|
+
export declare const useFieldsetTheme: ((themeProps: {
|
|
4
|
+
readonly disabled: boolean;
|
|
5
|
+
}) => (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string) & {
|
|
6
|
+
componentThemeName: "Fieldset";
|
|
7
|
+
themeDefinition: {
|
|
8
|
+
readonly variants: {
|
|
9
|
+
readonly disabled: [true, false];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type FieldsetProps = PropsWithChildren<ComponentProps<typeof useFieldsetTheme> & {
|
|
14
|
+
className?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function Fieldset({ disabled, className, children }: FieldsetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fieldset as HeadlessFieldset } from "@headlessui/react";
|
|
4
|
+
import { createComponentTheme } from "../theme/internals.js";
|
|
5
|
+
export const useFieldsetTheme = createComponentTheme("Fieldset", {
|
|
6
|
+
variants: {
|
|
7
|
+
disabled: [true, false]
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export function Fieldset({ disabled = false, className, children }) {
|
|
11
|
+
let theme = useFieldsetTheme({ disabled });
|
|
12
|
+
return /* @__PURE__ */ jsx(HeadlessFieldset, { className: theme(null, className), disabled, children });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Fieldset.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../source/components/Fieldset.tsx"],
|
|
4
|
+
"sourcesContent": ["import {Fieldset as HeadlessFieldset} from '@headlessui/react';\nimport {type PropsWithChildren} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\n\nexport const useFieldsetTheme = createComponentTheme('Fieldset', {\n variants: {\n disabled: [true, false],\n },\n});\n\nexport type FieldsetProps = PropsWithChildren<\n ComponentProps<typeof useFieldsetTheme> & {\n className?: string | undefined;\n }\n>;\n\nexport function Fieldset({disabled = false, className, children}: FieldsetProps) {\n let theme = useFieldsetTheme({disabled});\n\n return (\n <HeadlessFieldset className={theme(null, className)} disabled={disabled}>\n {children}\n </HeadlessFieldset>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAqBI;AArBJ,SAAQ,YAAY,wBAAuB;AAG3C,SAA6B,4BAA2B;AAEjD,aAAM,mBAAmB,qBAAqB,YAAY;AAAA,EAC/D,UAAU;AAAA,IACR,UAAU,CAAC,MAAM,KAAK;AAAA,EACxB;AACF,CAAC;AAQM,gBAAS,SAAS,EAAC,WAAW,OAAO,WAAW,SAAQ,GAAkB;AAC/E,MAAI,QAAQ,iBAAiB,EAAC,SAAQ,CAAC;AAEvC,SACE,oBAAC,oBAAiB,WAAW,MAAM,MAAM,SAAS,GAAG,UAClD,UACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/components/Icon.js
CHANGED
|
@@ -30,14 +30,15 @@ export const Icon = forwardRef(
|
|
|
30
30
|
...rest
|
|
31
31
|
};
|
|
32
32
|
let Child;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
let resolvedName = `${name}Icon`;
|
|
34
|
+
if (size === "medium" && resolvedName && icons20[resolvedName]) {
|
|
35
|
+
Child = icons20[resolvedName];
|
|
35
36
|
}
|
|
36
|
-
if (size === "small" &&
|
|
37
|
-
Child = icons16[
|
|
37
|
+
if (size === "small" && resolvedName && icons16[resolvedName]) {
|
|
38
|
+
Child = icons16[resolvedName];
|
|
38
39
|
}
|
|
39
|
-
if (size === "large" &&
|
|
40
|
-
Child = icons24[
|
|
40
|
+
if (size === "large" && resolvedName && icons24[resolvedName]) {
|
|
41
|
+
Child = icons24[resolvedName];
|
|
41
42
|
}
|
|
42
43
|
return createElement(Component, props, Child ? /* @__PURE__ */ jsx(Child, {}) : children);
|
|
43
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/Icon.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as icons16 from '@heroicons/react/16/solid';\nimport * as icons20 from '@heroicons/react/20/solid';\nimport * as icons24 from '@heroicons/react/24/outline';\nimport {\n type ComponentPropsWithoutRef,\n createElement,\n type ElementType,\n type PropsWithChildren,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {forwardRef} from './internals.js';\n\nexport const useIconTheme = createComponentTheme('Icon', {\n variants: {\n size: ['small', 'medium', 'large'],\n },\n});\n\nconst ICON_ELEMENT = 'span';\n\nexport type IconProps<T extends ElementType> = PropsWithChildren<\n ComponentProps<typeof useIconTheme> &\n ComponentPropsWithoutRef<T> & {\n as?: T | undefined;\n name?: string | undefined;\n className?: string | undefined;\n }\n>;\n\nexport const Icon = forwardRef(\n <T extends ElementType = typeof ICON_ELEMENT>(\n {\n size = 'medium',\n as: Component = ICON_ELEMENT as T,\n name,\n className,\n children,\n ...rest\n }: IconProps<T>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useIconTheme({size});\n let props: Record<string, unknown> = {\n ref,\n className: theme(null, className),\n ...rest,\n };\n let Child: ElementType | undefined;\n\n if (size === 'medium'
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import * as icons16 from '@heroicons/react/16/solid';\nimport * as icons20 from '@heroicons/react/20/solid';\nimport * as icons24 from '@heroicons/react/24/outline';\nimport {\n type ComponentPropsWithoutRef,\n createElement,\n type ElementType,\n type PropsWithChildren,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {forwardRef} from './internals.js';\n\nexport const useIconTheme = createComponentTheme('Icon', {\n variants: {\n size: ['small', 'medium', 'large'],\n },\n});\n\nconst ICON_ELEMENT = 'span';\n\nexport type IconProps<T extends ElementType> = PropsWithChildren<\n ComponentProps<typeof useIconTheme> &\n ComponentPropsWithoutRef<T> & {\n as?: T | undefined;\n name?: string | undefined;\n className?: string | undefined;\n }\n>;\n\nexport const Icon = forwardRef(\n <T extends ElementType = typeof ICON_ELEMENT>(\n {\n size = 'medium',\n as: Component = ICON_ELEMENT as T,\n name,\n className,\n children,\n ...rest\n }: IconProps<T>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useIconTheme({size});\n let props: Record<string, unknown> = {\n ref,\n className: theme(null, className),\n ...rest,\n };\n let Child: ElementType | undefined;\n let resolvedName = `${name}Icon`;\n\n if (\n size === 'medium' &&\n resolvedName &&\n (icons20[resolvedName as keyof typeof icons20] as unknown)\n ) {\n Child = icons20[resolvedName as keyof typeof icons20] as ElementType;\n }\n\n if (\n size === 'small' &&\n resolvedName &&\n (icons16[resolvedName as keyof typeof icons16] as unknown)\n ) {\n Child = icons16[resolvedName as keyof typeof icons16] as ElementType;\n }\n\n if (\n size === 'large' &&\n resolvedName &&\n (icons24[resolvedName as keyof typeof icons24] as unknown)\n ) {\n Child = icons24[resolvedName as keyof typeof icons24] as ElementType;\n }\n\n return createElement(Component, props, (Child ? <Child /> : children) as ReactNode);\n },\n);\n"],
|
|
5
|
+
"mappings": ";AA6EoD;AA7EpD,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB;AAAA,EAEE;AAAA,OAKK;AAEP,SAA6B,4BAA2B;AACxD,SAAQ,kBAAiB;AAElB,aAAM,eAAe,qBAAqB,QAAQ;AAAA,EACvD,UAAU;AAAA,IACR,MAAM,CAAC,SAAS,UAAU,OAAO;AAAA,EACnC;AACF,CAAC;AAED,MAAM,eAAe;AAWd,aAAM,OAAO;AAAA,EAClB,CACE;AAAA,IACE,OAAO;AAAA,IACP,IAAI,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,QAAQ,aAAa,EAAC,KAAI,CAAC;AAC/B,QAAI,QAAiC;AAAA,MACnC;AAAA,MACA,WAAW,MAAM,MAAM,SAAS;AAAA,MAChC,GAAG;AAAA,IACL;AACA,QAAI;AACJ,QAAI,eAAe,GAAG,IAAI;AAE1B,QACE,SAAS,YACT,gBACC,QAAQ,YAAoC,GAC7C;AACA,cAAQ,QAAQ,YAAoC;AAAA,IACtD;AAEA,QACE,SAAS,WACT,gBACC,QAAQ,YAAoC,GAC7C;AACA,cAAQ,QAAQ,YAAoC;AAAA,IACtD;AAEA,QACE,SAAS,WACT,gBACC,QAAQ,YAAoC,GAC7C;AACA,cAAQ,QAAQ,YAAoC;AAAA,IACtD;AAEA,WAAO,cAAc,WAAW,OAAQ,QAAQ,oBAAC,SAAM,IAAK,QAAsB;AAAA,EACpF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -71,7 +71,8 @@ export const Input = forwardRef(
|
|
|
71
71
|
rootProps["data-clear-button"] = "";
|
|
72
72
|
}
|
|
73
73
|
if (field) {
|
|
74
|
-
|
|
74
|
+
let { key, ...restProps } = getInputProps(field, { type: "text" });
|
|
75
|
+
inputProps = { ...restProps, ...inputProps };
|
|
75
76
|
}
|
|
76
77
|
return /* @__PURE__ */ jsxs("span", { ...rootProps, children: [
|
|
77
78
|
/* @__PURE__ */ jsx(HeadlessInput, { ...inputProps }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/Input.tsx"],
|
|
4
|
-
"sourcesContent": ["import {getInputProps} from '@conform-to/react';\nimport {Input as HeadlessInput} from '@headlessui/react';\nimport {XMarkIcon} from '@heroicons/react/16/solid';\nimport {\n type ComponentPropsWithoutRef,\n type ComponentType,\n type ElementType,\n type Ref,\n useCallback,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {forwardRef} from './internals.js';\nimport {useField} from './useField.js';\nimport {useFieldName} from './useFieldName.js';\n\nexport const useInputTheme = createComponentTheme('Input', {\n variants: {\n disabled: [true, false],\n },\n elements: ['root', 'input', 'icon', 'clearButton'],\n});\n\nconst INPUT_ELEMENT = 'input';\n\nexport type InputProps<T extends ElementType> = ComponentProps<typeof useInputTheme> &\n ComponentPropsWithoutRef<T> & {\n as?: T | undefined;\n name?: string | undefined;\n className?: string | undefined;\n icon?: ComponentType<object> | undefined;\n showClearButton?: boolean | undefined;\n };\n\nexport const Input = forwardRef(\n <T extends ElementType = typeof INPUT_ELEMENT>(\n {\n disabled = false,\n as = INPUT_ELEMENT as T,\n name,\n className,\n icon: Icon,\n showClearButton = false,\n ...rest\n }: InputProps<T>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useInputTheme({disabled});\n let fieldName = useFieldName();\n let field = useField();\n let inputRef = useRef<HTMLInputElement>();\n\n useImperativeHandle(ref, () => {\n if (inputRef.current) {\n return inputRef.current;\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- false positive\n return {} as HTMLElement;\n });\n\n let handleClear = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n inputRef.current.dispatchEvent(new Event('input', {bubbles: true}));\n }\n }, []);\n\n let rootProps: Record<string, unknown> = {\n className: theme.root('relative', className),\n };\n let inputProps: Record<string, unknown> = {\n as,\n ref: inputRef,\n disabled,\n name: field?.name ?? fieldName ?? name,\n className: theme.input(null, className),\n size: 1, // so the input default width without styling is small\n ...rest,\n };\n let iconProps: Record<string, unknown> = {\n className: theme.icon('absolute'),\n };\n let clearButtonProps: Record<string, unknown> = {\n className: theme.clearButton('absolute'),\n };\n\n if (Icon) {\n rootProps['data-icon'] = '';\n }\n\n if (showClearButton) {\n rootProps['data-clear-button'] = '';\n }\n\n if (field) {\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import {getInputProps} from '@conform-to/react';\nimport {Input as HeadlessInput} from '@headlessui/react';\nimport {XMarkIcon} from '@heroicons/react/16/solid';\nimport {\n type ComponentPropsWithoutRef,\n type ComponentType,\n type ElementType,\n type Ref,\n useCallback,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\nimport {forwardRef} from './internals.js';\nimport {useField} from './useField.js';\nimport {useFieldName} from './useFieldName.js';\n\nexport const useInputTheme = createComponentTheme('Input', {\n variants: {\n disabled: [true, false],\n },\n elements: ['root', 'input', 'icon', 'clearButton'],\n});\n\nconst INPUT_ELEMENT = 'input';\n\nexport type InputProps<T extends ElementType> = ComponentProps<typeof useInputTheme> &\n ComponentPropsWithoutRef<T> & {\n as?: T | undefined;\n name?: string | undefined;\n className?: string | undefined;\n icon?: ComponentType<object> | undefined;\n showClearButton?: boolean | undefined;\n };\n\nexport const Input = forwardRef(\n <T extends ElementType = typeof INPUT_ELEMENT>(\n {\n disabled = false,\n as = INPUT_ELEMENT as T,\n name,\n className,\n icon: Icon,\n showClearButton = false,\n ...rest\n }: InputProps<T>,\n ref: Ref<HTMLElement>,\n ) => {\n let theme = useInputTheme({disabled});\n let fieldName = useFieldName();\n let field = useField();\n let inputRef = useRef<HTMLInputElement>();\n\n useImperativeHandle(ref, () => {\n if (inputRef.current) {\n return inputRef.current;\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- false positive\n return {} as HTMLElement;\n });\n\n let handleClear = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n inputRef.current.dispatchEvent(new Event('input', {bubbles: true}));\n }\n }, []);\n\n let rootProps: Record<string, unknown> = {\n className: theme.root('relative', className),\n };\n let inputProps: Record<string, unknown> = {\n as,\n ref: inputRef,\n disabled,\n name: field?.name ?? fieldName ?? name,\n className: theme.input(null, className),\n size: 1, // so the input default width without styling is small\n ...rest,\n };\n let iconProps: Record<string, unknown> = {\n className: theme.icon('absolute'),\n };\n let clearButtonProps: Record<string, unknown> = {\n className: theme.clearButton('absolute'),\n };\n\n if (Icon) {\n rootProps['data-icon'] = '';\n }\n\n if (showClearButton) {\n rootProps['data-clear-button'] = '';\n }\n\n if (field) {\n let {key, ...restProps} = getInputProps(field, {type: 'text'});\n\n inputProps = {...restProps, ...inputProps};\n }\n\n return (\n <span {...rootProps}>\n <HeadlessInput {...inputProps} />\n {Icon ?\n <Icon {...iconProps} />\n : null}\n {showClearButton ?\n <XMarkIcon {...clearButtonProps} onClick={handleClear} />\n : null}\n </span>\n );\n },\n);\n"],
|
|
5
|
+
"mappings": ";AAwGM,SACE,KADF;AAxGN,SAAQ,qBAAoB;AAC5B,SAAQ,SAAS,qBAAoB;AACrC,SAAQ,iBAAgB;AACxB;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAA6B,4BAA2B;AACxD,SAAQ,kBAAiB;AACzB,SAAQ,gBAAe;AACvB,SAAQ,oBAAmB;AAEpB,aAAM,gBAAgB,qBAAqB,SAAS;AAAA,EACzD,UAAU;AAAA,IACR,UAAU,CAAC,MAAM,KAAK;AAAA,EACxB;AAAA,EACA,UAAU,CAAC,QAAQ,SAAS,QAAQ,aAAa;AACnD,CAAC;AAED,MAAM,gBAAgB;AAWf,aAAM,QAAQ;AAAA,EACnB,CACE;AAAA,IACE,WAAW;AAAA,IACX,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,G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,kBACC,oBAAC,aAAW,GAAG,kBAAkB,SAAS,aAAa,IACvD;AAAA,OACJ;AAAA,EAEJ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type ComponentProps } from '../theme/internals.js';
|
|
3
|
+
export declare const useLegendTheme: (() => (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string) & {
|
|
4
|
+
componentThemeName: "Legend";
|
|
5
|
+
themeDefinition: undefined;
|
|
6
|
+
};
|
|
7
|
+
export type LegendProps = PropsWithChildren<ComponentProps<typeof useLegendTheme> & {
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function Legend({ className, children }: LegendProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Legend as HeadlessLegend } from "@headlessui/react";
|
|
4
|
+
import { createComponentTheme } from "../theme/internals.js";
|
|
5
|
+
export const useLegendTheme = createComponentTheme("Legend");
|
|
6
|
+
export function Legend({ className, children }) {
|
|
7
|
+
let theme = useLegendTheme();
|
|
8
|
+
return /* @__PURE__ */ jsx(HeadlessLegend, { className: theme(null, className), children });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Legend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../source/components/Legend.tsx"],
|
|
4
|
+
"sourcesContent": ["import {Legend as HeadlessLegend} from '@headlessui/react';\nimport {type PropsWithChildren} from 'react';\n\nimport {type ComponentProps, createComponentTheme} from '../theme/internals.js';\n\nexport const useLegendTheme = createComponentTheme('Legend');\n\nexport type LegendProps = PropsWithChildren<\n ComponentProps<typeof useLegendTheme> & {\n className?: string | undefined;\n }\n>;\n\nexport function Legend({className, children}: LegendProps) {\n let theme = useLegendTheme();\n\n return <HeadlessLegend className={theme(null, className)}>{children}</HeadlessLegend>;\n}\n"],
|
|
5
|
+
"mappings": ";AAgBS;AAhBT,SAAQ,UAAU,sBAAqB;AAGvC,SAA6B,4BAA2B;AAEjD,aAAM,iBAAiB,qBAAqB,QAAQ;AAQpD,gBAAS,OAAO,EAAC,WAAW,SAAQ,GAAgB;AACzD,MAAI,QAAQ,eAAe;AAE3B,SAAO,oBAAC,kBAAe,WAAW,MAAM,MAAM,SAAS,GAAI,UAAS;AACtE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,6 +4,7 @@ export declare const useListboxTheme: ((themeProps: {
|
|
|
4
4
|
readonly disabled: boolean;
|
|
5
5
|
readonly invalid: boolean;
|
|
6
6
|
}) => {
|
|
7
|
+
filter: (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string;
|
|
7
8
|
root: (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string;
|
|
8
9
|
icon: (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string;
|
|
9
10
|
label: (baseClassName?: import("../theme/internals.js").ClassName, overrideClassName?: import("../theme/internals.js").ClassName) => string;
|
|
@@ -15,7 +16,7 @@ export declare const useListboxTheme: ((themeProps: {
|
|
|
15
16
|
readonly disabled: [true, false];
|
|
16
17
|
readonly invalid: [true, false];
|
|
17
18
|
};
|
|
18
|
-
readonly elements: ["root", "label", "icon", "options"];
|
|
19
|
+
readonly elements: ["root", "label", "icon", "options", "filter"];
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
export type ListboxItem<T> = {
|
|
@@ -27,20 +28,27 @@ export type ListboxProps<T extends ElementType, V extends boolean | number | str
|
|
|
27
28
|
value?: V | undefined;
|
|
28
29
|
defaultValue?: V | undefined;
|
|
29
30
|
multiple?: false | undefined;
|
|
31
|
+
hideSelected?: never;
|
|
30
32
|
items?: Array<ListboxItem<V>> | undefined;
|
|
31
33
|
placeholder?: string;
|
|
32
34
|
name?: string | undefined;
|
|
33
35
|
className?: string | undefined;
|
|
36
|
+
showFilter?: boolean | undefined;
|
|
34
37
|
onChange?: (selectedValue: V) => void;
|
|
35
38
|
} | {
|
|
36
39
|
as?: T | undefined;
|
|
37
40
|
value?: V[] | undefined;
|
|
38
41
|
defaultValue?: V[] | undefined;
|
|
39
42
|
multiple: true;
|
|
43
|
+
hideSelected?: {
|
|
44
|
+
limit: number;
|
|
45
|
+
message?: string | undefined;
|
|
46
|
+
} | undefined;
|
|
40
47
|
items?: Array<ListboxItem<V>> | undefined;
|
|
41
48
|
placeholder?: string;
|
|
42
49
|
name?: string | undefined;
|
|
43
50
|
className?: string | undefined;
|
|
51
|
+
showFilter?: boolean | undefined;
|
|
44
52
|
onChange?: (selectedValue: V[]) => void;
|
|
45
53
|
})>;
|
|
46
54
|
export declare const Listbox: <T extends ElementType = import("react").ExoticComponent<{
|