@kopexa/alert-dialog
Version:
A modal dialog that interrupts the user with important content and expects a response.
189 lines (187 loc) • 5.91 kB
JavaScript
"use client";
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/alert-dialog.tsx
var alert_dialog_exports = {};
__export(alert_dialog_exports, {
AlertDialogAction: () => AlertDialogAction,
AlertDialogCancel: () => AlertDialogCancel,
AlertDialogContent: () => AlertDialogContent,
AlertDialogDescription: () => AlertDialogDescription,
AlertDialogFooter: () => AlertDialogFooter,
AlertDialogHeader: () => AlertDialogHeader,
AlertDialogOverlay: () => AlertDialogOverlay,
AlertDialogPortal: () => AlertDialogPortal,
AlertDialogRoot: () => AlertDialogRoot,
AlertDialogTitle: () => AlertDialogTitle,
AlertDialogTrigger: () => AlertDialogTrigger
});
module.exports = __toCommonJS(alert_dialog_exports);
var import_react_utils = require("@kopexa/react-utils");
var import_theme = require("@kopexa/theme");
var AlertDialogPrimitive = __toESM(require("@radix-ui/react-alert-dialog"));
var import_jsx_runtime = require("react/jsx-runtime");
var [Provider, useAlertDialogContext] = (0, import_react_utils.createContext)();
function AlertDialogRoot(props) {
const styles = (0, import_theme.alertDialog)();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogPrimitive.Root, { "data-slot": "alert-dialog", ...props }) });
}
function AlertDialogTrigger(props) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogPrimitive.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
}
function AlertDialogPortal({ ...props }) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogPrimitive.Portal, { "data-slot": "alert-dialog-portal", ...props });
}
function AlertDialogOverlay({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Overlay,
{
"data-slot": "alert-dialog-overlay",
className: styles.overlay(className),
...props
}
);
}
function AlertDialogContent({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AlertDialogPortal, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogOverlay, {}),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Content,
{
"data-slot": "alert-dialog-content",
className: styles.content(className),
...props
}
)
] });
}
function AlertDialogHeader({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"div",
{
"data-slot": "alert-dialog-header",
className: styles.header(className),
...props
}
);
}
function AlertDialogFooter({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"div",
{
"data-slot": "alert-dialog-footer",
className: styles.footer(className),
...props
}
);
}
function AlertDialogTitle({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Title,
{
"data-slot": "alert-dialog-title",
className: styles.title(className),
...props
}
);
}
function AlertDialogDescription({
className,
...props
}) {
const { styles } = useAlertDialogContext();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Description,
{
"data-slot": "alert-dialog-description",
className: styles.description(className),
...props
}
);
}
function AlertDialogAction({
className,
color,
variant,
...props
}) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Action,
{
className: (0, import_theme.button)({ className, color, variant }),
...props
}
);
}
function AlertDialogCancel({
className,
...props
}) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
AlertDialogPrimitive.Cancel,
{
className: (0, import_theme.button)({ variant: "ghost", className }),
...props
}
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogOverlay,
AlertDialogPortal,
AlertDialogRoot,
AlertDialogTitle,
AlertDialogTrigger
});