@anoki/fse-ui
Version:
FSE UI components library
128 lines (124 loc) • 4.66 kB
JavaScript
import * as l from "react";
import { createContextScope as T } from "./index.es472.js";
import { useComposedRefs as A } from "./index.es471.js";
import { createDialogScope as v, Root as O, Portal as j, Overlay as b, WarningProvider as w, Content as M, Title as I, Description as L, Close as f, Trigger as $ } from "./index.es324.js";
import { composeEventHandlers as F } from "./index.es470.js";
import { createSlottable as G } from "./index.es481.js";
import { j as i } from "./index.es244.js";
var D = "AlertDialog", [W, te] = T(D, [
v
]), s = v(), m = (e) => {
const { __scopeAlertDialog: o, ...r } = e, t = s(o);
return /* @__PURE__ */ i.jsx(O, { ...t, ...r, modal: !0 });
};
m.displayName = D;
var Y = "AlertDialogTrigger", q = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, ...t } = e, a = s(r);
return /* @__PURE__ */ i.jsx($, { ...a, ...t, ref: o });
}
);
q.displayName = Y;
var B = "AlertDialogPortal", y = (e) => {
const { __scopeAlertDialog: o, ...r } = e, t = s(o);
return /* @__PURE__ */ i.jsx(j, { ...t, ...r });
};
y.displayName = B;
var H = "AlertDialogOverlay", _ = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, ...t } = e, a = s(r);
return /* @__PURE__ */ i.jsx(b, { ...a, ...t, ref: o });
}
);
_.displayName = H;
var n = "AlertDialogContent", [V, k] = W(n), z = G("AlertDialogContent"), N = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, children: t, ...a } = e, d = s(r), p = l.useRef(null), P = A(o, p), g = l.useRef(null);
return /* @__PURE__ */ i.jsx(
w,
{
contentName: n,
titleName: R,
docsSlug: "alert-dialog",
children: /* @__PURE__ */ i.jsx(V, { scope: r, cancelRef: g, children: /* @__PURE__ */ i.jsxs(
M,
{
role: "alertdialog",
...d,
...a,
ref: P,
onOpenAutoFocus: F(a.onOpenAutoFocus, (c) => {
var u;
c.preventDefault(), (u = g.current) == null || u.focus({ preventScroll: !0 });
}),
onPointerDownOutside: (c) => c.preventDefault(),
onInteractOutside: (c) => c.preventDefault(),
children: [
/* @__PURE__ */ i.jsx(z, { children: t }),
/* @__PURE__ */ i.jsx(Q, { contentRef: p })
]
}
) })
}
);
}
);
N.displayName = n;
var R = "AlertDialogTitle", x = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, ...t } = e, a = s(r);
return /* @__PURE__ */ i.jsx(I, { ...a, ...t, ref: o });
}
);
x.displayName = R;
var C = "AlertDialogDescription", E = l.forwardRef((e, o) => {
const { __scopeAlertDialog: r, ...t } = e, a = s(r);
return /* @__PURE__ */ i.jsx(L, { ...a, ...t, ref: o });
});
E.displayName = C;
var J = "AlertDialogAction", K = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, ...t } = e, a = s(r);
return /* @__PURE__ */ i.jsx(f, { ...a, ...t, ref: o });
}
);
K.displayName = J;
var h = "AlertDialogCancel", S = l.forwardRef(
(e, o) => {
const { __scopeAlertDialog: r, ...t } = e, { cancelRef: a } = k(h, r), d = s(r), p = A(o, a);
return /* @__PURE__ */ i.jsx(f, { ...d, ...t, ref: p });
}
);
S.displayName = h;
var Q = ({ contentRef: e }) => {
const o = `\`${n}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${n}\` by passing a \`${C}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${n}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
return l.useEffect(() => {
var t;
document.getElementById(
(t = e.current) == null ? void 0 : t.getAttribute("aria-describedby")
) || console.warn(o);
}, [o, e]), null;
}, ae = m, ie = y, le = _, se = N, ne = S, ce = x, pe = E;
export {
m as AlertDialog,
K as AlertDialogAction,
S as AlertDialogCancel,
N as AlertDialogContent,
E as AlertDialogDescription,
_ as AlertDialogOverlay,
y as AlertDialogPortal,
x as AlertDialogTitle,
q as AlertDialogTrigger,
ne as Cancel,
se as Content,
pe as Description,
le as Overlay,
ie as Portal,
ae as Root,
ce as Title,
te as createAlertDialogScope
};
//# sourceMappingURL=index.es396.js.map