monkey-front-components 0.0.303 → 0.0.304

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.
@@ -2604,6 +2604,164 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
2604
2604
  }]
2605
2605
  }] });
2606
2606
 
2607
+ class ProductsModel {
2608
+ constructor(data) {
2609
+ this.url = data?.url;
2610
+ this.token = data?.token;
2611
+ this.username = data?.username;
2612
+ this.ownerGovernmentId = data?.ownerGovernmentId;
2613
+ this.ownerName = data?.ownerName;
2614
+ this.product = data?.product;
2615
+ this.name = data?.name;
2616
+ this.type = data?.type;
2617
+ this.handleLogo();
2618
+ }
2619
+ handleLogo() {
2620
+ const { product, token, url } = this;
2621
+ if (!url)
2622
+ return;
2623
+ const contries = {
2624
+ '.monkey.exchange': 'br',
2625
+ '.monkeyecx.com': 'br',
2626
+ '.sales.finance': 'br',
2627
+ '.monkeyexchange.cl': 'cl'
2628
+ };
2629
+ const domain = url.substring(url.indexOf('.', -1), url.length);
2630
+ const country = contries[domain];
2631
+ const sufix = {
2632
+ SUPPLY_CHAIN: 'SCF',
2633
+ SALES_FINANCE: 'SF'
2634
+ }[product];
2635
+ const handled = `https://assets.monkey.exchange/${sufix}/${country}/wl/${token}/login.svg`;
2636
+ this.logo = handled.toLowerCase();
2637
+ }
2638
+ }
2639
+
2640
+ class MECXProductsFilterComponent {
2641
+ constructor() {
2642
+ this.isLoading = false;
2643
+ this.onChangeFilter = new EventEmitter();
2644
+ this._search = '';
2645
+ // not to do
2646
+ }
2647
+ onSearchFilter(event) {
2648
+ this._search = event;
2649
+ if (!event) {
2650
+ this.onChangeFilter.next('');
2651
+ return;
2652
+ }
2653
+ event = `${event}`.toLowerCase();
2654
+ this.onChangeFilter.next(event);
2655
+ }
2656
+ onClearFilter() {
2657
+ this._search = '';
2658
+ this.onChangeFilter.next(this._search);
2659
+ }
2660
+ }
2661
+ MECXProductsFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2662
+ MECXProductsFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXProductsFilterComponent, selector: "mecx-products-filter", inputs: { isLoading: "isLoading" }, outputs: { onChangeFilter: "onChangeFilter" }, ngImport: i0, template: "<monkey-input-filter [placeholder]=\"'SIDEBAR-ACTIONS.PROFILE.FILTER.SEARCH-INPUT' | translate\"\n (onChange)=\"onSearchFilter($event)\" icon=\"search-16\" [(value)]=\"_search\">\n</monkey-input-filter>\n<monkey-button type=\"filter\" color=\"border\" (click)=\"onClearFilter()\">\n Limpar\n</monkey-button>", styles: [":host{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}:host ::ng-deep mecx-form-field-filter mecx-form-field-body{height:44px}:host ::ng-deep monkey-input-filter{width:100%}@media screen and (min-width: 960px){:host ::ng-deep monkey-input-filter{margin-right:8px}}\n"], components: [{ type: i1$2.MonkeyInputFilterComponent, selector: "monkey-input-filter", inputs: ["name", "label", "helperMessage", "placeholder", "icon", "type", "infoMessage", "errorMessage", "mask", "prefix", "onlyNumber", "onlyAlphaNumeric", "upperCase", "lowerCase", "capitalize", "currency", "iconPosition", "value"], outputs: ["onChange"] }, { type: i1$2.MonkeyButtonComponent, selector: "monkey-button", inputs: ["label", "icon", "iconPosition", "type", "color", "disabled", "size"] }], pipes: { "translate": i1$3.TranslatePipe } });
2663
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsFilterComponent, decorators: [{
2664
+ type: Component,
2665
+ args: [{ selector: 'mecx-products-filter', template: "<monkey-input-filter [placeholder]=\"'SIDEBAR-ACTIONS.PROFILE.FILTER.SEARCH-INPUT' | translate\"\n (onChange)=\"onSearchFilter($event)\" icon=\"search-16\" [(value)]=\"_search\">\n</monkey-input-filter>\n<monkey-button type=\"filter\" color=\"border\" (click)=\"onClearFilter()\">\n Limpar\n</monkey-button>", styles: [":host{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}:host ::ng-deep mecx-form-field-filter mecx-form-field-body{height:44px}:host ::ng-deep monkey-input-filter{width:100%}@media screen and (min-width: 960px){:host ::ng-deep monkey-input-filter{margin-right:8px}}\n"] }]
2666
+ }], ctorParameters: function () { return []; }, propDecorators: { isLoading: [{
2667
+ type: Input
2668
+ }], onChangeFilter: [{
2669
+ type: Output
2670
+ }] } });
2671
+
2672
+ class MECXProductsComponent extends BaseComponent {
2673
+ constructor(tokenStorage) {
2674
+ super();
2675
+ this.tokenStorage = tokenStorage;
2676
+ this.onAccess = new EventEmitter();
2677
+ this._filter = '';
2678
+ }
2679
+ onImgError(img) {
2680
+ const index = Math.floor(Math.random() * (6 - 1 + 1)) + 1;
2681
+ img.src = `https://assets.monkeyecx.com/icons/icon-${index}.svg`;
2682
+ }
2683
+ onHandleProducts() {
2684
+ const { _filter } = this;
2685
+ this._filteredProducts = this._products.map(({ name, items }) => {
2686
+ const found = items?.filter((_) => {
2687
+ const cmpA = `${_.name}`.toLowerCase();
2688
+ const cmpB = `${_filter}`.toLowerCase();
2689
+ return cmpA.includes(cmpB);
2690
+ });
2691
+ if (found && found.length) {
2692
+ return {
2693
+ name,
2694
+ items: found
2695
+ };
2696
+ }
2697
+ return null;
2698
+ }).filter((_) => { return _; });
2699
+ }
2700
+ onHandleMe() {
2701
+ const programs = this.tokenStorage.getMe()?.programs?.map((_) => {
2702
+ return new ProductsModel(_);
2703
+ });
2704
+ const onlyUnique = (value, index, self) => {
2705
+ return self.indexOf(value) === index;
2706
+ };
2707
+ const products = programs.map(({ product }) => {
2708
+ return product;
2709
+ }).filter(onlyUnique);
2710
+ this._products = Object.entries(products).map(([key, value]) => {
2711
+ const found = programs.filter(({ product }) => {
2712
+ return `${product}` === `${value}`;
2713
+ })?.sort((a, b) => {
2714
+ const groupA = `${a?.name}`.toLowerCase();
2715
+ const groupB = `${b?.name}`.toLowerCase();
2716
+ return groupA !== groupB ? 1 : -1;
2717
+ });
2718
+ return {
2719
+ name: value,
2720
+ items: found
2721
+ };
2722
+ })?.sort((a, b) => {
2723
+ const groupA = `${a?.name}`.toLowerCase();
2724
+ const groupB = `${b?.name}`.toLowerCase();
2725
+ return groupA !== groupB ? -1 : 1;
2726
+ });
2727
+ this._filteredProducts = this._products;
2728
+ }
2729
+ ngOnInit() {
2730
+ this.tokenStorage
2731
+ .meHasChanged()
2732
+ .pipe(takeUntil(this.__unsubscribeAll))
2733
+ .subscribe(() => {
2734
+ this.onHandleMe();
2735
+ });
2736
+ }
2737
+ onHandleChangeFilter(event) {
2738
+ this._filter = event;
2739
+ this.onHandleProducts();
2740
+ }
2741
+ }
2742
+ MECXProductsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsComponent, deps: [{ token: i1$4.MonkeyEcxTokenStorageService }], target: i0.ɵɵFactoryTarget.Component });
2743
+ MECXProductsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: MECXProductsComponent, selector: "mecx-products", outputs: { onAccess: "onAccess" }, usesInheritance: true, ngImport: i0, template: "<mecx-products-filter (onChangeFilter)=\"onHandleChangeFilter($event)\"></mecx-products-filter>\r\n<div *ngFor=\"let product of _filteredProducts\" class=\"product\">\r\n <span class=\"title\">{{ 'PRODUCTS.'+product.name | translate }}</span>\r\n <div class=\"items\">\r\n <div *ngFor=\"let item of product.items\" class=\"item\"\r\n (click)=\"onAccess.next(item)\">\r\n <div class=\"icon\">\r\n <img [src]=\"item.logo\" #img (error)=\"onImgError(img)\">\r\n </div>\r\n <span class=\"name\">{{ item.name }}</span>\r\n </div>\r\n </div>\r\n</div>", styles: [":host{display:flex;flex-direction:column}:host .product .title{font-style:normal;font-weight:600;font-size:24px;line-height:32px;letter-spacing:.04em;color:#4b4a53;margin-top:8px}:host .product .items{display:grid;grid-template-columns:repeat(2,1fr);grid-column-gap:10px;grid-row-gap:10px}:host .product .items .item{cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100px;padding:12px}:host .product .items .item .icon img{width:100%;max-width:140px}:host .product .items .item .name{font-style:normal;font-weight:400;font-size:18px;line-height:24px;color:#72717e;margin-top:8px}:host .product .items .item:hover{box-shadow:0 25px 52px 8px #eaeaeae0}\n"], components: [{ type: MECXProductsFilterComponent, selector: "mecx-products-filter", inputs: ["isLoading"], outputs: ["onChangeFilter"] }], directives: [{ type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i1$3.TranslatePipe } });
2744
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsComponent, decorators: [{
2745
+ type: Component,
2746
+ args: [{ selector: 'mecx-products', template: "<mecx-products-filter (onChangeFilter)=\"onHandleChangeFilter($event)\"></mecx-products-filter>\r\n<div *ngFor=\"let product of _filteredProducts\" class=\"product\">\r\n <span class=\"title\">{{ 'PRODUCTS.'+product.name | translate }}</span>\r\n <div class=\"items\">\r\n <div *ngFor=\"let item of product.items\" class=\"item\"\r\n (click)=\"onAccess.next(item)\">\r\n <div class=\"icon\">\r\n <img [src]=\"item.logo\" #img (error)=\"onImgError(img)\">\r\n </div>\r\n <span class=\"name\">{{ item.name }}</span>\r\n </div>\r\n </div>\r\n</div>", styles: [":host{display:flex;flex-direction:column}:host .product .title{font-style:normal;font-weight:600;font-size:24px;line-height:32px;letter-spacing:.04em;color:#4b4a53;margin-top:8px}:host .product .items{display:grid;grid-template-columns:repeat(2,1fr);grid-column-gap:10px;grid-row-gap:10px}:host .product .items .item{cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100px;padding:12px}:host .product .items .item .icon img{width:100%;max-width:140px}:host .product .items .item .name{font-style:normal;font-weight:400;font-size:18px;line-height:24px;color:#72717e;margin-top:8px}:host .product .items .item:hover{box-shadow:0 25px 52px 8px #eaeaeae0}\n"] }]
2747
+ }], ctorParameters: function () { return [{ type: i1$4.MonkeyEcxTokenStorageService }]; }, propDecorators: { onAccess: [{
2748
+ type: Output
2749
+ }] } });
2750
+
2751
+ class MECXProductsModule {
2752
+ }
2753
+ MECXProductsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2754
+ MECXProductsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsModule, declarations: [MECXProductsComponent, MECXProductsFilterComponent], imports: [CommonModule, i1$3.TranslateModule, MonkeyInputModule, MonkeyButtonModule], exports: [MECXProductsComponent] });
2755
+ MECXProductsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsModule, imports: [[CommonModule, TranslateModule.forChild(), MonkeyInputModule, MonkeyButtonModule]] });
2756
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MECXProductsModule, decorators: [{
2757
+ type: NgModule,
2758
+ args: [{
2759
+ declarations: [MECXProductsComponent, MECXProductsFilterComponent],
2760
+ imports: [CommonModule, TranslateModule.forChild(), MonkeyInputModule, MonkeyButtonModule],
2761
+ exports: [MECXProductsComponent]
2762
+ }]
2763
+ }] });
2764
+
2607
2765
  /*
2608
2766
  * Public API Surface of monkey-front-components
2609
2767
  */
