ConfirmModal-FHGIQVx7.js 2.1 KB

1
  1. import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{T as t,k as n,w as r}from"./client-DWQBE01c.js";import{t as i}from"./loader-circle-QIogdiwG.js";import{t as a}from"./triangle-alert-C-5b4OJS.js";import{n as o,t as s}from"./Card-DwWt21H0.js";import{t as c}from"./Button-CDViejCk.js";var l=e(n(),1),u=r();function d({title:e,message:n,confirmText:r,cancelText:d,cancelVariant:f,cardClassName:p,overlayZIndex:m,variant:h=`default`,isLoading:g=!1,loadingText:_,confirmDisabled:v=!1,children:y,onConfirm:b,onCancel:x}){let{t:S}=t(),C=r??S(`common.confirm`),w=d??S(`common.cancel`),T=_??S(`common.loading`);(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!g&&x()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x,g]);let E={danger:{icon:`text-red-600 dark:text-red-400`,button:`bg-red-500 hover:bg-red-600`},warning:{icon:`text-yellow-600 dark:text-yellow-400`,button:`bg-yellow-500 hover:bg-yellow-600 text-black`},default:{icon:`text-bambu-green`,button:`bg-bambu-green hover:bg-bambu-green-dark`}}[h];return(0,u.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 ${m??`z-50`}`,onClick:g?void 0:x,children:(0,u.jsx)(s,{className:`w-full max-w-md ${p??``}`,onClick:e=>e.stopPropagation(),children:(0,u.jsxs)(o,{className:`p-6`,children:[(0,u.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,u.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-dark ${E.icon}`,children:(0,u.jsx)(a,{className:`w-6 h-6`})}),(0,u.jsxs)(`div`,{className:`flex-1`,children:[(0,u.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e}),(0,u.jsx)(`p`,{className:`text-bambu-gray text-sm whitespace-pre-line`,children:n}),y&&(0,u.jsx)(`div`,{className:`mt-4`,children:y})]})]}),(0,u.jsxs)(`div`,{className:`flex gap-3 mt-6`,children:[(0,u.jsx)(c,{variant:f??`secondary`,onClick:x,className:`flex-1`,disabled:g,children:w}),(0,u.jsx)(c,{onClick:b,className:`flex-1 ${E.button}`,disabled:g||v,children:g?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(i,{className:`w-4 h-4 mr-2 animate-spin`}),T]}):C})]})]})})})}export{d as t};