@guiexpert/react-table 18.1.76 → 18.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.js +1 -1
- 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 s=0;s<e.length;s++){const o=e[s];t.push('<row r="${r + 1}" spans="1:2" x14ac:dyDescent="0.2">');for(let i=0;i<o.length;i++){const r=o[i],l=this.getCellAddress(s,i);if(typeof r=="number")t.push(`<c r="${l}"><v>${r}</v></c>`);else if(r instanceof Date){const a=r;t.push(`<c r="${l}" t="inlineStr"><is><t>${a.toISOString()}</t></is></c>`)}else{const a=r!=null?this.escapeXml(String(r)):"";t.push(`<c r="${l}" t="inlineStr"><is><t>${a}</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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}getCellAddress(e,t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let o="";for(;t>=0;)o=s[t%26]+o,t=Math.floor(t/26)-1;return`${o}${e+1}`}createZip(e){const t=[];let s=0;const o=[];e.forEach((h,d)=>{const u=new TextEncoder().encode(d),g=new TextEncoder().encode(h),b=new Uint8Array(30+u.length),f=new DataView(b.buffer);b.set([80,75,3,4],0),f.setUint16(4,20,!0),f.setUint16(6,0,!0),f.setUint16(8,0,!0),f.setUint16(10,0,!0),f.setUint16(12,0,!0),f.setUint32(14,0,!0),f.setUint32(18,g.length,!0),f.setUint32(22,g.length,!0),f.setUint16(26,u.length,!0),f.setUint16(28,0,!0),b.set(u,30),t.push(b,g),o.push({path:d,offset:s,contentSize:g.length}),s+=b.length+g.length});const i=s;o.forEach(h=>{const d=new TextEncoder().encode(h.path),u=new Uint8Array(46+d.length),g=new DataView(u.buffer);u.set([80,75,1,2],0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,0,!0),g.setUint16(14,0,!0),g.setUint32(16,0,!0),g.setUint32(20,h.contentSize,!0),g.setUint32(24,h.contentSize,!0),g.setUint16(28,d.length,!0),g.setUint16(30,0,!0),g.setUint16(32,0,!0),g.setUint16(34,0,!0),g.setUint16(36,0,!0),g.setUint32(38,0,!0),g.setUint32(42,h.offset,!0),u.set(d,46),t.push(u),s+=u.length});const r=new Uint8Array(22),l=new DataView(r.buffer);r.set([80,75,5,6],0),l.setUint16(4,0,!0),l.setUint16(6,0,!0),l.setUint16(8,o.length,!0),l.setUint16(10,o.length,!0),l.setUint32(12,s-i,!0),l.setUint32(16,i,!0),l.setUint16(20,0,!0),t.push(r);const a=t.reduce((h,d)=>h+d.length,0),n=new Uint8Array(a);let c=0;for(const h of t)n.set(h,c),c+=h.length;return n}generateBuffer(e,t=""){const s=this.generateMap(e,t);return this.createZip(s)}}class U extends we{constructor(e,t,s,o,i,r=new P,l=new Be){var c;if(super(e,t,new le(s),o),this.eventListener=i,this.copyService=r,this.excelService=l,this.licenseManager=k.getInstance(),this.selectionService=new Ae(this),this.api=new pe(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 Y),(c=this.tableOptions)!=null&&c.autoRestoreOptions){const h=this.tableOptions.autoRestoreOptions,d=h.getStorageKeyFn;d&&(h.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new ge(d)),h.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new ue(d)),h.autoRestoreSortingState&&(this.storeSortingService=new me(d)))}this.mouseHandler=new ce(this),this.inputHandler=new Ce(this),this.resizeHandler=new Le(this,o.resizeEventDebounceDelay),this.shortcutService=new Te(this),this.shortcutService.addListener(this.selectionService);const a=this.getSelectionModel?this.getSelectionModel():void 0;a&&a.addEventSelectionChangedListener(this);const n=this.getFocusModel?this.getFocusModel():void 0;n&&n.addEventFocusChangedListener(this)}static create(e,t,s=new oe,o=new Y,i=new te,r=new P){return new U(e,t,i,s,o,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[s,o]=t.getFocus();this.tableModel.getBodyModel().isEditable(s,o)&&(this.clearSelection(),this.initRenderEditor(s,o))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,s=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,s).then(o=>this.copyService.copyContent(o))}return!1}updateModelValueAfterEdit(e,t,s,o){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,s,o)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(z.createSingle(t,s)),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 _;if(t.originalEvent=e,e){const s=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(s),t.rowIndex=this.getNumberByAttr(s,"data-row-index"),t.columnIndex=this.getNumberByAttr(s,"data-col-index"),t.action=this.getStringByAttr(s,"data-ge-action"),t.areaIdent){const o=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=o.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const o=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,o)}}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 s,o;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(s=e.originalEvent)==null||s.preventDefault(),(o=e.originalEvent)==null||o.stopImmediatePropagation();return}this.lastContextmenu=t,this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var s;const t=this.tableModel.getBodyModel();V(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(s=this.storeStateCollapsedExpandService)==null||s.collapsedStateAll(e))}toggleRowCheckbox(e,t,s){var a;const o=this.tableModel.getAreaModel(s),i=o.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";o.setRowChecked(e,r),this.repaint();const l=(a=o.rowSelectionModel)==null?void 0:a.getCheckedRows();this.eventListener.onCheckboxChanged(l||[])}onMouseClicked(e,t){let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){this.resetEditorRenderer();const o=this.getFocusModel();o&&(s=o.hasChanged(),o.clearChanged())}return s}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,s){var i,r;const o=this.tableModel.getColumnDef(s);if(o!=null&&o.sortable&&o.sortable()){e.preventDefault(),e.stopPropagation();const l=o.sortStatesOrder?o.sortStatesOrder:this.tableOptions.sortOrder,a=o.sortState??"",n=l[(l.indexOf(a)+1)%l.length],c=new xe(s,n);this.tableModel.doSort([c])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(d=>d.sortState=""),o.sortState=n),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([c])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const o=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,o)}setSelectionModel(e,t=!1){const s=()=>e;this.tableOptions.getSelectionModel=s,this.getSelectionModel=s,this.selectionService.getSelectionModel=s,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 s=this.getFocusModel();if(s){const[o,i]=s.getFocus();return s.setFocus(o+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 s;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",(s=this.mouseHandler.mouseEvent)==null?void 0:s.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 s=this.storeScrollPosStateService.getScrollOffset();s&&this.scrollViewport.scrollTo(...s)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const s=this.storeSortingService.getSortItems();s!=null&&s.length&&this.tableModel.getBodyModel().doSort(s)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const s=this.tableOptions.autoRestoreOptions,o=s.getRowId;if(s.autoRestoreCollapsedExpandedState&&o){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(V(r)){const l=r,a=r.getRowCount();for(let n=0;n<a;n++){const c=r.getRowByIndex(n);if(c)if(i.allExpanded)c.expanded=!0;else if(i.allCollapsed)c.expanded=!1;else{const h=o(c.data);i.mode==="expanded"?c.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h):i.mode==="collapsed"&&(c.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h))}}l.recalcVisibleTreeRows()}}}}calcAutoColumnWidths(){const e=this.tableModel.getBodyModel(),t=this.tableModel.getColumnCount(),s=(e==null?void 0:e.getRowCount())??0;if(!e)return console.warn("Body model is not available."),[];const o=new Array(t).fill(0);for(let i=0;i<s;i++)for(let r=0;r<t;r++){const l=e.getValueAt(i,r),a=(l==null?void 0:l.toString().length)||0;a>o[r]&&(o[r]=a)}return o.map(i=>Math.max(i*10,50))}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t)}autoResizeColumns(e=!0){const t=this.calcAutoColumnWidths();for(let s=0;s<t.length;s++){const o=t[s];this.tableModel.setColumnWidth(s,o)}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,s=this.firstVisibleRowIndex+this.displayedRowCount-1;return e<t?(this.scrollToIndex(0,e),!0):e>s?(this.scrollToIndex(0,e-this.displayedRowCount+1),!0):!1}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}}const W=class W{};W.themes=["light","combat","paper","blackboard"],W.vars={light:`html[data-theme="light"] {
|
|
37
|
+
`)}escapeXml(e){return e==null?"":String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}getCellAddress(e,t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let o="";for(;t>=0;)o=s[t%26]+o,t=Math.floor(t/26)-1;return`${o}${e+1}`}createZip(e){const t=[];let s=0;const o=[];e.forEach((h,d)=>{const u=new TextEncoder().encode(d),g=new TextEncoder().encode(h),b=new Uint8Array(30+u.length),f=new DataView(b.buffer);b.set([80,75,3,4],0),f.setUint16(4,20,!0),f.setUint16(6,0,!0),f.setUint16(8,0,!0),f.setUint16(10,0,!0),f.setUint16(12,0,!0),f.setUint32(14,0,!0),f.setUint32(18,g.length,!0),f.setUint32(22,g.length,!0),f.setUint16(26,u.length,!0),f.setUint16(28,0,!0),b.set(u,30),t.push(b,g),o.push({path:d,offset:s,contentSize:g.length}),s+=b.length+g.length});const i=s;o.forEach(h=>{const d=new TextEncoder().encode(h.path),u=new Uint8Array(46+d.length),g=new DataView(u.buffer);u.set([80,75,1,2],0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,0,!0),g.setUint16(14,0,!0),g.setUint32(16,0,!0),g.setUint32(20,h.contentSize,!0),g.setUint32(24,h.contentSize,!0),g.setUint16(28,d.length,!0),g.setUint16(30,0,!0),g.setUint16(32,0,!0),g.setUint16(34,0,!0),g.setUint16(36,0,!0),g.setUint32(38,0,!0),g.setUint32(42,h.offset,!0),u.set(d,46),t.push(u),s+=u.length});const r=new Uint8Array(22),l=new DataView(r.buffer);r.set([80,75,5,6],0),l.setUint16(4,0,!0),l.setUint16(6,0,!0),l.setUint16(8,o.length,!0),l.setUint16(10,o.length,!0),l.setUint32(12,s-i,!0),l.setUint32(16,i,!0),l.setUint16(20,0,!0),t.push(r);const a=t.reduce((h,d)=>h+d.length,0),n=new Uint8Array(a);let c=0;for(const h of t)n.set(h,c),c+=h.length;return n}generateBuffer(e,t=""){const s=this.generateMap(e,t);return this.createZip(s)}}class U extends we{constructor(e,t,s,o,i,r=new P,l=new Be){var c;if(super(e,t,new le(s),o),this.eventListener=i,this.copyService=r,this.excelService=l,this.licenseManager=k.getInstance(),this.selectionService=new Ae(this),this.api=new pe(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 Y),(c=this.tableOptions)!=null&&c.autoRestoreOptions){const h=this.tableOptions.autoRestoreOptions,d=h.getStorageKeyFn;d&&(h.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new ge(d)),h.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new ue(d)),h.autoRestoreSortingState&&(this.storeSortingService=new me(d)))}this.mouseHandler=new ce(this),this.inputHandler=new Ce(this),this.resizeHandler=new Le(this,o.resizeEventDebounceDelay),this.shortcutService=new Te(this),this.shortcutService.addListener(this.selectionService);const a=this.getSelectionModel?this.getSelectionModel():void 0;a&&a.addEventSelectionChangedListener(this);const n=this.getFocusModel?this.getFocusModel():void 0;n&&n.addEventFocusChangedListener(this)}static create(e,t,s=new oe,o=new Y,i=new te,r=new P){return new U(e,t,i,s,o,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[s,o]=t.getFocus();this.tableModel.getBodyModel().isEditable(s,o)&&(this.clearSelection(),this.initRenderEditor(s,o))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,s=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,s).then(o=>this.copyService.copyContent(o))}return!1}updateModelValueAfterEdit(e,t,s,o){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,s,o)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(z.createSingle(t,s)),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 _;if(t.originalEvent=e,e){const s=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(s),t.rowIndex=this.getNumberByAttr(s,"data-row-index"),t.columnIndex=this.getNumberByAttr(s,"data-col-index"),t.action=this.getStringByAttr(s,"data-ge-action"),t.areaIdent){const o=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=o.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const o=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,o)}}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 s,o;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(s=e.originalEvent)==null||s.preventDefault(),(o=e.originalEvent)==null||o.stopImmediatePropagation();return}this.lastContextmenu=t,this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var s;const t=this.tableModel.getBodyModel();V(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(s=this.storeStateCollapsedExpandService)==null||s.collapsedStateAll(e))}toggleRowCheckbox(e,t,s){var a;const o=this.tableModel.getAreaModel(s),i=o.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";o.setRowChecked(e,r),this.repaint();const l=(a=o.rowSelectionModel)==null?void 0:a.getCheckedRows();this.eventListener.onCheckboxChanged(l||[])}onMouseClicked(e,t){let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){this.resetEditorRenderer();const o=this.getFocusModel();o&&(s=o.hasChanged(),o.clearChanged())}return s}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,s){var i,r;const o=this.tableModel.getColumnDef(s);if(o!=null&&o.sortable&&o.sortable()){e.preventDefault(),e.stopPropagation();const l=o.sortStatesOrder?o.sortStatesOrder:this.tableOptions.sortOrder,a=o.sortState??"",n=l[(l.indexOf(a)+1)%l.length],c=new xe(s,n);this.tableModel.doSort([c])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(d=>d.sortState=""),o.sortState=n),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([c])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const o=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,o)}setSelectionModel(e,t=!1){const s=()=>e;this.tableOptions.getSelectionModel=s,this.getSelectionModel=s,this.selectionService.getSelectionModel=s,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 s=this.getFocusModel();if(s){const[o,i]=s.getFocus();return s.setFocus(o+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 s;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",(s=this.mouseHandler.mouseEvent)==null?void 0:s.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 s=this.storeScrollPosStateService.getScrollOffset();s&&this.scrollViewport.scrollTo(...s)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const s=this.storeSortingService.getSortItems();s!=null&&s.length&&this.tableModel.getBodyModel().doSort(s)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const s=this.tableOptions.autoRestoreOptions,o=s.getRowId;if(s.autoRestoreCollapsedExpandedState&&o){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(V(r)){const l=r,a=r.getRowCount();for(let n=0;n<a;n++){const c=r.getRowByIndex(n);if(c)if(i.allExpanded)c.expanded=!0;else if(i.allCollapsed)c.expanded=!1;else{const h=o(c.data);i.mode==="expanded"?c.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h):i.mode==="collapsed"&&(c.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h))}}l.recalcVisibleTreeRows()}}}}calcAutoColumnWidths(){const e=this.tableModel.getBodyModel(),t=this.tableModel.getColumnCount(),s=(e==null?void 0:e.getRowCount())??0;if(!e)return console.warn("Body model is not available."),[];const o=new Array(t).fill(0);for(let i=0;i<s;i++)for(let r=0;r<t;r++){const l=e.getValueAt(i,r),a=(l==null?void 0:l.toString().length)||0;a>o[r]&&(o[r]=a)}return o.map(i=>Math.max(i*10,50))}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t)}autoResizeColumns(e=!0){const t=this.calcAutoColumnWidths();for(let s=0;s<t.length;s++){const o=t[s];this.tableModel.setColumnWidth(s,o)}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,s=this.firstVisibleRowIndex+this.displayedRowCount-1;return e<t?(this.scrollToIndex(0,e+2),!0):e>s?(this.scrollToIndex(0,e-2),!0):!1}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}}const W=class W{};W.themes=["light","combat","paper","blackboard"],W.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
|
@@ -3739,7 +3739,7 @@ class U extends xe {
|
|
|
3739
3739
|
*/
|
|
3740
3740
|
ensureRowIsVisible(e) {
|
|
3741
3741
|
const t = this.firstVisibleRowIndex, s = this.firstVisibleRowIndex + this.displayedRowCount - 1;
|
|
3742
|
-
return e < t ? (this.scrollToIndex(0, e), !0) : e > s ? (this.scrollToIndex(0, e -
|
|
3742
|
+
return e < t ? (this.scrollToIndex(0, e + 2), !0) : e > s ? (this.scrollToIndex(0, e - 2), !0) : !1;
|
|
3743
3743
|
}
|
|
3744
3744
|
getFirstVisibleRowIndex() {
|
|
3745
3745
|
return this.firstVisibleRowIndex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/react-table",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.77",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"tslib": "^2.3.0",
|
|
21
21
|
"react": "18.2.0",
|
|
22
22
|
"react-dom": "18.2.0",
|
|
23
|
-
"@guiexpert/table": "^1.1.
|
|
23
|
+
"@guiexpert/table": "^1.1.77"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@vitejs/plugin-react": "^4.1.1",
|