@porscheinformatik/clr-addons 10.4.0 → 10.4.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.
Files changed (35) hide show
  1. package/abstract-form-component/abstract-form-component.d.ts +3 -2
  2. package/brand-avatar/index.d.ts +2 -0
  3. package/bundles/clr-addons.umd.js +95 -47
  4. package/bundles/clr-addons.umd.js.map +1 -1
  5. package/clr-addons.d.ts +0 -2
  6. package/clr-addons.metadata.json +1 -1
  7. package/esm2015/abstract-form-component/abstract-form-component.js +8 -7
  8. package/esm2015/abstract-form-component/abstract-form-component.ngsummary.json +1 -1
  9. package/esm2015/brand-avatar/index.js +8 -0
  10. package/esm2015/brand-avatar/index.ngsummary.json +1 -0
  11. package/esm2015/clr-addons.js +1 -3
  12. package/esm2015/clr-addons.ngsummary.json +1 -1
  13. package/esm2015/generic-quick-list/generic-quick-list.js +4 -3
  14. package/esm2015/index.js +3 -2
  15. package/esm2015/index.ngsummary.json +1 -1
  16. package/esm2015/multilingual/abstract-multilingual.js +4 -2
  17. package/esm2015/multilingual/multilingual-input/multilingual-input.ngfactory.js +1 -1
  18. package/esm2015/multilingual/multilingual-input/multilingual-input.ngsummary.json +1 -1
  19. package/esm2015/multilingual/multilingual-textarea/multilingual-textarea.ngfactory.js +1 -1
  20. package/esm2015/multilingual/multilingual-textarea/multilingual-textarea.ngsummary.json +1 -1
  21. package/esm2015/numericfield/numeric-field.js +29 -15
  22. package/esm2015/numericfield/numeric-field.ngsummary.json +1 -1
  23. package/esm2015/public_api.ngsummary.json +1 -1
  24. package/fesm2015/clr-addons.js +52 -27
  25. package/fesm2015/clr-addons.js.map +1 -1
  26. package/index.d.ts +1 -0
  27. package/numericfield/numeric-field.d.ts +3 -2
  28. package/package.json +1 -1
  29. package/src/main-nav-group/main-nav-group.scss +7 -2
  30. package/styles/clr-addons-phs.css +9 -7
  31. package/styles/clr-addons-phs.css.map +1 -1
  32. package/styles/clr-addons-phs.min.css +1 -1
  33. package/styles/clr-addons-phs.min.css.map +1 -1
  34. package/bundles/clr-addons.umd.min.js +0 -17
  35. package/bundles/clr-addons.umd.min.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { AfterViewInit, Injector, OnDestroy } from '@angular/core';
1
+ import { AfterViewInit, Injector, OnDestroy, OnInit } from '@angular/core';
2
2
  import { ControlValueAccessor, FormControl } from '@angular/forms';
3
3
  import { Subject } from 'rxjs';
