@timlassiter11/yatl 0.1.9 → 0.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/datatable.d.mts +19 -15
- package/dist/datatable.d.ts +19 -15
- package/dist/datatable.global.js +2 -2
- package/dist/datatable.global.js.map +1 -1
- package/dist/datatable.js +2 -2
- package/dist/datatable.js.map +1 -1
- package/dist/datatable.mjs +2 -2
- package/dist/datatable.mjs.map +1 -1
- package/package.json +1 -1
package/dist/datatable.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Bt=Object.defineProperty;var It=Object.getOwnPropertySymbols;var Jt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable;var Pt=c=>{throw TypeError(c)};var Vt=(c,o,e)=>o in c?Bt(c,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[o]=e,et=(c,o)=>{for(var e in o||(o={}))Jt.call(o,e)&&Vt(c,e,o[e]);if(It)for(var e of It(o))Yt.call(o,e)&&Vt(c,e,o[e]);return c};var Ft=(c,o,e)=>o.has(c)||Pt("Cannot "+e);var t=(c,o,e)=>(Ft(c,o,"read from private field"),e?e.call(c):o.get(c)),h=(c,o,e)=>o.has(c)?Pt("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(c):o.set(c,e),u=(c,o,e,r)=>(Ft(c,o,"write to private field"),r?r.call(c,e):o.set(c,e),e),f=(c,o,e)=>(Ft(c,o,"access private method"),e);var Dt=(c,o,e,r)=>({set _(s){u(c,o,s,e)},get _(){return t(c,o,r)}});var x=c=>{if(typeof c=="string"&&c!=="")return c.split(" ");if(Array.isArray(c))return c;if(!c)return[];throw new TypeError("classes must be string or array of strings")},_t=c=>c.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,o=>o.toUpperCase()),Nt=c=>{let o=/"[^"]*"|\S+/g;return(c.match(o)||[]).map(r=>r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r)};var ot,H,S,rt,$,W,at,X,Y,lt,dt,ht,vt,$t,it=class it{constructor({container:o,element:e,generator:r,nodePadding:s=10}){h(this,vt);h(this,H);h(this,S);h(this,rt);h(this,$,0);h(this,W,0);h(this,at,2);h(this,X,0);h(this,Y,!1);h(this,lt,0);h(this,dt,()=>{t(this,H).scrollTop!==t(this,lt)&&(u(this,lt,t(this,H).scrollTop),t(this,X)&&cancelAnimationFrame(t(this,X)),u(this,X,requestAnimationFrame(()=>this.renderChunk())))});h(this,ht,()=>{this.renderChunk()});u(this,H,o),u(this,S,e),u(this,rt,r),u(this,at,s),new IntersectionObserver(n=>{for(let d of n)d.intersectionRatio===1&&this.renderChunk()}).observe(t(this,S))}get rowHeight(){return t(this,W)||f(this,vt,$t).call(this),t(this,W)}get started(){return t(this,Y)}scrollToIndex(o){if(o<0||o>=t(this,$))throw new RangeError("Index out of bounds.");this.scrollToPx(this.rowHeight*o)}scrollToPx(o){t(this,H).scrollTop=o,this.renderChunk()}start(o){t(this,Y)||(t(this,H).addEventListener("scroll",t(this,dt)),window.addEventListener("resize",t(this,ht)),u(this,Y,!0)),t(this,H).classList.add("dt-virtual-scroll"),u(this,$,o),this.renderChunk()}stop(){t(this,X)&&cancelAnimationFrame(t(this,X)),t(this,H).classList.remove("dt-virtual-scroll"),t(this,H).removeEventListener("scroll",t(this,dt)),window.removeEventListener("resize",t(this,ht)),u(this,Y,!1)}renderChunk(){let o=t(this,H).scrollTop,e=t(this,$),r=this.rowHeight,s=t(this,at);if(!this.started||!t(this,S).checkVisibility()||!e||!r)return;let i=r*e;t(this,S).innerHTML=`<div style="height: ${i}px;"></div>`;let n=t(this,S).offsetHeight,d=t(this,H).offsetHeight;!t(it,ot)&&n<Math.round(i-1)&&(u(it,ot,!0),console.error("Max element height exceeded. Virtual scroll may not work."));let a=Math.floor(o/r)-s;a=Math.max(0,a);let m=Math.ceil(d/r)+2*s;m=Math.min(e-a,m),a%2===1&&a--;let b=a*r,L=i-(b+m*r);try{t(this,S).innerHTML="";let F=new Array(m).fill(null).map((N,gt)=>t(this,rt).call(this,gt+a)),V=document.createElement("div"),D=document.createElement("div");V.style.visibility="hidden",V.style.height=b+"px",D.style.visibility="hidden",D.style.height=L+"px",t(this,S).append(V),t(this,S).append(...F),t(this,S).append(D)}catch(F){F instanceof RangeError&&console.log(F)}}};ot=new WeakMap,H=new WeakMap,S=new WeakMap,rt=new WeakMap,$=new WeakMap,W=new WeakMap,at=new WeakMap,X=new WeakMap,Y=new WeakMap,lt=new WeakMap,dt=new WeakMap,ht=new WeakMap,vt=new WeakSet,$t=function(){if(t(this,$)===0||!t(this,S).checkVisibility()){u(this,W,0);return}let e=Math.min(1e3,t(this,$)),r=[];for(let s=0;s<e;++s)r.push(t(this,rt).call(this,s));if(t(this,S).innerHTML="",t(this,S).append(...r),u(this,W,t(this,S).offsetHeight/e),t(this,W)<=0)throw new nt(`First ${e} rows had no rendered height. Virtual scroll can't be used.`);t(this,W)*t(this,$)>33554400&&console.warn("Virtual scroll height exceeded maximum known element height.")},h(it,ot,!1);var bt=it,nt=class extends Error{constructor(o){super(o)}};var E,P,k,y,v,M,C,_,G,O,ft,A,I,p,U,l,jt,wt,Ht,Xt,q,qt,Et,ct,yt,Rt,Gt,zt,ut,At,Tt,mt,pt,Ct,Lt,xt,St,Ot,kt,Mt,z=class z extends EventTarget{constructor(e,r={}){var a,m,b,L,F,V,D,N,gt;super();h(this,l);h(this,E);h(this,P);h(this,k);h(this,y);h(this,v,new Map);h(this,M,new Map);h(this,C,[]);h(this,_);h(this,G);h(this,O);h(this,ft,0);h(this,A);h(this,I);h(this,p);h(this,U,!1);h(this,Tt,e=>{if(!(e.target instanceof HTMLElement)||!e.target.classList.contains("dt-resizer")||!(e.currentTarget instanceof HTMLElement)||!e.currentTarget.dataset.dtField)return;e.stopImmediatePropagation(),e.preventDefault();let r=e.currentTarget.dataset.dtField,s=t(this,v).get(r);s&&(u(this,I,s),s.resizeStartX=e.clientX,s.resizeStartWidth=s.header.offsetWidth,document.addEventListener("mousemove",t(this,mt)),document.addEventListener("mouseup",t(this,pt)))});h(this,mt,e=>{if(!t(this,I))return;e.stopImmediatePropagation(),e.preventDefault();let r=e.clientX-t(this,I).resizeStartX,s=t(this,I).resizeStartWidth+r;f(this,l,At).call(this,t(this,I),s)});h(this,pt,e=>{if(!t(this,I))return;e.stopImmediatePropagation(),e.preventDefault(),document.removeEventListener("mousemove",t(this,mt)),document.removeEventListener("mouseup",t(this,pt));let r=new CustomEvent("dt.col.resize",{cancelable:!1,detail:{column:t(this,I).field,width:t(this,I).header.offsetWidth}});this.dispatchEvent(r),u(this,I,void 0)});h(this,Ct,e=>{if(!(e.target instanceof HTMLElement)||!e.target.classList.contains("dt-resizer")||!(e.currentTarget instanceof HTMLElement)||!e.currentTarget.dataset.dtField)return;let r=e.currentTarget.dataset.dtField;r&&f(this,l,At).call(this,r)});h(this,Lt,e=>{let s=e.target.dataset.dtField;e.dataTransfer&&s&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s))});h(this,xt,e=>(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),!1));h(this,St,e=>{e.target.classList.add("dt-drag-over")});h(this,Ot,e=>{e.target.classList.remove("dt-drag-over")});h(this,kt,e=>{var m;let r=(m=e.dataTransfer)==null?void 0:m.getData("text/plain"),i=e.currentTarget.dataset.dtField;if(!r||!i)return;e.preventDefault(),e.stopPropagation();let n=[...t(this,v).values()],d=n.findIndex(b=>b.field===r),a=n.findIndex(b=>b.field===i);if(d>-1&&a>-1){let[b]=n.splice(d,1),L=t(this,v).get(i);if(!L)return;n.splice(a,0,b);let F=n.map(D=>D.field),V=new CustomEvent("dt.col.reorder",{cancelable:!0,detail:{draggedColumn:b.field,dropColumn:L.field,order:F}});if(!this.dispatchEvent(V))return;this.setColumnOrder(F)}});h(this,Mt,()=>{let e=document.querySelectorAll(".dt-drag-over");for(let r of e)r.classList.remove("dt-drag-over")});if(u(this,p,et(et({columns:[],data:[]},z.DEFAULT_OPTIONS),r)),typeof e=="string"){let g=document.querySelector(e);if(!g)throw new SyntaxError(`Failed to find table using selector ${e}`);u(this,E,g)}else u(this,E,e);if(!(t(this,E)instanceof HTMLTableElement))throw new TypeError("Invalid table element type. Must be HTMLTableElement");if(!Array.isArray(t(this,p).columns))throw new TypeError("columns must be a list of columns");u(this,A,{scroller:[...x(t(this,p).classes.scroller),...x(z.DEFAULT_OPTIONS.classes.scroller)],thead:[...x(t(this,p).classes.thead),...x(z.DEFAULT_OPTIONS.classes.thead)],tbody:[...x(t(this,p).classes.tbody),...x(z.DEFAULT_OPTIONS.classes.tbody)],tfoot:[...x(t(this,p).classes.tfoot),...x(z.DEFAULT_OPTIONS.classes.tfoot)],tr:[...x(t(this,p).classes.tr),...x(z.DEFAULT_OPTIONS.classes.tr)],th:[...x(t(this,p).classes.th),...x(z.DEFAULT_OPTIONS.classes.th)],td:[...x(t(this,p).classes.td),...x(z.DEFAULT_OPTIONS.classes.td)],mark:[...x(t(this,p).classes.mark),...x(z.DEFAULT_OPTIONS.classes.mark)]}),t(this,E).classList.add("data-table"),u(this,y,document.createElement("div")),t(this,y).classList.add(...t(this,A).scroller),t(this,y).style.overflow="auto",t(this,y).style.height="100%",t(this,E).style.height!==""&&(t(this,y).style.height=t(this,E).style.height,t(this,E).style.height=""),(a=t(this,E).parentElement)==null||a.insertBefore(t(this,y),t(this,E)),t(this,y).append(t(this,E)),t(this,E).querySelectorAll("thead").length>1&&console.warn("Multiple theads found in table. Using last one."),t(this,E).querySelectorAll("tbody").length>1&&console.warn("Multiple tbodys found in table. Using first one.");let s=t(this,E).querySelector("thead:last-of-type");s?u(this,P,s):(u(this,P,document.createElement("thead")),t(this,E).insertBefore(t(this,P),t(this,E).firstChild)),t(this,P).classList.add(...t(this,A).thead);let i=t(this,P).querySelector("tr:last-of-type");i||(i=document.createElement("tr"),t(this,P).append(i)),i.classList.add(...t(this,A).tr),i.innerHTML="";let n=t(this,E).querySelector("tbody:first-of-type");n?u(this,k,n):(u(this,k,document.createElement("tbody")),t(this,E).append(t(this,k))),t(this,k).classList.add(...t(this,A).tbody),t(this,k).addEventListener("click",g=>{var j;if((j=window.getSelection())!=null&&j.toString())return;let T,w,B;if(g.target instanceof HTMLTableCellElement?(w=g.target,T=w.parentElement,B=w.dataset.dtField):g.target instanceof HTMLTableRowElement&&(T=g.target),T){let J=parseInt(T.dataset.dtIndex||"");if(!isNaN(J)){let st=t(this,C).find(tt=>tt._metadata.index===J);if(st){let tt=new CustomEvent("dt.row.clicked",{cancelable:!1,detail:{row:st,index:J,column:B,originalEvent:g}});this.dispatchEvent(tt)}}}});let d=!1;for(let g of t(this,p).columns){let T={field:g.field,title:g.title||_t(g.field),header:document.createElement("th"),headerContent:document.createElement("div"),visible:(m=g.visible)!=null?m:!0,sortable:(b=g.sortable)!=null?b:t(this,p).sortable,searchable:(L=g.searchable)!=null?L:t(this,p).searchable,tokenize:(F=g.tokenize)!=null?F:t(this,p).tokenize,sortOrder:(V=g.sortOrder)!=null?V:null,sortPriority:(D=g.sortPriority)!=null?D:0,resizeStartWidth:null,resizeStartX:null,valueFormatter:g.valueFormatter,elementFormatter:g.elementFormatter,comparatorCallback:g.sorter,filterCallback:g.filter,sortValueCallback:g.sortValue};t(this,v).set(g.field,T);let w=T.header;w.classList.add(...t(this,A).th),w.dataset.dtField=g.field,w.hidden=!T.visible;let B=T.headerContent;B.classList.add("dt-header-content"),w.append(B);let j=document.createElement("div");j.classList.add("dt-header-title-wrapper"),B.append(j);let J=document.createElement("span");J.classList.add("dt-header-title"),J.innerHTML=T.title,j.append(J);let st=document.createElement("div");st.classList.add("dt-sort-icon"),j.append(st);let tt=document.createElement("div");tt.classList.add("dt-resizer"),B.append(tt),i.append(w),T.visible&&(d=!0),T.sortable&&w.classList.add("dt-sortable"),t(this,p).rearrangeable&&(w.draggable=!0),((N=g.resizable)!=null?N:t(this,p).resizable)&&w.classList.add("dt-resizable"),j.addEventListener("click",()=>{w.classList.contains("dt-sortable")&&(T.sortOrder?T.sortOrder==="asc"?this.sort(T.field,"desc"):T.sortOrder&&this.sort(T.field,null):this.sort(T.field,"asc"))}),w.addEventListener("dragstart",t(this,Lt)),w.addEventListener("dragenter",t(this,St)),w.addEventListener("dragover",t(this,xt)),w.addEventListener("dragleave",t(this,Ot)),w.addEventListener("drop",t(this,kt)),w.addEventListener("dragend",t(this,Mt)),w.addEventListener("mousedown",t(this,Tt)),w.addEventListener("dblclick",t(this,Ct)),typeof g.width=="number"?w.style.width=g.width+"px":typeof g.width=="string"&&(w.style.width=g.width)}if(t(this,v).size===0)console.warn("No columns found. At least one column is required.");else if(!d){console.warn("At least a single column must be visible. Showing the first column.");let g=t(this,v).keys().next().value;this.showColumn(g)}this.virtualScroll=t(this,p).virtualScroll,this.loadData((gt=t(this,p).data)!=null?gt:[])}get columnStates(){return[...t(this,v).values()].map(e=>({field:e.field,title:e.title,visible:e.visible,sortOrder:e.sortOrder,sortPriority:e.sortPriority,width:e.header.style.width}))}set columnStates(e){var r,s,i,n;for(let d of e){let a=t(this,v).get(d.field);if(!a){console.warn(`Attempting to restore state for non-existent column ${d.field}`);continue}a.visible=(r=d.visible)!=null?r:a.visible,a.sortOrder=(s=d.sortOrder)!=null?s:a.sortOrder,a.sortPriority=(i=d.sortPriority)!=null?i:a.sortPriority,a.header.style.width=(n=d.width)!=null?n:a.header.style.width}this.refresh()}get rows(){return[...t(this,C)]}get data(){return[...t(this,M).values()]}get length(){return t(this,C)?t(this,C).length:0}get table(){return t(this,E)}get virtualScroll(){return!!t(this,O)}set virtualScroll(e){var r;e!=this.virtualScroll&&(e?u(this,O,new bt({container:t(this,y),element:t(this,k),generator:s=>f(this,l,zt).call(this,s)})):((r=t(this,O))==null||r.stop(),u(this,O,void 0)),f(this,l,yt).call(this))}get scoring(){return t(this,p).scoring}set scoring(e){e!==t(this,p).scoring&&(t(this,p).scoring=e,t(this,_)&&f(this,l,q).call(this))}loadData(e,r={}){var d;let s=t(this,y).scrollTop,i=t(this,y).scrollLeft;r.append||(t(this,M).clear(),u(this,C,[]));let n=t(this,M).size;for(let a of e){let m=f(this,l,jt).call(this,a,n);t(this,M).set(n,m),n++}f(this,l,ct).call(this),f(this,l,q).call(this),r.keepScroll&&(t(this,y).scrollTop=s,t(this,y).scrollLeft=i,(d=t(this,O))==null||d.renderChunk())}showMessage(e,r){Array.isArray(r)?r=r.join(" "):typeof r!="string"&&(r="");let s=t(this,v).size;t(this,k).innerHTML=`<tr class="${r}"><td colSpan=${s}>${e}</td></tr>`}clearMessage(){f(this,l,yt).call(this)}search(e){if(e===""&&(e=void 0),typeof e=="string"){e=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").trim();let r=t(this,p).tokenizer(e).join("|");u(this,_,new RegExp(`${r}`,"gi"))}else u(this,_,e);f(this,l,q).call(this)}filter(e){if(e!=null||(e={}),typeof e!="object"&&typeof e!="function")throw new TypeError("filters must be object or function");u(this,G,e),f(this,l,q).call(this)}sort(e,r){var a;let s=t(this,v).get(e);if(!s){console.warn(`Attempting to sort non-existent column ${e}`);return}r!=s.sortOrder&&(r==="asc"||r==="desc"?s.sortPriority===Number.MAX_VALUE&&(s.sortPriority=Dt(this,ft)._++):(s.sortPriority=Number.MAX_VALUE,Dt(this,ft)._--),s.sortOrder=r);let i=new CustomEvent("dt.col.sort",{cancelable:!0,detail:{column:s.field,order:s.sortOrder}});if(!this.dispatchEvent(i))return;let n=t(this,y).scrollTop,d=t(this,y).scrollLeft;f(this,l,ct).call(this),f(this,l,Et).call(this),t(this,y).scrollTop=n,t(this,y).scrollLeft=d,(a=t(this,O))==null||a.renderChunk()}setColumnVisibility(e,r){let s=t(this,v).get(e);if(!s){console.warn(`Attempting to ${r?"show":"hide"} non-existent column ${e}`);return}if(s.visible===r)return;let i=new CustomEvent("dt.col.visibility",{cancelable:!0,detail:{column:s.field,visible:r}});this.dispatchEvent(i)&&(s.visible=r,f(this,l,ct).call(this),f(this,l,Et).call(this))}showColumn(e){this.setColumnVisibility(e,!0)}hideColumn(e){this.setColumnVisibility(e,!1)}export(e,r=!1){let i=[...(r?t(this,M):t(this,C)).values()],n=[...t(this,v).values()].filter(L=>r||L.visible).map(L=>`"${L.title}"`).join(","),d=i.map(L=>{let F=[];for(let V of Object.keys(L)){let D=t(this,v).get(V);if(!D)continue;let N=L[V];(r||!D.header.hidden)&&(typeof D.valueFormatter=="function"&&(N=D.valueFormatter(N,L)),N=String(N).replace('"','""'),F.push(`"${N}"`))}return F.join(",")}).join(`
|
|
1
|
+
var Kt=Object.defineProperty;var It=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var Vt=f=>{throw TypeError(f)};var At=(f,o,e)=>o in f?Kt(f,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[o]=e,et=(f,o)=>{for(var e in o||(o={}))Qt.call(o,e)&&At(f,e,o[e]);if(It)for(var e of It(o))Jt.call(o,e)&&At(f,e,o[e]);return f};var kt=(f,o,e)=>o.has(f)||Vt("Cannot "+e);var t=(f,o,e)=>(kt(f,o,"read from private field"),e?e.call(f):o.get(f)),h=(f,o,e)=>o.has(f)?Vt("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(f):o.set(f,e),c=(f,o,e,s)=>(kt(f,o,"write to private field"),s?s.call(f,e):o.set(f,e),e),u=(f,o,e)=>(kt(f,o,"access private method"),e);var S=f=>{if(typeof f=="string"&&f!=="")return f.split(" ");if(Array.isArray(f))return f;if(!f)return[];throw new TypeError("classes must be string or array of strings")},Pt=f=>f.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,o=>o.toUpperCase()),Wt=(f="\\S+")=>{let o=new RegExp(`"[^"]*"|${f}`,"g");return e=>(e.match(o)||[]).map(r=>(r=r.toLocaleLowerCase().trim(),r.startsWith('"')&&r.endsWith('"')?{value:r.slice(1,-1),quoted:!0}:{value:r,quoted:!1}))};var ot,I,O,rt,N,$,at,X,q,lt,dt,ht,bt,_t,it=class it{constructor({container:o,element:e,generator:s,nodePadding:r=10}){h(this,bt);h(this,I);h(this,O);h(this,rt);h(this,N,0);h(this,$,0);h(this,at,2);h(this,X,0);h(this,q,!1);h(this,lt,0);h(this,dt,()=>{t(this,I).scrollTop!==t(this,lt)&&(c(this,lt,t(this,I).scrollTop),t(this,X)&&cancelAnimationFrame(t(this,X)),c(this,X,requestAnimationFrame(()=>this.renderChunk())))});h(this,ht,()=>{this.renderChunk()});c(this,I,o),c(this,O,e),c(this,rt,s),c(this,at,r),new IntersectionObserver(n=>{for(let d of n)d.intersectionRatio===1&&this.renderChunk()}).observe(t(this,O))}get rowHeight(){return t(this,$)||u(this,bt,_t).call(this),t(this,$)}get started(){return t(this,q)}scrollToIndex(o){if(o<0||o>=t(this,N))throw new RangeError("Index out of bounds.");this.scrollToPx(this.rowHeight*o)}scrollToPx(o){t(this,I).scrollTop=o,this.renderChunk()}start(o){t(this,q)||(t(this,I).addEventListener("scroll",t(this,dt)),window.addEventListener("resize",t(this,ht)),c(this,q,!0)),t(this,I).classList.add("dt-virtual-scroll"),c(this,N,o),this.renderChunk()}stop(){t(this,X)&&cancelAnimationFrame(t(this,X)),t(this,I).classList.remove("dt-virtual-scroll"),t(this,I).removeEventListener("scroll",t(this,dt)),window.removeEventListener("resize",t(this,ht)),c(this,q,!1)}renderChunk(){let o=t(this,I).scrollTop,e=t(this,N),s=this.rowHeight,r=t(this,at);if(!this.started||!t(this,O).checkVisibility()||!e||!s)return;let i=s*e;t(this,O).innerHTML=`<div style="height: ${i}px;"></div>`;let n=t(this,O).offsetHeight,d=t(this,I).offsetHeight;!t(it,ot)&&n<Math.round(i-1)&&(c(it,ot,!0),console.error("Max element height exceeded. Virtual scroll may not work."));let a=Math.floor(o/s)-r;a=Math.max(0,a);let g=Math.ceil(d/s)+2*r;g=Math.min(e-a,g),a%2===1&&a--;let b=a*s,L=i-(b+g*s);try{t(this,O).innerHTML="";let x=new Array(g).fill(null).map((_,gt)=>t(this,rt).call(this,gt+a)),R=document.createElement("div"),F=document.createElement("div");R.style.visibility="hidden",R.style.height=b+"px",F.style.visibility="hidden",F.style.height=L+"px",t(this,O).append(R),t(this,O).append(...x),t(this,O).append(F)}catch(x){x instanceof RangeError&&console.log(x)}}};ot=new WeakMap,I=new WeakMap,O=new WeakMap,rt=new WeakMap,N=new WeakMap,$=new WeakMap,at=new WeakMap,X=new WeakMap,q=new WeakMap,lt=new WeakMap,dt=new WeakMap,ht=new WeakMap,bt=new WeakSet,_t=function(){if(t(this,N)===0||!t(this,O).checkVisibility()){c(this,$,0);return}let e=Math.min(1e3,t(this,N)),s=[];for(let r=0;r<e;++r)s.push(t(this,rt).call(this,r));if(t(this,O).innerHTML="",t(this,O).append(...s),c(this,$,t(this,O).offsetHeight/e),t(this,$)<=0)throw new nt(`First ${e} rows had no rendered height. Virtual scroll can't be used.`);t(this,$)*t(this,N)>33554400&&console.warn("Virtual scroll height exceeded maximum known element height.")},h(it,ot,!1);var pt=it,nt=class extends Error{constructor(o){super(o)}};var E,W,H,y,v,z,C,M,B,D,V,P,m,U,l,Ut,Mt,Rt,Ft,jt,G,Xt,vt,ct,wt,Dt,Gt,Ht,ut,zt,Et,ft,mt,yt,Tt,Ct,Lt,St,xt,Ot,k=class k extends EventTarget{constructor(e,s={}){var a,g,b,L,x,R,F,_,gt;super();h(this,l);h(this,E);h(this,W);h(this,H);h(this,y);h(this,v,new Map);h(this,z,new Map);h(this,C,[]);h(this,M);h(this,B);h(this,D);h(this,V);h(this,P);h(this,m);h(this,U,!1);h(this,Et,e=>{if(!(e.target instanceof HTMLElement)||!e.target.classList.contains("dt-resizer")||!(e.currentTarget instanceof HTMLElement)||!e.currentTarget.dataset.dtField)return;e.stopImmediatePropagation(),e.preventDefault();let s=e.currentTarget.dataset.dtField,r=t(this,v).get(s);r&&(c(this,P,r),r.resizeStartX=e.clientX,r.resizeStartWidth=r.header.offsetWidth,document.addEventListener("mousemove",t(this,ft)),document.addEventListener("mouseup",t(this,mt)))});h(this,ft,e=>{if(!t(this,P))return;e.stopImmediatePropagation(),e.preventDefault();let s=e.clientX-t(this,P).resizeStartX,r=t(this,P).resizeStartWidth+s;u(this,l,zt).call(this,t(this,P),r)});h(this,mt,e=>{if(!t(this,P))return;e.stopImmediatePropagation(),e.preventDefault(),document.removeEventListener("mousemove",t(this,ft)),document.removeEventListener("mouseup",t(this,mt));let s=new CustomEvent("dt.col.resize",{cancelable:!1,detail:{column:t(this,P).field,width:t(this,P).header.offsetWidth}});this.dispatchEvent(s),c(this,P,void 0)});h(this,yt,e=>{if(!(e.target instanceof HTMLElement)||!e.target.classList.contains("dt-resizer")||!(e.currentTarget instanceof HTMLElement)||!e.currentTarget.dataset.dtField)return;let s=e.currentTarget.dataset.dtField;s&&u(this,l,zt).call(this,s)});h(this,Tt,e=>{let r=e.target.dataset.dtField;e.dataTransfer&&r&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",r))});h(this,Ct,e=>(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),!1));h(this,Lt,e=>{e.target.classList.add("dt-drag-over")});h(this,St,e=>{e.target.classList.remove("dt-drag-over")});h(this,xt,e=>{var g;let s=(g=e.dataTransfer)==null?void 0:g.getData("text/plain"),i=e.currentTarget.dataset.dtField;if(!s||!i)return;e.preventDefault(),e.stopPropagation();let n=[...t(this,v).values()],d=n.findIndex(b=>b.field===s),a=n.findIndex(b=>b.field===i);if(d>-1&&a>-1){let[b]=n.splice(d,1),L=t(this,v).get(i);if(!L)return;n.splice(a,0,b);let x=n.map(F=>F.field),R=new CustomEvent("dt.col.reorder",{cancelable:!0,detail:{draggedColumn:b.field,dropColumn:L.field,order:x}});if(!this.dispatchEvent(R))return;this.setColumnOrder(x)}});h(this,Ot,()=>{let e=document.querySelectorAll(".dt-drag-over");for(let s of e)s.classList.remove("dt-drag-over")});if(c(this,m,et(et({columns:[],data:[]},k.DEFAULT_OPTIONS),s)),t(this,m).enableSearchScoring&&!t(this,m).tokenizeSearch&&(t(this,m).enableSearchScoring=!1,console.warn("Search scoring enabled with tokenization disabled... Ignoring")),typeof e=="string"){let p=document.querySelector(e);if(!p)throw new SyntaxError(`Failed to find table using selector ${e}`);c(this,E,p)}else c(this,E,e);if(!(t(this,E)instanceof HTMLTableElement))throw new TypeError("Invalid table element type. Must be HTMLTableElement");if(!Array.isArray(t(this,m).columns))throw new TypeError("columns must be a list of columns");c(this,V,{scroller:[...S(t(this,m).classes.scroller),...S(k.DEFAULT_OPTIONS.classes.scroller)],thead:[...S(t(this,m).classes.thead),...S(k.DEFAULT_OPTIONS.classes.thead)],tbody:[...S(t(this,m).classes.tbody),...S(k.DEFAULT_OPTIONS.classes.tbody)],tfoot:[...S(t(this,m).classes.tfoot),...S(k.DEFAULT_OPTIONS.classes.tfoot)],tr:[...S(t(this,m).classes.tr),...S(k.DEFAULT_OPTIONS.classes.tr)],th:[...S(t(this,m).classes.th),...S(k.DEFAULT_OPTIONS.classes.th)],td:[...S(t(this,m).classes.td),...S(k.DEFAULT_OPTIONS.classes.td)],mark:[...S(t(this,m).classes.mark),...S(k.DEFAULT_OPTIONS.classes.mark)]}),t(this,E).classList.add("data-table"),c(this,y,document.createElement("div")),t(this,y).classList.add(...t(this,V).scroller),t(this,y).style.overflow="auto",t(this,y).style.height="100%",t(this,E).style.height!==""&&(t(this,y).style.height=t(this,E).style.height,t(this,E).style.height=""),(a=t(this,E).parentElement)==null||a.insertBefore(t(this,y),t(this,E)),t(this,y).append(t(this,E)),t(this,E).querySelectorAll("thead").length>1&&console.warn("Multiple theads found in table. Using last one."),t(this,E).querySelectorAll("tbody").length>1&&console.warn("Multiple tbodys found in table. Using first one.");let r=t(this,E).querySelector("thead:last-of-type");r?c(this,W,r):(c(this,W,document.createElement("thead")),t(this,E).insertBefore(t(this,W),t(this,E).firstChild)),t(this,W).classList.add(...t(this,V).thead);let i=t(this,W).querySelector("tr:last-of-type");i||(i=document.createElement("tr"),t(this,W).append(i)),i.classList.add(...t(this,V).tr),i.innerHTML="";let n=t(this,E).querySelector("tbody:first-of-type");n?c(this,H,n):(c(this,H,document.createElement("tbody")),t(this,E).append(t(this,H))),t(this,H).classList.add(...t(this,V).tbody),t(this,H).addEventListener("click",p=>{var j;if((j=window.getSelection())!=null&&j.toString())return;let T,w,Q;if(p.target instanceof HTMLTableCellElement?(w=p.target,T=w.parentElement,Q=w.dataset.dtField):p.target instanceof HTMLTableRowElement&&(T=p.target),T){let J=parseInt(T.dataset.dtIndex||"");if(!isNaN(J)){let st=t(this,C).find(tt=>tt._metadata.index===J);if(st){let tt=new CustomEvent("dt.row.clicked",{cancelable:!1,detail:{row:st,index:J,column:Q,originalEvent:p}});this.dispatchEvent(tt)}}}});let d=!1;for(let p of t(this,m).columns){let T={field:p.field,title:p.title||Pt(p.field),header:document.createElement("th"),headerContent:document.createElement("div"),visible:(g=p.visible)!=null?g:!0,sortable:(b=p.sortable)!=null?b:t(this,m).sortable,searchable:(L=p.searchable)!=null?L:!1,tokenize:t(this,m).tokenizeSearch&&(x=p.tokenize)!=null?x:!1,sortOrder:(R=p.sortOrder)!=null?R:null,sortPriority:(F=p.sortPriority)!=null?F:0,resizeStartWidth:null,resizeStartX:null,valueFormatter:p.valueFormatter,elementFormatter:p.elementFormatter,comparatorCallback:p.sorter,filterCallback:p.filter,sortValueCallback:p.sortValue};t(this,v).set(p.field,T);let w=T.header;w.classList.add(...t(this,V).th),w.dataset.dtField=p.field,w.hidden=!T.visible;let Q=T.headerContent;Q.classList.add("dt-header-content"),w.append(Q);let j=document.createElement("div");j.classList.add("dt-header-title-wrapper"),Q.append(j);let J=document.createElement("span");J.classList.add("dt-header-title"),J.innerHTML=T.title,j.append(J);let st=document.createElement("div");st.classList.add("dt-sort-icon"),j.append(st);let tt=document.createElement("div");tt.classList.add("dt-resizer"),Q.append(tt),i.append(w),T.visible&&(d=!0),T.sortable&&w.classList.add("dt-sortable"),t(this,m).rearrangeable&&(w.draggable=!0),((_=p.resizable)!=null?_:t(this,m).resizable)&&w.classList.add("dt-resizable"),j.addEventListener("click",()=>{w.classList.contains("dt-sortable")&&(T.sortOrder?T.sortOrder==="asc"?this.sort(T.field,"desc"):T.sortOrder&&this.sort(T.field,null):this.sort(T.field,"asc"))}),w.addEventListener("dragstart",t(this,Tt)),w.addEventListener("dragenter",t(this,Lt)),w.addEventListener("dragover",t(this,Ct)),w.addEventListener("dragleave",t(this,St)),w.addEventListener("drop",t(this,xt)),w.addEventListener("dragend",t(this,Ot)),w.addEventListener("mousedown",t(this,Et)),w.addEventListener("dblclick",t(this,yt)),typeof p.width=="number"?w.style.width=p.width+"px":typeof p.width=="string"&&(w.style.width=p.width)}if(t(this,v).size===0)console.warn("No columns found. At least one column is required.");else if(!d){console.warn("At least a single column must be visible. Showing the first column.");let p=t(this,v).keys().next().value;this.showColumn(p)}this.virtualScroll=t(this,m).virtualScroll,this.loadData((gt=t(this,m).data)!=null?gt:[])}get columnStates(){return[...t(this,v).values()].map(e=>({field:e.field,title:e.title,visible:e.visible,sortOrder:e.sortOrder,sortPriority:e.sortPriority,width:e.header.style.width}))}set columnStates(e){var s,r,i,n;for(let d of e){let a=t(this,v).get(d.field);if(!a){console.warn(`Attempting to restore state for non-existent column ${d.field}`);continue}a.visible=(s=d.visible)!=null?s:a.visible,a.sortOrder=(r=d.sortOrder)!=null?r:a.sortOrder,a.sortPriority=(i=d.sortPriority)!=null?i:a.sortPriority,a.header.style.width=(n=d.width)!=null?n:a.header.style.width}this.refresh()}get rows(){return[...t(this,C)]}get data(){return[...t(this,z).values()]}get length(){return t(this,C)?t(this,C).length:0}get table(){return t(this,E)}get virtualScroll(){return!!t(this,D)}set virtualScroll(e){var s;e!=this.virtualScroll&&(e?c(this,D,new pt({container:t(this,y),element:t(this,H),generator:r=>u(this,l,Ht).call(this,r)})):((s=t(this,D))==null||s.stop(),c(this,D,void 0)),u(this,l,wt).call(this))}get scoring(){return t(this,m).enableSearchScoring}set scoring(e){if(e&&!t(this,m).tokenizeSearch){console.warn("Cannot enable scoring when tokenization is disabled... Ignoring");return}e!==t(this,m).enableSearchScoring&&(t(this,m).enableSearchScoring=e,t(this,M)&&u(this,l,G).call(this))}loadData(e,s={}){var d;let r=t(this,y).scrollTop,i=t(this,y).scrollLeft;s.append||(t(this,z).clear(),c(this,C,[]));let n=t(this,z).size;for(let a of e){let g=u(this,l,Ut).call(this,a,n);t(this,z).set(n,g),n++}u(this,l,ct).call(this),u(this,l,G).call(this),s.keepScroll&&(t(this,y).scrollTop=r,t(this,y).scrollLeft=i,(d=t(this,D))==null||d.renderChunk())}showMessage(e,s){Array.isArray(s)?s=s.join(" "):typeof s!="string"&&(s="");let r=t(this,v).size;t(this,H).innerHTML=`<tr class="${s}"><td colSpan=${r}>${e}</td></tr>`}clearMessage(){u(this,l,wt).call(this)}search(e){e===""&&(e=void 0),typeof e=="string"?t(this,m).tokenizeSearch?c(this,M,t(this,m).tokenizer(e)):c(this,M,[{value:e.toLocaleLowerCase(),quoted:!0}]):c(this,M,e),u(this,l,G).call(this)}filter(e){if(e!=null||(e={}),typeof e!="object"&&typeof e!="function")throw new TypeError("filters must be object or function");c(this,B,e),u(this,l,G).call(this)}sort(e,s){var a;let r=t(this,v).get(e);if(!r){console.warn(`Attempting to sort non-existent column ${e}`);return}if(s===r.sortOrder)return;if(s&&!r.sortOrder){let g=this.columnStates.map(b=>b.sortOrder?b.sortPriority:0);r.sortPriority=Math.max(...g)+1}r.sortOrder=s;let i=new CustomEvent("dt.col.sort",{cancelable:!0,detail:{column:r.field,order:r.sortOrder}});if(!this.dispatchEvent(i))return;let n=t(this,y).scrollTop,d=t(this,y).scrollLeft;u(this,l,ct).call(this),u(this,l,vt).call(this),t(this,y).scrollTop=n,t(this,y).scrollLeft=d,(a=t(this,D))==null||a.renderChunk()}setColumnVisibility(e,s){let r=t(this,v).get(e);if(!r){console.warn(`Attempting to ${s?"show":"hide"} non-existent column ${e}`);return}if(r.visible===s)return;let i=new CustomEvent("dt.col.visibility",{cancelable:!0,detail:{column:r.field,visible:s}});this.dispatchEvent(i)&&(r.visible=s,u(this,l,ct).call(this),u(this,l,vt).call(this))}showColumn(e){this.setColumnVisibility(e,!0)}hideColumn(e){this.setColumnVisibility(e,!1)}export(e,s=!1){let i=[...(s?t(this,z):t(this,C)).values()],n=[...t(this,v).values()].filter(L=>s||L.visible).map(L=>`"${L.title}"`).join(","),d=i.map(L=>{let x=[];for(let R of Object.keys(L)){let F=t(this,v).get(R);if(!F)continue;let _=L[R];(s||!F.header.hidden)&&(typeof F.valueFormatter=="function"&&(_=F.valueFormatter(_,L)),_=String(_).replace('"','""'),x.push(`"${_}"`))}return x.join(",")}).join(`
|
|
2
2
|
`),a=n+`
|
|
3
|
-
`+d,
|
|
3
|
+
`+d,g=new Blob([a],{type:"text/csv;charset=utf-8,"}),b=document.createElement("a");b.style.display="none",b.href=URL.createObjectURL(g),b.download=`${e}.csv`,document.body.append(b),b.click(),b.remove()}scrollToRow(e){var i;let r=(i=e._metadata)==null?void 0:i.index;if(typeof r=="number")this.scrollToOriginalIndex(r);else throw new TypeError("Invalid row")}scrollToOriginalIndex(e){let s=t(this,z).get(e);if(s){let r=t(this,C).indexOf(s);if(r>=0){this.scrollToFilteredIndex(r);return}else throw new Error("Cannot scroll to filtered out row")}else throw new RangeError(`Row index ${e} out of range`)}scrollToFilteredIndex(e){let s=t(this,C)[e];if(!s)throw new RangeError(`Row index ${e} out of range`);if(t(this,D))t(this,D).scrollToIndex(e);else{let r=t(this,H).querySelector(`tr[data-dt-index="${s._metadata.index}"]`);if(r){r.scrollIntoView(!0);let i=parseFloat(getComputedStyle(t(this,W)).height);t(this,y).scrollTop-=i}}}scrollToPx(e){if(t(this,D))t(this,D).scrollToPx(e);else{let s=parseFloat(getComputedStyle(t(this,W)).height);t(this,y).scrollTop-=s}}setColumnOrder(e){if(!Array.isArray(e))throw new TypeError("fields must be an array of field names");let s=new Map;for(let r of e){let i=t(this,v).get(r);i&&s.set(r,i)}for(let[r,i]of t(this,v))s.has(r)||s.set(r,i);c(this,v,s),this.refresh()}refresh(){u(this,l,ct).call(this),u(this,l,G).call(this)}indexOf(e,s){let i=[...t(this,z).values()].find(n=>{if(e in n)return n[e]===s});return i?i._metadata.index:-1}updateRow(e,s){let r=t(this,z).get(e);r&&(Object.assign(r,s),u(this,l,G).call(this))}deleteRow(e){t(this,z).delete(e),u(this,l,G).call(this)}withoutUpdates(e){c(this,U,!0);try{e(this)}finally{c(this,U,!1),this.refresh()}}addEventListener(e,s,r){super.addEventListener(e,s,r)}};E=new WeakMap,W=new WeakMap,H=new WeakMap,y=new WeakMap,v=new WeakMap,z=new WeakMap,C=new WeakMap,M=new WeakMap,B=new WeakMap,D=new WeakMap,V=new WeakMap,P=new WeakMap,m=new WeakMap,U=new WeakMap,l=new WeakSet,Ut=function(e,s){let r={index:s++,tokens:{},compareValues:{},sortValues:{}};e._metadata=r;for(let[i,n]of t(this,v)){let d=u(this,l,ut).call(this,e,i);typeof n.sortValueCallback=="function"?r.sortValues[i]=n.sortValueCallback(d):d instanceof String?r.sortValues[i]=d.toLocaleLowerCase():r.sortValues[i]=d,r.compareValues[i]=String(d).toLocaleLowerCase(),n.searchable&&n.tokenize&&d&&(r.tokens[i]=t(this,m).tokenizer(d).map(a=>a.value))}return e},Mt=function(e,s){if(e.length===0||s.length===0)return 0;let r=0,i=0;if(s===e)i=k.MatchWeights.EXACT,r=e.length;else if(s.startsWith(e))i=k.MatchWeights.PREFIX,r=e.length;else if(s.includes(e))i=k.MatchWeights.SUBSTRING,r=e.length;else return 0;let d=1/(1+(s.length-e.length));return r*i*d},Rt=function(e,s,r){return e instanceof RegExp?e.test(s)?1:0:t(this,m).enableSearchScoring?e.quoted||!r?u(this,l,Mt).call(this,e.value,s):r.map(i=>u(this,l,Mt).call(this,e.value,i)).reduce((i,n)=>i+=n,0):e.quoted||!r?s.includes(e.value)?1:0:r.some(i=>i==e.value)?1:0},Ft=function(e,s,r){if(Array.isArray(s)){for(let i of s)if(u(this,l,Ft).call(this,e,i))return!0;return!1}return typeof r=="function"?r(e,s):s instanceof RegExp?s.test(String(e)):s===e},jt=function(e,s){if(typeof t(this,B)=="function")return t(this,B).call(this,e,s);for(let r of Object.keys(t(this,B)||{})){let i=t(this,B)[r];if(i==null)continue;let n=u(this,l,ut).call(this,e,r);if(typeof i=="function"){if(!i(n))return!1}else{let d=t(this,v).get(r),a=d?d.filterCallback:void 0;if(!u(this,l,Ft).call(this,n,i,a))return!1}}return!0},G=function(){if(t(this,U))return;let e=[...t(this,z).values()];c(this,C,e.filter((r,i)=>{if(r._metadata.searchScore=0,!u(this,l,jt).call(this,r,i))return!1;if(!t(this,M))return!0;let d=[...[...t(this,v).values()].filter(a=>a.searchable).map(a=>a.field),...t(this,m).extraSearchFields];for(let a of d){let g=t(this,v).get(a),b=String(u(this,l,ut).call(this,r,a)),L=r._metadata.compareValues[a],x=r._metadata.tokens[a],R=0;if(t(this,M)instanceof RegExp)R=u(this,l,Rt).call(this,t(this,M),b,x);else for(let F of t(this,M))R+=u(this,l,Rt).call(this,F,L,x);r._metadata.searchScore+=R}return r._metadata.searchScore>0})),u(this,l,vt).call(this);let s=new CustomEvent("dt.rows.changed",{cancelable:!1,detail:{dataTable:this}});this.dispatchEvent(s)},Xt=function(e,s,r){let i,n;if(r.sortOrder==="asc"?(i=e._metadata.sortValues[r.field],n=s._metadata.sortValues[r.field]):r.sortOrder==="desc"&&(i=s._metadata.sortValues[r.field],n=e._metadata.sortValues[r.field]),typeof r.sorter=="function"){let d=r.sorter(i,n);if(d!==0)return d}return i<n?-1:i>n?1:0},vt=function(){if(t(this,U))return;let e=[...t(this,v).values()].filter(s=>!s.header.hidden&&s.sortOrder).sort((s,r)=>s.sortPriority-r.sortPriority);t(this,C).sort((s,r)=>{if(this.scoring&&t(this,M)){let i=s._metadata.searchScore||0,n=r._metadata.searchScore||0;if(i>n)return-1;if(i<n)return 1}for(let i of e){let n=u(this,l,Xt).call(this,s,r,i);if(n!==0)return n}return s._metadata.index-r._metadata.index}),u(this,l,wt).call(this)},ct=function(){var e,s,r,i,n,d,a;if(!t(this,U))for(let g of t(this,v).values())(e=g.header.parentElement)==null||e.append(g.header),g.header.hidden=!g.visible,g.sortOrder==="asc"?((s=g.header)==null||s.classList.add("dt-ascending"),(r=g.header)==null||r.classList.remove("dt-descending")):g.sortOrder==="desc"?((i=g.header)==null||i.classList.add("dt-descending"),(n=g.header)==null||n.classList.remove("dt-ascending")):((d=g.header)==null||d.classList.remove("dt-ascending"),(a=g.header)==null||a.classList.remove("dt-descending"))},wt=function(){if(!t(this,U)){if(t(this,H).innerHTML="",t(this,D))try{t(this,D).start(t(this,C).length)}catch(e){e instanceof nt&&(console.warn("Failed to start virtual scroll... falling back to standard rendering"),console.warn(e.stack))}else{if(t(this,C).length>$t){let s=$t.toLocaleString();console.warn(`Virtual scroll disabled with more than ${s} rows... Good luck with that!`)}let e=t(this,C).map((s,r)=>u(this,l,Ht).call(this,r));t(this,H).append(...e)}t(this,z).size===0?this.showMessage(t(this,m).noDataText,"dt-empty"):t(this,C).length===0&&this.showMessage(t(this,m).noMatchText,"dt-empty")}},Dt=function(e,s){if(e.children.length===0){let r=e.innerText,i=t(this,V).mark.join(" ");r=r.replace(s,n=>`<mark class="${i}">${n}</mark>`),e.innerHTML=r}else for(let r of e.children)r instanceof HTMLElement&&u(this,l,Dt).call(this,r,s)},Gt=function(e,s,r,i){if(typeof r.valueFormatter=="function"&&(s=r.valueFormatter(s,i)),e.innerText=s==null?"-":s,typeof r.elementFormatter=="function"&&r.elementFormatter(s,i,e),t(this,m).highlightSearch&&t(this,M)&&r.searchable){let n;if(t(this,M)instanceof RegExp)n=t(this,M);else{let d=t(this,M).map(a=>a.value).join("|");n=new RegExp(d,"gi")}u(this,l,Dt).call(this,e,n)}e.hidden=!r.visible},Ht=function(e){let s=t(this,C)[e],r=document.createElement("tr");r.classList.add(...t(this,V).tr),r.dataset.dtIndex=String(s._metadata.index);for(let[i,n]of t(this,v)){let d=u(this,l,ut).call(this,s,i),a=document.createElement("td");a.classList.add(...t(this,V).td),a.dataset.dtField=i;let g=n.header.style.width;g&&g!=="0px"&&(a.style.maxWidth=g),u(this,l,Gt).call(this,a,d,n,s),r.append(a)}if(typeof t(this,m).rowFormatter=="function")try{t(this,m).rowFormatter(s,r)}catch(i){console.error("Row formatter callback failed with the following error"),console.error(i)}return r},ut=function(e,s){let r=s.split("."),i=e;for(let n of r)if(i&&typeof i=="object")i=i[n];else return;return i},zt=function(e,s){if(typeof e=="string"){let b=t(this,v).get(e);if(!b)throw new Error("Column not found");e=b}let r,i;s==null?(r="",i=""):s<=0?(r="0px",i=""):(r=`${s}px`,i=`${s}px`);let n=e.header.offsetWidth;e.header.style.width=r,e.header.style.maxWidth=r;let d=t(this,H).querySelectorAll(`td[data-dt-field="${e.field}"]`);for(let b of d)b.style.maxWidth=i;let a=e.header.offsetWidth-n,g=t(this,E).offsetWidth+a;t(this,E).style.width=`${g}px`},Et=new WeakMap,ft=new WeakMap,mt=new WeakMap,yt=new WeakMap,Tt=new WeakMap,Ct=new WeakMap,Lt=new WeakMap,St=new WeakMap,xt=new WeakMap,Ot=new WeakMap,k.MatchWeights={EXACT:100,PREFIX:50,SUBSTRING:10},k.DEFAULT_OPTIONS={virtualScroll:!0,highlightSearch:!0,tokenizeSearch:!1,enableSearchScoring:!1,sortable:!0,resizable:!0,rearrangeable:!0,extraSearchFields:[],noDataText:"No records found",noMatchText:"No matching records found",classes:{scroller:"dt-scroller",thead:"dt-headers",tbody:"",tfoot:"",tr:"",th:"",td:""},tokenizer:Wt()};var Nt=k,$t=1e4;var K,Y,A,Z,Bt=class{constructor(o,e,s){h(this,K);h(this,Y);h(this,A,{saveColumnSorting:!0,saveColumnVisibility:!0,saveColumnWidth:!0,saveColumnOrder:!0});h(this,Z,()=>setTimeout(()=>this.saveState(),0));c(this,K,o),c(this,Y,e),c(this,A,et(et({},t(this,A)),s)),this.restoreState(),t(this,A).saveColumnSorting&&o.addEventListener("dt.col.sort",t(this,Z)),t(this,A).saveColumnVisibility&&o.addEventListener("dt.col.visibility",t(this,Z)),t(this,A).saveColumnWidth&&o.addEventListener("dt.col.resize",t(this,Z)),t(this,A).saveColumnOrder&&o.addEventListener("dt.col.reorder",t(this,Z))}saveState(){let o=t(this,K).columnStates;for(let e of o)t(this,A).saveColumnSorting||(e.sortOrder=void 0,e.sortPriority=void 0),t(this,A).saveColumnVisibility||(e.visible=void 0),t(this,A).saveColumnWidth||(e.width=void 0);localStorage.setItem(t(this,Y),JSON.stringify(t(this,K).columnStates))}restoreState(){let o=localStorage.getItem(t(this,Y));if(o)try{let e=JSON.parse(o);t(this,K).columnStates=e,t(this,A).saveColumnOrder&&t(this,K).setColumnOrder(e.map(s=>s.field))}catch(e){console.error("Failed to restore DataTable state:",e)}}clearState(){localStorage.removeItem(t(this,Y))}};K=new WeakMap,Y=new WeakMap,A=new WeakMap,Z=new WeakMap;export{Nt as DataTable,Bt as LocalStorageAdapter,Wt as createRegexTokenizer};
|
|
4
4
|
//# sourceMappingURL=datatable.mjs.map
|