@wizishop/angular-components 0.0.75 → 0.0.78

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.
@@ -2474,21 +2474,13 @@ class SelectComponent {
2474
2474
  this.clickOnCallToAction = new EventEmitter();
2475
2475
  this.openCategories = false;
2476
2476
  this.searchValue = '';
2477
- this.currentLabel = '';
2478
- this.currentLabelIcon = '';
2477
+ this.indexItemSelected = -1;
2478
+ // ControlValueAccessor methods
2479
+ this.onChange = () => { };
2480
+ this.onTouch = () => { };
2479
2481
  }
2480
2482
  ngOnInit() {
2481
- this.currentLabel = this.placeholder;
2482
- this.emptyResult = this.translateService.instant('datatable.noresult ');
2483
- this.setInitialValues();
2484
- }
2485
- setInitialValues() {
2486
- if (!this.items.length) {
2487
- return;
2488
- }
2489
- this.triggerValueSelect = this.items;
2490
- const itemSelected = this.getItemSelected();
2491
- this.setCurrentItem(itemSelected);
2483
+ this.indexItemSelected = this.items.findIndex(item => item.selected);
2492
2484
  }
2493
2485
  onClose() {
2494
2486
  this.openCategories = false;
@@ -2496,25 +2488,20 @@ class SelectComponent {
2496
2488
  customTB(item, index) {
2497
2489
  return `${item.id}-${index}`;
2498
2490
  }
2499
- onSelectItem(index) {
2491
+ onSelectItem(id) {
2500
2492
  this.unselectAll();
2501
- const itemSelected = this.items[index];
2502
- this.setCurrentItem(itemSelected);
2503
- this.selectValue.emit(index);
2493
+ this.setIndexItemSelected(id);
2494
+ const itemSelected = this.getItemSelected();
2495
+ itemSelected.selected = true;
2496
+ this.selectValue.emit(this.indexItemSelected);
2497
+ this.onChange(itemSelected);
2504
2498
  }
2505
2499
  onClickCallToAction() {
2506
2500
  this.onClose();
2507
2501
  this.clickOnCallToAction.emit(this.callToAction.value);
2508
2502
  }
2509
2503
  getItemSelected() {
2510
- let itemSelected = null;
2511
- this.items.forEach(item => {
2512
- if (!item.selected) {
2513
- return;
2514
- }
2515
- itemSelected = item;
2516
- });
2517
- return itemSelected;
2504
+ return this.items[this.indexItemSelected];
2518
2505
  }
2519
2506
  showCategories() {
2520
2507
  this.openCategories = true;
@@ -2522,26 +2509,32 @@ class SelectComponent {
2522
2509
  this.searchElement.nativeElement.focus();
2523
2510
  }, 0);
2524
2511
  }
2525
- setCurrentItem(itemSelected) {
2526
- if (!itemSelected) {
2512
+ unselectAll() {
2513
+ this.items.forEach(item => item.selected = false);
2514
+ }
2515
+ setIndexItemSelected(id) {
2516
+ this.indexItemSelected = this.items.findIndex(item => item.id === id);
2517
+ }
2518
+ writeValue(selectItem) {
2519
+ if (!selectItem) {
2527
2520
  return;
2528
2521
  }
2529
- itemSelected.selected = true;
2530
- this.currentLabel = itemSelected.name;
2531
- this.currentLabelIcon = itemSelected.icon;
2522
+ this.unselectAll();
2523
+ selectItem.selected = true;
2524
+ this.setIndexItemSelected(selectItem.id);
2532
2525
  }
2533
- searchInSelect() {
2534
- console.log(this.searchValue);
2535
- this.triggerValueSelect = this.items.filter(item => item.name.indexOf(this.searchValue) >= 0);
2526
+ registerOnChange(fn) {
2527
+ this.onChange = fn;
2536
2528
  }
2537
- unselectAll() {
2538
- this.items.forEach(item => item.selected = false);
2529
+ registerOnTouched(fn) {
2530
+ this.onTouch = fn;
2539
2531
  }
2540
2532
  }
2541
2533
  SelectComponent.decorators = [
2542
2534
  { type: Component, args: [{
2543
2535
  selector: 'wac-select',
2544
- 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"
2536
+ 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>",
2537
+ providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: SelectComponent, multi: true }]
2545
2538
  },] }
2546
2539
  ];
2547
2540
  SelectComponent.ctorParameters = () => [
@@ -3325,16 +3318,14 @@ class FormatObjectToRecursifTreePipe {
3325
3318
  this.childrenProperties = childrenProperties;
3326
3319
  const treeDepth = 0;
3327
3320
  objectList.forEach(object => this.recursiveFormatObjectToRecursifTree(object, treeDepth));
3328
- console.log('objectList');
3329
- console.log(objectList);
3330
3321
  return objectList;
3331
3322
  }
3332
3323
  recursiveFormatObjectToRecursifTree(object, treeDepth) {
3333
3324
  for (const childrenProperty of this.childrenProperties) {
3334
- object.hasTreeChrildren = true;
3325
+ object.hasTreeChildren = true;
3335
3326
  if (!object.hasOwnProperty(childrenProperty)) {
3336
3327
  // No more chrildren
3337
- object.hasTreeChrildren = false;
3328
+ object.hasTreeChildren = false;
3338
3329
  continue;
3339
3330
  }
3340
3331
  if (!Array.isArray(object[childrenProperty])) {
@@ -3376,10 +3367,10 @@ class FormatObjectToSimpleTreePipe {
3376
3367
  object.treeLabel = object[property];
3377
3368
  continue;
3378
3369
  }
3379
- object.hasTreeChrildren = true;
3370
+ object.hasTreeChildren = true;
3380
3371
  if (!this.childrenProperties.includes(property)) {
3381
3372
  // No more chrildren
3382
- object.hasTreeChrildren = false;
3373
+ object.hasTreeChildren = false;
3383
3374
  continue;
3384
3375
  }
3385
3376
  if (!Array.isArray(object[property])) {
@@ -3399,14 +3390,31 @@ FormatObjectToSimpleTreePipe.decorators = [
3399
3390
  },] }
3400
3391
  ];
3401
3392
 
3393
+ class SelectFiltersPipe {
3394
+ transform(items, filterName) {
3395
+ return items.filter(item => {
3396
+ const regexp = new RegExp(filterName, 'i');
3397
+ return regexp.test(item.name);
3398
+ });
3399
+ }
3400
+ }
3401
+ SelectFiltersPipe.decorators = [
3402
+ { type: Pipe, args: [{
3403
+ name: 'selectFilters'
3404
+ },] }
3405
+ ];
3406
+
3402
3407
  const exportedPipes = [FormatObjectToRecursifTreePipe, FormatObjectToSimpleTreePipe];
3408
+ const pipes$1 = [
3409
+ SelectFiltersPipe
3410
+ ];
3403
3411
  class SharedPipes {
3404
3412
  }
3405
3413
  SharedPipes.decorators = [
3406
3414
  { type: NgModule, args: [{
3407
3415
  imports: [CommonModule, FormsModule],
3408
- declarations: exportedPipes,
3409
- exports: exportedPipes
3416
+ declarations: [...exportedPipes, ...pipes$1],
3417
+ exports: [...exportedPipes, ...pipes$1]
3410
3418
  },] }
3411
3419
  ];
3412
3420
 
@@ -3494,6 +3502,7 @@ SharedComponentsModule.decorators = [
3494
3502
  TranslateModule.forChild(),
3495
3503
  ReactiveFormsModule,
3496
3504
  SharedDirectives,
3505
+ SharedPipes,
3497
3506
  CdkTableModule,
3498
3507
  TagInputModule,
3499
3508
  PaginationModule,
@@ -3537,5 +3546,5 @@ WiziComponentsModule.decorators = [
3537
3546
  * Generated bundle index. Do not edit.
3538
3547
  */
3539
3548
 
3540
- export { AbstractDebounceDirective, AlertComponent, AlertPopupComponent, AlertPopupModule, AlertPopupService, AutoHideDirective, BackComponent, BlockComponent, ButtonComponent, CalendarComponent, CheckBoxRow, CheckboxComponent, DebounceKeyupDirective, DeleteComponent, DropdownComponent, FiltersComponent, FiltersTableService, FormatObjectToRecursifTreePipe, FormatObjectToSimpleTreePipe, FreePopinComponent, H1Component, H2Component, H3Component, H4Component, HeaderPageComponent, HtmlContainer, ImageComponent, InfoComponent, InputComponent, InputSearchComponent, InputWithSelectComponent, LabelComponent, LinkComponent, LoaderComponent, LogoComponent, MultipleSearchComponent, MultipleSearchPlusComponent, PaginationComponent, PopinComponent, ProgressBarComponent, RadioComponent, SearchComponent, SelectComponent, SelectInTextComponent, SelectedListComponent, SeparatorComponent, SettingsComponent, SharedComponentsModule, SharedDirectives, SharedPipes, SnackbarComponent, StateComponent, SwitchComponent, TabComponent, TableColumn, TableColumnHeader, TableComponent, TableRow, TagComponent, TextAreaComponent, TextComponent, TooltipComponent, TreeComponent, TreeModule, UploadComponent, WiziComponentsModule, WrapperBlocsComponent, WrapperComponent, WzEditInPlaceComponent, ZindexToggleDirective, DomService as ɵa, PaginationModule as ɵb, PagniationArrayTotalPages as ɵc, PagniationIsLastPage as ɵd, PagniationText as ɵe, TableModule as ɵf, InputSearchModule as ɵg, InputModule as ɵh, TooltipModule as ɵi, ProgressBarModule as ɵj, LoaderModule as ɵk, CheckboxModule as ɵl, inOutY as ɵm, inOutX as ɵn };
3549
+ export { AbstractDebounceDirective, AlertComponent, AlertPopupComponent, AlertPopupModule, AlertPopupService, AutoHideDirective, BackComponent, BlockComponent, ButtonComponent, CalendarComponent, CheckBoxRow, CheckboxComponent, DebounceKeyupDirective, DeleteComponent, DropdownComponent, FiltersComponent, FiltersTableService, FormatObjectToRecursifTreePipe, FormatObjectToSimpleTreePipe, FreePopinComponent, H1Component, H2Component, H3Component, H4Component, HeaderPageComponent, HtmlContainer, ImageComponent, InfoComponent, InputComponent, InputSearchComponent, InputWithSelectComponent, LabelComponent, LinkComponent, LoaderComponent, LogoComponent, MultipleSearchComponent, MultipleSearchPlusComponent, PaginationComponent, PopinComponent, ProgressBarComponent, RadioComponent, SearchComponent, SelectComponent, SelectFiltersPipe, SelectInTextComponent, SelectedListComponent, SeparatorComponent, SettingsComponent, SharedComponentsModule, SharedDirectives, SharedPipes, SnackbarComponent, StateComponent, SwitchComponent, TabComponent, TableColumn, TableColumnHeader, TableComponent, TableRow, TagComponent, TextAreaComponent, TextComponent, TooltipComponent, TreeComponent, TreeModule, UploadComponent, WiziComponentsModule, WrapperBlocsComponent, WrapperComponent, WzEditInPlaceComponent, ZindexToggleDirective, DomService as ɵa, PaginationModule as ɵb, PagniationArrayTotalPages as ɵc, PagniationIsLastPage as ɵd, PagniationText as ɵe, TableModule as ɵf, InputSearchModule as ɵg, InputModule as ɵh, TooltipModule as ɵi, ProgressBarModule as ɵj, LoaderModule as ɵk, CheckboxModule as ɵl, inOutY as ɵm, inOutX as ɵn };
3541
3550
  //# sourceMappingURL=wizishop-angular-components.js.map