@alaarab/ogrid-core 2.5.7 → 2.5.8

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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  function me(t){if(t)return {id:t.id,displayName:t.displayName,email:"email"in t&&t.email?t.email:t.mail||t.userPrincipalName||"",photo:t.photo}}function F(t,e,n){let r=Math.min(t.startRow,t.endRow),o=Math.max(t.startRow,t.endRow),l=Math.min(t.startCol,t.endCol),i=Math.max(t.startCol,t.endCol);return e>=r&&e<=o&&n>=l&&n<=i}function R(t){return {startRow:Math.min(t.startRow,t.endRow),endRow:Math.max(t.startRow,t.endRow),startCol:Math.min(t.startCol,t.endCol),endCol:Math.max(t.startCol,t.endCol)}}function k(t){if(t==null)return "";let e=String(t);return e.includes(",")||e.includes('"')||e.includes(`
2
- `)?`"${e.replace(/"/g,'""')}"`:e}function z(t){return t.map(e=>k(e.name)).join(",")}function Y(t,e,n,r){return t.map((o,l)=>e.map(i=>{if(r?.exportMode==="formulas"&&r.hasFormula&&r.getFormula&&r.columnIdToIndex){let a=r.columnIdToIndex.get(i.columnId);if(a!==void 0&&r.hasFormula(a,l)){let u=r.getFormula(a,l);if(u)return k(u)}}return k(n(o,i.columnId))}).join(","))}function fe(t,e,n,r,o){let l=z(e),i=Y(t,e,n,o),a=[l,...i].join(`
3
- `);j(a,r??`export_${new Date().toISOString().slice(0,10)}.csv`);}function j(t,e){let n=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");try{o.setAttribute("href",r),o.setAttribute("download",e),o.style.visibility="hidden",document.body.appendChild(o),o.click();}finally{try{document.body.removeChild(o);}catch{}URL.revokeObjectURL(r);}}function x(t,e){return e.valueGetter?e.valueGetter(t):t[e.columnId]}function h(t,e){return t.editable===true||typeof t.editable=="function"&&t.editable(e)}function pe(t,e){return {getCellValue:(n,r)=>r<0||r>=t.length||n<0||n>=e.length?null:x(t[r],e[n]),getRowCount:()=>t.length,getColumnCount:()=>e.length}}function _(t){return "children"in t&&Array.isArray(t.children)}function K(t){let e=[];for(let n of t)_(n)?e.push(...K(n.children)):e.push(n);return e}function ge(t,e){function n(m,c){let s=c;for(let d of m)_(d)&&(s=Math.max(s,n(d.children,c+1)));return s}let r=n(t,0);if(r===0){let m=[];for(let c of t)if(!_(c)){if(e&&!e.has(c.columnId))continue;m.push({label:c.name,colSpan:1,isGroup:false,columnDef:c,depth:0});}return [m]}let o=r+1,l=Array.from({length:o},()=>[]),i=new Map;function a(m){let c=i.get(m);if(c!==void 0)return c;let s=0;for(let d of m)_(d)?s+=a(d.children):(!e||e.has(d.columnId))&&s++;return i.set(m,s),s}function u(m,c){for(let s of m)if(_(s)){let d=a(s.children);if(d===0)continue;l[c].push({label:s.headerName,colSpan:d,isGroup:true,depth:c}),u(s.children,c+1);}else {if(e&&!e.has(s.columnId))continue;l[c].push({label:s.name,colSpan:1,isGroup:false,columnDef:s,depth:c});}}return u(t,0),l.filter(m=>m.length>0)}function v(t){return t!=null&&typeof t=="object"&&"type"in t}function w(t){return (v(t.filterable)?t.filterable:null)?.filterField??t.columnId}function Ce(t,e,n){if(n===void 0||n.type==="text"&&n.value.trim()===""||n.type==="multiSelect"&&n.value.length===0||n.type==="date"&&!n.value.from&&!n.value.to||n.type==="people"&&!n.value){let{[e]:o,...l}=t;return l}return {...t,[e]:n}}function Ie(t,e){let n=[];for(let l=0;l<e.length;l++){let i=e[l];(v(i.filterable)?i.filterable:null)?.type==="multiSelect"&&n.push({col:i,field:w(i)});}if(n.length===0)return {};let r=new Map;for(let l=0;l<n.length;l++)r.set(n[l].field,new Set);for(let l=0;l<t.length;l++){let i=t[l];for(let a=0;a<n.length;a++){let u=x(i,n[a].col),m=r.get(n[a].field);u!=null&&u!==""&&m&&m.add(String(u));}}let o={};for(let l=0;l<n.length;l++){let i=r.get(n[l].field);o[n[l].field]=i?Array.from(i).sort():[];}return o}function be(t){let e=[];for(let n of t)(v(n.filterable)?n.filterable:null)?.type==="multiSelect"&&e.push(w(n));return e}function xe(t){let{totalCount:e,filteredCount:n,selectedCount:r,selectedCellCount:o,aggregation:l,suppressRowCount:i}=t,a=[];return i||a.push({key:"total",label:"Rows:",value:e}),n!==void 0&&n!==e&&a.push({key:"filtered",label:"Filtered:",value:n}),r!==void 0&&r>0&&a.push({key:"selected",label:"Selected:",value:r}),o!==void 0&&o>1&&a.push({key:"cells",label:"Cells:",value:o}),l&&(a.push({key:"sum",label:"Sum:",value:l.sum}),a.push({key:"avg",label:"Avg:",value:Math.round(l.avg*100)/100}),a.push({key:"min",label:"Min:",value:l.min}),a.push({key:"max",label:"Max:",value:l.max}),a.push({key:"count",label:"Count:",value:l.count})),a}function he(t,e,n,r){return t?typeof t=="object"?t:{totalCount:e,selectedCount:n>0?n:void 0,filteredCount:r!==void 0&&r!==e?r:void 0}:null}var Z=[10,25,50,100];function kt(t,e){return e.includes(t)?e:[...e,t].sort((n,r)=>n-r)}var Q=5;function Re(t,e,n,r){if(n<=0)return null;let o=r?.maxPageButtons??Q,l=Math.ceil(n/e),i,a,u;if(l<=o){i=[];for(let s=1;s<=l;s++)i.push(s);a=false,u=false;}else {let s=Math.max(1,t-2),d=Math.min(l,t+2);d-s+1<o&&(s===1?d=Math.min(l,s+o-1):d===l&&(s=Math.max(1,d-o+1))),i=[];for(let f=s;f<=d;f++)i.push(f);a=s>1,u=d<l;}let m=Math.max(1,(t-1)*e+1),c=Math.min(t*e,n);return {totalPages:l,pageNumbers:i,showStartEllipsis:a,showEndEllipsis:u,startItem:m,endItem:c,pageSizeOptions:kt(e,r?.pageSizeOptions??Z)}}var ye=[{id:"undo",label:"Undo",shortcut:"Ctrl+Z"},{id:"redo",label:"Redo",shortcut:"Ctrl+Y"},{id:"copy",label:"Copy",shortcut:"Ctrl+C",disabledWhenNoSelection:true,dividerBefore:true},{id:"cut",label:"Cut",shortcut:"Ctrl+X",disabledWhenNoSelection:true},{id:"paste",label:"Paste",shortcut:"Ctrl+V"},{id:"selectAll",label:"Select all",shortcut:"Ctrl+A",dividerBefore:true}];function Te(t){return typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?t.replace("Ctrl","\u2318"):t}function Se(t){let{onCopy:e,onCut:n,onPaste:r,onSelectAll:o,onUndo:l,onRedo:i,onClose:a}=t;return {undo:()=>{l(),a();},redo:()=>{i(),a();},copy:()=>{e(),a();},cut:()=>{n(),a();},paste:()=>{r(),a();},selectAll:()=>{o(),a();}}}var we=[{id:"pinLeft",label:"Pin left"},{id:"pinRight",label:"Pin right"},{id:"unpin",label:"Unpin"}];function De(t){let{canPinLeft:e,canPinRight:n,canUnpin:r,currentSort:o,isSortable:l=true,isResizable:i=true}=t,a=[];if(a.push({id:"pinLeft",label:"Pin left",disabled:!e},{id:"pinRight",label:"Pin right",disabled:!n},{id:"unpin",label:"Unpin",disabled:!r,divider:l||i}),l)if(!o)a.push({id:"sortAsc",label:"Sort ascending"},{id:"sortDesc",label:"Sort descending",divider:i});else {let u=o==="asc"?"desc":"asc",m=o==="asc"?"Sort descending":"Sort ascending";a.push({id:`sort${u==="asc"?"Asc":"Desc"}`,label:m},{id:"clearSort",label:"Clear sort",divider:i});}return i&&a.push({id:"autosizeThis",label:"Autosize this column"},{id:"autosizeAll",label:"Autosize all columns"}),a}function T(t,e,n,r){if(r.valueParser){let l={newValue:t,oldValue:e,data:n,column:r},i=r.valueParser(l);return i===void 0?{valid:false,value:void 0}:{valid:true,value:i}}if(r.cellEditor==="select"&&r.cellEditorParams?.values!=null&&Array.isArray(r.cellEditorParams.values)){let l=r.cellEditorParams.values,i=typeof t=="string"?t:String(t??"");if(i==="")return {valid:true,value:""};let a=l.find(u=>String(u).toLowerCase()===i.toLowerCase());return a!==void 0?{valid:true,value:a}:{valid:false,value:void 0}}let o=r.type;if(o==="date"){let l=ee({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="boolean"){let l=te({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="numeric"){let l=J({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}return {valid:true,value:t}}function J(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function ve(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[$\u20AC\u00A3\u00A5]/g,"").replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim(),r=new Date(n);if(!Number.isNaN(r.getTime()))return r.toISOString()}function Ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim();return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n:void 0}function te(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim().toLowerCase();if(["true","yes","1"].includes(n))return true;if(["false","no","0"].includes(n))return false}function Fe(t,e,n){if(!n)return null;let r=R(n),o=0,l=0,i=1/0,a=-1/0,u=0;for(let m=r.startRow;m<=r.endRow;m++)for(let c=r.startCol;c<=r.endCol;c++){if(m>=t.length||c>=e.length)continue;o++;let s=t[m],d=e[c],f=x(s,d),p=typeof f=="number"?f:Number(f);!isNaN(p)&&isFinite(p)&&(l+=p,p<i&&(i=p),p>a&&(a=p),u++);}return o<2||u===0?null:{sum:l,avg:l/u,min:i,max:a,count:u}}var Me=new WeakMap;function M(t,e,n,r,o){let l=Me.get(e);if(!l){l=new Map;for(let m=0;m<e.length;m++)l.set(e[m].columnId,e[m]);Me.set(e,l);}let i=[];for(let m=0;m<e.length;m++){let c=e[m],s=w(c),d=n[s];if(d)switch(d.type){case "multiSelect":if(d.value.length>0){let f=new Set(d.value);i.push(p=>f.has(String(x(p,c))));}break;case "text":{let f=d.value.trim();if(f){let p=f.toLowerCase(),g=new Map;for(let I=0;I<t.length;I++)g.set(t[I],String(x(t[I],c)??"").toLowerCase());i.push(I=>(g.get(I)??"").includes(p));}break}case "people":{let f=d.value.email.toLowerCase(),p=new Map;for(let g=0;g<t.length;g++)p.set(t[g],String(x(t[g],c)??"").toLowerCase());i.push(g=>(p.get(g)??"")===f);break}case "date":{let f=d.value,p=f.from?new Date(f.from+"T00:00:00").getTime():NaN,g=f.to?new Date(f.to+"T23:59:59.999").getTime():NaN,I=new Map;for(let C=0;C<t.length;C++){let b=x(t[C],c);if(b==null)I.set(t[C],NaN);else {let y=new Date(String(b)).getTime();I.set(t[C],Number.isNaN(y)?NaN:y);}}i.push(C=>{let b=I.get(C)??NaN;return !(Number.isNaN(b)||!Number.isNaN(p)&&b<p||!Number.isNaN(g)&&b>g)});break}}}let a=i.length>0,u=a?t.filter(m=>{for(let c=0;c<i.length;c++)if(!i[c](m))return false;return true}):t;if(r){let m=a?u:u.slice(),c=l.get(r),s=c?.compare,d=o==="asc"?1:-1;if(c?.type==="date"&&!s){let p=new Map;for(let g=0;g<m.length;g++){let I=m[g],C=c?x(I,c):I[r];if(C==null)p.set(I,NaN);else {let b=new Date(String(C)).getTime();p.set(I,Number.isNaN(b)?0:b);}}m.sort((g,I)=>{let C=p.get(g)??NaN,b=p.get(I)??NaN;return Number.isNaN(C)&&Number.isNaN(b)?0:Number.isNaN(C)?-1*d:Number.isNaN(b)?1*d:C===b?0:C>b?d:-d});}else if(s)m.sort((p,g)=>s(p,g)*d);else {let p=new Map;for(let g=0;g<m.length;g++){let I=m[g],C=c?x(I,c):I[r];C==null?p.set(I,void 0):typeof C=="number"?p.set(I,C):p.set(I,String(C).toLowerCase());}m.sort((g,I)=>{let C=p.get(g),b=p.get(I);return C===void 0&&b===void 0?0:C===void 0?-1*d:b===void 0?1*d:C===b?0:C>b?d:-d});}return m}return u}function D(t,e){if(!t)return false;let n=Math.min(t.startRow,t.endRow),r=Math.max(t.startRow,t.endRow);return e>=n&&e<=r}function Ne(t,e){if(t.item!==e.item||t.isSelected!==e.isSelected||t.hasCheckboxCol!==e.hasCheckboxCol||t.visibleCols!==e.visibleCols||t.columnMeta!==e.columnMeta||t.cellClassMap!==e.cellClassMap||t.columnLayouts!==e.columnLayouts)return false;let n=t.rowIndex;if(t.editingRowId!==e.editingRowId&&(t.editingRowId===t.rowId||e.editingRowId===e.rowId))return false;let r=t.activeCell?.rowIndex===n,o=e.activeCell?.rowIndex===n;if(r!==o||r&&o&&t.activeCell?.columnIndex!==e.activeCell?.columnIndex)return false;let l=D(t.selectionRange,n),i=D(e.selectionRange,n);if(l!==i||l&&i&&(t.selectionRange?.startCol!==e.selectionRange?.startCol||t.selectionRange?.endCol!==e.selectionRange?.endCol))return false;let a=t.selectionRange?.endRow===n,u=e.selectionRange?.endRow===n;return !(a!==u||(a||u)&&t.isDragging!==e.isDragging||t.cutRange!==e.cutRange&&(D(t.cutRange,n)||D(e.cutRange,n))||t.copyRange!==e.copyRange&&(D(t.copyRange,n)||D(e.copyRange,n)))}function ne(t,e){return e?e.left?.includes(t)?"left":e.right?.includes(t)?"right":"unpinned":"unpinned"}function Pe(t,e,n){let r=t.filter(i=>i!==e),o=Math.max(0,Math.min(n,r.length)),l=[...r];return l.splice(o,0,e),l}function Ae(t){let{mouseX:e,columnOrder:n,draggedColumnId:r,draggedPinState:o,tableElement:l,pinnedColumns:i}=t,a=l.querySelectorAll("[data-column-id]");if(a.length===0)return null;let u=[];if(a.forEach(d=>{let f=d.getAttribute("data-column-id");if(!f||ne(f,i)!==o)return;let g=d.getBoundingClientRect(),I=n.indexOf(f);I!==-1&&u.push({columnId:f,left:g.left,right:g.right,midX:g.left+g.width/2,orderIndex:I});}),u.length===0)return null;u.sort((d,f)=>d.left-f.left);let m,c;if(e<=u[0].midX)m=u[0].orderIndex,c=u[0].left;else if(e>=u[u.length-1].midX){let d=u[u.length-1];m=d.orderIndex+1,c=d.right;}else {let d=-1;for(let f=0;f<u.length-1;f++)if(e>=u[f].midX&&e<u[f+1].midX){d=f;break}if(d===-1)return null;m=u[d].orderIndex+1,c=u[d].right;}let s=n.indexOf(r);return s===m||s+1===m?{targetIndex:m,indicatorX:null}:{targetIndex:m,indicatorX:c}}function Oe(t,e,n,r=2){if(e.length===0||n<=0)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let o=0,l=e.length,i=-1;for(let s=0;s<e.length;s++){let d=o;o+=e[s],o>t&&l===e.length&&(l=s),d<t+n&&(i=s);}if(l>i)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let a=Math.max(0,l-r),u=Math.min(e.length-1,i+r),m=0;for(let s=0;s<a;s++)m+=e[s];let c=0;for(let s=u+1;s<e.length;s++)c+=e[s];return {startIndex:a,endIndex:u,leftOffset:m,rightOffset:c}}function ke(t,e,n){let r=[],o=[],l=[];for(let a of t){let u=n?.[a.columnId];u==="left"?r.push(a):u==="right"?o.push(a):l.push(a);}if(!e||e.endIndex<0)return {pinnedLeft:r,virtualizedUnpinned:l,pinnedRight:o,leftSpacerWidth:0,rightSpacerWidth:0};let i=l.slice(e.startIndex,e.endIndex+1);return {pinnedLeft:r,virtualizedUnpinned:i,pinnedRight:o,leftSpacerWidth:e.leftOffset,rightSpacerWidth:e.rightOffset}}function _e(t,e,n,r,o=5){if(r<=0||e<=0||n<=0)return {startIndex:0,endIndex:0,offsetTop:0,offsetBottom:0};let l=Math.max(0,Math.floor(t/e)-o),i=Math.min(r-1,Math.ceil((t+n)/e)+o),a=l*e,u=Math.max(0,(r-i-1)*e);return {startIndex:l,endIndex:i,offsetTop:a,offsetBottom:u}}function Le(t,e){return t*e}function Ve(t,e,n,r="start"){let o=t*e;switch(r){case "start":return o;case "center":return Math.max(0,o-(n-e)/2);case "end":return Math.max(0,o-n+e)}}function Ue(){let t=self;t.onmessage=e=>{let n=e.data;if(n.type!=="sort-filter")return;let{requestId:r,values:o,filters:l,sort:i}=n,a=o.length,u=[],m=Object.entries(l);if(m.length===0){u=new Array(a);for(let s=0;s<a;s++)u[s]=s;}else for(let s=0;s<a;s++){let d=true;for(let f=0;f<m.length;f++){let p=Number(m[f][0]),g=m[f][1],I=o[s][p];switch(g.type){case "text":{let C=g.value.trim().toLowerCase();C&&!String(I??"").toLowerCase().includes(C)&&(d=false);break}case "multiSelect":{g.value.length>0&&(new Set(g.value).has(String(I??""))||(d=false));break}case "date":{if(I==null){d=false;break}let C=new Date(String(I)).getTime();if(isNaN(C)){d=false;break}if(g.value.from){let b=new Date(g.value.from+"T00:00:00").getTime();if(C<b){d=false;break}}if(g.value.to){let b=new Date(g.value.to+"T23:59:59.999").getTime();if(C>b){d=false;break}}break}}if(!d)break}d&&u.push(s);}if(i){let{columnIndex:s,direction:d}=i,f=d==="asc"?1:-1;u.sort((p,g)=>{let I=o[p][s],C=o[g][s];if(I==null&&C==null)return 0;if(I==null)return -1*f;if(C==null)return 1*f;if(typeof I=="number"&&typeof C=="number")return I===C?0:I>C?f:-f;let b=String(I).toLowerCase(),y=String(C).toLowerCase();return b===y?0:b>y?f:-f});}let c={type:"sort-filter-result",requestId:r,indices:u};t.postMessage(c);};}var S=null,_t=0,E=new Map;function re(){if(S)return S;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u")return null;try{let t=Ue.toString(),e=new Blob([`(${t})()`],{type:"application/javascript"}),n=URL.createObjectURL(e);return S=new Worker(n),URL.revokeObjectURL(n),S.onmessage=r=>{let{requestId:o,indices:l}=r.data,i=E.get(o);i&&(E.delete(o),i.resolve(l));},S.onerror=r=>{for(let[o,l]of E)l.reject(new Error(r.message||"Worker error")),E.delete(o);},S}catch{return null}}function He(){S&&(S.terminate(),S=null);for(let[t,e]of E)e.reject(new Error("Worker terminated")),E.delete(t);}function oe(t,e){let n=new Array(t.length);for(let r=0;r<t.length;r++){let o=new Array(e.length);for(let l=0;l<e.length;l++){let i=x(t[r],e[l]);i==null?o[l]=null:typeof i=="string"||typeof i=="number"||typeof i=="boolean"?o[l]=i:o[l]=String(i);}n[r]=o;}return n}function Be(t,e,n,r,o){if(r&&e.find(f=>f.columnId===r)?.compare)return Promise.resolve(M(t,e,n,r,o));let l=re();if(!l)return Promise.resolve(M(t,e,n,r,o));let i=new Map;for(let d=0;d<e.length;d++)i.set(e[d].columnId,d);let a=oe(t,e),u=e.map((d,f)=>({type:d.type??"text",index:f})),m={};for(let d of e){let f=w(d),p=n[f];if(!p)continue;let g=i.get(d.columnId);if(g!==void 0)switch(p.type){case "text":m[g]={type:"text",value:p.value};break;case "multiSelect":m[g]={type:"multiSelect",value:p.value};break;case "date":m[g]={type:"date",value:{from:p.value.from,to:p.value.to}};break;case "people":return Promise.resolve(M(t,e,n,r,o))}}let c;if(r){let d=i.get(r);d!==void 0&&(c={columnIndex:d,direction:o??"asc"});}let s=++_t;return new Promise((d,f)=>{E.set(s,{resolve:g=>{let I=new Array(g.length);for(let C=0;C<g.length;C++)I[C]=t[g[C]];d(I);},reject:f});let p={type:"sort-filter",requestId:s,values:a,columnMeta:u,filters:m,sort:c};l.postMessage(p);})}var H="YYYY-MM-DD";function B(t,e,n="UTC"){if(t==null)return null;let r=t instanceof Date?t:new Date(String(t));if(Number.isNaN(r.getTime()))return null;let o,l,i;if(n==="UTC")o=r.getUTCFullYear(),l=r.getUTCMonth()+1,i=r.getUTCDate();else {let s=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(r);o=parseInt(s.find(d=>d.type==="year")?.value??"0",10),l=parseInt(s.find(d=>d.type==="month")?.value??"0",10),i=parseInt(s.find(d=>d.type==="day")?.value??"0",10);}let a=String(o).padStart(4,"0"),u=String(l).padStart(2,"0"),m=String(i).padStart(2,"0");return e.replace("YYYY",a).replace("MM",u).replace("DD",m)}function Ge(t,e){if(!t||!t.trim())return null;let r=t.trim().split(/[/\-.\s]+/).filter(Boolean);if(r.length===0)return null;let o=new Date().getUTCFullYear(),l=Lt(e),i,a,u;if(r.length===3){let[c,s,d]=r.map(Number);l==="YMD"?(i=c,a=s,u=d):l==="DMY"?(u=c,a=s,i=d):(a=c,u=s,i=d),i!==void 0&&i<100&&(i=i<50?2e3+i:1900+i);}else if(r.length===2){let[c,s]=r.map(Number);l==="DMY"?(u=c,a=s):(a=c,u=s),i=o;}else if(r.length===1){let c=r[0];if(/^\d+$/.test(c))if(c.length===8)i=parseInt(c.slice(0,4),10),a=parseInt(c.slice(4,6),10),u=parseInt(c.slice(6,8),10);else if(c.length===4)a=parseInt(c.slice(0,2),10),u=parseInt(c.slice(2,4),10),i=o;else return null;else return null}else return null;if(!Vt(i,a,u))return null;let m=new Date(Date.UTC(i,a-1,u));return m.getUTCFullYear()!==i||m.getUTCMonth()+1!==a||m.getUTCDate()!==u?null:m}function We(t){return t}function Lt(t){let e=t.indexOf("Y"),n=t.indexOf("M"),r=t.indexOf("D");return e===-1||n===-1||r===-1?"MDY":e<n&&n<r?"YMD":r<n&&n<e?"DMY":"MDY"}function Vt(t,e,n){return !(t==null||e==null||n==null||!Number.isFinite(t)||!Number.isFinite(e)||!Number.isFinite(n)||e<1||e>12||n<1||n>31)}var L=class{constructor(e,n){this.type=e;this.message=n;}toString(){return this.type}};function Xe(t,e){let n=v(t.filterable)?t.filterable:null,r=n?.type??"none",o=n?.filterField??t.columnId,l=t.sortable!==false,i=e.filters[o],a={columnKey:t.columnId,columnName:t.name,filterType:r,isSorted:e.sortBy===t.columnId,isSortedDescending:e.sortBy===t.columnId&&e.sortDirection==="desc",onSort:l?()=>e.onColumnSort(t.columnId):void 0};return r==="text"?{...a,textValue:i?.type==="text"?i.value:"",onTextChange:u=>e.onFilterChange(o,u.trim()?{type:"text",value:u}:void 0)}:r==="people"?{...a,selectedUser:i?.type==="people"?i.value:void 0,onUserChange:u=>e.onFilterChange(o,u?{type:"people",value:u}:void 0),peopleSearch:e.peopleSearch}:r==="multiSelect"?{...a,options:e.filterOptions[o]??[],isLoadingOptions:e.loadingFilterOptions[o]??false,selectedValues:i?.type==="multiSelect"?i.value:[],onFilterChange:u=>e.onFilterChange(o,u.length?{type:"multiSelect",value:u}:void 0)}:r==="date"?{...a,dateValue:i?.type==="date"?i.value:void 0,onDateChange:u=>e.onFilterChange(o,u?{type:"date",value:u}:void 0)}:a}var W=class W{constructor(){this.cache=new Map;this.lastVersion="";}static computeVersion(e){let n=e.editingCell,r=e.activeCell,o=e.selectionRange,l=e.cutRange,i=e.copyRange;return (n?`${String(n.rowId)}\0${n.columnId}`:"")+""+(r?`${r.rowIndex}\0${r.columnIndex}`:"")+""+(o?`${o.startRow}\0${o.startCol}\0${o.endRow}\0${o.endCol}`:"")+""+(l?`${l.startRow}\0${l.startCol}\0${l.endRow}\0${l.endCol}`:"")+""+(i?`${i.startRow}\0${i.startCol}\0${i.endRow}\0${i.endCol}`:"")+""+(e.isDragging?"1":"0")+""+(e.editable!==false?"1":"0")+""+(e.onCellValueChanged?"1":"0")+""+(e.formulaVersion??0)}get(e,n,r,o){let l=e*W.MAX_COL_STRIDE+n,i=this.cache.get(l);if(i!==void 0&&i.version===r)return i.descriptor;let a=o();return this.cache.set(l,{version:r,descriptor:a}),a}updateVersion(e){this.lastVersion=e;}get currentVersion(){return this.lastVersion}clear(){this.cache.clear();}};W.MAX_COL_STRIDE=1024;var G=W;function qe(t,e,n,r,o,l){return l!==void 0?l.get(n,r,l.currentVersion,()=>$e(t,e,n,r,o)):$e(t,e,n,r,o)}function $e(t,e,n,r,o){let l=o.getRowId(t),i=r+o.colOffset,a=h(e,t),u=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor!="function",m=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor=="function"&&e.cellEditorPopup!==false,c=u||m,s=o.editingCell?.rowId===l&&o.editingCell?.columnId===e.columnId,d=!o.isDragging&&o.activeCell?.rowIndex===n&&o.activeCell?.columnIndex===i,f=o.selectionRange!=null&&o.selectionRange.startRow===o.selectionRange.endRow&&o.selectionRange.startCol===o.selectionRange.endCol,p=o.selectionRange!=null&&!f&&F(o.selectionRange,n,r),g=o.cutRange!=null&&F(o.cutRange,n,r),I=o.copyRange!=null&&F(o.copyRange,n,r),C=!o.isDragging&&o.copyRange==null&&o.cutRange==null&&o.selectionRange!=null&&n===o.selectionRange.endRow&&r===o.selectionRange.endCol,b=e.pinned!=null,y=e.pinned??void 0,P=x(t,e),A=o.hasFormula?.(r,n)??false,U=A?o.getFormulaValue?.(r,n):void 0,q="display",O;s&&u?(q="editing-inline",e.cellEditor==="text"||e.cellEditor==="select"||e.cellEditor==="checkbox"||e.cellEditor==="richSelect"||e.cellEditor==="date"?O=e.cellEditor:e.type==="date"?O="date":e.type==="boolean"?O="checkbox":O="text"):s&&m&&typeof e.cellEditor=="function"&&(q="editing-popover");let Ot=s&&A?o.getFormula?.(r,n)??P:P;return {mode:q,editorType:O,value:Ot,isActive:d,isInRange:p,isInCutRange:g,isInCopyRange:I,isSelectionEndCell:C,canEditAny:c,isPinned:b,pinnedSide:y,globalColIndex:i,rowId:l,rowIndex:n,displayValue:U!==void 0?U:P,columnType:e.type}}function ze(t,e,n){if(n instanceof L)return n.toString();let r=t;if(r.renderCell&&typeof r.renderCell=="function")return r.renderCell(e);if(t.valueFormatter)return t.valueFormatter(n,e);if(n==null)return null;if(t.type==="date"){let o=t.dateFormat??H,l=B(n,o);if(l!==null)return l}return t.type==="boolean"?n?"True":"False":String(n)}function Ye(t,e,n){let r=t,o=n instanceof L,l=r.cellStyle?typeof r.cellStyle=="function"?r.cellStyle(e):r.cellStyle:void 0;return o?{...l,color:"var(--ogrid-formula-error-color, #d32f2f)"}:l}function je(t,e,n,r){let o=n.editorType??"text";return {value:n.value,item:t,column:e,rowIndex:n.rowIndex,editorType:o,onCommit:l=>r.commitCellEdit(t,e.columnId,n.value,l,n.rowIndex,n.globalColIndex,o==="checkbox"?{skipAdvance:true}:void 0),onCancel:()=>r.setEditingCell(null)}}function Ke(t,e,n,r,o){let l=n.value,i=r!==void 0?r:l,a=r;return {value:i,onValueChange:u=>{a=u,o.setPendingEditorValue(u);},onCommit:()=>{let u=a!==void 0?a:l;o.commitCellEdit(t,e.columnId,l,u,n.rowIndex,n.globalColIndex);},onCancel:o.cancelPopoverEdit,item:t,column:e,cellEditorParams:e.cellEditorParams}}function Ze(t,e){let n=null,r=((...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{t(...o),n=null;},e);});return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null);},r}function Qe(t,e,n){let r=e.startCol+n,o=e.endCol+n,l=t.querySelector(`[data-row-index="${e.startRow}"][data-col-index="${r}"]`),i=t.querySelector(`[data-row-index="${e.endRow}"][data-col-index="${o}"]`);if(!l||!i)return null;let a=t.getBoundingClientRect(),u=l.getBoundingClientRect(),m=i.getBoundingClientRect();return {top:u.top-a.top,left:u.left-a.left,width:m.right-u.left,height:m.bottom-u.top}}function Je(t){let e=new Map;if(!t)return e;let n=t.querySelectorAll("[data-row-index][data-col-index]");for(let r=0;r<n.length;r++){let o=n[r],l=o.getAttribute("data-row-index")??"",i=o.getAttribute("data-col-index")??"";e.set(`${l},${i}`,o);}return e}function et(t,e){if(typeof document>"u"||document.getElementById(t))return;let n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n);}function tt(t,e,n){return n===null?{field:"",direction:"asc"}:n?{field:e,direction:n}:{field:e,direction:t.field===e&&t.direction==="asc"?"desc":"asc"}}var nt=48,rt=50,le=80,ot=16,lt=30,it="__row_number__",at=6;var ie=16,ae=520;function Ut(t){let e=getComputedStyle(t),n=(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),r=(parseFloat(e.borderLeftWidth)||0)+(parseFloat(e.borderRightWidth)||0),o=0;for(let s=0;s<t.children.length;s++){let d=t.children[s],f=d.className||"";if(f.includes("resizeHandle")||f.includes("resize-handle")||f.includes("ogrid-resize-handle")){o=d.offsetWidth;break}}let l=t.firstElementChild;if(!l)return t.offsetWidth;let i=[],a=s=>{for(let d=0;d<s.children.length;d++){let f=s.children[d],p=getComputedStyle(f);(p.overflow==="hidden"||p.flexShrink!=="0")&&(i.push({el:f,overflow:f.style.overflow,flexShrink:f.style.flexShrink,width:f.style.width,minWidth:f.style.minWidth,maxWidth:f.style.maxWidth}),f.style.overflow="visible",f.style.flexShrink="0",f.style.width="max-content",f.style.minWidth="max-content",f.style.maxWidth="none"),a(f);}},u=l.style.position,m=l.style.width;l.style.position="absolute",l.style.width="max-content",a(l);let c=l.offsetWidth;l.style.position=u,l.style.width=m;for(let s of i)s.el.style.overflow=s.overflow,s.el.style.flexShrink=s.flexShrink,s.el.style.width=s.width,s.el.style.minWidth=s.minWidth,s.el.style.maxWidth=s.maxWidth;return c+o+n+r}function st(t,e,n){let r=e??80,l=(n??document).querySelectorAll(`[data-column-id="${t}"]`);if(l.length===0)return r;let i=r,a=[],u=[],m=[];if(l.forEach(c=>{let s=c;if(!!s.querySelector?.("[data-header-label]"))i=Math.max(i,Ut(s));else {let f=s.firstElementChild??s;a.push(f);}}),a.length>0){for(let c=0;c<a.length;c++){let s=a[c];u.push(s.style.position),m.push(s.style.width),s.style.position="absolute",s.style.width="max-content";}for(let c=0;c<a.length;c++)i=Math.max(i,a[c].offsetWidth+ie);for(let c=0;c<a.length;c++)a[c].style.position=u[c],a[c].style.width=m[c];}return Math.min(ae,Math.max(r,Math.ceil(i)))}function N(t,e,n,r){if(t===e)return t;let o=t+n;if(!r(t)&&!r(o)){let i=o;for(;i!==e;){if(r(i+n))return i;i+=n;}return e}let l=o;for(;l!==e;){if(!r(l))return l;l+=n;}return e}function ut(t,e,n,r,o,l){let i=t,a=e;return l?e>o?a=e-1:t>0&&(i=t-1,a=r):e<r?a=e+1:t<n&&(i=t+1,a=o),{rowIndex:i,columnIndex:a}}function dt(t){let{direction:e,rowIndex:n,columnIndex:r,dataColIndex:o,colOffset:l,maxRowIndex:i,maxColIndex:a,visibleColCount:u,isCtrl:m,isShift:c,selectionRange:s,isEmptyAt:d}=t,f=n,p=r;e==="ArrowDown"?f=m?N(n,i,1,b=>d(b,Math.max(0,o))):Math.min(n+1,i):e==="ArrowUp"?f=m?N(n,0,-1,b=>d(b,Math.max(0,o))):Math.max(n-1,0):e==="ArrowRight"?m&&o>=0?p=N(o,u-1,1,b=>d(n,b))+l:p=Math.min(r+1,a):m&&o>=0?p=N(o,0,-1,b=>d(n,b))+l:p=Math.max(r-1,l);let g=p-l,I=e==="ArrowDown"||e==="ArrowUp",C;return c?I?C=R({startRow:s?.startRow??n,startCol:s?.startCol??o,endRow:f,endCol:s?.endCol??o}):C=R({startRow:s?.startRow??n,startCol:s?.startCol??o,endRow:s?.endRow??n,endCol:g}):C={startRow:f,startCol:g,endRow:f,endCol:g},{newRowIndex:f,newColumnIndex:p,newDataColIndex:g,newRange:C}}function ct(t,e,n){let r=R(t),o=[];for(let l=r.startRow;l<=r.endRow;l++)for(let i=r.startCol;i<=r.endCol;i++){if(l>=e.length||i>=n.length)continue;let a=e[l],u=n[i];if(!h(u,a))continue;let m=x(a,u),c=T("",m,a,u);c.valid&&o.push({item:a,columnId:u.columnId,oldValue:m,newValue:c.value,rowIndex:l});}return o}function mt(t,e){return t===e?true:!t||!e?false:t.startRow===e.startRow&&t.endRow===e.endRow&&t.startCol===e.startCol&&t.endCol===e.endCol}function ft(t,e,n){return e<0||n<0?null:{startRow:Math.max(0,Math.min(t.startRow,e)),endRow:Math.max(0,Math.min(t.endRow,e)),startCol:Math.max(0,Math.min(t.startCol,n)),endCol:Math.max(0,Math.min(t.endCol,n))}}function pt(t,e=40,n=2,r=20){let o=Math.min(t/e,1);return n+o*(r-n)}function gt(t,e,n,r,o,l){let i=new Set(l),a=Math.min(t,e),u=Math.max(t,e);for(let m=a;m<=u;m++)if(m<r.length){let c=o(r[m]);n?i.add(c):i.delete(c);}return i}function Ct(t,e,n){if(t.size===0||e.length===0)return {allSelected:false,someSelected:false};let r=t.size>=e.length&&e.every(l=>t.has(n(l))),o=!r&&t.size>0;return {allSelected:r,someSelected:o}}function se(t,e){let n=e!=null&&e!==""?e:t;if(n==null||n==="")return "";try{return String(n).replace(/[\t\n]/g," ")}catch{return "[Object]"}}function It(t,e,n,r){let o=R(n),l=[];for(let i=o.startRow;i<=o.endRow;i++){let a=[];for(let u=o.startCol;u<=o.endCol&&!(i>=t.length||u>=e.length);u++){let m=t[i],c=e[u];if(r?.hasFormula&&r?.getFormula){let p=r.flatColumns.findIndex(g=>g.columnId===c.columnId);if(p>=0&&r.hasFormula(p,i)){let g=r.getFormula(p,i);if(g){a.push(g);continue}}}let s=x(m,c),f=(c.clipboardFormatter?c.clipboardFormatter(s,m):null)??(c.valueFormatter?c.valueFormatter(s,m):s);a.push(se(s,f));}l.push(a.join(" "));}return l.join(`\r
4
- `)}function bt(t){return t.trim()?t.split(/\r?\n/).filter(n=>n.length>0).map(n=>n.split(" ")):[]}function xt(t,e,n,r,o,l){let i=[];for(let a=0;a<t.length;a++){let u=t[a];for(let m=0;m<u.length;m++){let c=e+a,s=n+m;if(c>=r.length||s>=o.length)continue;let d=r[c],f=o[s];if(!h(f,d))continue;let p=u[m]??"";if(p.startsWith("=")&&l?.setFormula){let C=l.flatColumns.findIndex(b=>b.columnId===f.columnId);if(C>=0){l.setFormula(C,c,p);continue}}let g=x(d,f),I=T(p,g,d,f);I.valid&&i.push({item:d,columnId:f.columnId,oldValue:g,newValue:I.value,rowIndex:c});}}return i}function ht(t,e,n){let r=[];for(let o=t.startRow;o<=t.endRow;o++)for(let l=t.startCol;l<=t.endCol;l++){if(o>=e.length||l>=n.length)continue;let i=e[o],a=n[l];if(!h(a,i))continue;let u=x(i,a),m=T("",u,i,a);m.valid&&r.push({item:i,columnId:a.columnId,oldValue:u,newValue:m.value,rowIndex:o});}return r}function V(t){let e="",n=t;for(;n>=0;)e=String.fromCharCode(n%26+65)+e,n=Math.floor(n/26)-1;return e}function $(t){let e=0,n=t.toUpperCase();for(let r=0;r<n.length;r++)e=e*26+(n.charCodeAt(r)-64);return e-1}function Rt(t,e){return `${V(t)}${e}`}var yt=/(?:'[^']*'!|[A-Za-z_]\w*!)?(\$?)([A-Z]+)(\$?)(\d+)/g;function Tt(t,e,n){return yt.lastIndex=0,t.replace(yt,(r,o,l,i,a)=>{let u=r.indexOf(o+l),m=u>0?r.substring(0,u):"",c=l,s=a;if(o!=="$"){let d=$(l)+e;if(d<0)return "#REF!";c=V(d);}if(i!=="$"){let d=parseInt(a,10)+n;if(d<1)return "#REF!";s=String(d);}return `${m}${o}${c}${i}${s}`})}function ue(t,e){if(t.columnId===e.columnId)return true;let n=t.type??"text",r=e.type??"text";return !(n!==r||t.cellEditor!==e.cellEditor)}function St(t,e,n,r,o,l){let i=[],a=r[t.startRow],u=o[t.startCol];if(!a||!u)return i;let m=x(a,u),c=l?l.flatColumns.findIndex(s=>s.columnId===u.columnId):-1;for(let s=t.startRow;s<=t.endRow;s++)for(let d=t.startCol;d<=t.endCol;d++){if(s===e&&d===n||s>=r.length||d>=o.length)continue;let f=r[s],p=o[d];if(!h(p,f)||!ue(u,p))continue;if(l&&l.hasFormula&&l.getFormula&&l.setFormula&&c>=0&&l.hasFormula(c,e)){let C=l.getFormula(c,e);if(C){let b=s-e,y=d-n,P=Tt(C,y,b),A=l.flatColumns.findIndex(U=>U.columnId===p.columnId);if(A>=0){l.setFormula(A,s,P);continue}}}let g=x(f,p),I=T(m,g,f,p);I.valid&&i.push({item:f,columnId:p.columnId,oldValue:g,newValue:I.value,rowIndex:s});}return i}var X=class{constructor(e=100){this.history=[];this.redoStack=[];this.batch=null;this.maxDepth=e;}get canUndo(){return this.history.length>0}get canRedo(){return this.redoStack.length>0}get historyLength(){return this.history.length}get redoLength(){return this.redoStack.length}get isBatching(){return this.batch!==null}push(e){e.length!==0&&(this.batch!==null?this.batch.push(...e):(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0));}record(e){this.push([e]);}beginBatch(){this.batch===null&&(this.batch=[]);}endBatch(){let e=this.batch;this.batch=null,!(!e||e.length===0)&&(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0);}undo(){let e=this.history.pop();return e?(this.redoStack.push(e),e):null}redo(){let e=this.redoStack.pop();return e?(this.history.push(e),e):null}clear(){this.history=[],this.redoStack=[];}};function wt(t){if(!Array.isArray(t)||t.length===0){console.warn("[OGrid] columns prop is empty or not an array");return}let e=typeof process<"u"&&process.env?.NODE_ENV!=="production",n=new Set;for(let r of t)r.columnId||console.warn("[OGrid] Column missing columnId:",r),n.has(r.columnId)&&console.warn(`[OGrid] Duplicate columnId: "${r.columnId}"`),n.add(r.columnId),e&&r.editable===true&&r.cellEditor==null&&console.warn(`[OGrid] Column "${r.columnId}" has editable=true but no cellEditor defined. Cells will not open an editor on double-click. Set cellEditor to 'text', 'select', 'checkbox', 'date', or a custom component.`);}function Dt(t){typeof process<"u"&&process.env?.NODE_ENV==="production"||t.enabled===true&&(!t.rowHeight||t.rowHeight<=0)&&console.warn("[OGrid] virtualScroll.enabled is true but rowHeight is missing or <= 0. Set a positive rowHeight (e.g. virtualScroll: { enabled: true, rowHeight: 36 }) for correct virtual scrolling behavior.");}function vt(t,e){if(typeof process<"u"&&process.env.NODE_ENV==="production"||!e)return;let n=new Set,r=Math.min(t.length,100);for(let o=0;o<r;o++){let l=e(t[o]);if(l==null){console.warn(`[OGrid] getRowId returned null/undefined for row ${o}`);return}if(n.has(l)){console.warn(`[OGrid] Duplicate row ID "${l}" at index ${o}. getRowId must return unique values.`);return}n.add(l);}}var de=[{minWidth:0,maxPriority:0},{minWidth:576,maxPriority:1},{minWidth:768,maxPriority:2},{minWidth:992,maxPriority:3},{minWidth:1200,maxPriority:1/0}];function ce(t,e,n){let r=n?.breakpoints??de,o=new Set;if(t<=0||e.length===0)return o;let l=1/0;for(let i=r.length-1;i>=0;i--)if(t>=r[i].minWidth){l=r[i].maxPriority;break}if(l===1/0)return o;for(let i of e)i.responsivePriority!=null&&(i.required||i.responsivePriority>l&&o.add(i.columnId));return o}function Et(t){return t===true?{}:t||void 0}function Ft(t,e,n){if(!n||e<=0)return t;let r=ce(e,t,n);return r.size===0?t:t.filter(o=>!r.has(o.columnId))}var Mt=300,Nt=300,Pt=300;var At={RESIZE_HANDLE:1,ACTIVE_CELL:2,FILL_HANDLE:3,SELECTION_OVERLAY:4,ROW_NUMBER:5,CLIPBOARD_OVERLAY:5,PINNED:6,SELECTION_CELL:7,THEAD:8,PINNED_HEADER:10,HEADER_FOCUS:11,SELECTION_HEADER_PINNED:12,LOADING:2,DROP_INDICATOR:100,DROPDOWN:1e3,FILTER_POPOVER:1e3,MODAL:2e3,FULLSCREEN:9999,CONTEXT_MENU:1e4};export{ie as AUTOSIZE_EXTRA_PX,ae as AUTOSIZE_MAX_PX,ot as CELL_PADDING,nt as CHECKBOX_COLUMN_WIDTH,we as COLUMN_HEADER_MENU_ITEMS,G as CellDescriptorCache,H as DEFAULT_DATE_FORMAT,Mt as DEFAULT_DEBOUNCE_MS,le as DEFAULT_MIN_COLUMN_WIDTH,at as GRID_BORDER_RADIUS,ye as GRID_CONTEXT_MENU_ITEMS,Q as MAX_PAGE_BUTTONS,Z as PAGE_SIZE_OPTIONS,Nt as PEOPLE_SEARCH_DEBOUNCE_MS,de as RESPONSIVE_BREAKPOINTS,it as ROW_NUMBER_COLUMN_ID,lt as ROW_NUMBER_COLUMN_MIN_WIDTH,rt as ROW_NUMBER_COLUMN_WIDTH,Pt as SIDEBAR_TRANSITION_MS,X as UndoRedoStack,At as Z_INDEX,ct as applyCellDeletion,ht as applyCutClear,St as applyFillValues,xt as applyPastedValues,gt as applyRangeRowSelection,Ft as applyResponsiveHiding,ue as areFillCompatible,Ne as areGridRowPropsEqual,te as booleanParser,Je as buildCellIndex,z as buildCsvHeader,Y as buildCsvRows,ge as buildHeaderRows,je as buildInlineEditorProps,Ke as buildPopoverEditorProps,Ae as calculateDropTarget,ft as clampSelectionToBounds,$ as columnLetterToIndex,Fe as computeAggregations,dt as computeArrowNavigation,pt as computeAutoScrollSpeed,tt as computeNextSortState,Ct as computeRowSelectionState,ut as computeTabNavigation,Le as computeTotalHeight,Oe as computeVisibleColumnRange,_e as computeVisibleRange,pe as createGridDataAccessor,re as createSortFilterWorker,ve as currencyParser,ee as dateParser,Ze as debounce,Ie as deriveFilterOptionsFromData,Ee as emailParser,k as escapeCsvValue,fe as exportToCsv,oe as extractValueMatrix,N as findCtrlArrowTarget,K as flattenColumns,Rt as formatCellReference,se as formatCellValueForTsv,B as formatDateForDisplay,It as formatSelectionAsTsv,Te as formatShortcut,qe as getCellRenderDescriptor,x as getCellValue,De as getColumnHeaderMenuItems,Se as getContextMenuHandlers,he as getDataGridStatusBarConfig,We as getDateInputPlaceholder,w as getFilterField,Xe as getHeaderFilterConfig,be as getMultiSelectFilterFields,Re as getPaginationViewModel,ne as getPinStateForColumn,ce as getResponsiveHiddenColumns,Ve as getScrollTopForRow,xe as getStatusBarParts,V as indexToColumnLetter,et as injectGlobalStyles,h as isColumnEditable,v as isFilterConfig,F as isInSelectionRange,D as isRowInRange,st as measureColumnContentWidth,Qe as measureRange,Ce as mergeFilter,R as normalizeSelectionRange,J as numberParser,bt as parseTsvClipboard,Ge as parseUserInputDate,T as parseValue,ke as partitionColumnsForVirtualization,M as processClientSideData,Be as processClientSideDataAsync,mt as rangesEqual,Pe as reorderColumnArray,ze as resolveCellDisplayContent,Ye as resolveCellStyle,Et as resolveResponsiveConfig,He as terminateSortFilterWorker,me as toUserLike,j as triggerCsvDownload,wt as validateColumns,vt as validateRowIds,Dt as validateVirtualScrollConfig};
2
+ `)?`"${e.replace(/"/g,'""')}"`:e}function Y(t){return t.map(e=>k(e.name)).join(",")}function j(t,e,n,r){return t.map((o,l)=>e.map(i=>{if(r?.exportMode==="formulas"&&r.hasFormula&&r.getFormula&&r.columnIdToIndex){let a=r.columnIdToIndex.get(i.columnId);if(a!==void 0&&r.hasFormula(a,l)){let u=r.getFormula(a,l);if(u)return k(u)}}return k(n(o,i.columnId))}).join(","))}function fe(t,e,n,r,o){let l=Y(e),i=j(t,e,n,o),a=[l,...i].join(`
3
+ `);K(a,r??`export_${new Date().toISOString().slice(0,10)}.csv`);}function K(t,e){let n=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");try{o.setAttribute("href",r),o.setAttribute("download",e),o.style.visibility="hidden",document.body.appendChild(o),o.click();}finally{try{document.body.removeChild(o);}catch{}URL.revokeObjectURL(r);}}function x(t,e){return e.valueGetter?e.valueGetter(t):t[e.columnId]}function h(t,e){return t.editable===true||typeof t.editable=="function"&&t.editable(e)}function pe(t,e){return {getCellValue:(n,r)=>r<0||r>=t.length||n<0||n>=e.length?null:x(t[r],e[n]),getRowCount:()=>t.length,getColumnCount:()=>e.length}}function L(t){return "children"in t&&Array.isArray(t.children)}function Z(t){let e=[];for(let n of t)L(n)?e.push(...Z(n.children)):e.push(n);return e}function ge(t,e){function n(m,c){let d=c;for(let s of m)L(s)&&(d=Math.max(d,n(s.children,c+1)));return d}let r=n(t,0);if(r===0){let m=[];for(let c of t)if(!L(c)){if(e&&!e.has(c.columnId))continue;m.push({label:c.name,colSpan:1,isGroup:false,columnDef:c,depth:0});}return [m]}let o=r+1,l=Array.from({length:o},()=>[]),i=new Map;function a(m){let c=i.get(m);if(c!==void 0)return c;let d=0;for(let s of m)L(s)?d+=a(s.children):(!e||e.has(s.columnId))&&d++;return i.set(m,d),d}function u(m,c){for(let d of m)if(L(d)){let s=a(d.children);if(s===0)continue;l[c].push({label:d.headerName,colSpan:s,isGroup:true,depth:c}),u(d.children,c+1);}else {if(e&&!e.has(d.columnId))continue;l[c].push({label:d.name,colSpan:1,isGroup:false,columnDef:d,depth:c});}}return u(t,0),l.filter(m=>m.length>0)}function v(t){return t!=null&&typeof t=="object"&&"type"in t}function w(t){return (v(t.filterable)?t.filterable:null)?.filterField??t.columnId}function Ce(t,e,n){if(n===void 0||n.type==="text"&&n.value.trim()===""||n.type==="multiSelect"&&n.value.length===0||n.type==="date"&&!n.value.from&&!n.value.to||n.type==="people"&&!n.value){let{[e]:o,...l}=t;return l}return {...t,[e]:n}}function Ie(t,e){let n=[];for(let l=0;l<e.length;l++){let i=e[l];(v(i.filterable)?i.filterable:null)?.type==="multiSelect"&&n.push({col:i,field:w(i)});}if(n.length===0)return {};let r=new Map;for(let l=0;l<n.length;l++)r.set(n[l].field,new Set);for(let l=0;l<t.length;l++){let i=t[l];for(let a=0;a<n.length;a++){let u=x(i,n[a].col),m=r.get(n[a].field);u!=null&&u!==""&&m&&m.add(String(u));}}let o={};for(let l=0;l<n.length;l++){let i=r.get(n[l].field);o[n[l].field]=i?Array.from(i).sort():[];}return o}function be(t){let e=[];for(let n of t)(v(n.filterable)?n.filterable:null)?.type==="multiSelect"&&e.push(w(n));return e}function xe(t){let{totalCount:e,filteredCount:n,selectedCount:r,selectedCellCount:o,aggregation:l,suppressRowCount:i}=t,a=[];return i||a.push({key:"total",label:"Rows:",value:e}),n!==void 0&&n!==e&&a.push({key:"filtered",label:"Filtered:",value:n}),r!==void 0&&r>0&&a.push({key:"selected",label:"Selected:",value:r}),o!==void 0&&o>1&&a.push({key:"cells",label:"Cells:",value:o}),l&&(a.push({key:"sum",label:"Sum:",value:l.sum}),a.push({key:"avg",label:"Avg:",value:Math.round(l.avg*100)/100}),a.push({key:"min",label:"Min:",value:l.min}),a.push({key:"max",label:"Max:",value:l.max}),a.push({key:"count",label:"Count:",value:l.count})),a}function he(t,e,n,r){return t?typeof t=="object"?t:{totalCount:e,selectedCount:n>0?n:void 0,filteredCount:r!==void 0&&r!==e?r:void 0}:null}var Q=[10,25,50,100];function Lt(t,e){return e.includes(t)?e:[...e,t].sort((n,r)=>n-r)}var J=5;function Re(t,e,n,r){if(n<=0)return null;let o=r?.maxPageButtons??J,l=Math.ceil(n/e),i,a,u;if(l<=o){i=[];for(let d=1;d<=l;d++)i.push(d);a=false,u=false;}else {let d=Math.max(1,t-2),s=Math.min(l,t+2);s-d+1<o&&(d===1?s=Math.min(l,d+o-1):s===l&&(d=Math.max(1,s-o+1))),i=[];for(let f=d;f<=s;f++)i.push(f);a=d>1,u=s<l;}let m=Math.max(1,(t-1)*e+1),c=Math.min(t*e,n);return {totalPages:l,pageNumbers:i,showStartEllipsis:a,showEndEllipsis:u,startItem:m,endItem:c,pageSizeOptions:Lt(e,r?.pageSizeOptions??Q)}}var ye=[{id:"undo",label:"Undo",shortcut:"Ctrl+Z"},{id:"redo",label:"Redo",shortcut:"Ctrl+Y"},{id:"copy",label:"Copy",shortcut:"Ctrl+C",disabledWhenNoSelection:true,dividerBefore:true},{id:"cut",label:"Cut",shortcut:"Ctrl+X",disabledWhenNoSelection:true},{id:"paste",label:"Paste",shortcut:"Ctrl+V"},{id:"selectAll",label:"Select all",shortcut:"Ctrl+A",dividerBefore:true}];function Te(t){return typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?t.replace("Ctrl","\u2318"):t}function Se(t){let{onCopy:e,onCut:n,onPaste:r,onSelectAll:o,onUndo:l,onRedo:i,onClose:a}=t;return {undo:()=>{l(),a();},redo:()=>{i(),a();},copy:()=>{e(),a();},cut:()=>{n(),a();},paste:()=>{r(),a();},selectAll:()=>{o(),a();}}}var we=[{id:"pinLeft",label:"Pin left"},{id:"pinRight",label:"Pin right"},{id:"unpin",label:"Unpin"}];function De(t){let{canPinLeft:e,canPinRight:n,canUnpin:r,currentSort:o,isSortable:l=true,isResizable:i=true}=t,a=[];if(a.push({id:"pinLeft",label:"Pin left",disabled:!e},{id:"pinRight",label:"Pin right",disabled:!n},{id:"unpin",label:"Unpin",disabled:!r,divider:l||i}),l)if(!o)a.push({id:"sortAsc",label:"Sort ascending"},{id:"sortDesc",label:"Sort descending",divider:i});else {let u=o==="asc"?"desc":"asc",m=o==="asc"?"Sort descending":"Sort ascending";a.push({id:`sort${u==="asc"?"Asc":"Desc"}`,label:m},{id:"clearSort",label:"Clear sort",divider:i});}return i&&a.push({id:"autosizeThis",label:"Autosize this column"},{id:"autosizeAll",label:"Autosize all columns"}),a}function T(t,e,n,r){if(r.valueParser){let l={newValue:t,oldValue:e,data:n,column:r},i=r.valueParser(l);return i===void 0?{valid:false,value:void 0}:{valid:true,value:i}}if(r.cellEditor==="select"&&r.cellEditorParams?.values!=null&&Array.isArray(r.cellEditorParams.values)){let l=r.cellEditorParams.values,i=typeof t=="string"?t:String(t??"");if(i==="")return {valid:true,value:""};let a=l.find(u=>String(u).toLowerCase()===i.toLowerCase());return a!==void 0?{valid:true,value:a}:{valid:false,value:void 0}}let o=r.type;if(o==="date"){let l=te({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="boolean"){let l=ne({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="numeric"){let l=ee({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}return {valid:true,value:t}}function ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function ve(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[$\u20AC\u00A3\u00A5]/g,"").replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function te(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim(),r=new Date(n);if(!Number.isNaN(r.getTime()))return r.toISOString()}function Ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim();return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n:void 0}function ne(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim().toLowerCase();if(["true","yes","1"].includes(n))return true;if(["false","no","0"].includes(n))return false}function Fe(t,e,n){if(!n)return null;let r=R(n),o=0,l=0,i=1/0,a=-1/0,u=0;for(let m=r.startRow;m<=r.endRow;m++)for(let c=r.startCol;c<=r.endCol;c++){if(m>=t.length||c>=e.length)continue;o++;let d=t[m],s=e[c],f=x(d,s),g=typeof f=="number"?f:Number(f);!isNaN(g)&&isFinite(g)&&(l+=g,g<i&&(i=g),g>a&&(a=g),u++);}return o<2||u===0?null:{sum:l,avg:l/u,min:i,max:a,count:u}}var Me=new WeakMap;function M(t,e,n,r,o){let l=Me.get(e);if(!l){l=new Map;for(let m=0;m<e.length;m++)l.set(e[m].columnId,e[m]);Me.set(e,l);}let i=[];for(let m=0;m<e.length;m++){let c=e[m],d=w(c),s=n[d];if(s)switch(s.type){case "multiSelect":if(s.value.length>0){let f=new Set(s.value);i.push(g=>f.has(String(x(g,c))));}break;case "text":{let f=s.value.trim();if(f){let g=f.toLowerCase(),p=new Map;for(let I=0;I<t.length;I++)p.set(t[I],String(x(t[I],c)??"").toLowerCase());i.push(I=>(p.get(I)??"").includes(g));}break}case "people":{let f=s.value.email.toLowerCase(),g=new Map;for(let p=0;p<t.length;p++)g.set(t[p],String(x(t[p],c)??"").toLowerCase());i.push(p=>(g.get(p)??"")===f);break}case "date":{let f=s.value,g=f.from?new Date(f.from+"T00:00:00").getTime():NaN,p=f.to?new Date(f.to+"T23:59:59.999").getTime():NaN,I=new Map;for(let C=0;C<t.length;C++){let b=x(t[C],c);if(b==null)I.set(t[C],NaN);else {let y=new Date(String(b)).getTime();I.set(t[C],Number.isNaN(y)?NaN:y);}}i.push(C=>{let b=I.get(C)??NaN;return !(Number.isNaN(b)||!Number.isNaN(g)&&b<g||!Number.isNaN(p)&&b>p)});break}}}let a=i.length>0,u=a?t.filter(m=>{for(let c=0;c<i.length;c++)if(!i[c](m))return false;return true}):t;if(r){let m=a?u:u.slice(),c=l.get(r),d=c?.compare,s=o==="asc"?1:-1;if(c?.type==="date"&&!d){let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];if(C==null)g.set(I,NaN);else {let b=new Date(String(C)).getTime();g.set(I,Number.isNaN(b)?0:b);}}m.sort((p,I)=>{let C=g.get(p)??NaN,b=g.get(I)??NaN;return Number.isNaN(C)&&Number.isNaN(b)?0:Number.isNaN(C)?-1*s:Number.isNaN(b)?1*s:C===b?0:C>b?s:-s});}else if(d)m.sort((g,p)=>d(g,p)*s);else {let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];C==null?g.set(I,void 0):typeof C=="number"?g.set(I,C):g.set(I,String(C).toLowerCase());}m.sort((p,I)=>{let C=g.get(p),b=g.get(I);return C===void 0&&b===void 0?0:C===void 0?-1*s:b===void 0?1*s:C===b?0:C>b?s:-s});}return m}return u}function D(t,e){if(!t)return false;let n=Math.min(t.startRow,t.endRow),r=Math.max(t.startRow,t.endRow);return e>=n&&e<=r}function Pe(t,e){if(t.item!==e.item||t.isSelected!==e.isSelected||t.hasCheckboxCol!==e.hasCheckboxCol||t.visibleCols!==e.visibleCols||t.columnMeta!==e.columnMeta||t.cellClassMap!==e.cellClassMap||t.columnLayouts!==e.columnLayouts)return false;let n=t.rowIndex;if(t.editingRowId!==e.editingRowId&&(t.editingRowId===t.rowId||e.editingRowId===e.rowId))return false;let r=t.activeCell?.rowIndex===n,o=e.activeCell?.rowIndex===n;if(r!==o||r&&o&&t.activeCell?.columnIndex!==e.activeCell?.columnIndex)return false;let l=D(t.selectionRange,n),i=D(e.selectionRange,n);if(l!==i||l&&i&&(t.selectionRange?.startCol!==e.selectionRange?.startCol||t.selectionRange?.endCol!==e.selectionRange?.endCol))return false;let a=t.selectionRange?.endRow===n,u=e.selectionRange?.endRow===n;return !(a!==u||(a||u)&&t.isDragging!==e.isDragging||t.cutRange!==e.cutRange&&(D(t.cutRange,n)||D(e.cutRange,n))||t.copyRange!==e.copyRange&&(D(t.copyRange,n)||D(e.copyRange,n)))}function re(t,e){return e?e.left?.includes(t)?"left":e.right?.includes(t)?"right":"unpinned":"unpinned"}function Ne(t,e,n){let r=t.filter(i=>i!==e),o=Math.max(0,Math.min(n,r.length)),l=[...r];return l.splice(o,0,e),l}function Ae(t){let{mouseX:e,columnOrder:n,draggedColumnId:r,draggedPinState:o,tableElement:l,pinnedColumns:i}=t,a=l.querySelectorAll("[data-column-id]");if(a.length===0)return null;let u=[];if(a.forEach(s=>{let f=s.getAttribute("data-column-id");if(!f||re(f,i)!==o)return;let p=s.getBoundingClientRect(),I=n.indexOf(f);I!==-1&&u.push({columnId:f,left:p.left,right:p.right,midX:p.left+p.width/2,orderIndex:I});}),u.length===0)return null;u.sort((s,f)=>s.left-f.left);let m,c;if(e<=u[0].midX)m=u[0].orderIndex,c=u[0].left;else if(e>=u[u.length-1].midX){let s=u[u.length-1];m=s.orderIndex+1,c=s.right;}else {let s=-1;for(let f=0;f<u.length-1;f++)if(e>=u[f].midX&&e<u[f+1].midX){s=f;break}if(s===-1)return null;m=u[s].orderIndex+1,c=u[s].right;}let d=n.indexOf(r);return d===m||d+1===m?{targetIndex:m,indicatorX:null}:{targetIndex:m,indicatorX:c}}function _e(t,e,n,r=2){if(e.length===0||n<=0)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let o=0,l=e.length,i=-1;for(let d=0;d<e.length;d++){let s=o;o+=e[d],o>t&&l===e.length&&(l=d),s<t+n&&(i=d);}if(l>i)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let a=Math.max(0,l-r),u=Math.min(e.length-1,i+r),m=0;for(let d=0;d<a;d++)m+=e[d];let c=0;for(let d=u+1;d<e.length;d++)c+=e[d];return {startIndex:a,endIndex:u,leftOffset:m,rightOffset:c}}function Oe(t,e,n){let r=[],o=[],l=[];for(let a of t){let u=n?.[a.columnId];u==="left"?r.push(a):u==="right"?o.push(a):l.push(a);}if(!e||e.endIndex<0)return {pinnedLeft:r,virtualizedUnpinned:l,pinnedRight:o,leftSpacerWidth:0,rightSpacerWidth:0};let i=l.slice(e.startIndex,e.endIndex+1);return {pinnedLeft:r,virtualizedUnpinned:i,pinnedRight:o,leftSpacerWidth:e.leftOffset,rightSpacerWidth:e.rightOffset}}function ke(t,e,n,r,o=5){if(r<=0||e<=0||n<=0)return {startIndex:0,endIndex:0,offsetTop:0,offsetBottom:0};let l=Math.max(0,Math.floor(t/e)-o),i=Math.min(r-1,Math.ceil((t+n)/e)+o),a=l*e,u=Math.max(0,(r-i-1)*e);return {startIndex:l,endIndex:i,offsetTop:a,offsetBottom:u}}function Le(t,e){return t*e}function Ve(t,e,n,r="start"){let o=t*e;switch(r){case "start":return o;case "center":return Math.max(0,o-(n-e)/2);case "end":return Math.max(0,o-n+e)}}function Ue(){let t=self;t.onmessage=e=>{let n=e.data;if(n.type!=="sort-filter")return;let{requestId:r,values:o,filters:l,sort:i}=n,a=o.length,u=[],m=Object.entries(l);if(m.length===0){u=new Array(a);for(let d=0;d<a;d++)u[d]=d;}else for(let d=0;d<a;d++){let s=true;for(let f=0;f<m.length;f++){let g=Number(m[f][0]),p=m[f][1],I=o[d][g];switch(p.type){case "text":{let C=p.value.trim().toLowerCase();C&&!String(I??"").toLowerCase().includes(C)&&(s=false);break}case "multiSelect":{p.value.length>0&&(new Set(p.value).has(String(I??""))||(s=false));break}case "date":{if(I==null){s=false;break}let C=new Date(String(I)).getTime();if(isNaN(C)){s=false;break}if(p.value.from){let b=new Date(p.value.from+"T00:00:00").getTime();if(C<b){s=false;break}}if(p.value.to){let b=new Date(p.value.to+"T23:59:59.999").getTime();if(C>b){s=false;break}}break}}if(!s)break}s&&u.push(d);}if(i){let{columnIndex:d,direction:s}=i,f=s==="asc"?1:-1;u.sort((g,p)=>{let I=o[g][d],C=o[p][d];if(I==null&&C==null)return 0;if(I==null)return -1*f;if(C==null)return 1*f;if(typeof I=="number"&&typeof C=="number")return I===C?0:I>C?f:-f;let b=String(I).toLowerCase(),y=String(C).toLowerCase();return b===y?0:b>y?f:-f});}let c={type:"sort-filter-result",requestId:r,indices:u};t.postMessage(c);};}var S=null,Vt=0,E=new Map;function oe(){if(S)return S;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u")return null;try{let t=Ue.toString(),e=new Blob([`(${t})()`],{type:"application/javascript"}),n=URL.createObjectURL(e);return S=new Worker(n),URL.revokeObjectURL(n),S.onmessage=r=>{let{requestId:o,indices:l}=r.data,i=E.get(o);i&&(E.delete(o),i.resolve(l));},S.onerror=r=>{for(let[o,l]of E)l.reject(new Error(r.message||"Worker error")),E.delete(o);},S}catch{return null}}function He(){S&&(S.terminate(),S=null);for(let[t,e]of E)e.reject(new Error("Worker terminated")),E.delete(t);}function le(t,e){let n=new Array(t.length);for(let r=0;r<t.length;r++){let o=new Array(e.length);for(let l=0;l<e.length;l++){let i=x(t[r],e[l]);i==null?o[l]=null:typeof i=="string"||typeof i=="number"||typeof i=="boolean"?o[l]=i:o[l]=String(i);}n[r]=o;}return n}function Be(t,e,n,r,o){if(r&&e.find(f=>f.columnId===r)?.compare)return Promise.resolve(M(t,e,n,r,o));let l=oe();if(!l)return Promise.resolve(M(t,e,n,r,o));let i=new Map;for(let s=0;s<e.length;s++)i.set(e[s].columnId,s);let a=le(t,e),u=e.map((s,f)=>({type:s.type??"text",index:f})),m={};for(let s of e){let f=w(s),g=n[f];if(!g)continue;let p=i.get(s.columnId);if(p!==void 0)switch(g.type){case "text":m[p]={type:"text",value:g.value};break;case "multiSelect":m[p]={type:"multiSelect",value:g.value};break;case "date":m[p]={type:"date",value:{from:g.value.from,to:g.value.to}};break;case "people":return Promise.resolve(M(t,e,n,r,o))}}let c;if(r){let s=i.get(r);s!==void 0&&(c={columnIndex:s,direction:o??"asc"});}let d=++Vt;return new Promise((s,f)=>{E.set(d,{resolve:p=>{let I=new Array(p.length);for(let C=0;C<p.length;C++)I[C]=t[p[C]];s(I);},reject:f});let g={type:"sort-filter",requestId:d,values:a,columnMeta:u,filters:m,sort:c};l.postMessage(g);})}var B="YYYY-MM-DD";function G(t,e,n="UTC"){if(t==null)return null;let r=t instanceof Date?t:new Date(String(t));if(Number.isNaN(r.getTime()))return null;let o,l,i;if(n==="UTC")o=r.getUTCFullYear(),l=r.getUTCMonth()+1,i=r.getUTCDate();else {let d=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(r);o=parseInt(d.find(s=>s.type==="year")?.value??"0",10),l=parseInt(d.find(s=>s.type==="month")?.value??"0",10),i=parseInt(d.find(s=>s.type==="day")?.value??"0",10);}let a=String(o).padStart(4,"0"),u=String(l).padStart(2,"0"),m=String(i).padStart(2,"0");return e.replace("YYYY",a).replace("MM",u).replace("DD",m)}function Ge(t,e){if(!t||!t.trim())return null;let r=t.trim().split(/[/\-.\s]+/).filter(Boolean);if(r.length===0)return null;let o=new Date().getUTCFullYear(),l=Ut(e),i,a,u;if(r.length===3){let[c,d,s]=r.map(Number);l==="YMD"?(i=c,a=d,u=s):l==="DMY"?(u=c,a=d,i=s):(a=c,u=d,i=s),i!==void 0&&i<100&&(i=i<50?2e3+i:1900+i);}else if(r.length===2){let[c,d]=r.map(Number);l==="DMY"?(u=c,a=d):(a=c,u=d),i=o;}else if(r.length===1){let c=r[0];if(/^\d+$/.test(c))if(c.length===8)i=parseInt(c.slice(0,4),10),a=parseInt(c.slice(4,6),10),u=parseInt(c.slice(6,8),10);else if(c.length===4)a=parseInt(c.slice(0,2),10),u=parseInt(c.slice(2,4),10),i=o;else return null;else return null}else return null;if(!Ht(i,a,u))return null;let m=new Date(Date.UTC(i,a-1,u));return m.getUTCFullYear()!==i||m.getUTCMonth()+1!==a||m.getUTCDate()!==u?null:m}function We(t){return t}function Ut(t){let e=t.indexOf("Y"),n=t.indexOf("M"),r=t.indexOf("D");return e===-1||n===-1||r===-1?"MDY":e<n&&n<r?"YMD":r<n&&n<e?"DMY":"MDY"}function Ht(t,e,n){return !(t==null||e==null||n==null||!Number.isFinite(t)||!Number.isFinite(e)||!Number.isFinite(n)||e<1||e>12||n<1||n>31)}var V=class{constructor(e,n){this.type=e;this.message=n;}toString(){return this.type}};function Xe(t,e){let n=v(t.filterable)?t.filterable:null,r=n?.type??"none",o=n?.filterField??t.columnId,l=t.sortable!==false,i=e.filters[o],a={columnKey:t.columnId,columnName:t.name,filterType:r,isSorted:e.sortBy===t.columnId,isSortedDescending:e.sortBy===t.columnId&&e.sortDirection==="desc",onSort:l?()=>e.onColumnSort(t.columnId):void 0};return r==="text"?{...a,textValue:i?.type==="text"?i.value:"",onTextChange:u=>e.onFilterChange(o,u.trim()?{type:"text",value:u}:void 0)}:r==="people"?{...a,selectedUser:i?.type==="people"?i.value:void 0,onUserChange:u=>e.onFilterChange(o,u?{type:"people",value:u}:void 0),peopleSearch:e.peopleSearch}:r==="multiSelect"?{...a,options:e.filterOptions[o]??[],isLoadingOptions:e.loadingFilterOptions[o]??false,selectedValues:i?.type==="multiSelect"?i.value:[],onFilterChange:u=>e.onFilterChange(o,u.length?{type:"multiSelect",value:u}:void 0)}:r==="date"?{...a,dateValue:i?.type==="date"?i.value:void 0,onDateChange:u=>e.onFilterChange(o,u?{type:"date",value:u}:void 0)}:a}var $=class ${constructor(){this.cache=new Map;this.lastVersion="";}static computeVersion(e){let n=e.editingCell,r=e.activeCell,o=e.selectionRange,l=e.cutRange,i=e.copyRange;return (n?`${String(n.rowId)}\0${n.columnId}`:"")+""+(r?`${r.rowIndex}\0${r.columnIndex}`:"")+""+(o?`${o.startRow}\0${o.startCol}\0${o.endRow}\0${o.endCol}`:"")+""+(l?`${l.startRow}\0${l.startCol}\0${l.endRow}\0${l.endCol}`:"")+""+(i?`${i.startRow}\0${i.startCol}\0${i.endRow}\0${i.endCol}`:"")+""+(e.isDragging?"1":"0")+""+(e.editable!==false?"1":"0")+""+(e.onCellValueChanged?"1":"0")+""+(e.formulaVersion??0)}get(e,n,r,o){let l=e*$.MAX_COL_STRIDE+n,i=this.cache.get(l);if(i!==void 0&&i.version===r)return i.descriptor;let a=o();return this.cache.set(l,{version:r,descriptor:a}),a}updateVersion(e){this.lastVersion=e;}get currentVersion(){return this.lastVersion}clear(){this.cache.clear();}};$.MAX_COL_STRIDE=1024;var W=$;function qe(t,e,n,r,o,l){return l!==void 0?l.get(n,r,l.currentVersion,()=>$e(t,e,n,r,o)):$e(t,e,n,r,o)}function $e(t,e,n,r,o){let l=o.getRowId(t),i=r+o.colOffset,a=h(e,t),u=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor!="function",m=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor=="function"&&e.cellEditorPopup!==false,c=u||m,d=o.editingCell?.rowId===l&&o.editingCell?.columnId===e.columnId,s=!o.isDragging&&o.activeCell?.rowIndex===n&&o.activeCell?.columnIndex===i,f=o.selectionRange!=null&&o.selectionRange.startRow===o.selectionRange.endRow&&o.selectionRange.startCol===o.selectionRange.endCol,g=o.selectionRange!=null&&!f&&F(o.selectionRange,n,r),p=o.cutRange!=null&&F(o.cutRange,n,r),I=o.copyRange!=null&&F(o.copyRange,n,r),C=!o.isDragging&&o.copyRange==null&&o.cutRange==null&&o.selectionRange!=null&&n===o.selectionRange.endRow&&r===o.selectionRange.endCol,b=e.pinned!=null,y=e.pinned??void 0,N=x(t,e),H=o.hasFormula?.(r,n)??false,A=H?o.getFormulaValue?.(r,n):void 0,_="display",O;d&&u?(_="editing-inline",e.cellEditor==="text"||e.cellEditor==="select"||e.cellEditor==="checkbox"||e.cellEditor==="richSelect"||e.cellEditor==="date"?O=e.cellEditor:e.type==="date"?O="date":e.type==="boolean"?O="checkbox":O="text"):d&&m&&typeof e.cellEditor=="function"&&(_="editing-popover");let kt=d&&H?o.getFormula?.(r,n)??N:N;return {mode:_,editorType:O,value:kt,isActive:s,isInRange:g,isInCutRange:p,isInCopyRange:I,isSelectionEndCell:C,canEditAny:c,isPinned:b,pinnedSide:y,globalColIndex:i,rowId:l,rowIndex:n,displayValue:A!==void 0?A:N,columnType:e.type}}function ze(t,e,n){if(n instanceof V)return n.toString();let r=t;if(r.renderCell&&typeof r.renderCell=="function")return r.renderCell(e);if(t.valueFormatter)return t.valueFormatter(n,e);if(n==null)return null;if(t.type==="date"){let o=t.dateFormat??B,l=G(n,o);if(l!==null)return l}return t.type==="boolean"?n?"True":"False":String(n)}function Ye(t,e,n){let r=t,o=n instanceof V,l=r.cellStyle?typeof r.cellStyle=="function"?r.cellStyle(e):r.cellStyle:void 0;return o?{...l,color:"var(--ogrid-formula-error-color, #d32f2f)"}:l}function je(t,e,n,r){let o=n.editorType??"text";return {value:n.value,item:t,column:e,rowIndex:n.rowIndex,editorType:o,onCommit:l=>r.commitCellEdit(t,e.columnId,n.value,l,n.rowIndex,n.globalColIndex,o==="checkbox"?{skipAdvance:true}:void 0),onCancel:()=>r.setEditingCell(null)}}function Ke(t,e,n,r,o){let l=n.value,i=r!==void 0?r:l,a=r;return {value:i,onValueChange:u=>{a=u,o.setPendingEditorValue(u);},onCommit:()=>{let u=a!==void 0?a:l;o.commitCellEdit(t,e.columnId,l,u,n.rowIndex,n.globalColIndex);},onCancel:o.cancelPopoverEdit,item:t,column:e,cellEditorParams:e.cellEditorParams}}function Ze(t,e){let n=null,r=((...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{t(...o),n=null;},e);});return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null);},r}function Qe(t,e,n){let r=e.startCol+n,o=e.endCol+n,l=t.querySelector(`[data-row-index="${e.startRow}"][data-col-index="${r}"]`),i=t.querySelector(`[data-row-index="${e.endRow}"][data-col-index="${o}"]`);if(!l||!i)return null;let a=t.getBoundingClientRect(),u=l.getBoundingClientRect(),m=i.getBoundingClientRect();return {top:u.top-a.top,left:u.left-a.left,width:m.right-u.left,height:m.bottom-u.top}}function Je(t){let e=new Map;if(!t)return e;let n=t.querySelectorAll("[data-row-index][data-col-index]");for(let r=0;r<n.length;r++){let o=n[r],l=o.getAttribute("data-row-index")??"",i=o.getAttribute("data-col-index")??"";e.set(`${l},${i}`,o);}return e}function et(t,e){if(typeof document>"u"||document.getElementById(t))return;let n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n);}function tt(t,e,n){return n===null?{field:"",direction:"asc"}:n?{field:e,direction:n}:{field:e,direction:t.field===e&&t.direction==="asc"?"desc":"asc"}}var nt=48,rt=50,X=80,ot=16,lt=30,it="__row_number__",at=6;var ie=16,ae=520,Bt=44,Gt=8;function st(t){return Math.max(80,Math.ceil(t.length*Gt+Bt))}function Wt(t){let e=getComputedStyle(t),n=(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),r=(parseFloat(e.borderLeftWidth)||0)+(parseFloat(e.borderRightWidth)||0),o=0;for(let d=0;d<t.children.length;d++){let s=t.children[d],f=s.className||"";if(f.includes("resizeHandle")||f.includes("resize-handle")||f.includes("ogrid-resize-handle")){o=s.offsetWidth;break}}let l=t.firstElementChild;if(!l)return t.offsetWidth;let i=[],a=d=>{for(let s=0;s<d.children.length;s++){let f=d.children[s],g=getComputedStyle(f);(g.overflow==="hidden"||g.flexShrink!=="0")&&(i.push({el:f,overflow:f.style.overflow,flexShrink:f.style.flexShrink,width:f.style.width,minWidth:f.style.minWidth,maxWidth:f.style.maxWidth}),f.style.overflow="visible",f.style.flexShrink="0",f.style.width="max-content",f.style.minWidth="max-content",f.style.maxWidth="none"),a(f);}},u=l.style.position,m=l.style.width;l.style.position="absolute",l.style.width="max-content",a(l);let c=l.offsetWidth;l.style.position=u,l.style.width=m;for(let d of i)d.el.style.overflow=d.overflow,d.el.style.flexShrink=d.flexShrink,d.el.style.width=d.width,d.el.style.minWidth=d.minWidth,d.el.style.maxWidth=d.maxWidth;return c+o+n+r}function ut(t,e,n){let r=e??80,l=(n??document).querySelectorAll(`[data-column-id="${t}"]`);if(l.length===0)return r;let i=r,a=[],u=[],m=[];if(l.forEach(c=>{let d=c;if(!!d.querySelector?.("[data-header-label]"))i=Math.max(i,Wt(d));else {let f=d.firstElementChild??d;a.push(f);}}),a.length>0){for(let c=0;c<a.length;c++){let d=a[c];u.push(d.style.position),m.push(d.style.width),d.style.position="absolute",d.style.width="max-content";}for(let c=0;c<a.length;c++)i=Math.max(i,a[c].offsetWidth+ie);for(let c=0;c<a.length;c++)a[c].style.position=u[c],a[c].style.width=m[c];}return Math.min(ae,Math.max(r,Math.ceil(i)))}function P(t,e,n,r){if(t===e)return t;let o=t+n;if(!r(t)&&!r(o)){let i=o;for(;i!==e;){if(r(i+n))return i;i+=n;}return e}let l=o;for(;l!==e;){if(!r(l))return l;l+=n;}return e}function dt(t,e,n,r,o,l){let i=t,a=e;return l?e>o?a=e-1:t>0&&(i=t-1,a=r):e<r?a=e+1:t<n&&(i=t+1,a=o),{rowIndex:i,columnIndex:a}}function ct(t){let{direction:e,rowIndex:n,columnIndex:r,dataColIndex:o,colOffset:l,maxRowIndex:i,maxColIndex:a,visibleColCount:u,isCtrl:m,isShift:c,selectionRange:d,isEmptyAt:s}=t,f=n,g=r;e==="ArrowDown"?f=m?P(n,i,1,b=>s(b,Math.max(0,o))):Math.min(n+1,i):e==="ArrowUp"?f=m?P(n,0,-1,b=>s(b,Math.max(0,o))):Math.max(n-1,0):e==="ArrowRight"?m&&o>=0?g=P(o,u-1,1,b=>s(n,b))+l:g=Math.min(r+1,a):m&&o>=0?g=P(o,0,-1,b=>s(n,b))+l:g=Math.max(r-1,l);let p=g-l,I=e==="ArrowDown"||e==="ArrowUp",C;return c?I?C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:f,endCol:d?.endCol??o}):C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:d?.endRow??n,endCol:p}):C={startRow:f,startCol:p,endRow:f,endCol:p},{newRowIndex:f,newColumnIndex:g,newDataColIndex:p,newRange:C}}function mt(t,e,n){let r=R(t),o=[];for(let l=r.startRow;l<=r.endRow;l++)for(let i=r.startCol;i<=r.endCol;i++){if(l>=e.length||i>=n.length)continue;let a=e[l],u=n[i];if(!h(u,a))continue;let m=x(a,u),c=T("",m,a,u);c.valid&&o.push({item:a,columnId:u.columnId,oldValue:m,newValue:c.value,rowIndex:l});}return o}function ft(t,e){return t===e?true:!t||!e?false:t.startRow===e.startRow&&t.endRow===e.endRow&&t.startCol===e.startCol&&t.endCol===e.endCol}function pt(t,e,n){return e<0||n<0?null:{startRow:Math.max(0,Math.min(t.startRow,e)),endRow:Math.max(0,Math.min(t.endRow,e)),startCol:Math.max(0,Math.min(t.startCol,n)),endCol:Math.max(0,Math.min(t.endCol,n))}}function gt(t,e=40,n=2,r=20){let o=Math.min(t/e,1);return n+o*(r-n)}function Ct(t,e,n,r,o,l){let i=new Set(l),a=Math.min(t,e),u=Math.max(t,e);for(let m=a;m<=u;m++)if(m<r.length){let c=o(r[m]);n?i.add(c):i.delete(c);}return i}function It(t,e,n){if(t.size===0||e.length===0)return {allSelected:false,someSelected:false};let r=t.size>=e.length&&e.every(l=>t.has(n(l))),o=!r&&t.size>0;return {allSelected:r,someSelected:o}}function se(t,e){let n=e!=null&&e!==""?e:t;if(n==null||n==="")return "";try{return String(n).replace(/[\t\n]/g," ")}catch{return "[Object]"}}function bt(t,e,n,r){let o=R(n),l=[];for(let i=o.startRow;i<=o.endRow;i++){let a=[];for(let u=o.startCol;u<=o.endCol&&!(i>=t.length||u>=e.length);u++){let m=t[i],c=e[u];if(r?.hasFormula&&r?.getFormula){let g=r.flatColumns.findIndex(p=>p.columnId===c.columnId);if(g>=0&&r.hasFormula(g,i)){let p=r.getFormula(g,i);if(p){a.push(p);continue}}}let d=x(m,c),f=(c.clipboardFormatter?c.clipboardFormatter(d,m):null)??(c.valueFormatter?c.valueFormatter(d,m):d);a.push(se(d,f));}l.push(a.join(" "));}return l.join(`\r
4
+ `)}function xt(t){return t.trim()?t.split(/\r?\n/).filter(n=>n.length>0).map(n=>n.split(" ")):[]}function ht(t,e,n,r,o,l){let i=[];for(let a=0;a<t.length;a++){let u=t[a];for(let m=0;m<u.length;m++){let c=e+a,d=n+m;if(c>=r.length||d>=o.length)continue;let s=r[c],f=o[d];if(!h(f,s))continue;let g=u[m]??"";if(g.startsWith("=")&&l?.setFormula){let C=l.flatColumns.findIndex(b=>b.columnId===f.columnId);if(C>=0){l.setFormula(C,c,g);continue}}let p=x(s,f),I=T(g,p,s,f);I.valid&&i.push({item:s,columnId:f.columnId,oldValue:p,newValue:I.value,rowIndex:c});}}return i}function Rt(t,e,n){let r=[];for(let o=t.startRow;o<=t.endRow;o++)for(let l=t.startCol;l<=t.endCol;l++){if(o>=e.length||l>=n.length)continue;let i=e[o],a=n[l];if(!h(a,i))continue;let u=x(i,a),m=T("",u,i,a);m.valid&&r.push({item:i,columnId:a.columnId,oldValue:u,newValue:m.value,rowIndex:o});}return r}function U(t){let e="",n=t;for(;n>=0;)e=String.fromCharCode(n%26+65)+e,n=Math.floor(n/26)-1;return e}function q(t){let e=0,n=t.toUpperCase();for(let r=0;r<n.length;r++)e=e*26+(n.charCodeAt(r)-64);return e-1}function yt(t,e){return `${U(t)}${e}`}var Tt=/(?:'[^']*'!|[A-Za-z_]\w*!)?(\$?)([A-Z]+)(\$?)(\d+)/g;function St(t,e,n){return Tt.lastIndex=0,t.replace(Tt,(r,o,l,i,a)=>{let u=r.indexOf(o+l),m=u>0?r.substring(0,u):"",c=l,d=a;if(o!=="$"){let s=q(l)+e;if(s<0)return "#REF!";c=U(s);}if(i!=="$"){let s=parseInt(a,10)+n;if(s<1)return "#REF!";d=String(s);}return `${m}${o}${c}${i}${d}`})}function ue(t,e){if(t.columnId===e.columnId)return true;let n=t.type??"text",r=e.type??"text";return !(n!==r||t.cellEditor!==e.cellEditor)}function wt(t,e,n,r,o,l){let i=[],a=r[t.startRow],u=o[t.startCol];if(!a||!u)return i;let m=x(a,u),c=l?l.flatColumns.findIndex(s=>s.columnId===u.columnId):-1,d=new Set;for(let s=t.startCol;s<=t.endCol;s++)s<o.length&&ue(u,o[s])&&d.add(s);for(let s=t.startRow;s<=t.endRow;s++)for(let f=t.startCol;f<=t.endCol;f++){if(s===e&&f===n||s>=r.length||!d.has(f))continue;let g=r[s],p=o[f];if(!h(p,g))continue;if(l&&l.hasFormula&&l.getFormula&&l.setFormula&&c>=0&&l.hasFormula(c,e)){let b=l.getFormula(c,e);if(b){let y=s-e,N=f-n,H=St(b,N,y),A=l.flatColumns.findIndex(_=>_.columnId===p.columnId);if(A>=0){l.setFormula(A,s,H);continue}}}let I=x(g,p),C=T(m,I,g,p);C.valid&&i.push({item:g,columnId:p.columnId,oldValue:I,newValue:C.value,rowIndex:s});}return i}var z=class{constructor(e=100){this.history=[];this.redoStack=[];this.batch=null;this.maxDepth=e;}get canUndo(){return this.history.length>0}get canRedo(){return this.redoStack.length>0}get historyLength(){return this.history.length}get redoLength(){return this.redoStack.length}get isBatching(){return this.batch!==null}push(e){e.length!==0&&(this.batch!==null?this.batch.push(...e):(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0));}record(e){this.push([e]);}beginBatch(){this.batch===null&&(this.batch=[]);}endBatch(){let e=this.batch;this.batch=null,!(!e||e.length===0)&&(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0);}undo(){let e=this.history.pop();return e?(this.redoStack.push(e),e):null}redo(){let e=this.redoStack.pop();return e?(this.history.push(e),e):null}clear(){this.history=[],this.redoStack=[];}};function Dt(t){if(!Array.isArray(t)||t.length===0){console.warn("[OGrid] columns prop is empty or not an array");return}let e=typeof process<"u"&&process.env?.NODE_ENV!=="production",n=new Set;for(let r of t)r.columnId||console.warn("[OGrid] Column missing columnId:",r),n.has(r.columnId)&&console.warn(`[OGrid] Duplicate columnId: "${r.columnId}"`),n.add(r.columnId),e&&r.editable===true&&r.cellEditor==null&&console.warn(`[OGrid] Column "${r.columnId}" has editable=true but no cellEditor defined. Cells will not open an editor on double-click. Set cellEditor to 'text', 'select', 'checkbox', 'date', or a custom component.`);}function vt(t){typeof process<"u"&&process.env?.NODE_ENV==="production"||t.enabled===true&&(!t.rowHeight||t.rowHeight<=0)&&console.warn("[OGrid] virtualScroll.enabled is true but rowHeight is missing or <= 0. Set a positive rowHeight (e.g. virtualScroll: { enabled: true, rowHeight: 36 }) for correct virtual scrolling behavior.");}function Et(t,e){if(typeof process<"u"&&process.env.NODE_ENV==="production"||!e)return;let n=new Set,r=Math.min(t.length,100);for(let o=0;o<r;o++){let l=e(t[o]);if(l==null){console.warn(`[OGrid] getRowId returned null/undefined for row ${o}`);return}if(n.has(l)){console.warn(`[OGrid] Duplicate row ID "${l}" at index ${o}. getRowId must return unique values.`);return}n.add(l);}}var de=[{minWidth:0,maxPriority:0},{minWidth:576,maxPriority:1},{minWidth:768,maxPriority:2},{minWidth:992,maxPriority:3},{minWidth:1200,maxPriority:1/0}];function ce(t,e,n){let r=n?.breakpoints??de,o=new Set;if(t<=0||e.length===0)return o;let l=1/0;for(let i=r.length-1;i>=0;i--)if(t>=r[i].minWidth){l=r[i].maxPriority;break}if(l===1/0)return o;for(let i of e)i.responsivePriority!=null&&(i.required||i.responsivePriority>l&&o.add(i.columnId));return o}function Ft(t){return t===true?{}:t||void 0}function Mt(t,e,n){if(!n||e<=0)return t;let r=ce(e,t,n);return r.size===0?t:t.filter(o=>!r.has(o.columnId))}function Pt(t,e,n,r,o){t.stopPropagation();let l=n-r;o.setActiveCell({rowIndex:e,columnIndex:n}),o.setSelectionRange({startRow:e,startCol:l,endRow:e,endCol:l});}var Nt=300,At=300,_t=300;var Ot={RESIZE_HANDLE:1,ACTIVE_CELL:2,FILL_HANDLE:3,SELECTION_OVERLAY:4,ROW_NUMBER:5,CLIPBOARD_OVERLAY:5,PINNED:6,SELECTION_CELL:7,THEAD:8,PINNED_HEADER:10,HEADER_FOCUS:11,SELECTION_HEADER_PINNED:12,LOADING:2,DROP_INDICATOR:100,DROPDOWN:1e3,FILTER_POPOVER:1e3,MODAL:2e3,FULLSCREEN:9999,CONTEXT_MENU:1e4};export{ie as AUTOSIZE_EXTRA_PX,ae as AUTOSIZE_MAX_PX,ot as CELL_PADDING,nt as CHECKBOX_COLUMN_WIDTH,we as COLUMN_HEADER_MENU_ITEMS,W as CellDescriptorCache,B as DEFAULT_DATE_FORMAT,Nt as DEFAULT_DEBOUNCE_MS,X as DEFAULT_MIN_COLUMN_WIDTH,at as GRID_BORDER_RADIUS,ye as GRID_CONTEXT_MENU_ITEMS,J as MAX_PAGE_BUTTONS,Q as PAGE_SIZE_OPTIONS,At as PEOPLE_SEARCH_DEBOUNCE_MS,de as RESPONSIVE_BREAKPOINTS,it as ROW_NUMBER_COLUMN_ID,lt as ROW_NUMBER_COLUMN_MIN_WIDTH,rt as ROW_NUMBER_COLUMN_WIDTH,_t as SIDEBAR_TRANSITION_MS,z as UndoRedoStack,Ot as Z_INDEX,mt as applyCellDeletion,Rt as applyCutClear,wt as applyFillValues,ht as applyPastedValues,Ct as applyRangeRowSelection,Mt as applyResponsiveHiding,ue as areFillCompatible,Pe as areGridRowPropsEqual,ne as booleanParser,Je as buildCellIndex,Y as buildCsvHeader,j as buildCsvRows,ge as buildHeaderRows,je as buildInlineEditorProps,Ke as buildPopoverEditorProps,Ae as calculateDropTarget,pt as clampSelectionToBounds,q as columnLetterToIndex,Fe as computeAggregations,ct as computeArrowNavigation,gt as computeAutoScrollSpeed,tt as computeNextSortState,It as computeRowSelectionState,dt as computeTabNavigation,Le as computeTotalHeight,_e as computeVisibleColumnRange,ke as computeVisibleRange,pe as createGridDataAccessor,oe as createSortFilterWorker,ve as currencyParser,te as dateParser,Ze as debounce,Ie as deriveFilterOptionsFromData,Ee as emailParser,k as escapeCsvValue,st as estimateHeaderMinWidth,fe as exportToCsv,le as extractValueMatrix,P as findCtrlArrowTarget,Z as flattenColumns,yt as formatCellReference,se as formatCellValueForTsv,G as formatDateForDisplay,bt as formatSelectionAsTsv,Te as formatShortcut,qe as getCellRenderDescriptor,x as getCellValue,De as getColumnHeaderMenuItems,Se as getContextMenuHandlers,he as getDataGridStatusBarConfig,We as getDateInputPlaceholder,w as getFilterField,Xe as getHeaderFilterConfig,be as getMultiSelectFilterFields,Re as getPaginationViewModel,re as getPinStateForColumn,ce as getResponsiveHiddenColumns,Ve as getScrollTopForRow,xe as getStatusBarParts,Pt as handleBooleanCellPointerDown,U as indexToColumnLetter,et as injectGlobalStyles,h as isColumnEditable,v as isFilterConfig,F as isInSelectionRange,D as isRowInRange,ut as measureColumnContentWidth,Qe as measureRange,Ce as mergeFilter,R as normalizeSelectionRange,ee as numberParser,xt as parseTsvClipboard,Ge as parseUserInputDate,T as parseValue,Oe as partitionColumnsForVirtualization,M as processClientSideData,Be as processClientSideDataAsync,ft as rangesEqual,Ne as reorderColumnArray,ze as resolveCellDisplayContent,Ye as resolveCellStyle,Ft as resolveResponsiveConfig,He as terminateSortFilterWorker,me as toUserLike,K as triggerCsvDownload,Dt as validateColumns,Et as validateRowIds,vt as validateVirtualScrollConfig};
@@ -20,6 +20,8 @@ export type { AggregationResult } from './utils';
20
20
  export { processClientSideData } from './utils';
21
21
  export { areGridRowPropsEqual, isRowInRange } from './utils';
22
22
  export type { GridRowComparatorProps } from './utils';
23
+ export { handleBooleanCellPointerDown } from './utils';
24
+ export type { BooleanCellSelectHandlers } from './utils';
23
25
  export { getPinStateForColumn, reorderColumnArray, calculateDropTarget, } from './utils';
24
26
  export type { ColumnPinState, IDropTarget, ICalculateDropTargetParams } from './utils';
25
27
  export { computeVisibleRange, computeTotalHeight, getScrollTopForRow, computeVisibleColumnRange, partitionColumnsForVirtualization, } from './utils';
@@ -33,7 +35,7 @@ export { measureRange, buildCellIndex, injectGlobalStyles } from './utils';
33
35
  export type { OverlayRect } from './utils';
34
36
  export { computeNextSortState } from './utils';
35
37
  export type { ISortState } from './utils';
36
- export { measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX } from './utils';
38
+ export { measureColumnContentWidth, estimateHeaderMinWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX } from './utils';
37
39
  export { findCtrlArrowTarget, computeTabNavigation, computeArrowNavigation, applyCellDeletion } from './utils';
38
40
  export type { ArrowNavigationContext, ArrowNavigationResult } from './utils';
39
41
  export { rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, applyRangeRowSelection, computeRowSelectionState } from './utils';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shared utilities for boolean (checkbox) cell handling across all OGrid UI packages.
3
+ *
4
+ * The boolean cell pointerdown pattern repeats across React, Angular, and Vue:
5
+ * 1. Stop propagation so the parent td's drag-select logic doesn't fire.
6
+ * 2. Select the boolean cell (set active cell + selection range).
7
+ *
8
+ * Extracting this here lets each package call a single helper instead of
9
+ * inlining the same three-step dance every time.
10
+ *
11
+ * Note: The vanilla JS package (TableRenderer.ts) uses a lower-level onCellMouseDown
12
+ * callback interface that bundles selection into a single call. It doesn't use this
13
+ * helper, but the stopPropagation step is still the same.
14
+ */
15
+ import type { IActiveCell, ISelectionRange } from '../types';
16
+ /**
17
+ * Callbacks that each UI package provides to select a cell in the grid.
18
+ * These map directly to the interaction handles exposed by the state layer.
19
+ */
20
+ export interface BooleanCellSelectHandlers {
21
+ setActiveCell: (cell: IActiveCell | null) => void;
22
+ setSelectionRange: (range: ISelectionRange | null) => void;
23
+ }
24
+ /**
25
+ * Handle a pointerdown event on a boolean (checkbox) cell.
26
+ *
27
+ * Stops the event from bubbling to the parent td, which would otherwise start
28
+ * a drag-select. Then selects the cell so the grid shows it as active.
29
+ *
30
+ * @param event - The native or synthetic pointer event from the checkbox.
31
+ * @param rowIndex - Row index of the boolean cell.
32
+ * @param globalColIndex - Global column index (includes checkbox/row-number offset).
33
+ * @param colOffset - Number of pinned left columns (checkbox col + row numbers col).
34
+ * @param handlers - Grid interaction callbacks for setting the active cell.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * // React
39
+ * onPointerDown={(e) =>
40
+ * handleBooleanCellPointerDown(e, descriptor.rowIndex, descriptor.globalColIndex, colOffset, {
41
+ * setActiveCell,
42
+ * setSelectionRange: (r) => interaction.setSelectionRange(r),
43
+ * })
44
+ * }
45
+ *
46
+ * // Angular (in the component method)
47
+ * onBooleanCheckboxPointerDown(event: PointerEvent, rowIndex: number, globalColIndex: number): void {
48
+ * handleBooleanCellPointerDown(event, rowIndex, globalColIndex, this.colOffset(), {
49
+ * setActiveCell: (c) => this.state().interaction.setActiveCell?.(c),
50
+ * setSelectionRange: (r) => this.state().interaction.setSelectionRange?.(r),
51
+ * });
52
+ * }
53
+ * ```
54
+ */
55
+ export declare function handleBooleanCellPointerDown(event: {
56
+ stopPropagation(): void;
57
+ }, rowIndex: number, globalColIndex: number, colOffset: number, handlers: BooleanCellSelectHandlers): void;
@@ -5,6 +5,21 @@
5
5
  export declare const AUTOSIZE_EXTRA_PX = 16;
