UNPKG

@lanaco/lnc-react-ui

Version:

React component library

45 lines (44 loc) 999 B
import { useState as o, useMemo as k } from "react"; import { c as v, d as C, e as D, f as w, g as M } from "./floating-ui.react.esm-umB-tMXa.js"; import { o as S, f as U, s as A, a as E } from "./floating-ui.dom-vNhdy5RI.js"; function R({ initialOpen: r = !1, placement: p, offsetValue: u, modal: a = !0, open: i, onOpenChange: f }) { const [m, g] = o(r), [c, I] = o(void 0), [d, b] = o(void 0), e = i ?? m, s = f ?? g, t = v({ placement: p, open: e, onOpenChange: s, whileElementsMounted: E, middleware: [ S(u), U({ fallbackAxisSideDirection: "end" }), A({ padding: 5 }) ] }), n = t.context, h = C(n, { enabled: i == null }), x = D(n), O = w(n), l = M([h, x, O]); return k( () => ({ open: e, setOpen: s, ...l, ...t, modal: a, labelId: c, descriptionId: d, setLabelId: I, setDescriptionId: b }), [e, s, l, t, a, c, d] ); } export { R as default };