matcha-components 19.96.0 → 19.101.0

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,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, Renderer2, HostBinding, Inject, HostListener, ContentChild, Directive, forwardRef, ChangeDetectionStrategy, NgModule, createComponent, Injectable } from '@angular/core';
2
+ import { EventEmitter, Output, Input, Component, ContentChildren, ElementRef, Renderer2, HostBinding, Inject, HostListener, ContentChild, Directive, forwardRef, Injectable, ChangeDetectionStrategy, NgModule, createComponent } from '@angular/core';
3
3
  import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
4
- import { Subscription, Subject } from 'rxjs';
4
+ import { Subscription, Subject, BehaviorSubject } from 'rxjs';
5
5
  import { debounceTime } from 'rxjs/operators';
6
6
  import * as i1 from '@angular/common';
7
7
  import { CommonModule } from '@angular/common';
8
+ import * as i1$1 from '@angular/forms';
8
9
  import { FormControlName, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
9
10
 
10
11
  const customAnimation = animation([
@@ -1887,6 +1888,147 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1887
1888
  args: ['size']
1888
1889
  }] } });
1889
1890
 
1891
+ class MatchaOptionService {
1892
+ constructor() {
1893
+ this._optionsSubject = new BehaviorSubject([]);
1894
+ this.options$ = this._optionsSubject.asObservable();
1895
+ this._activeOptionSubject = new BehaviorSubject(0);
1896
+ this.activeOption$ = this._activeOptionSubject.asObservable();
1897
+ this._canShowOptionsSubject = new BehaviorSubject(false);
1898
+ this.canShowOptions$ = this._canShowOptionsSubject.asObservable();
1899
+ this._selectedOptionSubject = new Subject();
1900
+ this.selectedOption$ = this._selectedOptionSubject.asObservable();
1901
+ }
1902
+ setSelectedOption(selectedOption) {
1903
+ this._selectedOptionSubject.next(selectedOption);
1904
+ }
1905
+ getCanShowOptions() {
1906
+ return this._canShowOptionsSubject.value;
1907
+ }
1908
+ setCanShowOptions(canShowOptions) {
1909
+ this._canShowOptionsSubject.next(canShowOptions);
1910
+ }
1911
+ updateOptions(options) {
1912
+ this._optionsSubject.next(options);
1913
+ }
1914
+ updateActiveOption(activeOption) {
1915
+ this._activeOptionSubject.next(activeOption);
1916
+ }
1917
+ resetActiveOption() {
1918
+ this.updateActiveOption(0);
1919
+ const currentOptions = this._optionsSubject.value;
1920
+ const activeOption = this._activeOptionSubject.value;
1921
+ currentOptions.forEach((option, index) => {
1922
+ index === activeOption ? option.setIsOptionActive(true, false) : option.setIsOptionActive(false, false);
1923
+ });
1924
+ return;
1925
+ }
1926
+ removeActiveOption() {
1927
+ const currentOptions = this._optionsSubject.value;
1928
+ currentOptions.forEach((option) => {
1929
+ option.isOptionActive = false;
1930
+ });
1931
+ this.updateActiveOption(-1);
1932
+ return;
1933
+ }
1934
+ changeActiveOption(stepsToMove) {
1935
+ const currentOptions = this._optionsSubject.value;
1936
+ const lastActiveOption = this._activeOptionSubject.value;
1937
+ this.updateActiveOption(Math.max(0, Math.min(currentOptions.length - 1, lastActiveOption + stepsToMove)));
1938
+ const currentActiveOption = this._activeOptionSubject.value;
1939
+ currentOptions.forEach((option, index) => {
1940
+ option.setIsOptionActive(index === currentActiveOption, false);
1941
+ });
1942
+ return;
1943
+ }
1944
+ selectActiveOption() {
1945
+ const currentOptions = this._optionsSubject.value;
1946
+ const activeOption = this._activeOptionSubject.value;
1947
+ if (currentOptions[activeOption]) {
1948
+ currentOptions[activeOption].selectOption();
1949
+ }
1950
+ }
1951
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1952
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionService, providedIn: 'root' }); }
1953
+ }
1954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionService, decorators: [{
1955
+ type: Injectable,
1956
+ args: [{
1957
+ providedIn: 'root',
1958
+ }]
1959
+ }], ctorParameters: () => [] });
1960
+
1961
+ class MatchaOptionComponent {
1962
+ constructor(changeDetectorRef, matchaOptionService) {
1963
+ this.changeDetectorRef = changeDetectorRef;
1964
+ this.matchaOptionService = matchaOptionService;
1965
+ this.isOptionActive = false;
1966
+ }
1967
+ selectOption() {
1968
+ this.matchaOptionService.setCanShowOptions(true);
1969
+ this.matchaOptionService.setSelectedOption(this.value);
1970
+ setTimeout(() => {
1971
+ this.matchaOptionService.setCanShowOptions(false);
1972
+ }, 300);
1973
+ }
1974
+ setIsOptionActive(isOptionActive, isMouseEvent) {
1975
+ if (isMouseEvent) {
1976
+ this.matchaOptionService.removeActiveOption();
1977
+ }
1978
+ this.isOptionActive = isOptionActive;
1979
+ this.changeDetectorRef.detectChanges();
1980
+ }
1981
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: MatchaOptionService }], target: i0.ɵɵFactoryTarget.Component }); }
1982
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: MatchaOptionComponent, isStandalone: false, selector: "matcha-option", inputs: { value: "value" }, ngImport: i0, template: "<span\n (click)=\"selectOption()\"\n (mouseenter)=\"setIsOptionActive(true, true)\"\n (mouseleave)=\"setIsOptionActive(false, true)\"\n [class.background-bg]=\"isOptionActive\"\n class=\"d-block py-8 cursor-pointer px-16 w-100-p\">\n <ng-content></ng-content>\n</span>\n", styles: [""] }); }
1983
+ }
1984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionComponent, decorators: [{
1985
+ type: Component,
1986
+ args: [{ selector: 'matcha-option', standalone: false, template: "<span\n (click)=\"selectOption()\"\n (mouseenter)=\"setIsOptionActive(true, true)\"\n (mouseleave)=\"setIsOptionActive(false, true)\"\n [class.background-bg]=\"isOptionActive\"\n class=\"d-block py-8 cursor-pointer px-16 w-100-p\">\n <ng-content></ng-content>\n</span>\n" }]
1987
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: MatchaOptionService }], propDecorators: { value: [{
1988
+ type: Input
1989
+ }] } });
1990
+
1991
+ class MatchaAutocompleteComponent {
1992
+ constructor(changeDetectorRef, matchaOptionService) {
1993
+ this.changeDetectorRef = changeDetectorRef;
1994
+ this.matchaOptionService = matchaOptionService;
1995
+ this.isDisplayAutocomplete = false;
1996
+ this.activeOption = 0;
1997
+ }
1998
+ ngOnInit() {
1999
+ this.matchaOptionService.canShowOptions$.subscribe((canShowOptions) => {
2000
+ if (!canShowOptions) {
2001
+ this.matchaOptionService.resetActiveOption();
2002
+ }
2003
+ this.isDisplayAutocomplete = canShowOptions;
2004
+ });
2005
+ }
2006
+ ngAfterContentInit() {
2007
+ const options = this.options.toArray();
2008
+ if (options.length > 0) {
2009
+ options[0].setIsOptionActive(true, false);
2010
+ }
2011
+ this.matchaOptionService.updateOptions(options);
2012
+ this.options.changes.subscribe((newOptions) => {
2013
+ this.matchaOptionService.updateOptions(newOptions.toArray());
2014
+ this.matchaOptionService.resetActiveOption();
2015
+ });
2016
+ this.matchaOptionService.activeOption$.subscribe((currentActiveOption) => {
2017
+ this.activeOption = currentActiveOption;
2018
+ this.changeDetectorRef.detectChanges();
2019
+ });
2020
+ }
2021
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: MatchaOptionService }], target: i0.ɵɵFactoryTarget.Component }); }
2022
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: MatchaAutocompleteComponent, isStandalone: false, selector: "matcha-autocomplete", queries: [{ propertyName: "options", predicate: MatchaOptionComponent }], ngImport: i0, template: "<ng-container *ngIf=\"isDisplayAutocomplete\">\n <div class=\"background-bg pt-24 position-absolute z-index-2 w-100-p\">\n <ul class=\"background-surface m-0 radius-8 elevation-z-1 p-0\">\n <ng-content></ng-content>\n </ul>\n </div>\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
2023
+ }
2024
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteComponent, decorators: [{
2025
+ type: Component,
2026
+ args: [{ selector: 'matcha-autocomplete', standalone: false, template: "<ng-container *ngIf=\"isDisplayAutocomplete\">\n <div class=\"background-bg pt-24 position-absolute z-index-2 w-100-p\">\n <ul class=\"background-surface m-0 radius-8 elevation-z-1 p-0\">\n <ng-content></ng-content>\n </ul>\n </div>\n</ng-container>\n" }]
2027
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: MatchaOptionService }], propDecorators: { options: [{
2028
+ type: ContentChildren,
2029
+ args: [MatchaOptionComponent]
2030
+ }] } });
2031
+
1890
2032
  class MatchaSlideToggleComponent {
1891
2033
  set checked(value) {
1892
2034
  const newCheckedState = value === '' ? true : !!value;
@@ -3817,6 +3959,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
3817
3959
  }]
