14 lines
5.3 KiB
JavaScript
14 lines
5.3 KiB
JavaScript
import{r as s,j as e,R as y,L as j}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{S as N}from"./arrow-up-Ba39LAbN.js";const k=n=>s.createElement("svg",{className:"fill-current",width:"1em",height:"1em",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},s.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.31462 10.3761C5.45194 10.5293 5.65136 10.6257 5.87329 10.6257C5.8736 10.6257 5.8739 10.6257 5.87421 10.6257C6.0663 10.6259 6.25845 10.5527 6.40505 10.4062L9.40514 7.4082C9.69814 7.11541 9.69831 6.64054 9.40552 6.34754C9.11273 6.05454 8.63785 6.05438 8.34486 6.34717L6.62329 8.06753L6.62329 1.875C6.62329 1.46079 6.28751 1.125 5.87329 1.125C5.45908 1.125 5.12329 1.46079 5.12329 1.875L5.12329 8.06422L3.40516 6.34719C3.11218 6.05439 2.6373 6.05454 2.3445 6.34752C2.0517 6.64051 2.05185 7.11538 2.34484 7.40818L5.31462 10.3761Z",fill:""})),C=({children:n,content:i,placement:c="top",className:a="",delay:g=200})=>{const[f,r]=s.useState(!1),[h,v]=s.useState({top:0,left:0}),b=s.useRef(null),x=s.useRef(null),t=s.useRef(),d={top:"bottom-full left-1/2 mb-2 -translate-x-1/2 before:top-full before:left-1/2 before:-translate-x-1/2 before:-mt-1 before:border-t-gray-900",bottom:"top-full left-1/2 mt-2 -translate-x-1/2 before:bottom-full before:left-1/2 before:-translate-x-1/2 before:-mb-1 before:border-b-gray-900",left:"right-full top-1/2 mr-2 -translate-y-1/2 before:left-full before:top-1/2 before:-translate-y-1/2 before:-ml-1 before:border-l-gray-900",right:"left-full top-1/2 ml-2 -translate-y-1/2 before:right-full before:top-1/2 before:-translate-y-1/2 before:-mr-1 before:border-r-gray-900"},l=()=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{r(!0)},g)},m=()=>{t.current&&clearTimeout(t.current),r(!1)};return s.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]),e.jsxs("div",{ref:x,className:`relative inline-flex ${a}`,style:{zIndex:1},onMouseEnter:l,onMouseLeave:m,children:[n,f&&e.jsx("div",{ref:b,className:`
|
|
absolute z-[99999] px-3 py-2 text-xs font-medium text-white bg-gray-900 rounded-lg
|
|
opacity-100 pointer-events-none transition-opacity duration-200
|
|
whitespace-normal max-w-xs shadow-lg
|
|
before:absolute before:border-4 before:border-transparent before:content-['']
|
|
${d[c]}
|
|
`,style:{zIndex:99999},onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:typeof i=="string"?e.jsx("span",{children:i}):e.jsx("div",{className:"text-white",children:i})})]})},E={blue:{bg:"bg-blue-50 dark:bg-blue-500/10",hover:"hover:bg-blue-100 dark:hover:bg-blue-500/20",border:"bg-brand-500",icon:"text-brand-500"},green:{bg:"bg-green-50 dark:bg-green-500/10",hover:"hover:bg-green-100 dark:hover:bg-green-500/20",border:"bg-success-500",icon:"text-success-500"},orange:{bg:"bg-amber-50 dark:bg-amber-500/10",hover:"hover:bg-amber-100 dark:hover:bg-amber-500/20",border:"bg-warning-500",icon:"text-warning-500"},purple:{bg:"bg-purple-50 dark:bg-purple-500/10",hover:"hover:bg-purple-100 dark:hover:bg-purple-500/20",border:"bg-purple-500",icon:"text-purple-500"},red:{bg:"bg-red-50 dark:bg-red-500/10",hover:"hover:bg-red-100 dark:hover:bg-red-500/20",border:"bg-error-500",icon:"text-error-500"},success:{bg:"bg-green-50 dark:bg-green-500/10",hover:"hover:bg-green-100 dark:hover:bg-green-500/20",border:"bg-success-500",icon:"text-success-500"}};function R({title:n,value:i,subtitle:c,trend:a,icon:g,accentColor:f,href:r,onClick:h,tooltip:v,details:b,className:x=""}){const[t,d]=s.useState(!1),l=E[f],m=o=>typeof o=="number"?o.toLocaleString():o,p=v||(b?e.jsx("div",{className:"space-y-1",children:b.map((o,w)=>e.jsxs("div",{className:"flex justify-between gap-4 text-xs",children:[e.jsxs("span",{className:"text-gray-300",children:[o.label,":"]}),e.jsx("span",{className:"font-medium text-white",children:o.value})]},w))}):null),u=e.jsxs("div",{className:`
|
|
rounded-2xl border border-gray-200 bg-white p-5
|
|
dark:border-gray-800 dark:bg-white/[0.03] md:p-6
|
|
hover:shadow-lg transition-all cursor-pointer group
|
|
relative overflow-hidden
|
|
${x}
|
|
`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:h,children:[e.jsx("div",{className:`absolute left-0 top-0 bottom-0 w-1 ${l.border}`}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:n}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("h4",{className:"font-bold text-gray-800 text-title-sm dark:text-white/90",children:m(i)}),a!==void 0&&a!==0&&e.jsxs("div",{className:`flex items-center gap-1 text-xs ${a>0?"text-success-500":"text-error-500"}`,children:[a>0?e.jsx(N,{className:"size-3"}):e.jsx(k,{className:"size-3"}),e.jsx("span",{children:Math.abs(a)})]})]}),c&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:c})]}),e.jsx("div",{className:`flex items-center justify-center w-12 h-12 rounded-xl ${l.bg} ${l.hover} transition-colors flex-shrink-0`,children:y.cloneElement(g,{className:`${l.icon} size-6`})})]}),t&&p&&e.jsx("div",{className:"absolute inset-0 bg-black/5 dark:bg-white/5 rounded-2xl"})]});if(p){const o=r?e.jsx(j,{to:r,className:"block",children:u}):u;return e.jsx(C,{content:p,placement:"top",children:o})}return r?e.jsx(j,{to:r,children:u}):u}export{R as E};
|