@porscheinformatik/clr-addons 21.5.2 → 21.5.4

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, NgModule, Injectable, EventEmitter, Output, Input, Directive, ViewChild, ContentChildren, TemplateRef, ViewChildren, HostBinding, ElementRef, Renderer2, forwardRef, DOCUMENT, Inject, ContentChild, Optional, input, ChangeDetectionStrategy, signal, computed, SkipSelf, inject, model, contentChild, linkedSignal, DestroyRef, contentChildren, effect, NgZone, viewChild, HostAttributeToken, ViewContainerRef, afterRenderEffect, InjectionToken, isSignal, HostListener, LOCALE_ID, Self, Host, output, ChangeDetectorRef, Injector, untracked, runInInjectionContext } from '@angular/core';
2
+ import { Component, NgModule, Injectable, EventEmitter, Output, Input, Directive, ViewChild, ContentChildren, TemplateRef, ViewChildren, HostBinding, ElementRef, Renderer2, forwardRef, DOCUMENT, Inject, ContentChild, Optional, input, ChangeDetectionStrategy, signal, computed, SkipSelf, inject, model, contentChild, linkedSignal, DestroyRef, contentChildren, effect, NgZone, viewChild, ViewContainerRef, afterRenderEffect, InjectionToken, isSignal, HostListener, LOCALE_ID, Self, Host, output, ChangeDetectorRef, Injector, untracked, runInInjectionContext } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule, NgComponentOutlet, NgTemplateOutlet, getLocaleDateFormat, FormatWidth, NgOptimizedImage, NgClass } from '@angular/common';
5
5
  import * as i2 from '@clr/angular/icon';
@@ -5010,19 +5010,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
5010
5010
  */
5011
5011
  let columnId = 0;
