@porscheinformatik/clr-addons 12.5.0 → 12.6.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.
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, NgModule, Injectable, EventEmitter, Input, Output, Directive, ViewChild, TemplateRef, ContentChildren, ViewChildren, HostBinding, ElementRef, Renderer2, forwardRef, ContentChild, HostListener, InjectionToken, Inject, Optional } from '@angular/core';
2
+ import { Component, NgModule, Injectable, EventEmitter, Input, Output, Directive, ViewChild, ContentChildren, TemplateRef, ViewChildren, HostBinding, ElementRef, Renderer2, forwardRef, ContentChild, HostListener, InjectionToken, Inject, Optional } from '@angular/core';
3
3
  import * as i2 from '@angular/common';
4
4
  import { CommonModule, DOCUMENT } from '@angular/common';
5
5
  import * as i3$1 from '@angular/forms';
6
6
  import { FormsModule, NG_VALIDATORS, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
7
7
  import * as i1 from '@clr/angular';
8
- import { ClarityModule, ClrFormsModule, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule } from '@clr/angular';
8
+ import { ClarityModule, ClrFormsModule, ClrDropdown, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule, ClrDatagridPagination } from '@clr/angular';
9
9
  import { Subject, BehaviorSubject, timer, asyncScheduler, interval, of, ReplaySubject, takeUntil as takeUntil$1 } from 'rxjs';
10
10
  import { takeUntil, observeOn, take } from 'rxjs/operators';
11
11
  import * as i3 from '@angular/router';
@@ -645,22 +645,49 @@ class ClrDropdownOverflowDirective {
645
645
  this.elRef = elRef;
646
646
  this.defaultItemMinHeightRem = 1.5;
647
647
  this.marginBottomRem = 0.1;
648
+ this.destroy$ = new Subject();
648
649
  }
649
- ngAfterViewInit() {
650
- this.calculateDropdownMenu();
650
+ ngAfterContentInit() {
651
+ // first trigger manually because the subscription lower only triggers after first change
652
+ if (!this.nestedDropdownChildren?.length) {
653
+ this.applyDropdownOverflowStyles();
654
+ }
655
+ this.nestedDropdownChildren.changes.pipe(takeUntil(this.destroy$)).subscribe((children) => {
656
+ // if there are any nested dropdowns, our overflow fix prevents those from showing and needs to be removed
657
+ if (!children?.length) {
658
+ this.applyDropdownOverflowStyles();
659
+ }
660
+ else if (children?.length) {
661
+ this.removeDropdownOverflowStyles();
662
+ }
663
+ });
651
664
  }
652
- calculateDropdownMenu() {
665
+ ngOnDestroy() {
666
+ this.destroy$.next();
667
+ this.destroy$.complete();
668
+ }
669
+ applyDropdownOverflowStyles() {
653
670
  // the vertical position of our element in the current window
654
671
  const y = this.elRef.nativeElement.getBoundingClientRect().y;
655
672
  const itemMinHeightPx = this.getItemMinHeight(this.clrDropdownMenuItemMinHeight);
656
673
  // see https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements
657
- for (const item of this.elRef.nativeElement.getElementsByClassName('dropdown-item')) {
674
+ for (const item of this.getAllChildDropdownMenuItems()) {
658
675
  item.style.minHeight = itemMinHeightPx + 'px';
659
676
  }
660
677
  this.elRef.nativeElement.style.maxHeight =
661
678
  this.getMenuMaxHeight(this.clrDropdownMenuMaxHeight, window.innerHeight - y - this.convertRemToPixels(this.marginBottomRem)) + 'px';
662
679
  this.elRef.nativeElement.style.overflowY = 'auto';
663
680
  }
681
+ removeDropdownOverflowStyles() {
682
+ for (const item of this.getAllChildDropdownMenuItems()) {
683
+ item.style.minHeight = null;
684
+ }
685
+ this.elRef.nativeElement.style.maxHeight = null;
686
+ this.elRef.nativeElement.style.overflowY = null;
687
+ }
688
+ getAllChildDropdownMenuItems() {
689
+ return this.elRef.nativeElement.getElementsByClassName('dropdown-item');
690
+ }
664
691
  getMenuMaxHeight(menuMaxHeightProvided, menuMaxHeightPx) {
665
692
  if (menuMaxHeightProvided) {
666
693
  const maxHeightPx = this.convertToPixels(menuMaxHeightProvided);
@@ -698,7 +725,7 @@ class ClrDropdownOverflowDirective {
698
725
  }
699
726
  }
700
727
  ClrDropdownOverflowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrDropdownOverflowDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
701
- ClrDropdownOverflowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: ClrDropdownOverflowDirective, selector: "clr-dropdown-menu", inputs: { clrDropdownMenuMaxHeight: "clrDropdownMenuMaxHeight", clrDropdownMenuItemMinHeight: "clrDropdownMenuItemMinHeight" }, ngImport: i0 });
728
+ ClrDropdownOverflowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: ClrDropdownOverflowDirective, selector: "clr-dropdown-menu", inputs: { clrDropdownMenuMaxHeight: "clrDropdownMenuMaxHeight", clrDropdownMenuItemMinHeight: "clrDropdownMenuItemMinHeight" }, queries: [{ propertyName: "nestedDropdownChildren", predicate: ClrDropdown, descendants: true }], ngImport: i0 });
702
729
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrDropdownOverflowDirective, decorators: [{
703
730
  type: Directive,
704
731
  args: [{ selector: 'clr-dropdown-menu' }]
@@ -706,6 +733,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
706
733
  type: Input
707
734
  }], clrDropdownMenuItemMinHeight: [{
708
735
  type: Input
736
+ }], nestedDropdownChildren: [{
737
+ type: ContentChildren,
738
+ args: [ClrDropdown, { descendants: true }]
709
739
  }] } });
