@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 y } from "@react-aria/dialog";
import { FocusScope as C } from "@react-aria/focus";
import { useModal as D, useOverlay as g, 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_1ytb4_1", R = "_drawer__content_1ytb4_22", T = "_drawer__header_1ytb4_32", E = "_drawer__footer_1ytb4_39", K = "_drawer__heading_1ytb4_26", M = "_drawer__buttons_1ytb4_64", r = {
drawer: F,
drawer__content: R,
drawer__header: T,
drawer__footer: E,
drawer__heading: K,
"drawer--open": "_drawer--open_1ytb4_59",
drawer__buttons: M
}, q = 200;
function U({
buttons: s,
children: n,
isOpen: o,
onClose: l,
title: c,
closeButtonAriaValueText: i = "Close",
...w
}) {
const [m, t] = x(r.drawer), { modalProps: u } = D({ isDisabled: !o }), a = S(null);
function _() {
t(r.drawer), globalThis.setTimeout(() => {
l();
}, q);
}
const { overlayProps: f, underlayProps: h } = g(
{ isDismissable: !0, isKeyboardDismissDisabled: !1, isOpen: o, onClose: _ },
a
), { dialogProps: b, titleProps: p } = y({}, a);
return N({ isDisabled: !o }), j(() => {
t(P(r.drawer, { [r["drawer--open"]]: o }));
}, [o]), /* @__PURE__ */ e(v, { children: /* @__PURE__ */ e(k, { ...h, children: /* @__PURE__ */ e(C, { contain: !0, restoreFocus: !0, children: /* @__PURE__ */ d(
"aside",
{
...u,
...f,
...b,
...w,
className: m,
ref: a,
children: [
/* @__PURE__ */ d("header", { className: r.drawer__header, children: [
/* @__PURE__ */ e("h1", { className: r.drawer__heading, ...p, children: c }),
/* @__PURE__ */ e(B, { "aria-label": i, 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