@wizishop/angular-components 0.0.109 → 0.0.112

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.
@@ -927,7 +927,8 @@
927
927
  this.confirmDeleteText = '';
928
928
  this.confirmDeletePosition = 'right';
929
929
  this.click = new i0.EventEmitter();
930
- this.isLoading = false;
930
+ this.isLoadingChange = new i0.EventEmitter();
931
+ this._isLoading = false;
931
932
  this.interval = null;
932
933
  this.waitForConfirmDelete = false;
933
934
  this.buttonMaxWidth = '0px';
@@ -936,30 +937,45 @@
936
937
  this.buttonWidthDelete = '0px';
937
938
  this.currentLoading = 0;
938
939
  }
940
+ Object.defineProperty(ButtonComponent.prototype, "isLoading", {
941
+ get: function () {
942
+ return this._isLoading;
943
+ },
944
+ set: function (isLoading) {
945
+ this._isLoading = isLoading;
946
+ this.isLoadingChange.next(isLoading);
947
+ this.toggleLoading();
948
+ },
949
+ enumerable: false,
950
+ configurable: true
951
+ });
939
952
  ButtonComponent.prototype.ngOnInit = function () {
940
953
  if (this.confirmDelete) {
941
954
  this.waitForConfirmDelete = true;
942
955
  }
943
956
  };
