@wizishop/angular-components 0.0.73 → 0.0.76

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 (30) hide show
  1. package/angular-components.scss +263 -262
  2. package/assets/i18n/en.json +1 -1
  3. package/assets/i18n/fr.json +1 -1
  4. package/bundles/wizishop-angular-components.umd.js +74 -50
  5. package/bundles/wizishop-angular-components.umd.js.map +1 -1
  6. package/bundles/wizishop-angular-components.umd.min.js +1 -1
  7. package/bundles/wizishop-angular-components.umd.min.js.map +1 -1
  8. package/esm2015/lib/components/button/button.component.js +2 -2
  9. package/esm2015/lib/components/selects/select/select.component.js +30 -37
  10. package/esm2015/lib/components/selects/select-items.dto.js +1 -1
  11. package/esm2015/lib/components/shared-components.module.js +3 -1
  12. package/esm2015/lib/components/tree/tree.component.js +8 -5
  13. package/esm2015/lib/components/tree/tree.dto.js +1 -1
  14. package/esm2015/lib/pipes/select/select-filters.pipe.js +15 -0
  15. package/esm2015/lib/pipes/shared-pipes.module.js +7 -3
  16. package/esm2015/lib/pipes/tree/format-object-to-recursif-tree.pipe.js +10 -5
  17. package/esm2015/lib/pipes/tree/format-object-to-simple-tree.pipe.js +9 -5
  18. package/esm2015/public-api.js +2 -1
  19. package/fesm2015/wizishop-angular-components.js +74 -52
  20. package/fesm2015/wizishop-angular-components.js.map +1 -1
  21. package/lib/components/selects/select/select.component.d.ts +10 -10
  22. package/lib/components/selects/select-items.dto.d.ts +1 -1
  23. package/lib/components/tree/tree.component.d.ts +2 -1
  24. package/lib/components/tree/tree.dto.d.ts +2 -0
  25. package/lib/pipes/select/select-filters.pipe.d.ts +5 -0
  26. package/package.json +1 -1
  27. package/public-api.d.ts +1 -0
  28. package/wizishop-angular-components-0.0.76.tgz +0 -0
  29. package/wizishop-angular-components.metadata.json +1 -1
  30. package/wizishop-angular-components-0.0.73.tgz +0 -0
@@ -911,7 +911,7 @@
911
911
  this.label = '';
912
912
  this.icon = '';
913
913
  this.widthAuto = false;
914
- this.contentHorizontalPosition = 'left';
914
+ this.contentHorizontalPosition = 'center';
915
915
  this.iconFontSize = 12;
916
916
  this.hasLoader = false;
917
917
  this.disabled = false;
@@ -2912,21 +2912,12 @@
2912
2912
  this.clickOnCallToAction = new i0.EventEmitter();
2913
2913
  this.openCategories = false;
2914
2914
  this.searchValue = '';
2915
- this.currentLabel = '';
2916
- this.currentLabelIcon = '';
2915
+ this.indexItemSelected = -1;
2916
+ // ControlValueAccessor methods
2917
+ this.onChange = function () { };
2918
+ this.onTouch = function () { };
2917
2919
  }
2918
2920
  SelectComponent.prototype.ngOnInit = function () {
2919
- this.currentLabel = this.placeholder;
2920
- this.emptyResult = this.translateService.instant('datatable.noresult ');
2921
- this.setInitialValues();
2922
- };
2923
- SelectComponent.prototype.setInitialValues = function () {
2924
- if (!this.items.length) {
2925
- return;
2926
- }
2927
- this.triggerValueSelect = this.items;
2928
- var itemSelected = this.getItemSelected();
2929
- this.setCurrentItem(itemSelected);
2930
2921
  };
