@uva-glass/component-library
Version:
React components UvA
63 lines (62 loc) • 2.4 kB
JavaScript
import { jsx as e, jsxs as d } from "react/jsx-runtime";
import { useDialog as b } from "@react-aria/dialog";
import { FocusScope as C } from "@react-aria/focus";
import { useModal as D, useOverlay as y, usePreventScroll as N, OverlayContainer as v } from "@react-aria/overlays";
import { c as P } from "../../clsx-OuTLNxxd.js";
import { useState as x, useRef as S, useEffect as j } from "react";
import { Backdrop as k } from "../Backdrop/Backdrop.js";
import { OverlayCloseButton as B } from "../OverlayCloseButton/OverlayCloseButton.js";
import '../../assets/Drawer.css';const F = "_drawer_1g9hi_1", R = "_drawer__content_1g9hi_22", T = "_drawer__header_1g9hi_32", E = "_drawer__footer_1g9hi_39", K = "_drawer__heading_1g9hi_26", M = "_drawer__buttons_1g9hi_64", r = {
drawer: F,
drawer__content: R,
drawer__header: T,
drawer__footer: E,
drawer__heading: K,
"drawer--open": "_drawer--open_1g9hi_59",
drawer__buttons: M
}, q = 200;
function U({
buttons: s,
children: n,
isOpen: o,
onClose: i,
title: l,
closeButtonAriaValueText: c = "Close",
...w
}) {
const [m, t] = x(r.drawer), { modalProps: h } = D({ isDisabled: !o }), a = S(null);
function _() {
t(r.drawer), globalThis.setTimeout(() => {
i();
}, q);
}
const { overlayProps: u, underlayProps: f } = y(
{ isDismissable: !0, isKeyboardDismissDisabled: !1, isOpen: o, onClose: _ },
a
), { dialogProps: g, titleProps: p } = b({}, a);
return N({ isDisabled: !o }), j(() => {
t(P(r.drawer, { [r["drawer--open"]]: o }));
}, [o]), /* @__PURE__ */ e(v, { children: /* @__PURE__ */ e(k, { ...f, children: /* @__PURE__ */ e(C, { contain: !0, restoreFocus: !0, children: /* @__PURE__ */ d(
"aside",
{
...h,
...u,
...g,
...w,
className: m,
ref: a,
children: [
/* @__PURE__ */ d("header", { className: r.drawer__header, children: [
/* @__PURE__ */ e("h1", { className: r.drawer__heading, ...p, children: l }),
/* @__PURE__ */ e(B, { "aria-label": c, onClick: _ })
] }),
/* @__PURE__ */ e("div", { className: r.drawer__content, children: n }),
s && /* @__PURE__ */ e("footer", { className: r.drawer__footer, children: /* @__PURE__ */ e("div", { className: r.drawer__buttons, children: s }) })
]
}
) }) }) });
}
export {
U as Drawer
};
//# sourceMappingURL=Drawer.js.map