zek 14.2.49 → 14.2.51

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.
package/fesm2020/zek.mjs CHANGED
@@ -335,11 +335,14 @@ class Convert {
335
335
  }
336
336
  return false;
337
337
  }
338
- static toNumber(value) {
339
- if (typeof value !== 'undefined' && value !== null && value !== '') {
340
- return +value;
341
- }
342
- return 0;
338
+ static toNumber(value, defaultValue = 0) {
339
+ return this.isNumber(value) ? Number(value) : defaultValue;
340
+ }
341
+ static isNumber(value) {
342
+ // parseFloat(value) handles most of the cases we're interested in (it treats null, empty string,
343
+ // and other non-number values as NaN, where Number just uses 0) but it considers the string
344
+ // '123hello' to be a valid number. Therefore we also check if Number(value) is NaN.
345
+ return !isNaN(parseFloat(value)) && !isNaN(Number(value));
343
346
  }
344
347
  }
345
348
 
@@ -788,9 +791,6 @@ class ObjectHelper {
788
791
  }
789
792
  }
790
793
  ;
791
- static isBoolean(val) {
792
- return val === false || val === true;
793
- }
794
794
  static deepCopy(value) {
795
795
  if (!this.isObject(value))
796
796
  return value;
@@ -4854,39 +4854,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImpor
4854
4854
  }]
4855
4855
  }] });
4856
4856
 
4857
- function toPercent(v) {
4858
- let n = MathHelper.round(Convert.toNumber(v));
4859
- if (n > 100) {
4860
- return 100;
4861
- }
4862
- else if (n < 0) {
4863
- return 0;
4864
- }
4865
- return n;
4857
+ function clamp(v, min = 0, max = 100) {
4858
+ return Math.max(min, Math.min(max, v));
4866
4859
  }
4867
4860
  class ZekProgress {
4868
4861
  constructor() {
4869
- this._max = 100;
4870
4862
  this._value = 0;
4871
- this._normalizedValue = 0;
4872
4863
  this._showValue = false;
4873
4864
  this._striped = false;
4874
4865
  this._animated = false;
4875
4866
  this._label = null;
4876
4867
  this._height = null;
4877
- }
4878
- get max() {
4879
- return this._max;
4880
- }
4881
- set max(v) {
4882
- this._max = toPercent(v);
4868
+ this._background = 'primary';
4883
4869
  }
4884
4870
  get value() {
4885
4871
  return this._value;
4886
4872
  }
4887
4873
  set value(v) {
4888
- this._value = Convert.toNumber(v);
4889
- this._normalizedValue = toPercent(this._value);
4874
+ this._value = clamp(Convert.toNumber(v) || 0);
4890
4875
  }
4891
4876
  get showValue() {
4892
4877
  return this._showValue;
@@ -4910,19 +4895,14 @@ class ZekProgress {
4910
4895
  return this._label;
4911
4896
  }
4912
4897
  set label(v) {
4913
- if (this.label)
4914
- this._label = v;
4898
+ this._label = v ? v : null;
4915
4899
  }
4916
4900
  get height() {
4917
4901
  return this._height;
4918
4902
  }
4919
4903
  set height(v) {
4920
- if (ObjectHelper.isDefined(v)) {
4921
- this._height = Convert.toNumber(v);
4922
- }
4923
- else {
4924
- this._height = null;
4925
- }
4904
+ let tmp = Convert.toNumber(v) || 0;
4905
+ this._height = tmp > 0 ? tmp : null;
4926
4906
  }
4927
4907
  get background() {
4928
4908
  return this._background;
@@ -4932,11 +4912,13 @@ class ZekProgress {
4932
4912
  }
4933
4913
  }
4934
4914
  ZekProgress.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: ZekProgress, deps: [], target: i0.ɵɵFactoryTarget.Component });
4935
- ZekProgress.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: ZekProgress, selector: "zek-progress", inputs: { max: "max", striped: "striped", animated: "animated", label: "label", height: "height", background: "background" }, ngImport: i0, template: "<div class=\"progress\">\r\n <div class=\"progress-bar\" role=\"progressbar\"\r\n [class.progress-bar-striped]=\"striped || animated\"\r\n [class.progress-bar-animated]=\"animated\"\r\n [style.height.px]=\"height\"\r\n [style.width.%]=\"_normalizedValue\"\r\n [attr.aria-valuenow]=\"_normalizedValue\"\r\n aria-valuemin=\"0\"\r\n [attr.aria-valuemax]=\"max\">\r\n <ng-container *ngIf=\"showValue\">{{_normalizedValue}}%</ng-container>\r\n {{label}}\r\n </div>\r\n</div>", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4915
+ ZekProgress.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: ZekProgress, selector: "zek-progress", inputs: { value: "value", showValue: "showValue", striped: "striped", animated: "animated", label: "label", height: "height", background: "background" }, ngImport: i0, template: "<div class=\"progress\">\r\n <div class=\"progress-bar bg-{{background}}\" role=\"progressbar\"\r\n [class.progress-bar-striped]=\"striped || animated\"\r\n [class.progress-bar-animated]=\"animated\"\r\n [style.height.px]=\"height\"\r\n [style.width.%]=\"value\"\r\n [attr.aria-valuenow]=\"value\"\r\n aria-valuemin=\"0\"\r\n aria-valuemax=\"100\">\r\n <ng-container *ngIf=\"showValue\">{{value}}%</ng-container>\r\n {{label}}\r\n </div>\r\n</div>", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4936
4916
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: ZekProgress, decorators: [{
4937
4917
  type: Component,
4938
- args: [{ selector: 'zek-progress', template: "<div class=\"progress\">\r\n <div class=\"progress-bar\" role=\"progressbar\"\r\n [class.progress-bar-striped]=\"striped || animated\"\r\n [class.progress-bar-animated]=\"animated\"\r\n [style.height.px]=\"height\"\r\n [style.width.%]=\"_normalizedValue\"\r\n [attr.aria-valuenow]=\"_normalizedValue\"\r\n aria-valuemin=\"0\"\r\n [attr.aria-valuemax]=\"max\">\r\n <ng-container *ngIf=\"showValue\">{{_normalizedValue}}%</ng-container>\r\n {{label}}\r\n </div>\r\n</div>", styles: [":host{display:block}\n"] }]
4939
- }], propDecorators: { max: [{
4918
+ args: [{ selector: 'zek-progress', template: "<div class=\"progress\">\r\n <div class=\"progress-bar bg-{{background}}\" role=\"progressbar\"\r\n [class.progress-bar-striped]=\"striped || animated\"\r\n [class.progress-bar-animated]=\"animated\"\r\n [style.height.px]=\"height\"\r\n [style.width.%]=\"value\"\r\n [attr.aria-valuenow]=\"value\"\r\n aria-valuemin=\"0\"\r\n aria-valuemax=\"100\">\r\n <ng-container *ngIf=\"showValue\">{{value}}%</ng-container>\r\n {{label}}\r\n </div>\r\n</div>", styles: [":host{display:block}\n"] }]
4919
+ }], propDecorators: { value: [{
4920
+ type: Input
4921
+ }], showValue: [{
4940
4922
  type: Input
4941
4923
  }], striped: [{
4942
4924
  type: Input