@jerry-fd/ui 0.5.8 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/antd-data-filter.js +1 -1
- package/chunk-2CZQBNNA.js +2 -0
- package/chunk-3IQZCZ7C.js +2 -0
- package/{chunk-U66T3F2Z.js → chunk-EGC423Q6.js} +1 -1
- package/chunk-NS7IV62X.js +1 -0
- package/data-table.js +2 -2
- package/index.d.ts +272 -8
- package/index.js +2 -2
- package/package.json +1 -1
- package/styles/index.css +1 -1
- package/theme/shadows.css +8 -0
- package/chunk-3JWTLC47.js +0 -1
- package/chunk-G54QLYD2.js +0 -2
- package/chunk-PICBT6ES.js +0 -2
package/data-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {k as k$1,l as l$1,m as m$2,f as f$1,c as c$1,d,o as o$1,g as g$1,h as h$1,i,q as q$1,r as r$1,e}from'./chunk-
|
|
2
|
-
`).reduce((y,x)=>{let H=x.indexOf(": ");return H!==-1&&(y[x.slice(0,H).toLowerCase()]=x.slice(H+2)),y},{});function O(y){if(b){b.cancel();let x=y instanceof Blob?y.size:y instanceof ArrayBuffer?y.byteLength:typeof y=="string"?y.length:0;r.onDownloadProgress?.({loaded:x,total:x,lengthComputable:true,percentage:100});}r.withResponseHeaders?a({data:y,status:v,headers:Y}):a(y);}if(v>=200&&v<300)if(l==="json"){let y=w;try{let x=y!==""?JSON.parse(y):null;if(!(f?.(x)??!0))throw new D("invalid response");O(x);}catch(x){e(x);}}else f?.(w)??true?O(w):e(new D("invalid response"));else {let y=null;if(!V)if(_.includes("application/json"))try{y=w!==""?JSON.parse(w):null;}catch{}else y=w||null;e(new D("Xhr Request failed",v,y));}g(),m=null;},m.onabort=function(){m&&(b?.cancel(),u?.cancel(),e(new D(D.ECONNABORTED)),g(),m=null);},m.onerror=function(){b?.cancel(),u?.cancel(),e(new D("Network Error",D.ERR_NETWORK)),g(),m=null;},m.ontimeout=function(){b?.cancel(),u?.cancel(),e(new D("Timeout exceeded",D.ETIMEDOUT)),g(),m=null;},typeof p=="object"&&Object.keys(p).forEach(R=>{m?.setRequestHeader(R,p[R]);}),i==null&&m.setRequestHeader("Content-Type",""),l&&l!=="json"&&(m.responseType=l),r.onDownloadProgress&&(b=Ee(r.onDownloadProgress),m.addEventListener("progress",b)),r.onUploadProgress&&m.upload&&(u=Ee(r.onUploadProgress),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",R=>{u?.cancel(),r.onUploadProgress?.({loaded:R.loaded,total:R.loaded,lengthComputable:true,percentage:100});})),r.signal&&(h=()=>{m&&(e(new D(D.REQUEST_CANCELED,D.REQUEST_CANCELED)),m.abort(),m=null);},r.signal.aborted?h():r.signal.addEventListener("abort",h)),m.send(i??null);})}function Ee(t){return e(a=>{t({loaded:a.loaded,total:a.lengthComputable?a.total:0,lengthComputable:a.lengthComputable,percentage:a.lengthComputable&&a.total>0?Math.round(a.loaded/a.total*100):null});},250)}var D=class extends Error{constructor(a,e,o){super(a);b(this,"message");b(this,"code");b(this,"data");this.name="RequestError",this.message=a,e&&(this.code=e),o!==void 0&&(this.data=o);}};b(D,"ETIMEDOUT","ETIMEDOUT"),b(D,"ERR_NETWORK","ERR_NETWORK"),b(D,"ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION_VALUE"),b(D,"ERR_BAD_OPTION","ERR_BAD_OPTION"),b(D,"ECONNABORTED","ECONNABORTED"),b(D,"ERR_FR_TOO_MANY_REDIRECTS","ERR_FR_TOO_MANY_REDIRECTS"),b(D,"ERR_DEPRECATED","ERR_DEPRECATED"),b(D,"ERR_BAD_RESPONSE","ERR_BAD_RESPONSE"),b(D,"ERR_BAD_REQUEST","ERR_BAD_REQUEST"),b(D,"ERR_CANCELED","ERR_CANCELED"),b(D,"REQUEST_CANCELED","REQUEST_CANCELED"),b(D,"ERR_NOT_SUPPORT","ERR_NOT_SUPPORT"),b(D,"ERR_INVALID_URL","ERR_INVALID_URL");var ke=150,yt={ease:[.26,.08,.25,1],duration:.25},Ea={initial:{opacity:0,scale:.95},visible:{opacity:1,scale:1,transition:{...yt,when:"beforeChildren"}},hidden:{opacity:0,scale:1.05,transition:{...yt,when:"afterChildren"}}},Pa={initial:{y:10,opacity:0},visible:{y:0,opacity:1,transition:yt},hidden:{y:-10,opacity:0,transition:yt}};function Ae({containerRef:t,accept:n,acceptHint:a,onFileSelect:e}){let o=k.useRef(null),r=k.useRef(null),[s,c,l]=r$1(false),p=k.useCallback(g=>{g.stopPropagation();let{target:m,relatedTarget:b}=g;m.matches(".data-drop-target, .data-drop-area")&&(!b||!b.matches(".data-drop-target, .data-drop-area"))&&(o.current=window.setTimeout(()=>{l();},ke));},[l]),i=k.useCallback(()=>{o.current&&window.clearTimeout(o.current);},[]),f=k.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{l();},ke);},[l]),h=k.useEffectEvent(async g=>{let{dataTransfer:m}=g,b=[];m.files&&m.files.length>0&&(b=b.concat(Array.from(m.files))),b.length&&(r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{e?.(b);},600));});return mt(()=>{if(!t?.current)return;let g=t.current;return g.addEventListener("dragenter",c),()=>{g.removeEventListener("dragenter",c),o.current&&window.clearTimeout(o.current),r.current&&window.clearTimeout(r.current);}}),jsx(Portal.Root,{container:t?.current,asChild:true,children:jsx(AnimatePresence,{children:s&&jsx(m$1.div,{className:"data-drop-area absolute inset-0 bottom-8 z-10 flex items-center justify-center select-none",onDragLeave:p,onDragOver:i,onDrop:f,initial:"hidden",animate:"visible",exit:"hidden",variants:Ea,children:jsx(ka,{accept:n,acceptHint:a,onFileSelect:h})})})})}function ka({accept:t,acceptHint:n,onFileSelect:a}){let e=Q(),[o,r]=k.useState(false),s=k.useCallback(p=>{if(!t||!p.dataTransfer.items.length){r(false);return}let i=[...p.dataTransfer.items].every(f=>wa(f.type,t));r(!i);},[t]),c$1=k.useCallback(p=>{let{relatedTarget:i,currentTarget:f}=p;i&&f.contains(i)&&p.stopPropagation();},[]),l=k.useCallback(p=>{if(o){p.preventDefault();return}a(p);},[o,a]);return jsxs("div",{"data-dropzone":true,onDragEnter:s,onDrop:l,onDragLeave:c$1,className:"data-drop-target relative flex h-full w-full items-center justify-center rounded-[8px] bg-bg-weak p-16",children:[jsx("svg",{className:c("pointer-events-none absolute top-16 left-16 h-[calc(100%-32px)] w-[calc(100%-32px)] overflow-visible",o?"text-error-base":"text-primary-base"),children:jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",rx:"8",fill:"none",stroke:"currentColor",strokeDasharray:"11, 8",strokeDashoffset:"0",strokeLinecap:"round",strokeWidth:"2",children:jsx("animate",{attributeName:"stroke-dashoffset",from:"0",to:"-19",dur:"0.5s",repeatCount:"indefinite"})})}),jsxs(m$1.div,{className:c("pointer-events-none flex flex-col items-center gap-4",o?"text-error-base":"text-primary-base"),variants:Pa,children:[jsxs("div",{className:"flex flex-col items-center",children:[jsx(FolderUp,{className:"size-48"}),jsx("strong",{className:"text-title-h6",children:e(o?"file_type_rejected":"drop_file_hint")})]}),jsx("span",{className:"text-text-soft",children:n?e("file_support_list",{formats:n}):e("file_support_all")})]})]})}function wa(t,n,a=""){if(!n||n==="*")return true;if(!t&&!a)return false;let e=n.split(",").map(s=>s.trim().toLowerCase()),o=(t||"").toLowerCase(),r=(a||"").toLowerCase();return e.some(s=>{if(s.startsWith("."))return r.endsWith(s);if(s.endsWith("/*")){let c=s.slice(0,-1);return o.startsWith(c)}return o===s})}function Ne(t=""){return `${t}-${Date.now().toString(36)+Math.random().toString(36).slice(2)}`}function _e(t){return t?t.filter(n=>n.filter!==void 0).map(n=>{let{filter:a,dataIndex:e,title:o}=n,r=Array.isArray(e)?e.join("."):e,s=a.displayName??(typeof o=="string"?o:r);return {...a,columnId:r,displayName:s}}):[]}function Le(t){return t.key?String(t.key):Array.isArray(t.dataIndex)?t.dataIndex.join("."):String(t.dataIndex)}function Aa(t){return typeof t=="string"&&t.length>0}function Oe(t){return [Array.isArray(t.dataIndex)?t.dataIndex.join(" "):typeof t.dataIndex=="string"?t.dataIndex:null,typeof t.title=="string"?t.title:null,t.key!==null?String(t.key):null].filter(Aa)}function Be(t,n=22){if(!t)return "";if(t.length<=n)return t;let a=Math.floor(n/2.5),e=t.lastIndexOf("."),o,r;if(e>0?(o=t.substring(0,e),r=t.substring(e)):(o=t,r=""),o.length<=a*2)return t;let s=o.substring(0,a),c=o.substring(o.length-a);return `${s}\u2026${c}${r}`}function Me(t,n){return {type:"import",localTaskId:Ne(n?`import-file-${n}`:"import-file"),status:"pending",progress:0,file:t}}function Fe({tooltip:t,btnProps:n,disabled:a,loading:e,containerRef:o,accept:r,acceptHint:s,requestConfig:c,onBeforeUpload:l}){let p=Q(),i=k.useId(),f=tt(b=>b.addTask),h=tt(b=>b.updateTask),g=a||e,m=k.useCallback(async b=>{if(b=[b[0]],l&&typeof l=="function"){let u=await l(b);if(u===false)return;Array.isArray(u)&&(b=u);}b.forEach((u,R)=>{let v=new AbortController,_={...Me(u,R),abortController:v};if(f(_),!c)throw Error("requestConfig is required.");let{url:V,method:w="POST",fieldName:Y="file",body:O,onSuccess:y,onFailed:x,onUploadProgress:H,...W}=c,M=new FormData;M.append(Y,u),O instanceof FormData?O.forEach((L,$)=>M.append($,L)):O&&Object.keys(O).forEach(L=>{M.append(L,O[L]);}),Pe(V,{...W,onUploadProgress:L=>{H?.(L),h(_.localTaskId,{status:"importing",progress:L.percentage??0});},method:w,body:M,signal:v.signal}).then(L=>{y?.(L),h(_.localTaskId,{status:"done"});}).catch(L=>{x?.(L),h(_.localTaskId,{status:"failed"});});});},[c,l,f,h]);return jsxs(Fragment,{children:[jsx(Ae,{containerRef:o,onFileSelect:m,accept:r,acceptHint:s}),jsx("input",{type:"file",id:i,accept:r,multiple:false,onChange:b=>{let u=Array.from(b.target.files??[]);u.length&&(m(u),b.target.value="");},className:"invisible absolute -top-9999 -left-9999"}),jsx(i$1,{content:t??p("import_tooltip"),children:jsx("label",{htmlFor:i,className:"m-0 inline-flex cursor-pointer p-0 leading-none",children:jsx(P,{variant:"neutral",mode:"stroke",loading:e,startContent:jsx(Upload,{}),disabled:g,className:"pointer-events-none",...n,children:p("data_import")})})})]})}function He({disabled:t,columns:n}){let a=Q(),{alwaysShowingColumns:e}=rt(),[o,r]=k.useState(false),s=Se(),c$1=Z(p=>p.setColumnVisibilityState),l=k.useCallback((p,i)=>{c$1(f=>({...f,[p]:i}));},[c$1]);return jsxs(F,{open:o,onOpenChange:r,children:[jsx(G,{asChild:true,children:jsx(P,{mode:"stroke",variant:"neutral",size:"small",className:c(o&&"active","relative gap-0"),disabled:t,startContent:jsx(Settings2,{}),children:jsx(i$1,{content:a("column_set"),children:jsx("div",{className:"absolute inset-0"})})})}),jsx(H,{align:"end",side:"bottom",arrow:false,className:"w-fit rounded-xl p-0",sideOffset:6,children:jsxs(w,{children:[jsx(x,{autoFocus:true,placeholder:"Search..."}),jsx(z,{children:a("no_results")}),jsx(y,{className:"max-h-256",children:jsx(A,{children:n.map(p=>{let i=Le(p),f=s[i]!==false,h=typeof p.title=="string"&&p.title?.trim()==="",g=h?p.key:p.title;return jsxs(C,{keywords:Oe(p),onSelect:()=>l(i,!f),className:"group flex items-center gap-6",value:i,disabled:e?.includes(i),children:[jsx(Checkbox,{checked:f,tabIndex:-1,className:c("mr-4 opacity-100")}),jsx("span",{className:c(h&&"capitalize"),children:g})]},i)})})})]})})]})}var $e=["data_refresh","size_setting","column_setting","filter_btn"];function Va({btnProps:t,disabled:n,loading:a,onAction:e}){let o=Q();return jsx(P,{variant:"primary",startContent:jsx(Download,{}),loading:a,disabled:n||a,onClick:()=>e({action:"data_export"}),...t,children:o("data_export")})}var Ha={initial:{opacity:0,scale:.85,x:10,originX:1},animate:{opacity:1,scale:1,x:0,originX:1},exit:{opacity:0,scale:.85,x:10,originX:1}},Ua={ease:[.26,.08,.25,1],duration:.25};function Xe({containerRef:t,columns:n,filter:a,items:e=$e,className:o,onAction:r,...s}){let{loading:c$1,syncing:l,exporting:p,disabled:i}=De(),f=k.useMemo(()=>e.map(u=>Xa(u)),[e]),h=k.useMemo(()=>f.filter(u=>!u.hidden),[f]),g=k.useCallback(u=>{r?.(u);},[r]),m=k.useMemo(()=>({disabled:i,loading:c$1,syncing:l,exporting:p,columns:n,onAction:g}),[i,c$1,p,l,n,g]),b=u=>{let R={btnProps:u.btnProps,tooltip:u.tooltip,disabled:i||l||c$1,loading:c$1,onAction:g};switch(u.type){case "data_refresh":return jsx($a,{...R,syncing:l});case "size_setting":return jsx(Re,{...u.btnProps});case "column_setting":return jsx(He,{...u.btnProps,columns:n});case "data_export":return jsx(Va,{...R,loading:p});case "data_import":return jsx(Fe,{...R,loading:p,containerRef:t,requestConfig:u.requestConfig,onBeforeUpload:u.onBeforeUpload,acceptHint:u.acceptHint,accept:u.accept});case "custom":return u.render?.(m);case "filter_btn":return a;default:return null}};return jsx(m$1.div,{"data-slot":"data-table-toolbar",className:c("flex items-center gap-8 transition-opacity",o),...s,children:jsx(AnimatePresence,{mode:"popLayout",initial:false,children:h.map(u=>jsx(m$1.div,{layout:true,variants:Ha,initial:"initial",animate:"animate",exit:"exit",className:"leading-none",transition:Ua,children:b(u)},u.key))})})}function $a({btnProps:t,tooltip:n,disabled:a,loading:e,syncing:o,onAction:r}){let s=Q(),c=n??s("refresh");return jsx(i$1,{content:c,children:jsx(P,{mode:"stroke",variant:"neutral",startContent:jsx(RefreshCw,{}),loading:o||e,disabled:a||e||o,className:"gap-0",onClick:()=>r({action:"data_refresh"}),...t})})}function Xa(t){return typeof t=="string"?{type:t,key:t}:t.type==="custom"?{type:"custom",key:t.key,hidden:t.hidden,render:t.render}:t.type==="data_import"?{type:"data_import",key:t.key??t.type,hidden:t.hidden,btnProps:t.btnProps,tooltip:t.tooltip,accept:t.accept,acceptHint:t.acceptHint,requestConfig:t.requestConfig,onBeforeUpload:t.onBeforeUpload}:{type:t.type,key:t.key??t.type,hidden:t.hidden,btnProps:t.btnProps,tooltip:t.tooltip}}function qe({className:t,value:n,...a}){return jsx(Progress.Root,{"data-slot":"progress",className:c("relative flex h-4 w-full items-center overflow-x-hidden rounded-full bg-bg-soft",t),...a,children:jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:"size-full flex-1 bg-primary-base transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})})}function je({onAction:t,...n}){let a=gt();return jsx(m$1.div,{"data-slot":"data-table-taskbar",className:"w-fit items-center justify-center bg-bg-white select-none",...n,children:a.map(e=>e.type==="import"?jsx(qa,{...e,onSuccess:()=>{t?.({action:"import_done"});}},e.localTaskId):jsx(ja,{...e},e.localTaskId))})}function qa(t){let n=Q(),a=tt(s=>s.removeTask),e=t.status==="failed",o=t.status==="done";return jsxs("div",{className:"flex h-full items-center gap-8",children:[jsxs("span",{className:c("truncate text-md font-medium",o?"text-success-base":e?"text-error-base":"text-text-strong"),children:[n(e?"import_failed":o?"import_done":t.status)," ",Be(t.file.name)]}),jsxs("span",{className:"min-w-34 shrink-0 text-right text-sm text-text-sub",children:[t.progress,"%"]}),jsx(P,{variant:"neutral",mode:"ghost",size:"xsmall",className:"min-w-28 rounded-full px-0",onClick:()=>{t.abortController?.signal.aborted===false&&!e&&!o&&t.abortController?.abort("User canceled"),a(t.localTaskId),o&&t.onSuccess?.(t.localTaskId);},startContent:o?jsx(Check,{className:"text-success-base"}):jsx(Ga,{})})]})}function ja(t){return jsxs("div",{className:"flex w-fit min-w-220 flex-col justify-center gap-6",children:[jsxs("div",{className:"lable flex items-center justify-center gap-12",children:[jsx("span",{className:"font-medium text-text-strong",children:"Task Name"}),jsx("span",{className:"ml-auto text-sm text-text-sub",children:t.progress})]}),jsx(qe,{value:66})]})}function Ga(){return jsxs("svg",{width:"0.8em",height:"0.8em",viewBox:"0 0 12 12",fill:"none",children:[jsx("path",{d:"M10.4854 1.99998L2.00007 10.4853",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M10.4854 10.4844L2.00007 1.99908",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Ge={initial:{y:10,opacity:0},animate:{y:0,opacity:1},exit:{y:-10,opacity:0}},Ye={ease:[.26,.08,.25,1],duration:.25};function Qe({containerRef:t,items:n,filter:a,columns:e,onAction:o}){let r=gt();return jsx(AnimatePresence,{initial:false,mode:"popLayout",children:r.length?jsx(je,{variants:Ge,initial:"initial",animate:"animate",exit:"exit",transition:Ye,onAction:o},"task-bar"):jsx(Xe,{variants:Ge,initial:"initial",animate:"animate",exit:"exit",transition:Ye,containerRef:t,onAction:o,filter:a,columns:e,items:n},"toolbar")})}var Qa=26,Je=44,Ja=200,Za=250,to={},eo=t=>t.querySelector(".ant-table-thead")?.offsetHeight??Je,kt=(t,n)=>{if(!t)return 0;let a=t.querySelectorAll(':scope [data-id^="data-table-card-"]'),e=0;return a.forEach(o=>{let r=o.getAttribute("data-id")==="data-table-card-content";e+=r?0:o.clientHeight;}),document.documentElement.clientHeight-n-window.scrollY-Qa-eo(t)-e-3};function Ze(t,n,{x:a,y:e,...o}=to,r,s,c){let[l,p]=k.useState(e),i=k.useRef(0),f=k.useRef(null);if(k.useLayoutEffect(()=>{if(!s)return;i.current=t.current?.offsetTop??0,f.current||(f.current=d(()=>{i.current=t.current?.offsetTop??0,p(kt(t.current,i.current));},Ja,false,true)),window.addEventListener("resize",f.current);let g=null;return t.current&&(g=new MutationObserver(f.current),g.observe(t.current,{childList:true,subtree:true,attributes:true,attributeFilter:["style","class","hidden"]})),()=>{f.current&&(window.removeEventListener("resize",f.current),f.current.cancel()),g?.disconnect();}},[t,s]),k.useEffect(()=>{if(!s||e!==void 0)return;p(kt(t.current,i.current));let g=setTimeout(()=>{p(kt(t.current,i.current));},Za);return ()=>{clearTimeout(g);}},[e,n,t,s]),!s)return {x:a,y:e,...o};let h=l&&typeof l=="number"?l+(r?Je:0):l;return {x:c&&!a?1280:a??"max-content",y:c&&!h?620:h,...o}}var ro={ease:[.26,.08,.25,1],duration:.3},no={},so={root:"m-0 flex w-full [&_.ant-pagination-total-text]:ps-6 [&_.ant-pagination-total-text]:mr-auto"};function io(t){let{store:n,tabList:a,alwaysShowingColumns:e,...o}=t;return mt(()=>{let r=document.body,s=l=>{l.preventDefault(),l.dataTransfer&&(l.target.closest("[data-dropzone]")?l.dataTransfer.dropEffect="copy":l.dataTransfer.dropEffect="none");},c=l=>{l.preventDefault();};return r.addEventListener("drop",c),r.addEventListener("dragover",s),r.addEventListener("dragenter",s),()=>{r.removeEventListener("drop",c),r.removeEventListener("dragover",s),r.removeEventListener("dragenter",s);}}),jsx(Ce,{store:n,tabList:a,alwaysShowingColumns:e,children:jsx(lo,{...o})})}function lo(t$1){let{ref:n$1,activeTabId:a,variant:e,style:o$1,cardTitle:r$1,cardIcon:s$1,cardDescription:c$1,classNames:l$2,enableTableAutoScrollSizer:p$1,slots:i,columns:f$2,filterColumns:h$1,tableColumns:g$1,defaultFilters:m$3,tableProps:b,paginationProps:u$1,toolbarItems:R,isCustomTab:v,tabRenderCtx:_,customRender:V,onToolbarAction:w,onFiltersChange:Y}=t$1,O=Q(),y=k.useRef(null),x=k.useRef(null),{tabList:H}=rt(),{syncing:W,loading:M}=ve(),L=tt(P=>P.updateTableId),[$,ut]=h({filters:m$3,onFiltersChange:Y});k.useEffect(()=>{L(a);},[a]);let{current:et}=u$1;k.useEffect(()=>{let P=setTimeout(()=>{if(p$1&&!b.virtual){let q=y.current?.querySelector(".ant-table-body");q&&(q.scrollTop=0);}else y.current?.scrollIntoView({block:"start"});},350);return ()=>clearTimeout(P)},[et]);let Dt=$&&$.length!==0,ht=!!(M&&g$1.some(P=>P.skeleton)),St=Math.min(u$1.pageSize,15),vt=k.useCallback(P=>O("pagination_total").replace("{total}",String(P)),[O]),d=Ze(x,`${$?.length}-${a}`,b.scroll,v,p$1,b.virtual),T=ht?jsx(me,{id:`${a}-skeleton`,columns:g$1,size:b.size,count:St,scroll:d}):jsx(Table,{id:`${a}-data-table`,columns:g$1,loading:M,showSorterTooltip:false,...b,scroll:d}),E=!!u$1.total&&(u$1.hideOnSinglePage!==true||u$1.total>u$1.pageSize);return jsxs(l,{ref:f$1([x,n$1]),style:o$1,className:c("relative rounded-[16px]",p$1&&"h-full max-h-[calc(100vh-var(--offset-top))] overflow-hidden",l$2?.root),variant:e,children:[jsxs(m,{"data-id":"data-table-card-header",className:c("data-table-card-header relative min-h-56 grow-0 px-14 pt-12 pb-10",e==="accent"&&"pt-10",H&&H?.length>1&&"border-b-0",l$2?.cardHeader),children:[jsxs(q,{className:c("flex items-center gap-12",l$2?.cardHeading),children:[s$1&&jsx(t,{className:c("size-32 border border-stone-200 bg-stone-100 text-text-sub",!!(r$1&&c$1)&&"size-44 [&_svg]:size-24",l$2?.cardIcon),children:s$1}),r$1&&jsxs("div",{className:c(c$1&&"flex flex-col gap-4"),children:[jsx(s,{children:r$1}),c$1&&jsx(u,{children:c$1})]})]}),jsx(AnimatePresence,{initial:false,children:R!==false&&jsx(r,{as:m$1.div,className:l$2?.cardToolbar,...k$1,children:jsx(Qe,{containerRef:y,items:R,columns:f$2,onAction:w,filter:h$1.length!==0&&jsx(g,{columns:h$1,filters:$,actions:ut,disabled:M||W,align:"end",enableAutoBack:true},`${a}-filter`)})})})]}),i?.cardSummary&&jsx(o,{"data-id":"data-table-card-summary",className:c("grow-0 p-12",l$2?.cardSummary),children:i.cardSummary}),jsx(xe,{"data-id":"data-table-card-tabs",className:"grow-0 p-0"}),jsx(AnimatePresence,{initial:false,children:Dt&&jsx(m$1.div,{"data-id":"data-table-card-filter-values",...l$1,children:jsx(o,{className:"p-0",children:jsx(f,{columns:h$1,filters:$,actions:ut,"data-id":"data-table-active-filters",className:"flex flex-wrap gap-10 px-12 pt-16",disabled:W||M,enableAutoClose:true})})},a)}),jsxs(n,{"data-id":"data-table-card-content",className:c("relative grow p-12 pb-0",(W||M)&&"pointer-events-none",p$1&&"overflow-hidden",l$2?.cardContent),children:[i?.tableSummary&&jsx(o,{"data-id":"data-table-card-table-summary",className:c("grow-0 p-0 pb-12",l$2?.tableSummary),children:i.tableSummary}),jsx(AnimatePresence,{mode:"popLayout",initial:false,children:jsx(m$1.div,{ref:y,className:c("relative w-full",v&&p$1&&"overflow-auto"),style:v&&p$1?{maxHeight:d.y}:no,...m$2,transition:ro,children:v?V?.(_):T},a)})]}),E&&jsx(p,{"data-id":"data-table-card-pager",className:"flex min-h-44 w-full grow-0 items-center justify-between",children:jsx(Pagination,{classNames:so,disabled:M||W,size:"small",showTotal:vt,...u$1})}),i?.cardFooter&&jsx(p,{"data-id":"data-table-card-footer",className:c("grow-0 px-16 py-12",l$2?.cardFooter),children:i.cardFooter})]})}function po(t){let{tabList:n,fireOnMount:a=true,storageKey:e,onTabChange:o,onTableChange:r,onToolbarAction:s}=t,{pagination:c,tableStateStorageKey:l}=c$1(),p=k.useRef(new Set),[i]=k.useState(()=>{let d=be(n[0].id,e??l);for(let T of n)d.getState().initTab(T.id,ea(T)),p.current.add(T.id);return d}),f=k.useRef({onTabChange:o,onTableChange:r,onToolbarAction:s});f.current={onTabChange:o,onTableChange:r,onToolbarAction:s};let h=k.useRef(new Map);h.current=new Map(n.map(d=>[d.id,d]));let g=n.map(d=>d.id).join(),m=k.useRef(true);k.useEffect(()=>{if(m.current){m.current=false;return}for(let d of n)p.current.has(d.id)||(i.getState().initTab(d.id,ea(d)),p.current.add(d.id));},[i,g]);let b=n.map(d=>`${d.id}:${d.loading}:${d.syncing}:${d.exporting}:${d.disabled}`).join();k.useEffect(()=>{let{syncTabExternal:d}=i.getState();for(let T of n)d(T.id,{loading:T.loading,syncing:T.syncing,exporting:T.exporting,disabled:T.disabled});},[i,b]),k.useEffect(()=>{let d=i.getState().stateVersion;return i.subscribe(T=>{if(T.stateVersion===d)return;d=T.stateVersion;let E=T.activeTabId,P=T.tabs[E];if(!P)return;let q={pagination:P.pagination,filters:P.filters,sorter:P.sorter},Nt=T.changeReason;Nt==="tab_switch"&&f.current.onTabChange?.(E),f.current.onTableChange?.(q,Nt,E);})},[i]);let u=k.useRef(false);k.useEffect(()=>{if(u.current||(u.current=true,!a))return;let d=i.getState(),T=d.activeTabId,E=d.tabs[T];E&&f.current.onTableChange?.(E,"mount",T);},[i,a]);let R=useStore(i,d=>d.activeTabId),v=useStore(i,useShallow(d=>d.tabs[d.activeTabId]??B)),_=h.current.get(R),V=_?.type==="custom",w=V?void 0:_,Y=V?_:void 0,{columnVisibility:O,pagination:y}=v,x=w?.columns,H=Y?.filterColumns,W=k.useMemo(()=>x?x.filter(d=>!d.hidden):[],[x]),M=k.useMemo(()=>V?H??[]:_e(x),[V,H,x]),L=k.useMemo(()=>W.filter(d=>{let T=d.key??d.dataIndex;return !T||O[T]!==false}),[W,O]),$=k.useCallback(d=>{let T=i.getState(),E=T.activeTabId,P=T.tabs[E]?.filters??[],q=typeof d=="function"?d(P):d;T.setFilters(E,q);},[i]),ut=k.useCallback((d,T,E,P)=>{let q=i.getState().activeTabId;i.getState().setTableChange(q,E,P);},[i]),et=k.useCallback((d,T)=>{let E=i.getState().activeTabId;i.getState().setPagination(E,d,T);},[i]),Dt=k.useCallback(d=>{let T=i.getState(),E=T.activeTabId,P=T.tabs[E],q={pagination:P?.pagination??B.pagination,filters:P?.filters??B.filters,sorter:P?.sorter??B.sorter};d.tableState=q,f.current.onToolbarAction?.(d,E);},[i]),ht=k.useMemo(()=>({...c,current:y.current,pageSize:y.pageSize,total:_?.total,onChange:et,onShowSizeChange:et}),[c,y,_?.total,et]),St=k.useMemo(()=>({loading:v.loading,syncing:v.syncing,exporting:v.exporting,disabled:v.disabled,filters:v.filters,pagination:y,onFiltersChange:$,onPaginationChange:et}),[v,y,$,et]),vt=k.useMemo(()=>n.map(({id:d,label:T,value:E})=>({id:d,label:T,value:E})),[g]);return {store:i,activeTabId:R,tabList:vt,columns:W,filterColumns:M,tableColumns:L,tableProps:{dataSource:w?.dataSource,rowKey:w?.rowKey,size:v.tableSize,pagination:false,scroll:w?.scroll,virtual:w?.virtual,onChange:ut},paginationProps:ht,defaultFilters:v.filters,onFiltersChange:$,toolbarItems:_?.toolbarItems,onToolbarAction:Dt,isCustomTab:V,customRender:Y?.render,tabRenderCtx:St,enableTableAutoScrollSizer:w?.enableTableAutoScrollSizer??Y?.enableTableAutoScrollSizer??true}}function ea(t){return {pagination:t.defaultPagination,filters:t.defaultFilters,sorter:t.type!=="custom"?t.defaultSorter:void 0,loading:t.loading,syncing:t.syncing,exporting:t.exporting,disabled:t.disabled}}export{$e as DEFAULT_TOOLBAR_ITEMS,io as DataTable,po as useDataTable};
|
|
1
|
+
import {k as k$1,l as l$1,m as m$2,f as f$1,c as c$1,d,o as o$1,g as g$1,h as h$1,i,q as q$1,r as r$1,e}from'./chunk-EGC423Q6.js';import {h,g,f}from'./chunk-NS7IV62X.js';export{b as DATE_FORMATS,d as formatDateRange,c as getDateDisplayFormat,e as getPickerInputFormat}from'./chunk-NS7IV62X.js';import {S,l,m,q,t,c,s,u,r,o,n,p,P,i as i$1,F,G,H,w,x,z,y,A,C}from'./chunk-2CZQBNNA.js';export{S as useTransition}from'./chunk-2CZQBNNA.js';import {b}from'./chunk-M7AD2PUT.js';import {Table,Pagination,Checkbox}from'antd';import {AnimatePresence,m as m$1}from'motion/react';import k from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {create,useStore,createStore}from'zustand';import {useShallow}from'zustand/react/shallow';import {persist}from'zustand/middleware';import {immer}from'zustand/middleware/immer';import {Check,Upload,Download,Settings2,RefreshCw,FolderUp}from'lucide-react';import {Progress,Portal}from'radix-ui';function mt(t){k.useEffect(t,[]);}var la={small:"min-h-22",medium:"min-h-26",middle:"min-h-30",large:"min-h-38"};function me({count:t,size:n="small",classNames:a,columns:e,scroll:o}){let r=k.useCallback(()=>ca(e,la[n]),[e,n]);return jsx(Table,{rowKey:"id",size:n,rowHoverable:false,classNames:a,dataSource:Array.from({length:t},(s,c)=>({id:c})),pagination:false,scroll:o,children:e.map((s,c)=>jsx(Table.Column,{dataIndex:s.dataIndex,width:s.width,title:jsx(o$1,{className:"h-22 w-full animate-none bg-bg-antd"}),render:r,onCell:()=>c===0?{colSpan:e.length}:{colSpan:0}},s.key||s.dataIndex))})}var ue=16;function ca(t,n){let a=t.length,o=`calc((100% - ${ue*(a-1)}px) / ${a})`,r=t.some(s=>s.skeleton==="avatar"||s.skeleton==="double-line");return jsx("div",{className:c("flex items-center",n),style:{gap:`${ue}px`},children:t.map((s,c)=>{let l=s?.key??c;return jsx("div",{style:{width:o},children:da(s.skeleton,r)},l)})})}function da(t,n){switch(t){case "avatar":return jsx(ua,{});case "double-line":return jsx(ma,{});case "group":return jsx(ba,{needAlignment:n});default:return jsx(pa,{needAlignment:n})}}function pa({needAlignment:t}){return jsxs("div",{className:"grid h-full gap-4",children:[t&&jsx("div",{className:"h-12 w-1"}),jsx(o$1,{className:"h-10"})]})}function ua(){return jsxs("div",{className:"flex w-full items-center gap-6",children:[jsx(o$1,{className:"shrink-0 rounded-full",style:{width:"var(--avatar-size, 32px)",height:"var(--avatar-size, 32px)"}}),jsxs("div",{className:"grid flex-1 gap-4",children:[jsx(o$1,{className:"h-12 w-[60%]"}),jsx(o$1,{className:"h-10"})]})]})}function ma(){return jsxs("div",{className:"grid h-full w-full gap-4 py-4",children:[jsx(o$1,{className:"h-12 w-[60%]"}),jsx(o$1,{className:"h-10"})]})}function ba({needAlignment:t}){return jsxs("div",{className:"grid h-full gap-4",children:[t&&jsx("div",{className:"h-12 w-1"}),jsxs("div",{className:"flex w-full items-center gap-4",children:[jsx(o$1,{className:"h-10 w-[20%]"}),jsx(o$1,{className:"h-10 w-[20%]"}),jsx(o$1,{className:"h-10 w-[20%]"}),jsx(o$1,{className:"h-10 w-[20%]"}),jsx(o$1,{className:"h-10 w-[20%]"})]})]})}var B={pagination:{current:1,pageSize:10},filters:[],sorter:{},extra:{action:"paginate",currentDataSource:[]},tableSize:"small",columnVisibility:{},exporting:false,loading:false,syncing:false,disabled:false},J=(t,n)=>(t.tabs[n]||(t.tabs[n]={...B}),t.tabs[n]),ya="APP_UI_TABLE_CONFIG",Ca=(t,n)=>({activeTabId:n,tabs:{},stateVersion:0,changeReason:"mount",setActiveTab:a=>t(e=>{e.activeTabId=a,J(e,a),e.changeReason="tab_switch",e.stateVersion++;}),syncTabExternal:(a,e)=>t(o=>{let r=o.tabs[a];r&&(r.loading=e.loading,r.syncing=e.syncing,r.exporting=e.exporting,r.disabled=e.disabled);}),initTab:(a,e)=>t(o=>{let r=o.tabs[a];r?(e.pagination&&(r.pagination=e.pagination),e.filters&&(r.filters=e.filters),e.sorter&&(r.sorter=e.sorter),r.loading=e.loading,r.syncing=e.syncing,r.exporting=e.exporting,r.disabled=e.disabled):o.tabs[a]={...B,...e};}),setFilters:(a,e)=>t(o=>{let r=J(o,a);r.filters=e,r.pagination.current=1,o.changeReason="filter",o.stateVersion++;}),setPagination:(a,e,o)=>t(r=>{let s=J(r,a);s.pagination={current:e,pageSize:o},r.changeReason="paginate",r.stateVersion++;}),setTableChange:(a,e,o)=>t(r=>{let s=J(r,a);s.sorter=e,s.extra=o,r.changeReason="sort",r.stateVersion++;}),setTableSize:a=>t(e=>{J(e,e.activeTabId).tableSize=a;}),setColumnVisibility:(a,e)=>t(o=>{J(o,o.activeTabId).columnVisibility[a]=e;}),setColumnVisibilityState:a=>t(e=>{let o=J(e,e.activeTabId);o.columnVisibility=typeof a=="function"?a(o.columnVisibility):a;}),toggleColumnVisibility:a=>t(e=>{let o=J(e,e.activeTabId);o.columnVisibility[a]=!o.columnVisibility[a];}),resetTabUIState:a=>t(e=>{let o=a??e.activeTabId,r=e.tabs[o];r&&(r.tableSize=B.tableSize,r.columnVisibility={});})}),be=(t,n=ya)=>createStore()(persist(immer(a=>Ca(a,t)),{name:n,partialize:a=>({tableUIStatus:Object.fromEntries(Object.entries(a.tabs).map(([e,o])=>[e,{tableSize:o.tableSize,columnVisibility:o.columnVisibility}]))}),merge:(a,e)=>{let o=a,r={...e};if(!o?.tableUIStatus)return r;for(let[s,c]of Object.entries(o.tableUIStatus)){let l=r.tabs[s];l?(c.tableSize&&(l.tableSize=c.tableSize),c.columnVisibility&&(l.columnVisibility=c.columnVisibility)):r.tabs[s]={...B,tableSize:c.tableSize??B.tableSize,columnVisibility:c.columnVisibility??{}};}return r}}));var Te=k.createContext(null),ge=["id","action","actions"],ye=k.createContext({alwaysShowingColumns:ge});function Ce({store:t,tabList:n,alwaysShowingColumns:a,children:e}){let o=k.useMemo(()=>({tabList:n,alwaysShowingColumns:a??ge}),[n,a]);return jsx(ye.Provider,{value:o,children:jsx(Te.Provider,{value:t,children:e})})}function ft(){let t=k.useContext(Te);if(!t)throw new Error("useDataTableStoreApi must be used within DataTableProvider");return t}function Z(t){let n=ft();return useStore(n,t)}function De(){let t=ft();return useStore(t,useShallow(n=>n.tabs[n.activeTabId]??B))}function he(){return Z(t=>t.tabs[t.activeTabId]?.tableSize??B.tableSize)}function Se(){let t=ft();return useStore(t,useShallow(n=>n.tabs[n.activeTabId]?.columnVisibility??B.columnVisibility))}function ve(){let t=ft();return useStore(t,useShallow(n=>{let a=n.tabs[n.activeTabId];return {loading:a?.loading??false,syncing:a?.syncing??false,exporting:a?.exporting??false,disabled:a?.disabled??false}}))}function rt(){return k.useContext(ye)}function xe(t){let{tabList:n}=rt(),a=Z(o=>o.activeTabId),e=Z(o=>o.setActiveTab);return !n||!n?.length||n.length===1?null:jsx(o,{...t,children:jsx(g$1,{className:c("w-full"),value:a,onValueChange:e,children:jsx(h$1,{variant:"line",size:"medium",className:"w-full px-12",children:n.map(o=>jsx(i,{value:o.value,className:"px-8 py-8",children:o.label},o.id))})})})}var tt=create((t,n)=>({activeTableId:"",tasks:{},updateTableId:a=>t(()=>({activeTableId:a})),addTask:a=>t(e=>{let o=e.activeTableId;return {tasks:{...e.tasks,[o]:[...e.tasks[o]??[],a]}}}),removeTask:a=>t(e=>{let o=e.activeTableId;return {tasks:{...e.tasks,[o]:(e.tasks[o]??[]).filter(r=>r.localTaskId!==a)}}}),updateTask:(a,e)=>t(o=>{let r=o.activeTableId;return {tasks:{...o.tasks,[r]:(o.tasks[r]??[]).map(s=>s.localTaskId===a?{...s,...e}:s)}}}),getTasks:()=>{let a=n();return a.tasks[a.activeTableId]??[]}})),gt=()=>tt(useShallow(t=>t.tasks[t.activeTableId]??[]));function Re({className:t,...n}){let a=S(),[e,o]=k.useState(false),r=Z(l=>l.setTableSize),s=he(),c$1=k.useMemo(()=>[{groupType:"radio",value:s,options:[{label:a("large"),value:"large"},{label:a("middle"),value:"middle"},{label:a("compact"),value:"small"}],onValueChange:r}],[r,a,s]);return jsx(q$1,{side:"bottom",align:"end",collisionPadding:6,items:c$1,className:"min-w-100",open:e,onOpenChange:o,children:jsxs(P,{mode:"stroke",variant:"neutral",size:"small",className:c("gap-0",t,e&&"active"),...n,children:[jsx(i$1,{content:a("density"),size:"small",children:jsx("div",{className:"absolute inset-0"})}),jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-16",viewBox:"0 0 1024 1024",children:jsx("path",{d:"M840 836H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm0-724H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM610.8 378c6 0 9.4-7 5.7-11.7L515.7 238.7a7.14 7.14 0 0 0-11.3 0L403.6 366.3a7.23 7.23 0 0 0 5.7 11.7H476v268h-62.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V378h62.8z"})})]})})}function Pe(t,n){return new Promise((a,e)=>{let r=Object.assign({},{method:"GET",responseType:"json"},n),{method:s,timeout:c,responseType:l,headers:p,body:i,validateResponse:f}=r,h;function g(){r.signal&&r.signal.removeEventListener("abort",h);}if(r.signal&&r.signal.aborted)return e(new D("Aborted"));let m=new XMLHttpRequest,b=null,u=null;m.open(s.toUpperCase(),t,true),m.timeout=c||0,m.withCredentials=r.withCredentials===true,m.onloadend=function(){if(!m)return;let v=m.status,_=m.getResponseHeader("Content-Type")??"",V=l&&l!=="text"&&l!=="json",w=V?m.response:m.responseText,Y=m.getAllResponseHeaders().split(`\r
|
|
2
|
+
`).reduce((y,x)=>{let H=x.indexOf(": ");return H!==-1&&(y[x.slice(0,H).toLowerCase()]=x.slice(H+2)),y},{});function O(y){if(b){b.cancel();let x=y instanceof Blob?y.size:y instanceof ArrayBuffer?y.byteLength:typeof y=="string"?y.length:0;r.onDownloadProgress?.({loaded:x,total:x,lengthComputable:true,percentage:100});}r.withResponseHeaders?a({data:y,status:v,headers:Y}):a(y);}if(v>=200&&v<300)if(l==="json"){let y=w;try{let x=y!==""?JSON.parse(y):null;if(!(f?.(x)??!0))throw new D("invalid response");O(x);}catch(x){e(x);}}else f?.(w)??true?O(w):e(new D("invalid response"));else {let y=null;if(!V)if(_.includes("application/json"))try{y=w!==""?JSON.parse(w):null;}catch{}else y=w||null;e(new D("Xhr Request failed",v,y));}g(),m=null;},m.onabort=function(){m&&(b?.cancel(),u?.cancel(),e(new D(D.ECONNABORTED)),g(),m=null);},m.onerror=function(){b?.cancel(),u?.cancel(),e(new D("Network Error",D.ERR_NETWORK)),g(),m=null;},m.ontimeout=function(){b?.cancel(),u?.cancel(),e(new D("Timeout exceeded",D.ETIMEDOUT)),g(),m=null;},typeof p=="object"&&Object.keys(p).forEach(R=>{m?.setRequestHeader(R,p[R]);}),i==null&&m.setRequestHeader("Content-Type",""),l&&l!=="json"&&(m.responseType=l),r.onDownloadProgress&&(b=Ee(r.onDownloadProgress),m.addEventListener("progress",b)),r.onUploadProgress&&m.upload&&(u=Ee(r.onUploadProgress),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",R=>{u?.cancel(),r.onUploadProgress?.({loaded:R.loaded,total:R.loaded,lengthComputable:true,percentage:100});})),r.signal&&(h=()=>{m&&(e(new D(D.REQUEST_CANCELED,D.REQUEST_CANCELED)),m.abort(),m=null);},r.signal.aborted?h():r.signal.addEventListener("abort",h)),m.send(i??null);})}function Ee(t){return e(a=>{t({loaded:a.loaded,total:a.lengthComputable?a.total:0,lengthComputable:a.lengthComputable,percentage:a.lengthComputable&&a.total>0?Math.round(a.loaded/a.total*100):null});},250)}var D=class extends Error{constructor(a,e,o){super(a);b(this,"message");b(this,"code");b(this,"data");this.name="RequestError",this.message=a,e&&(this.code=e),o!==void 0&&(this.data=o);}};b(D,"ETIMEDOUT","ETIMEDOUT"),b(D,"ERR_NETWORK","ERR_NETWORK"),b(D,"ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION_VALUE"),b(D,"ERR_BAD_OPTION","ERR_BAD_OPTION"),b(D,"ECONNABORTED","ECONNABORTED"),b(D,"ERR_FR_TOO_MANY_REDIRECTS","ERR_FR_TOO_MANY_REDIRECTS"),b(D,"ERR_DEPRECATED","ERR_DEPRECATED"),b(D,"ERR_BAD_RESPONSE","ERR_BAD_RESPONSE"),b(D,"ERR_BAD_REQUEST","ERR_BAD_REQUEST"),b(D,"ERR_CANCELED","ERR_CANCELED"),b(D,"REQUEST_CANCELED","REQUEST_CANCELED"),b(D,"ERR_NOT_SUPPORT","ERR_NOT_SUPPORT"),b(D,"ERR_INVALID_URL","ERR_INVALID_URL");var ke=150,yt={ease:[.26,.08,.25,1],duration:.25},Ea={initial:{opacity:0,scale:.95},visible:{opacity:1,scale:1,transition:{...yt,when:"beforeChildren"}},hidden:{opacity:0,scale:1.05,transition:{...yt,when:"afterChildren"}}},Pa={initial:{y:10,opacity:0},visible:{y:0,opacity:1,transition:yt},hidden:{y:-10,opacity:0,transition:yt}};function Ae({containerRef:t,accept:n,acceptHint:a,onFileSelect:e}){let o=k.useRef(null),r=k.useRef(null),[s,c,l]=r$1(false),p=k.useCallback(g=>{g.stopPropagation();let{target:m,relatedTarget:b}=g;m.matches(".data-drop-target, .data-drop-area")&&(!b||!b.matches(".data-drop-target, .data-drop-area"))&&(o.current=window.setTimeout(()=>{l();},ke));},[l]),i=k.useCallback(()=>{o.current&&window.clearTimeout(o.current);},[]),f=k.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{l();},ke);},[l]),h=k.useEffectEvent(async g=>{let{dataTransfer:m}=g,b=[];m.files&&m.files.length>0&&(b=b.concat(Array.from(m.files))),b.length&&(r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{e?.(b);},600));});return mt(()=>{if(!t?.current)return;let g=t.current;return g.addEventListener("dragenter",c),()=>{g.removeEventListener("dragenter",c),o.current&&window.clearTimeout(o.current),r.current&&window.clearTimeout(r.current);}}),jsx(Portal.Root,{container:t?.current,asChild:true,children:jsx(AnimatePresence,{children:s&&jsx(m$1.div,{className:"data-drop-area absolute inset-0 bottom-8 z-10 flex items-center justify-center select-none",onDragLeave:p,onDragOver:i,onDrop:f,initial:"hidden",animate:"visible",exit:"hidden",variants:Ea,children:jsx(ka,{accept:n,acceptHint:a,onFileSelect:h})})})})}function ka({accept:t,acceptHint:n,onFileSelect:a}){let e=S(),[o,r]=k.useState(false),s=k.useCallback(p=>{if(!t||!p.dataTransfer.items.length){r(false);return}let i=[...p.dataTransfer.items].every(f=>wa(f.type,t));r(!i);},[t]),c$1=k.useCallback(p=>{let{relatedTarget:i,currentTarget:f}=p;i&&f.contains(i)&&p.stopPropagation();},[]),l=k.useCallback(p=>{if(o){p.preventDefault();return}a(p);},[o,a]);return jsxs("div",{"data-dropzone":true,onDragEnter:s,onDrop:l,onDragLeave:c$1,className:"data-drop-target relative flex h-full w-full items-center justify-center rounded-[8px] bg-bg-weak p-16",children:[jsx("svg",{className:c("pointer-events-none absolute top-16 left-16 h-[calc(100%-32px)] w-[calc(100%-32px)] overflow-visible",o?"text-error-base":"text-primary-base"),children:jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",rx:"8",fill:"none",stroke:"currentColor",strokeDasharray:"11, 8",strokeDashoffset:"0",strokeLinecap:"round",strokeWidth:"2",children:jsx("animate",{attributeName:"stroke-dashoffset",from:"0",to:"-19",dur:"0.5s",repeatCount:"indefinite"})})}),jsxs(m$1.div,{className:c("pointer-events-none flex flex-col items-center gap-4",o?"text-error-base":"text-primary-base"),variants:Pa,children:[jsxs("div",{className:"flex flex-col items-center",children:[jsx(FolderUp,{className:"size-48"}),jsx("strong",{className:"text-title-h6",children:e(o?"file_type_rejected":"drop_file_hint")})]}),jsx("span",{className:"text-text-soft",children:n?e("file_support_list",{formats:n}):e("file_support_all")})]})]})}function wa(t,n,a=""){if(!n||n==="*")return true;if(!t&&!a)return false;let e=n.split(",").map(s=>s.trim().toLowerCase()),o=(t||"").toLowerCase(),r=(a||"").toLowerCase();return e.some(s=>{if(s.startsWith("."))return r.endsWith(s);if(s.endsWith("/*")){let c=s.slice(0,-1);return o.startsWith(c)}return o===s})}function Ne(t=""){return `${t}-${Date.now().toString(36)+Math.random().toString(36).slice(2)}`}function _e(t){return t?t.filter(n=>n.filter!==void 0).map(n=>{let{filter:a,dataIndex:e,title:o}=n,r=Array.isArray(e)?e.join("."):e,s=a.displayName??(typeof o=="string"?o:r);return {...a,columnId:r,displayName:s}}):[]}function Le(t){return t.key?String(t.key):Array.isArray(t.dataIndex)?t.dataIndex.join("."):String(t.dataIndex)}function Aa(t){return typeof t=="string"&&t.length>0}function Oe(t){return [Array.isArray(t.dataIndex)?t.dataIndex.join(" "):typeof t.dataIndex=="string"?t.dataIndex:null,typeof t.title=="string"?t.title:null,t.key!==null?String(t.key):null].filter(Aa)}function Be(t,n=22){if(!t)return "";if(t.length<=n)return t;let a=Math.floor(n/2.5),e=t.lastIndexOf("."),o,r;if(e>0?(o=t.substring(0,e),r=t.substring(e)):(o=t,r=""),o.length<=a*2)return t;let s=o.substring(0,a),c=o.substring(o.length-a);return `${s}\u2026${c}${r}`}function Me(t,n){return {type:"import",localTaskId:Ne(n?`import-file-${n}`:"import-file"),status:"pending",progress:0,file:t}}function Fe({tooltip:t,btnProps:n,disabled:a,loading:e,containerRef:o,accept:r,acceptHint:s,requestConfig:c,onBeforeUpload:l}){let p=S(),i=k.useId(),f=tt(b=>b.addTask),h=tt(b=>b.updateTask),g=a||e,m=k.useCallback(async b=>{if(b=[b[0]],l&&typeof l=="function"){let u=await l(b);if(u===false)return;Array.isArray(u)&&(b=u);}b.forEach((u,R)=>{let v=new AbortController,_={...Me(u,R),abortController:v};if(f(_),!c)throw Error("requestConfig is required.");let{url:V,method:w="POST",fieldName:Y="file",body:O,onSuccess:y,onFailed:x,onUploadProgress:H,...W}=c,M=new FormData;M.append(Y,u),O instanceof FormData?O.forEach((L,$)=>M.append($,L)):O&&Object.keys(O).forEach(L=>{M.append(L,O[L]);}),Pe(V,{...W,onUploadProgress:L=>{H?.(L),h(_.localTaskId,{status:"importing",progress:L.percentage??0});},method:w,body:M,signal:v.signal}).then(L=>{y?.(L),h(_.localTaskId,{status:"done"});}).catch(L=>{x?.(L),h(_.localTaskId,{status:"failed"});});});},[c,l,f,h]);return jsxs(Fragment,{children:[jsx(Ae,{containerRef:o,onFileSelect:m,accept:r,acceptHint:s}),jsx("input",{type:"file",id:i,accept:r,multiple:false,onChange:b=>{let u=Array.from(b.target.files??[]);u.length&&(m(u),b.target.value="");},className:"invisible absolute -top-9999 -left-9999"}),jsx(i$1,{content:t??p("import_tooltip"),children:jsx("label",{htmlFor:i,className:"m-0 inline-flex cursor-pointer p-0 leading-none",children:jsx(P,{variant:"neutral",mode:"stroke",loading:e,startContent:jsx(Upload,{}),disabled:g,className:"pointer-events-none",...n,children:p("data_import")})})})]})}function He({disabled:t,columns:n}){let a=S(),{alwaysShowingColumns:e}=rt(),[o,r]=k.useState(false),s=Se(),c$1=Z(p=>p.setColumnVisibilityState),l=k.useCallback((p,i)=>{c$1(f=>({...f,[p]:i}));},[c$1]);return jsxs(F,{open:o,onOpenChange:r,children:[jsx(G,{asChild:true,children:jsx(P,{mode:"stroke",variant:"neutral",size:"small",className:c(o&&"active","relative gap-0"),disabled:t,startContent:jsx(Settings2,{}),children:jsx(i$1,{content:a("column_set"),children:jsx("div",{className:"absolute inset-0"})})})}),jsx(H,{align:"end",side:"bottom",arrow:false,className:"w-fit rounded-xl p-0",sideOffset:6,children:jsxs(w,{children:[jsx(x,{autoFocus:true,placeholder:"Search..."}),jsx(z,{children:a("no_results")}),jsx(y,{className:"max-h-256",children:jsx(A,{children:n.map(p=>{let i=Le(p),f=s[i]!==false,h=typeof p.title=="string"&&p.title?.trim()==="",g=h?p.key:p.title;return jsxs(C,{keywords:Oe(p),onSelect:()=>l(i,!f),className:"group flex items-center gap-6",value:i,disabled:e?.includes(i),children:[jsx(Checkbox,{checked:f,tabIndex:-1,className:c("mr-4 opacity-100")}),jsx("span",{className:c(h&&"capitalize"),children:g})]},i)})})})]})})]})}var $e=["data_refresh","size_setting","column_setting","filter_btn"];function Va({btnProps:t,disabled:n,loading:a,onAction:e}){let o=S();return jsx(P,{variant:"primary",startContent:jsx(Download,{}),loading:a,disabled:n||a,onClick:()=>e({action:"data_export"}),...t,children:o("data_export")})}var Ha={initial:{opacity:0,scale:.85,x:10,originX:1},animate:{opacity:1,scale:1,x:0,originX:1},exit:{opacity:0,scale:.85,x:10,originX:1}},Ua={ease:[.26,.08,.25,1],duration:.25};function Xe({containerRef:t,columns:n,filter:a,items:e=$e,className:o,onAction:r,...s}){let{loading:c$1,syncing:l,exporting:p,disabled:i}=De(),f=k.useMemo(()=>e.map(u=>Xa(u)),[e]),h=k.useMemo(()=>f.filter(u=>!u.hidden),[f]),g=k.useCallback(u=>{r?.(u);},[r]),m=k.useMemo(()=>({disabled:i,loading:c$1,syncing:l,exporting:p,columns:n,onAction:g}),[i,c$1,p,l,n,g]),b=u=>{let R={btnProps:u.btnProps,tooltip:u.tooltip,disabled:i||l||c$1,loading:c$1,onAction:g};switch(u.type){case "data_refresh":return jsx($a,{...R,syncing:l});case "size_setting":return jsx(Re,{...u.btnProps});case "column_setting":return jsx(He,{...u.btnProps,columns:n});case "data_export":return jsx(Va,{...R,loading:p});case "data_import":return jsx(Fe,{...R,loading:p,containerRef:t,requestConfig:u.requestConfig,onBeforeUpload:u.onBeforeUpload,acceptHint:u.acceptHint,accept:u.accept});case "custom":return u.render?.(m);case "filter_btn":return a;default:return null}};return jsx(m$1.div,{"data-slot":"data-table-toolbar",className:c("flex items-center gap-8 transition-opacity",o),...s,children:jsx(AnimatePresence,{mode:"popLayout",initial:false,children:h.map(u=>jsx(m$1.div,{layout:true,variants:Ha,initial:"initial",animate:"animate",exit:"exit",className:"leading-none",transition:Ua,children:b(u)},u.key))})})}function $a({btnProps:t,tooltip:n,disabled:a,loading:e,syncing:o,onAction:r}){let s=S(),c=n??s("refresh");return jsx(i$1,{content:c,children:jsx(P,{mode:"stroke",variant:"neutral",startContent:jsx(RefreshCw,{}),loading:o||e,disabled:a||e||o,className:"gap-0",onClick:()=>r({action:"data_refresh"}),...t})})}function Xa(t){return typeof t=="string"?{type:t,key:t}:t.type==="custom"?{type:"custom",key:t.key,hidden:t.hidden,render:t.render}:t.type==="data_import"?{type:"data_import",key:t.key??t.type,hidden:t.hidden,btnProps:t.btnProps,tooltip:t.tooltip,accept:t.accept,acceptHint:t.acceptHint,requestConfig:t.requestConfig,onBeforeUpload:t.onBeforeUpload}:{type:t.type,key:t.key??t.type,hidden:t.hidden,btnProps:t.btnProps,tooltip:t.tooltip}}function qe({className:t,value:n,...a}){return jsx(Progress.Root,{"data-slot":"progress",className:c("relative flex h-4 w-full items-center overflow-x-hidden rounded-full bg-bg-soft",t),...a,children:jsx(Progress.Indicator,{"data-slot":"progress-indicator",className:"size-full flex-1 bg-primary-base transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})})}function je({onAction:t,...n}){let a=gt();return jsx(m$1.div,{"data-slot":"data-table-taskbar",className:"w-fit items-center justify-center bg-bg-white select-none",...n,children:a.map(e=>e.type==="import"?jsx(qa,{...e,onSuccess:()=>{t?.({action:"import_done"});}},e.localTaskId):jsx(ja,{...e},e.localTaskId))})}function qa(t){let n=S(),a=tt(s=>s.removeTask),e=t.status==="failed",o=t.status==="done";return jsxs("div",{className:"flex h-full items-center gap-8",children:[jsxs("span",{className:c("truncate text-md font-medium",o?"text-success-base":e?"text-error-base":"text-text-strong"),children:[n(e?"import_failed":o?"import_done":t.status)," ",Be(t.file.name)]}),jsxs("span",{className:"min-w-34 shrink-0 text-right text-sm text-text-sub",children:[t.progress,"%"]}),jsx(P,{variant:"neutral",mode:"ghost",size:"xsmall",className:"min-w-28 rounded-full px-0",onClick:()=>{t.abortController?.signal.aborted===false&&!e&&!o&&t.abortController?.abort("User canceled"),a(t.localTaskId),o&&t.onSuccess?.(t.localTaskId);},startContent:o?jsx(Check,{className:"text-success-base"}):jsx(Ga,{})})]})}function ja(t){return jsxs("div",{className:"flex w-fit min-w-220 flex-col justify-center gap-6",children:[jsxs("div",{className:"lable flex items-center justify-center gap-12",children:[jsx("span",{className:"font-medium text-text-strong",children:"Task Name"}),jsx("span",{className:"ml-auto text-sm text-text-sub",children:t.progress})]}),jsx(qe,{value:66})]})}function Ga(){return jsxs("svg",{width:"0.8em",height:"0.8em",viewBox:"0 0 12 12",fill:"none",children:[jsx("path",{d:"M10.4854 1.99998L2.00007 10.4853",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M10.4854 10.4844L2.00007 1.99908",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Ge={initial:{y:10,opacity:0},animate:{y:0,opacity:1},exit:{y:-10,opacity:0}},Ye={ease:[.26,.08,.25,1],duration:.25};function Qe({containerRef:t,items:n,filter:a,columns:e,onAction:o}){let r=gt();return jsx(AnimatePresence,{initial:false,mode:"popLayout",children:r.length?jsx(je,{variants:Ge,initial:"initial",animate:"animate",exit:"exit",transition:Ye,onAction:o},"task-bar"):jsx(Xe,{variants:Ge,initial:"initial",animate:"animate",exit:"exit",transition:Ye,containerRef:t,onAction:o,filter:a,columns:e,items:n},"toolbar")})}var Qa=26,Je=44,Ja=200,Za=250,to={},eo=t=>t.querySelector(".ant-table-thead")?.offsetHeight??Je,kt=(t,n)=>{if(!t)return 0;let a=t.querySelectorAll(':scope [data-id^="data-table-card-"]'),e=0;return a.forEach(o=>{let r=o.getAttribute("data-id")==="data-table-card-content";e+=r?0:o.clientHeight;}),document.documentElement.clientHeight-n-window.scrollY-Qa-eo(t)-e-3};function Ze(t,n,{x:a,y:e,...o}=to,r,s,c){let[l,p]=k.useState(e),i=k.useRef(0),f=k.useRef(null);if(k.useLayoutEffect(()=>{if(!s)return;i.current=t.current?.offsetTop??0,f.current||(f.current=d(()=>{i.current=t.current?.offsetTop??0,p(kt(t.current,i.current));},Ja,false,true)),window.addEventListener("resize",f.current);let g=null;return t.current&&(g=new MutationObserver(f.current),g.observe(t.current,{childList:true,subtree:true,attributes:true,attributeFilter:["style","class","hidden"]})),()=>{f.current&&(window.removeEventListener("resize",f.current),f.current.cancel()),g?.disconnect();}},[t,s]),k.useEffect(()=>{if(!s||e!==void 0)return;p(kt(t.current,i.current));let g=setTimeout(()=>{p(kt(t.current,i.current));},Za);return ()=>{clearTimeout(g);}},[e,n,t,s]),!s)return {x:a,y:e,...o};let h=l&&typeof l=="number"?l+(r?Je:0):l;return {x:c&&!a?1280:a??"max-content",y:c&&!h?620:h,...o}}var ro={ease:[.26,.08,.25,1],duration:.3},no={},so={root:"m-0 flex w-full [&_.ant-pagination-total-text]:ps-6 [&_.ant-pagination-total-text]:mr-auto"};function io(t){let{store:n,tabList:a,alwaysShowingColumns:e,...o}=t;return mt(()=>{let r=document.body,s=l=>{l.preventDefault(),l.dataTransfer&&(l.target.closest("[data-dropzone]")?l.dataTransfer.dropEffect="copy":l.dataTransfer.dropEffect="none");},c=l=>{l.preventDefault();};return r.addEventListener("drop",c),r.addEventListener("dragover",s),r.addEventListener("dragenter",s),()=>{r.removeEventListener("drop",c),r.removeEventListener("dragover",s),r.removeEventListener("dragenter",s);}}),jsx(Ce,{store:n,tabList:a,alwaysShowingColumns:e,children:jsx(lo,{...o})})}function lo(t$1){let{ref:n$1,activeTabId:a,variant:e,style:o$1,cardTitle:r$1,cardIcon:s$1,cardDescription:c$1,classNames:l$2,enableTableAutoScrollSizer:p$1,slots:i,columns:f$2,filterColumns:h$1,tableColumns:g$1,defaultFilters:m$3,tableProps:b,paginationProps:u$1,toolbarItems:R,isCustomTab:v,tabRenderCtx:_,customRender:V,onToolbarAction:w,onFiltersChange:Y}=t$1,O=S(),y=k.useRef(null),x=k.useRef(null),{tabList:H}=rt(),{syncing:W,loading:M}=ve(),L=tt(P=>P.updateTableId),[$,ut]=h({filters:m$3,onFiltersChange:Y});k.useEffect(()=>{L(a);},[a]);let{current:et}=u$1;k.useEffect(()=>{let P=setTimeout(()=>{if(p$1&&!b.virtual){let q=y.current?.querySelector(".ant-table-body");q&&(q.scrollTop=0);}else y.current?.scrollIntoView({block:"start"});},350);return ()=>clearTimeout(P)},[et]);let Dt=$&&$.length!==0,ht=!!(M&&g$1.some(P=>P.skeleton)),St=Math.min(u$1.pageSize,15),vt=k.useCallback(P=>O("pagination_total").replace("{total}",String(P)),[O]),d=Ze(x,`${$?.length}-${a}`,b.scroll,v,p$1,b.virtual),T=ht?jsx(me,{id:`${a}-skeleton`,columns:g$1,size:b.size,count:St,scroll:d}):jsx(Table,{id:`${a}-data-table`,columns:g$1,loading:M,showSorterTooltip:false,...b,scroll:d}),E=!!u$1.total&&(u$1.hideOnSinglePage!==true||u$1.total>u$1.pageSize);return jsxs(l,{ref:f$1([x,n$1]),style:o$1,className:c("relative rounded-[16px]",p$1&&"h-full max-h-[calc(100vh-var(--offset-top))] overflow-hidden",l$2?.root),variant:e,children:[jsxs(m,{"data-id":"data-table-card-header",className:c("data-table-card-header relative min-h-56 grow-0 px-14 pt-12 pb-10",e==="accent"&&"pt-10",H&&H?.length>1&&"border-b-0",l$2?.cardHeader),children:[jsxs(q,{className:c("flex items-center gap-12",l$2?.cardHeading),children:[s$1&&jsx(t,{className:c("size-32 border border-stone-200 bg-stone-100 text-text-sub",!!(r$1&&c$1)&&"size-44 [&_svg]:size-24",l$2?.cardIcon),children:s$1}),r$1&&jsxs("div",{className:c(c$1&&"flex flex-col gap-4"),children:[jsx(s,{children:r$1}),c$1&&jsx(u,{children:c$1})]})]}),jsx(AnimatePresence,{initial:false,children:R!==false&&jsx(r,{as:m$1.div,className:l$2?.cardToolbar,...k$1,children:jsx(Qe,{containerRef:y,items:R,columns:f$2,onAction:w,filter:h$1.length!==0&&jsx(g,{columns:h$1,filters:$,actions:ut,disabled:M||W,align:"end",enableAutoBack:true},`${a}-filter`)})})})]}),i?.cardSummary&&jsx(o,{"data-id":"data-table-card-summary",className:c("grow-0 p-12",l$2?.cardSummary),children:i.cardSummary}),jsx(xe,{"data-id":"data-table-card-tabs",className:"grow-0 p-0"}),jsx(AnimatePresence,{initial:false,children:Dt&&jsx(m$1.div,{"data-id":"data-table-card-filter-values",...l$1,children:jsx(o,{className:"p-0",children:jsx(f,{columns:h$1,filters:$,actions:ut,"data-id":"data-table-active-filters",className:"flex flex-wrap gap-10 px-12 pt-16",disabled:W||M,enableAutoClose:true})})},a)}),jsxs(n,{"data-id":"data-table-card-content",className:c("relative grow p-12 pb-0",(W||M)&&"pointer-events-none",p$1&&"overflow-hidden",l$2?.cardContent),children:[i?.tableSummary&&jsx(o,{"data-id":"data-table-card-table-summary",className:c("grow-0 p-0 pb-12",l$2?.tableSummary),children:i.tableSummary}),jsx(AnimatePresence,{mode:"popLayout",initial:false,children:jsx(m$1.div,{ref:y,className:c("relative w-full",v&&p$1&&"overflow-auto"),style:v&&p$1?{maxHeight:d.y}:no,...m$2,transition:ro,children:v?V?.(_):T},a)})]}),E&&jsx(p,{"data-id":"data-table-card-pager",className:"flex min-h-44 w-full grow-0 items-center justify-between",children:jsx(Pagination,{classNames:so,disabled:M||W,size:"small",showTotal:vt,...u$1})}),i?.cardFooter&&jsx(p,{"data-id":"data-table-card-footer",className:c("grow-0 px-16 py-12",l$2?.cardFooter),children:i.cardFooter})]})}function po(t){let{tabList:n,fireOnMount:a=true,storageKey:e,onTabChange:o,onTableChange:r,onToolbarAction:s}=t,{pagination:c,tableStateStorageKey:l}=c$1(),p=k.useRef(new Set),[i]=k.useState(()=>{let d=be(n[0].id,e??l);for(let T of n)d.getState().initTab(T.id,ea(T)),p.current.add(T.id);return d}),f=k.useRef({onTabChange:o,onTableChange:r,onToolbarAction:s});f.current={onTabChange:o,onTableChange:r,onToolbarAction:s};let h=k.useRef(new Map);h.current=new Map(n.map(d=>[d.id,d]));let g=n.map(d=>d.id).join(),m=k.useRef(true);k.useEffect(()=>{if(m.current){m.current=false;return}for(let d of n)p.current.has(d.id)||(i.getState().initTab(d.id,ea(d)),p.current.add(d.id));},[i,g]);let b=n.map(d=>`${d.id}:${d.loading}:${d.syncing}:${d.exporting}:${d.disabled}`).join();k.useEffect(()=>{let{syncTabExternal:d}=i.getState();for(let T of n)d(T.id,{loading:T.loading,syncing:T.syncing,exporting:T.exporting,disabled:T.disabled});},[i,b]),k.useEffect(()=>{let d=i.getState().stateVersion;return i.subscribe(T=>{if(T.stateVersion===d)return;d=T.stateVersion;let E=T.activeTabId,P=T.tabs[E];if(!P)return;let q={pagination:P.pagination,filters:P.filters,sorter:P.sorter},Nt=T.changeReason;Nt==="tab_switch"&&f.current.onTabChange?.(E),f.current.onTableChange?.(q,Nt,E);})},[i]);let u=k.useRef(false);k.useEffect(()=>{if(u.current||(u.current=true,!a))return;let d=i.getState(),T=d.activeTabId,E=d.tabs[T];E&&f.current.onTableChange?.(E,"mount",T);},[i,a]);let R=useStore(i,d=>d.activeTabId),v=useStore(i,useShallow(d=>d.tabs[d.activeTabId]??B)),_=h.current.get(R),V=_?.type==="custom",w=V?void 0:_,Y=V?_:void 0,{columnVisibility:O,pagination:y}=v,x=w?.columns,H=Y?.filterColumns,W=k.useMemo(()=>x?x.filter(d=>!d.hidden):[],[x]),M=k.useMemo(()=>V?H??[]:_e(x),[V,H,x]),L=k.useMemo(()=>W.filter(d=>{let T=d.key??d.dataIndex;return !T||O[T]!==false}),[W,O]),$=k.useCallback(d=>{let T=i.getState(),E=T.activeTabId,P=T.tabs[E]?.filters??[],q=typeof d=="function"?d(P):d;T.setFilters(E,q);},[i]),ut=k.useCallback((d,T,E,P)=>{let q=i.getState().activeTabId;i.getState().setTableChange(q,E,P);},[i]),et=k.useCallback((d,T)=>{let E=i.getState().activeTabId;i.getState().setPagination(E,d,T);},[i]),Dt=k.useCallback(d=>{let T=i.getState(),E=T.activeTabId,P=T.tabs[E],q={pagination:P?.pagination??B.pagination,filters:P?.filters??B.filters,sorter:P?.sorter??B.sorter};d.tableState=q,f.current.onToolbarAction?.(d,E);},[i]),ht=k.useMemo(()=>({...c,current:y.current,pageSize:y.pageSize,total:_?.total,onChange:et,onShowSizeChange:et}),[c,y,_?.total,et]),St=k.useMemo(()=>({loading:v.loading,syncing:v.syncing,exporting:v.exporting,disabled:v.disabled,filters:v.filters,pagination:y,onFiltersChange:$,onPaginationChange:et}),[v,y,$,et]),vt=k.useMemo(()=>n.map(({id:d,label:T,value:E})=>({id:d,label:T,value:E})),[g]);return {store:i,activeTabId:R,tabList:vt,columns:W,filterColumns:M,tableColumns:L,tableProps:{dataSource:w?.dataSource,rowKey:w?.rowKey,size:v.tableSize,pagination:false,scroll:w?.scroll,virtual:w?.virtual,onChange:ut},paginationProps:ht,defaultFilters:v.filters,onFiltersChange:$,toolbarItems:_?.toolbarItems,onToolbarAction:Dt,isCustomTab:V,customRender:Y?.render,tabRenderCtx:St,enableTableAutoScrollSizer:w?.enableTableAutoScrollSizer??Y?.enableTableAutoScrollSizer??true}}function ea(t){return {pagination:t.defaultPagination,filters:t.defaultFilters,sorter:t.type!=="custom"?t.defaultSorter:void 0,loading:t.loading,syncing:t.syncing,exporting:t.exporting,disabled:t.disabled}}export{$e as DEFAULT_TOOLBAR_ITEMS,io as DataTable,po as useDataTable};
|
package/index.d.ts
CHANGED
|
@@ -945,6 +945,265 @@ type InternalDrawerProps = 'open' | 'onOpenChange' | 'trigger' | 'children';
|
|
|
945
945
|
type UseDrawerOptions = Omit<DrawerProps, InternalDrawerProps>;
|
|
946
946
|
declare function useDrawer<TData = unknown>(options?: UseDrawerOptions): readonly [DrawerProps, TData | null, (record: TData) => void, () => void];
|
|
947
947
|
|
|
948
|
+
declare const fancyButtonVariants: tailwind_variants.TVReturnType<{
|
|
949
|
+
variant: {
|
|
950
|
+
neutral: {
|
|
951
|
+
root: string;
|
|
952
|
+
};
|
|
953
|
+
primary: {
|
|
954
|
+
root: string;
|
|
955
|
+
};
|
|
956
|
+
error: {
|
|
957
|
+
root: string;
|
|
958
|
+
};
|
|
959
|
+
basic: {
|
|
960
|
+
root: string[];
|
|
961
|
+
};
|
|
962
|
+
};
|
|
963
|
+
size: {
|
|
964
|
+
large: {
|
|
965
|
+
root: string;
|
|
966
|
+
contentIcon: string;
|
|
967
|
+
};
|
|
968
|
+
medium: {
|
|
969
|
+
root: string;
|
|
970
|
+
contentIcon: string;
|
|
971
|
+
};
|
|
972
|
+
small: {
|
|
973
|
+
root: string;
|
|
974
|
+
contentIcon: string;
|
|
975
|
+
};
|
|
976
|
+
xsmall: {
|
|
977
|
+
root: string;
|
|
978
|
+
contentIcon: string;
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
loading: {
|
|
982
|
+
true: {
|
|
983
|
+
root: string;
|
|
984
|
+
};
|
|
985
|
+
};
|
|
986
|
+
}, {
|
|
987
|
+
root: string[];
|
|
988
|
+
contentIcon: string;
|
|
989
|
+
overlay: string;
|
|
990
|
+
}, undefined, {
|
|
991
|
+
variant: {
|
|
992
|
+
neutral: {
|
|
993
|
+
root: string;
|
|
994
|
+
};
|
|
995
|
+
primary: {
|
|
996
|
+
root: string;
|
|
997
|
+
};
|
|
998
|
+
error: {
|
|
999
|
+
root: string;
|
|
1000
|
+
};
|
|
1001
|
+
basic: {
|
|
1002
|
+
root: string[];
|
|
1003
|
+
};
|
|
1004
|
+
};
|
|
1005
|
+
size: {
|
|
1006
|
+
large: {
|
|
1007
|
+
root: string;
|
|
1008
|
+
contentIcon: string;
|
|
1009
|
+
};
|
|
1010
|
+
medium: {
|
|
1011
|
+
root: string;
|
|
1012
|
+
contentIcon: string;
|
|
1013
|
+
};
|
|
1014
|
+
small: {
|
|
1015
|
+
root: string;
|
|
1016
|
+
contentIcon: string;
|
|
1017
|
+
};
|
|
1018
|
+
xsmall: {
|
|
1019
|
+
root: string;
|
|
1020
|
+
contentIcon: string;
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
loading: {
|
|
1024
|
+
true: {
|
|
1025
|
+
root: string;
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
}, {
|
|
1029
|
+
root: string[];
|
|
1030
|
+
contentIcon: string;
|
|
1031
|
+
overlay: string;
|
|
1032
|
+
}, tailwind_variants.TVReturnType<{
|
|
1033
|
+
variant: {
|
|
1034
|
+
neutral: {
|
|
1035
|
+
root: string;
|
|
1036
|
+
};
|
|
1037
|
+
primary: {
|
|
1038
|
+
root: string;
|
|
1039
|
+
};
|
|
1040
|
+
error: {
|
|
1041
|
+
root: string;
|
|
1042
|
+
};
|
|
1043
|
+
basic: {
|
|
1044
|
+
root: string[];
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
size: {
|
|
1048
|
+
large: {
|
|
1049
|
+
root: string;
|
|
1050
|
+
contentIcon: string;
|
|
1051
|
+
};
|
|
1052
|
+
medium: {
|
|
1053
|
+
root: string;
|
|
1054
|
+
contentIcon: string;
|
|
1055
|
+
};
|
|
1056
|
+
small: {
|
|
1057
|
+
root: string;
|
|
1058
|
+
contentIcon: string;
|
|
1059
|
+
};
|
|
1060
|
+
xsmall: {
|
|
1061
|
+
root: string;
|
|
1062
|
+
contentIcon: string;
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
loading: {
|
|
1066
|
+
true: {
|
|
1067
|
+
root: string;
|
|
1068
|
+
};
|
|
1069
|
+
};
|
|
1070
|
+
}, {
|
|
1071
|
+
root: string[];
|
|
1072
|
+
contentIcon: string;
|
|
1073
|
+
overlay: string;
|
|
1074
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
1075
|
+
declare const FancyButtonRoot: React$1.ForwardRefExoticComponent<VariantProps<tailwind_variants.TVReturnType<{
|
|
1076
|
+
variant: {
|
|
1077
|
+
neutral: {
|
|
1078
|
+
root: string;
|
|
1079
|
+
};
|
|
1080
|
+
primary: {
|
|
1081
|
+
root: string;
|
|
1082
|
+
};
|
|
1083
|
+
error: {
|
|
1084
|
+
root: string;
|
|
1085
|
+
};
|
|
1086
|
+
basic: {
|
|
1087
|
+
root: string[];
|
|
1088
|
+
};
|
|
1089
|
+
};
|
|
1090
|
+
size: {
|
|
1091
|
+
large: {
|
|
1092
|
+
root: string;
|
|
1093
|
+
contentIcon: string;
|
|
1094
|
+
};
|
|
1095
|
+
medium: {
|
|
1096
|
+
root: string;
|
|
1097
|
+
contentIcon: string;
|
|
1098
|
+
};
|
|
1099
|
+
small: {
|
|
1100
|
+
root: string;
|
|
1101
|
+
contentIcon: string;
|
|
1102
|
+
};
|
|
1103
|
+
xsmall: {
|
|
1104
|
+
root: string;
|
|
1105
|
+
contentIcon: string;
|
|
1106
|
+
};
|
|
1107
|
+
};
|
|
1108
|
+
loading: {
|
|
1109
|
+
true: {
|
|
1110
|
+
root: string;
|
|
1111
|
+
};
|
|
1112
|
+
};
|
|
1113
|
+
}, {
|
|
1114
|
+
root: string[];
|
|
1115
|
+
contentIcon: string;
|
|
1116
|
+
overlay: string;
|
|
1117
|
+
}, undefined, {
|
|
1118
|
+
variant: {
|
|
1119
|
+
neutral: {
|
|
1120
|
+
root: string;
|
|
1121
|
+
};
|
|
1122
|
+
primary: {
|
|
1123
|
+
root: string;
|
|
1124
|
+
};
|
|
1125
|
+
error: {
|
|
1126
|
+
root: string;
|
|
1127
|
+
};
|
|
1128
|
+
basic: {
|
|
1129
|
+
root: string[];
|
|
1130
|
+
};
|
|
1131
|
+
};
|
|
1132
|
+
size: {
|
|
1133
|
+
large: {
|
|
1134
|
+
root: string;
|
|
1135
|
+
contentIcon: string;
|
|
1136
|
+
};
|
|
1137
|
+
medium: {
|
|
1138
|
+
root: string;
|
|
1139
|
+
contentIcon: string;
|
|
1140
|
+
};
|
|
1141
|
+
small: {
|
|
1142
|
+
root: string;
|
|
1143
|
+
contentIcon: string;
|
|
1144
|
+
};
|
|
1145
|
+
xsmall: {
|
|
1146
|
+
root: string;
|
|
1147
|
+
contentIcon: string;
|
|
1148
|
+
};
|
|
1149
|
+
};
|
|
1150
|
+
loading: {
|
|
1151
|
+
true: {
|
|
1152
|
+
root: string;
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
}, {
|
|
1156
|
+
root: string[];
|
|
1157
|
+
contentIcon: string;
|
|
1158
|
+
overlay: string;
|
|
1159
|
+
}, tailwind_variants.TVReturnType<{
|
|
1160
|
+
variant: {
|
|
1161
|
+
neutral: {
|
|
1162
|
+
root: string;
|
|
1163
|
+
};
|
|
1164
|
+
primary: {
|
|
1165
|
+
root: string;
|
|
1166
|
+
};
|
|
1167
|
+
error: {
|
|
1168
|
+
root: string;
|
|
1169
|
+
};
|
|
1170
|
+
basic: {
|
|
1171
|
+
root: string[];
|
|
1172
|
+
};
|
|
1173
|
+
};
|
|
1174
|
+
size: {
|
|
1175
|
+
large: {
|
|
1176
|
+
root: string;
|
|
1177
|
+
contentIcon: string;
|
|
1178
|
+
};
|
|
1179
|
+
medium: {
|
|
1180
|
+
root: string;
|
|
1181
|
+
contentIcon: string;
|
|
1182
|
+
};
|
|
1183
|
+
small: {
|
|
1184
|
+
root: string;
|
|
1185
|
+
contentIcon: string;
|
|
1186
|
+
};
|
|
1187
|
+
xsmall: {
|
|
1188
|
+
root: string;
|
|
1189
|
+
contentIcon: string;
|
|
1190
|
+
};
|
|
1191
|
+
};
|
|
1192
|
+
loading: {
|
|
1193
|
+
true: {
|
|
1194
|
+
root: string;
|
|
1195
|
+
};
|
|
1196
|
+
};
|
|
1197
|
+
}, {
|
|
1198
|
+
root: string[];
|
|
1199
|
+
contentIcon: string;
|
|
1200
|
+
overlay: string;
|
|
1201
|
+
}, undefined, unknown, unknown, undefined>>> & Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "prefix"> & {
|
|
1202
|
+
asChild?: boolean;
|
|
1203
|
+
startContent?: React$1.ReactNode;
|
|
1204
|
+
endContent?: React$1.ReactNode;
|
|
1205
|
+
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1206
|
+
|
|
948
1207
|
type CopyableTextProps = Omit<ButtonSharedProps, 'loading'> & {
|
|
949
1208
|
className?: string;
|
|
950
1209
|
content: string;
|
|
@@ -1624,18 +1883,21 @@ type UIViewTransitionProps = {
|
|
|
1624
1883
|
/** 应用在实际动画视图层上的类名。 */
|
|
1625
1884
|
viewClassName?: string;
|
|
1626
1885
|
children: React__default.ReactNode;
|
|
1627
|
-
/**
|
|
1886
|
+
/** 是否让退出视图变暗,仅对支持该效果的动画生效;在容器高度固定的场景下体验最佳。 */
|
|
1628
1887
|
dimmed?: boolean;
|
|
1888
|
+
/** 是否启用内容高度测量并驱动容器高度过渡;固定尺寸场景可关闭。 */
|
|
1889
|
+
measureHeight?: boolean;
|
|
1629
1890
|
/** 视图切换过程中是否冻结点击事件,动画完成后自动恢复。 */
|
|
1630
1891
|
lockPointerDuringTransition?: boolean;
|
|
1631
1892
|
};
|
|
1632
1893
|
declare const UIViewTransition: React__default.ForwardRefExoticComponent<UIViewTransitionProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
1633
1894
|
|
|
1634
1895
|
type UIMorphingModalLength = number | string;
|
|
1635
|
-
type
|
|
1896
|
+
type UIMorphingModalSize = {
|
|
1636
1897
|
width: UIMorphingModalLength;
|
|
1637
1898
|
height: UIMorphingModalLength;
|
|
1638
1899
|
};
|
|
1900
|
+
type UIMorphingModalInputSize = UIMorphingModalLength | UIMorphingModalSize;
|
|
1639
1901
|
type UIMorphingModalContentAnimationState = 'entered' | 'exited';
|
|
1640
1902
|
type UIMorphingModalProps = {
|
|
1641
1903
|
/** 是否打开弹窗 */
|
|
@@ -1651,12 +1913,14 @@ type UIMorphingModalProps = {
|
|
|
1651
1913
|
containerClassName?: string;
|
|
1652
1914
|
/** 始终显示在弹窗中的视觉锚点内容 */
|
|
1653
1915
|
visual?: React$1.ReactNode;
|
|
1654
|
-
/**
|
|
1655
|
-
defaultSize?:
|
|
1656
|
-
/**
|
|
1657
|
-
expandedSize?:
|
|
1916
|
+
/** 弹窗默认的紧凑尺寸,支持单值或 `{ width, height }`。 */
|
|
1917
|
+
defaultSize?: UIMorphingModalInputSize;
|
|
1918
|
+
/** 弹窗展开后的宽高,支持单值或 `{ width, height }`,并可传入 `'auto'` 以跟随内容尺寸。 */
|
|
1919
|
+
expandedSize?: UIMorphingModalInputSize;
|
|
1658
1920
|
/** 预留的确认回调 */
|
|
1659
1921
|
onOk?: () => void;
|
|
1922
|
+
/** 点击 backdrop 时的回调,仅在当前动画序列结束后才会触发,由外部决定如何处理。 */
|
|
1923
|
+
onBackdropClick?: (event: React$1.MouseEvent<HTMLDivElement>) => void;
|
|
1660
1924
|
/** 关闭动画完成后的回调 */
|
|
1661
1925
|
onCloseComplete?: () => void;
|
|
1662
1926
|
/** 内容显隐动画完成后的回调 */
|
|
@@ -1664,7 +1928,7 @@ type UIMorphingModalProps = {
|
|
|
1664
1928
|
/** 尺寸展开状态变化动画完成后的回调 */
|
|
1665
1929
|
onExpandedChangeComplete?: (expanded: boolean) => void;
|
|
1666
1930
|
};
|
|
1667
|
-
declare function UIMorphingModal({ open, loading, visual, backgroundViewRef, children, className, containerClassName, defaultSize, expandedSize, onCloseComplete, onContentAnimationComplete, onExpandedChangeComplete, }: UIMorphingModalProps): react_jsx_runtime.JSX.Element;
|
|
1931
|
+
declare function UIMorphingModal({ open, loading, visual, backgroundViewRef, children, className, containerClassName, defaultSize, expandedSize, onBackdropClick, onCloseComplete, onContentAnimationComplete, onExpandedChangeComplete, }: UIMorphingModalProps): react_jsx_runtime.JSX.Element;
|
|
1668
1932
|
|
|
1669
1933
|
/** Allowed screen identifier type for UIScreen. */
|
|
1670
1934
|
type UIScreenValue = string | number;
|
|
@@ -1732,4 +1996,4 @@ declare const useFlag: (initial?: boolean) => [boolean, NoneToVoidFunction, None
|
|
|
1732
1996
|
|
|
1733
1997
|
declare const useToggle: (initial?: boolean) => [boolean, NoneToVoidFunction];
|
|
1734
1998
|
|
|
1735
|
-
export { AnimationCard, type AnimationCardProps, type AnimationName$1 as AnimationName, index as Avatar, Badge, type BadgeProps, ButtonSharedProps, card as Card, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPanel, command as Command, CopyableText, type CopyableTextProps, type DebouncedFunction, Drawer, type DrawerProps, DropdownMenu, type DropdownMenuItemProps, type DropdownMenuProps, type DropdownMenuVariants, HoverCard, type MenuPropBase, PopConfirm, type PopConfirmProps, popover as Popover, PopoverPreset, type PopoverPresetProps, type Scheduler, ScrollArea, Skeleton, Spinner, StateSwitcher, Swap, Switch, tabs as Tabs, type ThrottledFunction, Tooltip, TooltipArrow, TooltipProvider, TooltipRoot, TooltipTrigger, UIMorphingModal, type UIMorphingModalContentAnimationState, type UIMorphingModalProps, UIProvider, UIScreen, type UIScreenControls, type UIScreenNavigateFn, type UIScreenNavigateOptions, type UIScreenProps, type UIScreenValue, type UIScreenViewProps, UIViewTransition, type UIViewTransitionProps, type UseDrawerOptions, cn, compact, debounce, dropdownMenuStyles, findOption, formatCurrency, formatIntegerCompact, formatNumber, getFirstLetters, mergeRefs, omit, pick, throttle, tooltipVariants, tv, twMergeConfig, unique, useDisableContentMenu, useDrawer, useFlag, useForceUpdate, usePrevious, useToggle, useUIScreen };
|
|
1999
|
+
export { AnimationCard, type AnimationCardProps, type AnimationName$1 as AnimationName, index as Avatar, Badge, type BadgeProps, ButtonSharedProps, card as Card, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPanel, command as Command, CopyableText, type CopyableTextProps, type DebouncedFunction, Drawer, type DrawerProps, DropdownMenu, type DropdownMenuItemProps, type DropdownMenuProps, type DropdownMenuVariants, FancyButtonRoot as FancyButton, HoverCard, type MenuPropBase, PopConfirm, type PopConfirmProps, popover as Popover, PopoverPreset, type PopoverPresetProps, type Scheduler, ScrollArea, Skeleton, Spinner, StateSwitcher, Swap, Switch, tabs as Tabs, type ThrottledFunction, Tooltip, TooltipArrow, TooltipProvider, TooltipRoot, TooltipTrigger, UIMorphingModal, type UIMorphingModalContentAnimationState, type UIMorphingModalProps, UIProvider, UIScreen, type UIScreenControls, type UIScreenNavigateFn, type UIScreenNavigateOptions, type UIScreenProps, type UIScreenValue, type UIScreenViewProps, UIViewTransition, type UIViewTransitionProps, type UseDrawerOptions, cn, compact, debounce, dropdownMenuStyles, fancyButtonVariants, findOption, formatCurrency, formatIntegerCompact, formatNumber, getFirstLetters, mergeRefs, omit, pick, throttle, tooltipVariants, tv, twMergeConfig, unique, useDisableContentMenu, useDrawer, useFlag, useForceUpdate, usePrevious, useToggle, useUIScreen };
|