@shival99/z-ui 2.6.6 → 2.6.7

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.
@@ -21,7 +21,7 @@ import { ZTooltipDirective } from '@shival99/z-ui/components/z-tooltip';
21
21
  import { ZSafeHtmlPipe, ZFormatNumPipe } from '@shival99/z-ui/pipes';
22
22
  import { ZTranslateService, ZCacheService } from '@shival99/z-ui/services';
23
23
  import { ZExcelService } from '@shival99/z-ui/services/excel';
24
- import { zMergeClasses } from '@shival99/z-ui/utils';
24
+ import { zMergeClasses, zCreateDestroySafeTimeout } from '@shival99/z-ui/utils';
25
25
  import { tableFeatures, createSortedRowModel, createPaginatedRowModel, createFilteredRowModel, createFacetedUniqueValues, createFacetedRowModel, createFacetedMinMaxValues, createExpandedRowModel, stockFeatures, injectTable, FlexRenderDirective } from '@tanstack/angular-table';
26
26
  import { injectVirtualizer, defaultRangeExtractor, elementScroll } from '@tanstack/angular-virtual';
27
27
  import { NgScrollbar } from 'ngx-scrollbar';
@@ -5624,6 +5624,7 @@ class ZTableComponent {
5624
5624
  _zTranslate = inject(ZTranslateService);
5625
5625
  _overlayService = inject(ZOverlayService);
5626
5626
  _viewContainerRef = inject(ViewContainerRef);
5627
+ _destroyRef = inject(DestroyRef);
5627
5628
  /** Prevents recursive scroll sync between thead/tbody/tfoot */
5628
5629
  _isSyncingScroll = signal(false, /* @ts-ignore */
5629
5630
  ...(ngDevMode ? [{ debugName: "_isSyncingScroll" }] : /* istanbul ignore next */ []));
@@ -5637,7 +5638,7 @@ class ZTableComponent {
5637
5638
  _settingsDebounceTimeout = null;
5638
5639
  _visibilityDebounceTimeout = null;
5639
5640
  /** Debounces filter change emissions to server */
5640
- _filterEmitDebounceTimeout = null;
5641
+ _filterEmitDebounceTimer = zCreateDestroySafeTimeout(this._destroyRef);
5641
5642
  /** Keeps the bulk bar mounted long enough for its exit animation */
5642
5643
  _bulkBarTimer = null;
5643
5644
  _bulkBarOverlayRef = null;
@@ -6431,7 +6432,10 @@ class ZTableComponent {
6431
6432
  if (this.isServerGrouping()) {
6432
6433
  const selectedColumnId = this.groupingColumnIds()[0];
6433
6434
  const fallbackColumnId = this.serverGroupColumnId();
6434
- return selectedColumnId ? [selectedColumnId] : fallbackColumnId ? [fallbackColumnId] : [];
6435
+ if (selectedColumnId) {
6436
+ return [selectedColumnId];
6437
+ }
6438
+ return fallbackColumnId ? [fallbackColumnId] : [];
6435
6439
  }
6436
6440
  return this.groupingColumnIds();
6437
6441
  }, /* @ts-ignore */
@@ -7932,7 +7936,13 @@ class ZTableComponent {
7932
7936
  const stickyGroupMeta = this._stickyGroupHeaderMeta();
7933
7937
  // Estimate for not-yet-measured rows: learned height if available, else virtual.size.
7934
7938
  const dynamicRowEstimate = isDynamic && this._dynamicEstimateHeight !== null ? this._dynamicEstimateHeight : rowHeight;
7935
- const itemCount = isGrouping ? flatItems.length : groups.length > 0 ? groups.length : this._virtualGroupCount();
7939
+ let itemCount = this._virtualGroupCount();
7940
+ if (isGrouping) {
7941
+ itemCount = flatItems.length;
7942
+ }
7943
+ if (!isGrouping && groups.length > 0) {
7944
+ itemCount = groups.length;
7945
+ }
7936
7946
  return {
7937
7947
  scrollElement,
7938
7948
  count: itemCount,
@@ -8306,11 +8316,13 @@ class ZTableComponent {
8306
8316
  // Virtual scroll windows the rows itself, so it needs the full row model — otherwise the
8307
8317
  // default pageSize of 10 leaves the paginated row model truncating the data it ever sees.
8308
8318
  const isVirtualConfig = !!cfg.virtual && (typeof cfg.virtual === 'boolean' ? cfg.virtual : cfg.virtual.enabled);
8309
- const configuredPageSize = cfg.pagination?.enabled
8310
- ? cfg.pagination.pageSize
8311
- : isVirtualConfig
8312
- ? Number.MAX_SAFE_INTEGER
8313
- : undefined;
8319
+ let configuredPageSize;
8320
+ if (cfg.pagination?.enabled) {
8321
+ configuredPageSize = cfg.pagination.pageSize;
8322
+ }
8323
+ if (!cfg.pagination?.enabled && isVirtualConfig) {
8324
+ configuredPageSize = Number.MAX_SAFE_INTEGER;
8325
+ }
8314
8326
  const initialPageSize = cfg.initialState?.pagination?.pageSize;
8315
8327
  const paginationSchemaKey = `${this._getConfigCacheKey(key || 'initial-pagination')}:${configuredPageSize ?? ''}:${initialPageSize ?? ''}`;
8316
8328
  if (!cfg.initialState?.pagination &&
@@ -8567,11 +8579,13 @@ class ZTableComponent {
8567
8579
  updateItem: (id, updates, fieldKey) => {
8568
8580
  const current = this.zConfig();
8569
8581
  current.data = current.data.map((row, index) => {
8570
- const rowId = fieldKey
8571
- ? row[fieldKey]
8572
- : current.getRowId
8573
- ? current.getRowId(row, index, undefined, current.data)
8574
- : row['id'];
8582
+ let rowId = row['id'];
8583
+ if (fieldKey) {
8584
+ rowId = row[fieldKey];
8585
+ }
8586
+ if (!fieldKey && current.getRowId) {
8587
+ rowId = current.getRowId(row, index, undefined, current.data);
8588
+ }
8575
8589
  return rowId === id ? { ...row, ...updates } : row;
8576
8590
  });
8577
8591
  this._dataForceUpdate.update(v => v + 1);
@@ -8580,11 +8594,13 @@ class ZTableComponent {
8580
8594
  deleteItem: (id, fieldKey) => {
8581
8595
  const current = this.zConfig();
8582
8596
  current.data = current.data.filter((row, index) => {
8583
- const rowId = fieldKey
8584
- ? row[fieldKey]
8585
- : current.getRowId
8586
- ? current.getRowId(row, index, undefined, current.data)
8587
- : row['id'];
8597
+ let rowId = row['id'];
8598
+ if (fieldKey) {
8599
+ rowId = row[fieldKey];
8600
+ }
8601
+ if (!fieldKey && current.getRowId) {
8602
+ rowId = current.getRowId(row, index, undefined, current.data);
8603
+ }
8588
8604
  return rowId !== id;
8589
8605
  });
8590
8606
  this._dataForceUpdate.update(v => v + 1);
@@ -8826,10 +8842,7 @@ class ZTableComponent {
8826
8842
  }, this.zConfig().debounceTime ?? Z_DEFAULT_DEBOUNCE_TIME);
8827
8843
  }
8828
8844
  _emitFilterChangeDebounced(filters, search) {
8829
- if (this._filterEmitDebounceTimeout) {
8830
- clearTimeout(this._filterEmitDebounceTimeout);
8831
- }
8832
- this._filterEmitDebounceTimeout = setTimeout(() => {
8845
+ this._filterEmitDebounceTimer.schedule(() => {
8833
8846
  this.zChange.emit({
8834
8847
  type: 'filter',
8835
8848
  data: { filters, search },
@@ -10076,7 +10089,7 @@ class ZTableComponent {
10076
10089
  if (!(target instanceof HTMLElement)) {
10077
10090
  return false;
10078
10091
  }
10079
- return !!target.closest('button, input, textarea, select, [contenteditable="true"], z-input, z-select, z-calendar, z-checkbox, z-switch');
10092
+ return !!target.closest('button, input, textarea, select, [contenteditable="true"], z-input, z-select, z-calendar, z-checkbox, z-switch, scrollbar-thumb-x, scrollbar-thumb-y, scrollbar-track-x, scrollbar-track-y, scrollbarbutton');
10080
10093
  }
10081
10094
  _isCellSelectionDragTarget(target) {
10082
10095
  if (this._document.body.classList.contains('z-table-pointer-dragging')) {
@@ -10600,7 +10613,13 @@ class ZTableComponent {
10600
10613
  if (position && !this.pinAvailabilityMap()[columnId]?.[position]) {
10601
10614
  return;
10602
10615
  }
10603
- const tanStackPosition = position === 'left' ? 'start' : position === 'right' ? 'end' : false;
10616
+ let tanStackPosition = false;
10617
+ if (position === 'left') {
10618
+ tanStackPosition = 'start';
10619
+ }
10620
+ if (position === 'right') {
10621
+ tanStackPosition = 'end';
10622
+ }
10604
10623
  column.pin(tanStackPosition);
10605
10624
  // A configured header colSpan renders as one solid block, so pinning (or unpinning) the
10606
10625
  // leading column must carry its covered columns along — otherwise unpinning only the