5012
5012
  class ClrTreetableColumn {
5013
- get dataTestId() {
5014
- return this._userDataTestId ?? `treetable-column-${this.columnId}`;
5015
- }
5016
5013
  ngOnInit() {
5017
5014
  this._columnState.register({ id: this.columnId, titleTemplateRef: this._columnTitleRef() });
5018
5015
  }
5016
+ ngAfterViewInit() {
5017
+ // Only set a default testid if the consumer didn't already provide one.
5018
+ const host = this._elementRef.nativeElement;
5019
+ if (!host.hasAttribute('data-testid')) {
5020
+ this._renderer.setAttribute(host, 'data-testid', `treetable-column-${this.columnId}`);
5021
+ }
5022
+ }
5019
5023
  ngOnDestroy() {
5020
5024
  this._columnState.unregister(this.columnId);
5021
5025
  }
5022
5026
  constructor() {
5023
5027
  this.columnId = `clr-tt-col-${columnId++}`;
5024
- /* Keep a data-testid set by the consumer, and only fall back to the default when none was provided. */
5025
- this._userDataTestId = inject(new HostAttributeToken('data-testid'), { optional: true });
5028
+ this._elementRef = inject(ElementRef);
5029
+ this._renderer = inject(Renderer2);
5026
5030
  this._columnTitleRef = viewChild('columnTitle', { ...(ngDevMode ? { debugName: "_columnTitleRef" } : /* istanbul ignore next */ {}), read: TemplateRef });
5027
5031
  this._columnState = inject(TreetableColumnStateService);
5028
5032
  this._sort = inject((SortStateService));
@@ -5107,7 +5111,7 @@ class ClrTreetableColumn {
5107
5111
  this._sort.toggle(comparator, reverse);
5108
5112
  }
5109
5113
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: ClrTreetableColumn, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5110
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.20", type: ClrTreetableColumn, isStandalone: false, selector: "clr-tt-column", inputs: { clrTtSortBy: { classPropertyName: "clrTtSortBy", publicName: "clrTtSortBy", isSignal: true, isRequired: false, transformFunction: null }, clrTtSortOrder: { classPropertyName: "clrTtSortOrder", publicName: "clrTtSortOrder", isSignal: true, isRequired: false, transformFunction: null }, clrTtColumnSize: { classPropertyName: "clrTtColumnSize", publicName: "clrTtColumnSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { clrTtSortOrderChange: "clrTtSortOrderChange", clrTtColumnResize: "clrTtColumnResize" }, host: { attributes: { "role": "columnheader" }, properties: { "class.treetable-column": "true", "attr.aria-sort": "ariaSort()", "attr.data-testid": "dataTestId" } }, providers: [ClrPopoverService], viewQueries: [{ propertyName: "_columnTitleRef", first: true, predicate: ["columnTitle"], descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: `
5114
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.20", type: ClrTreetableColumn, isStandalone: false, selector: "clr-tt-column", inputs: { clrTtSortBy: { classPropertyName: "clrTtSortBy", publicName: "clrTtSortBy", isSignal: true, isRequired: false, transformFunction: null }, clrTtSortOrder: { classPropertyName: "clrTtSortOrder", publicName: "clrTtSortOrder", isSignal: true, isRequired: false, transformFunction: null }, clrTtColumnSize: { classPropertyName: "clrTtColumnSize", publicName: "clrTtColumnSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { clrTtSortOrderChange: "clrTtSortOrderChange", clrTtColumnResize: "clrTtColumnResize" }, host: { attributes: { "role": "columnheader" }, properties: { "class.treetable-column": "true", "attr.aria-sort": "ariaSort()" } }, providers: [ClrPopoverService], viewQueries: [{ propertyName: "_columnTitleRef", first: true, predicate: ["columnTitle"], descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: `
5111
5115
  @if (isSortable()) {
5112
5116
  <button type="button" class="treetable-column-title" data-testId="clrTtSortButton" (click)="sort()">
5113
5117
  <ng-container *ngTemplateOutlet="columnTitle" />
@@ -5172,7 +5176,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
5172
5176
  host: {
5173
5177
  '[class.treetable-column]': 'true',
5174
5178
  '[attr.aria-sort]': 'ariaSort()',
5175
- '[attr.data-testid]': 'dataTestId',
5176
5179
  role: 'columnheader',
5177
5180
  },
5178
5181
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -5635,16 +5638,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
5635
5638
  * This software is released under MIT license.
5636
5639
  * The full license information can be found in LICENSE in the root directory of this project.
5637
5640
  */
5641
+ const DEFAULT_TEST_ID = 'treetable-cell';
5638
5642
  class ClrTreetableCell {
5639
5643
  constructor() {
5640
- /* Keep a data-testid set by the consumer, and only fall back to the default when none was provided. */
5641
- this._userDataTestId = inject(new HostAttributeToken('data-testid'), { optional: true });
5644
+ this._elementRef = inject(ElementRef);
5645
+ this._renderer = inject(Renderer2);
5642
5646
  }
5643
- get dataTestId() {
5644
- return this._userDataTestId ?? 'treetable-cell';
5647
+ ngAfterViewInit() {
5648
+ // Only set a default testid if the consumer didn't already provide one.
5649
+ const host = this._elementRef.nativeElement;
5650
+ if (!host.hasAttribute('data-testid')) {
5651
+ this._renderer.setAttribute(host, 'data-testid', DEFAULT_TEST_ID);
5652
+ }
5645
5653
  }
5646
5654
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: ClrTreetableCell, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
5647
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.20", type: ClrTreetableCell, isStandalone: false, selector: "clr-tt-cell", host: { attributes: { "role": "gridcell" }, properties: { "class.treetable-cell": "true", "attr.data-testid": "dataTestId" } }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
5655
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.20", type: ClrTreetableCell, isStandalone: false, selector: "clr-tt-cell", host: { attributes: { "role": "gridcell" }, properties: { "class.treetable-cell": "true" } }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
5648
5656
  }
5649
5657
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: ClrTreetableCell, decorators: [{
5650
5658
  type: Component,
@@ -5653,7 +5661,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
5653
5661
  template: '<ng-content></ng-content>',
5654
5662
  host: {
5655
5663
  '[class.treetable-cell]': 'true',
5656
- '[attr.data-testid]': 'dataTestId',
5657
5664
  role: 'gridcell',
5658
5665
  },
5659
5666
  standalone: false,
@@ -5733,6 +5740,7 @@ class TreetableHeaderRenderer {
5733
5740
  }
5734
5741
  setWidth(width) {
5735
5742
  const el = this.elementRef.nativeElement;
5743
+ this.renderer.setStyle(el, 'max-width', `${width}px`);
5736
5744
  this.renderer.setStyle(el, 'width', `${width}px`);
5737
5745
  this.renderer.setStyle(el, 'flex', '0 0 auto');
5738
5746
  }
@@ -5776,6 +5784,7 @@ class TreetableCellRenderer {
5776
5784
  }
5777
5785
  setWidth(width) {
5778
5786
  const el = this.elementRef.nativeElement;
5787
+ this.renderer.setStyle(el, 'max-width', `${width}px`);
5779
5788
  this.renderer.setStyle(el, 'width', `${width}px`);
5780
5789
  this.renderer.setStyle(el, 'flex', '0 0 auto');
5781
5790
  }
@@ -13189,7 +13198,9 @@ class StatePersistenceKeyDirective {
13189
13198
  }
13190
13199
  initColumnOrder(savedState) {
13191
13200
  if (savedState?.columns) {
13192
- const entries = Object.entries(savedState.columns).map(([key, value]) => [key, value.order]);
13201
+ const entries = Object.entries(savedState.columns)
13202
+ .filter(([, value]) => typeof value.order === 'number')
13203
+ .map(([key, value]) => [key, value.order]);
13193
13204
  this.reorderDirective.initializeColumnOrder(Object.fromEntries(entries));
13194
13205
  }
13195
13206
  }