4
- export declare abstract class ClrAbstractFormComponent implements ControlValueAccessor, AfterViewInit, OnDestroy {
4
+ export declare abstract class ClrAbstractFormComponent implements ControlValueAccessor, OnInit, AfterViewInit, OnDestroy {
5
5
  private injector;
6
6
  formControl: boolean;
7
7
  showError: boolean;
@@ -11,6 +11,7 @@ export declare abstract class ClrAbstractFormComponent implements ControlValueAc
11
11
  invalid: boolean;
12
12
  destroyed: Subject<unknown>;
13
13
  constructor(injector: Injector);
14
+ ngOnInit(): void;
14
15
  ngAfterViewInit(): void;
15
16
  abstract writeValue(value: unknown): void;
16
17
  onChange: (_: unknown) => void;
@@ -0,0 +1,2 @@
1
+ export * from './brand-avatar';
2
+ export * from './brand-avatar.module';
@@ -1,8 +1,28 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@clr/angular'), require('rxjs'), require('rxjs/operators'), require('@angular/router'), require('@angular/animations'), require('@clr/icons'), require('@clr/icons/shapes/all-shapes')) :
3
3
  typeof define === 'function' && define.amd ? define('@porscheinformatik/clr-addons', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@clr/angular', 'rxjs', 'rxjs/operators', '@angular/router', '@angular/animations', '@clr/icons', '@clr/icons/shapes/all-shapes'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.porscheinformatik = global.porscheinformatik || {}, global.porscheinformatik['clr-addons'] = {}), global.ng.core, global.ng.common, global.ng.forms, global['@clr/angular'], global.rxjs, global.rxjs.operators, global.ng.router, global.ng.animations, global.icons, global.allShapes));
5
- }(this, (function (exports, i0, common, forms, angular, rxjs, operators, router, animations, icons, allShapes) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.porscheinformatik = global.porscheinformatik || {}, global.porscheinformatik["clr-addons"] = {}), global.ng.core, global.ng.common, global.ng.forms, global["@clr/angular"], global.rxjs, global.rxjs.operators, global.ng.router, global.ng.animations, global.icons, global.allShapes));
5
+ })(this, (function (exports, i0, common, forms, angular, rxjs, operators, router, animations, icons, allShapes) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
6
26
 
7
27
  /*
8
28
  * Copyright (c) 2018-2019 Porsche Informatik. All Rights Reserved.
@@ -60,7 +80,7 @@
60
80
  };
61
81
  return ClrBreadcrumbService;
62
82
  }());
63
- ClrBreadcrumbService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ClrBreadcrumbService_Factory() { return new ClrBreadcrumbService(); }, token: ClrBreadcrumbService, providedIn: "root" });
83
+ ClrBreadcrumbService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ClrBreadcrumbService_Factory() { return new ClrBreadcrumbService(); }, token: ClrBreadcrumbService, providedIn: "root" });
64
84
  ClrBreadcrumbService.decorators = [
65
85
  { type: i0.Injectable, args: [{
66
86
  providedIn: 'root',
@@ -775,7 +795,7 @@
775
795
  };
776
796
  ClrGenericQuickList.prototype.ngAfterViewInit = function () {
777
797
  var _this = this;
778
- this.timeout = setTimeout(function () { return _this.setFocusOnAdd(); }, 1);
798
+ this.timeout = setTimeout(function () { return _this.setFocusOnAdd(); });
779
799
  };
780
800
  ClrGenericQuickList.prototype.addItem = function () {
781
801
  var newItem = Object.assign({}, this.blankItem);
@@ -792,9 +812,10 @@
792
812
  this.rowCountFocus = this.itemRows.length;
793
813
  this.itemRows.changes.subscribe(function (els) {
794
814
  if (els.length > _this.rowCountFocus && !!els.last) {
795
- var firstFocusable = els.last.nativeElement.querySelector("button, a, input, select, textarea, [tabindex]:not([tabindex='-1'])");
796
- if (firstFocusable) {
797
- firstFocusable.focus();
815
+ var firstFocusable_1 = els.last.nativeElement.querySelector("button, a, input, select, textarea, [tabindex]:not([tabindex='-1'])");
816
+ if (firstFocusable_1) {
817
+ // needed if the first focusable binds to focus attribute -> ExpressionHasChangedAfterItHasBeenChecked
818
+ setTimeout(function () { return firstFocusable_1.focus(); });
798
819
  }
799
820
  }
800
821
  _this.rowCountFocus = els.length;
@@ -1826,6 +1847,12 @@
1826
1847
  this.onChange = function (_) { };
1827
1848
  this.onTouch = this.defaultOnTouch;
1828
1849
  }
1850
+ ClrAbstractFormComponent.prototype.ngOnInit = function () {
1851
+ var controlIdService = this.injector.get(angular["ɵbc"], null);
1852
+ if (controlIdService) {
1853
+ this.inputId = controlIdService.id;
1854
+ }
1855
+ };
1829
1856
  ClrAbstractFormComponent.prototype.ngAfterViewInit = function () {
1830
1857
  var _this = this;
1831
1858
  // get the form control to know invalid state in angular
@@ -1837,18 +1864,13 @@
1837
1864
  _this.showError = _this.invalid && _this.control.touched;
1838
1865
  });
1839
1866
  }
1840
- var markControlService = this.injector.get(angular.ɵbi, null);
1867
+ var markControlService = this.injector.get(angular["ɵbi"], null);
1841
1868
  if (markControlService) {
1842
1869
  markControlService.touchedChange.subscribe(function () {
1843
1870
  _this.control.markAsTouched();
1844
1871
  _this.control.updateValueAndValidity();
1845
1872
  });
1846
1873
  }
1847
- var controlIdService = this.injector.get(angular.ɵbc, null);
1848
- if (controlIdService) {
1849
- // timeout to prevent ExpressionChangedAfterItHasBeenCheckedError
1850
- setTimeout(function () { return (_this.inputId = controlIdService.id); });
1851
- }
1852
1874
  };
1853
1875
  ClrAbstractFormComponent.prototype.registerOnChange = function (fn) {
1854
1876
  this.onChange = fn;
@@ -1905,10 +1927,12 @@
1905
1927
  };
1906
1928
  ClrMultilingualAbstract.prototype.changeLanguage = function (lang) {
1907
1929
  var _this = this;
1930
+ // need as the click for closing the menu is registered on a single item
1931
+ // if the language change destroys it immediately, the click won't get fired
1908
1932
  setTimeout(function () {
1909
1933
  _this.selectedLang = lang;
1910
1934
  _this.inputElement.nativeElement.focus();
1911
- }, 0);
1935
+ });
1912
1936
  };
1913
1937
  return ClrMultilingualAbstract;
1914
1938
  }(ClrAbstractFormComponent));
@@ -1945,7 +1969,7 @@
1945
1969
  useExisting: i0.forwardRef(function () { return ClrMultilingualInput; }),
1946
1970
  multi: true,
1947
1971
  },
1948
- angular.ɵbc,
1972
+ angular["ɵbc"],
1949
1973
  ]
1950
1974
  },] }
1951
1975
  ];
@@ -1970,7 +1994,7 @@
1970
1994
  useExisting: i0.forwardRef(function () { return ClrMultilingualTextarea; }),
1971
1995
  multi: true,
1972
1996
  },
1973
- angular.ɵbc,
1997
+ angular["ɵbc"],
1974
1998
  ]
1975
1999
  },] }
1976
2000
  ];
@@ -2246,11 +2270,11 @@
2246
2270
  this.autofillDecimals = false;
2247
2271
  this.decimalSeparator = ',';
2248
2272
  this.groupingSeparator = '.';
2249
- this.unit = null;
2250
2273
  this.unitPosition = 'right';
2251
2274
  this.numericValueChanged = new i0.EventEmitter();
2252
2275
  this.displayValue = '';
2253
2276
  this.originalValue = NaN;
2277
+ this._unit = null;
2254
2278
  this.allowedKeys = new Set(NUMBERS);
2255
2279
  /* Control Values Accessor Stuff below */
2256
2280
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -2269,6 +2293,20 @@
2269
2293
  enumerable: false,
2270
2294
  configurable: true
2271
2295
  });
