@vela-ui/react
Version:
Vela UI React components
105 lines (102 loc) • 2.5 kB
JavaScript
import {
Input,
InputGroup
} from "./chunk-NHADI6X2.mjs";
import {
Popover
} from "./chunk-MPQ6RJKJ.mjs";
import {
DropdownDescription,
DropdownItem,
DropdownLabel,
DropdownSection
} from "./chunk-2KYD4PYX.mjs";
import {
Button
} from "./chunk-BDRWTFDD.mjs";
import {
Description,
FieldError,
Label
} from "./chunk-FFLNGARZ.mjs";
import {
composeTailwindRenderProps
} from "./chunk-OCN72JL6.mjs";
import {
ChevronsUpDownIcon
} from "./chunk-JHQUP2BC.mjs";
// src/components/combobox.tsx
import {
ComboBox as AriaComboBox,
ListBox as AriaListBox,
composeRenderProps
} from "react-aria-components";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function Combobox({
label,
description,
errorMessage,
children,
className,
...props
}) {
return /* @__PURE__ */ jsx(
AriaComboBox,
{
"data-slot": "combobox",
...props,
className: composeTailwindRenderProps(className, "group flex w-full flex-col gap-2"),
children: composeRenderProps(children, (children2) => /* @__PURE__ */ jsxs(Fragment, { children: [
label && /* @__PURE__ */ jsx(Label, { children: label }),
children2,
description && /* @__PURE__ */ jsx(Description, { children: description }),
/* @__PURE__ */ jsx(FieldError, { children: errorMessage })
] }))
}
);
}
function ComboboxPopover({ className, ...props }) {
return /* @__PURE__ */ jsx(
Popover,
{
showArrow: false,
className,
style: { minWidth: "var(--trigger-width)" },
...props
}
);
}
function ComboboxList({ className, ...props }) {
return /* @__PURE__ */ jsx(
AriaListBox,
{
className: composeTailwindRenderProps(
className,
"max-h-[inherit] min-w-[inherit] overflow-auto p-1 outline-hidden"
),
...props
}
);
}
function ComboboxInput({
size,
endElementProps,
endElement = /* @__PURE__ */ jsx(Button, { variant: "ghost", shape: "square", size, ...endElementProps, children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, {}) }),
...props
}) {
return /* @__PURE__ */ jsx(InputGroup, { size, endElement, children: /* @__PURE__ */ jsx(Input, { ...props }) });
}
var ComboboxSection = DropdownSection;
var ComboboxItem = DropdownItem;
var ComboboxLabel = DropdownLabel;
var ComboboxDescription = DropdownDescription;
export {
Combobox,
ComboboxPopover,
ComboboxList,
ComboboxInput,
ComboboxSection,
ComboboxItem,
ComboboxLabel,
ComboboxDescription
};