synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
45 lines (44 loc) • 1.24 kB
JavaScript
import { jsxs as a, jsx as t } from "react/jsx-runtime";
import { useState as d, useRef as l, useEffect as f } from "react";
import { LoginAwareButton as p } from "../widgets/LoginAwareButton.js";
import { Box as u } from "@mui/material";
function y({ showSpinner: e = !1, ...n }) {
const [s, o] = d(0), i = l(null);
return f(() => {
if (i) {
const r = i.current?.offsetWidth ?? 0;
o(r);
}
}, []), /* @__PURE__ */ a(
"div",
{
"data-testid": "SpinnerButton",
style: { position: "relative", width: "max-content" },
children: [
e && /* @__PURE__ */ t(
"div",
{
style: {
position: "absolute",
top: "8px",
left: `${s / 2 - 8}px`
},
children: /* @__PURE__ */ t("span", { "data-testid": "SpinnerButton-spinner", className: "spinner" })
}
),
/* @__PURE__ */ t(u, { sx: { display: "flex" }, ref: i, children: /* @__PURE__ */ t(
p,
{
...n,
disabled: n.disabled || e,
style: { opacity: e ? 0.4 : 1 }
}
) })
]
}
);
}
export {
y as default
};
//# sourceMappingURL=SpinnerButton.js.map