UNPKG

@intility/bifrost-react-select

Version:

React select component for Intility's design system, Bifrost.

92 lines 2.13 kB
import { c as _c } from "react-compiler-runtime"; import { Dropdown } from "@intility/bifrost-react"; import useResizeObserver from "@intility/bifrost-react/hooks/useResizeObserver"; import { createContext, useContext, useRef } from "react"; import { components } from "react-select"; import { jsx as _jsx } from "react/jsx-runtime"; export const SelectRefCtx = /*#__PURE__*/createContext(null); export default function Menu(props) { const $ = _c(14); const { menuPlacement, menuPosition } = props; const controlElement = useContext(SelectRefCtx); const divRef = useRef(null); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = entry => { if (!divRef.current) { return; } divRef.current.style.width = entry.borderBoxSize[0].inlineSize + "px"; }; $[0] = t0; } else { t0 = $[0]; } useResizeObserver(controlElement, t0); const t1 = menuPlacement === "auto" ? "bottom" : menuPlacement; let t2; if ($[1] === Symbol.for("react.memo_cache_sentinel")) { t2 = [0, 4]; $[1] = t2; } else { t2 = $[1]; } const t3 = controlElement?.offsetWidth; let t4; if ($[2] !== t3) { t4 = { width: t3 }; $[2] = t3; $[3] = t4; } else { t4 = $[3]; } let t5; if ($[4] !== props) { t5 = /*#__PURE__*/_jsx(components.Menu, { ...props }); $[4] = props; $[5] = t5; } else { t5 = $[5]; } let t6; if ($[6] !== t4 || $[7] !== t5) { t6 = /*#__PURE__*/_jsx("div", { ref: divRef, style: t4, children: t5 }); $[6] = t4; $[7] = t5; $[8] = t6; } else { t6 = $[8]; } let t7; if ($[9] !== controlElement || $[10] !== menuPosition || $[11] !== t1 || $[12] !== t6) { t7 = /*#__PURE__*/_jsx(Dropdown, { unstyled: true, noArrow: true, visible: true, reference: controlElement, placement: t1, strategy: menuPosition, offset: t2, content: t6 }); $[9] = controlElement; $[10] = menuPosition; $[11] = t1; $[12] = t6; $[13] = t7; } else { t7 = $[13]; } return t7; }