@porscheinformatik/clr-addons 10.4.3 → 10.5.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,4 +1,5 @@
1
- import { Component, NgModule, ɵɵdefineInjectable, Injectable, EventEmitter, Input, Output, Directive, Renderer2, ElementRef, ViewChild, ContentChildren, TemplateRef, ViewChildren, APP_INITIALIZER, HostBinding, Injector, forwardRef, NgZone, ContentChild, ChangeDetectorRef, HostListener, ApplicationRef, ComponentFactoryResolver, Inject } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { Component, NgModule, Injectable, EventEmitter, Input, Output, Directive, Renderer2, ElementRef, ViewChild, ContentChildren, TemplateRef, ViewChildren, APP_INITIALIZER, HostBinding, Injector, forwardRef, NgZone, ContentChild, ChangeDetectorRef, HostListener, ApplicationRef, ComponentFactoryResolver, Inject } from '@angular/core';
2
3
  import { Location, CommonModule, DOCUMENT } from '@angular/common';
3
4
  import { FormsModule, NG_VALIDATORS, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
4
5
  import { ClarityModule, ClrFormsModule, ɵbc, ɵbi, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService } from '@clr/angular';
@@ -60,7 +61,7 @@ class ClrBreadcrumbService {
60
61
  this.breadcrumbChange.next(breadcrumbElements);
61
62
  }
62
63
  }