944
- ButtonComponent.prototype.launchLoading = function () {
957
+ ButtonComponent.prototype.toggleLoading = function () {
945
958
  var _this = this;
946
- if (this.isLoading || this.interval !== null) {
947
- return;
948
- }
949
- this.isLoading = true;
950
- this.currentLoading = 10;
951
- this.interval = setInterval(function () {
959
+ this.currentLoading = this.isLoading ? 10 : 100;
960
+ rxjs.interval(200).pipe(operators.takeWhile(function (time) { return _this.isLoading; })).subscribe(function () {
952
961
  if (_this.currentLoading < 85) {
953
962
  _this.currentLoading += Math.floor(Math.random() * 15);
954
963
  }
955
- if (!_this.isLoading) {
956
- _this.currentLoading = 100;
957
- setTimeout(function () {
958
- clearInterval(_this.interval);
959
- _this.interval = null;
960
- }, 100);
961
- }
962
- }, 200);
964
+ });
965
+ /* this.interval = setInterval(() => {
966
+
967
+ if (this.currentLoading < 85) {
968
+ this.currentLoading += Math.floor(Math.random() * 15);
969
+ }
970
+
971
+ if (!this.isLoading) {
972
+ this.currentLoading = 100;
973
+
974
+ setTimeout(() => {
975
+ clearInterval(this.interval);
976
+ }, 100);
977
+ }
978
+ }, 200); */
963
979
  };
964
980
  ButtonComponent.prototype.addMaxWidth = function () {
965
981
  this.buttonMaxWidth = this.buttonWidth + 'px';
@@ -975,21 +991,26 @@
975
991
  this.waitForConfirmDelete = true;
976
992
  };
977
993
  ButtonComponent.prototype.onButtonClick = function (event) {
994
+ var _this = this;
978
995
  event.stopPropagation();
979
- if (!this.disabled) {
980
- if (this.hasLoader) {
981
- this.launchLoading();
982
- }
983
- if (!this.waitForConfirmDelete) {
984
- this.click.emit(event);
985
- if (this.confirmDelete) {
986
- this.resetMaxWidthDelete();
987
- }
988
- }
989
- else {
990
- this.waitForConfirmDelete = false;
996
+ if (this.disabled) {
997
+ return;
998
+ }
999
+ if (this.hasLoader) {
1000
+ this.isLoading = false;
1001
+ setTimeout(function () {
1002
+ _this.isLoading = true;
1003
+ }, 0);
1004
+ }
1005
+ if (!this.waitForConfirmDelete) {
1006
+ this.click.emit(event);
1007
+ if (this.confirmDelete) {
1008
+ this.resetMaxWidthDelete();
991
1009
  }
992
1010
  }
1011
+ else {
1012
+ this.waitForConfirmDelete = false;
1013
+ }
993
1014
  };
994
1015
  ButtonComponent.prototype.ngAfterViewInit = function () {
995
1016
  var _this = this;
@@ -1007,7 +1028,7 @@
1007
1028
  ButtonComponent.decorators = [
1008
1029
  { type: i0.Component, args: [{
1009
1030
  selector: 'wac-button',
1010
- template: "<a\n [class]=\"'wac-button ' + extraClasses\"\n (click)=\"confirmDelete && waitForConfirmDelete ? addMaxWidthDelete() : '';onButtonClick($event);\"\n (mouseleave)=\"animation ? resetMaxWidth() : '';\"\n (mouseenter)=\"animation ? addMaxWidth() : '';\"\n wzAutoHide (clickOutside)=\"confirmDelete && !waitForConfirmDelete ? resetMaxWidthDelete() : ''\"\n [ngClass]=\"[\n label === '' ? 'alone' : '',\n animationRight ? 'animation-right' : '',\n animation ? 'animationText' : '',\n isLoading ? 'is-loading' : '',\n opacity ? 'opacity' : '',\n disabled ? 'disabled' : '',\n widthAuto ? 'width-auto' : '',\n whiteSpaceNowrap ? 'white-space-no-wrap' : '',\n !waitForConfirmDelete && confirmDelete ? 'step-delete' : '',\n confirmDelete ? 'deletePosition-' + confirmDeletePosition : ''\n ]\"\n [ngStyle]=\"{\n 'text-align': contentHorizontalPosition\n }\"\n>\n <span class=\"wac-button__wrapper\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n <span class=\"wac-button__animation\" [style.maxWidth]=\"buttonMaxWidth\" [style.width]=\"buttonWidth + 'px'\">\n <span #calculWidth class=\"wac-button__animation__text\" [innerHTML]=\"animationText\"></span>\n </span>\n <span class=\"wac-button__confirmDelete\" [style.maxWidth]=\"buttonMaxWidthDelete\" [style.width]=\"buttonWidthDelete + 'px'\">\n <span #calculWidthDelete class=\"wac-button__confirmDelete__text\" [innerHTML]=\"confirmDeleteText\"></span>\n </span>\n <span\n class=\"wac-button__loader\"\n [ngClass]=\"extraClasses.includes('is-outlined') ? 'outlined' : ''\"\n *ngIf=\"isLoading || interval !== null\"\n [style.width]=\"currentLoading + '%'\"\n >\n <span *ngIf=\"extraClasses.includes('is-outlined')\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n\n </span>\n</a>\n"
1031
+ template: "<a\n [class]=\"'wac-button ' + extraClasses\"\n (click)=\"confirmDelete && waitForConfirmDelete ? addMaxWidthDelete() : '';onButtonClick($event);\"\n (mouseleave)=\"animation ? resetMaxWidth() : '';\"\n (mouseenter)=\"animation ? addMaxWidth() : '';\"\n wzAutoHide (clickOutside)=\"confirmDelete && !waitForConfirmDelete ? resetMaxWidthDelete() : ''\"\n [ngClass]=\"[\n label === '' ? 'alone' : '',\n animationRight ? 'animation-right' : '',\n animation ? 'animationText' : '',\n isLoading ? 'is-loading' : '',\n opacity ? 'opacity' : '',\n disabled ? 'disabled' : '',\n widthAuto ? 'width-auto' : '',\n whiteSpaceNowrap ? 'white-space-no-wrap' : '',\n !waitForConfirmDelete && confirmDelete ? 'step-delete' : '',\n confirmDelete ? 'deletePosition-' + confirmDeletePosition : ''\n ]\"\n [ngStyle]=\"{\n 'text-align': contentHorizontalPosition\n }\"\n>\n <span class=\"wac-button__wrapper\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n <span class=\"wac-button__animation\" [style.maxWidth]=\"buttonMaxWidth\" [style.width]=\"buttonWidth + 'px'\">\n <span #calculWidth class=\"wac-button__animation__text\" [innerHTML]=\"animationText\"></span>\n </span>\n <span class=\"wac-button__confirmDelete\" [style.maxWidth]=\"buttonMaxWidthDelete\" [style.width]=\"buttonWidthDelete + 'px'\">\n <span #calculWidthDelete class=\"wac-button__confirmDelete__text\" [innerHTML]=\"confirmDeleteText\"></span>\n </span>\n <span\n class=\"wac-button__loader\"\n [ngClass]=\"extraClasses.includes('is-outlined') ? 'outlined' : ''\"\n *ngIf=\"isLoading\"\n [style.width]=\"currentLoading + '%'\"\n >\n <span *ngIf=\"extraClasses.includes('is-outlined')\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n\n </span>\n</a>\n"
1011
1032
  },] }
1012
1033
  ];
1013
1034
  ButtonComponent.ctorParameters = function () { return []; };
@@ -1030,6 +1051,8 @@
1030
1051
  confirmDeleteText: [{ type: i0.Input }],
1031
1052
  confirmDeletePosition: [{ type: i0.Input }],
1032
1053
  click: [{ type: i0.Output }],
1054
+ isLoading: [{ type: i0.Input }],
1055
+ isLoadingChange: [{ type: i0.Output }],
1033
1056
  calculWidth: [{ type: i0.ViewChild, args: ['calculWidth',] }],
1034
1057
  calculWidthDelete: [{ type: i0.ViewChild, args: ['calculWidthDelete',] }]
1035
1058
  };