1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
(()=>{var e={};e.id=888,e.ids=[888],e.modules={4407:(e,r,o)=>{"use strict";o.d(r,{N:()=>a,W:()=>l});var t=o(997),n=o(6689),s=o(349);let i=(0,n.createContext)(null);function l({children:e}){let[r,o]=(0,n.useState)(null),l=(0,n.useCallback)(e=>new Promise(r=>{o({title:e.title||"请确认操作",description:e.description||"",confirmText:e.confirmText||"确认",cancelText:e.cancelText||"取消",tone:e.tone||"danger",resolve:r})}),[]),a=(0,n.useCallback)(e=>{o(r=>(r?.resolve(e),null))},[]),c=(0,n.useMemo)(()=>({confirm:l}),[l]);return(0,t.jsxs)(i.Provider,{value:c,children:[e,r?t.jsx("div",{className:"modal-overlay modal-overlay--center",onClick:()=>a(!1),children:(0,t.jsxs)("div",{className:"confirm-card",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",children:[t.jsx("div",{className:`confirm-card__icon confirm-card__icon--${r.tone}`,children:t.jsx(s.J,{name:"danger"===r.tone?"trash":"info",size:18})}),(0,t.jsxs)("div",{className:"confirm-card__body",children:[t.jsx("h2",{id:"confirm-title",children:r.title}),r.description?t.jsx("p",{children:r.description}):null]}),(0,t.jsxs)("div",{className:"confirm-card__actions",children:[t.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>a(!1),children:r.cancelText}),t.jsx("button",{type:"button",className:`btn ${"danger"===r.tone?"btn-danger":"btn-primary"}`,onClick:()=>a(!0),children:r.confirmText})]})]})}):null]})}function a(){let e=(0,n.useContext)(i);if(!e)throw Error("useConfirm must be used within ConfirmProvider");return e}},4190:(e,r,o)=>{"use strict";o.d(r,{V:()=>l,p:()=>a});var t=o(997),n=o(6689),s=o(349);let i=(0,n.createContext)(null);function l({children:e}){let[r,o]=(0,n.useState)([]),l=(0,n.useRef)(new Map),a=(0,n.useCallback)(e=>{let r=l.current.get(e);r&&(clearTimeout(r),l.current.delete(e)),o(r=>r.filter(r=>r.id!==e))},[]),c=(0,n.useCallback)((e,r={})=>{let t=`${Date.now()}-${Math.random()}`,n={id:t,message:e,tone:r.tone||"info"};o(e=>[...e,n]);let s=setTimeout(()=>a(t),r.duration??2600);return l.current.set(t,s),t},[a]),d=(0,n.useMemo)(()=>({showToast:c,removeToast:a}),[c,a]);return(0,t.jsxs)(i.Provider,{value:d,children:[e,t.jsx("div",{className:"toast-stack","aria-live":"polite","aria-atomic":"true",children:r.map(e=>(0,t.jsxs)("div",{className:`toast toast--${e.tone}`,children:[t.jsx("span",{className:"toast__icon",children:t.jsx(s.J,{name:"success"===e.tone?"check":"error"===e.tone?"close":"info",size:16})}),t.jsx("span",{className:"toast__message",children:e.message}),t.jsx("button",{type:"button",className:"icon-button icon-button--ghost toast__close","aria-label":"关闭提示",onClick:()=>a(e.id),children:t.jsx(s.J,{name:"close",size:16})})]},e.id))})]})}function a(){let e=(0,n.useContext)(i);if(!e)throw Error("useToast must be used within ToastProvider");return e}},349:(e,r,o)=>{"use strict";o.d(r,{J:()=>i});var t=o(997),n=o(6689);let s={home:t.jsx("path",{d:"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5.5v-6h-5v6H4a1 1 0 0 1-1-1v-9.5Z",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),chart:(0,t.jsxs)(t.Fragment,{children:[t.jsx("path",{d:"M4 20h16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M7 16v-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M12 16V8",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M17 16v-7",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),repeat:(0,t.jsxs)(t.Fragment,{children:[t.jsx("path",{d:"M17 3l4 4-4 4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M3 7h18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M7 21l-4-4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M21 17H3",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),tags:(0,t.
|