63
- ClrBreadcrumbService.ɵprov = ɵɵdefineInjectable({ factory: function ClrBreadcrumbService_Factory() { return new ClrBreadcrumbService(); }, token: ClrBreadcrumbService, providedIn: "root" });
64
+ ClrBreadcrumbService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ClrBreadcrumbService_Factory() { return new ClrBreadcrumbService(); }, token: ClrBreadcrumbService, providedIn: "root" });
64
65
  ClrBreadcrumbService.decorators = [
65
66
  { type: Injectable, args: [{
66
67
  providedIn: 'root',
@@ -2136,7 +2137,8 @@ class ClrNumericField {
2136
2137
  }
2137
2138
  roundOrTruncate(value) {
2138
2139
  const method = this.roundValue ? 'round' : value < 0 ? 'ceil' : 'floor';
2139
- return Math[method](value * Math.pow(10, this.decimalPlaces)) / Math.pow(10, this.decimalPlaces);
2140
+ // 16 is the highest precision before numbers have weird behaviour. see https://stackoverflow.com/q/21472828/15120942
2141
+ return Math[method](+(value * Math.pow(10, this.decimalPlaces)).toPrecision(16)) / Math.pow(10, this.decimalPlaces);
2140
2142
  }
2141
2143
  }
2142
2144
  ClrNumericField.decorators = [
@@ -3306,7 +3308,7 @@ ClrTreetableModule.decorators = [
3306
3308
  ];
3307
3309
 
3308
3310
  /*
3309
- * Copyright (c) 2018-2019 Porsche Informatik. All Rights Reserved.
3311
+ * Copyright (c) 2018-2022 Porsche Informatik. All Rights Reserved.
3310
3312
  * This software is released under MIT license.
3311
3313
  * The full license information can be found in LICENSE in the root directory of this project.
3312
3314
  */
@@ -3316,11 +3318,23 @@ class ClrViewEditSection {
3316
3318
  this._preventSave = false;
3317
3319
  this._cancelText = 'Cancel';
3318
3320
  this._editable = true;
3319
- this._editMode = false;
3320
3321
  this._editIcon = 'pencil';
3322
+ this._isCollapsible = false;
3323
+ this._isCollapsed = false;
3324
+ this._isCollapsedChange = new EventEmitter();
3321
3325
  this._editModeChanged = new EventEmitter(false);
3322
3326
  this._submitted = new EventEmitter(false);
3323
3327
  this._cancelled = new EventEmitter(false);
3328
+ this._editMode = false;
3329
+ }
3330
+ set editMode(value) {
3331
+ this._editMode = value;
3332
+ if (value) {
3333
+ this.toggleCollapsed(false);
3334
+ }
3335
+ }
3336
+ get editMode() {
3337
+ return this._editMode;
3324
3338
  }
3325
3339
  onSubmit() {
3326
3340
  this._submitted.emit();
@@ -3334,16 +3348,47 @@ class ClrViewEditSection {
3334
3348
  }
3335
3349
  onEdit() {
3336
3350
  this.setEditMode(true);
3351
+ this.toggleCollapsed(false);
3337
3352
  }
3338
3353
  setEditMode(mode) {
3339
- this._editMode = mode;
3340
- this._editModeChanged.emit(this._editMode);
3354
+ this.editMode = mode;
3355
+ this._editModeChanged.emit(this.editMode);
3356
+ }
3357
+ toggleCollapsed(collapsed) {
3358
+ this._isCollapsed = collapsed;
3359
+ this._isCollapsedChange.emit(this._isCollapsed);
3360
+ }
3361
+ onCollapseExpand() {
3362
+ if (this._isCollapsed) {
3363
+ this.toggleCollapsed(false);
3364
+ }
3365
+ else {
3366
+ this.toggleCollapsed(true);
3367
+ }
3341
3368
  }
3342
3369
  }
3343
3370
  ClrViewEditSection.decorators = [
3344
3371
  { type: Component, args: [{
3345
3372
  selector: 'clr-view-edit-section',
3346
- template: "<div class=\"card view-edit-section\" (keyup.escape)=\"onCancel()\">\n <div class=\"card-block\">\n <div class=\"card-title\">\n {{_title}}\n <div class=\"ves-actions\">\n <button\n type=\"button\"\n (click)=\"onEdit()\"\n class=\"btn btn-icon btn-link ves-action\"\n *ngIf=\"_editable && !_editMode && actionBlock.children.length == 0\"\n >\n <clr-icon class=\"ves-edit-icon\" [attr.shape]=\"_editIcon\" size=\"20\"></clr-icon>\n </button>\n <div #actionBlock>\n <ng-content select=\"[action-block]\"></ng-content>\n </div>\n </div>\n </div>\n <div class=\"card-text\">\n <ng-template [ngTemplateOutlet]=\"viewRef\" *ngIf=\"!_editMode\"></ng-template>\n <ng-template [ngTemplateOutlet]=\"editRef\" *ngIf=\"_editMode\"></ng-template>\n <ng-container *ngIf=\"_editMode\">\n <form clrForm (ngSubmit)=\"onSubmit()\" class=\"button-bar\">\n <button class=\"btn btn-primary ves-save\" type=\"submit\">{{_saveText}}</button>\n <button class=\"btn ves-cancel\" (click)=\"onCancel()\" type=\"button\">{{_cancelText}}</button>\n </form>\n </ng-container>\n </div>\n </div>\n</div>\n"
3373
+ template: "<div class=\"card view-edit-section\" (keyup.escape)=\"onCancel()\">\n <div class=\"card-block\">\n <div class=\"card-title\">\n {{_title}}\n <button\n type=\"button\"\n (click)=\"onCollapseExpand()\"\n class=\"btn btn-icon btn-link ces-caret-btn\"\n *ngIf=\"_isCollapsible && !editMode\"\n >\n <clr-icon shape=\"caret up\" size=\"20\" class=\"ces-caret-icon\" [@rotateIcon]=\"_isCollapsed\"></clr-icon>\n </button>\n <div class=\"ves-actions\">\n <button\n type=\"button\"\n (click)=\"onEdit()\"\n class=\"btn btn-icon btn-link ves-action\"\n *ngIf=\"_editable && !editMode && actionBlock.children.length == 0\"\n >\n <clr-icon class=\"ves-edit-icon\" [attr.shape]=\"_editIcon\" size=\"20\"></clr-icon>\n </button>\n <div #actionBlock>\n <ng-content select=\"[action-block]\"></ng-content>\n </div>\n </div>\n </div>\n <div class=\"card-text\" [@collapseExpandAnimation] *ngIf=\"!(_isCollapsed && _isCollapsible)\">\n <ng-template [ngTemplateOutlet]=\"viewRef\" *ngIf=\"!editMode\"></ng-template>\n <ng-template [ngTemplateOutlet]=\"editRef\" *ngIf=\"editMode\"></ng-template>\n <ng-container *ngIf=\"editMode\">\n <form clrForm (ngSubmit)=\"onSubmit()\" class=\"button-bar\">\n <button class=\"btn btn-primary ves-save\" type=\"submit\">{{_saveText}}</button>\n <button class=\"btn ves-cancel\" (click)=\"onCancel()\" type=\"button\">{{_cancelText}}</button>\n </form>\n </ng-container>\n </div>\n </div>\n</div>\n",
3374
+ animations: [
3375
+ trigger('collapseExpandAnimation', [
3376
+ transition(':enter', [
3377
+ style({ opacity: 0, height: 0, overflow: 'hidden' }),
3378
+ animate('300ms', style({ opacity: 1, height: '*' })),
3379
+ ]),
3380
+ transition(':leave', [
3381
+ style({ opacity: 1, height: '*', overflow: 'hidden' }),
3382
+ animate('300ms', style({ opacity: 0, height: 0 })),
3383
+ ]),
3384
+ ]),
3385
+ trigger('rotateIcon', [
3386
+ state('true', style({ transform: 'rotate(0)' })),
3387
+ state('false', style({ transform: 'rotate(180deg)' })),
3388
+ transition('true => false', animate('300ms ease-out')),
3389
+ transition('false => true', animate('300ms ease-in')),
3390
+ ]),
3391
+ ]
3347
3392
  },] }
3348
3393
  ];
3349
3394
  ClrViewEditSection.propDecorators = {
@@ -3352,13 +3397,16 @@ ClrViewEditSection.propDecorators = {
3352
3397
  _preventSave: [{ type: Input, args: ['clrPreventModeChangeOnSave',] }],
3353
3398
  _cancelText: [{ type: Input, args: ['clrCancelText',] }],
3354
3399
  _editable: [{ type: Input, args: ['clrEditable',] }],
3355
- _editMode: [{ type: Input, args: ['clrEditMode',] }],
3356
3400
  _editIcon: [{ type: Input, args: ['clrEditIcon',] }],
3401
+ _isCollapsible: [{ type: Input, args: ['clrIsCollapsible',] }],
3402
+ _isCollapsed: [{ type: Input, args: ['clrIsCollapsed',] }],
3357
3403
  viewRef: [{ type: Input, args: ['clrViewRef',] }],
3358
3404
  editRef: [{ type: Input, args: ['clrEditRef',] }],
3405
+ _isCollapsedChange: [{ type: Output, args: ['clrIsCollapsedChange',] }],
3359
3406
  _editModeChanged: [{ type: Output, args: ['clrEditModeChange',] }],
3360
3407
  _submitted: [{ type: Output, args: ['clrSectionSubmitted',] }],
3361
- _cancelled: [{ type: Output, args: ['clrSectionEditCancelled',] }]
3408
+ _cancelled: [{ type: Output, args: ['clrSectionEditCancelled',] }],
3409
+ editMode: [{ type: Input, args: ['clrEditMode',] }]
3362
3410
  };
3363
3411
 
3364
3412
  /*