@guiexpert/preact-table 10.1.77 → 10.1.78

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 (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -34,7 +34,7 @@
34
34
  <sheetView tabSelected="1" workbookViewId="0"/></sheetViews>
35
35
  <sheetFormatPr baseColWidth="10" defaultRowHeight="16" x14ac:dyDescent="0.2"/>
36
36
  <sheetData>`);for(let o=0;o<e.length;o++){const s=e[o];t.push('<row r="${r + 1}" spans="1:2" x14ac:dyDescent="0.2">');for(let i=0;i<s.length;i++){const r=s[i],n=this.getCellAddress(o,i);if(typeof r=="number")t.push(`<c r="${n}"><v>${r}</v></c>`);else if(r instanceof Date){const l=r;t.push(`<c r="${n}" t="inlineStr"><is><t>${l.toISOString()}</t></is></c>`)}else{const l=r!=null?this.escapeXml(String(r)):"";t.push(`<c r="${n}" t="inlineStr"><is><t>${l}</t></is></c>`)}}t.push("</row>")}return t.push(""),t.push(""),t.push('</sheetData><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>'),t.push("</worksheet>"),t.join(`
37
- `)}escapeXml(e){return e==null?"":String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}getCellAddress(e,t){const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let s="";for(;t>=0;)s=o[t%26]+s,t=Math.floor(t/26)-1;return`${s}${e+1}`}createZip(e){const t=[];let o=0;const s=[];e.forEach((p,h)=>{const m=new TextEncoder().encode(h),u=new TextEncoder().encode(p),b=new Uint8Array(30+m.length),g=new DataView(b.buffer);b.set([80,75,3,4],0),g.setUint16(4,20,!0),g.setUint16(6,0,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,0,!0),g.setUint32(14,0,!0),g.setUint32(18,u.length,!0),g.setUint32(22,u.length,!0),g.setUint16(26,m.length,!0),g.setUint16(28,0,!0),b.set(m,30),t.push(b,u),s.push({path:h,offset:o,contentSize:u.length}),o+=b.length+u.length});const i=o;s.forEach(p=>{const h=new TextEncoder().encode(p.path),m=new Uint8Array(46+h.length),u=new DataView(m.buffer);m.set([80,75,1,2],0),u.setUint16(4,20,!0),u.setUint16(6,20,!0),u.setUint16(8,0,!0),u.setUint16(10,0,!0),u.setUint16(12,0,!0),u.setUint16(14,0,!0),u.setUint32(16,0,!0),u.setUint32(20,p.contentSize,!0),u.setUint32(24,p.contentSize,!0),u.setUint16(28,h.length,!0),u.setUint16(30,0,!0),u.setUint16(32,0,!0),u.setUint16(34,0,!0),u.setUint16(36,0,!0),u.setUint32(38,0,!0),u.setUint32(42,p.offset,!0),m.set(h,46),t.push(m),o+=m.length});const r=new Uint8Array(22),n=new DataView(r.buffer);r.set([80,75,5,6],0),n.setUint16(4,0,!0),n.setUint16(6,0,!0),n.setUint16(8,s.length,!0),n.setUint16(10,s.length,!0),n.setUint32(12,o-i,!0),n.setUint32(16,i,!0),n.setUint16(20,0,!0),t.push(r);const l=t.reduce((p,h)=>p+h.length,0),c=new Uint8Array(l);let d=0;for(const p of t)c.set(p,d),d+=p.length;return c}generateBuffer(e,t=""){const o=this.generateMap(e,t);return this.createZip(o)}}class Q extends Ye{constructor(e,t,o,s,i,r=new V,n=new dt){var d;if(super(e,t,new Be(o),s),this.eventListener=i,this.copyService=r,this.excelService=n,this.licenseManager=O.getInstance(),this.selectionService=new Qe(this),this.api=new $e(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,this.lastContextmenu=Date.now(),t.setTableScope(this),i||(this.eventListener=new se),(d=this.tableOptions)!=null&&d.autoRestoreOptions){const p=this.tableOptions.autoRestoreOptions,h=p.getStorageKeyFn;h&&(p.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new Ne(h)),p.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new Ge(h)),p.autoRestoreSortingState&&(this.storeSortingService=new Ue(h)))}this.mouseHandler=new He(this),this.inputHandler=new Je(this),this.resizeHandler=new ct(this,s.resizeEventDebounceDelay),this.shortcutService=new st(this),this.shortcutService.addListener(this.selectionService);const l=this.getSelectionModel?this.getSelectionModel():void 0;l&&l.addEventSelectionChangedListener(this);const c=this.getFocusModel?this.getFocusModel():void 0;c&&c.addEventFocusChangedListener(this)}static create(e,t,o=new Re,s=new se,i=new Ee,r=new V){return new Q(e,t,i,o,s,r)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[o,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(o,s)&&(this.clearSelection(),this.initRenderEditor(o,s))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,o=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,o).then(s=>this.copyService.copyContent(s))}return!1}updateModelValueAfterEdit(e,t,o,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,o,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(Z.createSingle(t,o)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;return this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition(),this}createGeMouseEvent(e){const t=new Y;if(t.originalEvent=e,e){const o=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(o),t.rowIndex=this.getNumberByAttr(o,"data-row-index"),t.columnIndex=this.getNumberByAttr(o,"data-col-index"),t.action=this.getStringByAttr(o,"data-ge-action"),t.areaIdent){const s=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=s.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const s=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,s)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e,t){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.lastDragFrom===this.dragTo&&this.lastDragTo===this.dragFrom||(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.lastDragFrom=this.dragFrom,this.lastDragTo=this.dragTo,this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())),t&&(this.adjustDraggingColumn(e,t.columnIndex,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&(this.hideDraggingColumn(),this.repaint()),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.firstDraggingRendering=!0,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){var o,s;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(o=e.originalEvent)==null||o.preventDefault(),(s=e.originalEvent)==null||s.stopImmediatePropagation();return}this.lastContextmenu=t,this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var o;const t=this.tableModel.getBodyModel();X(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(o=this.storeStateCollapsedExpandService)==null||o.collapsedStateAll(e))}toggleRowCheckbox(e,t,o){var l;const s=this.tableModel.getAreaModel(o),i=s.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";s.setRowChecked(e,r),this.repaint();const n=(l=s.rowSelectionModel)==null?void 0:l.getCheckedRows();this.eventListener.onCheckboxChanged(n||[])}onMouseClicked(e,t){let o=this.selectionService.onMouseClicked(e,t);if(!o&&this.getFocusModel){this.resetEditorRenderer();const s=this.getFocusModel();s&&(o=s.hasChanged(),s.clearChanged())}return o}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}publishGeMouseEvent(e){this.eventListener.onMouseClicked(e)}onFocusChanged(e){this.eventListener.onFocusChanged(e)}onSelectionChanged(e){this.eventListener.onSelectionChanged(e)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,o){var i,r;const s=this.tableModel.getColumnDef(o);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const n=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,l=s.sortState??"",c=n[(n.indexOf(l)+1)%n.length],d=new qe(o,c);this.tableModel.doSort([d])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(h=>h.sortState=""),s.sortState=c),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([d])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const s=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,s)}setSelectionModel(e,t=!1){const o=()=>e;this.tableOptions.getSelectionModel=o,this.getSelectionModel=o,this.selectionService.getSelectionModel=o,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e),console.info("####### !!!!!! *******, this.tableModel.columnDefs")),this.firstInit()}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const[s,i]=o.getFocus();return o.setFocus(s+t,i+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var o;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(o=this.mouseHandler.mouseEvent)==null?void 0:o.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const o=this.storeScrollPosStateService.getScrollOffset();o&&this.scrollViewport.scrollTo(...o)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const o=this.storeSortingService.getSortItems();o!=null&&o.length&&this.tableModel.getBodyModel().doSort(o)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const o=this.tableOptions.autoRestoreOptions,s=o.getRowId;if(o.autoRestoreCollapsedExpandedState&&s){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(X(r)){const n=r,l=r.getRowCount();for(let c=0;c<l;c++){const d=r.getRowByIndex(c);if(d)if(i.allExpanded)d.expanded=!0;else if(i.allCollapsed)d.expanded=!1;else{const p=s(d.data);i.mode==="expanded"?d.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p):i.mode==="collapsed"&&(d.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p))}}n.recalcVisibleTreeRows()}}}}calcAutoColumnWidths(){const e=this.tableModel.getBodyModel(),t=this.tableModel.getColumnCount(),o=(e==null?void 0:e.getRowCount())??0;if(!e)return console.warn("Body model is not available."),[];const s=new Array(t).fill(0);for(let i=0;i<o;i++)for(let r=0;r<t;r++){const n=e.getValueAt(i,r),l=(n==null?void 0:n.toString().length)||0;l>s[r]&&(s[r]=l)}return s.map(i=>Math.max(i*10,50))}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t)}autoResizeColumns(e=!0){const t=this.calcAutoColumnWidths();for(let o=0;o<t.length;o++){const s=t[o];this.tableModel.setColumnWidth(o,s)}e&&this.recalcWrappers()}recalcWrappers(){this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}reSort(){var t;let e=((t=this.storeSortingService)==null?void 0:t.getSortItems())??[];this.tableModel.doSort(e)}sort(e){this.tableModel.sort(e)}getDisplayedRowCount(){return this.displayedRowCount}ensureRowIsVisible(e){const t=this.firstVisibleRowIndex,o=this.firstVisibleRowIndex+this.displayedRowCount-1;return e<t?(this.scrollToIndex(0,e+2),!0):e>o?(this.scrollToIndex(0,e-2),!0):!1}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}}const $=class ${};$.themes=["light","combat","paper","blackboard"],$.vars={light:`html[data-theme="light"] {
37
+ `)}escapeXml(e){return e==null?"":String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}getCellAddress(e,t){const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let s="";for(;t>=0;)s=o[t%26]+s,t=Math.floor(t/26)-1;return`${s}${e+1}`}createZip(e){const t=[];let o=0;const s=[];e.forEach((p,h)=>{const m=new TextEncoder().encode(h),u=new TextEncoder().encode(p),b=new Uint8Array(30+m.length),g=new DataView(b.buffer);b.set([80,75,3,4],0),g.setUint16(4,20,!0),g.setUint16(6,0,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,0,!0),g.setUint32(14,0,!0),g.setUint32(18,u.length,!0),g.setUint32(22,u.length,!0),g.setUint16(26,m.length,!0),g.setUint16(28,0,!0),b.set(m,30),t.push(b,u),s.push({path:h,offset:o,contentSize:u.length}),o+=b.length+u.length});const i=o;s.forEach(p=>{const h=new TextEncoder().encode(p.path),m=new Uint8Array(46+h.length),u=new DataView(m.buffer);m.set([80,75,1,2],0),u.setUint16(4,20,!0),u.setUint16(6,20,!0),u.setUint16(8,0,!0),u.setUint16(10,0,!0),u.setUint16(12,0,!0),u.setUint16(14,0,!0),u.setUint32(16,0,!0),u.setUint32(20,p.contentSize,!0),u.setUint32(24,p.contentSize,!0),u.setUint16(28,h.length,!0),u.setUint16(30,0,!0),u.setUint16(32,0,!0),u.setUint16(34,0,!0),u.setUint16(36,0,!0),u.setUint32(38,0,!0),u.setUint32(42,p.offset,!0),m.set(h,46),t.push(m),o+=m.length});const r=new Uint8Array(22),n=new DataView(r.buffer);r.set([80,75,5,6],0),n.setUint16(4,0,!0),n.setUint16(6,0,!0),n.setUint16(8,s.length,!0),n.setUint16(10,s.length,!0),n.setUint32(12,o-i,!0),n.setUint32(16,i,!0),n.setUint16(20,0,!0),t.push(r);const l=t.reduce((p,h)=>p+h.length,0),c=new Uint8Array(l);let d=0;for(const p of t)c.set(p,d),d+=p.length;return c}generateBuffer(e,t=""){const o=this.generateMap(e,t);return this.createZip(o)}}class Q extends Ye{constructor(e,t,o,s,i,r=new V,n=new dt){var d;if(super(e,t,new Be(o),s),this.eventListener=i,this.copyService=r,this.excelService=n,this.licenseManager=O.getInstance(),this.selectionService=new Qe(this),this.api=new $e(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,this.lastContextmenu=Date.now(),t.setTableScope(this),i||(this.eventListener=new se),(d=this.tableOptions)!=null&&d.autoRestoreOptions){const p=this.tableOptions.autoRestoreOptions,h=p.getStorageKeyFn;h&&(p.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new Ne(h)),p.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new Ge(h)),p.autoRestoreSortingState&&(this.storeSortingService=new Ue(h)))}this.mouseHandler=new He(this),this.inputHandler=new Je(this),this.resizeHandler=new ct(this,s.resizeEventDebounceDelay),this.shortcutService=new st(this),this.shortcutService.addListener(this.selectionService);const l=this.getSelectionModel?this.getSelectionModel():void 0;l&&l.addEventSelectionChangedListener(this);const c=this.getFocusModel?this.getFocusModel():void 0;c&&c.addEventFocusChangedListener(this)}static create(e,t,o=new Re,s=new se,i=new Ee,r=new V){return new Q(e,t,i,o,s,r)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[o,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(o,s)&&(this.clearSelection(),this.initRenderEditor(o,s))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,o=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,o).then(s=>this.copyService.copyContent(s))}return!1}updateModelValueAfterEdit(e,t,o,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,o,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(Z.createSingle(t,o)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;return this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition(),this}createGeMouseEvent(e){const t=new Y;if(t.originalEvent=e,e){const o=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(o),t.rowIndex=this.getNumberByAttr(o,"data-row-index"),t.columnIndex=this.getNumberByAttr(o,"data-col-index"),t.action=this.getStringByAttr(o,"data-ge-action"),t.areaIdent){const s=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=s.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const s=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,s)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e,t){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.lastDragFrom===this.dragTo&&this.lastDragTo===this.dragFrom||(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.lastDragFrom=this.dragFrom,this.lastDragTo=this.dragTo,this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())),t&&(this.adjustDraggingColumn(e,t.columnIndex,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&(this.hideDraggingColumn(),this.repaint()),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.firstDraggingRendering=!0,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){var o,s;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(o=e.originalEvent)==null||o.preventDefault(),(s=e.originalEvent)==null||s.stopImmediatePropagation();return}this.lastContextmenu=t,this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var o;const t=this.tableModel.getBodyModel();X(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(o=this.storeStateCollapsedExpandService)==null||o.collapsedStateAll(e))}toggleRowCheckbox(e,t,o){var l;const s=this.tableModel.getAreaModel(o),i=s.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";s.setRowChecked(e,r),this.repaint();const n=(l=s.rowSelectionModel)==null?void 0:l.getCheckedRows();this.eventListener.onCheckboxChanged(n||[])}onMouseClicked(e,t){let o=this.selectionService.onMouseClicked(e,t);if(!o&&this.getFocusModel){this.resetEditorRenderer();const s=this.getFocusModel();s&&(o=s.hasChanged(),s.clearChanged())}return o}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}publishGeMouseEvent(e){this.eventListener.onMouseClicked(e)}onFocusChanged(e){this.eventListener.onFocusChanged(e)}onSelectionChanged(e){this.eventListener.onSelectionChanged(e)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,o){var i,r;const s=this.tableModel.getColumnDef(o);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const n=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,l=s.sortState??"",c=n[(n.indexOf(l)+1)%n.length],d=new qe(o,c);this.tableModel.doSort([d])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(h=>h.sortState=""),s.sortState=c),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([d])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const s=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,s)}setSelectionModel(e,t=!1){const o=()=>e;this.tableOptions.getSelectionModel=o,this.getSelectionModel=o,this.selectionService.getSelectionModel=o,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e),console.info("####### !!!!!! *******, this.tableModel.columnDefs")),this.firstInit()}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const[s,i]=o.getFocus();return o.setFocus(s+t,i+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var o;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(o=this.mouseHandler.mouseEvent)==null?void 0:o.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const o=this.storeScrollPosStateService.getScrollOffset();o&&this.scrollViewport.scrollTo(...o)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const o=this.storeSortingService.getSortItems();o!=null&&o.length&&this.tableModel.getBodyModel().doSort(o)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const o=this.tableOptions.autoRestoreOptions,s=o.getRowId;if(o.autoRestoreCollapsedExpandedState&&s){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(X(r)){const n=r,l=r.getRowCount();for(let c=0;c<l;c++){const d=r.getRowByIndex(c);if(d)if(i.allExpanded)d.expanded=!0;else if(i.allCollapsed)d.expanded=!1;else{const p=s(d.data);i.mode==="expanded"?d.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p):i.mode==="collapsed"&&(d.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p))}}n.recalcVisibleTreeRows()}}}}calcAutoColumnWidths(){const e=this.tableModel.getBodyModel(),t=this.tableModel.getColumnCount(),o=(e==null?void 0:e.getRowCount())??0;if(!e)return console.warn("Body model is not available."),[];const s=new Array(t).fill(0);for(let i=0;i<o;i++)for(let r=0;r<t;r++){const n=e.getValueAt(i,r),l=(n==null?void 0:n.toString().length)||0;l>s[r]&&(s[r]=l)}return s.map(i=>Math.max(i*10,50))}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t)}autoResizeColumns(e=!0){const t=this.calcAutoColumnWidths();for(let o=0;o<t.length;o++){const s=t[o];this.tableModel.setColumnWidth(o,s)}e&&this.recalcWrappers()}recalcWrappers(){this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}reSort(){var t;let e=((t=this.storeSortingService)==null?void 0:t.getSortItems())??[];this.tableModel.doSort(e)}sort(e){this.tableModel.sort(e)}getDisplayedRowCount(){return this.displayedRowCount}ensureRowIsVisible(e){const t=this.firstVisibleRowIndex,o=this.firstVisibleRowIndex+this.displayedRowCount-1;return e<t?(this.scrollToIndex(0,e+2),!0):e>o?(this.scrollToIndex(0,e+this.displayedRowCount-3),!0):!1}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}}const $=class ${};$.themes=["light","combat","paper","blackboard"],$.vars={light:`html[data-theme="light"] {
38
38
  --ge-table-bg: rgba(255,255,255, 0.5);
39
39
  --ge-table-header-west-bg: rgba(233, 233, 233, 0.5);
40
40
  --ge-table-header-center-bg: rgba(233, 233, 233, 0.5);
package/index.js CHANGED
@@ -3741,7 +3741,7 @@ class te extends tt {
3741
3741
  */
3742
3742
  ensureRowIsVisible(e) {
3743
3743
  const t = this.firstVisibleRowIndex, o = this.firstVisibleRowIndex + this.displayedRowCount - 1;
3744
- return e < t ? (this.scrollToIndex(0, e + 2), !0) : e > o ? (this.scrollToIndex(0, e - 2), !0) : !1;
3744
+ return e < t ? (this.scrollToIndex(0, e + 2), !0) : e > o ? (this.scrollToIndex(0, e + this.displayedRowCount - 3), !0) : !1;
3745
3745
  }
3746
3746
  getFirstVisibleRowIndex() {
3747
3747
  return this.firstVisibleRowIndex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/preact-table",
3
- "version": "10.1.77",
3
+ "version": "10.1.78",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "tslib": "^2.3.0",
21
21
  "preact": "^10.19.4",
22
- "@guiexpert/table": "^1.1.77"
22
+ "@guiexpert/table": "^1.1.78"
23
23
  },
24
24
  "devDependencies": {
25
25
  "react-scripts-ts": "^3.1.0",