710
740
 
711
741
  /*
@@ -1745,14 +1775,14 @@ class ClrMultilingualTextarea extends ClrMultilingualAbstract {
1745
1775
  }
1746
1776
  }
1747
1777
  ClrMultilingualTextarea.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrMultilingualTextarea, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
1748
- ClrMultilingualTextarea.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: ClrMultilingualTextarea, selector: "clr-multilingual-textarea", providers: [
1778
+ ClrMultilingualTextarea.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: ClrMultilingualTextarea, selector: "clr-multilingual-textarea", inputs: { rows: "rows" }, providers: [
1749
1779
  {
1750
1780
  provide: NG_VALUE_ACCESSOR,
1751
1781
  useExisting: forwardRef(() => ClrMultilingualTextarea),
1752
1782
  multi: true,
1753
1783
  },
1754
1784
  ControlIdService,
1755
- ], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"label\"></ng-content>\n<div class=\"clr-control-container\" [ngClass]=\"controlClasses\">\n <clr-multilingual-selector\n *ngIf=\"showLanguageSelector()\"\n [disabled]=\"disabled\"\n [texts]=\"shownTexts\"\n [selectedLang]=\"selectedLang\"\n (selectedLangChange)=\"changeLanguage($event)\"\n >\n </clr-multilingual-selector>\n <div class=\"clr-multi-input-wrapper\">\n <div class=\"clr-textarea-wrapper\">\n <textarea\n class=\"clr-textarea\"\n [id]=\"inputId\"\n [ngModel]=\"!!shownTexts && !!selectedLang ? shownTexts.get(selectedLang) : ''\"\n (ngModelChange)=\"setText(selectedLang, $event)\"\n (blur)=\"onTouch()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly || readonly === ''\"\n [maxlength]=\"maxlength || null\"\n #input\n ></textarea>\n <clr-icon *ngIf=\"showError\" class=\"clr-validate-icon\" shape=\"exclamation-circle\" aria-hidden=\"true\"></clr-icon>\n </div>\n <ng-content select=\"clr-control-helper\" *ngIf=\"!showError\"></ng-content>\n <ng-content select=\"clr-control-error\" *ngIf=\"showError\"></ng-content>\n </div>\n</div>\n", components: [{ type: ClrMultilingualSelector, selector: "clr-multilingual-selector", inputs: ["disabled", "texts", "selectedLang"], outputs: ["selectedLangChange"] }], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3$1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1.ClrIconCustomTag, selector: "clr-icon" }] });
1785
+ ], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"label\"></ng-content>\n<div class=\"clr-control-container\" [ngClass]=\"controlClasses\">\n <clr-multilingual-selector\n *ngIf=\"showLanguageSelector()\"\n [disabled]=\"disabled\"\n [texts]=\"shownTexts\"\n [selectedLang]=\"selectedLang\"\n (selectedLangChange)=\"changeLanguage($event)\"\n >\n </clr-multilingual-selector>\n <div class=\"clr-multi-input-wrapper\">\n <div class=\"clr-textarea-wrapper\">\n <textarea\n class=\"clr-textarea\"\n [id]=\"inputId\"\n [ngModel]=\"!!shownTexts && !!selectedLang ? shownTexts.get(selectedLang) : ''\"\n (ngModelChange)=\"setText(selectedLang, $event)\"\n (blur)=\"onTouch()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly || readonly === ''\"\n [maxlength]=\"maxlength || null\"\n [rows]=\"rows || 1\"\n #input\n ></textarea>\n <clr-icon *ngIf=\"showError\" class=\"clr-validate-icon\" shape=\"exclamation-circle\" aria-hidden=\"true\"></clr-icon>\n </div>\n <ng-content select=\"clr-control-helper\" *ngIf=\"!showError\"></ng-content>\n <ng-content select=\"clr-control-error\" *ngIf=\"showError\"></ng-content>\n </div>\n</div>\n", components: [{ type: ClrMultilingualSelector, selector: "clr-multilingual-selector", inputs: ["disabled", "texts", "selectedLang"], outputs: ["selectedLangChange"] }], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3$1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { type: i1.ClrIconCustomTag, selector: "clr-icon" }] });
1756
1786
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrMultilingualTextarea, decorators: [{
1757
1787
  type: Component,
1758
1788
  args: [{ selector: 'clr-multilingual-textarea', providers: [
@@ -1762,8 +1792,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
1762
1792
  multi: true,
1763
1793
  },
1764
1794
  ControlIdService,
1765
- ], template: "<ng-content select=\"label\"></ng-content>\n<div class=\"clr-control-container\" [ngClass]=\"controlClasses\">\n <clr-multilingual-selector\n *ngIf=\"showLanguageSelector()\"\n [disabled]=\"disabled\"\n [texts]=\"shownTexts\"\n [selectedLang]=\"selectedLang\"\n (selectedLangChange)=\"changeLanguage($event)\"\n >\n </clr-multilingual-selector>\n <div class=\"clr-multi-input-wrapper\">\n <div class=\"clr-textarea-wrapper\">\n <textarea\n class=\"clr-textarea\"\n [id]=\"inputId\"\n [ngModel]=\"!!shownTexts && !!selectedLang ? shownTexts.get(selectedLang) : ''\"\n (ngModelChange)=\"setText(selectedLang, $event)\"\n (blur)=\"onTouch()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly || readonly === ''\"\n [maxlength]=\"maxlength || null\"\n #input\n ></textarea>\n <clr-icon *ngIf=\"showError\" class=\"clr-validate-icon\" shape=\"exclamation-circle\" aria-hidden=\"true\"></clr-icon>\n </div>\n <ng-content select=\"clr-control-helper\" *ngIf=\"!showError\"></ng-content>\n <ng-content select=\"clr-control-error\" *ngIf=\"showError\"></ng-content>\n </div>\n</div>\n" }]
1766
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
1795
+ ], template: "<ng-content select=\"label\"></ng-content>\n<div class=\"clr-control-container\" [ngClass]=\"controlClasses\">\n <clr-multilingual-selector\n *ngIf=\"showLanguageSelector()\"\n [disabled]=\"disabled\"\n [texts]=\"shownTexts\"\n [selectedLang]=\"selectedLang\"\n (selectedLangChange)=\"changeLanguage($event)\"\n >\n </clr-multilingual-selector>\n <div class=\"clr-multi-input-wrapper\">\n <div class=\"clr-textarea-wrapper\">\n <textarea\n class=\"clr-textarea\"\n [id]=\"inputId\"\n [ngModel]=\"!!shownTexts && !!selectedLang ? shownTexts.get(selectedLang) : ''\"\n (ngModelChange)=\"setText(selectedLang, $event)\"\n (blur)=\"onTouch()\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly || readonly === ''\"\n [maxlength]=\"maxlength || null\"\n [rows]=\"rows || 1\"\n #input\n ></textarea>\n <clr-icon *ngIf=\"showError\" class=\"clr-validate-icon\" shape=\"exclamation-circle\" aria-hidden=\"true\"></clr-icon>\n </div>\n <ng-content select=\"clr-control-helper\" *ngIf=\"!showError\"></ng-content>\n <ng-content select=\"clr-control-error\" *ngIf=\"showError\"></ng-content>\n </div>\n</div>\n" }]
1796
+ }], ctorParameters: function () { return [{ type: i0.Injector }]; }, propDecorators: { rows: [{
1797
+ type: Input
1798
+ }] } });
1767
1799
 
1768
1800
  /*
1769
1801
  * Copyright (c) 2018-2022 Porsche Informatik. All Rights Reserved.
@@ -4576,9 +4608,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
4576
4608
  }] } });
4577
4609
 
4578
4610
  class StatePersistenceKeyDirective {
4611
+ ngAfterContentInit() {
4612
+ if (this.pagination && this.pagination.page) {
4613
+ /* persist page size changes in local storage */
4614
+ this.pagination.page.sizeChange.subscribe(pageSize => {
4615
+ let state = JSON.parse(localStorage.getItem(this.clrStatePersistenceKey));
4616
+ if (!state) {
4617
+ state = {};
4618
+ }
4619
+ state.pageSize = pageSize;
4620
+ localStorage.setItem(this.clrStatePersistenceKey, JSON.stringify(state));
4621
+ });
4622
+ /* init page size of datagrid if already persisted in local storage */
4623
+ const state = JSON.parse(localStorage.getItem(this.clrStatePersistenceKey));
4624
+ if (state && state.pageSize) {
4625
+ /* postpone set size to other cycle as it is already set in this change detection cycle */
4626
+ setTimeout(() => (this.pagination.page.size = state.pageSize));
4627
+ }
4628
+ }
4629
+ }
4579
4630
  }