2931
2922
  SelectComponent.prototype.onClose = function () {
2932
2923
  this.openCategories = false;
@@ -2934,25 +2925,20 @@
2934
2925
  SelectComponent.prototype.customTB = function (item, index) {
2935
2926
  return item.id + "-" + index;
2936
2927
  };
2937
- SelectComponent.prototype.onSelectItem = function (index) {
2928
+ SelectComponent.prototype.onSelectItem = function (id) {
2938
2929
  this.unselectAll();
2939
- var itemSelected = this.items[index];
2940
- this.setCurrentItem(itemSelected);
2941
- this.selectValue.emit(index);
2930
+ this.setIndexItemSelected(id);
2931
+ var itemSelected = this.getItemSelected();
2932
+ itemSelected.selected = true;
2933
+ this.selectValue.emit(this.indexItemSelected);
2934
+ this.onChange(itemSelected);
2942
2935
  };
2943
2936
  SelectComponent.prototype.onClickCallToAction = function () {
2944
2937
  this.onClose();
2945
2938
  this.clickOnCallToAction.emit(this.callToAction.value);
2946
2939
  };
2947
2940
  SelectComponent.prototype.getItemSelected = function () {
2948
- var itemSelected = null;
2949
- this.items.forEach(function (item) {
2950
- if (!item.selected) {
2951
- return;
2952
- }
2953
- itemSelected = item;
2954
- });
2955
- return itemSelected;
2941
+ return this.items[this.indexItemSelected];
2956
2942
  };
2957
2943
  SelectComponent.prototype.showCategories = function () {
2958
2944
  var _this = this;
@@ -2961,28 +2947,33 @@
2961
2947
  _this.searchElement.nativeElement.focus();
2962
2948
  }, 0);
2963
2949
  };