6
6
  /** Maximum column width from autosize. */
7
7
  export declare const AUTOSIZE_MAX_PX = 520;
8
+ /**
9
+ * Estimate the minimum column width (in pixels) needed to display the given
10
+ * header name without truncation.
11
+ *
12
+ * This is a DOM-free approximation used at initialization time, before any
13
+ * actual measurements are available. It uses a fixed character-width estimate
14
+ * for the default header font (14px bold), plus overhead for padding and the
15
+ * column-options menu button.
16
+ *
17
+ * The result is always at least DEFAULT_MIN_COLUMN_WIDTH.
18
+ *
19
+ * @param headerName - The column's display name (used for text-length estimation).
20
+ * @returns Estimated minimum pixel width to fit the header without ellipsis.
21
+ */
22
+ export declare function estimateHeaderMinWidth(headerName: string): number;
8
23
  /**
9
24
  * Measure the ideal width for a column by scanning all DOM cells with
10
25
  * `[data-column-id="<columnId>"]` and computing the maximum content width.
@@ -6,11 +6,9 @@ import type { IColumnDef, ICellValueChangedEvent } from '../types/columnTypes';
6
6
  import type { ISelectionRange } from '../types/dataGridTypes';
7
7
  /**
8
8
  * Check whether two columns are type-compatible for fill operations.
9
- * Returns true if a value from the source column can be filled into the target column.
10
9
  *
11
10
  * Columns are compatible when they share the same built-in type AND the same cellEditor.
12
11
  * This prevents dragging a text value onto a color picker, or a rating onto a date field.
13
- * Same-column fills (different rows) always pass because both sides are identical.
14
12
  */
