@lanaco/lnc-react-ui
Version:
React component library
39 lines (38 loc) • 1.03 kB
JavaScript
import { jsx as f } from "react/jsx-runtime";
import { forwardRef as m, isValidElement as c, cloneElement as i, useContext as u } from "react";
import { a as P } from "./floating-ui.react.esm-umB-tMXa.js";
import { P as l } from "./index-S5Cd7WrG.js";
import d from "./PopoverContext.js";
const g = () => {
const t = u(d);
if (t == null)
throw new Error("Popover components must be wrapped in <Popover />");
return t;
}, v = m(function({ children: e, asChild: s, ...r }, p) {
const o = g(), a = e.ref, n = P([o.reference, p, a]);
return s && c(e) ? i(
e,
o.getReferenceProps({
ref: n,
...r,
...e.props,
"data-state": o.open ? "open" : "closed"
})
) : /* @__PURE__ */ f(
"div",
{
ref: n,
"data-state": o.open ? "open" : "closed",
style: { width: "max-content" },
...o.getReferenceProps(r),
children: e
}
);
});
v.propTypes = {
/** Allows the user to pass any element as the anchor */
asChild: l.bool
};
export {
v as default
};