laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
158 lines (157 loc) • 4.14 kB
JavaScript
"use client";
import { jsx as a, jsxs as l } from "react/jsx-runtime";
import { Root as u, Close as r, Content as f, Description as p, Title as x, Trigger as v, Portal as D, Overlay as b } from "../../node_modules/@radix-ui/react-dialog/dist/index.js";
import { designTokens as n } from "../design-tokens.js";
import { cn as o } from "../../lib/utils.js";
import h from "../../node_modules/lucide-react/dist/esm/icons/x.js";
function O({
...t
}) {
return /* @__PURE__ */ a(u, { "data-slot": "dialog", ...t });
}
function P({
...t
}) {
return /* @__PURE__ */ a(v, { "data-slot": "dialog-trigger", ...t });
}
function w({
...t
}) {
return /* @__PURE__ */ a(D, { "data-slot": "dialog-portal", ...t });
}
function _({
...t
}) {
return /* @__PURE__ */ a(r, { "data-slot": "dialog-close", ...t });
}
function y({
className: t,
...e
}) {
return /* @__PURE__ */ a(
b,
{
"data-slot": "dialog-overlay",
className: o(
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
t
),
...e
}
);
}
function R({
className: t,
children: e,
size: i = "default",
closeOnOverlay: d = !0,
showCloseButton: g = !0,
...c
}) {
const m = {
sm: "sm:max-w-sm",
default: "sm:max-w-lg",
lg: "sm:max-w-2xl",
xl: "sm:max-w-3xl"
}[i];
return /* @__PURE__ */ l(w, { "data-slot": "dialog-portal", children: [
/* @__PURE__ */ a(y, {}),
/* @__PURE__ */ l(
f,
{
"data-slot": "dialog-content",
onPointerDownOutside: (s) => {
s.target?.closest("[data-command-portal]") && s.preventDefault(), d || s.preventDefault();
},
className: o(
"bg-d-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 border-d-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200",
n.radius.lg,
m,
t
),
...c,
children: [
e,
g && /* @__PURE__ */ l(
r,
{
className: o(
"ring-offset-d-background data-[state=open]:bg-d-accent data-[state=open]:text-d-secondary-foreground bg-d-muted/30 hover:bg-d-muted/60 absolute top-4 right-4 cursor-pointer p-1.5 transition-all hover:opacity-100 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
n.focusRing,
n.radius.default
),
children: [
/* @__PURE__ */ a(h, {}),
/* @__PURE__ */ a("span", { className: "sr-only", children: "Close" })
]
}
)
]
}
)
] });
}
function F({ className: t, ...e }) {
return /* @__PURE__ */ a(
"div",
{
"data-slot": "dialog-header",
className: o("flex flex-col gap-2 text-center sm:text-left", t),
...e
}
);
}
function H({ className: t, ...e }) {
return /* @__PURE__ */ a(
"div",
{
"data-slot": "dialog-footer",
className: o(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
t
),
...e
}
);
}
function X({
className: t,
...e
}) {
return /* @__PURE__ */ a(
x,
{
"data-slot": "dialog-title",
className: o(
"text-start text-lg leading-none font-semibold sm:max-w-[calc(100%-2rem)]",
t
),
...e
}
);
}
function q({
className: t,
...e
}) {
return /* @__PURE__ */ a(
p,
{
"data-slot": "dialog-description",
className: o("text-d-muted-foreground text-start text-sm", t),
...e
}
);
}
export {
O as Dialog,
_ as DialogClose,
R as DialogContent,
q as DialogDescription,
H as DialogFooter,
F as DialogHeader,
y as DialogOverlay,
w as DialogPortal,
X as DialogTitle,
P as DialogTrigger
};