@@ -2612,5 +2770,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
2612
2770
  * Generated bundle index. Do not edit.
2613
2771
  */
2614
2772
 
2615
- export { BaseComponent, BaseDynamic, BaseDynamicArray, BaseScrollComponent, MECXDynamicDirective, MECXDynamicFileUploadComponent, MECXDynamicFormArrayComponent, MECXDynamicFormComponent, MECXDynamicInputComponent, MECXDynamicInputPhoneComponent, MECXDynamicModule, MECXDynamicRadioComponent, MECXDynamicSelectComponent, MECXFilterComponent, MECXFilterModule, MECXPasswordStrengthComponent, MECXPasswordStrengthModule, MECXProgressBarComponent, MECXProgressBarModule, MECXProgressBarService, validators };
2773
+ export { BaseComponent, BaseDynamic, BaseDynamicArray, BaseScrollComponent, MECXDynamicDirective, MECXDynamicFileUploadComponent, MECXDynamicFormArrayComponent, MECXDynamicFormComponent, MECXDynamicInputComponent, MECXDynamicInputPhoneComponent, MECXDynamicModule, MECXDynamicRadioComponent, MECXDynamicSelectComponent, MECXFilterComponent, MECXFilterModule, MECXPasswordStrengthComponent, MECXPasswordStrengthModule, MECXProductsComponent, MECXProductsModule, MECXProgressBarComponent, MECXProgressBarModule, MECXProgressBarService, validators };
2616
2774
  //# sourceMappingURL=monkey-front-components.mjs.map