@wizishop/angular-components 0.0.74 → 0.0.77

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.
@@ -1,5 +1,5 @@
1
1
  import { NwbFilterRoutingBuilder, NwbAllModule } from '@wizishop/ng-wizi-bulma';
2
- import { Component, ViewEncapsulation, Input, EventEmitter, Output, Directive, HostListener, ɵɵdefineInjectable, ɵɵinject, ComponentFactoryResolver, ApplicationRef, INJECTOR, Injectable, Injector, ElementRef, Renderer2, NgModule, ViewChild, Pipe, Inject, ContentChild } from '@angular/core';
2
+ import { Component, ViewEncapsulation, Input, EventEmitter, Output, Directive, HostListener, ɵɵdefineInjectable, ɵɵinject, ComponentFactoryResolver, ApplicationRef, INJECTOR, Injectable, Injector, ElementRef, Renderer2, NgModule, ViewChild, Pipe, Inject } from '@angular/core';
3
3
  import { CommonModule, DOCUMENT } from '@angular/common';
4
4
  import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
5
  import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
@@ -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 = () => [
@@ -3307,14 +3300,14 @@ class TreeComponent {
3307
3300
  TreeComponent.decorators = [
3308
3301
  { type: Component, args: [{
3309
3302
  selector: 'wac-tree',
3310
- 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]=\"optionTemplateRef || defaultItem\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: i }\"\n >\n </ng-container>\n\n <wac-tree [items]=\"item.treeChildren\" *ngIf=\"item.treeChildren?.length\">\n <!-- Todo maybe pass child template -->\n </wac-tree>\n </li>\n </ul>\n</div>"
3303
+ 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>"
3311
3304
  },] }
3312
3305
  ];
3313
3306
  TreeComponent.ctorParameters = () => [];
3314
3307
  TreeComponent.propDecorators = {
3315
3308
  items: [{ type: Input }],
3316
3309
  treeDepth: [{ type: Input }],
3317
- optionTemplateRef: [{ type: ContentChild, args: ["optionTemplate", { static: false },] }]
3310
+ optionTemplate: [{ type: Input, args: ["optionTemplate",] }]
3318
3311
  };
3319
3312
 
3320
3313
  class FormatObjectToRecursifTreePipe {
@@ -3329,13 +3322,13 @@ class FormatObjectToRecursifTreePipe {
3329
3322
  }
3330
3323
  recursiveFormatObjectToRecursifTree(object, treeDepth) {
3331
3324
  for (const childrenProperty of this.childrenProperties) {
3332
- object.hasTreeChrildren = true;
3325
+ object.hasTreeChildren = true;
3333
3326
  if (!object.hasOwnProperty(childrenProperty)) {
3334
3327
  // No more chrildren
3335
3328
  object.hasTreeChrildren = false;
3336
3329
  continue;
3337
3330
  }
3338
- if (Array.isArray(object[childrenProperty])) {
3331
+ if (!Array.isArray(object[childrenProperty])) {
3339
3332
  throw `Property : "${childrenProperty}", is not an array. it could not be transform to a recursive list.`;
3340
3333
  }
3341
3334
  // Add treeChildren property filled with name children property
@@ -3380,7 +3373,7 @@ class FormatObjectToSimpleTreePipe {
3380
3373
  object.hasTreeChrildren = false;
3381
3374
  continue;
3382
3375
  }
3383
- if (Array.isArray(object[property])) {
3376
+ if (!Array.isArray(object[property])) {
3384
3377
  throw `Property : "${property}", is not an array. it could not be transform to a recursive list.`;
3385
3378
  }
3386
3379
  // Add treeChildren property filled with name children property
@@ -3397,14 +3390,31 @@ FormatObjectToSimpleTreePipe.decorators = [
3397
3390
  },] }
3398
3391
  ];
3399
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
+
3400
3407
  const exportedPipes = [FormatObjectToRecursifTreePipe, FormatObjectToSimpleTreePipe];
3408
+ const pipes$1 = [
3409
+ SelectFiltersPipe
3410
+ ];
3401
3411
  class SharedPipes {
3402
3412
  }
3403
3413
  SharedPipes.decorators = [
3404
3414
  { type: NgModule, args: [{
3405
3415
  imports: [CommonModule, FormsModule],
3406
- declarations: exportedPipes,
3407
- exports: exportedPipes
3416
+ declarations: [...exportedPipes, ...pipes$1],
3417
+ exports: [...exportedPipes, ...pipes$1]
3408
3418
  },] }
3409
3419
  ];
3410
3420
 
@@ -3492,6 +3502,7 @@ SharedComponentsModule.decorators = [
3492
3502
  TranslateModule.forChild(),
3493
3503
  ReactiveFormsModule,
3494
3504
  SharedDirectives,
3505
+ SharedPipes,
3495
3506
  CdkTableModule,
3496
3507
  TagInputModule,
3497
3508
  PaginationModule,
@@ -3535,5 +3546,5 @@ WiziComponentsModule.decorators = [
3535
3546
  * Generated bundle index. Do not edit.
3536
3547
  */
3537
3548
 
3538
- 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 };
3539
3550
  //# sourceMappingURL=wizishop-angular-components.js.map