2296
+ Object.defineProperty(ClrNumericField.prototype, "unit", {
2297
+ set: function (value) {
2298
+ if (value != this._unit) {
2299
+ this._unit = value;
2300
+ if (this.unitSpan != null) {
2301
+ this.unitSpan.innerHTML = '';
2302
+ var newUnitText = this.renderer.createText(value);
2303
+ this.renderer.appendChild(this.unitSpan, newUnitText);
2304
+ }
2305
+ }
2306
+ },
2307
+ enumerable: false,
2308
+ configurable: true
2309
+ });
2272
2310
  ClrNumericField.prototype.registerOnChange = function (fn) {
2273
2311
  this.onChange = fn;
2274
2312
  };
@@ -2356,18 +2394,13 @@
2356
2394
  this.injectUnitSymbol();
2357
2395
  };
2358
2396
  ClrNumericField.prototype.handleInputChanged = function () {
2359
- var _this = this;
2360
- // Call in set timeout to avoid Expression has changed after it has been checked error.
2361
- // Sometimes the value changes because we cut off decimal places
2362
- setTimeout(function () {
2363
- _this.updateInput(_this.formatNumber(_this._numericValue.toString().replace(new RegExp('[.]', 'g'), _this.decimalSeparator), true));
2364
- }, 1);
2397
+ this.updateInput(this.formatNumber(this._numericValue.toString().replace(new RegExp('[.]', 'g'), this.decimalSeparator), true), true);
2365
2398
  };
2366
2399
  ClrNumericField.prototype.formatInput = function (element, finalFormatting) {
2367
2400
  var cursorPos = element.selectionStart;
2368
2401
  var length = element.value.length;
2369
2402
  var setCursor = this.displayValue !== element.value;
2370
- this.updateInput(this.formatNumber(element.value, finalFormatting));
2403
+ this.updateInput(this.formatNumber(element.value, finalFormatting), false);
2371
2404
  if (setCursor) {
2372
2405
  element.selectionStart = element.selectionEnd = Math.max(cursorPos + element.value.length - length, 0);
2373
2406
  }
@@ -2477,13 +2510,21 @@
2477
2510
  }
2478
2511
  return result;
2479
2512
  };
