UNPKG

vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

3 lines (2 loc) 21.5 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Gt=require("../tree/hooks.cjs"),S=require("vue"),m=require("@vexip-ui/utils"),E=require("./symbol.cjs"),re=Object.freeze({sum:NaN,min:NaN,max:NaN});let Yt=1;function j(){return`__vxp-table-key-${Yt++}`}function Vt(D){return D+1}const U=100,L=10;function Jt(D){const t=S.reactive({...D,columns:[],normalColumns:[],allColumns:[],summaries:[],data:[],dataKey:D.dataKey??E.DEFAULT_KEY_FIELD,rowData:[],treeRowData:[],width:0,rightFixedColumns:[],leftFixedColumns:[],aboveSummaries:[],belowSummaries:[],rowMinHeight:D.rowMinHeight||36,rowDraggable:!!D.rowDraggable,columnMap:new Map,rowMap:new Map,summaryMap:new Map,idMaps:new WeakMap,checkedAll:!1,partial:!1,widths:new Map,sorters:new Map,filters:new Map,resized:new Set,bodyYScroll:0,bodyXScroll:0,padTop:0,startRow:0,endRow:0,dragging:!1,heightBITree:null,virtualData:[],totalHeight:D.rowMinHeight*D.data.length,colResizing:!1,resizeLeft:0,cellSpanMap:new Map,collapseMap:new Map,sidePadding:D.sidePadding||[0,0],locked:!1,barScrolling:!1,heightTrigger:0,hoveredRowKey:null});Z(D.columns),ee(D.summaries),te(D.data);const G=S.computed(()=>typeof t.dataFilter=="function"?t.rowData.filter(e=>t.dataFilter(e.data)):t.rowData),O=S.computed(()=>t.customFilter?G.value:zt(t.filters,G.value,t.singleFilter)),Y=S.computed(()=>t.customSorter?O.value:Pt(t.sorters,O.value,t.columns,t.singleSorter)),A=S.computed(()=>{const e=Bt(t.currentPage,t.pageSize,Y.value);for(let n=0,s=e.length;n<s;++n)e[n].listIndex=n,e[n].last=n===s-1;return e}),ce=S.computed(()=>new Set(A.value.map(e=>e.key))),V=S.computed(()=>{const e=A.value,n=t.columns.find(l=>l.type==="selection"),s=new Set;if(n&&typeof n.disableRow=="function"){const l=n.disableRow;for(let i=0,a=e.length;i<a;++i){const c=e[i];l(c.data)&&s.add(c.key)}}return s}),de=S.computed(()=>{const e=A.value,n=t.columns.find(l=>l.type==="expand"),s=new Set;if(n&&typeof n.disableRow=="function"){const l=n.disableRow;for(let i=0,a=e.length;i<a;++i){const c=e[i];l(c.data)&&s.add(c.key)}}return s}),ue=S.computed(()=>{const e=A.value,n=t.columns.find(l=>l.type==="drag"),s=new Set;if(n&&typeof n.disableRow=="function"){const l=n.disableRow;for(let i=0,a=e.length;i<a;++i){const c=e[i];l(c.data)&&s.add(c.key)}}return s}),J=S.computed(()=>!t.disabledTree&&t.rowData.some(e=>{var n;return(n=e.children)==null?void 0:n.length})),fe=S.computed(()=>!!t.columns.find(e=>"type"in e&&e.type==="drag")),he=S.computed(()=>!!A.value.find(e=>e.dragging)),pe=S.computed(()=>$()),me=S.computed(()=>$(t.normalColumns)),ge=S.computed(()=>$(t.leftFixedColumns)),we=S.computed(()=>$(t.rightFixedColumns)),ye=S.computed(()=>t.columns.find(e=>e.type==="expand")),be=S.computed(()=>{const{columns:e,summaries:n,data:s}=t,l=new Map;if(!n.length)return l;for(const i of e){const a=i.key;if(i.type||i.noSummary){l.set(a,re);continue}const c=typeof i.accessor=="function"?i.accessor:d=>d[a];let f=0,u=1/0,h=-1/0,r=!1;for(let d=0,o=s.length;d<o;++d){const y=c(s[d],d),g=parseFloat(y);Number.isNaN(g)||(f+=g,u=Math.min(u,g),h=Math.max(h,g),r=!0)}r?l.set(a,{sum:f,min:u,max:h}):l.set(a,re)}return l}),xe=S.computed(()=>Q(t.aboveSummaries)),Se=S.computed(()=>Q()),Ce=S.computed(()=>t.columns.find(e=>!e.type&&e.indented)),ke=S.computed(()=>!!(t.leftFixedColumns.length||t.rightFixedColumns.length)),T=S.reactive({filteredData:O,sortedData:Y,processedData:A,visibleKeys:ce,disableCheckRows:V,disableExpandRows:de,disableDragRows:ue,usingTree:J,hasDragColumn:fe,rowDragging:he,totalWidths:pe,normalWidths:me,leftFixedWidths:ge,rightFixedWidths:we,expandColumn:ye,summaryData:be,topFixedHeights:xe,bottomFixedHeights:Se,indentedColumn:Ce,hasFixedColumn:ke}),Re={setColumns:m.debounceMinor(Z),setSummaries:m.debounceMinor(ee),setData:m.debounceMinor(te),updateTotalHeight:m.debounceMinor(ae),isGroupColumn:X,buildSummaryKey:_,setColumnProp:De,setSummaryProp:Fe,setDataKey:Te,setCurrentPage:Ae,setPageSize:Ne,setRowClass:Ee,setRowStyle:He,setRowAttrs:Ie,setCellClass:Ke,setCellStyle:_e,setCellAttrs:Le,setHeadClass:$e,setHeadStyle:ze,setHeadAttrs:Pe,setFootClass:Be,setFootStyle:je,setFootAttrs:Oe,setTableWidth:Xe,setRowHeight:Ue,setRowMinHeight:Ge,setCellHeight:Ye,setVirtual:nt,setRowDraggable:Ve,setBodyYScroll:Je,setBodyXScroll:Qe,setBorder:Ze,setStripe:et,setHighlight:tt,setRowProp:ot,setLocale:st,setTooltipTheme:lt,setTooltipWidth:it,setSingleSorter:at,setSingleFilter:rt,setDragging:ct,setKeyConfig:dt,setDisabledTree:ut,setNoCascaded:ft,setColResizable:ht,setCustomSorter:pt,setCustomFilter:mt,setColumnResizing:gt,setResizeLeft:wt,setExpandRenderer:yt,setCellSpan:bt,setSidePadding:xt,setBorderWidth:St,setDataFilter:Ct,setEllipsis:kt,setLocked:Rt,setBarScrolling:Mt,setHoveredRowKey:vt,handleSort:Dt,clearSort:oe,handleFilter:Ft,clearFilter:se,toggleFilterItemActive:_t,refreshRowIndex:q,handleCheck:Nt,handleCheckAll:Et,clearCheckAll:le,setRenderRows:ie,handleExpand:Ht,handleDrag:It,collectUnderRows:z,setTreeExpanded:Kt,getParentRow:jt,handleColumnResize:Ot,getCurrentData:qt,createMinRowState:K,flatTreeRows:ne,refreshRowDepth:We,triggerHeightChange:Me,queryRow:Ut};S.watchEffect(()=>{t.heightBITree=m.createBITree(A.value.length,t.rowHeight||t.rowMinHeight),t.totalHeight=-1,ae()}),S.watchEffect(Xt);function Me(){++t.heightTrigger,t.heightTrigger>=Number.MAX_SAFE_INTEGER&&(t.heightTrigger=0)}function $(e=t.columns){const n=t.widths,s=[0];let l=0;for(let i=0,a=e.length;i<a;++i){const f=e[i].key,u=n.get(f)||0;l+=u,s.push(l)}return s}function Q(e=t.belowSummaries){const n=t.rowMap,s=[0];let l=0;for(let i=0,a=e.length;i<a;++i){const c=e[i],f=_(c.key),u=n.get(f);u&&(l+=u.height||0),s.push(l)}return s}function K(e){return{key:e,cellHeights:{},height:t.rowHeight??t.rowMinHeight}}function X(e){var n;return!!((n=e.children)!=null&&n.length)}function ve(e){const n=[],s=[],l=new Map,i=new Set,a=u=>u===!0||u==="left"?-1:u==="right"?1:0,c=(u,h,r=0,d=[])=>{u=u.filter(p=>!("children"in p)||X(p)).sort((p,w)=>(p.order||0)-(w.order||0)).sort((p,w)=>a(p.fixed)-a(w.fixed)),h=h===!0?"left":h;const o=u,y=d[r]??(d[r]=[]);let g=r>0?d[r-1].length-1:0;for(const{...p}of o){if(m.isNull(h)||(p.fixed=h),y[g]=p,X(p)){const w=c(p.children,p.fixed,r+1,d);p.key=Symbol("TableColumnGroup"),p.headSpan=w-g,g=w}else{const w=p.type&&E.columnTypes.includes(p.type);w&&(i.has(p.type)&&console.warn(`[vexip-ui:Table] Table has duplicate column with type '${p.type}'`),i.add(p.type));let R=p.key;m.isNull(R)&&(w?R=`__vxp_${p.type}`:(console.warn("[vexip-ui:Table] Table column requires key prop, but missing"),R=j())),p.key=R,s.push(p),g+=1}l.set(p.key,p)}return g};c(e,void 0,0,n);let f=0;for(const u of n)f=Math.max(u.length,f);for(const u of n)u.length&&(m.getLast(u).last=!0),u.length=f;for(let u=0,h=n.length;u<f;++u){let r=1;for(let d=h-1;d>=0;--d){const o=n[d][u];o?(o.colIndex=u,o.rowSpan=r,r=1):++r}}return{allColumns:n,baseColumns:s,columnMap:l}}function Z(e){const{widths:n,sorters:s,filters:l}=t,{allColumns:i,baseColumns:a,columnMap:c}=ve(e),f=[],u=[],h=[];for(let r=0,d=a.length;r<d;++r){const o=a[r];if(o.first=!1,o.last=!1,o.index=r,o.type&&E.columnTypes.includes(o.type)){switch(o.type){case"order":{o.truthIndex=!!o.truthIndex,typeof o.orderLabel!="function"&&(o.orderLabel=Vt),m.isNull(o.width)&&(o.width=60,o.minWidth=60);break}case"selection":{o.selectionSize=o.selectionSize||"default",typeof o.disableRow!="function"&&(o.disableRow=m.toFalse),m.isNull(o.width)&&(o.width=40,o.minWidth=40);break}case"expand":{typeof o.disableRow!="function"&&(o.disableRow=m.toFalse),m.isNull(o.width)&&(o.width=40,o.minWidth=40);break}case"drag":{typeof o.disableRow!="function"&&(o.disableRow=m.toFalse),m.isNull(o.width)&&(o.width=40,o.minWidth=40);break}}o.key||(o.key=`__vxp_${o.type}-${r}`)}else o.type=void 0;n.set(o.key,typeof o.width=="string"?L:Math.round(m.boundRange(o.width||U,o.minWidth||L,o.maxWidth||1/0))),s.set(o.key,Lt(o.sorter)),l.set(o.key,$t(o.filter));const y=o.fixed;y===!0||y==="left"?h.push(o):y==="right"?u.push(o):f.push(o)}if(t.allColumns.length>i.length)for(let r=i.length-1,d=t.allColumns.length;r<d;++r)t.rowMap.delete(`${E.TABLE_HEAD_PREFIX}${r}`);for(let r=0,d=i.length;r<d;++r){const o=`${E.TABLE_HEAD_PREFIX}${r}`;t.rowMap.set(o,K(o))}if(t.columnMap=c,t.columns=Array.from(h).concat(f,u),t.normalColumns=f,t.allColumns=i,t.columns.length){for(const r of t.columns)if(!r.type){r.first=!0;break}m.getLast(t.columns).last=!0}h.length&&(t.leftFixedColumns=h),u.length&&(t.rightFixedColumns=u)}function De(e,n,s){t.columnMap.has(e)&&(t.columnMap.get(e)[n]=s)}function _(e){return typeof e=="symbol"?e:`${E.TABLE_FOOT_PREFIX}${e}`}function ee(e){e=Array.from(e).sort((a,c)=>(a.order||0)-(c.order||0));const n=new Set(t.summaries.map(a=>a.key)),s=[],l=[],i=new Map;for(let a=0,c=e.length;a<c;++a){const f={...e[a]};let u=f.key;if(m.isNull(u)&&(console.error("[vexip-ui:Table] Table summary requires key prop, but missing"),u=j()),f.key=u,(f.above?s:l).push(f),!n.has(f.key)){const h=_(f.key);t.rowMap.set(h,K(h))}n.delete(f.key),i.set(f.key,f)}if(t.summaries=Array.from(s).concat(l),t.summaryMap=i,s.length&&(t.aboveSummaries=s),l.length&&(t.belowSummaries=l),n.size)for(const a of n)t.rowMap.delete(_(a))}function Fe(e,n,s){t.summaryMap.has(e)&&(t.summaryMap.get(e)[n]=s)}function Te(e){const n=t.dataKey;if(!m.isNull(e)&&n!==e){const{rowData:s,idMaps:l}=t;t.dataKey=e,s.forEach(i=>{let a=i.data[e];m.isNull(a)&&(a=j()),i.key=a,l.set(i.data,a)})}}function z(e,n=[]){var s;if(e.treeExpanded&&((s=e.children)!=null&&s.length))for(const l of e.children)n.push(l),z(l,n);return n}function te(e){const n=[],s=new Map,{allColumns:l,dataKey:i,keyConfig:a,idMaps:c,disabledTree:f}=t,u=t.rowMap,h=!!t.virtual,{children:r,checked:d,height:o,expanded:y,treeExpanded:g}=a;for(let w=0,R=l.length;w<R;++w){const C=`${E.TABLE_HEAD_PREFIX}${w}`;s.set(C,u.get(C)||K(C))}for(const w of t.summaries){const R=_(w.key);s.set(R,u.get(R)||K(R))}const p=(w,R,C)=>{for(let k=0,M=w.length;k<M;++k){const x=w[k];let v=x[i];m.isNull(v)&&(v=c.get(x),m.isNull(v)&&(v=j()));let b;if(u.has(v)){b=u.get(v);const{[d]:N,[o]:I,[y]:F,[g]:B}=b.data!==x?Object.assign(b.data,x):b.data;b.checked=m.isNull(N)?b.checked:!!N,b.height=m.isNull(I)?b.height:m.toNumber(I),b.expanded=m.isNull(F)?b.expanded:!!F,b.treeExpanded=m.isNull(B)?b.treeExpanded:!!B}else{const{[d]:N,[o]:I,[y]:F,[g]:B}=x;b={key:v,hidden:h,checked:!!N,height:m.toNumber(I),expanded:!!F,hover:!1,expandHeight:0,index:-1,children:[],depth:0,treeExpanded:!!B,partial:!1,dragging:!1,listIndex:0,cellHeights:S.reactive({}),last:!1,expandAnimate:!1,data:x},c.set(x,v)}C&&(b.parent=C.key,b.depth=C.depth+1),b.children=[];const W=b.data[r];W!=null&&W.length&&p(W,b.children,b),R.push(b),s.set(v,b)}};p(e,n),t.rowMap=s,t.treeRowData=n,f?t.rowData=n:ne(),t.data=e,q(),P()}function ne(){if(t.disabledTree)return;const e=[];for(const n of t.treeRowData)e.push(n),z(n,e);t.rowData=e}function We(){m.walkTree(t.treeRowData,(e,n)=>{e.depth=n})}function Ae(e){t.currentPage=e??1}function Ne(e){t.pageSize=e||0}function Ee(e){t.rowClass=e??""}function He(e){t.rowStyle=e??""}function Ie(e){t.rowAttrs=e??null}function Ke(e){t.cellClass=e??""}function _e(e){t.cellStyle=e??""}function Le(e){t.cellAttrs=e??null}function $e(e){t.headClass=e??""}function ze(e){t.headStyle=e??""}function Pe(e){t.headAttrs=e??null}function Be(e){t.footClass=e??""}function je(e){t.footStyle=e??""}function Oe(e){t.footAttrs=e??null}function Xe(e){e=m.toNumber(e);const{columns:n,widths:s,resized:l}=t,i=[],a=[];let c=e;for(let r=0,d=n.length;r<d;++r){const o=n[r],{minWidth:y,maxWidth:g}=o;if(l.has(o.key))c-=s.get(o.key),i.push(o);else if(o.width)if(typeof o.width=="string"){const p=m.boundRange(m.toNumber(o.width),0,100);if(p){const w=Math.round(m.boundRange(e*p/100,y||L,g||1/0));c-=w,s.set(o.key,w),i.push(o)}else a.push(o)}else{const p=Math.round(m.boundRange(o.width||U,y||L,g||1/0));c-=p,s.set(o.key,p),i.push(o)}else a.push(o)}const f=a.length,u=qe(a,c);let h=0;for(let r=0;r<f;++r){const d=a[r],o=Math[r%2?"ceil":"floor"](u[r]);r<f-1&&(h+=o),s.set(d.key,o)}f&&c>=h+m.getLast(u)&&s.set(m.getLast(a).key,c-h),t.width=e}function qe(e,n){const s=e.length,l=Math.max(n/s,U),i=e.map(d=>{let o=l;return d.minWidth!=null&&(o=Math.max(o,d.minWidth)),d.maxWidth!=null&&(o=Math.min(o,d.maxWidth)),o}),a=i.reduce((d,o)=>d+o,0);let c=n-a;const f=d=>e[d].maxWidth==null||i[d]<e[d].maxWidth,u=d=>e[d].minWidth==null||i[d]>e[d].minWidth,h=.1;let r=!1;for(;Math.abs(c)>h;){const d=i.map((y,g)=>c>0&&f(g)||c<0&&u(g)?g:-1).filter(y=>y!==-1);if(d.length===0){r=!1;break}const o=c/d.length;for(const y of d){const g=i[y];let p=g+o;e[y].minWidth!=null&&(p=Math.max(p,e[y].minWidth)),e[y].maxWidth!=null&&(p=Math.min(p,e[y].maxWidth)),c-=p-g,i[y]=p}r=!0}return!r&&c>h&&(i[s-1]+=c),i}function Ue(e){t.rowHeight=e}function Ge(e){t.rowMinHeight=e}function Ye(e,n,s){!m.isNull(s)&&t.rowMap.has(e)&&(t.rowMap.get(e).cellHeights[n]=s)}function Ve(e){t.rowDraggable=!!e}function Je(e){t.bodyYScroll=e}function Qe(e){t.bodyXScroll=e}function Ze(e){t.border=!!e}function et(e){t.stripe=!!e}function tt(e){t.highlight=!!e}function nt(e){t.virtual=!!e}function ot(e,n,s){const l=t.rowMap.get(e);l&&l[n]!==s&&(l[n]=s)}function st(e){t.locale=e}function lt(e){t.tooltipTheme=e}function it(e){t.tooltipWidth=e}function at(e){t.singleSorter=!!e}function rt(e){t.singleFilter=!!e}function ct(e){t.dragging=!!e}function dt(e){t.keyConfig=e}function ut(e){t.disabledTree=!!e}function ft(e){t.noCascaded=!!e}function ht(e){t.colResizable=e===!0?"lazy":e}function pt(e){t.customSorter=!!e}function mt(e){t.customFilter=!!e}function gt(e){t.colResizing=!!e}function wt(e){t.resizeLeft=e}function yt(e){t.expandRenderer=e}function bt(e){t.cellSpan=e}function xt(e){t.sidePadding=Array.isArray(e)?e:[e,e]}function St(e){t.borderWidth=Math.max(e,0)}function Ct(e){t.dataFilter=e}function kt(e){t.ellipsis=e}function Rt(e){t.locked=e}function Mt(e){t.barScrolling=e}function vt(e){if(t.hoveredRowKey!==e){const n=t.hoveredRowKey&&t.rowMap.get(t.hoveredRowKey),s=e&&t.rowMap.get(e);n&&(n.hover=!1),s&&(s.hover=!0)}t.hoveredRowKey=e}function Dt(e,n){t.sorters.has(e)&&(t.singleSorter&&n&&oe(),t.sorters.get(e).type=n)}function oe(){const e=t.sorters;for(const n of e.values())n.type=null}function Ft(e,n){t.filters.has(e)&&(t.singleFilter&&(Array.isArray(n)?n.length:n)&&se(),t.filters.get(e).active=Array.isArray(n)?Array.from(n):n)}function se(){const e=t.filters;for(const n of e.values()){n.active=null;for(const s of n.options)s.active=!1}}const{updateCheckedUpward:Tt,updateCheckedDown:Wt}=Gt.useCascadedChecked({getNode:e=>t.rowMap.get(e),disableNode:e=>V.value.has(e.key)});function At(e){const{rowMap:n,rowData:s}=t,{disableCheckRows:l}=T;if(!n.has(e))return;const i=[n.get(e)].concat(s.filter(a=>l.has(a.key)&&a.checked));for(let a=0,c=i.length;a<c;++a)Tt(i[a].key),Wt(i[a].key)}function Nt(e,n,s=!1){const{rowMap:l,noCascaded:i}=t,{disableCheckRows:a}=T,c=l.get(e);c&&(s&&(le(!0),c.checked=!!n),a.has(e)||(c.checked=!!n,c.partial=!1),!i&&At(e),P())}function Et(){const{rowData:e,checkedAll:n}=t,{disableCheckRows:s}=T;let l=!n;if(s.size){let i=!0;for(const a of e)if(!s.has(a.key)&&!a.checked){i=!1;break}l=!i}for(const i of e)s.has(i.key)||(i.checked=l);t.checkedAll=l,t.partial=!1,P()}function le(e=!1){const{rowData:n}=t,{disableCheckRows:s}=T;for(const l of n)(e||!s.has(l.key))&&(l.checked=!1),e&&(l.partial=!1);t.checkedAll=!1,t.partial=!1,!e&&P()}function P(){const e=t.rowData;let n=!1,s=!1,l=!1;for(let i=0,a=e.length;i<a;++i)if(e[i].checked?n=!0:s=!0,n&&s){l=!0;break}n&&!l?t.checkedAll=!0:t.checkedAll=!1,t.partial=l}function ie(e,n,s=!1){const{startRow:l,endRow:i,heightBITree:a,virtualData:c}=t;if(!s&&e===l&&n===i)return;const{processedData:f}=T;if(!f.length){c.length=0;return}const u=new Set([...c]),h=[],r=[];for(let o=0,y=f.length;o<y;++o){const g=f[o];g.hidden=!(o>=e&&o<n),g.hidden?(g.hover=!1,u.has(g)&&r.push(g)):u.has(g)||h.push(g),u.delete(g)}r.push(...u);const d=Math.min(h.length,r.length);for(let o=0;o<d;++o)c[c.indexOf(r[o])]=h[o];h.length>r.length?c.push(...h.slice(d)):h.length<r.length&&(t.virtualData=c.filter(o=>!r.includes(o))),t.padTop=(a==null?void 0:a.sum(e))??0,t.startRow=e,t.endRow=n}function Ht(e,n){const{rowMap:s}=t,{disableExpandRows:l}=T;s.has(e)&&!l.has(e)&&(s.get(e).expanded=!!n)}function It(e,n){const{rowMap:s}=t,{disableDragRows:l}=T;s.has(e)&&!l.has(e)&&(s.get(e).dragging=!!n)}function Kt(e,n){var f;if(!J.value)return;const{rowMap:s,rowData:l,virtual:i}=t,a=s.get(e);if(!((f=a==null?void 0:a.children)!=null&&f.length))return;const c=z({...a,treeExpanded:!0});n?l.splice(a.index+1,0,...c):l.splice(a.index+1,c.length),a.treeExpanded=!!n,q(),i&&ie(t.startRow,t.endRow,!0)}function _t(e){const{key:n,value:s,active:l=!1,disableOthers:i=!1}=e;if(t.filters.has(n)){const a=t.filters.get(n).options;if(i)for(let f=0,u=a.length;f<u;++f)a[f].active=!1;const c=a.find(f=>f.value===s);c&&(c.active=l)}}function q(){const e=t.rowData;for(let n=0,s=e.length;n<s;++n)e[n].index=n}function ae(){const{heightBITree:e}=t;e?t.totalHeight=e.sum()??0:t.totalHeight=0}function Lt(e=!1){const n=typeof e=="boolean"?{able:e}:e,{able:s=!0,type:l=null,order:i=0,method:a=null}=n;return{able:s,type:l,order:i,method:a}}function $t(e){e=e||{able:!1,options:[]};const{able:n=!0,custom:s=!1,multiple:l=!1,active:i=null,method:a=null,meta:c}=e,f=m.deepClone(e.options??[]),u=[];for(let h=0,r=f.length;h<r;++h){const d=f[h],o=typeof d=="string"?{value:d}:{...d};o.label=o.label??o.value.toString();let y=!1;l&&Array.isArray(i)?y=i.includes(o.value):m.isNull(i)||(y=Object.is(o.value,i)),o.active=y,u.push(o)}return{able:n,custom:s,meta:c,options:u,multiple:l,active:i,method:a}}function zt(e,n,s){const l=[],i=[];for(const c of e.values()){const{able:f,active:u,method:h}=c;if(f&&u&&typeof h=="function"&&(l.push(c),s))break}const a=l.length;for(let c=0,f=n.length;c<f;++c){const u=n[c];let h=!0;for(let r=0;r<a;r++){const{active:d,method:o}=l[r];if(h=o(d,u.data),!h)break}h&&i.push(u)}return i}function Pt(e,n,s,l){const i=[];for(const[a,c]of e){const f=a,{able:u,type:h,order:r,method:d}=c;if(u&&h){const o=s.find(g=>g.key===f),y=o==null?void 0:o.accessor;if(i.push({able:u,key:f,order:r,type:h,method:d??void 0,accessor(g){return typeof y=="function"?y(g.data,g.index):g.data[f]}}),l)break}}return i.sort((a,c)=>a.order-c.order),m.sortByProps(n,i)}function Bt(e,n,s){return n>0?s.slice((e-1)*n,e*n):s}function jt(e){const{rowMap:n}=t,s=n.get(e);return m.isNull(s==null?void 0:s.parent)?null:n.get(s.parent)??null}let H;function Ot(e,n){const{resized:s,widths:l,columns:i,columnMap:a,width:c}=t,f=e.length;if(!i.length||!f)return;const u=n/f,h=m.getLast(i).key;for(let d=0;d<f;++d){const o=e[d],y=a.get(o);if(!y)continue;const g=f===1?Math.round(u):Math[d%2?"ceil":"floor"](u),{minWidth:p,maxWidth:w}=y;s.add(o),l.set(o,m.boundRange(g,p||L,w||1/0))}let r=0;for(const d of l.values())r+=d;r=m.toFixed(r,1),r-l.get(h)<c-(H??l.get(h))?(H||(H=l.get(h)),l.set(h,l.get(h)+c-r)):H&&(l.set(h,H),H=void 0)}function Xt(){const{normalColumns:e,leftFixedColumns:n,rightFixedColumns:s,aboveSummaries:l,belowSummaries:i,rowData:a,cellSpanMap:c,collapseMap:f}=t,{processedData:u}=T;for(const r of["left","default","right"])c.set(r,new Map),f.set(r,new Map);function h(r,d,o,y,g=""){const p=`${g}${r},${d}`,w=f.get(o);if(w.has(p)){c.get(o).set(p,{colSpan:0,rowSpan:0});return}const R=y(),{colSpan:C,rowSpan:k}=R;for(let M=0;M<C;++M)for(let x=0;x<k;++x){if(!M&&!x)continue;const v=`${g}${r+x},${d+M}`;let b=w.get(v);b||(b=new Set,w.set(v,b)),b.add(p)}c.get(o).set(p,R)}for(const r of[e,n,s]){if(!r.length)continue;const d=r[0].fixed===!0?"left":r[0].fixed||"default",o=r[0].fixed===!0?"left":r[0].fixed||void 0,y=t.leftFixedColumns.length,g=t.allColumns[0].length-t.rightFixedColumns.length;let p;d==="left"?p=t.allColumns.map(w=>w.slice(0,y)):d==="right"?p=t.allColumns.map(w=>w.slice(g,t.allColumns[0].length)):p=t.allColumns.map(w=>w.slice(y,g));for(let w=0,R=p.length;w<R;++w){const C=p[w];for(let k=0,M=C.length;k<M;++k){const x=C[k];if(!x)continue;const v=x.fixed===!0?"left":x.fixed||"default";h(w,k,v,()=>{const b=v==="left"?n:v==="right"?s:e;return{colSpan:m.boundRange(x.headSpan??1,0,b.length-k),rowSpan:x.rowSpan}},"h")}}for(let w=0,R=r.length;w<R;++w){const C=r[w];for(const k of a)h(k.index,C.index,d,()=>{let M;typeof C.cellSpan=="function"?M=C.cellSpan({row:k.data,index:k.index,fixed:o}):typeof t.cellSpan=="function"&&(M=t.cellSpan({row:k.data,rowIndex:k.index,column:C,columnIndex:C.index,fixed:o})),M=M||{colSpan:1,rowSpan:1};const x={colSpan:M.colSpan??1,rowSpan:M.rowSpan??1};return x.colSpan=m.boundRange(x.colSpan,0,r.length-w),x.rowSpan=m.boundRange(x.rowSpan,0,u.length-k.listIndex),x});for(const{prefix:k,summaries:M}of[{prefix:"af",summaries:l},{prefix:"bf",summaries:i}])for(let x=0,v=M.length;x<v;++x){const b=M[x];h(x,C.index,d,()=>{let W;typeof b.cellSpan=="function"&&(W=b.cellSpan({column:C,index:C.index,fixed:o}));const{colSpan:N,rowSpan:I}=W||{colSpan:1,rowSpan:1},F={colSpan:N??1,rowSpan:I??1};return F.colSpan=m.boundRange(F.colSpan,0,r.length-w),F.rowSpan=m.boundRange(F.rowSpan,0,M.length-x),F},k)}}}}function qt(){const{treeRowData:e,disabledTree:n,keyConfig:s}=t;return n?e.map(l=>({...l.data})):m.mapTree(e,l=>({...l.data}),{childField:s.children})}function Ut(e){const{dataKey:n,rowMap:s,idMaps:l}=t;let i;return typeof e=="object"?i=l.get(e)??e[n]:i=e,m.isNull(i)?void 0:s.get(i)}return{state:t,getters:T,mutations:Re}}exports.useStore=Jt; //# sourceMappingURL=store.cjs.map