@guiexpert/table 1.1.50 → 1.1.55

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 CHANGED
@@ -302,7 +302,7 @@ export class ${t} implements CellRendererIf {
302
302
  --ge-table-column-resize-handle-border: oklch(0% 0 0);
303
303
  --ge-table-dragged-col-div-bg: #2c2e33;
304
304
  --ge-table-drop-zone-bg: #758129;
305
- }`};let me=re;class be{constructor(e,t=!0,s,o,i=0,r=!1,n=!1){this.data=e,this.expanded=t,this.children=s,this.parent=o,this.deep=i,this.checked=r,this.keep=n,this.type="TreeRow"}}class oe{static buildTreeRows(e,t="children",s=12){const o=[];for(const i of e)o.push(oe.buildTreeRow(i,t,void 0,0,s));return o}static buildTreeRow(e,t="children",s=new be(e,!0,[],void 0,0),o=0,i=12){var n;if(o>i)return console.warn("Max deep limit reached: ",o),s;const r=e[t];if(r)for(const l of r){const a=new be(l,!0,[],s,o+1);if((n=s.children)==null||n.push(a),oe.buildTreeRow(l,t,a,o+1),o>i)return console.warn("Max deep limit reached: ",o),s}return s}}class N{constructor(e=34,t=34,s=34){this.header=e,this.body=t,this.footer=s}}class y{constructor(e=100,t="px"){this.value=e,this.unit=t}}const xt=()=>!0,ye=()=>!1;class H{constructor(e,t,s=new y(100,"px"),o=new M,i=new M,r=new y(100,"px"),n=new y(100,"px"),l,a,c,d,u,f,p,m,g=()=>this.visible){this.property=e,this.headerLabel=t,this.width=s,this.classes=o,this.rendererMap=i,this.minWidth=r,this.maxWidth=n,this.sortable=l,this.sortComparator=a,this.sortState=c,this.sortStatesOrder=d,this.sortIconVisible=u,this.editable=f,this.getEditRenderer=p,this.editInputPipe=m,this.isVisible=g,this.visible=!0,s.unit!=="px"&&(this.minWidth=new y(0,"px"),this.maxWidth=new y(1e5,"px"))}static bodyRenderer(e){return new M(void 0,e,void 0)}static create(e){const t=new M(e.headerRenderer,e.bodyRenderer,e.footerRenderer),s=new M(e.headerClasses,e.bodyClasses,e.footerClasses),o=e.sortIconVisible??e.sortable??ye,i=e.editable??e.editable??ye,r=e.isVisible??e.isVisible??xt;return new H(e.property??"",e.headerLabel??"",e.width??new y(100,"px"),s,t,e.minWidth??new y(100,"px"),e.maxWidth??new y(100,"px"),e.sortable,e.sortComparator,e.sortState,e.sortStatesOrder,o,i,e.getEditRenderer,e.editInputPipe,r)}}const Nt=new y(500,"px"),Gt=new y(400,"px"),St=new y(300,"px"),zt=new y(290,"px"),jt=new y(280,"px"),Yt=new y(270,"px"),Ut=new y(260,"px"),Kt=new y(250,"px"),Xt=new y(240,"px"),Jt=new y(230,"px"),qt=new y(220,"px"),Zt=new y(210,"px"),xe=new y(200,"px"),Qt=new y(190,"px"),es=new y(180,"px"),ts=new y(170,"px"),ss=new y(160,"px"),os=new y(150,"px"),is=new y(140,"px"),rs=new y(130,"px"),ns=new y(120,"px"),ls=new y(110,"px"),as=new y(100,"px"),cs=new y(90,"px"),ds=new y(80,"px"),hs=new y(70,"px"),us=new y(60,"px"),ps=new y(50,"px"),gs=new y(40,"px"),fs=new y(30,"px"),ms=new y(20,"px"),bs=new y(10,"px"),ys=new y(0,"px");class ue{constructor(e,t=[],s=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=s,this.rowSelectionModel=void 0,this.yPositions=[],this.cellRenderers=t.map(o=>o.rendererMap[e])}getTextValueAt(e,t){return""+this.getValueAt(e,t)}getTooltipAt(e,t){return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var s;const t=this.getRowByIndex(e);return(s=this.rowSelectionModel)==null?void 0:s.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const s=this.getRowByIndex(e);this.rowSelectionModel.checkRow(s,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){return this.defaultRowHeight>0?this.defaultRowHeight*e:this.yPositions[e]}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}isEditable(e,t){var o,i;const s=(o=this.columnDefs)==null?void 0:o[t];return((i=s==null?void 0:s.editable)==null?void 0:i.call(s))??!1}setValue(e,t,s){var n;const o=(n=this.columnDefs[t])==null?void 0:n.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e),r=this.columnDefs[t].property;return r.includes(".")?this.setPropertyValue(i,r.split("."),s):(i[r]=s,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,s){const o=t.shift();if(o){const i=e[o];return i&&t.length?this.setPropertyValue(i,t,s):(e[o]=s,!0)}return!1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}}class P extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.arr=t,this.defaultRowHeight=s,this.columnDefs=o,this.filteredArr=[...t]}externalFilterChanged(e){this.filteredArr=this.arr?this.arr.filter(e):[]}getRowCount(){return this.filteredArr?this.filteredArr.length:0}getValueAt(e,t){return this.filteredArr[e][t]}setValue(e,t,s){var i;const o=(i=this.columnDefs[t])==null?void 0:i.editInputPipe;return o&&(s=o(s,e,t)),this.arr[e][t]=s,!0}getRowByIndex(e){return this.filteredArr[e]}getRowHeight(e){return this.defaultRowHeight}changeColumnOrder(e,t){this.filteredArr.forEach(s=>this.arrayMove(s,e,t)),super.changeColumnOrder(e,t)}}class F{constructor(e="body"){this.areaIdent=e,this.rowSelectionModel=void 0}getRowCount(){return 0}getValueAt(e,t){return""}getTextValueAt(e,t){return""}getCellRenderer(e,t){}getRowHeight(e){return 0}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!1}isRowChecked(e){}setRowChecked(e,t){}getTooltipAt(e,t){return""}getMaxColspan(){return 0}getMaxRowspan(){return 0}getYPosByRowIndex(e){return 0}init(){}externalFilterChanged(e){}isFilterable(){return!1}doSort(e){return!1}isEditable(e,t){return!1}setValue(e,t,s){return!1}isSelectable(e,t){return!1}changeColumnOrder(e,t){}}class wt{flattenTree(e,t=[]){var s;for(const o of e)this.isVisible(o)&&t.push(o),(s=o.children)!=null&&s.length&&this.flattenTree(o.children,t);return t}isVisible(e){return e.parent?e.parent.expanded?this.isVisible(e.parent):!1:!0}}class Ct{genericSortComparator(e,t,s){if(typeof e=="number"&&typeof t=="number")return s*(e-t);if(typeof e=="string"&&typeof t=="string")return s*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return s*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return s*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const o=e,i=t;if(o.length&&i.length)return this.genericSortComparator(o[0],i[0],s)}return s*(""+e).localeCompare(""+t)}}class Se extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.type="AreaModelTree",this.sorterService=new Ct,this.service=new wt,this.properties=o.map(i=>i.property),this.flattenRows=this.service.flattenTree(t),this.filteredFlattenRows=[...this.flattenRows]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}recalcVisibleTreeRows(){this.filteredFlattenRows=this.service.flattenTree(this.rows)}getFilteredFlattenRows(){return this.filteredFlattenRows}getRowCount(){let e=0;for(const t of this.filteredFlattenRows)this.service.isVisible(t)&&e++;return e}getValueAt(e,t){const s=this.getRowByIndex(e);if(s){const o=this.properties[t];if(o)return o.includes(".")?this.getPropertyValue(s.data,o.split(".")):s.data[o]}return""}getRowHeight(e){return this.defaultRowHeight}getCustomClassesAt(e,t){return["ge-table-tree-cell","ge-table-tree-deep-"+this.filteredFlattenRows[e].deep]}getRowByIndex(e){return this.filteredFlattenRows[e]}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}externalFilterChanged(e){this.lastPredictFn=e,this.doFiltering()}doSort(e){const{columnIndex:t,sortState:s}=e[e.length-1],o=s==="asc"?1:s==="desc"?-1:0,i=this.properties[t];return this.treeSort(this.rows,i,o),this.flattenRows=this.service.flattenTree(this.rows),this.filteredFlattenRows=[...this.flattenRows],!0}toggleExpandCollapseAll(e){this.expandAllRecursive(this.rows,e),this.flattenRows=this.service.flattenTree(this.rows),this.doFiltering()}setAllParentsOk(e){return e.parent&&(e.parent.keep=!0,this.setAllParentsOk(e.parent)),!1}setValue(e,t,s){var r;const o=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e);if(i){const n=i.data,l=this.columnDefs[t].property;return l.includes(".")?this.setPropertyValue(n,l.split("."),s):(n[l]=s,!0)}return!1}genericTreeTableSortComparator(e,t){return(s,o)=>{const i=this.getValueByT(s.data,e),r=this.getValueByT(o.data,e);return this.sorterService.genericSortComparator(i,r,t)}}expandAllRecursive(e,t){for(const s of e)s.expanded=t,s.children&&this.expandAllRecursive(s.children,t)}doFiltering(){if(!this.lastPredictFn)this.filteredFlattenRows=[...this.flattenRows?this.flattenRows:[]];else{this.flattenRows||(this.flattenRows=[]);let e=0;this.flattenRows.forEach(s=>{e=Math.max(e,s.deep)});const t=this.flattenRows.filter((s,o,i)=>this.lastPredictFn(s,o,i));this.flattenRows.forEach(s=>s.keep=!1),this.flattenRows.forEach(s=>{t.includes(s)&&(s.keep=!0,this.setAllParentsOk(s))}),this.filteredFlattenRows=this.flattenRows.filter((s,o,i)=>s.keep)}}getPropertyValue(e,t){const s=t.shift();let o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}treeSort(e,t,s){e.sort(this.genericTreeTableSortComparator(t,s));for(const o of e)o.children&&this.treeSort(o.children,t,s)}}class we{constructor(e=[]){this.allRootNodes=e}checkRow(e,t){if(e.checked=t,e.children)for(const s of e.children)this.checkRow(s,t);this.autoCheckParent(e.parent)}checkAll(e){for(const t of this.allRootNodes)t.checked=!1,t.children&&this.checkAll(t.children)}getCheckedRows(){const e=[];return this.addSelectedRecursive(this.allRootNodes,e),e}isRowChecked(e){if(e.checked)return"full";const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);return!t&&!s?"semi":"none"}setCheckedRows(e){this.addCheckedRows(e)}addCheckedRows(e){for(const t of e)t.checked=!0}autoCheckParent(e){if(e){const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);t?e.checked=!0:e.checked=!1,this.autoCheckParent(e.parent)}}areAllChildrenChecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(!o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenChecked(o))return!1}return!0}areAllChildrenUnchecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenUnchecked(o))return!1}return!0}addSelectedRecursive(e,t){for(const s of e)s.checked&&t.push(s),s.children&&this.addSelectedRecursive(s.children,t)}}class Ce{constructor(e=0,t=0,s=0,o=0){this.top=e,this.right=t,this.bottom=s,this.left=o}}class vt{constructor(){this.checkedRows=[]}getCheckedRows(){return this.checkedRows}setCheckedRows(e){this.checkedRows=e}addCheckedRows(e){this.checkedRows||(this.checkedRows=[]);for(const t of e)this.checkedRows.includes(t)||this.checkedRows.push(t)}checkRow(e,t){this.checkedRows||(this.checkedRows=[]),t?this.checkedRows.includes(e)||this.checkedRows.push(e):this.removeSelectedRow(e)}isRowChecked(e){return this.checkedRows&&this.checkedRows.includes(e)?"full":"none"}checkAll(e){this.checkedRows=[]}removeSelectedRow(e){if(this.checkedRows){const t=this.checkedRows.indexOf(e);t>-1&&this.checkedRows.splice(t,1)}}}class Q{constructor(e,t,s,o=0,i=0,r=!1,n=new N,l=[],a=[],c=-1,d=0,u=400,f=()=>{}){var p,m,g,b;this.headerAreaModel=e,this.bodyAreaModel=t,this.footerAreaModel=s,this.fixedLeftColumnCount=o,this.fixedRightColumnCount=i,this.rowCheckboxVisible=r,this.defaultRowHeights=n,this.columnDefs=l,this.columnSizes=a,this.overridingColumnWidth=c,this.columnCount=d,this.parentSize=u,this.getSelectionModel=f,this.rowCount=0,this.contentHeightInPx=0,this.contentWidthInPx=0,this.padding=new Ce(0,0,0,0),this.xPositions=[],e.areaIdent="header",t.areaIdent="body",s.areaIdent="footer",this.columnCount||((p=this.columnDefs)!=null&&p.length?this.columnCount=this.columnDefs.length:(m=this.columnSizes)!=null&&m.length&&(this.columnCount=(g=this.columnSizes)==null?void 0:g.length)),(b=this.columnDefs)!=null&&b.length&&Xe(this.columnDefs[0])&&!t.rowSelectionModel&&(t.rowSelectionModel=new vt)}init(){this.recalcSize(this.parentSize),this.overridingColumnWidth===-1&&this.calcXPositions(),this.headerAreaModel&&this.headerAreaModel.init(),this.bodyAreaModel&&this.bodyAreaModel.init(),this.footerAreaModel&&this.footerAreaModel.init()}setParentWidth(e){this.parentSize=e}getColumnCount(){return this.columnCount}setColumnWidth(e,t){var s;t=Math.max(0,t),this.overridingColumnWidth!==-1&&(this.overridingColumnWidth=t),e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)&&(this.columnSizes[e]=t),this.recalcContentWidthInPx()}getColumnWidth(e){var s;const t=this.getColumnDef(e);return t&&t.isVisible&&!t.isVisible()?0:this.overridingColumnWidth!==-1?this.overridingColumnWidth:e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)?this.columnSizes[e]:0}getXPosByColumnIndex(e){return e===0?0:this.overridingColumnWidth>-1?this.overridingColumnWidth*e:this.xPositions[e]}recalcSize(e){this.recalcColumnWidths(e),this.recalcHeightAndPadding()}recalcHeightAndPadding(){const e=this.getAreaModel("body");this.rowCount=e.getRowCount(),this.contentHeightInPx=this.getAreaHeight("body"),this.recalcContentWidthInPx(),this.recalcPadding()}recalcPadding(){const e=this.getSideAreaWidth("west"),t=this.getSideAreaWidth("east"),s=this.getAreaHeight("header"),o=this.getAreaHeight("footer");this.padding=new Ce(s,t,o,e)}getPadding(){return this.padding}getContentHeightInPixel(){return this.contentHeightInPx}getContentWidthInPixel(){return this.contentWidthInPx}getRowHeight(e,t){return this.getAreaModel(e).getRowHeight(t)}getModel(e){return this.getAreaModel(e)}getAreaHeight(e){const t=this.getModel(e),s=t.getRowCount();if(this.defaultRowHeights[e])return s*this.defaultRowHeights[e];let o=0;for(let i=0;i<s;i++)o=o+t.getRowHeight(i);return o}getSideAreaWidth(e){const[t,s]=this.getSideStartAndEndColumnIndex(e);let o=0;for(let i=t;i<=s;i++)o=o+this.getColumnWidth(i);return o}getSideStartAndEndColumnIndex(e){const t=this.getFixedLeftColumnCount(),s=this.getFixedRightColumnCount();let o=0,i=this.columnCount-1;return e==="west"?i=t-1:e==="east"?o=this.columnCount-s:(o=t,i=this.columnCount-s-1),[o,i]}getColumnDef(e){if(e<this.columnDefs.length)return this.columnDefs[e]}getFixedLeftColumnCount(){return this.fixedLeftColumnCount}getFixedRightColumnCount(){return this.fixedRightColumnCount}getAreaModel(e){if(e==="header")return this.headerAreaModel;if(e==="body")return this.bodyAreaModel;if(e==="footer")return this.footerAreaModel;throw new Error("Wrong ident.")}getBodyModel(){return this.bodyAreaModel}isFooterVisibe(){var e;return(((e=this.footerAreaModel)==null?void 0:e.getRowCount())??0)>0}isHeaderVisibe(){var e;return(((e=this.headerAreaModel)==null?void 0:e.getRowCount())??0)>0}isRowCheckboxVisible(){return this.rowCheckboxVisible}externalFilterChanged(e){this.getAreaModel("body").externalFilterChanged(e)}doSort(e){return this.getAreaModel("body").doSort(e)}getColumnDefs(){return this.columnDefs}getColumnProperty(e){return this.columnDefs?this.columnDefs[e].property:""}getBodyRowByIndex(e){return this.getBodyModel().getRowByIndex(e)}isSortable(e){var t;if(this.columnDefs&&e<this.columnDefs.length){const s=(t=this.columnDefs[e])==null?void 0:t.sortable;if(typeof s=="function")return s()}return!1}changeColumnOrder(e,t){var s,o,i;this.arrayMove(this.columnDefs,e,t),this.arrayMove(this.columnSizes,e,t),(s=this.headerAreaModel)==null||s.changeColumnOrder(e,t),(o=this.bodyAreaModel)==null||o.changeColumnOrder(e,t),(i=this.footerAreaModel)==null||i.changeColumnOrder(e,t),this.calcXPositions()}recalcColumnWidths(e){var t,s,o;if(!((t=this.columnDefs)!=null&&t.length)&&!((s=this.columnSizes)!=null&&s.length)&&(this.columnSizes=new Array(this.getColumnCount()).fill(this.overridingColumnWidth)),(o=this.columnDefs)!=null&&o.length){const i=this.columnDefs.filter(l=>{var a;return((a=l.width)==null?void 0:a.unit)==="weight"});this.columnSizes=this.columnDefs.map(l=>{if(l.width.unit==="%"&&e){let a=Math.floor(l.width.value*e/100);if(l.minWidth){const c=this.sizeToPixel(l.minWidth,e);a=Math.max(c,a)}if(l.maxWidth){const c=this.sizeToPixel(l.maxWidth,e);a=Math.min(c,a)}return a}else if(l.width.unit==="px"&&e)return l.width.value;return 0});const r=this.columnSizes.reduce((l,a)=>l+a),n=e-r;if(n>0&&i.length){const l=i.map(a=>a.width.value).reduce((a,c)=>a+c);for(let a=0;a<this.columnDefs.length;a++){const c=this.columnDefs[a];c.width.unit==="weight"&&(this.columnSizes[a]=c.width.value*n/l)}}}}sizeToPixel(e,t){return e.unit==="px"?e.value:e.unit==="%"?Math.floor(e.value*t/100):-1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}recalcContentWidthInPx(){this.contentWidthInPx=this.getSideAreaWidth("center")}calcXPositions(){const e=this.getColumnCount();this.xPositions=new Array(e+1),this.xPositions[0]=0;for(let t=0;t<e;t++)this.xPositions[t+1]=this.getColumnWidth(t)+this.xPositions[t]}setTableScope(e){this.tableScope=e}getTableScope(){return this.tableScope}}class Rt extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.sorterService=new Ct,this.filteredRows=[...t],this.properties=o.map(i=>i.property)}setRows(e){this.rows=e,this.filteredRows=[...e]}filterRowsByPredict(e){this.rows=this.rows.filter(e),this.filteredRows=this.filteredRows.filter(e)}getRowCount(){var e;return((e=this.filteredRows)==null?void 0:e.length)??0}getValueAt(e,t){const s=this.properties[t];let o=this.filteredRows[e];return W(o)&&(o=o.data),o?this.getValueByT(o,s):""}getFilteredRows(){return this.filteredRows}getAllRows(){return this.rows}getRowHeight(e){return this.defaultRowHeight}getRowByIndex(e){return this.filteredRows[e]}externalFilterChanged(e){this.filteredRows=this.rows?this.rows.filter(e):[]}doSort(e){for(const t of e){const{columnIndex:s,sortState:o}=t,i=o==="asc"?1:o==="desc"?-1:0,r=this.properties[s];this.filteredRows=this.filteredRows.sort(this.genericFlatTableSortComparator(r,i))}return!0}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}genericFlatTableSortComparator(e,t){return(s,o)=>{const i=this.getValueByT(s,e),r=this.getValueByT(o,e);return this.sorterService.genericSortComparator(i,r,t)}}getPropertyValue(e,t){const s=t.shift(),o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}}class ve extends Rt{constructor(e,t,s,o){super(e,t,o,s),this.areaIdent=e,this.rows=t,this.columnDefs=s,this.defaultRowHeight=o}}class ${static createTableModel(e){var t,s,o,i,r,n,l,a,c,d,u,f,p,m;if(e.defaultRowHeights===void 0)if((t=e.tableOptions)!=null&&t.defaultRowHeights)e.defaultRowHeights=e.tableOptions.defaultRowHeights;else{if(e.defaultRowHeights=new N,e.headerAreaModel&&"defaultRowHeight"in e.headerAreaModel){const g=e.headerAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.header=g)}if(e.bodyAreaModel&&"defaultRowHeight"in e.bodyAreaModel){const g=e.bodyAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.body=g)}if(e.footerAreaModel&&"defaultRowHeight"in e.footerAreaModel){const g=e.footerAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.footer=g)}}if(e.columnDefs===void 0&&((s=e.properties)!=null&&s.length?e.columnDefs=e.properties.map(g=>new H(g,g.toUpperCase(),xe)):(o=e.rows)!=null&&o.length?e.columnDefs=Object.keys(e.rows[0]).map(g=>new H(g,g.toUpperCase(),xe)):e.columnDefs=[]),e.columnCount===void 0&&((i=e.columnDefs)!=null&&i.length?e.columnCount=e.columnDefs.length:(r=e.headerData)!=null&&r.length?e.columnCount=e.headerData[0].length:(n=e.columnSizes)!=null&&n.length?e.columnCount=(l=e.columnSizes)==null?void 0:l.length:console.warn('Property "columnCount" is missing and cannot be derived from other properties.')),e.headerAreaModel||((a=e.headerData)!=null&&a.length?e.headerAreaModel=new P("header",e.headerData,e.defaultRowHeights.header,e.columnDefs):(c=e.columnDefs)!=null&&c.length?e.headerAreaModel=new P("header",[e.columnDefs.map(g=>g.headerLabel)],e.defaultRowHeights.header,e.columnDefs):e.headerAreaModel=new F("header")),e.footerAreaModel||((d=e.footerData)!=null&&d.length?e.footerAreaModel=new P("footer",e.footerData,e.defaultRowHeights.footer,e.columnDefs):e.footerAreaModel=new F("footer")),!e.bodyAreaModel)if(e.rows)if((u=e.rows)!=null&&u.length&&W(e.rows[0])){const g=e.rows;e.bodyAreaModel=new Se("body",g,e.defaultRowHeights.body,e.columnDefs),(e.columnDefs[0].property==="CheckboxColumn"||(f=e.tableOptions)!=null&&f.showCheckboxWihoutExtraColumn)&&(e.bodyAreaModel.rowSelectionModel=new we(g))}else e.bodyAreaModel=new ve("body",e.rows,e.columnDefs,e.defaultRowHeights.body);else e.bodyData?e.bodyAreaModel=new P("body",e.bodyData,e.defaultRowHeights.body):e.bodyAreaModel=new F("body");return e.fixedLeftColumnCount===void 0&&(e.fixedLeftColumnCount=0),e.fixedRightColumnCount===void 0&&(e.fixedRightColumnCount=0),e.rowCheckboxVisible===void 0&&(e.rowCheckboxVisible=!1),e.overridingColumnWidth===void 0&&(e.overridingColumnWidth=-1),!e.getSelectionModel&&((p=e.tableOptions)!=null&&p.getSelectionModel)&&(e.getSelectionModel=(m=e.tableOptions)==null?void 0:m.getSelectionModel),new Q(e.headerAreaModel,e.bodyAreaModel,e.footerAreaModel,e.fixedLeftColumnCount,e.fixedRightColumnCount,e.rowCheckboxVisible,e.defaultRowHeights,e.columnDefs,e.columnSizes,e.overridingColumnWidth,e.columnCount,e.parentSize,e.getSelectionModel)}static buildByTypedRowsParam(e){return $.buildByTypedRows(e.rows??[],e.columnDefs,e.tableOptions??new K,e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0)}static buildByTypedRows(e,t,s=new K,o=0,i=0){const r=s.defaultRowHeights,n=t[0].property==="CheckboxColumn";if(e!=null&&e.length&&W(e[0])){const a=e,c=new Se("body",a,r.body,t);return(n||s.showCheckboxWihoutExtraColumn)&&(c.rowSelectionModel=new we(a)),$.createByAreaModelsParam({headerAreaModel:new P("header",[t.map(d=>d.headerLabel)],r.header),bodyAreaModel:c,footerAreaModel:new P("footer",[],r.footer),columnDefs:t,fixedLeftColumnCount:o,fixedRightColumnCount:i,defaultRowHeights:s.defaultRowHeights,rowCheckboxVisible:!1,columnSizes:[],columnCount:t.length,overridingColumnWidth:-1})}return $.createByObjectArrayParam({rows:e,columnDefs:t,fixedLeftColumnCount:o,fixedRightColumnCount:i,defaultRowHeights:s.defaultRowHeights})}static createByObjectArrayParam(e){const t=e.rowCheckboxVisible!==void 0?e.rowCheckboxVisible:!1;return $.createByObjectArray(e.rows,e.header??[],e.footer??[],e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0,t,e.defaultRowHeights??new N,e.columnDefs??[],e.columnSizes??[])}static createByAreaModels(e=new F,t,s=new F,o=0,i=0,r=!1,n=new N,l,a=[],c=-1,d){return new Q(e,t,s,o,i,r,n,l,a,c,d)}static createByAreaModelsParam(e){return $.createByAreaModels(e.headerAreaModel??new F,e.bodyAreaModel,e.footerAreaModel??new F,e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0,e.rowCheckboxVisible===void 0?!1:e.rowCheckboxVisible,e.defaultRowHeights,e.columnDefs??[],e.columnSizes??[],e.overridingColumnWidth??-1,e.columnCount??0)}static createByObjectArray(e,t=[],s=[],o=0,i=0,r=!1,n=new N,l,a=[]){let c;t!=null&&t.length?c=new P("header",t,n.header,l):l!=null&&l.length?c=new P("header",[l.map(f=>f.headerLabel)],n.header,l):c=new F;const d=s?new P("footer",s,n.footer,l):new F,u=new ve("body",e,l,n.body);return new Q(c,u,d,o,i,r,n,l,a)}}const xs=["COPY_2_CLIPBOARD","START_EDITING","TOGGLE_SELECTION","SELECT_ALL","DESELECT_ALL","NAVIGATE_LEFT","NAVIGATE_RIGHT","NAVIGATE_UP","NAVIGATE_DOWN"];class At{constructor(e,t){this.tableModel=e,this.tableOptions=t}}class Et{constructor(e,t,s,o,i,r,n){this.emmitDataKey=e,this.emmitCancelKey=t,this.queryId=s,this.filter=o,this.sorting=i,this.startIndex=r,this.endIndex=n}}class Ss extends Et{constructor(e,t,s,o,i,r,n,l){super(e,t,s,o,i,r,n),this.rows=l}}class Tt{constructor(e,t){this.value=e,this.label=t}}class ws{constructor(e,t){this.index=e,this.px=t}}const Cs={body:["ge-table-text-align-left"]},vs={body:["ge-table-text-align-center"]},Rs={body:["ge-table-text-align-right"]},As={header:["ge-table-text-align-left"],body:["ge-table-text-align-left"],footer:["ge-table-text-align-left"]},Es={header:["ge-table-text-align-center"],body:["ge-table-text-align-center"],footer:["ge-table-text-align-center"]},Ts={header:["ge-table-text-align-right"],body:["ge-table-text-align-right"],footer:["ge-table-text-align-right"]};class Re{render(e,t,s,o,i,r,n){if(i.isRowCheckable(t)){n.addClass(e,"ge-table-row-checkbox-div");const l=i.isRowChecked(t),a=l==="full"?"checked":"",c=l==="semi"?'<span style="opacity: 0.4;">✓<span>':"";e.innerHTML=`
305
+ }`};let me=re;class be{constructor(e,t=!0,s,o,i=0,r=!1,n=!1){this.data=e,this.expanded=t,this.children=s,this.parent=o,this.deep=i,this.checked=r,this.keep=n,this.type="TreeRow"}}class oe{static buildTreeRows(e,t="children",s=12){const o=[];for(const i of e)o.push(oe.buildTreeRow(i,t,void 0,0,s));return o}static buildTreeRow(e,t="children",s=new be(e,!0,[],void 0,0),o=0,i=12){var n;if(o>i)return console.warn("Max deep limit reached: ",o),s;const r=e[t];if(r)for(const l of r){const a=new be(l,!0,[],s,o+1);if((n=s.children)==null||n.push(a),oe.buildTreeRow(l,t,a,o+1),o>i)return console.warn("Max deep limit reached: ",o),s}return s}}class N{constructor(e=34,t=34,s=34){this.header=e,this.body=t,this.footer=s}}class y{constructor(e=100,t="px"){this.value=e,this.unit=t}}const xt=()=>!0,ye=()=>!1;class H{constructor(e,t,s=new y(100,"px"),o=new M,i=new M,r=new y(100,"px"),n=new y(100,"px"),l,a,c,d,u,f,p,m,g=()=>this.visible){this.property=e,this.headerLabel=t,this.width=s,this.classes=o,this.rendererMap=i,this.minWidth=r,this.maxWidth=n,this.sortable=l,this.sortComparator=a,this.sortState=c,this.sortStatesOrder=d,this.sortIconVisible=u,this.editable=f,this.getEditRenderer=p,this.editInputPipe=m,this.isVisible=g,this.visible=!0,s.unit!=="px"&&(this.minWidth=new y(0,"px"),this.maxWidth=new y(1e5,"px"))}static bodyRenderer(e){return new M(void 0,e,void 0)}static create(e){const t=new M(e.headerRenderer,e.bodyRenderer,e.footerRenderer),s=new M(e.headerClasses,e.bodyClasses,e.footerClasses),o=e.sortIconVisible??e.sortable??ye,i=e.editable??e.editable??ye,r=e.isVisible??e.isVisible??xt;return new H(e.property??"",e.headerLabel??"",e.width??new y(100,"px"),s,t,e.minWidth??new y(100,"px"),e.maxWidth??new y(100,"px"),e.sortable,e.sortComparator,e.sortState,e.sortStatesOrder,o,i,e.getEditRenderer,e.editInputPipe,r)}}const Nt=new y(500,"px"),Gt=new y(400,"px"),St=new y(300,"px"),zt=new y(290,"px"),jt=new y(280,"px"),Yt=new y(270,"px"),Ut=new y(260,"px"),Kt=new y(250,"px"),Xt=new y(240,"px"),Jt=new y(230,"px"),qt=new y(220,"px"),Zt=new y(210,"px"),xe=new y(200,"px"),Qt=new y(190,"px"),es=new y(180,"px"),ts=new y(170,"px"),ss=new y(160,"px"),os=new y(150,"px"),is=new y(140,"px"),rs=new y(130,"px"),ns=new y(120,"px"),ls=new y(110,"px"),as=new y(100,"px"),cs=new y(90,"px"),ds=new y(80,"px"),hs=new y(70,"px"),us=new y(60,"px"),ps=new y(50,"px"),gs=new y(40,"px"),fs=new y(30,"px"),ms=new y(20,"px"),bs=new y(10,"px"),ys=new y(0,"px");class ue{constructor(e,t=[],s=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=s,this.rowSelectionModel=void 0,this.yPositions=[],this.cellRenderers=t.map(o=>o.rendererMap[e])}getTextValueAt(e,t){return""+this.getValueAt(e,t)}getTooltipAt(e,t){return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var s;const t=this.getRowByIndex(e);return(s=this.rowSelectionModel)==null?void 0:s.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const s=this.getRowByIndex(e);this.rowSelectionModel.checkRow(s,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){return this.defaultRowHeight>0?this.defaultRowHeight*e:this.yPositions[e]}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}isEditable(e,t){var o,i;const s=(o=this.columnDefs)==null?void 0:o[t];return((i=s==null?void 0:s.editable)==null?void 0:i.call(s))??!1}setValue(e,t,s){var n;const o=(n=this.columnDefs[t])==null?void 0:n.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e),r=this.columnDefs[t].property;return r.includes(".")?this.setPropertyValue(i,r.split("."),s):(i[r]=s,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,s){const o=t.shift();if(o){const i=e[o];return i&&t.length?this.setPropertyValue(i,t,s):(e[o]=s,!0)}return!1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}}class P extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.arr=t,this.defaultRowHeight=s,this.columnDefs=o,this.filteredArr=[...t]}externalFilterChanged(e){this.filteredArr=this.arr?this.arr.filter(e):[]}getRowCount(){return this.filteredArr?this.filteredArr.length:0}getValueAt(e,t){return this.filteredArr[e][t]}setValue(e,t,s){var i;const o=(i=this.columnDefs[t])==null?void 0:i.editInputPipe;return o&&(s=o(s,e,t)),this.arr[e][t]=s,!0}getRowByIndex(e){return this.filteredArr[e]}getRowHeight(e){return this.defaultRowHeight}changeColumnOrder(e,t){this.filteredArr.forEach(s=>this.arrayMove(s,e,t)),super.changeColumnOrder(e,t)}}class F{constructor(e="body"){this.areaIdent=e,this.rowSelectionModel=void 0}getRowCount(){return 0}getValueAt(e,t){return""}getTextValueAt(e,t){return""}getCellRenderer(e,t){}getRowHeight(e){return 0}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!1}isRowChecked(e){}setRowChecked(e,t){}getTooltipAt(e,t){return""}getMaxColspan(){return 0}getMaxRowspan(){return 0}getYPosByRowIndex(e){return 0}init(){}externalFilterChanged(e){}isFilterable(){return!1}doSort(e){return!1}isEditable(e,t){return!1}setValue(e,t,s){return!1}isSelectable(e,t){return!1}changeColumnOrder(e,t){}}class wt{flattenTree(e,t=[]){var s;for(const o of e)this.isVisible(o)&&t.push(o),(s=o.children)!=null&&s.length&&this.flattenTree(o.children,t);return t}isVisible(e){return e.parent?e.parent.expanded?this.isVisible(e.parent):!1:!0}}class Ct{genericSortComparator(e,t,s){if(typeof e=="number"&&typeof t=="number")return s*(e-t);if(typeof e=="string"&&typeof t=="string")return s*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return s*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return s*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const o=e,i=t;if(o.length&&i.length)return this.genericSortComparator(o[0],i[0],s)}return s*(""+e).localeCompare(""+t)}}class Se extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.type="AreaModelTree",this.sorterService=new Ct,this.service=new wt,this.properties=o.map(i=>i.property),this.flattenRows=this.service.flattenTree(t),this.filteredFlattenRows=[...this.flattenRows]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}recalcVisibleTreeRows(){this.filteredFlattenRows=this.service.flattenTree(this.rows)}getFilteredFlattenRows(){return this.filteredFlattenRows}getRowCount(){let e=0;for(const t of this.filteredFlattenRows)this.service.isVisible(t)&&e++;return e}getValueAt(e,t){const s=this.getRowByIndex(e);if(s){const o=this.properties[t];if(o)return o.includes(".")?this.getPropertyValue(s.data,o.split(".")):s.data[o]}return""}getRowHeight(e){return this.defaultRowHeight}getCustomClassesAt(e,t){return["ge-table-tree-cell","ge-table-tree-deep-"+this.filteredFlattenRows[e].deep]}getRowByIndex(e){return this.filteredFlattenRows[e]}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}externalFilterChanged(e){this.lastPredictFn=e,this.doFiltering()}doSort(e){const{columnIndex:t,sortState:s}=e[e.length-1],o=s==="asc"?1:s==="desc"?-1:0,i=this.properties[t];return this.treeSort(this.rows,i,o),this.flattenRows=this.service.flattenTree(this.rows),this.filteredFlattenRows=[...this.flattenRows],!0}toggleExpandCollapseAll(e){this.expandAllRecursive(this.rows,e),this.flattenRows=this.service.flattenTree(this.rows),this.doFiltering()}setAllParentsOk(e){return e.parent&&(e.parent.keep=!0,this.setAllParentsOk(e.parent)),!1}setValue(e,t,s){var r;const o=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e);if(i){const n=i.data,l=this.columnDefs[t].property;return l.includes(".")?this.setPropertyValue(n,l.split("."),s):(n[l]=s,!0)}return!1}genericTreeTableSortComparator(e,t){const s=this.columnDefs.find(o=>o.property===e);return(o,i)=>{if(s!=null&&s.sortComparator){const l=this.getValueByT(o.data,e),a=this.getValueByT(i.data,e);return t*s.sortComparator(l,a,o.data,i.data)}const r=this.getValueByT(o.data,e),n=this.getValueByT(i.data,e);return this.sorterService.genericSortComparator(r,n,t)}}expandAllRecursive(e,t){for(const s of e)s.expanded=t,s.children&&this.expandAllRecursive(s.children,t)}doFiltering(){if(!this.lastPredictFn)this.filteredFlattenRows=[...this.flattenRows?this.flattenRows:[]];else{this.flattenRows||(this.flattenRows=[]);let e=0;this.flattenRows.forEach(s=>{e=Math.max(e,s.deep)});const t=this.flattenRows.filter((s,o,i)=>this.lastPredictFn(s,o,i));this.flattenRows.forEach(s=>s.keep=!1),this.flattenRows.forEach(s=>{t.includes(s)&&(s.keep=!0,this.setAllParentsOk(s))}),this.filteredFlattenRows=this.flattenRows.filter((s,o,i)=>s.keep)}}getPropertyValue(e,t){const s=t.shift();let o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}treeSort(e,t,s){e.sort(this.genericTreeTableSortComparator(t,s));for(const o of e)o.children&&this.treeSort(o.children,t,s)}}class we{constructor(e=[]){this.allRootNodes=e}checkRow(e,t){if(e.checked=t,e.children)for(const s of e.children)this.checkRow(s,t);this.autoCheckParent(e.parent)}checkAll(e){for(const t of this.allRootNodes)t.checked=!1,t.children&&this.checkAll(t.children)}getCheckedRows(){const e=[];return this.addSelectedRecursive(this.allRootNodes,e),e}isRowChecked(e){if(e.checked)return"full";const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);return!t&&!s?"semi":"none"}setCheckedRows(e){this.addCheckedRows(e)}addCheckedRows(e){for(const t of e)t.checked=!0}autoCheckParent(e){if(e){const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);t?e.checked=!0:e.checked=!1,this.autoCheckParent(e.parent)}}areAllChildrenChecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(!o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenChecked(o))return!1}return!0}areAllChildrenUnchecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenUnchecked(o))return!1}return!0}addSelectedRecursive(e,t){for(const s of e)s.checked&&t.push(s),s.children&&this.addSelectedRecursive(s.children,t)}}class Ce{constructor(e=0,t=0,s=0,o=0){this.top=e,this.right=t,this.bottom=s,this.left=o}}class vt{constructor(){this.checkedRows=[]}getCheckedRows(){return this.checkedRows}setCheckedRows(e){this.checkedRows=e}addCheckedRows(e){this.checkedRows||(this.checkedRows=[]);for(const t of e)this.checkedRows.includes(t)||this.checkedRows.push(t)}checkRow(e,t){this.checkedRows||(this.checkedRows=[]),t?this.checkedRows.includes(e)||this.checkedRows.push(e):this.removeSelectedRow(e)}isRowChecked(e){return this.checkedRows&&this.checkedRows.includes(e)?"full":"none"}checkAll(e){this.checkedRows=[]}removeSelectedRow(e){if(this.checkedRows){const t=this.checkedRows.indexOf(e);t>-1&&this.checkedRows.splice(t,1)}}}class Q{constructor(e,t,s,o=0,i=0,r=!1,n=new N,l=[],a=[],c=-1,d=0,u=400,f=()=>{}){var p,m,g,b;this.headerAreaModel=e,this.bodyAreaModel=t,this.footerAreaModel=s,this.fixedLeftColumnCount=o,this.fixedRightColumnCount=i,this.rowCheckboxVisible=r,this.defaultRowHeights=n,this.columnDefs=l,this.columnSizes=a,this.overridingColumnWidth=c,this.columnCount=d,this.parentSize=u,this.getSelectionModel=f,this.rowCount=0,this.contentHeightInPx=0,this.contentWidthInPx=0,this.padding=new Ce(0,0,0,0),this.xPositions=[],e.areaIdent="header",t.areaIdent="body",s.areaIdent="footer",this.columnCount||((p=this.columnDefs)!=null&&p.length?this.columnCount=this.columnDefs.length:(m=this.columnSizes)!=null&&m.length&&(this.columnCount=(g=this.columnSizes)==null?void 0:g.length)),(b=this.columnDefs)!=null&&b.length&&Xe(this.columnDefs[0])&&!t.rowSelectionModel&&(t.rowSelectionModel=new vt)}init(){this.recalcSize(this.parentSize),this.overridingColumnWidth===-1&&this.calcXPositions(),this.headerAreaModel&&this.headerAreaModel.init(),this.bodyAreaModel&&this.bodyAreaModel.init(),this.footerAreaModel&&this.footerAreaModel.init()}setParentWidth(e){this.parentSize=e}getColumnCount(){return this.columnCount}setColumnWidth(e,t){var s;t=Math.max(0,t),this.overridingColumnWidth!==-1&&(this.overridingColumnWidth=t),e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)&&(this.columnSizes[e]=t),this.recalcContentWidthInPx()}getColumnWidth(e){var s;const t=this.getColumnDef(e);return t&&t.isVisible&&!t.isVisible()?0:this.overridingColumnWidth!==-1?this.overridingColumnWidth:e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)?this.columnSizes[e]:0}getXPosByColumnIndex(e){return e===0?0:this.overridingColumnWidth>-1?this.overridingColumnWidth*e:this.xPositions[e]}recalcSize(e){this.recalcColumnWidths(e),this.recalcHeightAndPadding()}recalcHeightAndPadding(){const e=this.getAreaModel("body");this.rowCount=e.getRowCount(),this.contentHeightInPx=this.getAreaHeight("body"),this.recalcContentWidthInPx(),this.recalcPadding()}recalcPadding(){const e=this.getSideAreaWidth("west"),t=this.getSideAreaWidth("east"),s=this.getAreaHeight("header"),o=this.getAreaHeight("footer");this.padding=new Ce(s,t,o,e)}getPadding(){return this.padding}getContentHeightInPixel(){return this.contentHeightInPx}getContentWidthInPixel(){return this.contentWidthInPx}getRowHeight(e,t){return this.getAreaModel(e).getRowHeight(t)}getModel(e){return this.getAreaModel(e)}getAreaHeight(e){const t=this.getModel(e),s=t.getRowCount();if(this.defaultRowHeights[e])return s*this.defaultRowHeights[e];let o=0;for(let i=0;i<s;i++)o=o+t.getRowHeight(i);return o}getSideAreaWidth(e){const[t,s]=this.getSideStartAndEndColumnIndex(e);let o=0;for(let i=t;i<=s;i++)o=o+this.getColumnWidth(i);return o}getSideStartAndEndColumnIndex(e){const t=this.getFixedLeftColumnCount(),s=this.getFixedRightColumnCount();let o=0,i=this.columnCount-1;return e==="west"?i=t-1:e==="east"?o=this.columnCount-s:(o=t,i=this.columnCount-s-1),[o,i]}getColumnDef(e){if(e<this.columnDefs.length)return this.columnDefs[e]}getFixedLeftColumnCount(){return this.fixedLeftColumnCount}getFixedRightColumnCount(){return this.fixedRightColumnCount}getAreaModel(e){if(e==="header")return this.headerAreaModel;if(e==="body")return this.bodyAreaModel;if(e==="footer")return this.footerAreaModel;throw new Error("Wrong ident.")}getBodyModel(){return this.bodyAreaModel}isFooterVisibe(){var e;return(((e=this.footerAreaModel)==null?void 0:e.getRowCount())??0)>0}isHeaderVisibe(){var e;return(((e=this.headerAreaModel)==null?void 0:e.getRowCount())??0)>0}isRowCheckboxVisible(){return this.rowCheckboxVisible}externalFilterChanged(e){this.getAreaModel("body").externalFilterChanged(e)}doSort(e){return this.getAreaModel("body").doSort(e)}getColumnDefs(){return this.columnDefs}getColumnProperty(e){return this.columnDefs?this.columnDefs[e].property:""}getBodyRowByIndex(e){return this.getBodyModel().getRowByIndex(e)}isSortable(e){var t;if(this.columnDefs&&e<this.columnDefs.length){const s=(t=this.columnDefs[e])==null?void 0:t.sortable;if(typeof s=="function")return s()}return!1}changeColumnOrder(e,t){var s,o,i;this.arrayMove(this.columnDefs,e,t),this.arrayMove(this.columnSizes,e,t),(s=this.headerAreaModel)==null||s.changeColumnOrder(e,t),(o=this.bodyAreaModel)==null||o.changeColumnOrder(e,t),(i=this.footerAreaModel)==null||i.changeColumnOrder(e,t),this.calcXPositions()}recalcColumnWidths(e){var t,s,o;if(!((t=this.columnDefs)!=null&&t.length)&&!((s=this.columnSizes)!=null&&s.length)&&(this.columnSizes=new Array(this.getColumnCount()).fill(this.overridingColumnWidth)),(o=this.columnDefs)!=null&&o.length){const i=this.columnDefs.filter(l=>{var a;return((a=l.width)==null?void 0:a.unit)==="weight"});this.columnSizes=this.columnDefs.map(l=>{if(l.width.unit==="%"&&e){let a=Math.floor(l.width.value*e/100);if(l.minWidth){const c=this.sizeToPixel(l.minWidth,e);a=Math.max(c,a)}if(l.maxWidth){const c=this.sizeToPixel(l.maxWidth,e);a=Math.min(c,a)}return a}else if(l.width.unit==="px"&&e)return l.width.value;return 0});const r=this.columnSizes.reduce((l,a)=>l+a),n=e-r;if(n>0&&i.length){const l=i.map(a=>a.width.value).reduce((a,c)=>a+c);for(let a=0;a<this.columnDefs.length;a++){const c=this.columnDefs[a];c.width.unit==="weight"&&(this.columnSizes[a]=c.width.value*n/l)}}}}sizeToPixel(e,t){return e.unit==="px"?e.value:e.unit==="%"?Math.floor(e.value*t/100):-1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}recalcContentWidthInPx(){this.contentWidthInPx=this.getSideAreaWidth("center")}calcXPositions(){const e=this.getColumnCount();this.xPositions=new Array(e+1),this.xPositions[0]=0;for(let t=0;t<e;t++)this.xPositions[t+1]=this.getColumnWidth(t)+this.xPositions[t]}setTableScope(e){this.tableScope=e}getTableScope(){return this.tableScope}}class Rt extends ue{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.sorterService=new Ct,this.filteredRows=[...t],this.properties=o.map(i=>i.property)}setRows(e){this.rows=e,this.filteredRows=[...e]}filterRowsByPredict(e){this.rows=this.rows.filter(e),this.filteredRows=this.filteredRows.filter(e)}getRowCount(){var e;return((e=this.filteredRows)==null?void 0:e.length)??0}getValueAt(e,t){const s=this.properties[t];let o=this.filteredRows[e];return W(o)&&(o=o.data),o?this.getValueByT(o,s):""}getFilteredRows(){return this.filteredRows}getAllRows(){return this.rows}getRowHeight(e){return this.defaultRowHeight}getRowByIndex(e){return this.filteredRows[e]}externalFilterChanged(e){this.filteredRows=this.rows?this.rows.filter(e):[]}doSort(e){for(const t of e){const{columnIndex:s,sortState:o}=t,i=o==="asc"?1:o==="desc"?-1:0,r=this.properties[s];this.filteredRows=this.filteredRows.sort(this.genericFlatTableSortComparator(r,i))}return!0}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}genericFlatTableSortComparator(e,t){const s=this.columnDefs.find(o=>o.property===e);return(o,i)=>{if(s!=null&&s.sortComparator){const l=this.getValueByT(o,e),a=this.getValueByT(i,e);return t*s.sortComparator(l,a,o,i)}const r=this.getValueByT(o,e),n=this.getValueByT(i,e);return this.sorterService.genericSortComparator(r,n,t)}}getPropertyValue(e,t){const s=t.shift(),o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}}class ve extends Rt{constructor(e,t,s,o){super(e,t,o,s),this.areaIdent=e,this.rows=t,this.columnDefs=s,this.defaultRowHeight=o}}class ${static createTableModel(e){var t,s,o,i,r,n,l,a,c,d,u,f,p,m;if(e.defaultRowHeights===void 0)if((t=e.tableOptions)!=null&&t.defaultRowHeights)e.defaultRowHeights=e.tableOptions.defaultRowHeights;else{if(e.defaultRowHeights=new N,e.headerAreaModel&&"defaultRowHeight"in e.headerAreaModel){const g=e.headerAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.header=g)}if(e.bodyAreaModel&&"defaultRowHeight"in e.bodyAreaModel){const g=e.bodyAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.body=g)}if(e.footerAreaModel&&"defaultRowHeight"in e.footerAreaModel){const g=e.footerAreaModel.defaultRowHeight;g>-1&&(e.defaultRowHeights.footer=g)}}if(e.columnDefs===void 0&&((s=e.properties)!=null&&s.length?e.columnDefs=e.properties.map(g=>new H(g,g.toUpperCase(),xe)):(o=e.rows)!=null&&o.length?e.columnDefs=Object.keys(e.rows[0]).map(g=>new H(g,g.toUpperCase(),xe)):e.columnDefs=[]),e.columnCount===void 0&&((i=e.columnDefs)!=null&&i.length?e.columnCount=e.columnDefs.length:(r=e.headerData)!=null&&r.length?e.columnCount=e.headerData[0].length:(n=e.columnSizes)!=null&&n.length?e.columnCount=(l=e.columnSizes)==null?void 0:l.length:console.warn('Property "columnCount" is missing and cannot be derived from other properties.')),e.headerAreaModel||((a=e.headerData)!=null&&a.length?e.headerAreaModel=new P("header",e.headerData,e.defaultRowHeights.header,e.columnDefs):(c=e.columnDefs)!=null&&c.length?e.headerAreaModel=new P("header",[e.columnDefs.map(g=>g.headerLabel)],e.defaultRowHeights.header,e.columnDefs):e.headerAreaModel=new F("header")),e.footerAreaModel||((d=e.footerData)!=null&&d.length?e.footerAreaModel=new P("footer",e.footerData,e.defaultRowHeights.footer,e.columnDefs):e.footerAreaModel=new F("footer")),!e.bodyAreaModel)if(e.rows)if((u=e.rows)!=null&&u.length&&W(e.rows[0])){const g=e.rows;e.bodyAreaModel=new Se("body",g,e.defaultRowHeights.body,e.columnDefs),(e.columnDefs[0].property==="CheckboxColumn"||(f=e.tableOptions)!=null&&f.showCheckboxWihoutExtraColumn)&&(e.bodyAreaModel.rowSelectionModel=new we(g))}else e.bodyAreaModel=new ve("body",e.rows,e.columnDefs,e.defaultRowHeights.body);else e.bodyData?e.bodyAreaModel=new P("body",e.bodyData,e.defaultRowHeights.body):e.bodyAreaModel=new F("body");return e.fixedLeftColumnCount===void 0&&(e.fixedLeftColumnCount=0),e.fixedRightColumnCount===void 0&&(e.fixedRightColumnCount=0),e.rowCheckboxVisible===void 0&&(e.rowCheckboxVisible=!1),e.overridingColumnWidth===void 0&&(e.overridingColumnWidth=-1),!e.getSelectionModel&&((p=e.tableOptions)!=null&&p.getSelectionModel)&&(e.getSelectionModel=(m=e.tableOptions)==null?void 0:m.getSelectionModel),new Q(e.headerAreaModel,e.bodyAreaModel,e.footerAreaModel,e.fixedLeftColumnCount,e.fixedRightColumnCount,e.rowCheckboxVisible,e.defaultRowHeights,e.columnDefs,e.columnSizes,e.overridingColumnWidth,e.columnCount,e.parentSize,e.getSelectionModel)}static buildByTypedRowsParam(e){return $.buildByTypedRows(e.rows??[],e.columnDefs,e.tableOptions??new K,e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0)}static buildByTypedRows(e,t,s=new K,o=0,i=0){const r=s.defaultRowHeights,n=t[0].property==="CheckboxColumn";if(e!=null&&e.length&&W(e[0])){const a=e,c=new Se("body",a,r.body,t);return(n||s.showCheckboxWihoutExtraColumn)&&(c.rowSelectionModel=new we(a)),$.createByAreaModelsParam({headerAreaModel:new P("header",[t.map(d=>d.headerLabel)],r.header),bodyAreaModel:c,footerAreaModel:new P("footer",[],r.footer),columnDefs:t,fixedLeftColumnCount:o,fixedRightColumnCount:i,defaultRowHeights:s.defaultRowHeights,rowCheckboxVisible:!1,columnSizes:[],columnCount:t.length,overridingColumnWidth:-1})}return $.createByObjectArrayParam({rows:e,columnDefs:t,fixedLeftColumnCount:o,fixedRightColumnCount:i,defaultRowHeights:s.defaultRowHeights})}static createByObjectArrayParam(e){const t=e.rowCheckboxVisible!==void 0?e.rowCheckboxVisible:!1;return $.createByObjectArray(e.rows,e.header??[],e.footer??[],e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0,t,e.defaultRowHeights??new N,e.columnDefs??[],e.columnSizes??[])}static createByAreaModels(e=new F,t,s=new F,o=0,i=0,r=!1,n=new N,l,a=[],c=-1,d){return new Q(e,t,s,o,i,r,n,l,a,c,d)}static createByAreaModelsParam(e){return $.createByAreaModels(e.headerAreaModel??new F,e.bodyAreaModel,e.footerAreaModel??new F,e.fixedLeftColumnCount??0,e.fixedRightColumnCount??0,e.rowCheckboxVisible===void 0?!1:e.rowCheckboxVisible,e.defaultRowHeights,e.columnDefs??[],e.columnSizes??[],e.overridingColumnWidth??-1,e.columnCount??0)}static createByObjectArray(e,t=[],s=[],o=0,i=0,r=!1,n=new N,l,a=[]){let c;t!=null&&t.length?c=new P("header",t,n.header,l):l!=null&&l.length?c=new P("header",[l.map(f=>f.headerLabel)],n.header,l):c=new F;const d=s?new P("footer",s,n.footer,l):new F,u=new ve("body",e,l,n.body);return new Q(c,u,d,o,i,r,n,l,a)}}const xs=["COPY_2_CLIPBOARD","START_EDITING","TOGGLE_SELECTION","SELECT_ALL","DESELECT_ALL","NAVIGATE_LEFT","NAVIGATE_RIGHT","NAVIGATE_UP","NAVIGATE_DOWN"];class At{constructor(e,t){this.tableModel=e,this.tableOptions=t}}class Et{constructor(e,t,s,o,i,r,n){this.emmitDataKey=e,this.emmitCancelKey=t,this.queryId=s,this.filter=o,this.sorting=i,this.startIndex=r,this.endIndex=n}}class Ss extends Et{constructor(e,t,s,o,i,r,n,l){super(e,t,s,o,i,r,n),this.rows=l}}class Tt{constructor(e,t){this.value=e,this.label=t}}class ws{constructor(e,t){this.index=e,this.px=t}}const Cs={body:["ge-table-text-align-left"]},vs={body:["ge-table-text-align-center"]},Rs={body:["ge-table-text-align-right"]},As={header:["ge-table-text-align-left"],body:["ge-table-text-align-left"],footer:["ge-table-text-align-left"]},Es={header:["ge-table-text-align-center"],body:["ge-table-text-align-center"],footer:["ge-table-text-align-center"]},Ts={header:["ge-table-text-align-right"],body:["ge-table-text-align-right"],footer:["ge-table-text-align-right"]};class Re{render(e,t,s,o,i,r,n){if(i.isRowCheckable(t)){n.addClass(e,"ge-table-row-checkbox-div");const l=i.isRowChecked(t),a=l==="full"?"checked":"",c=l==="semi"?'<span style="opacity: 0.4;">✓<span>':"";e.innerHTML=`
306
306
  <input