2480
- ClrNumericField.prototype.updateInput = function (value) {
2513
+ ClrNumericField.prototype.updateInput = function (value, updateAsync) {
2514
+ var _this = this;
2481
2515
  this.displayValue = value;
2482
2516
  this.inputEl.nativeElement.value = value;
2483
2517
  this._numericValue = parseFloat(this.strip(value).replace(this.decimalSeparator, '.'));
2484
2518
  if (this._numericValue !== this.roundOrTruncate(this.originalValue)) {
2485
2519
  this.originalValue = this._numericValue;
2486
- this.numericValueChanged.emit(this._numericValue);
2520
+ if (updateAsync) {
2521
+ // Call in setTimeout to avoid Expression has changed after it has been checked error.
2522
+ // This happens for example if the initial input has more decimal places than allowed
2523
+ setTimeout(function () { return _this.numericValueChanged.emit(_this._numericValue); });
2524
+ }
2525
+ else {
2526
+ this.numericValueChanged.emit(this._numericValue);
2527
+ }
2487
2528
  }
2488
2529
  };
2489
2530
  ClrNumericField.prototype.getValueForFormControl = function () {
@@ -2497,7 +2538,7 @@
2497
2538
  ClrNumericField.prototype.injectUnitSymbol = function () {
2498
2539
  // Need to inject the unit symbol when the input element width is set to its actual value,
2499
2540
  // otherwise the icon wont show in the correct position
2500
- if (!!this.unit && !this.unitSpan && this.inputEl.nativeElement.offsetWidth !== 0) {
2541
+ if (!!this._unit && !this.unitSpan && this.inputEl.nativeElement.offsetWidth !== 0) {
2501
2542
  // Get the input wrapper and apply necessary styles
2502
2543
  var inputWrapper = this.inputEl.nativeElement.parentNode;
2503
2544
  this.renderer.addClass(inputWrapper, 'numeric-input-wrapper');
@@ -2505,7 +2546,7 @@
2505
2546
  if (!this.unitSpan) {
2506
2547
  this.unitSpan = this.renderer.createElement('span');
2507
2548
  this.renderer.addClass(this.unitSpan, 'unit');
2508
- var unitSymbol = this.renderer.createText(this.unit);
2549
+ var unitSymbol = this.renderer.createText(this._unit);
2509
2550
  this.renderer.appendChild(this.unitSpan, unitSymbol);
2510
2551
  this.renderer.appendChild(inputWrapper, this.unitSpan);
2511
2552
  }
@@ -2537,7 +2578,8 @@
2537
2578
  };
2538
2579
  ClrNumericField.prototype.roundOrTruncate = function (value) {
2539
2580
  var method = this.roundValue ? 'round' : value < 0 ? 'ceil' : 'floor';
2540
- return Math[method](value * Math.pow(10, this.decimalPlaces)) / Math.pow(10, this.decimalPlaces);
2581
+ // 16 is the highest precision before numbers have weird behaviour. see https://stackoverflow.com/q/21472828/15120942
2582
+ return Math[method](+(value * Math.pow(10, this.decimalPlaces)).toPrecision(16)) / Math.pow(10, this.decimalPlaces);
2541
2583
  };
2542
2584
  return ClrNumericField;
2543
2585
  }());
@@ -2570,10 +2612,10 @@
2570
2612
  autofillDecimals: [{ type: i0.Input, args: ['clrAutofillDecimals',] }],
2571
2613
  decimalSeparator: [{ type: i0.Input, args: ['clrDecimalSep',] }],
2572
2614
  groupingSeparator: [{ type: i0.Input, args: ['clrGroupingSep',] }],
2573
- unit: [{ type: i0.Input, args: ['clrUnit',] }],
2574
2615
  unitPosition: [{ type: i0.Input, args: ['clrUnitPosition',] }],
2575
2616
  numericValueChanged: [{ type: i0.Output, args: ['clrNumericValueChange',] }],
2576
- numericValue: [{ type: i0.Input, args: ['clrNumericValue',] }]
2617
+ numericValue: [{ type: i0.Input, args: ['clrNumericValue',] }],
2618
+ unit: [{ type: i0.Input, args: ['clrUnit',] }]
2577
2619
  };
2578
2620
 
2579
2621
  /*
@@ -4233,7 +4275,7 @@
4233
4275
  * This software is released under MIT license.
4234
4276
  * The full license information can be found in LICENSE in the root directory of this project.
4235
4277
  */
4236
- var AcceptedBrands;
4278
+ exports.AcceptedBrands = void 0;
4237
4279
  (function (AcceptedBrands) {
4238
4280
  AcceptedBrands[AcceptedBrands["AUDI"] = 0] = "AUDI";
4239
4281
  AcceptedBrands[AcceptedBrands["CUPRA"] = 1] = "CUPRA";
@@ -4243,14 +4285,14 @@
4243
4285
  AcceptedBrands[AcceptedBrands["SKODA"] = 5] = "SKODA";
4244
4286
  AcceptedBrands[AcceptedBrands["VW"] = 6] = "VW";
4245
4287
  AcceptedBrands[AcceptedBrands["VWN"] = 7] = "VWN";
4246
- })(AcceptedBrands || (AcceptedBrands = {}));
4288
+ })(exports.AcceptedBrands || (exports.AcceptedBrands = {}));
4247
4289
  var ClrBrandAvatar = /** @class */ (function () {
4248
4290
  function ClrBrandAvatar() {
4249
4291
  this.avatar = true;
4250
4292
  }
4251
4293
  ClrBrandAvatar.prototype.getShape = function () {
4252
4294
  var brandName = ClrBrandAvatar.getCleanBrandName(this.brand);
4253
- if (brandName in AcceptedBrands) {
4295
+ if (brandName in exports.AcceptedBrands) {
4254
4296
  return 'brand-' + brandName.toLowerCase();
4255
4297
  }
4256
4298
  return ClrBrandAvatar.DEFAULT_ICON_SHAPE;
@@ -4663,7 +4705,13 @@
4663
4705
  */
4664
4706
 
4665
4707
  /*
4666
- * Copyright (c) 2018-2020 Porsche Informatik. All Rights Reserved.
4708
+ * Copyright (c) 2020 Porsche Informatik. All Rights Reserved.
4709
+ * This software is released under MIT license.
4710
+ * The full license information can be found in LICENSE in the root directory of this project.
4711
+ */
4712
+
4713
+ /*
4714
+ * Copyright (c) 2018-2021 Porsche Informatik. All Rights Reserved.
4667
4715
  * This software is released under MIT license.
4668
4716
  * The full license information can be found in LICENSE in the root directory of this project.
4669
4717
  */
@@ -4699,6 +4747,8 @@
4699
4747
  exports.ClrAddonsModule = ClrAddonsModule;
4700
4748
  exports.ClrBackButton = ClrBackButton;
4701
4749
  exports.ClrBackButtonModule = ClrBackButtonModule;
4750
+ exports.ClrBrandAvatar = ClrBrandAvatar;
4751
+ exports.ClrBrandAvatarModule = ClrBrandAvatarModule;
4702
4752
  exports.ClrBreadcrumb = ClrBreadcrumb;
4703
4753
  exports.ClrBreadcrumbModule = ClrBreadcrumbModule;
4704
4754
  exports.ClrBreadcrumbService = ClrBreadcrumbService;
@@ -4838,19 +4888,17 @@
4838
4888
  exports.escapeHtml = escapeHtml;
4839
4889
  exports.escapeRegex = escapeRegex;
4840
4890
  exports.loadIcons = loadIcons;
4841
- exports.ɵa = TreetableMainRenderer;
4842
- exports.ɵb = TreetableHeaderRenderer;
4843
- exports.ɵc = TreetableRowRenderer;
4844
- exports.ɵd = TreetableCellRenderer;
4845
- exports.ɵe = ClrAddOption;
4846
- exports.ɵf = ClrMultilingualAbstract;
4847
- exports.ɵg = ClrAbstractFormComponent;
4848
- exports.ɵh = ClrAutocompleteOffModule;
4849
- exports.ɵi = ClrAutocompleteOff;
4850
- exports.ɵj = ClrBrandAvatarModule;
4851
- exports.ɵk = ClrBrandAvatar;
4891
+ exports["ɵa"] = TreetableMainRenderer;
4892
+ exports["ɵb"] = TreetableHeaderRenderer;
4893
+ exports["ɵc"] = TreetableRowRenderer;
4894
+ exports["ɵd"] = TreetableCellRenderer;
4895
+ exports["ɵe"] = ClrAddOption;
4896
+ exports["ɵf"] = ClrMultilingualAbstract;
4897
+ exports["ɵg"] = ClrAbstractFormComponent;
4898
+ exports["ɵh"] = ClrAutocompleteOffModule;
4899
+ exports["ɵi"] = ClrAutocompleteOff;
4852
4900
 
4853
4901
  Object.defineProperty(exports, '__esModule', { value: true });
4854
4902
 
4855
- })));
4903
+ }));
4856
4904
  //# sourceMappingURL=clr-addons.umd.js.map