@lanaco/lnc-react-ui
Version:
React component library
45 lines (44 loc) • 999 B
JavaScript
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-B-RMCmpu.js";
import { a as S, o as U, f as A, s as E } from "./floating-ui.dom-C16Oktn3.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: S,
middleware: [
U(u),
A({
fallbackAxisSideDirection: "end"
}),
E({ 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
};