2964
- SelectComponent.prototype.setCurrentItem = function (itemSelected) {
2965
- if (!itemSelected) {
2950
+ SelectComponent.prototype.unselectAll = function () {
2951
+ this.items.forEach(function (item) { return item.selected = false; });
2952
+ };
2953
+ SelectComponent.prototype.setIndexItemSelected = function (id) {
2954
+ this.indexItemSelected = this.items.findIndex(function (item) { return item.id === id; });
2955
+ };
2956
+ SelectComponent.prototype.writeValue = function (selectItem) {
2957
+ if (!selectItem) {
2966
2958
  return;
2967
2959
  }
2968
- itemSelected.selected = true;
2969
- this.currentLabel = itemSelected.name;
2970
- this.currentLabelIcon = itemSelected.icon;
2960
+ this.unselectAll();
2961
+ selectItem.selected = true;
2962
+ this.setIndexItemSelected(selectItem.id);
2971
2963
  };
2972
- SelectComponent.prototype.searchInSelect = function () {
2973
- var _this = this;
2974
- console.log(this.searchValue);
2975
- this.triggerValueSelect = this.items.filter(function (item) { return item.name.indexOf(_this.searchValue) >= 0; });
2964
+ SelectComponent.prototype.registerOnChange = function (fn) {
2965
+ this.onChange = fn;
2976
2966
  };
2977
- SelectComponent.prototype.unselectAll = function () {
2978
- this.items.forEach(function (item) { return item.selected = false; });
2967
+ SelectComponent.prototype.registerOnTouched = function (fn) {
2968
+ this.onTouch = fn;
2979
2969
  };
2980
2970
  return SelectComponent;
2981
2971
  }());
2982
2972
  SelectComponent.decorators = [
2983
2973
  { type: i0.Component, args: [{
2984
2974
  selector: 'wac-select',
2985
- template: "<p *ngIf=\"label\" [innerHTML]=\"label\" class=\"wac-select__label\"></p>\n<div class=\"wac-select\" wzAutoHide (clickOutside)=\"onClose()\" [ngStyle]=\"{ 'max-width': maxWidth }\" [zIndexToggle]=\"openCategories\">\n <div class=\"wac-select__current\" [ngClass]=\"{ 'select-disabled' : disabled }\" (click)=\"!disabled && openCategories = !openCategories\" *ngIf=\"!search\">\n <span *ngIf=\"currentLabelIcon\" class=\"icon\" [innerHTML]=\"currentLabelIcon\"></span><span [innerHTML]=\"currentLabel\"></span><span><i class=\"fas fa-chevron-down\"></i></span>\n </div>\n <div class=\"wac-select__current wac-select__current--withSearch\" [ngClass]=\"{ 'select-disabled' : disabled, 'open-search': openCategories }\" *ngIf=\"search\">\n <div class=\"wac-select__current__search\" *ngIf=\"openCategories && !disabled\">\n <i class=\"far fa-search\"></i>\n <input #search type=\"text\" [(ngModel)]=\"searchValue\" (keyup)=\"searchInSelect()\" />\n </div>\n <span (click)=\"openCategories = !openCategories;\" *ngIf=\"currentLabelIcon && !openCategories\" class=\"icon\" [innerHTML]=\"currentLabelIcon\"></span>\n <span (click)=\"showCategories()\" [innerHTML]=\"currentLabel\"></span>\n <span (click)=\"openCategories = !openCategories;\"><i class=\"fas fa-chevron-down\"></i></span>\n </div>\n <div class=\"wac-select__content\" *ngIf=\"!disabled\" [ngClass]=\"{ hidden: !openCategories, open: type === 'open' }\" [ngStyle]=\"{ 'max-width': maxWidthItems }\">\n <perfect-scrollbar [config]=\"{ suppressScrollX: true }\" *ngIf=\"triggerValueSelect.length > 0\">\n <div *ngIf=\"callToAction\" class=\"wac-select__content__cta\">\n <div (click)=\"onClickCallToAction()\">\n <i *ngIf=\"callToAction.icon\" [classList]=\"callToAction.icon\"></i><strong *ngIf=\"callToAction.boldText\">{{ callToAction.boldText }}</strong\n ><span>{{ callToAction?.name }}</span>\n </div>\n </div>\n <div (click)=\"onClose()\" class=\"wac-select__content__item\" *ngFor=\"let item of triggerValueSelect; trackBy: customTB; let index = index;\">\n <div [ngClass]=\"{ selected: item.selected }\" (click)=\"onSelectItem(index)\">\n <span class=\"icon\" [innerHTML]=\"item.icon\" *ngIf=\"item.icon\"></span>{{ item.name }}\n </div>\n </div>\n </perfect-scrollbar>\n <div class=\"wac-select__content__empty\" *ngIf=\"triggerValueSelect.length === 0\">\n <span *ngIf=\"emptyResult\">{{emptyResult}}</span>\n </div>\n </div>\n</div>\n"
2975
+ template: "<p *ngIf=\"label\" [innerHTML]=\"label\" class=\"wac-select__label\"></p>\n\n<div class=\"wac-select\" wzAutoHide (clickOutside)=\"onClose()\" [ngStyle]=\"{ 'max-width': maxWidth }\" [zIndexToggle]=\"openCategories\">\n\n <div class=\"wac-select__current\" [ngClass]=\"{ 'select-disabled' : disabled }\" (click)=\"!disabled && openCategories = !openCategories\" *ngIf=\"!search\">\n <span *ngIf=\"indexItemSelected !== -1\" class=\"icon\" [innerHTML]=\"items[indexItemSelected].icon\"></span>\n <span [innerHTML]=\"indexItemSelected !== -1 ? items[indexItemSelected].name : placeholder\"></span><span><i class=\"fas fa-chevron-down\"></i></span>\n </div>\n\n <div class=\"wac-select__current wac-select__current--withSearch\" [ngClass]=\"{ 'select-disabled' : disabled, 'open-search': openCategories }\" *ngIf=\"search\">\n <div class=\"wac-select__current__search\" *ngIf=\"openCategories && !disabled\">\n <i class=\"far fa-search\"></i>\n <input #search type=\"text\" [(ngModel)]=\"searchValue\" />\n </div>\n <span (click)=\"openCategories = !openCategories;\" *ngIf=\"items[indexItemSelected]?.icon && !openCategories\" class=\"icon\" [innerHTML]=\"items[indexItemSelected].icon\"></span>\n <span (click)=\"showCategories()\" [innerHTML]=\"items[indexItemSelected]?.name ? items[indexItemSelected].name : placeholder\"></span>\n <span (click)=\"openCategories = !openCategories;\"><i class=\"fas fa-chevron-down\"></i></span>\n </div>\n\n <div class=\"wac-select__content\" *ngIf=\"!disabled\" [ngClass]=\"{ hidden: !openCategories, open: type === 'open' }\" [ngStyle]=\"{ 'max-width': maxWidthItems }\">\n <perfect-scrollbar [config]=\"{ suppressScrollX: true }\" *ngIf=\"items.length\">\n\n <div *ngIf=\"callToAction\" class=\"wac-select__content__cta\">\n <div (click)=\"onClickCallToAction()\">\n <i *ngIf=\"callToAction.icon\" [classList]=\"callToAction.icon\"></i><strong *ngIf=\"callToAction.boldText\">{{ callToAction.boldText }}</strong\n ><span>{{ callToAction?.name }}</span>\n </div>\n </div>\n\n <div\n *ngFor=\"let item of items | selectFilters: searchValue; let index = index;\"\n (click)=\"onClose()\"\n class=\"wac-select__content__item\"\n >\n <div [ngClass]=\"{ selected: item.selected }\" (click)=\"onSelectItem(item.id)\">\n <span class=\"icon\" [innerHTML]=\"item.icon\" *ngIf=\"item.icon\"></span>{{ item.name }}\n </div>\n </div>\n\n </perfect-scrollbar>\n\n <div *ngIf=\"!(items | selectFilters: searchValue)?.length\" class=\"wac-select__content__empty\">\n <span>{{'wac.datatable.noresult' | translate}}</span>\n </div>\n\n </div>\n</div>",
2976
+ providers: [{ provide: forms.NG_VALUE_ACCESSOR, useExisting: SelectComponent, multi: true }]
2986
2977
  },] }
2987
2978
  ];
2988
2979
  SelectComponent.ctorParameters = function () { return [
@@ -3769,6 +3760,7 @@
3769
3760
 
3770
3761
  var TreeComponent = /** @class */ (function () {
3771
3762
  function TreeComponent() {
3763
+ this.treeDepth = 0;
3772
3764
  }
3773
3765
  TreeComponent.prototype.ngOnInit = function () { };
3774
3766
  return TreeComponent;
@@ -3776,13 +3768,14 @@
3776
3768
  TreeComponent.decorators = [
3777
3769
  { type: i0.Component, args: [{
3778
3770
  selector: 'wac-tree',
3779
- template: "<div *ngFor=\"let item of items; index as i\">\n <ul>\n <li>\n\n <ng-template #defaultItem>\n {{ item?.treeLabel }}\n </ng-template>\n\n <ng-container\n [ngTemplateOutlet]=\"optionTemplateRef || defaultItem\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: i }\"\n >\n </ng-container>\n\n <wac-tree [items]=\"item.treeChildren\" *ngIf=\"item.treeChildren?.length\"></wac-tree>\n </li>\n </ul>\n</div>"
3771
+ template: "<div *ngFor=\"let item of items; index as i\" [ngClass]=\"['treeDepth-' + treeDepth]\">\n <ul>\n <li>\n\n <ng-template #defaultItem>\n {{ item?.treeLabel }}\n </ng-template>\n\n <ng-container\n [ngTemplateOutlet]=\"optionTemplate || defaultItem\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: i }\"\n >\n </ng-container>\n\n <wac-tree [optionTemplate]=\"optionTemplate\" [items]=\"item.treeChildren\" *ngIf=\"item.treeChildren?.length\" [treeDepth]=\"treeDepth + 1\">\n <!-- Todo maybe pass child template -->\n\n </wac-tree>\n </li>\n </ul>\n</div>"
3780
3772
  },] }
3781
3773
  ];
3782
3774
  TreeComponent.ctorParameters = function () { return []; };
3783
3775
  TreeComponent.propDecorators = {
3784
3776
  items: [{ type: i0.Input }],
3785
- optionTemplateRef: [{ type: i0.ContentChild, args: ["optionTemplate", { static: false },] }]
3777
+ treeDepth: [{ type: i0.Input }],
3778
+ optionTemplate: [{ type: i0.Input, args: ["optionTemplate",] }]
3786
3779
  };
3787
3780
 
3788
3781
  var FormatObjectToRecursifTreePipe = /** @class */ (function () {
@@ -3792,24 +3785,28 @@
3792
3785
  FormatObjectToRecursifTreePipe.prototype.transform = function (objectList, childrenProperties) {
3793
3786
  var _this = this;
3794
3787
  this.childrenProperties = childrenProperties;
3795
- objectList.forEach(function (object) { return _this.recursiveFormatObjectToRecursifTree(object); });
3788
+ var treeDepth = 0;
3789
+ objectList.forEach(function (object) { return _this.recursiveFormatObjectToRecursifTree(object, treeDepth); });
3796
3790
  return objectList;
3797
3791
  };
3798
- FormatObjectToRecursifTreePipe.prototype.recursiveFormatObjectToRecursifTree = function (object) {
3792
+ FormatObjectToRecursifTreePipe.prototype.recursiveFormatObjectToRecursifTree = function (object, treeDepth) {
3799
3793
  var e_1, _a;
3800
3794
  try {
3801
3795
  for (var _b = __values(this.childrenProperties), _c = _b.next(); !_c.done; _c = _b.next()) {
3802
3796
  var childrenProperty = _c.value;
3797
+ object.hasTreeChildren = true;
3803
3798
  if (!object.hasOwnProperty(childrenProperty)) {
3799
+ // No more chrildren
3800
+ object.hasTreeChrildren = false;
3804
3801
  continue;
3805
3802
  }
3806
- if (Array.isArray(object[childrenProperty])) {
3803
+ if (!Array.isArray(object[childrenProperty])) {
3807
3804
  throw "Property : \"" + childrenProperty + "\", is not an array. it could not be transform to a recursive list.";
3808
3805
  }
3809
3806
  // Add treeChildren property filled with name children property
3810
3807
  object.treeChildren = object[childrenProperty];
3811
3808
  // call this function recursively until no children can be generated
3812
- this.recursiveFormatObjectToRecursifTree(object.treeChildren);
3809
+ this.recursiveFormatObjectToRecursifTree(object.treeChildren, treeDepth++);
3813
3810
  break;
3814
3811
  }
3815
3812
  }
@@ -3820,6 +3817,7 @@
3820
3817
  }
3821
3818
  finally { if (e_1) throw e_1.error; }
3822
3819
  }
3820
+ object.treeDepth = treeDepth;
3823
3821
  };
3824
3822
  return FormatObjectToRecursifTreePipe;
3825
3823
  }());
@@ -3838,10 +3836,11 @@
3838
3836
  var _this = this;
3839
3837
  this.childrenProperties = childrenProperties;
3840
3838
  this.labelProperties = labelProperties;
3841
- objectList.forEach(function (object) { return _this.recursiveFormatObjectToSimpleTree(object); });
3839
+ var treeDepth = 0;
3840
+ objectList.forEach(function (object) { return _this.recursiveFormatObjectToSimpleTree(object, treeDepth); });
3842
3841
  return objectList;
3843
3842
  };
3844
- FormatObjectToSimpleTreePipe.prototype.recursiveFormatObjectToSimpleTree = function (object) {
3843
+ FormatObjectToSimpleTreePipe.prototype.recursiveFormatObjectToSimpleTree = function (object, treeDepth) {
3845
3844
  for (var property in object) {
3846
3845
  if (!Object.prototype.hasOwnProperty.call(object, property)) {
3847
3846
  continue;
@@ -3850,16 +3849,19 @@
3850
3849
  object.treeLabel = object[property];
3851
3850
  continue;
3852
3851
  }
3852
+ object.hasTreeChrildren = true;
3853
3853
  if (!this.childrenProperties.includes(property)) {
3854
+ // No more chrildren
3855
+ object.hasTreeChrildren = false;
3854
3856
  continue;
3855
3857
  }
3856
- if (Array.isArray(object[property])) {
3858
+ if (!Array.isArray(object[property])) {
3857
3859
  throw "Property : \"" + property + "\", is not an array. it could not be transform to a recursive list.";
3858
3860
  }
3859
3861
  // Add treeChildren property filled with name children property
3860
3862
  object.treeChildren = object[property];
3861
3863
  // call this function recursively until no children can be generated
3862
- this.recursiveFormatObjectToSimpleTree(object.treeChildren);
3864
+ this.recursiveFormatObjectToSimpleTree(object.treeChildren, treeDepth++);
3863
3865
  break;
3864
3866
  }
3865
3867
  };
@@ -3871,7 +3873,27 @@
3871
3873
  },] }
3872
3874
  ];
3873
3875
 
3876
+ var SelectFiltersPipe = /** @class */ (function () {
3877
+ function SelectFiltersPipe() {
3878
+ }
3879
+ SelectFiltersPipe.prototype.transform = function (items, filterName) {
3880
+ return items.filter(function (item) {
3881
+ var regexp = new RegExp(filterName, 'i');
3882
+ return regexp.test(item.name);
3883
+ });
3884
+ };
3885
+ return SelectFiltersPipe;
3886
+ }());
3887
+ SelectFiltersPipe.decorators = [
3888
+ { type: i0.Pipe, args: [{
3889
+ name: 'selectFilters'
3890
+ },] }
3891
+ ];
3892
+
3874
3893
  var exportedPipes = [FormatObjectToRecursifTreePipe, FormatObjectToSimpleTreePipe];
3894
+ var pipes$1 = [
3895
+ SelectFiltersPipe
3896
+ ];
3875
3897
  var SharedPipes = /** @class */ (function () {
3876
3898
  function SharedPipes() {
3877
3899
  }
@@ -3880,8 +3902,8 @@
3880
3902
  SharedPipes.decorators = [
3881
3903
  { type: i0.NgModule, args: [{
3882
3904
  imports: [common.CommonModule, forms.FormsModule],
3883
- declarations: exportedPipes,
3884
- exports: exportedPipes
3905
+ declarations: __spread(exportedPipes, pipes$1),
3906
+ exports: __spread(exportedPipes, pipes$1)
3885
3907
  },] }
3886
3908
  ];
3887
3909
 
@@ -3975,6 +3997,7 @@
3975
3997
  core.TranslateModule.forChild(),
3976
3998
  forms.ReactiveFormsModule,
3977
3999
  SharedDirectives,
4000
+ SharedPipes,
3978
4001
  table.CdkTableModule,
3979
4002
  ngxChips.TagInputModule,
3980
4003
  PaginationModule,
@@ -4064,6 +4087,7 @@
4064
4087
  exports.RadioComponent = RadioComponent;
4065
4088
  exports.SearchComponent = SearchComponent;
4066
4089
  exports.SelectComponent = SelectComponent;
4090
+ exports.SelectFiltersPipe = SelectFiltersPipe;
4067
4091
  exports.SelectInTextComponent = SelectInTextComponent;
4068
4092
  exports.SelectedListComponent = SelectedListComponent;
4069
4093
  exports.SeparatorComponent = SeparatorComponent;