@timlassiter11/yatl 0.1.10 → 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.d.mts
CHANGED
|
@@ -36,12 +36,16 @@ type ComparatorCallback = (a: any, b: any) => number;
|
|
|
36
36
|
* @returns The derived value for sorting (e.g., a number or a standardized string).
|
|
37
37
|
*/
|
|
38
38
|
type SortValueCallback = (value: any) => number | string;
|
|
39
|
+
interface QueryToken {
|
|
40
|
+
value: string;
|
|
41
|
+
quoted: boolean;
|
|
42
|
+
}
|
|
39
43
|
/**
|
|
40
44
|
* Callback for tokenizing a value into a list of string tokens.
|
|
41
45
|
* @param value - The value to tokenize.
|
|
42
46
|
* @returns An array of tokens.
|
|
43
47
|
*/
|
|
44
|
-
type TokenizerCallback = (value: any) =>
|
|
48
|
+
type TokenizerCallback = (value: any) => QueryToken[];
|
|
45
49
|
/**
|
|
46
50
|
* Callback for filtering a row.
|
|
47
51
|
* @param row - The row data.
|
|
@@ -215,25 +219,19 @@ interface TableOptions {
|
|
|
215
219
|
*/
|
|
216
220
|
highlightSearch?: boolean;
|
|
217
221
|
/**
|
|
218
|
-
* Whether
|
|
219
|
-
* Can be overridden on individual columns.
|
|
222
|
+
* Whether the search query should be tokenized.
|
|
220
223
|
*/
|
|
221
|
-
|
|
224
|
+
tokenizeSearch?: boolean;
|
|
222
225
|
/**
|
|
223
|
-
* Whether
|
|
224
|
-
*
|
|
226
|
+
* Whether search results should be scored or not.
|
|
227
|
+
* Scoring is very computationally expensive...
|
|
225
228
|
*/
|
|
226
|
-
|
|
229
|
+
enableSearchScoring?: boolean;
|
|
227
230
|
/**
|
|
228
|
-
* Whether columns
|
|
231
|
+
* Whether columns should be sortable by default.
|
|
229
232
|
* Can be overridden on individual columns.
|
|
230
233
|
*/
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Whether search results should be scored or not.
|
|
234
|
-
* Scoring is very computationally expensive...
|
|
235
|
-
*/
|
|
236
|
-
scoring?: boolean;
|
|
234
|
+
sortable?: boolean;
|
|
237
235
|
/**
|
|
238
236
|
* Whether columns should be resizable by default.
|
|
239
237
|
* Can be overridden on individual columns.
|
|
@@ -276,6 +274,11 @@ interface LoadOptions {
|
|
|
276
274
|
keepScroll?: boolean;
|
|
277
275
|
}
|
|
278
276
|
|
|
277
|
+
declare const createRegexTokenizer: (exp?: string) => (value: string) => {
|
|
278
|
+
value: string;
|
|
279
|
+
quoted: boolean;
|
|
280
|
+
}[];
|
|
281
|
+
|
|
279
282
|
/**
|
|
280
283
|
* Represents a dynamic and interactive table with features like sorting, searching, filtering,
|
|
281
284
|
* column resizing, column rearranging, and virtual scrolling.
|
|
@@ -302,6 +305,7 @@ interface LoadOptions {
|
|
|
302
305
|
*/
|
|
303
306
|
declare class DataTable extends EventTarget {
|
|
304
307
|
#private;
|
|
308
|
+
private static readonly MatchWeights;
|
|
305
309
|
private static readonly DEFAULT_OPTIONS;
|
|
306
310
|
/**
|
|
307
311
|
* Initializes a new instance of the DataTable.
|
|
@@ -525,4 +529,4 @@ declare class LocalStorageAdapter {
|
|
|
525
529
|
clearState(): void;
|
|
526
530
|
}
|
|
527
531
|
|
|
528
|
-
export { type CellFormatterCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnState, type ComparatorCallback, DataTable, type DataTableEventMap, type FilterCallback, type LoadOptions, LocalStorageAdapter, type RowFormatterCallback, type SortOrder, type SortValueCallback, type TableClasses, type TableOptions, type TokenizerCallback, type ValueFormatterCallback };
|
|
532
|
+
export { type CellFormatterCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnState, type ComparatorCallback, DataTable, type DataTableEventMap, type FilterCallback, type LoadOptions, LocalStorageAdapter, type QueryToken, type RowFormatterCallback, type SortOrder, type SortValueCallback, type TableClasses, type TableOptions, type TokenizerCallback, type ValueFormatterCallback, createRegexTokenizer };
|
package/dist/datatable.d.ts
CHANGED
|
@@ -36,12 +36,16 @@ type ComparatorCallback = (a: any, b: any) => number;
|
|
|
36
36
|
* @returns The derived value for sorting (e.g., a number or a standardized string).
|
|
37
37
|
*/
|
|
38
38
|
type SortValueCallback = (value: any) => number | string;
|
|
39
|
+
interface QueryToken {
|
|
40
|
+
value: string;
|
|
41
|
+
quoted: boolean;
|
|
42
|
+
}
|
|
39
43
|
/**
|
|
40
44
|
* Callback for tokenizing a value into a list of string tokens.
|
|
41
45
|
* @param value - The value to tokenize.
|
|
42
46
|
* @returns An array of tokens.
|
|
43
47
|
*/
|
|
44
|
-
type TokenizerCallback = (value: any) =>
|
|
48
|
+
type TokenizerCallback = (value: any) => QueryToken[];
|
|
45
49
|
/**
|
|
46
50
|
* Callback for filtering a row.
|
|
47
51
|
* @param row - The row data.
|
|
@@ -215,25 +219,19 @@ interface TableOptions {
|
|
|
215
219
|
*/
|
|
216
220
|
highlightSearch?: boolean;
|
|
217
221
|
/**
|
|
218
|
-
* Whether
|
|
219
|
-
* Can be overridden on individual columns.
|
|
222
|
+
* Whether the search query should be tokenized.
|
|
220
223
|
*/
|
|
221
|
-
|
|
224
|
+
tokenizeSearch?: boolean;
|
|
222
225
|
/**
|
|
223
|
-
* Whether
|
|
224
|
-
*
|
|
226
|
+
* Whether search results should be scored or not.
|
|
227
|
+
* Scoring is very computationally expensive...
|
|
225
228
|
*/
|
|
226
|
-
|
|
229
|
+
enableSearchScoring?: boolean;
|
|
227
230
|
/**
|
|
228
|
-
* Whether columns
|
|
231
|
+
* Whether columns should be sortable by default.
|
|
229
232
|
* Can be overridden on individual columns.
|
|
230
233
|
*/
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Whether search results should be scored or not.
|
|
234
|
-
* Scoring is very computationally expensive...
|
|
235
|
-
*/
|
|
236
|
-
scoring?: boolean;
|
|
234
|
+
sortable?: boolean;
|
|
237
235
|
/**
|
|
238
236
|
* Whether columns should be resizable by default.
|
|
239
237
|
* Can be overridden on individual columns.
|
|
@@ -276,6 +274,11 @@ interface LoadOptions {
|
|
|
276
274
|
keepScroll?: boolean;
|
|
277
275
|
}
|
|
278
276
|
|
|
277
|
+
declare const createRegexTokenizer: (exp?: string) => (value: string) => {
|
|
278
|
+
value: string;
|
|
279
|
+
quoted: boolean;
|
|
280
|
+
}[];
|
|
281
|
+
|
|
279
282
|
/**
|
|
280
283
|
* Represents a dynamic and interactive table with features like sorting, searching, filtering,
|
|
281
284
|
* column resizing, column rearranging, and virtual scrolling.
|
|
@@ -302,6 +305,7 @@ interface LoadOptions {
|
|
|
302
305
|
*/
|
|
303
306
|
declare class DataTable extends EventTarget {
|
|
304
307
|
#private;
|
|
308
|
+
private static readonly MatchWeights;
|
|
305
309
|
private static readonly DEFAULT_OPTIONS;
|
|
306
310
|
/**
|
|
307
311
|
* Initializes a new instance of the DataTable.
|
|
@@ -525,4 +529,4 @@ declare class LocalStorageAdapter {
|
|
|
525
529
|
clearState(): void;
|
|
526
530
|
}
|
|
527
531
|
|
|
528
|
-
export { type CellFormatterCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnState, type ComparatorCallback, DataTable, type DataTableEventMap, type FilterCallback, type LoadOptions, LocalStorageAdapter, type RowFormatterCallback, type SortOrder, type SortValueCallback, type TableClasses, type TableOptions, type TokenizerCallback, type ValueFormatterCallback };
|
|
532
|
+
export { type CellFormatterCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnState, type ComparatorCallback, DataTable, type DataTableEventMap, type FilterCallback, type LoadOptions, LocalStorageAdapter, type QueryToken, type RowFormatterCallback, type SortOrder, type SortValueCallback, type TableClasses, type TableOptions, type TokenizerCallback, type ValueFormatterCallback, createRegexTokenizer };
|
package/dist/datatable.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var yatl=(()=>{var bt=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames,_t=Object.getOwnPropertySymbols;var $t=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Wt=d=>{throw TypeError(d)};var Nt=(d,n,e)=>n in d?bt(d,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[n]=e,et=(d,n)=>{for(var e in n||(n={}))$t.call(n,e)&&Nt(d,e,n[e]);if(_t)for(var e of _t(n))Qt.call(n,e)&&Nt(d,e,n[e]);return d};var te=(d,n)=>{for(var e in n)bt(d,e,{get:n[e],enumerable:!0})},ee=(d,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Zt(n))!$t.call(d,s)&&s!==e&&bt(d,s,{get:()=>n[s],enumerable:!(r=Yt(n,s))||r.enumerable});return d};var re=d=>ee(bt({},"__esModule",{value:!0}),d);var Dt=(d,n,e)=>n.has(d)||Wt("Cannot "+e);var t=(d,n,e)=>(Dt(d,n,"read from private field"),e?e.call(d):n.get(d)),c=(d,n,e)=>n.has(d)?Wt("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(d):n.set(d,e),u=(d,n,e,r)=>(Dt(d,n,"write to private field"),r?r.call(d,e):n.set(d,e),e),f=(d,n,e)=>(Dt(d,n,"access private method"),e);var Ht=(d,n,e,r)=>({set _(s){u(d,n,s,e)},get _(){return t(d,n,r)}});var se={};te(se,{DataTable:()=>Rt,LocalStorageAdapter:()=>Pt});var x=d=>{if(typeof d=="string"&&d!=="")return d.split(" ");if(Array.isArray(d))return d;if(!d)return[];throw new TypeError("classes must be string or array of strings")},Ut=d=>d.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase()),jt=d=>{let n=/"[^"]*"|\S+/g;return(d.match(n)||[]).map(r=>r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r)};var ot,H,S,rt,$,W,at,X,Y,lt,dt,ht,wt,Xt,it=class it{constructor({container:n,element:e,generator:r,nodePadding:s=10}){c(this,wt);c(this,H);c(this,S);c(this,rt);c(this,$,0);c(this,W,0);c(this,at,2);c(this,X,0);c(this,Y,!1);c(this,lt,0);c(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())))});c(this,ht,()=>{this.renderChunk()});u(this,H,n),u(this,S,e),u(this,rt,r),u(this,at,s),new IntersectionObserver(o=>{for(let h of o)h.intersectionRatio===1&&this.renderChunk()}).observe(t(this,S))}get rowHeight(){return t(this,W)||f(this,wt,Xt).call(this),t(this,W)}get started(){return t(this,Y)}scrollToIndex(n){if(n<0||n>=t(this,$))throw new RangeError("Index out of bounds.");this.scrollToPx(this.rowHeight*n)}scrollToPx(n){t(this,H).scrollTop=n,this.renderChunk()}start(n){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,$,n),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 n=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 o=t(this,S).offsetHeight,h=t(this,H).offsetHeight;!t(it,ot)&&o<Math.round(i-1)&&(u(it,ot,!0),console.error("Max element height exceeded. Virtual scroll may not work."));let a=Math.floor(n/r)-s;a=Math.max(0,a);let m=Math.ceil(h/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,wt=new WeakSet,Xt=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.")},c(it,ot,!1);var vt=it,nt=class extends Error{constructor(n){super(n)}};var E,P,k,y,v,M,C,_,G,O,ft,A,I,p,U,l,Gt,Et,zt,Kt,q,Bt,yt,ct,Tt,At,Jt,It,ut,Vt,Ct,mt,pt,Lt,xt,St,Ot,kt,Mt,Ft,z=class z extends EventTarget{constructor(e,r={}){var a,m,b,L,F,V,D,N,gt;super();c(this,l);c(this,E);c(this,P);c(this,k);c(this,y);c(this,v,new Map);c(this,M,new Map);c(this,C,[]);c(this,_);c(this,G);c(this,O);c(this,ft,0);c(this,A);c(this,I);c(this,p);c(this,U,!1);c(this,Ct,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)))});c(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,Vt).call(this,t(this,I),s)});c(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)});c(this,Lt,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,Vt).call(this,r)});c(this,xt,e=>{let s=e.target.dataset.dtField;e.dataTransfer&&s&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s))});c(this,St,e=>(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),!1));c(this,Ot,e=>{e.target.classList.add("dt-drag-over")});c(this,kt,e=>{e.target.classList.remove("dt-drag-over")});c(this,Mt,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 o=[...t(this,v).values()],h=o.findIndex(b=>b.field===r),a=o.findIndex(b=>b.field===i);if(h>-1&&a>-1){let[b]=o.splice(h,1),L=t(this,v).get(i);if(!L)return;o.splice(a,0,b);let F=o.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)}});c(this,Ft,()=>{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 o=t(this,E).querySelector("tbody:first-of-type");o?u(this,k,o):(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 h=!1;for(let g of t(this,p).columns){let T={field:g.field,title:g.title||Ut(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&&(h=!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,xt)),w.addEventListener("dragenter",t(this,Ot)),w.addEventListener("dragover",t(this,St)),w.addEventListener("dragleave",t(this,kt)),w.addEventListener("drop",t(this,Mt)),w.addEventListener("dragend",t(this,Ft)),w.addEventListener("mousedown",t(this,Ct)),w.addEventListener("dblclick",t(this,Lt)),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(!h){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,o;for(let h of e){let a=t(this,v).get(h.field);if(!a){console.warn(`Attempting to restore state for non-existent column ${h.field}`);continue}a.visible=(r=h.visible)!=null?r:a.visible,a.sortOrder=(s=h.sortOrder)!=null?s:a.sortOrder,a.sortPriority=(i=h.sortPriority)!=null?i:a.sortPriority,a.header.style.width=(o=h.width)!=null?o: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 vt({container:t(this,y),element:t(this,k),generator:s=>f(this,l,It).call(this,s)})):((r=t(this,O))==null||r.stop(),u(this,O,void 0)),f(this,l,Tt).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 h;let s=t(this,y).scrollTop,i=t(this,y).scrollLeft;r.append||(t(this,M).clear(),u(this,C,[]));let o=t(this,M).size;for(let a of e){let m=f(this,l,Gt).call(this,a,o);t(this,M).set(o,m),o++}f(this,l,ct).call(this),f(this,l,q).call(this),r.keepScroll&&(t(this,y).scrollTop=s,t(this,y).scrollLeft=i,(h=t(this,O))==null||h.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,Tt).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=Ht(this,ft)._++):(s.sortPriority=Number.MAX_VALUE,Ht(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 o=t(this,y).scrollTop,h=t(this,y).scrollLeft;f(this,l,ct).call(this),f(this,l,yt).call(this),t(this,y).scrollTop=o,t(this,y).scrollLeft=h,(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,yt).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()],o=[...t(this,v).values()].filter(L=>r||L.visible).map(L=>`"${L.title}"`).join(","),h=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
|
+
"use strict";var yatl=(()=>{var pt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable;var $t=h=>{throw TypeError(h)};var _t=(h,n,e)=>n in h?pt(h,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[n]=e,et=(h,n)=>{for(var e in n||(n={}))Nt.call(n,e)&&_t(h,e,n[e]);if(Wt)for(var e of Wt(n))Yt.call(n,e)&&_t(h,e,n[e]);return h};var Zt=(h,n)=>{for(var e in n)pt(h,e,{get:n[e],enumerable:!0})},te=(h,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of qt(n))!Nt.call(h,r)&&r!==e&&pt(h,r,{get:()=>n[r],enumerable:!(s=Jt(n,r))||s.enumerable});return h};var ee=h=>te(pt({},"__esModule",{value:!0}),h);var Mt=(h,n,e)=>n.has(h)||$t("Cannot "+e);var t=(h,n,e)=>(Mt(h,n,"read from private field"),e?e.call(h):n.get(h)),c=(h,n,e)=>n.has(h)?$t("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(h):n.set(h,e),u=(h,n,e,s)=>(Mt(h,n,"write to private field"),s?s.call(h,e):n.set(h,e),e),f=(h,n,e)=>(Mt(h,n,"access private method"),e);var re={};Zt(re,{DataTable:()=>Ft,LocalStorageAdapter:()=>Pt,createRegexTokenizer:()=>Rt});var S=h=>{if(typeof h=="string"&&h!=="")return h.split(" ");if(Array.isArray(h))return h;if(!h)return[];throw new TypeError("classes must be string or array of strings")},Ut=h=>h.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase()),Rt=(h="\\S+")=>{let n=new RegExp(`"[^"]*"|${h}`,"g");return e=>(e.match(n)||[]).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,vt,jt,it=class it{constructor({container:n,element:e,generator:s,nodePadding:r=10}){c(this,vt);c(this,I);c(this,O);c(this,rt);c(this,N,0);c(this,$,0);c(this,at,2);c(this,X,0);c(this,q,!1);c(this,lt,0);c(this,dt,()=>{t(this,I).scrollTop!==t(this,lt)&&(u(this,lt,t(this,I).scrollTop),t(this,X)&&cancelAnimationFrame(t(this,X)),u(this,X,requestAnimationFrame(()=>this.renderChunk())))});c(this,ht,()=>{this.renderChunk()});u(this,I,n),u(this,O,e),u(this,rt,s),u(this,at,r),new IntersectionObserver(o=>{for(let d of o)d.intersectionRatio===1&&this.renderChunk()}).observe(t(this,O))}get rowHeight(){return t(this,$)||f(this,vt,jt).call(this),t(this,$)}get started(){return t(this,q)}scrollToIndex(n){if(n<0||n>=t(this,N))throw new RangeError("Index out of bounds.");this.scrollToPx(this.rowHeight*n)}scrollToPx(n){t(this,I).scrollTop=n,this.renderChunk()}start(n){t(this,q)||(t(this,I).addEventListener("scroll",t(this,dt)),window.addEventListener("resize",t(this,ht)),u(this,q,!0)),t(this,I).classList.add("dt-virtual-scroll"),u(this,N,n),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)),u(this,q,!1)}renderChunk(){let n=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 o=t(this,O).offsetHeight,d=t(this,I).offsetHeight;!t(it,ot)&&o<Math.round(i-1)&&(u(it,ot,!0),console.error("Max element height exceeded. Virtual scroll may not work."));let a=Math.floor(n/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,vt=new WeakSet,jt=function(){if(t(this,N)===0||!t(this,O).checkVisibility()){u(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),u(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.")},c(it,ot,!1);var bt=it,nt=class extends Error{constructor(n){super(n)}};var E,W,H,y,v,z,C,M,B,D,V,P,m,U,l,Gt,Dt,Ht,zt,Bt,G,Kt,wt,ct,Et,It,Qt,At,ut,Vt,yt,ft,mt,Tt,Ct,Lt,St,xt,Ot,kt,k=class k extends EventTarget{constructor(e,s={}){var a,g,b,L,x,R,F,_,gt;super();c(this,l);c(this,E);c(this,W);c(this,H);c(this,y);c(this,v,new Map);c(this,z,new Map);c(this,C,[]);c(this,M);c(this,B);c(this,D);c(this,V);c(this,P);c(this,m);c(this,U,!1);c(this,yt,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&&(u(this,P,r),r.resizeStartX=e.clientX,r.resizeStartWidth=r.header.offsetWidth,document.addEventListener("mousemove",t(this,ft)),document.addEventListener("mouseup",t(this,mt)))});c(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;f(this,l,Vt).call(this,t(this,P),r)});c(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),u(this,P,void 0)});c(this,Tt,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&&f(this,l,Vt).call(this,s)});c(this,Ct,e=>{let r=e.target.dataset.dtField;e.dataTransfer&&r&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",r))});c(this,Lt,e=>(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),!1));c(this,St,e=>{e.target.classList.add("dt-drag-over")});c(this,xt,e=>{e.target.classList.remove("dt-drag-over")});c(this,Ot,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 o=[...t(this,v).values()],d=o.findIndex(b=>b.field===s),a=o.findIndex(b=>b.field===i);if(d>-1&&a>-1){let[b]=o.splice(d,1),L=t(this,v).get(i);if(!L)return;o.splice(a,0,b);let x=o.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)}});c(this,kt,()=>{let e=document.querySelectorAll(".dt-drag-over");for(let s of e)s.classList.remove("dt-drag-over")});if(u(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}`);u(this,E,p)}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,m).columns))throw new TypeError("columns must be a list of columns");u(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"),u(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?u(this,W,r):(u(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 o=t(this,E).querySelector("tbody:first-of-type");o?u(this,H,o):(u(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||Ut(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,Ct)),w.addEventListener("dragenter",t(this,St)),w.addEventListener("dragover",t(this,Lt)),w.addEventListener("dragleave",t(this,xt)),w.addEventListener("drop",t(this,Ot)),w.addEventListener("dragend",t(this,kt)),w.addEventListener("mousedown",t(this,yt)),w.addEventListener("dblclick",t(this,Tt)),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,o;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=(o=d.width)!=null?o: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?u(this,D,new bt({container:t(this,y),element:t(this,H),generator:r=>f(this,l,At).call(this,r)})):((s=t(this,D))==null||s.stop(),u(this,D,void 0)),f(this,l,Et).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)&&f(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(),u(this,C,[]));let o=t(this,z).size;for(let a of e){let g=f(this,l,Gt).call(this,a,o);t(this,z).set(o,g),o++}f(this,l,ct).call(this),f(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(){f(this,l,Et).call(this)}search(e){e===""&&(e=void 0),typeof e=="string"?t(this,m).tokenizeSearch?u(this,M,t(this,m).tokenizer(e)):u(this,M,[{value:e.toLocaleLowerCase(),quoted:!0}]):u(this,M,e),f(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");u(this,B,e),f(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 o=t(this,y).scrollTop,d=t(this,y).scrollLeft;f(this,l,ct).call(this),f(this,l,wt).call(this),t(this,y).scrollTop=o,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,f(this,l,ct).call(this),f(this,l,wt).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()],o=[...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=o+`
|
|
3
|
-
`+
|
|
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);u(this,v,s),this.refresh()}refresh(){f(this,l,ct).call(this),f(this,l,G).call(this)}indexOf(e,s){let i=[...t(this,z).values()].find(o=>{if(e in o)return o[e]===s});return i?i._metadata.index:-1}updateRow(e,s){let r=t(this,z).get(e);r&&(Object.assign(r,s),f(this,l,G).call(this))}deleteRow(e){t(this,z).delete(e),f(this,l,G).call(this)}withoutUpdates(e){u(this,U,!0);try{e(this)}finally{u(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,Gt=function(e,s){let r={index:s++,tokens:{},compareValues:{},sortValues:{}};e._metadata=r;for(let[i,o]of t(this,v)){let d=f(this,l,ut).call(this,e,i);typeof o.sortValueCallback=="function"?r.sortValues[i]=o.sortValueCallback(d):d instanceof String?r.sortValues[i]=d.toLocaleLowerCase():r.sortValues[i]=d,r.compareValues[i]=String(d).toLocaleLowerCase(),o.searchable&&o.tokenize&&d&&(r.tokens[i]=t(this,m).tokenizer(d).map(a=>a.value))}return e},Dt=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},Ht=function(e,s,r){return e instanceof RegExp?e.test(s)?1:0:t(this,m).enableSearchScoring?e.quoted||!r?f(this,l,Dt).call(this,e.value,s):r.map(i=>f(this,l,Dt).call(this,e.value,i)).reduce((i,o)=>i+=o,0):e.quoted||!r?s.includes(e.value)?1:0:r.some(i=>i==e.value)?1:0},zt=function(e,s,r){if(Array.isArray(s)){for(let i of s)if(f(this,l,zt).call(this,e,i))return!0;return!1}return typeof r=="function"?r(e,s):s instanceof RegExp?s.test(String(e)):s===e},Bt=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 o=f(this,l,ut).call(this,e,r);if(typeof i=="function"){if(!i(o))return!1}else{let d=t(this,v).get(r),a=d?d.filterCallback:void 0;if(!f(this,l,zt).call(this,o,i,a))return!1}}return!0},G=function(){if(t(this,U))return;let e=[...t(this,z).values()];u(this,C,e.filter((r,i)=>{if(r._metadata.searchScore=0,!f(this,l,Bt).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(f(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=f(this,l,Ht).call(this,t(this,M),b,x);else for(let F of t(this,M))R+=f(this,l,Ht).call(this,F,L,x);r._metadata.searchScore+=R}return r._metadata.searchScore>0})),f(this,l,wt).call(this);let s=new CustomEvent("dt.rows.changed",{cancelable:!1,detail:{dataTable:this}});this.dispatchEvent(s)},Kt=function(e,s,r){let i,o;if(r.sortOrder==="asc"?(i=e._metadata.sortValues[r.field],o=s._metadata.sortValues[r.field]):r.sortOrder==="desc"&&(i=s._metadata.sortValues[r.field],o=e._metadata.sortValues[r.field]),typeof r.sorter=="function"){let d=r.sorter(i,o);if(d!==0)return d}return i<o?-1:i>o?1:0},wt=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,o=r._metadata.searchScore||0;if(i>o)return-1;if(i<o)return 1}for(let i of e){let o=f(this,l,Kt).call(this,s,r,i);if(o!==0)return o}return s._metadata.index-r._metadata.index}),f(this,l,Et).call(this)},ct=function(){var e,s,r,i,o,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"),(o=g.header)==null||o.classList.remove("dt-ascending")):((d=g.header)==null||d.classList.remove("dt-ascending"),(a=g.header)==null||a.classList.remove("dt-descending"))},Et=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>Xt){let s=Xt.toLocaleString();console.warn(`Virtual scroll disabled with more than ${s} rows... Good luck with that!`)}let e=t(this,C).map((s,r)=>f(this,l,At).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")}},It=function(e,s){if(e.children.length===0){let r=e.innerText,i=t(this,V).mark.join(" ");r=r.replace(s,o=>`<mark class="${i}">${o}</mark>`),e.innerHTML=r}else for(let r of e.children)r instanceof HTMLElement&&f(this,l,It).call(this,r,s)},Qt=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 o;if(t(this,M)instanceof RegExp)o=t(this,M);else{let d=t(this,M).map(a=>a.value).join("|");o=new RegExp(d,"gi")}f(this,l,It).call(this,e,o)}e.hidden=!r.visible},At=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,o]of t(this,v)){let d=f(this,l,ut).call(this,s,i),a=document.createElement("td");a.classList.add(...t(this,V).td),a.dataset.dtField=i;let g=o.header.style.width;g&&g!=="0px"&&(a.style.maxWidth=g),f(this,l,Qt).call(this,a,d,o,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 o of r)if(i&&typeof i=="object")i=i[o];else return;return i},Vt=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 o=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-o,g=t(this,E).offsetWidth+a;t(this,E).style.width=`${g}px`},yt=new WeakMap,ft=new WeakMap,mt=new WeakMap,Tt=new WeakMap,Ct=new WeakMap,Lt=new WeakMap,St=new WeakMap,xt=new WeakMap,Ot=new WeakMap,kt=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:Rt()};var Ft=k,Xt=1e4;var K,Y,A,Z,Pt=class{constructor(n,e,s){c(this,K);c(this,Y);c(this,A,{saveColumnSorting:!0,saveColumnVisibility:!0,saveColumnWidth:!0,saveColumnOrder:!0});c(this,Z,()=>setTimeout(()=>this.saveState(),0));u(this,K,n),u(this,Y,e),u(this,A,et(et({},t(this,A)),s)),this.restoreState(),t(this,A).saveColumnSorting&&n.addEventListener("dt.col.sort",t(this,Z)),t(this,A).saveColumnVisibility&&n.addEventListener("dt.col.visibility",t(this,Z)),t(this,A).saveColumnWidth&&n.addEventListener("dt.col.resize",t(this,Z)),t(this,A).saveColumnOrder&&n.addEventListener("dt.col.reorder",t(this,Z))}saveState(){let n=t(this,K).columnStates;for(let e of n)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 n=localStorage.getItem(t(this,Y));if(n)try{let e=JSON.parse(n);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;return ee(re);})();
|
|
4
4
|
//# sourceMappingURL=datatable.global.js.map
|