fui-fancyui
Version:
FancyUI Libary
58 lines (57 loc) • 1.43 kB
JavaScript
"use client";
import { jsxs as A, jsx as l } from "react/jsx-runtime";
import { useRef as a, useState as c, useEffect as m } from "react";
import { StyledDialog as $, StyledHeader as E, StyledContent as F, StyledFooter as j } from "./SimpleDialog.style.js";
function b(f) {
const {
isOpen: s = !1,
children: d,
header: y,
footer: p,
themeType: h = "primary",
layer: S = 1,
externalStyle: x,
...T
} = f, e = a(null), [t, i] = c(!1), [g, o] = c(!1), r = a(null);
return m(() => {
if (s)
i(!0), requestAnimationFrame(() => {
o(!0);
}), r.current = document.activeElement;
else {
o(!1);
const n = setTimeout(() => {
i(!1);
}, 300);
return r.current && r.current.focus(), () => clearTimeout(n);
}
}, [s]), m(() => {
if (t && e.current) {
const n = setTimeout(() => {
var u;
(u = e == null ? void 0 : e.current) == null || u.focus();
}, 10);
return () => clearTimeout(n);
}
}, [t]), t ? /* @__PURE__ */ A(
$,
{
ref: e,
tabIndex: -1,
role: "dialog",
$isAnimating: g,
$themeType: h,
$layer: S,
$externalStyle: x,
...T,
children: [
/* @__PURE__ */ l(E, { children: y }),
/* @__PURE__ */ l(F, { children: d }),
/* @__PURE__ */ l(j, { children: p })
]
}
) : null;
}
export {
b as default
};