15
13
  export declare function areFillCompatible<T>(source: IColumnDef<T>, target: IColumnDef<T>): boolean;
16
14
  /**
@@ -30,7 +30,7 @@ export { measureRange, buildCellIndex, injectGlobalStyles } from './dom';
30
30
  export type { OverlayRect } from './dom';
31
31
  export { computeNextSortState } from './sortHelpers';
32
32
  export type { ISortState } from './sortHelpers';
33
- export { measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX } from './columnAutosize';
33
+ export { measureColumnContentWidth, estimateHeaderMinWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX } from './columnAutosize';
34
34
  export { findCtrlArrowTarget, computeTabNavigation, computeArrowNavigation, applyCellDeletion } from './keyboardNavigation';
35
35
  export type { ArrowNavigationContext, ArrowNavigationResult } from './keyboardNavigation';
36
36
  export { rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, applyRangeRowSelection, computeRowSelectionState } from './selectionHelpers';
@@ -45,3 +45,5 @@ export type { FormulaReference } from './formulaBarHelpers';
45
45
  export { getResponsiveHiddenColumns, RESPONSIVE_BREAKPOINTS, resolveResponsiveConfig, applyResponsiveHiding } from './responsiveColumns';
46
46
  export type { IResponsiveColumnsConfig } from './responsiveColumns';
47
47
  export { formatDateForDisplay, parseUserInputDate, getDateInputPlaceholder, DEFAULT_DATE_FORMAT } from './dateFormatter';
48
+ export { handleBooleanCellPointerDown } from './checkboxUtils';
49
+ export type { BooleanCellSelectHandlers } from './checkboxUtils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-core",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "description": "OGrid core – framework-agnostic types, algorithms, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",