@cyber-harbour/ui 2.1.26-beta.6 → 2.2.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/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -169,12 +169,13 @@ self.onmessage = async (e) => {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
`,tt=null,rt=null;function zt(){if(!tt){let r=new Blob([fn],{type:"application/javascript"});rt=URL.createObjectURL(r),tt=new Worker(rt);}return tt}chunkQQ6EL7I4_js.a(zt,"getSearchWorker");function Tr(){tt?.terminate(),tt=null,rt&&(URL.revokeObjectURL(rt),rt=null);}chunkQQ6EL7I4_js.a(Tr,"terminateSearchWorker");function Ir(r,o){let[n,a]=dr.useState(""),[p,u]=dr.useState("idle"),[m,k]=dr.useState(null),[M,C]=dr.useState({searched:0,total:0,found:0}),D=dr.useRef(null),y=dr.useCallback(t=>{if(!r||o===0)return;if(!t.trim()){k(null),u("idle"),C({searched:0,total:0,found:0});return}u("searching"),C({searched:0,total:o,found:0});let z=zt();z.onmessage=w=>{let{type:d}=w.data;d==="progress"&&C({searched:w.data.searched,total:w.data.total,found:w.data.found}),d==="done"&&(k(w.data.matchedIndices),u("done")),d==="cancelled"&&u("idle"),d==="error"&&(u("idle"),console.error("Search worker error:",w.data.message));},z.postMessage({type:"cancel"}),z.postMessage({type:"search",sessionId:r,query:t,chunkCount:o,chunkSize:1e3});},[r,o]),I=dr.useCallback(t=>{a(t),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{y(t);},300);},[y]),O=dr.useCallback(()=>{a(""),k(null),u("idle"),C({searched:0,total:0,found:0}),zt().postMessage({type:"cancel"});},[]);return dr.useEffect(()=>()=>{D.current&&clearTimeout(D.current),Tr();},[]),{query:n,onQueryChange:I,clearSearch:O,searchState:p,matchedIndices:m,searchProgress:M}}chunkQQ6EL7I4_js.a(Ir,"useCsvSearch");var kn={loading:"Loading...",rows:"rows",rowsIncomplete:"rows (incomplete)",retry:"Retry",searchPlaceholder:"Search...",searchFound:"found",searching:"Searching..."};function zr(r,o,n){let a=1/0,p=-1/0,u=Math.min(n,r.length-1);for(let m=o;m<=u;m++){let k=r[m];k<a&&(a=k),k>p&&(p=k);}return {min:a,max:p}}chunkQQ6EL7I4_js.a(zr,"getMinMax");var Bt=chunkQQ6EL7I4_js.a(r=>{let{state:o,headers:n,totalRows:a,getRow:p,error:u,progress:m,prefetchRange:k,sessionId:M,chunkCount:C,pinChunks:D}=Mr(r),y={...kn,...r.labels},{query:I,onQueryChange:O,clearSearch:t,searchState:z,matchedIndices:w}=Ir(M,C),d=w!==null,L=d?w.length:a,[S,P]=dr.useState([]),$=dr.useRef(null),H=dr.useRef(null);dr.useEffect(()=>{n.length>0&&S.length!==n.length&&P(n.map(A=>Math.min(Math.max(150,A.length*9),500)));},[n,S.length]),dr.useEffect(()=>()=>H.current?.(),[]);let ee=dr.useCallback((A,V)=>{A.preventDefault();let se=A.clientX,W=S[V]??150;$.current={index:V,startX:se,startWidth:W};let ae=chunkQQ6EL7I4_js.a(pe=>{if(!$.current)return;let me=pe.clientX-se,de=Math.max(50,W+me);P(te=>{let re=[...te];return re[V]=de,re});},"onMouseMove"),B=chunkQQ6EL7I4_js.a(()=>{$.current=null,H.current=null,document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",B);},"onMouseUp");H.current=B,document.addEventListener("mousemove",ae),document.addEventListener("mouseup",B);},[S]),ne=S.reduce((A,V)=>A+V,0),ve=dr.useCallback(()=>jsxRuntime.jsx(Cn,{children:n.map((A,V)=>jsxRuntime.jsxs(Pn,{style:{width:S[V]},children:[A,jsxRuntime.jsx(Nn,{onMouseDown:se=>ee(se,V)})]},A))}),[n,S,ee]),ge=dr.useCallback(A=>{if(d&&w){let{min:V,max:se}=zr(w,A.startIndex,A.endIndex),W=new Set,ae=Math.min(A.endIndex,w.length-1);for(let B=A.startIndex;B<=ae;B++)W.add(Math.floor(w[B]/1e3));D(Array.from(W)),V!==1/0&&k(V,se);}else D([]),k(A.startIndex,A.endIndex);},[k,D,d,w]),we=dr.useCallback(A=>{let V=d&&w?w[A]:A,se=p(V);return se?n.map(W=>jsxRuntime.jsx(jr,{style:{width:S[n.indexOf(W)]},children:se[W]??""},W)):n.map(W=>jsxRuntime.jsx(jr,{style:{width:S[n.indexOf(W)]},children:jsxRuntime.jsx(Tn,{})},W))},[p,n,S,d,w]);return dr.useEffect(()=>{if(L>0)if(d&&w){let{min:A,max:V}=zr(w,0,50);A!==1/0&&k(A,V);}else k(0,50);},[L,d,w,k]),o==="idle"||o==="loading"||o==="streaming"?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[jsxRuntime.jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"}),o==="streaming"&&a>0&&jsxRuntime.jsxs(chunkQQ6EL7I4_js.Ya,{variant:"body",color:"text.lighter",style:{fontSize:12},children:[y.loading," ",a.toLocaleString()," ",y.rows,m>0?` (${Math.round(m*100)}%)`:""]})]}):jsxRuntime.jsxs("div",{className:"h-full w-full flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 gap-3",children:[jsxRuntime.jsx(chunkQQ6EL7I4_js.Ya,{variant:"body",color:"text.lighter",style:{fontSize:12,whiteSpace:"nowrap"},children:`${L.toLocaleString()} ${d?y.searchFound:y.rows}${d?` / ${a.toLocaleString()}`:""}`}),jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(Rn,{type:"text",value:I,onChange:A=>O(A.target.value),placeholder:y.searchPlaceholder}),z==="searching"?jsxRuntime.jsx(En,{children:jsxRuntime.jsx(zn,{})}):I?jsxRuntime.jsx(Ln,{onClick:t,type:"button",children:"\u2715"}):null]})]}),o==="partial_error"&&jsxRuntime.jsxs(chunkQQ6EL7I4_js.pb,{className:"flex items-center justify-between mx-4 mb-2 px-3 py-2 rounded bg-red-50 border border-red-200",children:[jsxRuntime.jsx(chunkQQ6EL7I4_js.Ya,{variant:"body",style:{fontSize:12,color:"#dc2626"},children:u}),r.onRetry&&jsxRuntime.jsx(chunkQQ6EL7I4_js.z,{onClick:()=>r.onRetry?.(u??""),variant:"outlined",size:"small",children:y.retry})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0",children:n.length>0&&jsxRuntime.jsx(reactVirtuoso.TableVirtuoso,{totalCount:L,increaseViewportBy:300,fixedHeaderContent:ve,itemContent:we,rangeChanged:ge,style:{height:"100%"},components:{Table:chunkQQ6EL7I4_js.a(({style:A,context:V,...se})=>jsxRuntime.jsx(Sn,{style:{...A,width:ne},...se}),"Table"),TableHead:Dn,TableRow:chunkQQ6EL7I4_js.a(({context:A,...V})=>jsxRuntime.jsx(Mn,{...V}),"TableRow")}},d?"filtered":"all")})]})},"CsvDriver"),Sn=bo.styled.table
|
|
172
|
+
`,tt=null,rt=null;function zt(){if(!tt){let r=new Blob([fn],{type:"application/javascript"});rt=URL.createObjectURL(r),tt=new Worker(rt);}return tt}chunkQQ6EL7I4_js.a(zt,"getSearchWorker");function Tr(){tt?.terminate(),tt=null,rt&&(URL.revokeObjectURL(rt),rt=null);}chunkQQ6EL7I4_js.a(Tr,"terminateSearchWorker");function Ir(r,o){let[n,a]=dr.useState(""),[p,u]=dr.useState("idle"),[m,k]=dr.useState(null),[M,C]=dr.useState({searched:0,total:0,found:0}),D=dr.useRef(null),y=dr.useCallback(t=>{if(!r||o===0)return;if(!t.trim()){k(null),u("idle"),C({searched:0,total:0,found:0});return}u("searching"),C({searched:0,total:o,found:0});let z=zt();z.onmessage=w=>{let{type:d}=w.data;d==="progress"&&C({searched:w.data.searched,total:w.data.total,found:w.data.found}),d==="done"&&(k(w.data.matchedIndices),u("done")),d==="cancelled"&&u("idle"),d==="error"&&(u("idle"),console.error("Search worker error:",w.data.message));},z.postMessage({type:"cancel"}),z.postMessage({type:"search",sessionId:r,query:t,chunkCount:o,chunkSize:1e3});},[r,o]),I=dr.useCallback(t=>{a(t),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{y(t);},300);},[y]),O=dr.useCallback(()=>{a(""),k(null),u("idle"),C({searched:0,total:0,found:0}),zt().postMessage({type:"cancel"});},[]);return dr.useEffect(()=>()=>{D.current&&clearTimeout(D.current),Tr();},[]),{query:n,onQueryChange:I,clearSearch:O,searchState:p,matchedIndices:m,searchProgress:M}}chunkQQ6EL7I4_js.a(Ir,"useCsvSearch");var kn={loading:"Loading...",rows:"rows",rowsIncomplete:"rows (incomplete)",retry:"Retry",searchPlaceholder:"Search...",searchFound:"found",searching:"Searching..."};function zr(r,o,n){let a=1/0,p=-1/0,u=Math.min(n,r.length-1);for(let m=o;m<=u;m++){let k=r[m];k<a&&(a=k),k>p&&(p=k);}return {min:a,max:p}}chunkQQ6EL7I4_js.a(zr,"getMinMax");var Bt=chunkQQ6EL7I4_js.a(r=>{let{state:o,headers:n,totalRows:a,getRow:p,error:u,progress:m,prefetchRange:k,sessionId:M,chunkCount:C,pinChunks:D}=Mr(r),y={...kn,...r.labels},{query:I,onQueryChange:O,clearSearch:t,searchState:z,matchedIndices:w}=Ir(M,C),d=w!==null,L=d?w.length:a,[S,P]=dr.useState([]),$=dr.useRef(null),H=dr.useRef(null);dr.useEffect(()=>{n.length>0&&S.length!==n.length&&P(n.map(A=>Math.min(Math.max(150,A.length*9),500)));},[n,S.length]),dr.useEffect(()=>()=>H.current?.(),[]);let ee=dr.useCallback((A,V)=>{A.preventDefault();let se=A.clientX,W=S[V]??150;$.current={index:V,startX:se,startWidth:W};let ae=chunkQQ6EL7I4_js.a(pe=>{if(!$.current)return;let me=pe.clientX-se,de=Math.max(50,W+me);P(te=>{let re=[...te];return re[V]=de,re});},"onMouseMove"),B=chunkQQ6EL7I4_js.a(()=>{$.current=null,H.current=null,document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",B);},"onMouseUp");H.current=B,document.addEventListener("mousemove",ae),document.addEventListener("mouseup",B);},[S]),ne=S.reduce((A,V)=>A+V,0),ve=dr.useCallback(()=>jsxRuntime.jsx(Cn,{children:n.map((A,V)=>jsxRuntime.jsxs(Pn,{style:{width:S[V]},children:[A,jsxRuntime.jsx(Nn,{onMouseDown:se=>ee(se,V)})]},A))}),[n,S,ee]),ge=dr.useCallback(A=>{if(d&&w){let{min:V,max:se}=zr(w,A.startIndex,A.endIndex),W=new Set,ae=Math.min(A.endIndex,w.length-1);for(let B=A.startIndex;B<=ae;B++)W.add(Math.floor(w[B]/1e3));D(Array.from(W)),V!==1/0&&k(V,se);}else D([]),k(A.startIndex,A.endIndex);},[k,D,d,w]),we=dr.useCallback(A=>{let V=d&&w?w[A]:A,se=p(V);return se?n.map(W=>jsxRuntime.jsx(jr,{style:{width:S[n.indexOf(W)]},children:se[W]??""},W)):n.map(W=>jsxRuntime.jsx(jr,{style:{width:S[n.indexOf(W)]},children:jsxRuntime.jsx(Tn,{})},W))},[p,n,S,d,w]);return dr.useEffect(()=>{if(L>0)if(d&&w){let{min:A,max:V}=zr(w,0,50);A!==1/0&&k(A,V);}else k(0,50);},[L,d,w,k]),o==="idle"||o==="loading"||o==="streaming"?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[jsxRuntime.jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"}),o==="streaming"&&a>0&&jsxRuntime.jsxs(chunkQQ6EL7I4_js.Ya,{variant:"body",color:"text.lighter",style:{fontSize:12},children:[y.loading," ",a.toLocaleString()," ",y.rows,m>0?` (${Math.round(m*100)}%)`:""]})]}):jsxRuntime.jsxs("div",{className:"h-full w-full flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 gap-3",children:[jsxRuntime.jsx(chunkQQ6EL7I4_js.Ya,{variant:"body",color:"text.lighter",style:{fontSize:12,whiteSpace:"nowrap"},children:`${L.toLocaleString()} ${d?y.searchFound:y.rows}${d?` / ${a.toLocaleString()}`:""}`}),jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(Rn,{type:"text",value:I,onChange:A=>O(A.target.value),placeholder:y.searchPlaceholder}),z==="searching"?jsxRuntime.jsx(En,{children:jsxRuntime.jsx(zn,{})}):I?jsxRuntime.jsx(Ln,{onClick:t,type:"button",children:"\u2715"}):null]})]}),o==="partial_error"&&jsxRuntime.jsxs(chunkQQ6EL7I4_js.pb,{className:"flex items-center justify-between mx-4 mb-2 px-3 py-2 rounded bg-red-50 border border-red-200",children:[jsxRuntime.jsx(chunkQQ6EL7I4_js.Ya,{variant:"body",style:{fontSize:12,color:"#dc2626"},children:u}),r.onRetry&&jsxRuntime.jsx(chunkQQ6EL7I4_js.z,{onClick:()=>r.onRetry?.(u??""),variant:"outlined",size:"small",children:y.retry})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0",children:n.length>0&&jsxRuntime.jsx(reactVirtuoso.TableVirtuoso,{totalCount:L,increaseViewportBy:300,fixedHeaderContent:ve,itemContent:we,rangeChanged:ge,style:{height:"100%"},components:{Table:chunkQQ6EL7I4_js.a(({style:A,context:V,...se})=>jsxRuntime.jsx(Sn,{style:{...A,minWidth:"100%",width:ne},...se}),"Table"),TableHead:Dn,TableRow:chunkQQ6EL7I4_js.a(({context:A,...V})=>jsxRuntime.jsx(Mn,{...V}),"TableRow")}},d?"filtered":"all")})]})},"CsvDriver"),Sn=bo.styled.table(({theme:r})=>`
|
|
173
173
|
border-collapse: separate;
|
|
174
174
|
border-spacing: 0;
|
|
175
175
|
table-layout: fixed;
|
|
176
176
|
font-size: 13px;
|
|
177
|
-
|
|
177
|
+
background-color: ${r.colors.background};
|
|
178
|
+
`),Dn=bo.styled.thead(({theme:r})=>`
|
|
178
179
|
background-color: ${r.colors.background};
|
|
179
180
|
z-index: 1;
|
|
180
181
|
`),Cn=bo.styled.tr``,Pn=bo.styled.th(({theme:r})=>`
|