UNPKG

@hitachivantara/uikit-react-core

Version:
46 lines (45 loc) 1.56 kB
import { HvIcon } from "../icons.js"; import { HvButton } from "../Button/Button.js"; import { useClasses } from "./DropdownButton.styles.js"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { forwardRef } from "react"; import { jsx } from "react/jsx-runtime"; //#region src/DropdownButton/DropdownButton.tsx /** * IMPORTANT: This component is not ready to be exported to external users. * * Implements the DS dropdown button pattern. */ var HvDropdownButton = forwardRef(function HvDropdownButton(props, ref) { const { className, classes: classesProp, disabled, open, icon, readOnly, children: childrenProp, variant, ...others } = useDefaultProps("HvDropdownButton", props); const { classes, cx } = useClasses(classesProp, false); const endIcon = !icon && /* @__PURE__ */ jsx(HvIcon, { name: "CaretDown", size: "xs", rotate: open }); const children = childrenProp && typeof childrenProp === "string" ? /* @__PURE__ */ jsx("div", { className: classes.placeholder, children: childrenProp }) : childrenProp; return /* @__PURE__ */ jsx(HvButton, { ref, icon, disabled: disabled || readOnly, className: cx(classes.root, { [classes.open]: open, [classes.readOnly]: readOnly, [classes.disabled]: disabled }, className), classes: { endIcon: classes.arrowContainer }, endIcon, variant: open ? "secondarySubtle" : variant, ...others, children: icon ? children : /* @__PURE__ */ jsx("div", { className: classes.selection, children }) }); }); //#endregion export { HvDropdownButton };