307
307
  type="checkbox"
308
308
  data-area="${o}"
package/index.js CHANGED
@@ -4242,9 +4242,14 @@ class ve extends fe {
4242
4242
  return !1;
4243
4243
  }
4244
4244
  genericTreeTableSortComparator(e, t) {
4245
- return (s, o) => {
4246
- const i = this.getValueByT(s.data, e), r = this.getValueByT(o.data, e);
4247
- return this.sorterService.genericSortComparator(i, r, t);
4245
+ const s = this.columnDefs.find((o) => o.property === e);
4246
+ return (o, i) => {
4247
+ if (s != null && s.sortComparator) {
4248
+ const l = this.getValueByT(o.data, e), a = this.getValueByT(i.data, e);
4249
+ return t * s.sortComparator(l, a, o.data, i.data);
4250
+ }
4251
+ const r = this.getValueByT(o.data, e), n = this.getValueByT(i.data, e);
4252
+ return this.sorterService.genericSortComparator(r, n, t);
4248
4253
  };
4249
4254
  }
4250
4255
  expandAllRecursive(e, t) {
@@ -4815,9 +4820,14 @@ class Et extends fe {
4815
4820
  this.arrayMove(this.properties, e, t), super.changeColumnOrder(e, t);
4816
4821
  }
4817
4822
  genericFlatTableSortComparator(e, t) {
4818
- return (s, o) => {
4819
- const i = this.getValueByT(s, e), r = this.getValueByT(o, e);
4820
- return this.sorterService.genericSortComparator(i, r, t);
4823
+ const s = this.columnDefs.find((o) => o.property === e);
4824
+ return (o, i) => {
4825
+ if (s != null && s.sortComparator) {
4826
+ const l = this.getValueByT(o, e), a = this.getValueByT(i, e);
4827
+ return t * s.sortComparator(l, a, o, i);
4828
+ }
4829
+ const r = this.getValueByT(o, e), n = this.getValueByT(i, e);
4830
+ return this.sorterService.genericSortComparator(r, n, t);
4821
4831
  };
4822
4832
  }
4823
4833
  getPropertyValue(e, t) {
@@ -1,5 +1,5 @@
1
1
  import { SizeIf } from "../../common/size.if";
2
- import { ColumnDefIf } from "./column-def.if";
2
+ import { ColumnDefIf, ValueRowSortComparator } from "./column-def.if";
3
3
  import { CellRendererIf } from "../../../renderer/cell-render.if";
4
4
  import { AreaObjectMapType } from "../../common/area-map.type";
5
5
  import { AreaObjectMap } from "../../common/area-map";
@@ -19,7 +19,7 @@ export declare class ColumnDef implements ColumnDefIf {
19
19
  minWidth: SizeIf;
20
20
  maxWidth: SizeIf;
21
21
  sortable?: BooleanFunction | undefined;
22
- sortComparator?: (<T>(a: T, b: T) => number) | undefined;
22
+ sortComparator?: ValueRowSortComparator | undefined;
23
23
  sortState?: SortState | undefined;
24
24
  sortStatesOrder?: SortState[] | undefined;
25
25
  sortIconVisible?: BooleanFunction | undefined;
@@ -28,7 +28,7 @@ export declare class ColumnDef implements ColumnDefIf {
28
28
  editInputPipe?: editInputPipe | undefined;
29
29
  isVisible: BooleanFunction;
30
30
  visible: boolean;
31
- constructor(property: string, headerLabel: string, width?: SizeIf, classes?: AreaObjectMapType<string[]>, rendererMap?: AreaObjectMapType<CellRendererIf>, minWidth?: SizeIf, maxWidth?: SizeIf, sortable?: BooleanFunction | undefined, sortComparator?: (<T>(a: T, b: T) => number) | undefined, sortState?: SortState | undefined, sortStatesOrder?: SortState[] | undefined, sortIconVisible?: BooleanFunction | undefined, editable?: BooleanFunction | undefined, getEditRenderer?: GetEditRenderer | undefined, editInputPipe?: editInputPipe | undefined, isVisible?: BooleanFunction);
31
+ constructor(property: string, headerLabel: string, width?: SizeIf, classes?: AreaObjectMapType<string[]>, rendererMap?: AreaObjectMapType<CellRendererIf>, minWidth?: SizeIf, maxWidth?: SizeIf, sortable?: BooleanFunction | undefined, sortComparator?: ValueRowSortComparator | undefined, sortState?: SortState | undefined, sortStatesOrder?: SortState[] | undefined, sortIconVisible?: BooleanFunction | undefined, editable?: BooleanFunction | undefined, getEditRenderer?: GetEditRenderer | undefined, editInputPipe?: editInputPipe | undefined, isVisible?: BooleanFunction);
32
32
  static bodyRenderer(bodyRenderer: CellRendererIf): AreaObjectMap<CellRendererIf>;
33
33
  static create(param: {
34
34
  property?: string;
@@ -44,7 +44,7 @@ export declare class ColumnDef implements ColumnDefIf {
44
44
  footerClasses?: string[];
45
45
  sortable?: BooleanFunction;
46
46
  sortIconVisible?: BooleanFunction;
47
- sortComparator?: <T>(a: T, b: T) => number;
47
+ sortComparator?: ValueRowSortComparator;
48
48
  sortState?: SortState;
49
49
  sortStatesOrder?: SortState[];
50
50
  editable?: BooleanFunction;
@@ -5,6 +5,25 @@ import { BooleanFunction } from "../../common/boolean-function";
5
5
  import { SortState } from "../../common/sort-state.type";
6
6
  import { GetEditRenderer } from "../../../renderer/edit/edit-cell-renderer.type";
7
7
  import { editInputPipe } from "../../../renderer/edit/edit-input-pipe.if";
8
+ /**
9
+ * Represents a function that compares two values for sorting purposes.
10
+ * The function takes two values of type T and optionally their corresponding row objects of type U,
11
+ * compares them, and returns a number.
12
+ * If the result is negative, it means 'valueA' comes before 'valueB' in the sorted order.
13
+ * If the result is positive, it means 'valueB' comes before 'valueA' in the sorted order.
14
+ * If the result is zero, it means the two values are considered equal for sorting purposes.
15
+ *
16
+ * @typeparam T The type of values being compared.
17
+ * @typeparam U The type of row objects that contain the values.
18
+ *
19
+ * @param valueA The first value to be compared.
20
+ * @param valueB The second value to be compared.
21
+ * @param rowA Optional. The row object containing valueA.
22
+ * @param rowB Optional. The row object containing valueB.
23
+ *
24
+ * @returns A number indicating the relative order of 'valueA' and 'valueB'.
25
+ */
26
+ export type ValueRowSortComparator = <T, U>(valueA: T, valueB: T, rowA?: U, rowB?: U) => number;
8
27
  /**
9
28
  * Represents a column definition of one table column.
10
29
  */
@@ -69,19 +88,15 @@ export interface ColumnDefIf {
69
88
  sortIconVisible?: BooleanFunction;
70
89
  /**
71
90
  * Represents a function that compares two values for sorting purposes.
72
- * The function takes two arguments of type T, compares them, and returns a number.
73
- * If the result is negative, it means 'a' comes before 'b' in the sorted order.
74
- * If the result is positive, it means 'b' comes before 'a' in the sorted order.
91
+ * The function takes two values and optionally their corresponding row objects,
92
+ * compares them, and returns a number.
93
+ * If the result is negative, it means 'valueA' comes before 'valueB' in the sorted order.
94
+ * If the result is positive, it means 'valueB' comes before 'valueA' in the sorted order.
75
95
  * If the result is zero, it means the two values are considered equal for sorting purposes.
76
96
  *
77
- * @typeparam T The type of values being compared.
78
- *
79
- * @param a The first value to be compared.
80
- * @param b The second value to be compared.
81
- *
82
- * @returns A number indicating the relative order of 'a' and 'b'.
97
+ * @see ValueRowSortComparator
83
98
  */
84
- sortComparator?: <T>(a: T, b: T) => number;
99
+ sortComparator?: ValueRowSortComparator;
85
100
  /**
86
101
  * Represents the state of sorting for a list.
87
102
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/table",
3
- "version": "1.1.50",
3
+ "version": "1.1.55",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",