velox-grid 0.11.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +483 -0
  2. package/README.md +755 -0
  3. package/dist/react/index.esm.js +3757 -0
  4. package/dist/react/index.esm.js.map +1 -0
  5. package/dist/react/index.js +7 -0
  6. package/dist/react/index.js.map +1 -0
  7. package/dist/react/react/VeloxGridReact.d.ts +33 -0
  8. package/dist/react/react/VeloxGridReact.d.ts.map +1 -0
  9. package/dist/react/react/index.d.ts +9 -0
  10. package/dist/react/react/index.d.ts.map +1 -0
  11. package/dist/react/react/types.d.ts +52 -0
  12. package/dist/react/react/types.d.ts.map +1 -0
  13. package/dist/react/react/useVeloxGrid.d.ts +23 -0
  14. package/dist/react/react/useVeloxGrid.d.ts.map +1 -0
  15. package/dist/react/types/index.d.ts +878 -0
  16. package/dist/react/types/index.d.ts.map +1 -0
  17. package/dist/types/core/GridColumnMenu.d.ts +35 -0
  18. package/dist/types/core/GridColumnMenu.d.ts.map +1 -0
  19. package/dist/types/core/GridDragManager.d.ts +83 -0
  20. package/dist/types/core/GridDragManager.d.ts.map +1 -0
  21. package/dist/types/core/GridEditorFactory.d.ts +33 -0
  22. package/dist/types/core/GridEditorFactory.d.ts.map +1 -0
  23. package/dist/types/core/GridFilterPopup.d.ts +43 -0
  24. package/dist/types/core/GridFilterPopup.d.ts.map +1 -0
  25. package/dist/types/core/GridHistory.d.ts +84 -0
  26. package/dist/types/core/GridHistory.d.ts.map +1 -0
  27. package/dist/types/core/GridRenderer.d.ts +73 -0
  28. package/dist/types/core/GridRenderer.d.ts.map +1 -0
  29. package/dist/types/core/GridSummary.d.ts +98 -0
  30. package/dist/types/core/GridSummary.d.ts.map +1 -0
  31. package/dist/types/core/GridTooltip.d.ts +43 -0
  32. package/dist/types/core/GridTooltip.d.ts.map +1 -0
  33. package/dist/types/core/GridValidator.d.ts +63 -0
  34. package/dist/types/core/GridValidator.d.ts.map +1 -0
  35. package/dist/types/core/VeloxGrid.d.ts +437 -0
  36. package/dist/types/core/VeloxGrid.d.ts.map +1 -0
  37. package/dist/types/core/index.d.ts +15 -0
  38. package/dist/types/core/index.d.ts.map +1 -0
  39. package/dist/types/index.d.ts +16 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types/react/VeloxGridReact.d.ts +40 -0
  42. package/dist/types/react/VeloxGridReact.d.ts.map +1 -0
  43. package/dist/types/react/index.d.ts +9 -0
  44. package/dist/types/react/index.d.ts.map +1 -0
  45. package/dist/types/react/types.d.ts +55 -0
  46. package/dist/types/react/types.d.ts.map +1 -0
  47. package/dist/types/react/useVeloxGrid.d.ts +54 -0
  48. package/dist/types/react/useVeloxGrid.d.ts.map +1 -0
  49. package/dist/types/types/index.d.ts +878 -0
  50. package/dist/types/types/index.d.ts.map +1 -0
  51. package/dist/types/utils/data.d.ts +41 -0
  52. package/dist/types/utils/data.d.ts.map +1 -0
  53. package/dist/types/utils/dom.d.ts +13 -0
  54. package/dist/types/utils/dom.d.ts.map +1 -0
  55. package/dist/types/utils/export.d.ts +60 -0
  56. package/dist/types/utils/export.d.ts.map +1 -0
  57. package/dist/types/utils/index.d.ts +4 -0
  58. package/dist/types/utils/index.d.ts.map +1 -0
  59. package/dist/types/vue/index.d.ts +9 -0
  60. package/dist/types/vue/index.d.ts.map +1 -0
  61. package/dist/types/vue/types.d.ts +68 -0
  62. package/dist/types/vue/types.d.ts.map +1 -0
  63. package/dist/types/vue/useVeloxGrid.d.ts +49 -0
  64. package/dist/types/vue/useVeloxGrid.d.ts.map +1 -0
  65. package/dist/velox-grid.css +1 -0
  66. package/dist/velox-grid.esm.js +3387 -0
  67. package/dist/velox-grid.esm.js.map +1 -0
  68. package/dist/velox-grid.iife.js +14 -0
  69. package/dist/velox-grid.iife.js.map +1 -0
  70. package/dist/velox-grid.js +14 -0
  71. package/dist/velox-grid.js.map +1 -0
  72. package/dist/vue/index.esm.js +3754 -0
  73. package/dist/vue/index.esm.js.map +1 -0
  74. package/dist/vue/index.js +7 -0
  75. package/dist/vue/index.js.map +1 -0
  76. package/dist/vue/types/index.d.ts +878 -0
  77. package/dist/vue/types/index.d.ts.map +1 -0
  78. package/dist/vue/vue/index.d.ts +9 -0
  79. package/dist/vue/vue/index.d.ts.map +1 -0
  80. package/dist/vue/vue/types.d.ts +65 -0
  81. package/dist/vue/vue/types.d.ts.map +1 -0
  82. package/dist/vue/vue/useVeloxGrid.d.ts +21 -0
  83. package/dist/vue/vue/useVeloxGrid.d.ts.map +1 -0
  84. package/package.json +120 -0
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("vue");function p(c,e,i){const s=document.createElement(c);return e&&(s.className=e),s}function w(c,...e){c.classList.add(...e)}function R(c,...e){c.classList.remove(...e)}function ut(c,e){let i=!1;return function(...s){i||(c.apply(this,s),i=!0,setTimeout(()=>i=!1,e))}}function ft(c="velox"){return`${c}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function H(c,e="text"){if(c==null)return"";switch(e){case"number":return typeof c=="number"?c.toLocaleString():String(c);case"boolean":return c?"Yes":"No";case"date":return c instanceof Date?c.toLocaleDateString():String(c);case"datetime":return c instanceof Date?c.toLocaleString():String(c);case"text":default:return String(c)}}function pt(c,e,i="text"){if(c==null)return e==null?0:-1;if(e==null)return 1;switch(i){case"number":return c-e;case"boolean":return c===e?0:c?1:-1;case"date":case"datetime":const s=c instanceof Date?c:new Date(c),o=e instanceof Date?e:new Date(e);return s.getTime()-o.getTime();case"text":default:return String(c).localeCompare(String(e))}}function O(c,e,i){return e.length?[...c].sort((s,o)=>{for(const{field:n,direction:t}of e){if(!t)continue;const l=i[n]||"text",a=pt(s[n],o[n],l);if(a!==0)return t==="asc"?a:-a}return 0}):c}function mt(c,e){const{operator:i,value:s,value2:o}=e;if(i==="isEmpty")return c==null||c==="";if(i==="isNotEmpty")return c!=null&&c!=="";const n=String(c??"").toLowerCase(),t=String(s??"").toLowerCase();switch(i){case"equals":return n===t;case"notEquals":return n!==t;case"contains":return n.includes(t);case"notContains":return!n.includes(t);case"startsWith":return n.startsWith(t);case"endsWith":return n.endsWith(t);case"greaterThan":return Number(c)>Number(s);case"lessThan":return Number(c)<Number(s);case"greaterThanOrEqual":return Number(c)>=Number(s);case"lessThanOrEqual":return Number(c)<=Number(s);case"between":const l=Number(c);return l>=Number(s)&&l<=Number(o);default:return!0}}function V(c,e){if(!e||!e.conditions.length)return c;const{conditions:i,logic:s}=e;return c.filter(o=>{const n=i.map(t=>mt(o[t.field],t));return s==="and"?n.every(Boolean):n.some(Boolean)})}function z(c){const{data:e,displayData:i,columns:s,selectedRows:o,options:n}=c,t=n.columns?s.filter(r=>n.columns.includes(r.field)&&r.visible!==!1):s.filter(r=>r.visible!==!1);let l;if(n.selectedOnly&&o.length>0){const r=n.filteredOnly?i:e;l=o.map(h=>r[h]).filter(Boolean)}else n.filteredOnly?l=i:l=e;const a=[];if(n.includeHeader!==!1){const r=t.map(h=>$(h.header));a.push(r.join(","))}return l.forEach(r=>{const h=t.map(g=>{const d=r[g.field];return $(xt(d,g.type))});a.push(h.join(","))}),a.join(`\r
2
+ `)}function $(c){if(c==null)return"";const e=String(c);return e.includes(",")||e.includes('"')||e.includes(`
3
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function _(c){const{data:e,displayData:i,columns:s,selectedRows:o,options:n}=c,t=n.columns?s.filter(r=>n.columns.includes(r.field)&&r.visible!==!1):s.filter(r=>r.visible!==!1);let l;if(n.selectedOnly&&o.length>0){const r=n.filteredOnly?i:e;l=o.map(h=>r[h]).filter(Boolean)}else n.filteredOnly?l=i:l=e;const a=l.map(r=>{const h={};return t.forEach(g=>{h[g.field]=r[g.field]}),h});return JSON.stringify(a,null,2)}function W(){return typeof window.XLSX<"u"}function K(){const c=window.XLSX;if(!c)throw new Error('SheetJS (xlsx) library is not loaded. Please include it via CDN: <script src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"><\/script>');return c}function gt(c){const e=K(),{data:i,displayData:s,columns:o,selectedRows:n,options:t}=c,l=t.columns?o.filter(x=>t.columns.includes(x.field)&&x.visible!==!1):o.filter(x=>x.visible!==!1);let a;if(t.selectedOnly&&n.length>0){const x=t.filteredOnly?s:i;a=n.map(b=>x[b]).filter(Boolean)}else t.filteredOnly?a=s:a=i;const r=[];t.includeHeader!==!1&&r.push(l.map(x=>x.header)),a.forEach(x=>{const b=l.map(y=>{const S=x[y.field];return Ct(S,y.type)});r.push(b)});const h=e.utils.aoa_to_sheet(r),g=l.map(x=>({wch:Math.max(x.header.length,...a.slice(0,100).map(b=>{const y=b[x.field];return String(y??"").length}))+2}));h["!cols"]=g;const d=e.utils.book_new(),f=t.sheetName||"Sheet1";e.utils.book_append_sheet(d,h,f);const C=(t.filename||"export")+".xlsx";e.writeFile(d,C)}function Ct(c,e){if(c==null)return"";switch(e){case"number":return typeof c=="number"?c:parseFloat(String(c))||0;case"boolean":return!!c;case"date":case"datetime":if(c instanceof Date)return c;if(typeof c=="string"||typeof c=="number"){const i=new Date(c);return isNaN(i.getTime())?String(c):i}return String(c);default:return String(c)}}function xt(c,e){if(c==null)return"";switch(e){case"date":return c instanceof Date?c.toISOString().split("T")[0]:String(c);case"datetime":return c instanceof Date?c.toISOString():String(c);default:return String(c)}}function yt(c,e=!0){var s;const i={data:[],headers:[],errors:[]};try{const o=vt(c);if(o.length===0)return i.errors.push("CSV file is empty"),i;let n=0;if(e)i.headers=o[0],n=1;else{const t=((s=o[0])==null?void 0:s.length)||0;i.headers=Array.from({length:t},(l,a)=>`Column${a+1}`)}for(let t=n;t<o.length;t++){const l=o[t],a={};i.headers.forEach((r,h)=>{a[r]=l[h]??""}),i.data.push(a)}}catch(o){i.errors.push(`CSV parsing error: ${o instanceof Error?o.message:"Unknown error"}`)}return i}function vt(c){const e=[];let i=[],s="",o=!1;for(let n=0;n<c.length;n++){const t=c[n],l=c[n+1];if(o)t==='"'?l==='"'?(s+='"',n++):o=!1:s+=t;else if(t==='"')o=!0;else if(t===",")i.push(s),s="";else{if(t==="\r")continue;t===`
4
+ `?(i.push(s),i.some(a=>a.trim()!=="")&&e.push(i),i=[],s=""):s+=t}}return(s!==""||i.length>0)&&(i.push(s),i.some(n=>n.trim()!=="")&&e.push(i)),e}function wt(c,e=0){return new Promise(i=>{const s={data:[],headers:[],errors:[]};if(!W()){s.errors.push('SheetJS (xlsx) library is not loaded. Please include it via CDN: <script src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"><\/script>'),i(s);return}const o=K(),n=new FileReader;n.onload=t=>{var l;try{const a=(l=t.target)==null?void 0:l.result,r=o.read(a,{type:"array"}),h=r.SheetNames;if(e>=h.length){s.errors.push(`Sheet index ${e} not found. Available sheets: ${h.join(", ")}`),i(s);return}const g=h[e],d=r.Sheets[g],f=o.utils.sheet_to_json(d,{header:1});if(f.length===0){s.errors.push("Excel sheet is empty"),i(s);return}s.headers=f[0].map(C=>String(C??""));for(let C=1;C<f.length;C++){const x={},b=f[C];s.headers.forEach((y,S)=>{const E=b[S];x[y]=E??""}),Object.values(x).some(y=>y!=="")&&s.data.push(x)}i(s)}catch(a){s.errors.push(`Excel parsing error: ${a instanceof Error?a.message:"Unknown error"}`),i(s)}},n.onerror=()=>{s.errors.push("Failed to read file"),i(s)},n.readAsArrayBuffer(c)})}function q(c,e,i="text/plain"){const s=c instanceof Blob?c:new Blob([c],{type:i}),o=URL.createObjectURL(s),n=document.createElement("a");n.href=o,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}function bt(c){const e=z(c),i=(c.options.filename||"export")+".csv";q(e,i,"text/csv;charset=utf-8")}function St(c){const e=_(c),i=(c.options.filename||"export")+".json";q(e,i,"application/json")}const Et={enabled:!0,maxSize:50};class kt{constructor(e={}){this.undoStack=[],this.redoStack=[],this.options={...Et,...e}}isEnabled(){return this.options.enabled}setEnabled(e){this.options.enabled=e}setMaxSize(e){this.options.maxSize=e,this.trimStack()}push(e){this.options.enabled&&(this.undoStack.push(e),this.trimStack(),this.redoStack=[])}pushCellEdit(e,i,s,o){this.push({type:"cell_edit",timestamp:Date.now(),data:{rowIndex:e,field:i,oldValue:s,newValue:o}})}pushBulkEdit(e,i){i.length!==0&&this.push({type:e,timestamp:Date.now(),data:{changes:i}})}pushRowAdd(e,i){this.push({type:"row_add",timestamp:Date.now(),data:{row:{...e},index:i}})}pushRowRemove(e,i){this.push({type:"row_remove",timestamp:Date.now(),data:{row:{...e},index:i}})}popUndo(){if(!this.options.enabled||this.undoStack.length===0)return null;const e=this.undoStack.pop();return this.redoStack.push(e),e}popRedo(){if(!this.options.enabled||this.redoStack.length===0)return null;const e=this.redoStack.pop();return this.undoStack.push(e),e}canUndo(){return this.options.enabled&&this.undoStack.length>0}canRedo(){return this.options.enabled&&this.redoStack.length>0}getUndoCount(){return this.undoStack.length}getRedoCount(){return this.redoStack.length}clear(){this.undoStack=[],this.redoStack=[]}trimStack(){for(;this.undoStack.length>this.options.maxSize;)this.undoStack.shift()}}class Rt{static validate(e,i,s){const o=[];for(const n of i){const t=this.validateRule(e,n,s);t&&o.push({field:"",message:t})}return{valid:o.length===0,errors:o}}static validateRule(e,i,s){switch(i.type){case"required":return this.validateRequired(e)?null:i.message;case"min":return this.validateMin(e,i.value)?null:i.message;case"max":return this.validateMax(e,i.value)?null:i.message;case"minLength":return this.validateMinLength(e,i.value)?null:i.message;case"maxLength":return this.validateMaxLength(e,i.value)?null:i.message;case"pattern":return this.validatePattern(e,i.value)?null:i.message;case"custom":if(i.validator){const o=i.validator(e,s||{});return typeof o=="boolean"?o?null:i.message:o||null}return null;default:return null}}static validateRequired(e){return!(e==null||typeof e=="string"&&e.trim()==="")}static validateMin(e,i){if(e==null)return!0;const s=typeof e=="number"?e:parseFloat(String(e));return!isNaN(s)&&s>=i}static validateMax(e,i){if(e==null)return!0;const s=typeof e=="number"?e:parseFloat(String(e));return!isNaN(s)&&s<=i}static validateMinLength(e,i){return e==null?!0:String(e).length>=i}static validateMaxLength(e,i){return e==null?!0:String(e).length<=i}static validatePattern(e,i){return e==null?!0:(typeof i=="string"?new RegExp(i):i).test(String(e))}static validateRow(e,i){const s=[];for(const o of i)if(o.validation&&o.validation.length>0){const n=e[o.field],t=this.validate(n,o.validation,e);if(!t.valid)for(const l of t.errors)s.push({field:o.field,message:l.message})}return{valid:s.length===0,errors:s}}static validateAll(e,i){return e.map(s=>this.validateRow(s,i))}}class Dt{static createEditor(e,i,s,o,n){const{type:t}=i;switch(t){case"text":case"number":return this.createTextEditor(e,i,s,o,n);case"select":return this.createSelectEditor(e,i,s,o,n);case"date":return this.createDateEditor(e,i,s,o,n);case"checkbox":return this.createCheckboxEditor(e,i,s,o,n);case"custom":return this.createCustomEditor(e,i,s,o,n);default:return this.createTextEditor(e,i,s,o,n)}}static createTextEditor(e,i,s,o,n){const t=document.createElement("input");return t.className="velox-edit-input",t.type=i.type==="number"?"number":"text",t.value=e!=null?String(e):"",i.placeholder&&(t.placeholder=i.placeholder),i.type==="number"&&(i.min!==void 0&&(t.min=String(i.min)),i.max!==void 0&&(t.max=String(i.max)),i.step!==void 0&&(t.step=String(i.step))),t.addEventListener("blur",()=>{const l=i.type==="number"?parseFloat(t.value):t.value;s(l)}),t.addEventListener("keydown",l=>{if(l.key==="Enter"){l.preventDefault(),l.stopPropagation();const a=i.type==="number"?parseFloat(t.value):t.value;s(a),n&&n(l.shiftKey?"up":"down")}else if(l.key==="Tab"){l.preventDefault(),l.stopPropagation();const a=i.type==="number"?parseFloat(t.value):t.value;s(a),n&&n(l.shiftKey?"left":"right")}else l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),o())}),t}static createSelectEditor(e,i,s,o,n){const t=document.createElement("select");return t.className="velox-edit-select",i.options&&i.options.length>0&&i.options.forEach(l=>{const a=document.createElement("option");a.value=String(l.value??""),a.textContent=l.label,l.value===e&&(a.selected=!0),t.appendChild(a)}),t.addEventListener("change",()=>{console.log("๐Ÿ“ฆ Select change event",t.value),s(t.value)}),t.addEventListener("keydown",l=>{l.key==="Enter"?(l.preventDefault(),l.stopPropagation(),s(t.value),n&&n(l.shiftKey?"up":"down")):l.key==="Tab"?(l.preventDefault(),l.stopPropagation(),s(t.value),n&&n(l.shiftKey?"left":"right")):l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),o())}),t}static createDateEditor(e,i,s,o,n){const t=document.createElement("input");if(t.className="velox-edit-input velox-edit-date",t.type="date",e instanceof Date)t.value=e.toISOString().split("T")[0];else if(typeof e=="string"&&e){const l=new Date(e);isNaN(l.getTime())||(t.value=l.toISOString().split("T")[0])}return t.addEventListener("blur",()=>{s(t.value?new Date(t.value):null)}),t.addEventListener("keydown",l=>{l.key==="Enter"?(l.preventDefault(),l.stopPropagation(),s(t.value?new Date(t.value):null),n&&n(l.shiftKey?"up":"down")):l.key==="Tab"?(l.preventDefault(),l.stopPropagation(),s(t.value?new Date(t.value):null),n&&n(l.shiftKey?"left":"right")):l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),o())}),t}static createCheckboxEditor(e,i,s,o,n){const t=document.createElement("div");t.className="velox-edit-checkbox-container";const l=document.createElement("input");return l.className="velox-edit-checkbox",l.type="checkbox",l.checked=!!e,t.appendChild(l),l.addEventListener("change",()=>{console.log("๐Ÿ“ฆ Checkbox change event",l.checked),s(l.checked)}),l.addEventListener("keydown",a=>{a.key==="Enter"||a.key===" "?(a.preventDefault(),a.stopPropagation(),l.checked=!l.checked,s(l.checked),a.key==="Enter"&&n&&n(a.shiftKey?"up":"down")):a.key==="Tab"?(a.preventDefault(),a.stopPropagation(),s(l.checked),n&&n(a.shiftKey?"left":"right")):a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),o())}),t}static createCustomEditor(e,i,s,o,n){const t=document.createElement("div");if(t.className="velox-edit-custom",i.renderer)i.renderer(t,e,s,o);else return this.createTextEditor(e,{type:"text"},s,o,n);return t}}class Lt{constructor(e){this.container=e,this.tooltip=null,this.currentCell=null,this.hideTimeout=null,this.HIDE_DELAY=100,this.createTooltipElement()}createTooltipElement(){this.tooltip=document.createElement("div"),this.tooltip.className="velox-tooltip",this.tooltip.style.display="none",this.tooltip.style.position="absolute",this.tooltip.style.pointerEvents="none",this.container.appendChild(this.tooltip)}show(e,i,s,o){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.currentCell=e;let n=null;if(o.tooltip===!0?n=this.getAutoTooltipContent(e,i):typeof o.tooltip=="function"&&(n=o.tooltip(i,s)),!n||!this.tooltip){this.hide();return}this.tooltip.textContent=n,this.tooltip.style.display="block",this.positionTooltip(e)}getAutoTooltipContent(e,i){const s=e.querySelector(".velox-cell-content");return s&&(s.scrollWidth>s.clientWidth||s.scrollHeight>s.clientHeight)?String(i??""):null}positionTooltip(e){if(!this.tooltip)return;const i=e.getBoundingClientRect(),s=this.container.getBoundingClientRect(),o=this.tooltip.getBoundingClientRect();let n=i.bottom-s.top+5,t=i.left-s.left;const l=window.innerWidth,a=window.innerHeight;i.left+o.width>l&&(t=i.right-s.left-o.width),i.bottom+o.height+5>a&&(n=i.top-s.top-o.height-5),this.tooltip.style.top=`${n}px`,this.tooltip.style.left=`${t}px`}hide(){this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=window.setTimeout(()=>{this.tooltip&&(this.tooltip.style.display="none",this.tooltip.textContent=""),this.currentCell=null,this.hideTimeout=null},this.HIDE_DELAY)}update(){this.currentCell&&this.tooltip&&this.tooltip.style.display!=="none"&&this.positionTooltip(this.currentCell)}destroy(){this.hideTimeout&&clearTimeout(this.hideTimeout),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.currentCell=null}}class Tt{constructor(e){this.ctx=e}render(){const e=this.ctx.getState();console.log("๐ŸŽจ GridRenderer.render() called",{editing:e.edit.editing}),this.renderHeader(),this.renderBody(),this.renderFooter(),this.updateLoadingState(),console.log("๐ŸŽจ GridRenderer.render() completed",{editing:e.edit.editing})}renderHeader(){const e=this.ctx;if(e.fixedLeftHeader){e.fixedLeftHeader.innerHTML="";const s=p("div","velox-header-row");e.getFixedLeftColumns().forEach(o=>{if(o.field==="__drag"){const n=p("div","velox-row-drag-handle");n.style.visibility="hidden",s.appendChild(n)}else if(o.field==="__checkbox")s.appendChild(this.createHeaderCheckbarCell());else if(o.field==="__rownum"){const n=p("div","velox-header-cell velox-rownumber-cell");n.textContent="#",s.appendChild(n)}else s.appendChild(this.createHeaderCell(o))}),e.fixedLeftHeader.appendChild(s)}const i=p("div","velox-header-row");if(e.getScrollableColumns().forEach(s=>{if(s.field==="__drag"){const o=p("div","velox-row-drag-handle");o.style.visibility="hidden",i.appendChild(o)}else if(s.field==="__checkbox")i.appendChild(this.createHeaderCheckbarCell());else if(s.field==="__rownum"){const o=p("div","velox-header-cell velox-rownumber-cell");o.textContent="#",i.appendChild(o)}else i.appendChild(this.createHeaderCell(s))}),e.headerElement.innerHTML="",e.headerElement.appendChild(i),e.fixedRightHeader){e.fixedRightHeader.innerHTML="";const s=p("div","velox-header-row");e.getFixedRightColumns().forEach(o=>s.appendChild(this.createHeaderCell(o))),e.fixedRightHeader.appendChild(s),this.updateFixedRightWidth()}}createHeaderCheckbarCell(){const e=this.ctx,i=e.getOptions(),s=e.getState(),o=p("div","velox-header-cell velox-checkbox-cell"),n=i.checkBar;if(n.showAll&&!n.exclusive){const t=p("input","velox-checkbox");t.type="checkbox";const l=s.checkBar.checkableRows.size,a=s.checkBar.checkedRows.size,r=l>0&&a===l,h=a>0&&!r;t.checked=r,t.indeterminate=h,t.addEventListener("change",()=>e.checkAll(t.checked)),o.appendChild(t)}else if(n.exclusive){const t=p("span","velox-checkbox-label");t.textContent="์„ ํƒ",o.appendChild(t)}return o}createHeaderCell(e){var g;const i=this.ctx,s=i.getOptions(),o=i.getState(),n=p("div","velox-header-cell");n.dataset.field=e.field;const t=e.headerAlign||e.align||"left";if(w(n,`velox-header-cell--align-${t}`),e.width?(n.style.width=`${e.width}px`,n.style.minWidth=`${e.minWidth||e.width}px`,n.style.maxWidth=`${e.width}px`,n.style.flexShrink="0"):(n.style.flex="1",n.style.minWidth=`${e.minWidth||100}px`),e.headerClass&&w(n,e.headerClass),s.sortable&&e.sortable!==!1){w(n,"velox-header-cell--sortable");const d=o.sort.find(f=>f.field===e.field);d!=null&&d.direction&&w(n,"velox-header-cell--sorted")}const l=p("div","velox-header-content"),a=p("span","velox-column-drag-handle");a.innerHTML="โ‹ฎโ‹ฎ",a.title="๋“œ๋ž˜๊ทธํ•˜์—ฌ ์ปฌ๋Ÿผ ์ˆœ์„œ ๋ณ€๊ฒฝ",a.addEventListener("mousedown",d=>i.startColumnDrag(d,e)),l.appendChild(a);const r=p("span","velox-header-text");if(r.textContent=e.header,l.appendChild(r),n.appendChild(l),s.sortable&&e.sortable!==!1){const d=p("button","velox-sort-btn"),f=o.sort.find(C=>C.field===e.field);(f==null?void 0:f.direction)==="asc"?(w(d,"velox-sort-btn--asc"),d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h5.25m5.25-.75L17.25 9m0 0L21 12.75M17.25 9v12" /></svg>'):((f==null?void 0:f.direction)==="desc"&&w(d,"velox-sort-btn--desc"),d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0-3.75-3.75M17.25 21 21 17.25" /></svg>'),f!=null&&f.direction&&w(d,"velox-sort-btn--active"),d.title="์ •๋ ฌ",d.addEventListener("click",C=>{C.stopPropagation(),i.handleSort(e.field)}),n.appendChild(d)}if(s.filterable&&e.filterable!==!1){const d=p("button","velox-filter-btn");d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 0 1-.659 1.591l-5.432 5.432a2.25 2.25 0 0 0-.659 1.591v2.927a2.25 2.25 0 0 1-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 0 0-.659-1.591L3.659 7.409A2.25 2.25 0 0 1 3 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0 1 12 3Z" /></svg>',((g=o.filter)==null?void 0:g.conditions.some(C=>C.field===e.field))&&w(d,"velox-filter-btn--active"),d.addEventListener("click",C=>{C.stopPropagation(),i.showFilterPopup(e,d)}),n.appendChild(d)}const h=p("button","velox-column-menu-btn");if(h.innerHTML="โ‹ฏ",h.title="์ปฌ๋Ÿผ ๋ฉ”๋‰ด",h.addEventListener("click",d=>{d.stopPropagation(),i.showColumnMenu(e,h)}),n.appendChild(h),s.resizable&&e.resizable!==!1){const d=p("div","velox-resize-handle");d.addEventListener("mousedown",f=>i.startResize(f,e)),n.appendChild(d)}return n}renderBody(){const e=this.ctx,i=e.getOptions(),s=e.getVisibleRows(),o=e.getVirtualState(),n=i.rowHeight||40;if(e.fixedLeftBodyInner&&(e.fixedLeftBodyInner.innerHTML="",i.virtualScroll?(e.fixedLeftBodyInner.style.height=`${o.totalHeight}px`,e.fixedLeftBodyInner.style.position="relative"):(e.fixedLeftBodyInner.style.height="",e.fixedLeftBodyInner.style.position=""),s.forEach(({data:t,index:l})=>{const a=this.createRowBase(t,l,"fixedLeft");i.virtualScroll&&(a.style.position="absolute",a.style.top=`${l*n}px`,a.style.left="0",a.style.right="0"),e.fixedLeftBodyInner.appendChild(a)})),e.bodyInner.innerHTML="",i.virtualScroll?(e.bodyInner.style.height=`${o.totalHeight}px`,e.bodyInner.style.position="relative"):(e.bodyInner.style.height="",e.bodyInner.style.position=""),s.length===0){const t=p("div","velox-empty");t.textContent=i.emptyMessage||"๋ฐ์ดํ„ฐ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",e.bodyInner.appendChild(t);return}s.forEach(({data:t,index:l})=>{const a=this.createRowBase(t,l,"scrollable");i.virtualScroll&&(a.style.position="absolute",a.style.top=`${l*n}px`,a.style.left="0",a.style.right="0"),e.bodyInner.appendChild(a)}),e.fixedRightBodyInner&&(e.fixedRightBodyInner.innerHTML="",i.virtualScroll?(e.fixedRightBodyInner.style.height=`${o.totalHeight}px`,e.fixedRightBodyInner.style.position="relative"):(e.fixedRightBodyInner.style.height="",e.fixedRightBodyInner.style.position=""),s.forEach(({data:t,index:l})=>{const a=this.createRowBase(t,l,"fixedRight");i.virtualScroll&&(a.style.position="absolute",a.style.top=`${l*n}px`,a.style.left="0",a.style.right="0"),e.fixedRightBodyInner.appendChild(a)}),this.updateFixedRightWidth())}updateFixedRightWidth(){const e=this.ctx;if(!e.fixedRightContainer)return;const i=e.getFixedRightColumns();if(i.length===0)return;let s=0;i.forEach(n=>{s+=n.width||n.minWidth||100});const o=this.getScrollbarWidth(e.fixedRightBody);e.fixedRightContainer.style.width=`${s+o}px`,e.fixedRightContainer.style.minWidth=`${s+o}px`,e.fixedRightContainer.style.maxWidth=`${s+o}px`,e.fixedRightHeader&&o>0&&(e.fixedRightHeader.style.paddingRight=`${o}px`),e.fixedRightFooter&&o>0&&(e.fixedRightFooter.style.paddingRight=`${o}px`)}getScrollbarWidth(e){return e?e.offsetWidth-e.clientWidth:0}createRowBase(e,i,s){const o=this.ctx,n=o.getOptions(),t=o.getState(),l=p("div","velox-row");return l.dataset.rowIndex=String(i),i%2===1&&w(l,"velox-row--alt"),n.selectionStyle==="row"&&t.selection.selectedRows.has(i)&&w(l,"velox-row--selected"),s==="fixedLeft"&&t.checkBar.checkedRows.has(i)&&w(l,"velox-row--checked"),l.addEventListener("click",a=>{const r=a.target;r.classList.contains("velox-checkbox")||r.classList.contains("velox-row-drag-handle")||o.handleRowClick(i,a)}),s!=="fixedLeft"&&l.addEventListener("dblclick",a=>o.handleRowDoubleClick(i,a)),s==="fixedLeft"?o.getFixedLeftColumns().forEach(a=>{if(a.field==="__drag"){const r=p("div","velox-row-drag-handle");r.innerHTML="โ˜ฐ",r.title="๋“œ๋ž˜๊ทธํ•˜์—ฌ ํ–‰ ์ˆœ์„œ ๋ณ€๊ฒฝ",r.addEventListener("mousedown",h=>o.startRowDrag(h,i,l)),l.appendChild(r)}else if(a.field==="__checkbox")l.appendChild(this.createCheckbarCell(i));else if(a.field==="__rownum"){const r=p("div","velox-cell velox-rownumber-cell");r.textContent=String(i+1),l.appendChild(r)}else l.appendChild(this.createCell(e,i,a))}):s==="scrollable"?o.getScrollableColumns().forEach(a=>{if(a.field==="__drag"){const r=p("div","velox-row-drag-handle");r.innerHTML="โ˜ฐ",r.title="๋“œ๋ž˜๊ทธํ•˜์—ฌ ํ–‰ ์ˆœ์„œ ๋ณ€๊ฒฝ",r.addEventListener("mousedown",h=>o.startRowDrag(h,i,l)),l.appendChild(r)}else if(a.field==="__checkbox")l.appendChild(this.createCheckbarCell(i));else if(a.field==="__rownum"){const r=p("div","velox-cell velox-rownumber-cell");r.textContent=String(i+1),l.appendChild(r)}else l.appendChild(this.createCell(e,i,a))}):s==="fixedRight"&&o.getFixedRightColumns().forEach(a=>l.appendChild(this.createCell(e,i,a))),l}createCheckbarCell(e){const i=this.ctx,s=i.getOptions(),o=i.getState(),n=p("div","velox-cell velox-checkbox-cell"),t=s.checkBar,l=o.checkBar.checkableRows.has(e),a=o.checkBar.checkedRows.has(e),r=p("input","velox-checkbox");return r.type=t.exclusive?"radio":"checkbox",r.name=t.exclusive?`${i.getGridId()}-check`:"",r.checked=a,r.disabled=!l,l||w(n,"velox-checkbox-cell--disabled"),r.addEventListener("click",h=>{console.log("โœ… Checkbox clicked",{rowIndex:e,checked:r.checked}),h.stopPropagation()}),r.addEventListener("change",()=>{if(console.log("๐Ÿ”„ Checkbox changed",{rowIndex:e,checked:r.checked}),t.exclusive){const h={...i.getState().edit};o.checkBar.checkedRows.clear(),r.checked&&o.checkBar.checkedRows.add(e),this.render(),h.editing&&h.rowIndex!==null&&h.field!==null&&(i.getState().edit=h,i.renderEditCell(h.rowIndex,h.field,h.originalValue)),i.emitEvent("onCheckChange",e,r.checked)}else i.checkItem(e,r.checked)}),n.appendChild(r),n}createCell(e,i,s){const o=this.ctx,n=o.getOptions(),t=o.getState(),l=p("div","velox-cell");l.dataset.field=s.field,l.dataset.rowIndex=String(i);const a=s.align||"left";if(w(l,`velox-cell--align-${a}`),s.width?(l.style.width=`${s.width}px`,l.style.minWidth=`${s.minWidth||s.width}px`,l.style.maxWidth=`${s.width}px`,l.style.flexShrink="0"):(l.style.flex="1",l.style.minWidth=`${s.minWidth||100}px`),s.cellClass){const f=typeof s.cellClass=="function"?s.cellClass(e[s.field],e):s.cellClass;f&&w(l,f)}const r=`${i}:${s.field}`;t.selection.selectedCells.has(r)&&w(l,"velox-cell--selected");const h=t.selection.focusedCell;h&&h.rowIndex===i&&h.field===s.field&&w(l,"velox-cell--focused"),n.editable&&s.editable!==!1&&(w(l,"velox-cell--editable"),l.addEventListener("dblclick",f=>{if(l.classList.contains("velox-cell--editing")){console.log("๐Ÿšซ Double click ignored - already editing"),f.stopPropagation(),f.preventDefault();return}console.log("๐Ÿ–ฑ๏ธ๐Ÿ–ฑ๏ธ Double click detected",{rowIndex:i,field:s.field}),f.stopPropagation(),o.startEdit(i,s.field)}));const g=e[s.field],d=p("span","velox-cell-content");return s.renderer?d.innerHTML=s.renderer(g,e,s):s.formatter?d.textContent=s.formatter(g,e,s):d.textContent=H(g,s.type),l.appendChild(d),l.addEventListener("click",f=>{if(l.classList.contains("velox-cell--editing")){const C=f.target;if(C.tagName==="INPUT"||C.tagName==="SELECT"||C.tagName==="BUTTON"||C.tagName==="TEXTAREA"){console.log("โœ… Interactive element click allowed during edit"),f.stopPropagation();return}console.log("๐Ÿšซ Cell click ignored - editing mode (cell background)"),f.stopPropagation(),f.preventDefault();return}o.handleCellClick(i,s.field,g,f)}),l.addEventListener("mousedown",f=>{if(l.classList.contains("velox-cell--editing")){console.log("๐Ÿ”’ Cell mousedown - editing mode (ignored in renderer)");return}n.selectionStyle==="block"&&f.button===0&&o.startBlockSelection(i,s.field)}),l.addEventListener("mouseenter",()=>{o.isBlockSelecting()&&o.updateBlockSelection(i,s.field)}),s.tooltip&&(w(l,"velox-cell--has-tooltip"),l.addEventListener("mouseenter",()=>o.showTooltip(l,g,e,s)),l.addEventListener("mouseleave",()=>o.hideTooltip())),l}renderFooter(){var s,o;const e=this.ctx,i=e.getOptions();if((s=i.footerSummary)!=null&&s.visible){if(e.fixedLeftFooter){e.fixedLeftFooter.innerHTML="";const n=p("div","velox-footer-row");if(i.rowDraggable){const t=p("div","velox-row-drag-handle");t.style.visibility="hidden",n.appendChild(t)}if((o=i.checkBar)!=null&&o.visible){const t=p("div","velox-footer-cell velox-checkbox-cell");n.appendChild(t)}e.getFixedLeftColumns().forEach(t=>n.appendChild(this.createFooterCell(t))),e.fixedLeftFooter.appendChild(n)}if(e.footerElement){e.footerElement.innerHTML="";const n=p("div","velox-footer-row");if(i.showRowNumbers){const t=p("div","velox-footer-cell velox-rownumber-cell");n.appendChild(t)}e.getScrollableColumns().forEach(t=>n.appendChild(this.createFooterCell(t))),e.footerElement.appendChild(n)}if(e.fixedRightFooter){e.fixedRightFooter.innerHTML="";const n=p("div","velox-footer-row");e.getFixedRightColumns().forEach(t=>n.appendChild(this.createFooterCell(t))),e.fixedRightFooter.appendChild(n)}}}createFooterCell(e){var l,a;const i=this.ctx,s=i.getOptions(),o=p("div","velox-footer-cell");o.dataset.field=e.field;const n=e.align||"left";w(o,`velox-footer-cell--align-${n}`),e.width?(o.style.width=`${e.width}px`,o.style.minWidth=`${e.minWidth||e.width}px`):(o.style.flex="1",o.style.minWidth=`${e.minWidth||100}px`);const t=((a=(l=s.footerSummary)==null?void 0:l.columns)==null?void 0:a[e.field])||e.summary;if(t){const r=i.getSummaryValue(e.field),h=p("span","velox-footer-content");if(t.label){const d=p("span","velox-footer-label");d.textContent=t.label,h.appendChild(d)}const g=p("span","velox-footer-value");t.formatter?g.textContent=t.formatter(r):g.textContent=H(r,e.type),h.appendChild(g),o.appendChild(h),t.className&&w(o,t.className)}return o}updateLoadingState(){const e=this.ctx,i=e.getOptions();e.loadingOverlay&&(e.loadingOverlay.style.display=i.loading?"flex":"none")}updateRowValidationState(e){const i=this.ctx,s=i.getState(),o=i.rootElement.querySelector(`[data-row-index="${e}"]`);if(!o)return;o.querySelectorAll(".velox-cell").forEach(t=>{const a=t.dataset.field;if(!a)return;const r=s.columns.find(h=>h.field===a);r!=null&&r.validation})}}class Bt{constructor(e){this.ctx=e,this.filterPopup=null,this.boundHandleOutsideClick=this.handleOutsideClick.bind(this)}showFilterPopup(e,i){var b;this.closeFilterPopup();const s=this.ctx,o=s.getState(),n=p("div","velox-filter-popup"),t=i.getBoundingClientRect(),l=s.rootElement.getBoundingClientRect();n.style.top=`${t.bottom-l.top+5}px`,n.style.left=`${Math.max(0,t.left-l.left-100)}px`;const a=[...new Set(o.data.map(y=>y[e.field]))].filter(y=>y!=null).sort(),r=(b=o.filter)==null?void 0:b.conditions.find(y=>y.field===e.field),h=p("select","velox-filter-operator");[{value:"contains",label:"ํฌํ•จ"},{value:"equals",label:"๊ฐ™์Œ"},{value:"notEquals",label:"๊ฐ™์ง€ ์•Š์Œ"},{value:"startsWith",label:"์‹œ์ž‘"},{value:"endsWith",label:"๋"},{value:"greaterThan",label:">"},{value:"lessThan",label:"<"},{value:"greaterThanOrEqual",label:">="},{value:"lessThanOrEqual",label:"<="},{value:"isEmpty",label:"๋น„์–ด์žˆ์Œ"},{value:"isNotEmpty",label:"๋น„์–ด์žˆ์ง€ ์•Š์Œ"}].forEach(y=>{const S=p("option");S.value=y.value,S.textContent=y.label,(r==null?void 0:r.operator)===y.value&&(S.selected=!0),h.appendChild(S)}),n.appendChild(h);const d=p("input","velox-filter-input");if(d.type=e.type==="number"?"number":"text",d.placeholder="๊ฐ’ ์ž…๋ ฅ...",(r==null?void 0:r.value)!==void 0&&(d.value=String(r.value)),n.appendChild(d),a.length>0&&a.length<=15){const y=p("div","velox-filter-list"),S=p("div","velox-filter-list-label");S.textContent="๋น ๋ฅธ ์„ ํƒ:",y.appendChild(S),a.slice(0,10).forEach(E=>{const D=p("div","velox-filter-list-item");D.textContent=H(E,e.type),D.addEventListener("click",()=>{this.applyColumnFilter(e.field,"equals",E),this.closeFilterPopup()}),y.appendChild(D)}),n.appendChild(y)}const f=p("div","velox-filter-buttons"),C=p("button","velox-filter-apply");C.textContent="์ ์šฉ",C.addEventListener("click",()=>{const y=h.value,S=e.type==="number"?parseFloat(d.value):d.value;this.applyColumnFilter(e.field,y,S),this.closeFilterPopup()}),f.appendChild(C);const x=p("button","velox-filter-clear");x.textContent="ํ•ด์ œ",x.addEventListener("click",()=>{this.removeColumnFilter(e.field),this.closeFilterPopup()}),f.appendChild(x),n.appendChild(f),this.filterPopup=n,s.rootElement.appendChild(n),setTimeout(()=>document.addEventListener("click",this.boundHandleOutsideClick),0),d.focus()}closeFilterPopup(){this.filterPopup&&(this.filterPopup.remove(),this.filterPopup=null,document.removeEventListener("click",this.boundHandleOutsideClick))}handleOutsideClick(e){this.filterPopup&&!this.filterPopup.contains(e.target)&&this.closeFilterPopup()}applyColumnFilter(e,i,s){const o=this.ctx,n=o.getState(),t={field:e,operator:i,value:s};if(n.filter){const l=n.filter.conditions.filter(a=>a.field!==e);l.push(t),n.filter={conditions:l,logic:"and"}}else n.filter={conditions:[t],logic:"and"};o.clearSelectionState(),o.applyDataTransformations(),o.render(),o.emitEvent("onFilter",n.filter)}removeColumnFilter(e){const i=this.ctx,s=i.getState();if(s.filter){const o=s.filter.conditions.filter(n=>n.field!==e);s.filter=o.length===0?null:{conditions:o,logic:"and"},i.clearSelectionState(),i.applyDataTransformations(),i.render(),s.filter&&i.emitEvent("onFilter",s.filter)}}isOpen(){return this.filterPopup!==null}}class Mt{constructor(e){this.ctx=e,this.columnMenuPopup=null,this.boundHandleOutsideClick=this.handleOutsideClick.bind(this)}showColumnMenu(e,i){this.closeColumnMenu();const s=this.ctx,o=s.getOptions(),n=p("div","velox-column-menu"),t=i.getBoundingClientRect(),l=s.rootElement.getBoundingClientRect();n.style.top=`${t.bottom-l.top+5}px`,n.style.left=`${t.left-l.left}px`;const a={field:e.field,column:e,selectedRows:s.getSelectedRows(),selectedCells:s.getSelectedCells(),grid:s},r=o.contextMenu,h=(r==null?void 0:r.showDefaultItems)!==!1,g=(r==null?void 0:r.headerItems)||[],d=[{id:"sort-asc",label:"์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ",icon:"โ†‘",action:()=>s.sort(e.field,"asc")},{id:"sort-desc",label:"๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ",icon:"โ†“",action:()=>s.sort(e.field,"desc")},{id:"sort-clear",label:"์ •๋ ฌ ํ•ด์ œ",icon:"โœ•",action:()=>s.clearSort()},{type:"separator"},{id:"hide",label:"์ปฌ๋Ÿผ ์ˆจ๊ธฐ๊ธฐ",icon:"๐Ÿ‘",action:()=>s.hideColumn(e.field)},{id:"autofit",label:"์ปฌ๋Ÿผ ๋„ˆ๋น„ ์ž๋™",icon:"โ†”",action:()=>s.autoFitColumn(e.field)},{id:"autofit-all",label:"๋ชจ๋“  ์ปฌ๋Ÿผ ์ž๋™",icon:"โ‡”",action:()=>s.autoFitAllColumns()},{type:"separator"},{id:"fix-left",label:"์™ผ์ชฝ์— ๊ณ ์ •",icon:"โ—€",action:()=>s.fixColumn(e.field,"left")},{id:"unfix",label:"๊ณ ์ • ํ•ด์ œ",icon:"โ—‡",action:()=>s.fixColumn(e.field,!1)}];let f=[];h?(f=[...d],g.length>0&&(f.push({type:"separator"}),f.push(...g))):f=g,f.forEach(C=>{if(typeof C.visible=="function"?C.visible(a):C.visible!==!1)if(C.type==="separator"){const b=p("div","velox-column-menu-separator");n.appendChild(b)}else{const b=p("div","velox-column-menu-item");C.className&&w(b,C.className);const y=typeof C.disabled=="function"?C.disabled(a):C.disabled===!0;y&&w(b,"velox-column-menu-item--disabled");let S="";C.icon&&(S+=`<span class="velox-column-menu-icon">${C.icon}</span>`),S+=`<span class="velox-column-menu-label">${C.label||""}</span>`,C.shortcut&&(S+=`<span class="velox-column-menu-shortcut">${C.shortcut}</span>`),b.innerHTML=S,y||b.addEventListener("click",()=>{var E;(E=C.action)==null||E.call(C,a),this.closeColumnMenu()}),n.appendChild(b)}}),this.columnMenuPopup=n,s.rootElement.appendChild(n),setTimeout(()=>document.addEventListener("click",this.boundHandleOutsideClick),0)}closeColumnMenu(){this.columnMenuPopup&&(this.columnMenuPopup.remove(),this.columnMenuPopup=null,document.removeEventListener("click",this.boundHandleOutsideClick))}handleOutsideClick(e){this.columnMenuPopup&&!this.columnMenuPopup.contains(e.target)&&this.closeColumnMenu()}isOpen(){return this.columnMenuPopup!==null}}class Pt{constructor(e){this.ctx=e,this.columnDragging=null,this.rowDragging=null,this.resizing=null,this.boundHandleColumnDragMove=this.handleColumnDragMove.bind(this),this.boundHandleColumnDragEnd=this.handleColumnDragEnd.bind(this),this.boundHandleRowDragMove=this.handleRowDragMove.bind(this),this.boundHandleRowDragEnd=this.handleRowDragEnd.bind(this),this.boundHandleResizeMove=this.handleResizeMove.bind(this),this.boundHandleResizeEnd=this.handleResizeEnd.bind(this)}startColumnDrag(e,i){e.preventDefault(),e.stopPropagation(),this.columnDragging={field:i.field,startX:e.clientX,element:null};const s=p("div","velox-column-drag-indicator");s.textContent=i.header,s.style.position="fixed",s.style.left=`${e.clientX}px`,s.style.top=`${e.clientY}px`,document.body.appendChild(s),this.columnDragging.element=s,document.addEventListener("mousemove",this.boundHandleColumnDragMove),document.addEventListener("mouseup",this.boundHandleColumnDragEnd),w(document.body,"velox-no-select")}handleColumnDragMove(e){var n;const i=this.ctx;if(!((n=this.columnDragging)!=null&&n.element))return;this.columnDragging.element.style.left=`${e.clientX+10}px`,this.columnDragging.element.style.top=`${e.clientY+10}px`;const s=document.elementFromPoint(e.clientX,e.clientY),o=s==null?void 0:s.closest(".velox-header-cell");i.headerElement.querySelectorAll(".velox-header-cell--drop-target").forEach(t=>{R(t,"velox-header-cell--drop-target")}),o&&o.dataset.field!==this.columnDragging.field&&w(o,"velox-header-cell--drop-target")}handleColumnDragEnd(e){const i=this.ctx;if(!this.columnDragging)return;const s=this.columnDragging.field,o=document.elementFromPoint(e.clientX,e.clientY),n=o==null?void 0:o.closest(".velox-header-cell"),t=n==null?void 0:n.dataset.field;this.columnDragging.element&&this.columnDragging.element.remove(),i.headerElement.querySelectorAll(".velox-header-cell--drop-target").forEach(l=>{R(l,"velox-header-cell--drop-target")}),document.removeEventListener("mousemove",this.boundHandleColumnDragMove),document.removeEventListener("mouseup",this.boundHandleColumnDragEnd),R(document.body,"velox-no-select"),t&&t!==s&&i.reorderColumn(s,t),this.columnDragging=null}isColumnDragging(){return this.columnDragging!==null}startRowDrag(e,i,s){e.preventDefault(),e.stopPropagation(),this.rowDragging={index:i,startY:e.clientY,element:null};const o=p("div","velox-row-drag-indicator");o.textContent=`ํ–‰ ${i+1}`,o.style.position="fixed",o.style.left=`${e.clientX}px`,o.style.top=`${e.clientY}px`,document.body.appendChild(o),this.rowDragging.element=o,w(s,"velox-row--dragging"),document.addEventListener("mousemove",this.boundHandleRowDragMove),document.addEventListener("mouseup",this.boundHandleRowDragEnd),w(document.body,"velox-no-select")}handleRowDragMove(e){var n,t;const i=this.ctx;if(!((n=this.rowDragging)!=null&&n.element))return;this.rowDragging.element.style.left=`${e.clientX+10}px`,this.rowDragging.element.style.top=`${e.clientY+10}px`;const s=document.elementFromPoint(e.clientX,e.clientY),o=s==null?void 0:s.closest(".velox-row");if(i.bodyInner.querySelectorAll(".velox-row--drop-target").forEach(l=>{R(l,"velox-row--drop-target")}),(t=i.fixedLeftBodyInner)==null||t.querySelectorAll(".velox-row--drop-target").forEach(l=>{R(l,"velox-row--drop-target")}),o){const l=parseInt(o.dataset.rowIndex||"-1",10);l!==-1&&l!==this.rowDragging.index&&w(o,"velox-row--drop-target")}}handleRowDragEnd(e){var l;const i=this.ctx;if(!this.rowDragging)return;const s=this.rowDragging.index,o=document.elementFromPoint(e.clientX,e.clientY),n=o==null?void 0:o.closest(".velox-row"),t=n?parseInt(n.dataset.rowIndex||"-1",10):-1;this.rowDragging.element&&this.rowDragging.element.remove(),i.bodyInner.querySelectorAll(".velox-row--dragging, .velox-row--drop-target").forEach(a=>{R(a,"velox-row--dragging"),R(a,"velox-row--drop-target")}),(l=i.fixedLeftBodyInner)==null||l.querySelectorAll(".velox-row--dragging, .velox-row--drop-target").forEach(a=>{R(a,"velox-row--dragging"),R(a,"velox-row--drop-target")}),document.removeEventListener("mousemove",this.boundHandleRowDragMove),document.removeEventListener("mouseup",this.boundHandleRowDragEnd),R(document.body,"velox-no-select"),t!==-1&&t!==s&&i.moveRow(s,t),this.rowDragging=null}isRowDragging(){return this.rowDragging!==null}startResize(e,i){const s=this.ctx;e.preventDefault(),e.stopPropagation();const o=s.headerElement.querySelector(`[data-field="${i.field}"]`);o&&(this.resizing={column:i,startX:e.clientX,startWidth:o.offsetWidth},document.addEventListener("mousemove",this.boundHandleResizeMove),document.addEventListener("mouseup",this.boundHandleResizeEnd),w(document.body,"velox-no-select"))}handleResizeMove(e){const i=this.ctx;if(!this.resizing)return;const s=e.clientX-this.resizing.startX,o=Math.max(50,this.resizing.startWidth+s);this.resizing.column.width=o,i.invalidateColumnCache(),i.render()}handleResizeEnd(){const e=this.ctx;this.resizing&&(document.removeEventListener("mousemove",this.boundHandleResizeMove),document.removeEventListener("mouseup",this.boundHandleResizeEnd),R(document.body,"velox-no-select"),e.emitEvent("onColumnResize",this.resizing.column.field,this.resizing.column.width||0),this.resizing=null)}isResizing(){return this.resizing!==null}cleanup(){this.columnDragging&&(this.columnDragging.element&&this.columnDragging.element.remove(),document.removeEventListener("mousemove",this.boundHandleColumnDragMove),document.removeEventListener("mouseup",this.boundHandleColumnDragEnd),this.columnDragging=null),this.rowDragging&&(this.rowDragging.element&&this.rowDragging.element.remove(),document.removeEventListener("mousemove",this.boundHandleRowDragMove),document.removeEventListener("mouseup",this.boundHandleRowDragEnd),this.rowDragging=null),this.resizing&&(document.removeEventListener("mousemove",this.boundHandleResizeMove),document.removeEventListener("mouseup",this.boundHandleResizeEnd),this.resizing=null),R(document.body,"velox-no-select")}destroy(){this.cleanup()}}class Ht{constructor(e){this.context=e,this.summaryCache=new Map}calculateFooterSummary(e){var g,d;const i=this.context.getOptions(),s=this.context.getState().columns.find(f=>f.field===e);if(!s)return null;const o=s.summary||((d=(g=i.footerSummary)==null?void 0:g.columns)==null?void 0:d[e]);if(!o)return null;const n=`footer:${e}`;if(this.summaryCache.has(n))return this.summaryCache.get(n);const t=this.context.getDisplayData(),l=t.map(f=>f[e]),a=this.executeAggregation(o,l,t),r=this.formatSummaryValue(a,o,s),h={field:e,function:o.function,value:a,formattedValue:r};return this.summaryCache.set(n,h),h}calculateAllFooterSummaries(){var o;const e=this.context.getOptions(),i=new Map;return(o=e.footerSummary)!=null&&o.visible&&this.context.getVisibleColumns().forEach(n=>{const t=this.calculateFooterSummary(n.field);t&&i.set(n.field,t)}),i}calculateGroupSummary(e,i,s){var h,g;const o=this.context.getOptions(),n=this.context.getState().columns.find(d=>d.field===e);if(!n||!((h=o.groupSummary)!=null&&h.enabled))return null;const t=(g=o.groupSummary.columns)==null?void 0:g[e];if(!t)return null;const l=s.map(d=>d[e]),a=this.executeAggregation(t,l,s),r=this.formatSummaryValue(a,t,n);return{field:e,function:t.function,value:a,formattedValue:r}}executeAggregation(e,i,s){const o=i.filter(n=>n!=null);switch(e.function){case"sum":return this.calculateSum(o);case"avg":return this.calculateAverage(o);case"count":return this.calculateCount(o);case"min":return this.calculateMin(o);case"max":return this.calculateMax(o);case"custom":return e.customFunction?e.customFunction(i,s):null;default:return null}}calculateSum(e){return e.reduce((i,s)=>{const o=this.toNumber(s);return i+(o!==null?o:0)},0)}calculateAverage(e){if(e.length===0)return null;const i=this.calculateSum(e),s=e.filter(o=>this.toNumber(o)!==null).length;return s>0?i/s:null}calculateCount(e){return e.length}calculateMin(e){const i=e.map(s=>this.toNumber(s)).filter(s=>s!==null);return i.length>0?Math.min(...i):null}calculateMax(e){const i=e.map(s=>this.toNumber(s)).filter(s=>s!==null);return i.length>0?Math.max(...i):null}toNumber(e){if(typeof e=="number")return e;if(typeof e=="string"){const i=e.replace(/,/g,""),s=parseFloat(i);return isNaN(s)?null:s}return typeof e=="boolean"?e?1:0:null}formatSummaryValue(e,i,s){return i.formatter?i.formatter(e):s.formatter?s.formatter(e,{},s):e==null?"":typeof e=="number"?i.format?this.applyNumberFormat(e,i.format):this.formatNumber(e):String(e)}applyNumberFormat(e,i){const s=i.includes(","),o=i.match(/\.(\d+)/),n=o?o[1].length:0;let t=e.toFixed(n);if(s){const l=t.split(".");l[0]=l[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),t=l.join(".")}return t}formatNumber(e){return Number.isInteger(e)?e.toLocaleString("en-US"):e.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}invalidateCache(){this.summaryCache.clear()}invalidateFieldCache(e){this.summaryCache.delete(`footer:${e}`)}getSummaryValue(e){const i=this.calculateFooterSummary(e);return(i==null?void 0:i.value)??null}getAllSummaryValues(){const e=this.calculateAllFooterSummaries(),i={};return e.forEach((s,o)=>{i[o]=s.value}),i}}const Ft={rowHeight:40,headerHeight:44,showRowNumbers:!1,rowDraggable:!1,selectable:!0,selectionMode:"multiple",selectionStyle:"row",showCheckbox:!1,sortable:!0,filterable:!1,editable:!1,resizable:!0,virtualScroll:!1,bufferSize:5,theme:"default",locale:"ko-KR",emptyMessage:"๋ฐ์ดํ„ฐ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",loading:!1,loadingMessage:"๋กœ๋”ฉ ์ค‘...",undoable:!0,undoStackSize:50},A={visible:!1,exclusive:!1,showAll:!0};class U{constructor(e,i,s={}){var o,n,t,l,a;if(this.footerElement=null,this.fixedLeftFooter=null,this.loadingOverlay=null,this.fixedLeftContainer=null,this.fixedLeftHeader=null,this.fixedLeftBody=null,this.fixedLeftBodyInner=null,this.fixedRightContainer=null,this.fixedRightHeader=null,this.fixedRightBody=null,this.fixedRightBodyInner=null,this.fixedRightFooter=null,this.paginationContainer=null,this.infiniteScrollLoading=!1,this.infiniteScrollAllLoaded=!1,this.blockSelecting=null,this.measureCanvas=null,this.measureContext=null,this.virtualState={startIndex:0,endIndex:0,visibleCount:0,totalHeight:0},this.dataIndexMap=new Map,this.columnCache={visible:null,fixedLeft:null,scrollable:null,fixedRight:null,dirty:!0},this.tooltip=null,this.editModeCleanup=null,this.scrollHandlers=[],this.wheelHandler=null,typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);this.container=r}else this.container=e;this.options={...Ft,...i},this.options.checkBar?this.options.checkBar={...A,...this.options.checkBar}:this.options.showCheckbox&&(this.options.checkBar={...A,visible:!0}),this.events=s,this.gridId=ft("velox-grid"),this.boundHandleBlockSelectionEnd=this.handleBlockSelectionEnd.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this),this.history=new kt({enabled:this.options.undoable??!0,maxSize:this.options.undoStackSize??50}),this.renderer=new Tt(this),this.filterPopupManager=new Bt(this),this.columnMenuManager=new Mt(this),this.dragManager=new Pt(this),this.summary=new Ht(this),this.state={data:[],displayData:[],columns:this.options.columns.map(r=>({...r})),selection:{selectedRows:new Set,selectedCells:new Set,focusedCell:null,selections:[],lastSelectedRow:null},checkBar:{checkedRows:new Set,checkableRows:new Set},rowStates:new Map,sort:[],filter:null,edit:{editing:!1,rowIndex:null,field:null,originalValue:null},pagination:{currentPage:1,pageSize:((o=this.options.pagination)==null?void 0:o.pageSize)||20,totalCount:((n=this.options.dataSource)==null?void 0:n.totalCount)||0,totalPages:0,loading:!1},scroll:{top:0,left:0}},this.options.data&&(this.state.data=this.options.data.map(r=>({...r})),this.rebuildDataIndexMap(),this.state.displayData=[...this.state.data],this.initCheckableRows(),this.state.data.forEach(r=>{this.state.rowStates.set(r,"none")})),this.build(),this.tooltip=new Lt(this.rootElement),(t=this.options.pagination)!=null&&t.enabled?this.isRemoteDataSource()?(this.render(),this.fetchData()):(this.state.pagination.totalCount=this.state.data.length,this.updateTotalPages(),this.options.pagination.mode==="infinite"?this.applyLocalInfiniteScroll():this.applyLocalPagination(),this.render()):this.render(),this.attachEvents(),(a=(l=this.events).onReady)==null||a.call(l,this)}rebuildDataIndexMap(){this.dataIndexMap.clear(),this.state.data.forEach((e,i)=>{this.dataIndexMap.set(e,i)})}initCheckableRows(){this.state.checkBar.checkableRows.clear();const e=this.options.checkBar;this.state.displayData.forEach((i,s)=>{e!=null&&e.checkableCallback?e.checkableCallback(i,s)&&this.state.checkBar.checkableRows.add(s):this.state.checkBar.checkableRows.add(s)})}invalidateColumnCache(){this.columnCache.dirty=!0,this.columnCache.visible=null,this.columnCache.fixedLeft=null,this.columnCache.scrollable=null,this.columnCache.fixedRight=null}getSpecialColumnsWithOrder(){var i;const e=[];if(typeof this.options.rowDraggable=="object"&&this.options.rowDraggable.enabled){const s=this.options.rowDraggable.displayOrder??0;e.push({col:{field:"__drag",header:"",width:44,visible:!0},order:s})}else this.options.rowDraggable===!0&&e.push({col:{field:"__drag",header:"",width:44,visible:!0},order:0});if((i=this.options.checkBar)!=null&&i.visible){const s=this.options.checkBar.displayOrder??10;e.push({col:{field:"__checkbox",header:"",width:44,visible:!0},order:s})}if(typeof this.options.showRowNumbers=="object"&&this.options.showRowNumbers.visible){const s=this.options.showRowNumbers.displayOrder??20;e.push({col:{field:"__rownum",header:"#",width:50,visible:!0},order:s})}else this.options.showRowNumbers===!0&&e.push({col:{field:"__rownum",header:"#",width:50,visible:!0},order:20});return e.sort((s,o)=>s.order-o.order),e.map(s=>s.col)}getFixedLeftColumns(){if(this.columnCache.dirty||!this.columnCache.fixedLeft){const{colCount:e=0}=this.options.fixedOptions||{};if(e>0){const i=this.getSpecialColumnsWithOrder(),o=this.getDataColumns().slice(0,e);this.columnCache.fixedLeft=[...i,...o]}else this.columnCache.fixedLeft=[]}return this.columnCache.fixedLeft}getFixedRightColumns(){if(this.columnCache.dirty||!this.columnCache.fixedRight){const{rightCount:e=0}=this.options.fixedOptions||{},i=this.getDataColumns(),s=i.length;this.columnCache.fixedRight=e>0?i.slice(s-e):[]}return this.columnCache.fixedRight}getScrollableColumns(){if(this.columnCache.dirty||!this.columnCache.scrollable){const{colCount:e=0,rightCount:i=0}=this.options.fixedOptions||{},s=this.getDataColumns(),o=s.length;if(e===0){const n=this.getSpecialColumnsWithOrder(),t=o-i,l=t>0?s.slice(0,t):[];this.columnCache.scrollable=[...n,...l]}else{const n=e,t=o-i;this.columnCache.scrollable=n<t?s.slice(n,t):[]}this.columnCache.dirty=!1}return this.columnCache.scrollable}getDataColumns(){return this.state.columns.filter(e=>e.visible!==!1&&!this.isSpecialColumn(e))}isSpecialColumn(e){return e.field==="__checkbox"||e.field==="__rownum"||e.field==="__drag"}getVisibleColumns(){return(this.columnCache.dirty||!this.columnCache.visible)&&(this.columnCache.visible=this.state.columns.filter(e=>e.visible!==!1)),this.columnCache.visible}hasFixedLeft(){const{colCount:e=0}=this.options.fixedOptions||{};return e>0}hasFixedRight(){const{rightCount:e=0}=this.options.fixedOptions||{};return e>0}build(){var s,o,n,t;this.rootElement=p("div","velox-grid"),this.rootElement.id=this.gridId,this.rootElement.tabIndex=0,this.options.className&&w(this.rootElement,this.options.className),this.hasFixedRight()&&w(this.rootElement,"has-fixed-right"),this.options.width&&(this.rootElement.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width),this.options.height&&(this.rootElement.style.height=typeof this.options.height=="number"?`${this.options.height}px`:this.options.height);const e=p("div","velox-wrapper");this.hasFixedLeft()&&(this.fixedLeftContainer=p("div","velox-fixed-left"),this.fixedLeftHeader=p("div","velox-header velox-header--fixed"),this.fixedLeftBody=p("div","velox-body--fixed"),this.fixedLeftBodyInner=p("div","velox-body-inner"),this.fixedLeftBody.appendChild(this.fixedLeftBodyInner),this.fixedLeftContainer.appendChild(this.fixedLeftHeader),this.fixedLeftContainer.appendChild(this.fixedLeftBody),(s=this.options.footerSummary)!=null&&s.visible&&(this.fixedLeftFooter=p("div","velox-footer velox-footer--fixed"),this.fixedLeftContainer.appendChild(this.fixedLeftFooter)),e.appendChild(this.fixedLeftContainer));const i=p("div","velox-main");this.headerElement=p("div","velox-header"),this.bodyElement=p("div","velox-body"),this.bodyInner=p("div","velox-body-inner"),this.bodyElement.appendChild(this.bodyInner),i.appendChild(this.headerElement),i.appendChild(this.bodyElement),(o=this.options.footerSummary)!=null&&o.visible&&(this.footerElement=p("div","velox-footer"),i.appendChild(this.footerElement)),e.appendChild(i),this.hasFixedRight()&&(this.fixedRightContainer=p("div","velox-fixed-right"),this.fixedRightHeader=p("div","velox-header velox-header--fixed-right"),this.fixedRightBody=p("div","velox-body--fixed"),this.fixedRightBodyInner=p("div","velox-body-inner"),this.fixedRightBody.appendChild(this.fixedRightBodyInner),this.fixedRightContainer.appendChild(this.fixedRightHeader),this.fixedRightContainer.appendChild(this.fixedRightBody),(n=this.options.footerSummary)!=null&&n.visible&&(this.fixedRightFooter=p("div","velox-footer velox-footer--fixed-right"),this.fixedRightContainer.appendChild(this.fixedRightFooter)),e.appendChild(this.fixedRightContainer)),this.rootElement.appendChild(e),(t=this.options.pagination)!=null&&t.enabled&&(this.paginationContainer=p("div","velox-pagination"),this.rootElement.appendChild(this.paginationContainer)),this.container.innerHTML="",this.container.appendChild(this.rootElement),this.buildLoadingOverlay()}buildLoadingOverlay(){this.loadingOverlay=p("div","velox-loading-overlay"),this.loadingOverlay.style.display="none";const e=p("div","velox-loading-spinner"),i=p("div","velox-loading-message");i.textContent=this.options.loadingMessage||"๋กœ๋”ฉ ์ค‘...",this.loadingOverlay.appendChild(e),this.loadingOverlay.appendChild(i),this.rootElement.appendChild(this.loadingOverlay)}calculateVirtualState(){if(!this.options.virtualScroll)return;const e=this.options.rowHeight||40,i=this.bodyElement.clientHeight,s=this.bodyElement.scrollTop,o=this.options.bufferSize||5;this.virtualState.visibleCount=Math.ceil(i/e),this.virtualState.startIndex=Math.max(0,Math.floor(s/e)-o),this.virtualState.endIndex=Math.min(this.state.displayData.length,this.virtualState.startIndex+this.virtualState.visibleCount+o*2),this.virtualState.totalHeight=this.state.displayData.length*e}getVisibleRows(){if(!this.options.virtualScroll)return this.state.displayData.map((i,s)=>({data:i,index:s}));this.calculateVirtualState();const e=[];for(let i=this.virtualState.startIndex;i<this.virtualState.endIndex;i++)this.state.displayData[i]&&e.push({data:this.state.displayData[i],index:i});return e}render(){console.log("๐Ÿ”„ render() called",{editing:this.state.edit.editing,rowIndex:this.state.edit.rowIndex,field:this.state.edit.field}),this.renderer.render(),this.paginationContainer&&this.renderPagination()}renderHeader(){this.renderer.renderHeader()}renderBody(){this.renderer.renderBody()}updateLoadingState(){this.renderer.updateLoadingState()}showFilterPopup(e,i){this.filterPopupManager.showFilterPopup(e,i)}closeFilterPopup(){this.filterPopupManager.closeFilterPopup()}applyColumnFilter(e,i,s){this.filterPopupManager.applyColumnFilter(e,i,s)}removeColumnFilter(e){this.filterPopupManager.removeColumnFilter(e)}detachEvents(){this.scrollHandlers.forEach(e=>{this.bodyElement.removeEventListener("scroll",e),this.fixedRightBody&&this.fixedRightBody.removeEventListener("scroll",e)}),this.scrollHandlers=[],this.wheelHandler&&(this.bodyElement.removeEventListener("wheel",this.wheelHandler),this.wheelHandler=null)}attachEvents(){this.detachEvents();let e=!1,i=null;const s=n=>{var a,r;if(e||i!==null)return;i=window.setTimeout(()=>{i=null},16),e=!0;const t=n==="fixedRight"&&this.fixedRightBody?this.fixedRightBody.scrollTop:this.bodyElement.scrollTop,l=this.bodyElement.scrollLeft;this.state.scroll.top=t,this.state.scroll.left=l,this.fixedLeftBody&&this.fixedLeftBody.scrollTop!==t&&(this.fixedLeftBody.scrollTop=t),n!=="fixedRight"&&this.fixedRightBody&&this.fixedRightBody.scrollTop!==t&&(this.fixedRightBody.scrollTop=t),n!=="body"&&this.bodyElement.scrollTop!==t&&(this.bodyElement.scrollTop=t),this.headerElement.scrollLeft!==l&&(this.headerElement.scrollLeft=l),this.footerElement&&this.footerElement.scrollLeft!==l&&(this.footerElement.scrollLeft=l),this.options.virtualScroll&&this.renderBody(),(r=(a=this.events).onScroll)==null||r.call(a,this.state.scroll.top,this.state.scroll.left),(n==="body"||n==="fixedRight")&&this.checkInfiniteScroll(),e=!1},o=ut(()=>{const n=this.headerElement.scrollLeft;this.bodyElement.scrollLeft=n,this.footerElement&&(this.footerElement.scrollLeft=n)},16);if(this.hasFixedRight()){this.wheelHandler=l=>{l.preventDefault(),this.fixedRightBody&&(this.fixedRightBody.scrollTop+=l.deltaY)},this.bodyElement.addEventListener("wheel",this.wheelHandler,{passive:!1});const n=()=>s("fixedRight");this.fixedRightBody.addEventListener("scroll",n),this.scrollHandlers.push(n);const t=()=>s("body");this.bodyElement.addEventListener("scroll",t),this.scrollHandlers.push(t)}else{const n=()=>s("body");this.bodyElement.addEventListener("scroll",n),this.scrollHandlers.push(n)}this.headerElement.addEventListener("scroll",o),this.scrollHandlers.push(o),document.addEventListener("mouseup",this.boundHandleBlockSelectionEnd),this.rootElement.addEventListener("keydown",this.boundHandleKeyDown)}handleSort(e){var o,n,t;const i=this.state.sort.findIndex(l=>l.field===e);let s="asc";if(i>=0){const l=this.state.sort[i].direction;l==="asc"?s="desc":l==="desc"&&(s=null)}this.state.sort=s?[{field:e,direction:s}]:[],this.clearSelectionState(),this.applyDataTransformations(),(!this.isRemoteDataSource()||!((o=this.options.pagination)!=null&&o.enabled))&&this.render(),(t=(n=this.events).onSort)==null||t.call(n,this.state.sort)}handleRowClick(e,i){var o,n;if(!this.options.selectable)return;(this.options.selectionStyle||"row")==="row"&&this.handleRowSelection(e,i),(n=(o=this.events).onRowClick)==null||n.call(o,e,this.state.displayData[e])}handleRowSelection(e,i){var o,n;const s=this.options.selectionMode||"multiple";if(s!=="none")if(s==="multiple"&&(i.ctrlKey||i.metaKey)){const t=this.state.selection.selectedRows.has(e);this.selectRow(e,!t)}else if(s==="multiple"&&i.shiftKey){const t=Array.from(this.state.selection.selectedRows);if(t.length>0){const l=t[t.length-1],a=Math.min(l,e),r=Math.max(l,e);for(let h=a;h<=r;h++)this.state.selection.selectedRows.add(h);this.render(),(n=(o=this.events).onSelectionChange)==null||n.call(o,this.getSelectedRows())}else this.selectRow(e,!0)}else if(s==="extended"&&(i.ctrlKey||i.metaKey)){const t=this.state.selection.selectedRows.has(e);this.selectRow(e,!t)}else this.state.selection.selectedRows.clear(),this.selectRow(e,!0)}handleCellClick(e,i,s,o){var t,l;if(console.log("๐Ÿ” handleCellClick",{rowIndex:e,field:i,editing:this.state.edit.editing,editRow:this.state.edit.rowIndex,editField:this.state.edit.field}),this.state.edit.editing&&this.state.edit.rowIndex===e&&this.state.edit.field===i){console.log("โœ… Same cell clicked - maintaining edit mode");return}const n=this.options.selectionStyle||"row";n==="cell"||n==="block"?this.handleCellSelection(e,i,o):n==="row"&&(this.state.selection.focusedCell={rowIndex:e,field:i}),(l=(t=this.events).onCellClick)==null||l.call(t,e,i,s)}handleCellSelection(e,i,s){var t,l;const o=this.options.selectionMode||"multiple",n=`${e}:${i}`;if(o!=="none"){if(this.state.selection.focusedCell={rowIndex:e,field:i},o==="multiple"&&(s.ctrlKey||s.metaKey))this.state.selection.selectedCells.has(n)?this.state.selection.selectedCells.delete(n):this.state.selection.selectedCells.add(n);else if(o==="multiple"&&s.shiftKey){const a=this.state.selection.focusedCell;a&&this.selectCellRange(a.rowIndex,a.field,e,i)}else this.state.selection.selectedCells.clear(),this.state.selection.selectedCells.add(n);this.render(),(l=(t=this.events).onCellSelectionChange)==null||l.call(t,this.getSelectedCells())}}selectCellRange(e,i,s,o){const n=this.getVisibleColumns(),t=n.findIndex(d=>d.field===i),l=n.findIndex(d=>d.field===o),a=Math.min(e,s),r=Math.max(e,s),h=Math.min(t,l),g=Math.max(t,l);this.state.selection.selectedCells.clear();for(let d=a;d<=r;d++)for(let f=h;f<=g;f++){const C=n[f].field;this.state.selection.selectedCells.add(`${d}:${C}`)}}startBlockSelection(e,i){this.options.selectionStyle==="block"&&(this.blockSelecting={startRow:e,startField:i},this.state.selection.focusedCell={rowIndex:e,field:i},this.state.selection.selectedCells.clear(),this.state.selection.selectedCells.add(`${e}:${i}`),this.render())}updateBlockSelection(e,i){this.blockSelecting&&(this.selectCellRange(this.blockSelecting.startRow,this.blockSelecting.startField,e,i),this.render())}handleBlockSelectionEnd(){var e,i;this.blockSelecting&&(this.blockSelecting=null,(i=(e=this.events).onCellSelectionChange)==null||i.call(e,this.getSelectedCells()))}handleRowDoubleClick(e,i){var s,o;(o=(s=this.events).onRowDoubleClick)==null||o.call(s,e,this.state.displayData[e])}handleKeyDown(e){var a,r,h,g;if(this.state.edit.editing){e.key==="Escape"?this.cancelEdit():e.key==="Enter"?(e.preventDefault(),this.endEditAndMove(e.shiftKey?"up":"down")):e.key==="Tab"&&(e.preventDefault(),this.endEditAndMove(e.shiftKey?"left":"right"));return}if((e.ctrlKey||e.metaKey)&&e.key==="z"){e.preventDefault(),this.undo();return}if((e.ctrlKey||e.metaKey)&&e.key==="y"){e.preventDefault(),this.redo();return}if((e.ctrlKey||e.metaKey)&&e.key==="c"){e.preventDefault(),this.copy();return}if((e.ctrlKey||e.metaKey)&&e.key==="v"){e.preventDefault(),this.paste();return}if((e.ctrlKey||e.metaKey)&&e.key==="x"){e.preventDefault(),this.cut();return}if((e.key==="Delete"||e.key==="Backspace")&&this.options.editable){e.preventDefault(),this.deleteSelectedCells();return}const i=this.state.selection.focusedCell;if(!this.state.edit.editing&&this.options.editable&&i){const d=this.state.columns.find(f=>f.field===i.field);if((d==null?void 0:d.editable)!==!1&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault(),this.startEdit(i.rowIndex,i.field),setTimeout(()=>{const f=document.querySelector(".velox-edit-input");f&&(f.value=e.key,f.setSelectionRange(1,1))},0);return}}if((r=(a=this.events).onKeyDown)==null||r.call(a,e,i),!i)return;const s=this.getVisibleColumns(),o=s.findIndex(d=>d.field===i.field);let n=i.rowIndex,t=o,l=!1;switch(e.key){case"ArrowUp":n>0&&(n--,l=!0);break;case"ArrowDown":n<this.state.displayData.length-1&&(n++,l=!0);break;case"ArrowLeft":t>0&&(t--,l=!0);break;case"ArrowRight":t<s.length-1&&(t++,l=!0);break;case"Tab":e.shiftKey?t>0?t--:n>0&&(n--,t=s.length-1):t<s.length-1?t++:n<this.state.displayData.length-1&&(n++,t=0),l=!0;break;case"Home":e.ctrlKey&&(n=0),t=0,l=!0;break;case"End":e.ctrlKey&&(n=this.state.displayData.length-1),t=s.length-1,l=!0;break;case"PageUp":n=Math.max(0,n-this.virtualState.visibleCount),l=!0;break;case"PageDown":n=Math.min(this.state.displayData.length-1,n+this.virtualState.visibleCount),l=!0;break;case"Enter":case"F2":this.options.editable&&(this.startEdit(i.rowIndex,i.field),l=!0);break;case" ":(h=this.options.checkBar)!=null&&h.visible&&(this.checkItem(i.rowIndex,!this.isItemChecked(i.rowIndex)),l=!0);break;case"a":case"A":(e.ctrlKey||e.metaKey)&&(this.selectAllCells(),l=!0);break}if(l){e.preventDefault();const d=(g=s[t])==null?void 0:g.field;d&&(n!==i.rowIndex||d!==i.field)&&(this.setFocusedCell(n,d),e.shiftKey&&(this.options.selectionStyle==="cell"||this.options.selectionStyle==="block")?this.selectCellRange(i.rowIndex,i.field,n,d):!e.shiftKey&&!e.ctrlKey&&(this.state.selection.selectedCells.clear(),this.state.selection.selectedCells.add(`${n}:${d}`),this.options.selectionStyle==="row"&&(this.state.selection.selectedRows.clear(),this.state.selection.selectedRows.add(n))),this.render(),this.scrollToCell(n,d))}}selectAllCells(){var i,s;const e=this.getVisibleColumns();this.state.selection.selectedCells.clear();for(let o=0;o<this.state.displayData.length;o++)for(const n of e)this.state.selection.selectedCells.add(`${o}:${n.field}`);this.render(),(s=(i=this.events).onCellSelectionChange)==null||s.call(i,this.getSelectedCells())}startResize(e,i){this.dragManager.startResize(e,i)}applyDataTransformations(){var i;if((i=this.options.pagination)!=null&&i.enabled)if(this.infiniteScrollLoading=!1,this.infiniteScrollAllLoaded=!1,this.state.pagination.currentPage=1,this.isRemoteDataSource()){this.options.pagination.mode==="infinite"&&(this.state.data=[],this.state.displayData=[]),this.fetchData();return}else{this.options.pagination.mode==="infinite"?this.applyLocalInfiniteScroll():this.applyLocalPagination();return}let e=[...this.state.data];if(this.state.filter&&(e=V(e,this.state.filter)),this.state.sort.length>0){const s={};this.state.columns.forEach(o=>{s[o.field]=o.type||"text"}),e=O(e,this.state.sort,s)}this.state.displayData=e,this.initCheckableRows()}clearSelectionState(){this.state.selection.selectedRows.clear(),this.state.selection.selectedCells.clear(),this.state.selection.focusedCell=null}getData(){return this.state.data.map(e=>({...e}))}setData(e){var i,s,o;this.state.data=e.map(n=>({...n})),this.rebuildDataIndexMap(),this.clearSelectionState(),this.state.checkBar.checkedRows.clear(),this.state.rowStates.clear(),this.state.data.forEach(n=>{this.state.rowStates.set(n,"none")}),(i=this.options.pagination)!=null&&i.enabled&&!this.isRemoteDataSource()&&(this.state.pagination.totalCount=this.state.data.length,this.state.pagination.currentPage=1,this.updateTotalPages()),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(o=(s=this.events).onDataChange)==null||o.call(s,this.state.data)}getRow(e){return this.state.displayData[e]?{...this.state.displayData[e]}:null}getRowCount(){return this.state.data.length}getVisibleRowCount(){return this.state.displayData.length}addRow(e,i){var n,t,l,a;const s={...e},o=i!==void 0?i:this.state.data.length;this.state.data.splice(o,0,s),this.rebuildDataIndexMap(),this.state.rowStates.set(s,"created"),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(t=(n=this.events).onRowAdd)==null||t.call(n,s,o),(a=(l=this.events).onDataChange)==null||a.call(l,this.state.data)}updateRow(e,i){var n,t,l,a;const s=this.state.displayData[e];if(!s)return;const o=this.state.data.indexOf(s);o>=0&&(Object.assign(this.state.data[o],i),(this.state.rowStates.get(this.state.data[o])||"none")==="none"&&this.state.rowStates.set(this.state.data[o],"updated"),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(t=(n=this.events).onRowUpdate)==null||t.call(n,this.state.data[o],e,i),(a=(l=this.events).onDataChange)==null||a.call(l,this.state.data))}removeRow(e){var o,n,t,l;const i=this.state.displayData[e];if(!i)return;const s=this.state.data.indexOf(i);if(s>=0){const a=this.state.data[s];(this.state.rowStates.get(a)||"none")==="created"?this.state.rowStates.set(a,"createAndDeleted"):this.state.rowStates.set(a,"deleted"),this.state.data.splice(s,1),this.rebuildDataIndexMap(),this.state.selection.selectedRows.delete(e);const h=new Set;this.state.selection.selectedRows.forEach(d=>{d>e?h.add(d-1):d<e&&h.add(d)}),this.state.selection.selectedRows=h,this.state.checkBar.checkedRows.delete(e);const g=new Set;this.state.checkBar.checkedRows.forEach(d=>{d>e?g.add(d-1):d<e&&g.add(d)}),this.state.checkBar.checkedRows=g,this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(n=(o=this.events).onRowRemove)==null||n.call(o,a,e),(l=(t=this.events).onDataChange)==null||l.call(t,this.state.data)}}clearData(){var e,i;this.state.data=[],this.state.displayData=[],this.dataIndexMap.clear(),this.state.selection.selectedRows.clear(),this.state.selection.selectedCells.clear(),this.state.selection.focusedCell=null,this.state.checkBar.checkedRows.clear(),this.state.checkBar.checkableRows.clear(),this.summary.invalidateCache(),this.render(),(i=(e=this.events).onDataChange)==null||i.call(e,[])}getSelectedRows(){return Array.from(this.state.selection.selectedRows).sort((e,i)=>e-i)}getSelectedData(){return this.getSelectedRows().map(e=>this.state.displayData[e]).filter(Boolean).map(e=>({...e}))}selectRow(e,i=!0){var s,o,n,t;i?(this.options.selectionMode==="single"&&this.state.selection.selectedRows.clear(),this.state.selection.selectedRows.add(e)):this.state.selection.selectedRows.delete(e),this.render(),(o=(s=this.events).onRowSelect)==null||o.call(s,e,i),(t=(n=this.events).onSelectionChange)==null||t.call(n,this.getSelectedRows())}selectAll(e=!0){var i,s,o,n;if(e)for(let t=0;t<this.state.displayData.length;t++)this.state.selection.selectedRows.add(t);else this.state.selection.selectedRows.clear();this.render(),(s=(i=this.events).onAllSelect)==null||s.call(i,e),(n=(o=this.events).onSelectionChange)==null||n.call(o,this.getSelectedRows())}clearSelection(){var e,i,s,o;this.clearSelectionState(),this.render(),(i=(e=this.events).onSelectionChange)==null||i.call(e,[]),(o=(s=this.events).onCellSelectionChange)==null||o.call(s,[])}isRowSelected(e){return this.state.selection.selectedRows.has(e)}selectCell(e,i,s=!0){var n,t,l,a;const o=`${e}:${i}`;s?this.state.selection.selectedCells.add(o):this.state.selection.selectedCells.delete(o),this.render(),(t=(n=this.events).onCellSelect)==null||t.call(n,{rowIndex:e,field:i},s),(a=(l=this.events).onCellSelectionChange)==null||a.call(l,this.getSelectedCells())}getSelectedCells(){return Array.from(this.state.selection.selectedCells).map(e=>{const[i,s]=e.split(":");return{rowIndex:parseInt(i,10),field:s}})}setFocusedCell(e,i){this.state.selection.focusedCell={rowIndex:e,field:i},this.render()}getFocusedCell(){return this.state.selection.focusedCell}setSelection(e){if(this.state.selection.selectedCells.clear(),this.state.selection.selectedRows.clear(),e.style==="row")for(let i=e.startRow;i<=e.endRow;i++)this.state.selection.selectedRows.add(i);else(e.style==="cell"||e.style==="block")&&e.startColumn&&e.endColumn&&this.selectCellRange(e.startRow,e.startColumn,e.endRow,e.endColumn);this.state.selection.selections=[e],this.render()}getSelection(){const e=this.state.selection.selections;return e.length>0?e[0]:null}getSelectionData(){const e=this.getSelectedCells();if(e.length===0)return[];const i=[...new Set(e.map(l=>l.rowIndex))].sort((l,a)=>l-a),s=[...new Set(e.map(l=>l.field))],n=this.getVisibleColumns().filter(l=>s.includes(l.field)).map(l=>l.field),t=[];for(const l of i){const a=this.state.displayData[l];if(a){const r=n.map(h=>a[h]);t.push(r)}}return t}checkItem(e,i=!0){var n,t;if(console.log("๐Ÿ”ต checkItem START",{index:e,checked:i,currentEditState:this.state.edit}),!this.state.checkBar.checkableRows.has(e))return;const s=this.options.checkBar;s!=null&&s.exclusive&&i&&this.state.checkBar.checkedRows.clear(),i?this.state.checkBar.checkedRows.add(e):this.state.checkBar.checkedRows.delete(e);const o={...this.state.edit};console.log("๐Ÿ’พ Saved edit state before render",o),this.render(),console.log("๐Ÿ”„ Render complete, edit state after render",this.state.edit),o.editing&&o.rowIndex!==null&&o.field!==null&&(console.log("โ™ป๏ธ Restoring edit state",o),this.state.edit=o,this.renderEditCell(o.rowIndex,o.field,o.originalValue)),(t=(n=this.events).onCheckChange)==null||t.call(n,e,i),console.log("๐Ÿ”ต checkItem END")}checkItems(e,i=!0){e.forEach(s=>{this.state.checkBar.checkableRows.has(s)&&(i?this.state.checkBar.checkedRows.add(s):this.state.checkBar.checkedRows.delete(s))}),this.render()}checkAll(e=!0){var i,s,o;(i=this.options.checkBar)!=null&&i.exclusive||(e?this.state.checkBar.checkableRows.forEach(n=>{this.state.checkBar.checkedRows.add(n)}):this.state.checkBar.checkedRows.clear(),this.render(),(o=(s=this.events).onCheckAllChange)==null||o.call(s,e))}uncheckAll(){this.checkAll(!1)}getCheckedItems(){return Array.from(this.state.checkBar.checkedRows).sort((e,i)=>e-i)}getCheckedData(){return this.getCheckedItems().map(e=>this.state.displayData[e]).filter(Boolean).map(e=>({...e}))}isItemChecked(e){return this.state.checkBar.checkedRows.has(e)}isItemCheckable(e){return this.state.checkBar.checkableRows.has(e)}checkRow(e,i=!0){this.checkItem(e,i)}getCheckedRows(){return this.getCheckedItems()}sort(e,i="asc"){var s,o;this.state.sort=i?[{field:e,direction:i}]:[],this.clearSelectionState(),this.applyDataTransformations(),this.render(),(o=(s=this.events).onSort)==null||o.call(s,this.state.sort)}clearSort(){var e,i;this.state.sort=[],this.applyDataTransformations(),this.render(),(i=(e=this.events).onSort)==null||i.call(e,[])}getSortState(){return[...this.state.sort]}filter(e){var s,o;const i=Array.isArray(e)?e:[e];this.state.filter={conditions:i,logic:"and"},this.clearSelectionState(),this.applyDataTransformations(),this.render(),(o=(s=this.events).onFilter)==null||o.call(s,this.state.filter)}clearFilter(){this.state.filter=null,this.clearSelectionState(),this.applyDataTransformations(),this.render()}getFilterState(){return this.state.filter?{...this.state.filter}:null}startEdit(e,i){var n,t,l;if(console.log("๐ŸŽฌ startEdit called",{rowIndex:e,field:i,editable:this.options.editable}),!this.options.editable)return;if(this.state.edit.editing&&this.state.edit.rowIndex===e&&this.state.edit.field===i){console.log("โš ๏ธ Already editing this cell - ignoring startEdit");return}const s=this.state.columns.find(a=>a.field===i);if(console.log("๐Ÿ“‹ Column found",{column:s==null?void 0:s.field,editable:s==null?void 0:s.editable}),!s||s.editable===!1)return;this.state.edit.editing&&this.endEdit(!0);const o=(n=this.state.displayData[e])==null?void 0:n[i];this.state.edit={editing:!0,rowIndex:e,field:i,originalValue:o},console.log("โœ… Edit state updated",this.state.edit),(l=(t=this.events).onCellEditStart)==null||l.call(t,e,i,o),this.renderEditCell(e,i,o)}renderEditCell(e,i,s){console.log("๐ŸŽจ renderEditCell START",{rowIndex:e,field:i,value:s,currentEditState:this.state.edit}),this.editModeCleanup&&(console.log("๐Ÿงน Cleaning up previous edit mode listener"),this.editModeCleanup(),this.editModeCleanup=null);const o=this.bodyInner.querySelector(`[data-row-index="${e}"]`),n=o==null?void 0:o.querySelector(`[data-field="${i}"]`);if(console.log("๐Ÿ” Cell element found",{cell:!!n,hasClass:n==null?void 0:n.classList.contains("velox-cell--editing")}),!n)return;const t=this.state.columns.find(a=>a.field===i);if(!t)return;w(n,"velox-cell--editing"),console.log("โœ… Added velox-cell--editing class",{classList:Array.from(n.classList)});const l=a=>{const r=a.target;n.contains(r)?console.log("๐Ÿ“ฆ Inside cell click - maintaining edit mode"):(console.log("๐ŸŒ Outside click detected - ending edit"),this.editModeCleanup=null,document.removeEventListener("mousedown",l),this.endEdit(!0))};if(this.editModeCleanup=()=>{document.removeEventListener("mousedown",l)},setTimeout(()=>{document.addEventListener("mousedown",l)},0),t.editor){const a=Dt.createEditor(s,t.editor,r=>{var g;if(console.log("๐Ÿ’พ Editor save callback",{newValue:r,editing:this.state.edit.editing}),this.setCellValue(e,i,r),((g=t.editor)==null?void 0:g.type)==="checkbox"){console.log("โœ… Checkbox editor - maintaining edit mode, new value:",r),this.state.edit.originalValue=r;const d={...this.state.edit};d.editing&&(this.state.edit=d,this.renderEditCell(d.rowIndex,d.field,r))}else console.log("๐Ÿ›‘ Other editor - ending edit mode"),this.state.edit.editing=!1,this.applyDataTransformations(),this.render();const h=this.events;h.onCellEditEnd&&h.onCellEditEnd({rowIndex:e,field:i,oldValue:s,newValue:r,row:this.state.displayData[e]})},()=>{this.cancelEdit()},r=>{this.endEditAndMove(r)});n.innerHTML="",n.appendChild(a),a.addEventListener("mousedown",()=>{console.log("๐Ÿ–ฑ๏ธ Editor mousedown")}),setTimeout(()=>{(a instanceof HTMLInputElement||a instanceof HTMLSelectElement)&&(a.focus(),a instanceof HTMLInputElement&&a.type==="text"&&a.select())},0)}else{const a=p("input","velox-edit-input");a.type=t.type==="number"?"number":"text",a.value=s!=null?String(s):"",n.innerHTML="",n.appendChild(a),a.focus(),a.select(),a.addEventListener("mousedown",()=>{console.log("๐Ÿ–ฑ๏ธ Input mousedown")}),a.addEventListener("keydown",r=>{console.log("โŒจ๏ธ Input keydown:",r.key,{shiftKey:r.shiftKey}),r.key==="Enter"?(r.preventDefault(),r.stopPropagation(),console.log("โœ… Enter detected - calling endEditAndMove"),this.endEditAndMove(r.shiftKey?"up":"down")):r.key==="Tab"?(r.preventDefault(),r.stopPropagation(),console.log("โœ… Tab detected - calling endEditAndMove"),this.endEditAndMove(r.shiftKey?"left":"right")):r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),console.log("โœ… Escape detected - calling cancelEdit"),this.cancelEdit())})}}endEdit(e=!0){var l,a,r,h,g,d;if(console.log("๐Ÿ›‘ endEdit called",{save:e,editing:this.state.edit.editing}),this.editModeCleanup&&(console.log("๐Ÿงน Cleaning up edit mode listener on endEdit"),this.editModeCleanup(),this.editModeCleanup=null),!this.state.edit.editing)return;const{rowIndex:i,field:s,originalValue:o}=this.state.edit;if(i===null||s===null)return;const n=this.bodyInner.querySelector(`[data-row-index="${i}"]`),t=n==null?void 0:n.querySelector(`[data-field="${s}"]`);if(e&&t){const f=this.state.columns.find(L=>L.field===s),C=this.state.displayData[i];let x=o;const b=t.querySelector(".velox-edit-input"),y=t.querySelector(".velox-editor--select"),S=t.querySelector('.velox-editor--checkbox input[type="checkbox"]'),E=t.querySelector(".velox-editor--date"),D=t.querySelector(".velox-editor--number");if(S?x=S.checked:y?y.multiple?x=Array.from(y.selectedOptions).map(L=>L.value):x=y.value:E?x=E.value:D?x=D.value===""?null:Number(D.value):b&&(x=b.value),JSON.stringify(x)!==JSON.stringify(o)){if(f!=null&&f.validation&&f.validation.length>0){const M=f.type==="number"&&typeof x=="string"?parseFloat(x):x,T=Rt.validate(M,f.validation,C);if(!T.valid){if(t){w(t,"velox-cell--invalid");const B=T.errors.map(F=>F.message).join(", ");t.title=B}(a=(l=this.events).onValidationError)==null||a.call(l,{rowIndex:i,field:s,value:M,errors:T.errors.map(B=>B.message)}),b?b.focus():y?y.focus():E?E.focus():D&&D.focus();return}}const L=(f==null?void 0:f.type)==="number"&&typeof x=="string"?parseFloat(x):x;this.setCellValue(i,s,L),(h=(r=this.events).onCellEditEnd)==null||h.call(r,{rowIndex:i,field:s,oldValue:o,newValue:L,row:this.state.displayData[i]})}}else(d=(g=this.events).onCellEditCancel)==null||d.call(g,i,s);this.state.edit={editing:!1,rowIndex:null,field:null,originalValue:null},this.applyDataTransformations(),this.render()}cancelEdit(){this.endEdit(!1)}isEditing(){return this.state.edit.editing}endEditAndMove(e){var r;const{rowIndex:i,field:s}=this.state.edit;if(i===null||s===null)return;this.endEdit(!0);const o=this.getVisibleColumns(),n=o.findIndex(h=>h.field===s);let t=i,l=n;switch(e){case"up":t>0&&t--;break;case"down":t<this.state.displayData.length-1&&t++;break;case"left":l>0?l--:t>0&&(t--,l=o.length-1);break;case"right":l<o.length-1?l++:t<this.state.displayData.length-1&&(t++,l=0);break}const a=(r=o[l])==null?void 0:r.field;a&&(this.setFocusedCell(t,a),this.state.selection.selectedCells.clear(),this.state.selection.selectedCells.add(`${t}:${a}`),this.scrollToCell(t,a),this.render(),this.rootElement.focus())}getColumn(e){return this.state.columns.find(i=>i.field===e)||null}setColumnWidth(e,i){var o,n;const s=this.state.columns.find(t=>t.field===e);s&&(s.width=i,this.invalidateColumnCache(),this.render(),(n=(o=this.events).onColumnResize)==null||n.call(o,e,i))}showColumn(e){const i=this.state.columns.find(s=>s.field===e);i&&(i.visible=!0,this.invalidateColumnCache(),this.render())}hideColumn(e){const i=this.state.columns.find(s=>s.field===e);i&&(i.visible=!1,this.invalidateColumnCache(),this.render())}setColumns(e){this.state.columns=e.map(i=>({...i})),this.invalidateColumnCache(),this.render()}autoFitColumn(e){var n,t;const i=this.state.columns.find(l=>l.field===e);if(!i)return;let s=100;const o=i.header||"";s=Math.max(s,this.measureTextWidth(o)+40),this.state.displayData.forEach(l=>{const a=l[i.field],r=H(a,i.type),h=this.measureTextWidth(r)+20;s=Math.max(s,h)}),i.width=Math.min(s,500),this.invalidateColumnCache(),this.render(),(t=(n=this.events).onColumnResize)==null||t.call(n,e,i.width)}autoFitAllColumns(){this.getVisibleColumns().forEach(e=>this.autoFitColumn(e.field))}measureTextWidth(e,i){return this.measureCanvas||(this.measureCanvas=document.createElement("canvas"),this.measureContext=this.measureCanvas.getContext("2d")),this.measureContext?(this.measureContext.font=i||"14px sans-serif",this.measureContext.measureText(e).width):100}scrollToRow(e){const i=this.options.rowHeight||40;this.bodyElement.scrollTop=e*i,this.fixedLeftBody&&(this.fixedLeftBody.scrollTop=e*i)}scrollToTop(){this.bodyElement.scrollTop=0,this.fixedLeftBody&&(this.fixedLeftBody.scrollTop=0)}scrollToBottom(){this.bodyElement.scrollTop=this.bodyElement.scrollHeight,this.fixedLeftBody&&(this.fixedLeftBody.scrollTop=this.fixedLeftBody.scrollHeight)}scrollToCell(e,i){const s=this.options.rowHeight||40,o=this.bodyElement.clientHeight,n=this.bodyElement.scrollTop,t=e*s,l=t+s;t<n?this.bodyElement.scrollTop=t:l>n+o&&(this.bodyElement.scrollTop=l-o),this.fixedLeftBody&&(this.fixedLeftBody.scrollTop=this.bodyElement.scrollTop);const a=this.bodyInner.querySelector(`[data-field="${i}"]`);if(a){const r=a.offsetLeft,h=r+a.offsetWidth,g=this.bodyElement.clientWidth,d=this.bodyElement.scrollLeft;r<d?this.bodyElement.scrollLeft=r:h>d+g&&(this.bodyElement.scrollLeft=h-g)}}copy(){const e=this.getSelectionData();if(e.length===0)return;const i=e.map(s=>s.join(" ")).join(`
5
+ `);navigator.clipboard.writeText(i).then(()=>{var s,o;(o=(s=this.events).onCopy)==null||o.call(s,e.map(n=>n.map(t=>String(t??""))))})}paste(){const e=this.state.selection.focusedCell;e&&navigator.clipboard.readText().then(i=>{var t,l,a,r;const s=i.split(`
6
+ `).map(h=>h.split(" "));(l=(t=this.events).onPaste)==null||l.call(t,s,e);const o=this.getVisibleColumns(),n=o.findIndex(h=>h.field===e.field);s.forEach((h,g)=>{const d=e.rowIndex+g;d>=this.state.displayData.length||h.forEach((f,C)=>{const x=n+C;if(x>=o.length)return;const b=o[x].field,y=o[x];if(y.editable!==!1){const S=this.state.displayData[d],E=this.state.data.indexOf(S);E>=0&&(this.state.data[E][b]=y.type==="number"?parseFloat(f):f)}})}),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(r=(a=this.events).onDataChange)==null||r.call(a,this.state.data)})}cut(){var o,n,t,l;const e=this.getSelectionData();if(e.length===0)return;this.copy();const i=[];this.getSelectedCells().forEach(a=>{const r=this.state.columns.find(h=>h.field===a.field);if((r==null?void 0:r.editable)!==!1){const h=this.state.displayData[a.rowIndex],g=this.state.data.indexOf(h);if(g>=0){const d=this.state.data[g][a.field];i.push({rowIndex:a.rowIndex,field:a.field,oldValue:d,newValue:""}),this.state.data[g][a.field]=""}}}),i.length>0&&this.pushUndo({type:"cut",timestamp:Date.now(),data:{changes:i}}),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(n=(o=this.events).onCut)==null||n.call(o,e.map(a=>a.map(r=>String(r??"")))),(l=(t=this.events).onDataChange)==null||l.call(t,this.state.data)}pushUndo(e){this.history.push(e)}undo(){var i,s,o,n;const e=this.history.popUndo();if(!e)return!1;switch(e.type){case"cell_edit":{const t=e.data,l=this.state.displayData[t.rowIndex],a=this.state.data.indexOf(l);a>=0&&(this.state.data[a][t.field]=t.oldValue);break}case"bulk_edit":case"paste":case"cut":case"delete":{e.data.changes.forEach(l=>{const a=this.state.displayData[l.rowIndex],r=this.state.data.indexOf(a);r>=0&&(this.state.data[r][l.field]=l.oldValue)});break}case"row_add":{const t=e.data;this.state.data.splice(t.index,1),this.rebuildDataIndexMap();break}case"row_remove":{const t=e.data;this.state.data.splice(t.index,0,{...t.row}),this.rebuildDataIndexMap();break}}return this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(s=(i=this.events).onUndo)==null||s.call(i,e),(n=(o=this.events).onDataChange)==null||n.call(o,this.state.data),!0}redo(){var i,s,o,n;const e=this.history.popRedo();if(!e)return!1;switch(e.type){case"cell_edit":{const t=e.data,l=this.state.displayData[t.rowIndex],a=this.state.data.indexOf(l);a>=0&&(this.state.data[a][t.field]=t.newValue);break}case"bulk_edit":case"paste":case"cut":case"delete":{e.data.changes.forEach(l=>{const a=this.state.displayData[l.rowIndex],r=this.state.data.indexOf(a);r>=0&&(this.state.data[r][l.field]=l.newValue)});break}case"row_add":{const t=e.data;this.state.data.splice(t.index,0,{...t.row}),this.rebuildDataIndexMap();break}case"row_remove":{const t=e.data;this.state.data.splice(t.index,1),this.rebuildDataIndexMap();break}}return this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(s=(i=this.events).onRedo)==null||s.call(i,e),(n=(o=this.events).onDataChange)==null||n.call(o,this.state.data),!0}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}clearHistory(){this.history.clear()}deleteSelectedCells(){var s,o;if(!this.options.editable)return;const e=this.getSelectedCells();if(e.length===0)return;const i=[];e.forEach(n=>{const t=this.state.columns.find(l=>l.field===n.field);if((t==null?void 0:t.editable)!==!1){const l=this.state.displayData[n.rowIndex],a=this.state.data.indexOf(l);if(a>=0){const r=this.state.data[a][n.field];r!==""&&r!==null&&r!==void 0&&(i.push({rowIndex:n.rowIndex,field:n.field,oldValue:r,newValue:""}),this.state.data[a][n.field]="")}}}),i.length>0&&(this.pushUndo({type:"delete",timestamp:Date.now(),data:{changes:i}}),this.applyDataTransformations(),this.summary.invalidateCache(),this.render(),(o=(s=this.events).onDataChange)==null||o.call(s,this.state.data))}deleteSelectedRows(){const e=this.getSelectedRows();if(e.length===0)return;[...e].sort((s,o)=>o-s).forEach(s=>{this.removeRow(s)})}createExportContext(e={}){return{data:this.state.data,displayData:this.state.displayData,columns:this.state.columns,selectedRows:this.getSelectedRows(),options:e}}exportToExcel(e={}){const i=this.createExportContext(e);gt(i)}exportToCSV(e={}){const i=this.createExportContext(e);return z(i)}exportToJSON(e={}){const i=this.createExportContext(e);return _(i)}downloadCSV(e={}){const i=this.createExportContext(e);bt(i)}downloadJSON(e={}){const i=this.createExportContext(e);St(i)}importFromCSV(e,i=!0){const s=yt(e,i);return s.errors.length===0&&s.data.length>0&&this.setData(s.data),s}async importFromExcel(e,i=0){const s=await wt(e,i);return s.errors.length===0&&s.data.length>0&&this.setData(s.data),s}static isExcelSupported(){return W()}getCellValue(e,i){var s;return(s=this.state.displayData[e])==null?void 0:s[i]}setCellValue(e,i,s){var t,l;const o=this.state.displayData[e];if(!o)return;const n=this.state.data.indexOf(o);n>=0&&(this.state.data[n][i]=s,(this.state.rowStates.get(this.state.data[n])||"none")==="none"&&this.state.rowStates.set(this.state.data[n],"updated"),this.summary.invalidateCache(),this.applyDataTransformations(),this.render(),(l=(t=this.events).onDataChange)==null||l.call(t,this.state.data))}getSummaryValue(e){return this.summary.getSummaryValue(e)}getSummaryValues(){return this.summary.getAllSummaryValues()}refreshSummary(){this.summary.invalidateCache(),this.render()}setOptions(e){this.options={...this.options,...e},e.checkBar&&(this.options.checkBar={...A,...e.checkBar}),e.columns&&(this.state.columns=e.columns.map(i=>({...i}))),e.loading!==void 0&&this.updateLoadingState(),this.render()}getOptions(){return{...this.options}}setLoading(e){this.options.loading=e,this.updateLoadingState()}refresh(){this.applyDataTransformations(),this.render()}fixColumn(e,i){const s=this.state.columns.find(o=>o.field===e);s&&(s.fixed=i,this.invalidateColumnCache(),this.render())}reorderColumn(e,i){var t,l;const s=this.state.columns.findIndex(a=>a.field===e),o=this.state.columns.findIndex(a=>a.field===i);if(s===-1||o===-1)return;const[n]=this.state.columns.splice(s,1);this.state.columns.splice(o,0,n),this.invalidateColumnCache(),this.render(),(l=(t=this.events).onColumnReorder)==null||l.call(t,e,s,o)}showColumnMenu(e,i){this.closeFilterPopup(),this.columnMenuManager.showColumnMenu(e,i)}closeColumnMenu(){this.columnMenuManager.closeColumnMenu()}startColumnDrag(e,i){this.dragManager.startColumnDrag(e,i)}moveRow(e,i){var r,h;const s=this.state.displayData[e];if(!s)return;const o=this.state.data.indexOf(s);if(o===-1)return;const n=this.state.displayData[i],t=n?this.state.data.indexOf(n):this.state.data.length,[l]=this.state.data.splice(o,1),a=t>o?t-1:t;this.state.data.splice(a,0,l),this.rebuildDataIndexMap(),this.applyDataTransformations(),this.render(),(h=(r=this.events).onDataChange)==null||h.call(r,this.state.data)}startRowDrag(e,i,s){this.dragManager.startRowDrag(e,i,s)}getState(){return this.state}getEvents(){return this.events}getGridId(){return this.gridId}getDisplayData(){return this.state.displayData}getVirtualState(){return this.virtualState}emitEvent(e,...i){const s=this.events[e];s&&s(...i)}isBlockSelecting(){return this.blockSelecting!==null}showTooltip(e,i,s,o){this.tooltip&&this.tooltip.show(e,i,s,o)}hideTooltip(){this.tooltip&&this.tooltip.hide()}setFixedOptions(e){var n,t;const i=this.options.fixedOptions||{colCount:0,rightCount:0},s={colCount:e.colCount??((n=this.options.fixedOptions)==null?void 0:n.colCount)??0,rightCount:e.rightCount??((t=this.options.fixedOptions)==null?void 0:t.rightCount)??0},o=(i.colCount||0)===0&&s.colCount>0||(i.colCount||0)>0&&s.colCount===0||(i.rightCount||0)===0&&s.rightCount>0||(i.rightCount||0)>0&&s.rightCount===0;this.options.fixedOptions=s,this.invalidateColumnCache(),o&&this.rebuildDOM(),this.render()}rebuildDOM(){var s,o;const e=((s=this.bodyElement)==null?void 0:s.scrollTop)||0,i=((o=this.bodyElement)==null?void 0:o.scrollLeft)||0;this.detachEvents(),this.build(),this.attachEvents(),this.bodyElement&&(this.bodyElement.scrollTop=e,this.bodyElement.scrollLeft=i),this.fixedRightBody&&(this.fixedRightBody.scrollTop=e)}getFixedOptions(){return this.options.fixedOptions||{colCount:0,rightCount:0}}getRowState(e){const i=this.state.displayData[e];return i&&this.state.rowStates.get(i)||"none"}getRowStateByData(e){return this.state.rowStates.get(e)||"none"}setRowState(e,i){const s=this.state.displayData[e];s&&(this.state.rowStates.set(s,i),this.render())}getChanges(){const e=[],i=[],s=[];return this.state.rowStates.forEach((o,n)=>{o==="created"?e.push(n):o==="updated"?i.push(n):o==="deleted"&&s.push(n)}),{created:e,updated:i,deleted:s}}getCreatedRows(){const e=[];return this.state.rowStates.forEach((i,s)=>{i==="created"&&e.push(s)}),e}getUpdatedRows(){const e=[];return this.state.rowStates.forEach((i,s)=>{i==="updated"&&e.push(s)}),e}getDeletedRows(){const e=[];return this.state.rowStates.forEach((i,s)=>{i==="deleted"&&e.push(s)}),e}clearRowStates(){this.state.rowStates.clear(),this.state.data.forEach(e=>{this.state.rowStates.set(e,"none")}),this.render()}commit(){const e=[];this.state.rowStates.forEach((i,s)=>{i==="createAndDeleted"&&e.push(s)}),e.forEach(i=>{const s=this.state.data.indexOf(i);s>=0&&this.state.data.splice(s,1)}),this.state.rowStates.clear(),this.state.data.forEach(i=>{this.state.rowStates.set(i,"none")}),this.rebuildDataIndexMap(),this.applyDataTransformations(),this.render()}isRemoteDataSource(){var e;return((e=this.options.dataSource)==null?void 0:e.type)==="remote"}getPaginationState(){return{...this.state.pagination}}goToPage(e){var o,n;const{totalPages:i}=this.state.pagination,s=Math.max(1,Math.min(e,i||1));s===this.state.pagination.currentPage&&this.state.displayData.length>0||(this.state.pagination.currentPage=s,this.isRemoteDataSource()?this.fetchData():(this.applyLocalPagination(),this.render()),(n=(o=this.events).onPageChange)==null||n.call(o,s,this.state.pagination.pageSize))}setPageSize(e){var i,s;e<1||e===this.state.pagination.pageSize||(this.state.pagination.pageSize=e,this.state.pagination.currentPage=1,this.updateTotalPages(),this.isRemoteDataSource()?this.fetchData():(this.applyLocalPagination(),this.render()),(s=(i=this.events).onPageSizeChange)==null||s.call(i,e))}async fetchData(){const e=this.options.dataSource;if(!(e!=null&&e.fetch))return;const i={page:this.state.pagination.currentPage,pageSize:this.state.pagination.pageSize,sort:this.state.sort.length>0?this.state.sort:void 0,filter:this.state.filter};this.state.pagination.loading=!0,this.setLoading(!0);try{const s=await e.fetch(i);this.state.data=s.data.map(o=>({...o})),this.state.displayData=this.state.data,this.state.pagination.totalCount=s.totalCount,this.updateTotalPages(),this.state.rowStates.clear(),this.state.data.forEach(o=>{this.state.rowStates.set(o,"none")}),this.rebuildDataIndexMap(),this.summary.invalidateCache(),this.clearSelectionState()}catch(s){console.error("VeloxGrid: fetchData error",s)}finally{this.state.pagination.loading=!1,this.setLoading(!1),this.render()}}updateTotalPages(){const{pageSize:e,totalCount:i}=this.state.pagination;this.state.pagination.totalPages=Math.max(1,Math.ceil(i/e))}applyLocalPagination(){let e=[...this.state.data];if(this.state.filter&&(e=V(e,this.state.filter)),this.state.sort.length>0){const n={};this.state.columns.forEach(t=>{n[t.field]=t.type||"text"}),e=O(e,this.state.sort,n)}this.state.pagination.totalCount=e.length,this.updateTotalPages();const{currentPage:i,pageSize:s}=this.state.pagination,o=(i-1)*s;this.state.displayData=e.slice(o,o+s),this.initCheckableRows()}checkInfiniteScroll(){const e=this.options.pagination;if(!(e!=null&&e.enabled)||e.mode!=="infinite"||this.infiniteScrollLoading||this.infiniteScrollAllLoaded)return;const i=e.infiniteScrollThreshold||100,{scrollTop:s,scrollHeight:o,clientHeight:n}=this.bodyElement;o-s-n<=i&&this.loadNextPage()}async loadNextPage(){const{currentPage:e,totalPages:i}=this.state.pagination;if(e>=i){this.infiniteScrollAllLoaded=!0,this.renderInfiniteScrollStatus();return}if(this.infiniteScrollLoading=!0,this.state.pagination.currentPage++,this.renderInfiniteScrollStatus(),this.isRemoteDataSource()){const s=this.options.dataSource;if(!(s!=null&&s.fetch))return;const o={page:this.state.pagination.currentPage,pageSize:this.state.pagination.pageSize,sort:this.state.sort.length>0?this.state.sort:void 0,filter:this.state.filter};try{const n=await s.fetch(o),t=n.data.map(l=>({...l}));this.state.data.push(...t),this.state.displayData=[...this.state.data],this.state.pagination.totalCount=n.totalCount,this.updateTotalPages(),t.forEach(l=>this.state.rowStates.set(l,"none")),this.rebuildDataIndexMap(),this.summary.invalidateCache(),this.state.pagination.currentPage>=this.state.pagination.totalPages&&(this.infiniteScrollAllLoaded=!0)}catch(n){console.error("VeloxGrid: infinite scroll fetch error",n),this.state.pagination.currentPage--}}else this.applyLocalInfiniteScroll();this.infiniteScrollLoading=!1,this.render()}applyLocalInfiniteScroll(){let e=[...this.state.data];if(this.state.filter&&(e=V(e,this.state.filter)),this.state.sort.length>0){const n={};this.state.columns.forEach(t=>{n[t.field]=t.type||"text"}),e=O(e,this.state.sort,n)}const{currentPage:i,pageSize:s}=this.state.pagination,o=i*s;this.state.displayData=e.slice(0,o),o>=e.length&&(this.infiniteScrollAllLoaded=!0),this.initCheckableRows()}renderInfiniteScrollStatus(){if(this.paginationContainer){if(this.paginationContainer.innerHTML="",this.infiniteScrollLoading){const e=p("div","velox-infinite-status");e.textContent="Loading...",this.paginationContainer.appendChild(e)}else if(this.infiniteScrollAllLoaded){const e=p("div","velox-infinite-status velox-infinite-status--done"),{totalCount:i}=this.state.pagination;e.textContent=`All ${i.toLocaleString()} items loaded`,this.paginationContainer.appendChild(e)}}}renderPagination(){var g;if(!this.paginationContainer)return;if(((g=this.options.pagination)==null?void 0:g.mode)==="infinite"){this.renderInfiniteScrollStatus();return}const{currentPage:e,totalPages:i,totalCount:s,pageSize:o}=this.state.pagination,n=this.options.pagination,t=(n==null?void 0:n.maxPageButtons)||5;if(this.paginationContainer.innerHTML="",(n==null?void 0:n.showInfo)!==!1){const d=p("div","velox-pagination-info"),f=(e-1)*o+1,C=Math.min(e*o,s);d.textContent=s>0?`${f}-${C} / ${s.toLocaleString()}`:"0 items",this.paginationContainer.appendChild(d)}const l=p("div","velox-pagination-nav");l.appendChild(this.createPageButton("ยซ",1,e===1)),l.appendChild(this.createPageButton("โ€น",e-1,e===1));const a=Math.floor(t/2);let r=Math.max(1,e-a);const h=Math.min(i,r+t-1);if(h-r+1<t&&(r=Math.max(1,h-t+1)),r>1&&(l.appendChild(this.createPageButton("1",1,!1)),r>2)){const d=p("span","velox-pagination-ellipsis");d.textContent="โ€ฆ",l.appendChild(d)}for(let d=r;d<=h;d++){const f=this.createPageButton(String(d),d,!1);d===e&&w(f,"velox-pagination-btn--active"),l.appendChild(f)}if(h<i){if(h<i-1){const d=p("span","velox-pagination-ellipsis");d.textContent="โ€ฆ",l.appendChild(d)}l.appendChild(this.createPageButton(String(i),i,!1))}if(l.appendChild(this.createPageButton("โ€บ",e+1,e===i)),l.appendChild(this.createPageButton("ยป",i,e===i)),this.paginationContainer.appendChild(l),n!=null&&n.showSizeChanger){const d=p("div","velox-pagination-sizer"),f=document.createElement("select");f.className="velox-pagination-select",(n.pageSizeOptions||[10,20,50,100]).forEach(x=>{const b=document.createElement("option");b.value=String(x),b.textContent=`${x} / page`,x===o&&(b.selected=!0),f.appendChild(b)}),f.addEventListener("change",()=>{this.setPageSize(Number(f.value))}),d.appendChild(f),this.paginationContainer.appendChild(d)}}createPageButton(e,i,s){const o=p("button","velox-pagination-btn");return o.textContent=e,s?(o.setAttribute("disabled","true"),w(o,"velox-pagination-btn--disabled")):o.addEventListener("click",()=>this.goToPage(i)),o}destroy(){var e,i;this.dragManager.destroy(),this.detachEvents(),document.removeEventListener("mouseup",this.boundHandleBlockSelectionEnd),this.closeFilterPopup(),this.closeColumnMenu(),this.rootElement.removeEventListener("keydown",this.boundHandleKeyDown),this.measureCanvas=null,this.measureContext=null,this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),this.container.innerHTML="",(i=(e=this.events).onDestroy)==null||i.call(e)}}const Ot=k.defineComponent({__name:"VeloxGridVue",props:{columns:{},data:{default:()=>[]},width:{},height:{},rowHeight:{default:40},headerHeight:{default:44},showRowNumbers:{type:[Boolean,Object],default:!1},rowDraggable:{type:[Boolean,Object],default:!1},selectable:{type:Boolean,default:!0},selectionMode:{},selectionStyle:{},showCheckbox:{type:Boolean},checkBar:{},sortable:{type:Boolean,default:!0},filterable:{type:Boolean,default:!1},editable:{type:Boolean,default:!1},resizable:{type:Boolean,default:!0},virtualScroll:{type:Boolean,default:!0},bufferSize:{default:10},theme:{default:"default"},locale:{},emptyMessage:{default:"No data"},loading:{type:Boolean,default:!1},loadingMessage:{},className:{},undoable:{type:Boolean},undoStackSize:{},contextMenu:{},footerSummary:{},groupSummary:{},fixedOptions:{},dataSource:{},pagination:{},wrapperClass:{}},emits:["data-change","row-add","row-remove","row-update","selection-change","row-select","all-select","cell-click","cell-double-click","row-click","row-double-click","cell-select","cell-selection-change","check-change","check-all-change","sort","filter","cell-edit-start","cell-edit-end","cell-edit-cancel","validation-error","copy","paste","cut","key-down","undo","redo","scroll","column-resize","column-reorder","ready","destroy","page-change","page-size-change"],setup(c,{expose:e,emit:i}){const s=c,o=i,n=k.ref(null);let t=null;function l(){const{wrapperClass:u,...v}=s;return{...v,...{onDataChange:(...m)=>o("data-change",...m),onRowAdd:(...m)=>o("row-add",...m),onRowRemove:(...m)=>o("row-remove",...m),onRowUpdate:(...m)=>o("row-update",...m),onSelectionChange:(...m)=>o("selection-change",...m),onRowSelect:(...m)=>o("row-select",...m),onAllSelect:(...m)=>o("all-select",...m),onCellClick:(...m)=>o("cell-click",...m),onCellDoubleClick:(...m)=>o("cell-double-click",...m),onRowClick:(...m)=>o("row-click",...m),onRowDoubleClick:(...m)=>o("row-double-click",...m),onCellSelect:(...m)=>o("cell-select",...m),onCellSelectionChange:(...m)=>o("cell-selection-change",...m),onCheckChange:(...m)=>o("check-change",...m),onCheckAllChange:(...m)=>o("check-all-change",...m),onSort:(...m)=>o("sort",...m),onFilter:(...m)=>o("filter",...m),onCellEditStart:(...m)=>o("cell-edit-start",...m),onCellEditEnd:(...m)=>o("cell-edit-end",...m),onCellEditCancel:(...m)=>o("cell-edit-cancel",...m),onValidationError:(...m)=>o("validation-error",...m),onCopy:(...m)=>o("copy",...m),onPaste:(...m)=>o("paste",...m),onCut:(...m)=>o("cut",...m),onKeyDown:(...m)=>o("key-down",...m),onUndo:(...m)=>o("undo",...m),onRedo:(...m)=>o("redo",...m),onScroll:(...m)=>o("scroll",...m),onColumnResize:(...m)=>o("column-resize",...m),onColumnReorder:(...m)=>o("column-reorder",...m),onReady:(...m)=>o("ready",...m),onDestroy:()=>o("destroy"),onPageChange:(...m)=>o("page-change",...m),onPageSizeChange:(...m)=>o("page-size-change",...m)}}}k.onMounted(()=>{n.value&&(t=new U(n.value,l()))}),k.onUnmounted(()=>{t&&(t.destroy(),t=null)}),k.watch(()=>s.data,u=>{t&&u&&t.setData(u)}),k.watch(()=>s.columns,u=>{t&&u&&t.setColumns(u)}),k.watch(()=>s.loading,u=>{t&&u!==void 0&&t.setOptions({loading:u})});function a(){return t}function r(){t==null||t.destroy()}function h(){t==null||t.refresh()}function g(){return(t==null?void 0:t.getData())??[]}function d(u){t==null||t.setData(u)}function f(u){return(t==null?void 0:t.getRow(u))??null}function C(u,v){t==null||t.addRow(u,v)}function x(u,v){t==null||t.updateRow(u,v)}function b(u){t==null||t.removeRow(u)}function y(){t==null||t.clearData()}function S(){return(t==null?void 0:t.getSelectedRows())??[]}function E(){return(t==null?void 0:t.getSelectedData())??[]}function D(u,v){t==null||t.selectRow(u,v)}function N(u){t==null||t.selectAll(u)}function L(){t==null||t.clearSelection()}function M(u){return(t==null?void 0:t.isRowSelected(u))??!1}function T(u,v,P){t==null||t.selectCell(u,v,P)}function B(){return(t==null?void 0:t.getSelectedCells())??[]}function F(u,v){t==null||t.setFocusedCell(u,v)}function j(){return(t==null?void 0:t.getFocusedCell())??null}function X(u){t==null||t.setSelection(u)}function G(){return(t==null?void 0:t.getSelection())??null}function J(){return(t==null?void 0:t.getSelectionData())??[]}function Y(u,v){t==null||t.checkItem(u,v)}function Q(u,v){t==null||t.checkItems(u,v)}function Z(u){t==null||t.checkAll(u)}function I(){t==null||t.uncheckAll()}function ee(){return(t==null?void 0:t.getCheckedItems())??[]}function te(){return(t==null?void 0:t.getCheckedData())??[]}function ie(u){return(t==null?void 0:t.isItemChecked(u))??!1}function se(u){return(t==null?void 0:t.isItemCheckable(u))??!1}function oe(u,v){t==null||t.checkRow(u,v)}function ne(){return(t==null?void 0:t.getCheckedRows())??[]}function le(u,v){t==null||t.sort(u,v)}function ae(){t==null||t.clearSort()}function re(){return(t==null?void 0:t.getSortState())??[]}function de(u){t==null||t.filter(u)}function ce(){t==null||t.clearFilter()}function he(){return(t==null?void 0:t.getFilterState())??null}function ue(u,v){t==null||t.startEdit(u,v)}function fe(u){t==null||t.endEdit(u)}function pe(){t==null||t.cancelEdit()}function me(){return(t==null?void 0:t.isEditing())??!1}function ge(u){return(t==null?void 0:t.getColumn(u))??null}function Ce(u,v){t==null||t.setColumnWidth(u,v)}function xe(u){t==null||t.showColumn(u)}function ye(u){t==null||t.hideColumn(u)}function ve(u){t==null||t.setColumns(u)}function we(u){t==null||t.autoFitColumn(u)}function be(){t==null||t.autoFitAllColumns()}function Se(u){t==null||t.scrollToRow(u)}function Ee(){t==null||t.scrollToTop()}function ke(){t==null||t.scrollToBottom()}function Re(u,v){t==null||t.scrollToCell(u,v)}function De(){t==null||t.copy()}function Le(){t==null||t.paste()}function Te(){t==null||t.cut()}function Be(){return(t==null?void 0:t.undo())??!1}function Me(){return(t==null?void 0:t.redo())??!1}function Pe(){return(t==null?void 0:t.canUndo())??!1}function He(){return(t==null?void 0:t.canRedo())??!1}function Fe(){t==null||t.clearHistory()}function Oe(){t==null||t.deleteSelectedCells()}function Ve(){t==null||t.deleteSelectedRows()}function Ae(u){t==null||t.exportToExcel(u)}function Ne(u){return(t==null?void 0:t.exportToCSV(u))??""}function $e(u){t==null||t.downloadCSV(u)}function ze(u){return(t==null?void 0:t.exportToJSON(u))??"[]"}function _e(u){t==null||t.downloadJSON(u)}function We(u,v){return(t==null?void 0:t.importFromCSV(u,v))??{data:[],headers:[],errors:[]}}function Ke(u,v){return(t==null?void 0:t.importFromExcel(u,v))??Promise.resolve({data:[],headers:[],errors:[]})}function qe(){return(t==null?void 0:t.getRowCount())??0}function Ue(){return(t==null?void 0:t.getVisibleRowCount())??0}function je(u,v){return t==null?void 0:t.getCellValue(u,v)}function Xe(u,v,P){t==null||t.setCellValue(u,v,P)}function Ge(u){return t==null?void 0:t.getSummaryValue(u)}function Je(){return(t==null?void 0:t.getSummaryValues())??{}}function Ye(){t==null||t.refreshSummary()}function Qe(u){return(t==null?void 0:t.getRowState(u))??"none"}function Ze(u){return(t==null?void 0:t.getRowStateByData(u))??"none"}function Ie(u,v){t==null||t.setRowState(u,v)}function et(){return(t==null?void 0:t.getChanges())??{created:[],updated:[],deleted:[]}}function tt(){return(t==null?void 0:t.getCreatedRows())??[]}function it(){return(t==null?void 0:t.getUpdatedRows())??[]}function st(){return(t==null?void 0:t.getDeletedRows())??[]}function ot(){t==null||t.clearRowStates()}function nt(){t==null||t.commit()}function lt(u){t==null||t.setOptions(u)}function at(){return t==null?void 0:t.getOptions()}function rt(u){t==null||t.goToPage(u)}function dt(u){t==null||t.setPageSize(u)}function ct(){return(t==null?void 0:t.getPaginationState())??{currentPage:1,pageSize:20,totalCount:0,totalPages:0,loading:!1}}function ht(){return(t==null?void 0:t.fetchData())??Promise.resolve()}return e({getGridInstance:a,destroy:r,refresh:h,getData:g,setData:d,getRow:f,addRow:C,updateRow:x,removeRow:b,clearData:y,getSelectedRows:S,getSelectedData:E,selectRow:D,selectAll:N,clearSelection:L,isRowSelected:M,selectCell:T,getSelectedCells:B,setFocusedCell:F,getFocusedCell:j,setSelection:X,getSelection:G,getSelectionData:J,checkItem:Y,checkItems:Q,checkAll:Z,uncheckAll:I,getCheckedItems:ee,getCheckedData:te,isItemChecked:ie,isItemCheckable:se,checkRow:oe,getCheckedRows:ne,sort:le,clearSort:ae,getSortState:re,filter:de,clearFilter:ce,getFilterState:he,startEdit:ue,endEdit:fe,cancelEdit:pe,isEditing:me,getColumn:ge,setColumnWidth:Ce,showColumn:xe,hideColumn:ye,setColumns:ve,autoFitColumn:we,autoFitAllColumns:be,scrollToRow:Se,scrollToTop:Ee,scrollToBottom:ke,scrollToCell:Re,copy:De,paste:Le,cut:Te,undo:Be,redo:Me,canUndo:Pe,canRedo:He,clearHistory:Fe,deleteSelectedCells:Oe,deleteSelectedRows:Ve,exportToExcel:Ae,exportToCSV:Ne,downloadCSV:$e,exportToJSON:ze,downloadJSON:_e,importFromCSV:We,importFromExcel:Ke,getRowCount:qe,getVisibleRowCount:Ue,getCellValue:je,setCellValue:Xe,getSummaryValue:Ge,getSummaryValues:Je,refreshSummary:Ye,getRowState:Qe,getRowStateByData:Ze,setRowState:Ie,getChanges:et,getCreatedRows:tt,getUpdatedRows:it,getDeletedRows:st,clearRowStates:ot,commit:nt,setOptions:lt,getOptions:at,goToPage:rt,setPageSize:dt,getPaginationState:ct,fetchData:ht}),(u,v)=>(k.openBlock(),k.createElementBlock("div",{ref_key:"containerRef",ref:n,class:k.normalizeClass(c.wrapperClass)},null,2))}});function Vt(c){const e=k.ref(null),i=k.ref(null),s=k.ref(!1);return k.onMounted(()=>{e.value&&(i.value=new U(e.value,c),s.value=!0)}),k.onUnmounted(()=>{i.value&&(i.value.destroy(),i.value=null,s.value=!1)}),{containerRef:e,grid:i,isReady:s}}exports.VeloxGridVue=Ot;exports.useVeloxGrid=Vt;
7
+ //# sourceMappingURL=index.js.map