UNPKG

@hitachivantara/uikit-react-core

Version:
35 lines (34 loc) 1.33 kB
import { fixedForwardRef } from "../types/generic.js"; import { outlineStyles } from "../utils/focusUtils.js"; import { HvListItem } from "../ListContainer/ListItem/ListItem.js"; import { createClasses, useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { useRef } from "react"; import { jsx } from "react/jsx-runtime"; import { useOption } from "@mui/base"; import { useForkRef } from "@mui/material/utils"; //#region src/Select/Option.tsx var { staticClasses, useClasses } = createClasses("HvOption", { root: {}, highlighted: { ...outlineStyles } }); var HvOption = fixedForwardRef(function HvOption(props, ref) { const { classes: classesProp, className, disabled = false, label, value, children, ...others } = useDefaultProps("HvOption", props); const { classes, cx } = useClasses(classesProp); const optionRef = useRef(null); const rootRef = useForkRef(optionRef, ref); const { getRootProps, selected, highlighted } = useOption({ disabled, label: label ?? (typeof children === "string" ? children : optionRef.current?.textContent?.trim()), rootRef, value }); return /* @__PURE__ */ jsx(HvListItem, { ref, selected, className: cx(classes.root, className, { [classes.highlighted]: highlighted }), ...getRootProps(others), children }); }); //#endregion export { HvOption, staticClasses };