3818
3960
  }] });
3819
3961
 
3962
+ class MatchaOptionModule {
3963
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
3964
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionModule, declarations: [MatchaOptionComponent], imports: [CommonModule], exports: [MatchaOptionComponent] }); }
3965
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionModule, imports: [CommonModule] }); }
3966
+ }
3967
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaOptionModule, decorators: [{
3968
+ type: NgModule,
3969
+ args: [{
3970
+ declarations: [MatchaOptionComponent],
3971
+ imports: [CommonModule],
3972
+ exports: [MatchaOptionComponent],
3973
+ }]
3974
+ }] });
3975
+
3976
+ class MatchaAutocompleteDirective {
3977
+ displayAutocomplete() {
3978
+ this.matchaOptionService.setCanShowOptions(true);
3979
+ }
3980
+ hideAutocomplete() {
3981
+ setTimeout(() => {
3982
+ const canShowAutocomplete = this.matchaOptionService.getCanShowOptions();
3983
+ if (canShowAutocomplete) {
3984
+ this.matchaOptionService.setCanShowOptions(false);
3985
+ }
3986
+ }, 300);
3987
+ }
3988
+ onArrowDown(event) {
3989
+ switch (event.key) {
3990
+ case 'ArrowDown':
3991
+ this.matchaOptionService.changeActiveOption(1);
3992
+ break;
3993
+ case 'ArrowUp':
3994
+ this.matchaOptionService.changeActiveOption(-1);
3995
+ break;
3996
+ case 'Enter':
3997
+ this.matchaOptionService.selectActiveOption();
3998
+ break;
3999
+ default:
4000
+ break;
4001
+ }
4002
+ }
4003
+ constructor(ngControl, _elementRef, matchaOptionService) {
4004
+ this.ngControl = ngControl;
4005
+ this._elementRef = _elementRef;
4006
+ this.matchaOptionService = matchaOptionService;
4007
+ }
4008
+ ngOnInit() {
4009
+ this.matchaOptionService.selectedOption$.subscribe((option) => {
4010
+ this._updateInputValue(option);
4011
+ });
4012
+ }
4013
+ _updateInputValue(selectedOption) {
4014
+ if (this.ngControl.control) {
4015
+ this.ngControl.control.setValue(selectedOption);
4016
+ this.ngControl.control.markAsDirty();
4017
+ this.matchaOptionService.setCanShowOptions(false);
4018
+ this._elementRef.nativeElement.blur();
4019
+ }
4020
+ }
4021
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteDirective, deps: [{ token: i1$1.NgControl }, { token: i0.ElementRef }, { token: MatchaOptionService }], target: i0.ɵɵFactoryTarget.Directive }); }
4022
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.14", type: MatchaAutocompleteDirective, isStandalone: false, selector: "[matchaAutocomplete]", inputs: { matchaAutocomplete: "matchaAutocomplete" }, host: { listeners: { "focus": "displayAutocomplete()", "focusout": "hideAutocomplete()", "keydown": "onArrowDown($event)" } }, ngImport: i0 }); }
4023
+ }
4024
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteDirective, decorators: [{
4025
+ type: Directive,
4026
+ args: [{
4027
+ selector: '[matchaAutocomplete]',
4028
+ standalone: false,
4029
+ }]
4030
+ }], ctorParameters: () => [{ type: i1$1.NgControl }, { type: i0.ElementRef }, { type: MatchaOptionService }], propDecorators: { matchaAutocomplete: [{
4031
+ type: Input
4032
+ }], displayAutocomplete: [{
4033
+ type: HostListener,
4034
+ args: ['focus']
4035
+ }], hideAutocomplete: [{
4036
+ type: HostListener,
4037
+ args: ['focusout']
4038
+ }], onArrowDown: [{
4039
+ type: HostListener,
4040
+ args: ['keydown', ['$event']]
4041
+ }] } });
4042
+
4043
+ class MatchaAutocompleteModule {
4044
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
4045
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteModule, declarations: [MatchaAutocompleteComponent, MatchaAutocompleteDirective], imports: [CommonModule, FormsModule, MatchaOptionModule], exports: [MatchaAutocompleteComponent, MatchaAutocompleteDirective] }); }
4046
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteModule, imports: [CommonModule, FormsModule, MatchaOptionModule] }); }
4047
+ }
4048
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaAutocompleteModule, decorators: [{
4049
+ type: NgModule,
4050
+ args: [{
4051
+ declarations: [MatchaAutocompleteComponent, MatchaAutocompleteDirective],
4052
+ imports: [CommonModule, FormsModule, MatchaOptionModule],
4053
+ exports: [MatchaAutocompleteComponent, MatchaAutocompleteDirective],
4054
+ }]
4055
+ }] });
4056
+
3820
4057
  /*
3821
4058
  * Public API Surface of matcha-components
3822
4059
  */
@@ -3831,11 +4068,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
3831
4068
  // -----------------------------------------------------------
3832
4069
  // COMPONENTS
3833
4070
  // -----------------------------------------------------------
3834
- //export * from './lib/matcha-autocomplete/matcha-autocomplete.directive';
3835
4071
 
3836
4072
  /**
3837
4073
  * Generated bundle index. Do not edit.
3838
4074
  */
3839
4075
 
3840
- export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaLabelComponent, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOverlayService, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, MatchaTreeDirective, MatchaTreeModule };
4076
+ export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteDirective, MatchaAutocompleteModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaLabelComponent, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOptionService, MatchaOverlayService, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, MatchaTreeDirective, MatchaTreeModule };
3841
4077
  //# sourceMappingURL=matcha-components.mjs.map