4580
4631
  StatePersistenceKeyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: StatePersistenceKeyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4581
- StatePersistenceKeyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: StatePersistenceKeyDirective, selector: "[clrStatePersistenceKey]", inputs: { clrStatePersistenceKey: "clrStatePersistenceKey" }, ngImport: i0 });
4632
+ StatePersistenceKeyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: StatePersistenceKeyDirective, selector: "[clrStatePersistenceKey]", inputs: { clrStatePersistenceKey: "clrStatePersistenceKey" }, queries: [{ propertyName: "pagination", first: true, predicate: ClrDatagridPagination, descendants: true }], ngImport: i0 });
4582
4633
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: StatePersistenceKeyDirective, decorators: [{
4583
4634
  type: Directive,
4584
4635
  args: [{
@@ -4586,6 +4637,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
4586
4637
  }]
4587
4638
  }], propDecorators: { clrStatePersistenceKey: [{
4588
4639
  type: Input
4640
+ }], pagination: [{
4641
+ type: ContentChild,
4642
+ args: [ClrDatagridPagination]
4589
4643
  }] } });
4590
4644
 
4591
4645
  class ColumnHiddenStatePersistenceDirective {
@@ -4611,10 +4665,9 @@ class ColumnHiddenStatePersistenceDirective {
4611
4665
  if (persistedGridStateJson !== null) {
4612
4666
  const persistedGridState = JSON.parse(persistedGridStateJson);
4613
4667
  /* read column state if existing */
4614
- const persistedColumnState = persistedGridState[this.columnDirective.clrDgField];
4615
- if (persistedColumnState) {
4668
+ if (persistedGridState.columns && persistedGridState.columns[this.columnDirective.clrDgField]) {
4616
4669
  /* read column hidden state if existing */
4617
- const persistedColumnHiddenState = persistedColumnState.hidden;
4670
+ const persistedColumnHiddenState = persistedGridState.columns[this.columnDirective.clrDgField].hidden;
4618
4671
  if (persistedColumnHiddenState) {
4619
4672
  this.hideableColumnDirective.clrDgHidden = persistedColumnHiddenState === true;
4620
4673
  }
@@ -4630,10 +4683,13 @@ class ColumnHiddenStatePersistenceDirective {
4630
4683
  persistedGridState = JSON.parse(persistedGridStateJson);
4631
4684
  }
4632
4685
  /* read column state if existing */
4633
- let persistedColumnState = persistedGridState[this.columnDirective.clrDgField];
4686
+ if (!persistedGridState.columns) {
4687
+ persistedGridState.columns = {};
4688
+ }
4689
+ let persistedColumnState = persistedGridState.columns[this.columnDirective.clrDgField];
4634
4690
  if (!persistedColumnState) {
4635
4691
  persistedColumnState = {};
4636
- persistedGridState[this.columnDirective.clrDgField] = persistedColumnState;
4692
+ persistedGridState.columns[this.columnDirective.clrDgField] = persistedColumnState;
4637
4693
  }
4638
4694
  /* set column hidden state and persist in local storage */
4639
4695
  persistedColumnState.hidden = hidden;