cps-ui-kit 0.129.0 → 0.130.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5748,6 +5748,7 @@ class CpsTreeTableComponent {
5748
5748
  this.columns = [];
5749
5749
  this.colHeaderName = 'header';
5750
5750
  this.colFieldName = 'field';
5751
+ this.minWidth = 0;
5751
5752
  this.striped = true;
5752
5753
  this.bordered = true;
5753
5754
  this.size = 'normal';
@@ -5768,6 +5769,7 @@ class CpsTreeTableComponent {
5768
5769
  this.scrollable = true;
5769
5770
  this.scrollHeight = ''; // 'flex' or value+'px'
5770
5771
  this.virtualScroll = false; // works only if scrollable is true
5772
+ this.maxVirtualScrollItemHeight = 0;
5771
5773
  this.numToleratedItems = 10;
5772
5774
  this.paginator = false;
5773
5775
  this.alwaysShowPaginator = true;
@@ -5825,8 +5827,17 @@ class CpsTreeTableComponent {
5825
5827
  this.defScrollHeightPx = 0;
5826
5828
  this.defScrollHeight = '';
5827
5829
  this.scrollbarWidth = 0;
5830
+ this.observerDebouncers = new WeakMap();
5831
+ this.observerHandlers = new WeakMap();
5828
5832
  this.resizeObserver = new ResizeObserver((entries) => {
5829
5833
  entries.forEach((entry) => {
5834
+ if (!this.observerHandlers.has(entry.target)) {
5835
+ this.observerHandlers.set(entry.target, () => {
5836
+ entry.target.dispatchEvent(new CustomEvent('treeTableBodyResized'));
5837
+ });
5838
+ }
5839
+ clearTimeout(this.observerDebouncers.get(entry.target));
5840
+ this.observerDebouncers.set(entry.target, setTimeout(this.observerHandlers.get(entry.target), 100));
5830
5841
  const body = entry.target;
5831
5842
  const sbarVisible = body.scrollHeight > body.clientHeight;
5832
5843
  let wScroll = sbarVisible ? this.scrollbarWidth : 0;
@@ -5876,6 +5887,17 @@ class CpsTreeTableComponent {
5876
5887
  this.selectedColumns = this.columns;
5877
5888
  }
5878
5889
  ngAfterViewInit() {
5890
+ if (this.minWidth > 0) {
5891
+ const treeTableMain = this.primengTreeTable.el.nativeElement.querySelector('.p-treetable');
5892
+ if (treeTableMain)
5893
+ treeTableMain.style.overflow = 'auto';
5894
+ const scrollableWrapper = this.primengTreeTable.el.nativeElement.querySelector('.p-treetable-scrollable-wrapper');
5895
+ if (scrollableWrapper)
5896
+ scrollableWrapper.style.minWidth = this.minWidth + 'px';
5897
+ const treeTableHeader = this.primengTreeTable.el.nativeElement.querySelector('.p-treetable-header');
5898
+ if (treeTableHeader)
5899
+ treeTableHeader.style.minWidth = this.minWidth + 'px';
5900
+ }
5879
5901
  this.scrollableBody = this.primengTreeTable.el.nativeElement.querySelector('.p-treetable-scrollable-body');
5880
5902
  if (this.scrollableBody) {
5881
5903
  this.headerBox = this.primengTreeTable.el.nativeElement.querySelector('.p-treetable-scrollable-header-box');
@@ -5883,16 +5905,29 @@ class CpsTreeTableComponent {
5883
5905
  this.defScrollHeightPx = this.scrollableBody.clientHeight;
5884
5906
  if (this.headerBox) {
5885
5907
  this.scrollbarWidth = DomHandler.calculateScrollbarWidth();
5908
+ this.scrollableBody.addEventListener('treeTableBodyResized', () => {
5909
+ this._recalcVirtualHeight();
5910
+ });
5886
5911
  this.resizeObserver.observe(this.scrollableBody);
5887
5912
  }
5888
5913
  }
5889
5914
  }
5915
+ _updateVirtualScrollItemSize() {
5916
+ var _a, _b, _c, _d;
5917
+ if (!this.virtualScroll)
5918
+ return;
5919
+ const tr = (_d = (_c = (_b = (_a = this.primengTreeTable) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) === null || _c === void 0 ? void 0 : _c.querySelector('.p-treetable-tbody')) === null || _d === void 0 ? void 0 : _d.querySelector('tr');
5920
+ if (tr) {
5921
+ this.virtualScrollItemSize = tr.clientHeight || 0;
5922
+ if (this.maxVirtualScrollItemHeight > 0) {
5923
+ this.virtualScrollItemSize = Math.min(this.maxVirtualScrollItemHeight, this.virtualScrollItemSize);
5924
+ }
5925
+ }
5926
+ }
5890
5927
  ngAfterViewChecked() {
5891
- var _a, _b, _c, _d, _e;
5892
5928
  if (!this.virtualScroll || this.virtualScrollItemSize)
5893
5929
  return;
5894
- this.virtualScrollItemSize =
5895
- ((_e = (_d = (_c = (_b = (_a = this.primengTreeTable) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) === null || _c === void 0 ? void 0 : _c.querySelector('.p-treetable-tbody')) === null || _d === void 0 ? void 0 : _d.querySelector('tr')) === null || _e === void 0 ? void 0 : _e.clientHeight) || 0;
5930
+ this._recalcVirtualHeight();
5896
5931
  this.cdRef.detectChanges();
5897
5932
  }
5898
5933
  ngOnChanges(changes) {
@@ -5954,28 +5989,33 @@ class CpsTreeTableComponent {
5954
5989
  this.customSortFunction.emit(event);
5955
5990
  }
5956
5991
  _recalcVirtualHeight() {
5957
- if (this.virtualScroll && this.defScrollHeight) {
5958
- const itemsLen = this.primengTreeTable.serializedValue.length;
5959
- if (itemsLen < 1) {
5960
- this.scrollHeight = this.emptyBodyHeight
5961
- ? `calc(${this.emptyBodyHeight} + 1px)`
5962
- : this.virtualScrollItemSize + 1 + 'px';
5963
- }
5964
- else {
5965
- const curHeight = this.virtualScrollItemSize * itemsLen + 2;
5966
- if (this.defScrollHeight === 'flex') {
5967
- if (curHeight >= this.defScrollHeightPx) {
5968
- this.scrollHeight = 'flex';
5969
- setTimeout(() => {
5970
- this.scrollableBody.style.height = '100%';
5971
- this.cdRef.markForCheck();
5972
- });
5973
- return;
5992
+ setTimeout(() => {
5993
+ if (this.virtualScroll && this.defScrollHeight) {
5994
+ this._updateVirtualScrollItemSize();
5995
+ const itemsLen = this.primengTreeTable.serializedValue.length;
5996
+ if (itemsLen < 1) {
5997
+ this.scrollHeight = this.emptyBodyHeight
5998
+ ? `calc(${this.emptyBodyHeight} + 1px)`
5999
+ : this.virtualScrollItemSize + 1 + 'px';
6000
+ }
6001
+ else {
6002
+ const curHeight = this.virtualScrollItemSize * itemsLen + 2;
6003
+ if (this.defScrollHeight === 'flex') {
6004
+ if (curHeight >= this.defScrollHeightPx) {
6005
+ this.scrollHeight = 'flex';
6006
+ setTimeout(() => {
6007
+ this.scrollableBody.style.height = '100%';
6008
+ this.cdRef.markForCheck();
6009
+ });
6010
+ return;
6011
+ }
5974
6012
  }
6013
+ this.scrollHeight =
6014
+ Math.min(this.defScrollHeightPx, curHeight) + 'px';
5975
6015
  }
5976
- this.scrollHeight = Math.min(this.defScrollHeightPx, curHeight) + 'px';
6016
+ this.cdRef.markForCheck();
5977
6017
  }
5978
- }
6018
+ });
5979
6019
  }
5980
6020
  onFilterGlobal(value) {
5981
6021
  this.primengTreeTable.filterGlobal(value, 'contains');
@@ -6002,10 +6042,7 @@ class CpsTreeTableComponent {
6002
6042
  this.data = [...this.data];
6003
6043
  this.rowsRemoved.emit(this.selectedRows);
6004
6044
  this.clearSelection();
6005
- setTimeout(() => {
6006
- this._recalcVirtualHeight();
6007
- this.cdRef.markForCheck();
6008
- });
6045
+ this._recalcVirtualHeight();
6009
6046
  }
6010
6047
  clearSelection() {
6011
6048
  this.selectedRows = [];
@@ -6017,10 +6054,7 @@ class CpsTreeTableComponent {
6017
6054
  this.selectedRows = this.selectedRows.filter((v) => v !== node);
6018
6055
  this._removeNodeFromData(node);
6019
6056
  this.rowsRemoved.emit([node]);
6020
- setTimeout(() => {
6021
- this._recalcVirtualHeight();
6022
- this.cdRef.markForCheck();
6023
- });
6057
+ this._recalcVirtualHeight();
6024
6058
  }
6025
6059
  _removeNodeFromData(nodeToRemove, single = true) {
6026
6060
  const _findTopSortOrder = (_node) => {
@@ -6114,17 +6148,11 @@ class CpsTreeTableComponent {
6114
6148
  }
6115
6149
  onNodeExpanded(event) {
6116
6150
  this.nodeExpanded.emit(event);
6117
- setTimeout(() => {
6118
- this._recalcVirtualHeight();
6119
- this.cdRef.markForCheck();
6120
- });
6151
+ this._recalcVirtualHeight();
6121
6152
  }
6122
6153
  onNodeCollapsed(event) {
6123
6154
  this.nodeCollapsed.emit(event);
6124
- setTimeout(() => {
6125
- this._recalcVirtualHeight();
6126
- this.cdRef.markForCheck();
6127
- });
6155
+ this._recalcVirtualHeight();
6128
6156
  }
6129
6157
  onNodeSelected(event) {
6130
6158
  this.nodeSelected.emit(event);
@@ -6137,10 +6165,7 @@ class CpsTreeTableComponent {
6137
6165
  }
6138
6166
  onFilter(event) {
6139
6167
  this.filtered.emit(event);
6140
- setTimeout(() => {
6141
- this._recalcVirtualHeight();
6142
- this.cdRef.markForCheck();
6143
- });
6168
+ this._recalcVirtualHeight();
6144
6169
  }
6145
6170
  onSelectColumn(col) {
6146
6171
  let res = [];
@@ -6163,7 +6188,7 @@ class CpsTreeTableComponent {
6163
6188
  }
6164
6189
  }
6165
6190
  CpsTreeTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CpsTreeTableComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
6166
- CpsTreeTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsTreeTableComponent, isStandalone: true, selector: "cps-tree-table", inputs: { data: "data", columns: "columns", colHeaderName: "colHeaderName", colFieldName: "colFieldName", striped: "striped", bordered: "bordered", size: "size", selectable: "selectable", rowHover: "rowHover", showRowMenu: "showRowMenu", loading: "loading", tableStyle: "tableStyle", tableStyleClass: "tableStyleClass", sortable: "sortable", sortMode: "sortMode", customSort: "customSort", hasToolbar: "hasToolbar", toolbarSize: "toolbarSize", toolbarTitle: "toolbarTitle", toolbarIcon: "toolbarIcon", toolbarIconColor: "toolbarIconColor", scrollable: "scrollable", scrollHeight: "scrollHeight", virtualScroll: "virtualScroll", numToleratedItems: "numToleratedItems", paginator: "paginator", alwaysShowPaginator: "alwaysShowPaginator", rowsPerPageOptions: "rowsPerPageOptions", first: "first", rows: "rows", resetPageOnRowsChange: "resetPageOnRowsChange", resetPageOnSort: "resetPageOnSort", totalRecords: "totalRecords", emptyMessage: "emptyMessage", emptyBodyHeight: "emptyBodyHeight", lazy: "lazy", lazyLoadOnInit: "lazyLoadOnInit", showGlobalFilter: "showGlobalFilter", globalFilterPlaceholder: "globalFilterPlaceholder", globalFilterFields: "globalFilterFields", clearGlobalFilterOnLoading: "clearGlobalFilterOnLoading", showRemoveBtnOnSelect: "showRemoveBtnOnSelect", removeBtnOnSelectDisabled: "removeBtnOnSelectDisabled", showAdditionalBtnOnSelect: "showAdditionalBtnOnSelect", additionalBtnOnSelectTitle: "additionalBtnOnSelectTitle", additionalBtnOnSelectDisabled: "additionalBtnOnSelectDisabled", showActionBtn: "showActionBtn", actionBtnTitle: "actionBtnTitle", actionBtnDisabled: "actionBtnDisabled", showDataReloadBtn: "showDataReloadBtn", dataReloadBtnDisabled: "dataReloadBtnDisabled", showColumnsToggleBtn: "showColumnsToggleBtn", columnsToggleBtnDisabled: "columnsToggleBtnDisabled" }, outputs: { selectionChanged: "selectionChanged", actionBtnClicked: "actionBtnClicked", additionalBtnOnSelectClicked: "additionalBtnOnSelectClicked", editRowBtnClicked: "editRowBtnClicked", rowsRemoved: "rowsRemoved", pageChanged: "pageChanged", sorted: "sorted", filtered: "filtered", columnsSelected: "columnsSelected", lazyLoaded: "lazyLoaded", dataReloadBtnClicked: "dataReloadBtnClicked", nodeExpanded: "nodeExpanded", nodeCollapsed: "nodeCollapsed", nodeSelected: "nodeSelected", nodeUnselected: "nodeUnselected", customSortFunction: "customSortFunction" }, providers: [
6191
+ CpsTreeTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CpsTreeTableComponent, isStandalone: true, selector: "cps-tree-table", inputs: { data: "data", columns: "columns", colHeaderName: "colHeaderName", colFieldName: "colFieldName", minWidth: "minWidth", striped: "striped", bordered: "bordered", size: "size", selectable: "selectable", rowHover: "rowHover", showRowMenu: "showRowMenu", loading: "loading", tableStyle: "tableStyle", tableStyleClass: "tableStyleClass", sortable: "sortable", sortMode: "sortMode", customSort: "customSort", hasToolbar: "hasToolbar", toolbarSize: "toolbarSize", toolbarTitle: "toolbarTitle", toolbarIcon: "toolbarIcon", toolbarIconColor: "toolbarIconColor", scrollable: "scrollable", scrollHeight: "scrollHeight", virtualScroll: "virtualScroll", maxVirtualScrollItemHeight: "maxVirtualScrollItemHeight", numToleratedItems: "numToleratedItems", paginator: "paginator", alwaysShowPaginator: "alwaysShowPaginator", rowsPerPageOptions: "rowsPerPageOptions", first: "first", rows: "rows", resetPageOnRowsChange: "resetPageOnRowsChange", resetPageOnSort: "resetPageOnSort", totalRecords: "totalRecords", emptyMessage: "emptyMessage", emptyBodyHeight: "emptyBodyHeight", lazy: "lazy", lazyLoadOnInit: "lazyLoadOnInit", showGlobalFilter: "showGlobalFilter", globalFilterPlaceholder: "globalFilterPlaceholder", globalFilterFields: "globalFilterFields", clearGlobalFilterOnLoading: "clearGlobalFilterOnLoading", showRemoveBtnOnSelect: "showRemoveBtnOnSelect", removeBtnOnSelectDisabled: "removeBtnOnSelectDisabled", showAdditionalBtnOnSelect: "showAdditionalBtnOnSelect", additionalBtnOnSelectTitle: "additionalBtnOnSelectTitle", additionalBtnOnSelectDisabled: "additionalBtnOnSelectDisabled", showActionBtn: "showActionBtn", actionBtnTitle: "actionBtnTitle", actionBtnDisabled: "actionBtnDisabled", showDataReloadBtn: "showDataReloadBtn", dataReloadBtnDisabled: "dataReloadBtnDisabled", showColumnsToggleBtn: "showColumnsToggleBtn", columnsToggleBtnDisabled: "columnsToggleBtnDisabled" }, outputs: { selectionChanged: "selectionChanged", actionBtnClicked: "actionBtnClicked", additionalBtnOnSelectClicked: "additionalBtnOnSelectClicked", editRowBtnClicked: "editRowBtnClicked", rowsRemoved: "rowsRemoved", pageChanged: "pageChanged", sorted: "sorted", filtered: "filtered", columnsSelected: "columnsSelected", lazyLoaded: "lazyLoaded", dataReloadBtnClicked: "dataReloadBtnClicked", nodeExpanded: "nodeExpanded", nodeCollapsed: "nodeCollapsed", nodeSelected: "nodeSelected", nodeUnselected: "nodeUnselected", customSortFunction: "customSortFunction" }, providers: [
6167
6192
  TreeTableService,
6168
6193
  {
6169
6194
  provide: TreeTable,
@@ -6208,6 +6233,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
6208
6233
  type: Input
6209
6234
  }], colFieldName: [{
6210
6235
  type: Input
6236
+ }], minWidth: [{
6237
+ type: Input
6211
6238
  }], striped: [{
6212
6239
  type: Input
6213
6240
  }], bordered: [{
@@ -6248,6 +6275,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
6248
6275
  type: Input
6249
6276
  }], virtualScroll: [{
6250
6277
  type: Input
6278
+ }], maxVirtualScrollItemHeight: [{
6279
+ type: Input
6251
6280
  }], numToleratedItems: [{
6252
6281
  type: Input
6253
6282
  }], paginator: [{