wcz-layout
Version:
248 lines (247 loc) • 5.93 kB
JavaScript
import { t as DialogsContext } from "./DialogsContext-D5A8xncJ.js";
import { c } from "react/compiler-runtime";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, useEventCallback } from "@mui/material";
import { useContext } from "react";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/hooks/useDialogs.tsx
function AlertDialog(t0) {
const $ = c(23);
if ($[0] !== "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d") {
for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d";
}
const { open, payload, onClose } = t0;
const { t } = useTranslation();
let t1;
if ($[1] !== onClose) {
t1 = () => onClose();
$[1] = onClose;
$[2] = t1;
} else t1 = $[2];
let t2;
if ($[3] !== payload.title || $[4] !== t) {
t2 = payload.title ?? t("Layout.Dialog.Alert");
$[3] = payload.title;
$[4] = t;
$[5] = t2;
} else t2 = $[5];
let t3;
if ($[6] !== t2) {
t3 = /* @__PURE__ */ jsx(DialogTitle, { children: t2 });
$[6] = t2;
$[7] = t3;
} else t3 = $[7];
let t4;
if ($[8] !== payload.message) {
t4 = /* @__PURE__ */ jsx(DialogContent, { children: payload.message });
$[8] = payload.message;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== onClose) {
t5 = () => onClose();
$[10] = onClose;
$[11] = t5;
} else t5 = $[11];
let t6;
if ($[12] !== t) {
t6 = t("Layout.Dialog.Confirm");
$[12] = t;
$[13] = t6;
} else t6 = $[13];
let t7;
if ($[14] !== t5 || $[15] !== t6) {
t7 = /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, {
onClick: t5,
autoFocus: true,
children: t6
}) });
$[14] = t5;
$[15] = t6;
$[16] = t7;
} else t7 = $[16];
let t8;
if ($[17] !== open || $[18] !== t1 || $[19] !== t3 || $[20] !== t4 || $[21] !== t7) {
t8 = /* @__PURE__ */ jsxs(Dialog, {
maxWidth: "xs",
fullWidth: true,
open,
onClose: t1,
disableRestoreFocus: true,
children: [
t3,
t4,
t7
]
});
$[17] = open;
$[18] = t1;
$[19] = t3;
$[20] = t4;
$[21] = t7;
$[22] = t8;
} else t8 = $[22];
return t8;
}
function ConfirmDialog(t0) {
const $ = c(34);
if ($[0] !== "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d") {
for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d";
}
const { open, payload, onClose } = t0;
const { t } = useTranslation();
let t1;
if ($[1] !== onClose) {
t1 = () => onClose(false);
$[1] = onClose;
$[2] = t1;
} else t1 = $[2];
let t2;
if ($[3] !== payload.title || $[4] !== t) {
t2 = payload.title ?? t("Layout.Dialog.Confirm");
$[3] = payload.title;
$[4] = t;
$[5] = t2;
} else t2 = $[5];
let t3;
if ($[6] !== t2) {
t3 = /* @__PURE__ */ jsx(DialogTitle, { children: t2 });
$[6] = t2;
$[7] = t3;
} else t3 = $[7];
let t4;
if ($[8] !== payload.message) {
t4 = /* @__PURE__ */ jsx(DialogContent, { children: payload.message });
$[8] = payload.message;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== onClose) {
t5 = () => onClose(false);
$[10] = onClose;
$[11] = t5;
} else t5 = $[11];
let t6;
if ($[12] !== payload.cancelText || $[13] !== t) {
t6 = payload.cancelText ?? t("Layout.Dialog.Cancel");
$[12] = payload.cancelText;
$[13] = t;
$[14] = t6;
} else t6 = $[14];
let t7;
if ($[15] !== t5 || $[16] !== t6) {
t7 = /* @__PURE__ */ jsx(Button, {
onClick: t5,
children: t6
});
$[15] = t5;
$[16] = t6;
$[17] = t7;
} else t7 = $[17];
let t8;
if ($[18] !== onClose) {
t8 = () => onClose(true);
$[18] = onClose;
$[19] = t8;
} else t8 = $[19];
let t9;
if ($[20] !== t) {
t9 = t("Layout.Dialog.Confirm");
$[20] = t;
$[21] = t9;
} else t9 = $[21];
let t10;
if ($[22] !== t8 || $[23] !== t9) {
t10 = /* @__PURE__ */ jsx(Button, {
onClick: t8,
autoFocus: true,
children: t9
});
$[22] = t8;
$[23] = t9;
$[24] = t10;
} else t10 = $[24];
let t11;
if ($[25] !== t10 || $[26] !== t7) {
t11 = /* @__PURE__ */ jsxs(DialogActions, { children: [t7, t10] });
$[25] = t10;
$[26] = t7;
$[27] = t11;
} else t11 = $[27];
let t12;
if ($[28] !== open || $[29] !== t1 || $[30] !== t11 || $[31] !== t3 || $[32] !== t4) {
t12 = /* @__PURE__ */ jsxs(Dialog, {
maxWidth: "xs",
fullWidth: true,
open,
onClose: t1,
disableRestoreFocus: true,
children: [
t3,
t4,
t11
]
});
$[28] = open;
$[29] = t1;
$[30] = t11;
$[31] = t3;
$[32] = t4;
$[33] = t12;
} else t12 = $[33];
return t12;
}
function useDialogs() {
const $ = c(10);
if ($[0] !== "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d") {
for (let $i = 0; $i < 10; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "7272d374967a35accb5b4a69dba078d1be7a51f62b7d0c67acb5047c4cf88a5d";
}
const { open, close } = useContext(DialogsContext);
let t0;
if ($[1] !== open) {
t0 = (message, t1) => {
const { ...options } = t1 === void 0 ? {} : t1;
return open(AlertDialog, {
...options,
message
});
};
$[1] = open;
$[2] = t0;
} else t0 = $[2];
const alert = useEventCallback(t0);
let t1;
if ($[3] !== open) {
t1 = (message_0, t2) => {
const { ...options_0 } = t2 === void 0 ? {} : t2;
return open(ConfirmDialog, {
...options_0,
message: message_0
});
};
$[3] = open;
$[4] = t1;
} else t1 = $[4];
const confirm = useEventCallback(t1);
let t2;
if ($[5] !== alert || $[6] !== close || $[7] !== confirm || $[8] !== open) {
t2 = {
alert,
confirm,
open,
close
};
$[5] = alert;
$[6] = close;
$[7] = confirm;
$[8] = open;
$[9] = t2;
} else t2 = $[9];
return t2;
}
//#endregion
export { useDialogs as t };
//# sourceMappingURL=useDialogs-BaxhulU9.js.map