UNPKG

ngx-mat-dropdown

Version:
1,114 lines (1,105 loc) 42.6 kB
import { Injectable, ɵɵdefineInjectable, EventEmitter, Component, Input, Output, ViewChild, ElementRef, forwardRef, ChangeDetectionStrategy, Inject, ChangeDetectorRef, Optional, HostBinding, NgModule } from '@angular/core'; import { FormControl, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSelect, MatSelectModule } from '@angular/material/select'; import { ReplaySubject, Subject } from 'rxjs'; import { takeUntil, take, delay } from 'rxjs/operators'; import { MatOption } from '@angular/material/core'; import { CommonModule } from '@angular/common'; import { MatTooltipModule } from '@angular/material/tooltip'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatIconModule } from '@angular/material/icon'; import { MatCheckboxModule } from '@angular/material/checkbox'; /** * @fileoverview added by tsickle * Generated from: lib/mat-dropdown.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MatDropdownService = /** @class */ (function () { function MatDropdownService() { } MatDropdownService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ MatDropdownService.ctorParameters = function () { return []; }; /** @nocollapse */ MatDropdownService.ɵprov = ɵɵdefineInjectable({ factory: function MatDropdownService_Factory() { return new MatDropdownService(); }, token: MatDropdownService, providedIn: "root" }); return MatDropdownService; }()); /** * @fileoverview added by tsickle * Generated from: lib/dropdown-settings.model.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var DropdownSettingsModel = /** @class */ (function () { function DropdownSettingsModel(id, multiple, placeholder, labelKey, keyValue, tooltip) { if (id === void 0) { id = ""; } if (multiple === void 0) { multiple = false; } if (placeholder === void 0) { placeholder = "Search"; } if (labelKey === void 0) { labelKey = "name"; } if (keyValue === void 0) { keyValue = "key"; } if (tooltip === void 0) { tooltip = "Code"; } this.id = id; this.multiple = multiple; this.placeholder = placeholder; this.labelKey = labelKey; this.keyValue = keyValue; this.tooltip = tooltip ? tooltip : labelKey; } return DropdownSettingsModel; }()); if (false) { /** @type {?} */ DropdownSettingsModel.prototype.id; /** @type {?} */ DropdownSettingsModel.prototype.multiple; /** @type {?} */ DropdownSettingsModel.prototype.placeholder; /** @type {?} */ DropdownSettingsModel.prototype.labelKey; /** @type {?} */ DropdownSettingsModel.prototype.keyValue; /** @type {?} */ DropdownSettingsModel.prototype.tooltip; } /** * @fileoverview added by tsickle * Generated from: lib/mat-dropdown.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MatDropdownComponent = /** @class */ (function () { function MatDropdownComponent() { this.dropdownCtrl = new FormControl(); this.appearance = "outline"; /** * control for the MatSelect filter keyword */ this.FilterCtrl = new FormControl(); this.dropdownList = []; this.onselectItems = new EventEmitter(); this.filteredBanks = new ReplaySubject(1); /** * Subject that emits when the component has been destroyed. */ this._onDestroy = new Subject(); } Object.defineProperty(MatDropdownComponent.prototype, "dropdownDisabled", { set: /** * @param {?} isTrue * @return {?} */ function (isTrue) { if (isTrue) { this.dropdownCtrl.disable(); } else { this.dropdownCtrl.enable(); } }, enumerable: true, configurable: true }); Object.defineProperty(MatDropdownComponent.prototype, "getdropdownList", { set: /** * @param {?} list * @return {?} */ function (list) { if (list) { this.dropdownList = list; this.filteredBanks.next(list.slice()); } else { } }, enumerable: true, configurable: true }); Object.defineProperty(MatDropdownComponent.prototype, "onselect", { set: /** * @param {?} evt * @return {?} */ function (evt) { if (evt) { this.selectedItems = evt; // console.log(evt, this.preBind); this.dropdownCtrl.setValue(evt); } else { if (this.dropdownSettings.multiple) { this.selectedItems = []; } else this.selectedItems = null; this.dropdownCtrl.setValue(evt); } }, enumerable: true, configurable: true }); /** * @return {?} */ MatDropdownComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; // set intial value // listen for search field value changes this.FilterCtrl.valueChanges .pipe(takeUntil(this._onDestroy)) .subscribe((/** * @return {?} */ function () { /** @type {?} */ var evt = _this.FilterCtrl.value; _this._filter(evt); })); }; /** * @private * @param {?} evt * @return {?} */ MatDropdownComponent.prototype._filter = /** * @private * @param {?} evt * @return {?} */ function (evt) { var _this = this; if (evt) this.filteredBanks.next(this.dropdownList.filter((/** * @param {?} x * @return {?} */ function (x) { return x[_this.dropdownSettings.labelKey] .toLowerCase() .includes(evt.val.toLowerCase()); }))); else this.filteredBanks.next(this.dropdownList.slice()); }; /** * @return {?} */ MatDropdownComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { //this.dropdownCtrl.setValue(this.selectedItems); if (!this.dropdownSettings.multiple) this.setInitialValue(); }; /** * @return {?} */ MatDropdownComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this._onDestroy.next(); this._onDestroy.complete(); }; /** * @private * @return {?} */ MatDropdownComponent.prototype.setInitialValue = /** * @private * @return {?} */ function () { var _this = this; this.filteredBanks .pipe(take(1), takeUntil(this._onDestroy)) .subscribe((/** * @return {?} */ function () { _this.singleSelect.compareWith = (/** * @param {?} a * @param {?} b * @return {?} */ function (a, b) { if (a && b) return (a[_this.dropdownSettings.keyValue] === b[_this.dropdownSettings.keyValue]); }); })); }; /** * @param {?} evt * @return {?} */ MatDropdownComponent.prototype.OnSelectedEvent = /** * @param {?} evt * @return {?} */ function (evt) { this.onselectItems.emit(evt.source); //if (evt.isUserInput) { // this.onselectItems.emit(evt.source); //} else { // this.onselectItems.emit({ value: null }); //} }; // multi // multi /** * @param {?} checked * @return {?} */ MatDropdownComponent.prototype.AllClicked = // multi /** * @param {?} checked * @return {?} */ function (checked) { //console.log(checked, this.multidropdownCtrl) if (checked.checked) { // this.multidropdownCtrl.patchValue([...this.dropdownList.map(item => item.key), 0]); /** @type {?} */ var items = this.dropdownList.map((/** * @param {?} item * @return {?} */ function (item) { return item; })); this.dropdownCtrl.setValue(items); } else { // this.multidropdownCtrl.patchValue([]); this.dropdownCtrl.setValue([]); } this.onselectItems.emit(this.dropdownCtrl); }; /** * @param {?} check * @return {?} */ MatDropdownComponent.prototype.ischecked = /** * @param {?} check * @return {?} */ function (check) { /** @type {?} */ var selected = this.dropdownCtrl.value; return (this.dropdownList && selected && selected.length > 0 && this.dropdownList.length == selected.length); }; /** * @return {?} */ MatDropdownComponent.prototype.isIndeterminate = /** * @return {?} */ function () { /** @type {?} */ var selected = this.dropdownCtrl.value; return (this.dropdownList && selected && selected.length > 0 && selected.length < this.dropdownList.length); }; /** * @return {?} */ MatDropdownComponent.prototype.openedChange = /** * @return {?} */ function () { if (!this.innerSelectAll || !this.innerSelectAll.nativeElement) { return; } /** @type {?} */ var SelectAllElement = this.innerSelectAll.nativeElement; /** @type {?} */ var SelectAllPanelElement; while ((SelectAllElement = SelectAllElement.parentElement)) { if (SelectAllElement.classList.contains("mat-select-panel")) { SelectAllPanelElement = SelectAllElement; break; } } if (SelectAllPanelElement) { this.innerSelectAll.nativeElement.style.width = SelectAllPanelElement.clientWidth + "px"; /** @type {?} */ var children = this.innerSelectAll.nativeElement.childNodes; //if (children) // children[0].childNodes[0].style.width = SelectallpanelElement.clientWidth + 'px'; } }; MatDropdownComponent.decorators = [ { type: Component, args: [{ selector: "ngx-mat-dropdown", template: "<mat-form-field appearance=\"{{appearance}}\">\r\n <mat-label>{{dropdownSettings?.placeholder}}</mat-label>\r\n <mat-select disableOptionCentering [formControl]=\"dropdownCtrl\" [attr.id]=\"dropdownSettings?.id\" \r\n (selectionChange)=\"OnSelectedEvent($event)\"\r\n [placeholder]=\"dropdownSettings.placeholder \" \r\n #singleSelect [multiple]=\"dropdownSettings?.multiple\" \r\n matTooltip=\"{{selectedItems ? selectedItems[dropdownSettings.labelKey] : ''}}\"\r\n [multiple]=\"dropdownSettings?.multiple\">\r\n <mat-select-search [formControl]=\"FilterCtrl\" [multiple]=\"dropdownSettings?.multiple\" *ngIf=\"dropdownList.length > 5\"></mat-select-search>\r\n <div #innerSelectall [style.top.px]=\"dropdownList?.length <= 5 ? 0 : 44\" class=\"mat-select-all-inner\" *ngIf=\"dropdownList?.length !== 0 && dropdownSettings.multiple\" >\r\n <mat-checkbox class=\"mat-option mat-select-checkbox\" [disableRipple]=\"true\" [indeterminate]=\"isIndeterminate()\" [checked]=\"ischecked(check)\" (change)=\"AllClicked($event)\" #check>\r\n {{ check.checked ? ('Unselect All' ) : ('Select All' ) }}\r\n </mat-checkbox>\r\n </div>\r\n <mat-option *ngIf=\"dropdownList.length && !dropdownSettings.multiple\">None</mat-option>\r\n <mat-option *ngFor=\"let item of filteredBanks | async\" [value]=\"item\" \r\n matTooltip=\"{{item[dropdownSettings.labelKey]}}\">\r\n {{ item[dropdownSettings.labelKey] }}\r\n </mat-option>\r\n </mat-select>\r\n</mat-form-field>", styles: ["\n .mat-select-all-inner {\n position: absolute;\n top: 52px;\n width: calc(100% + 3px);\n \n background: white;\n z-index: 100;\n font-size: inherit;\n box-shadow: none;\n border-radius: 0;\n -webkit-transform: translate3d(0,0,0);\n}\n\n "] }] } ]; /** @nocollapse */ MatDropdownComponent.ctorParameters = function () { return []; }; MatDropdownComponent.propDecorators = { dropdownCtrl: [{ type: Input, args: ["ctrl",] }], appearance: [{ type: Input }], dropdownSettings: [{ type: Input, args: ["dropdownSettings",] }], dropdownDisabled: [{ type: Input, args: ["disabled",] }], getdropdownList: [{ type: Input, args: ["dropdownList",] }], onselect: [{ type: Input, args: ["selectedItems",] }], onselectItems: [{ type: Output, args: ["onselectItems",] }], singleSelect: [{ type: ViewChild, args: ["singleSelect", { read: ElementRef },] }], innerSelectAll: [{ type: ViewChild, args: ["innerSelectall", { read: ElementRef, static: true },] }] }; return MatDropdownComponent; }()); if (false) { /** @type {?} */ MatDropdownComponent.prototype.dropdownCtrl; /** @type {?} */ MatDropdownComponent.prototype.appearance; /** * control for the MatSelect filter keyword * @type {?} */ MatDropdownComponent.prototype.FilterCtrl; /** @type {?} */ MatDropdownComponent.prototype.dropdownSettings; /** @type {?} */ MatDropdownComponent.prototype.dropdownList; /** @type {?} */ MatDropdownComponent.prototype.selectedItems; /** @type {?} */ MatDropdownComponent.prototype.onselectItems; /** @type {?} */ MatDropdownComponent.prototype.filteredBanks; /** @type {?} */ MatDropdownComponent.prototype.singleSelect; /** @type {?} */ MatDropdownComponent.prototype.innerSelectAll; /** * Subject that emits when the component has been destroyed. * @type {?} * @private */ MatDropdownComponent.prototype._onDestroy; } /** * @fileoverview added by tsickle * Generated from: lib/mat-select-search/mat-select-search.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MatSelectSearchComponent = /** @class */ (function () { function MatSelectSearchComponent(matSelect, changeDetectorRef, matOption) { if (matOption === void 0) { matOption = null; } this.matSelect = matSelect; this.changeDetectorRef = changeDetectorRef; this.matOption = matOption; /** * Label of the search placeholder */ this.placeholderLabel = 'Search'; this.multiple = false; this.showSearch = true; /** * Label to be shown when no entries are found. Set to null if no message should be shown. */ this.noEntriesFoundLabel = 'No Data'; this.onChange = (/** * @param {?} _ * @return {?} */ function (_) { }); this.onTouched = (/** * @param {?} _ * @return {?} */ function (_) { }); /** * Whether the backdrop class has been set */ this.overlayClassSet = false; /** * Event that emits when the current value changes */ this.change = new EventEmitter(); this.AllClicked = new EventEmitter(); /** * Subject that emits when the component has been destroyed. */ this._onDestroy = new Subject(); } Object.defineProperty(MatSelectSearchComponent.prototype, "isInsideMatOption", { //@ViewChild('innerSelectall', { read: ElementRef }) innerSelectall: ElementRef; get: //@ViewChild('innerSelectall', { read: ElementRef }) innerSelectall: ElementRef; /** * @return {?} */ function () { return !!this.matOption; }, enumerable: true, configurable: true }); Object.defineProperty(MatSelectSearchComponent.prototype, "value", { /** Current search value */ get: /** * Current search value * @return {?} */ function () { return this._value; }, enumerable: true, configurable: true }); /** * @return {?} */ MatSelectSearchComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; // set custom panel class /** @type {?} */ var panelClass = 'mat-select-search-panel'; if (this.matSelect.panelClass) { if (Array.isArray(this.matSelect.panelClass)) { this.matSelect.panelClass.push(panelClass); } else if (typeof this.matSelect.panelClass === 'string') { this.matSelect.panelClass = [this.matSelect.panelClass, panelClass]; } else if (typeof this.matSelect.panelClass === 'object') { this.matSelect.panelClass[panelClass] = true; } } else { this.matSelect.panelClass = panelClass; } // set custom mat-option class if the component was placed inside a mat-option if (this.matOption) { this.matOption.disabled = true; this.matOption._getHostElement().classList.add('contains-mat-select-search'); } // when the select dropdown panel is opened or closed this.matSelect.openedChange // .pipe(takeUntil(this._onDestroy)) .pipe(delay(1), takeUntil(this._onDestroy)) .subscribe((/** * @param {?} opened * @return {?} */ function (opened) { if (opened) { // focus the search field when opening _this.getWidth(); _this._focus(); } else { // clear it when closing _this._reset(); } })); // set the first item active after the options changed this.matSelect.openedChange .pipe(take(1)) .pipe(takeUntil(this._onDestroy)) .subscribe((/** * @return {?} */ function () { _this._options = _this.matSelect.options; _this._options.changes .pipe(takeUntil(_this._onDestroy)) .subscribe((/** * @return {?} */ function () { /** @type {?} */ var keyManager = _this.matSelect._keyManager; if (keyManager && _this.matSelect.panelOpen) { // avoid "expression has been changed" error setTimeout((/** * @return {?} */ function () { keyManager.setFirstItemActive(); _this.getWidth(); // set no entries found class on mat option if (_this.matOption) { if (_this._noEntriesFound()) { _this.matOption._getHostElement().classList.add('mat-select-search-no-entries-found'); } else { _this.matOption._getHostElement().classList.remove('mat-select-search-no-entries-found'); } } }), 1); } })); })); // detect changes when the input changes this.change .pipe(takeUntil(this._onDestroy)) .subscribe((/** * @return {?} */ function () { _this.changeDetectorRef.detectChanges(); })); this.initMultipleHandling(); }; /** * @return {?} */ MatSelectSearchComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this._onDestroy.next(); this._onDestroy.complete(); }; /** * @return {?} */ MatSelectSearchComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { var _this = this; setTimeout((/** * @return {?} */ function () { _this.setOverlayClass(); })); this.matSelect.openedChange .pipe(take(1), takeUntil(this._onDestroy)).subscribe((/** * @return {?} */ function () { _this.matSelect.options.changes .pipe(takeUntil(_this._onDestroy)) .subscribe((/** * @return {?} */ function () { _this.changeDetectorRef.markForCheck(); })); })); }; /** * @param {?} event * @return {?} */ MatSelectSearchComponent.prototype._handleKeydown = /** * @param {?} event * @return {?} */ function (event) { if (event.keyCode === 32) { // do not propagate spaces to MatSelect, as this would select the currently active option event.stopPropagation(); } }; /** * @param {?} value * @return {?} */ MatSelectSearchComponent.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { /** @type {?} */ var valueChanged = value !== this._value; if (valueChanged) { this._value = value; this.change.emit({ type: 'Text', val: value }); } }; /** * @param {?} value * @return {?} */ MatSelectSearchComponent.prototype.onInputChange = /** * @param {?} value * @return {?} */ function (value) { /** @type {?} */ var valueChanged = value !== this._value; if (valueChanged) { this._value = value; this.onChange({ type: 'Text', val: value }); this.change.emit({ type: 'Text', val: value }); } }; /** * @param {?} value * @return {?} */ MatSelectSearchComponent.prototype.onBlur = /** * @param {?} value * @return {?} */ function (value) { this.writeValue(value); this.onTouched(); }; /** * @param {?} fn * @return {?} */ MatSelectSearchComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ MatSelectSearchComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @return {?} */ MatSelectSearchComponent.prototype._focus = /** * @return {?} */ function () { if (!this.searchSelectInput || !this.matSelect.panel) { return; } // save and restore scrollTop of panel, since it will be reset by focus() // note: this is hacky /** @type {?} */ var panel = this.matSelect.panel.nativeElement; /** @type {?} */ var scrollTop = panel.scrollTop; // focus this.searchSelectInput.nativeElement.focus(); panel.scrollTop = scrollTop; }; /** * Resets the current search value * {boolean} focus whether to focus after resetting * */ /** * Resets the current search value * {boolean} focus whether to focus after resetting * * @param {?=} focus * @return {?} */ MatSelectSearchComponent.prototype._reset = /** * Resets the current search value * {boolean} focus whether to focus after resetting * * @param {?=} focus * @return {?} */ function (focus) { if (!this.searchSelectInput) { return; } this.searchSelectInput.nativeElement.value = ''; this.onInputChange(''); if (focus) { this._focus(); } }; /** * Sets the overlay class to correct offsetY * so that the selected option is at the position of the select box when opening */ /** * Sets the overlay class to correct offsetY * so that the selected option is at the position of the select box when opening * @private * @return {?} */ MatSelectSearchComponent.prototype.setOverlayClass = /** * Sets the overlay class to correct offsetY * so that the selected option is at the position of the select box when opening * @private * @return {?} */ function () { var _this = this; if (this.overlayClassSet) { return; } /** @type {?} */ var overlayClasses = ['cdk-overlay-pane-select-search']; if (!this.matOption) { // add offset to panel if component is not placed inside mat-option overlayClasses.push('cdk-overlay-pane-select-search-with-offset'); } this.matSelect.overlayDir.attach .pipe(takeUntil(this._onDestroy)) .subscribe((/** * @return {?} */ function () { // note: this is hacky, but currently there is no better way to do this // note: this is hacky, but currently there is no better way to do this /** @type {?} */ var element; /** @type {?} */ var overlayElement; if (_this.searchSelectInput) { element = _this.searchSelectInput.nativeElement; while (element = element.parentElement) { if (element.classList.contains('cdk-overlay-pane')) { overlayElement = element; break; } } } if (overlayElement) { overlayClasses.forEach((/** * @param {?} overlayClass * @return {?} */ function (overlayClass) { overlayElement.classList.add(overlayClass); })); } })); this.overlayClassSet = true; }; /** * Initializes handling <mat-select [multiple]="true"> * Note: to improve this code, mat-select should be extended to allow disabling resetting the selection while filtering. */ /** * Initializes handling <mat-select [multiple]="true"> * Note: to improve this code, mat-select should be extended to allow disabling resetting the selection while filtering. * @private * @return {?} */ MatSelectSearchComponent.prototype.initMultipleHandling = /** * Initializes handling <mat-select [multiple]="true"> * Note: to improve this code, mat-select should be extended to allow disabling resetting the selection while filtering. * @private * @return {?} */ function () { var _this = this; // if <mat-select [multiple]="true"> // store previously selected values and restore them when they are deselected // because the option is not available while we are currently filtering this.matSelect.valueChange .pipe(takeUntil(this._onDestroy)) .subscribe((/** * @param {?} values * @return {?} */ function (values) { if (_this.matSelect.multiple) { /** @type {?} */ var restoreSelectedValues_1 = false; if (_this._value && _this._value.length && _this.previousSelectedValues && Array.isArray(_this.previousSelectedValues)) { if (!values || !Array.isArray(values)) { values = []; } /** @type {?} */ var optionValues_1 = _this.matSelect.options.map((/** * @param {?} option * @return {?} */ function (option) { return option.value; })); _this.previousSelectedValues.forEach((/** * @param {?} previousValue * @return {?} */ function (previousValue) { if (values.indexOf(previousValue) === -1 && optionValues_1.indexOf(previousValue) === -1) { // if a value that was selected before is deselected and not found in the options, it was deselected // due to the filtering, so we restore it. values.push(previousValue); restoreSelectedValues_1 = true; } })); } if (restoreSelectedValues_1) { _this.matSelect._onChange(values); } _this.previousSelectedValues = values; } })); }; /** * @private * @return {?} */ MatSelectSearchComponent.prototype.getWidth = /** * @private * @return {?} */ function () { if (!this.innerSelectSearch || !this.innerSelectSearch.nativeElement) { return; } /** @type {?} */ var element = this.innerSelectSearch.nativeElement; /** @type {?} */ var panelElement; while (element = element.parentElement) { if (element.classList.contains('mat-select-panel')) { panelElement = element; break; } } if (panelElement) { this.innerSelectSearch.nativeElement.style.width = panelElement.clientWidth + 'px'; } ////innerSelectall //if (!this.innerSelectall || !this.innerSelectall.nativeElement) { // return; //} //let Selectallelement: HTMLElement = this.innerSelectall.nativeElement; //let SelectallpanelElement: HTMLElement; //while (Selectallelement = Selectallelement.parentElement) { // if (Selectallelement.classList.contains('mat-select-panel')) { // SelectallpanelElement = Selectallelement; // break; // } //} //if (SelectallpanelElement) { // this.innerSelectall.nativeElement.style.width = SelectallpanelElement.clientWidth + 'px'; //} }; /** * @return {?} */ MatSelectSearchComponent.prototype._noEntriesFound = /** * @return {?} */ function () { if (!this._options) { return; } if (this.matOption) { return this.noEntriesFoundLabel && this.value && this._options.length === 1; } else { return this.noEntriesFoundLabel && this.value && this._options.length === 0; } }; /** * @param {?} change * @param {?} check * @return {?} */ MatSelectSearchComponent.prototype.toggleSelection = /** * @param {?} change * @param {?} check * @return {?} */ function (change, check) { if (change.checked) { //this.model.update.emit(this.values); this.onChange({ type: 'Check', val: change.checked }); this.change.emit({ type: 'Check', val: change.checked }); } else { this.onChange({ type: 'Check', val: change.checked }); this.change.emit({ type: 'Check', val: change.checked }); } }; /** * @param {?} check * @return {?} */ MatSelectSearchComponent.prototype.ischecked = /** * @param {?} check * @return {?} */ function (check) { console.log(this.matSelect.options, this.matSelect.value); /** @type {?} */ var selected = this.matSelect.selected; return this.matSelect.options && selected && selected.length > 0 && this.matSelect.options.length == selected.length; }; /** * @return {?} */ MatSelectSearchComponent.prototype.isIndeterminate = /** * @return {?} */ function () { /** @type {?} */ var selected = this.matSelect.selected; return this.matSelect.options && selected.length > 0 && selected.length < this.matSelect.options.length; }; MatSelectSearchComponent.decorators = [ { type: Component, args: [{ selector: 'mat-select-search', template: "\r\n<input *ngIf=\"showSearch\" matInput class=\"mat-select-search-input mat-select-search-hidden\" />\r\n<input matInput class=\"mat-select-checkbox mat-select-search-hidden\"*ngIf=\"multiple\" />\r\n\r\n<div #innerSelectSearch class=\"mat-select-search-inner\" *ngIf=\"showSearch\"\r\n [ngClass]=\"{'mat-select-search-inner-multiple': matSelect.multiple}\">\r\n <input matInput autocomplete=\"off\"\r\n class=\"mat-select-search-input\"\r\n #searchSelectInput\r\n (keydown)=\"_handleKeydown($event)\"\r\n (input)=\"onInputChange($event.target.value)\"\r\n (blur)=\"onBlur($event.target.value)\"\r\n placeholder=\"Search\" />\r\n <button mat-button *ngIf=\"value\"\r\n mat-icon-button\r\n aria-label=\"Clear\"\r\n (click)=\"_reset(true)\"\r\n class=\"mat-select-search-clear\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n</div>\r\n\r\n<div *ngIf=\"noEntriesFoundLabel && value && _options?.length === 0\"\r\n class=\"mat-select-search-no-entries-found\">\r\n {{noEntriesFoundLabel}}\r\n</div>\r\n", providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ function () { return MatSelectSearchComponent; })), multi: true } ], changeDetection: ChangeDetectionStrategy.OnPush, styles: [".mat-select-search-hidden{visibility:hidden}.mat-select-search-inner{position:absolute;top:0;width:calc(100% + 3px);border-bottom:1px solid #ccc;background:#fff;z-index:100;font-size:inherit;box-shadow:none;border-radius:0;-webkit-transform:translate3d(0,0,0)}.mat-select-search-inner.mat-select-search-inner-multiple{width:100%}::ng-deep .mat-select-search-panel{transform:none!important;overflow-x:hidden}.mat-select-search-input{padding:10px 30px 10px 10px;box-sizing:border-box}.mat-select-checkbox{padding:10px;box-sizing:border-box}.mat-select-search-no-entries-found{padding:10px}.mat-select-search-clear{position:absolute;right:4px;top:5px}:host.mat-select-search-inside-mat-option .mat-select-search-input{padding-top:0;padding-bottom:0;height:3em;line-height:3em}:host.mat-select-search-inside-mat-option .mat-select-checkbox{padding-top:0;padding-bottom:0;height:3em;line-height:3em}:host.mat-select-search-inside-mat-option .mat-select-search-clear{top:3px}::ng-deep .cdk-overlay-pane-select-search.cdk-overlay-pane-select-search-with-offset{margin-top:0}::ng-deep .mat-option[aria-disabled=true].contains-mat-select-search{position:static;padding:0}::ng-deep .mat-option[aria-disabled=true].contains-mat-select-search .mat-icon{margin-right:0}::ng-deep .mat-option[aria-disabled=true].contains-mat-select-search .mat-option-pseudo-checkbox{display:none}::ng-deep .mat-option[aria-disabled=true].contains-mat-select-search.mat-select-search-no-entries-found{height:6em}.mat-select-all-inner{position:absolute;top:52px;width:calc(100% + 3px);background:#fff;z-index:100;font-size:inherit;box-shadow:none;border-radius:0;-webkit-transform:translate3d(0,0,0)}"] }] } ]; /** @nocollapse */ MatSelectSearchComponent.ctorParameters = function () { return [ { type: MatSelect, decorators: [{ type: Inject, args: [MatSelect,] }] }, { type: ChangeDetectorRef }, { type: MatOption, decorators: [{ type: Optional }, { type: Inject, args: [MatOption,] }] } ]; }; MatSelectSearchComponent.propDecorators = { placeholderLabel: [{ type: Input }], multiple: [{ type: Input, args: ['multiple',] }], showSearch: [{ type: Input, args: ['showSearch',] }], noEntriesFoundLabel: [{ type: Input }], searchSelectInput: [{ type: ViewChild, args: ['searchSelectInput', { read: ElementRef },] }], innerSelectSearch: [{ type: ViewChild, args: ['innerSelectSearch', { read: ElementRef },] }], isInsideMatOption: [{ type: HostBinding, args: ['class.mat-select-search-inside-mat-option',] }] }; return MatSelectSearchComponent; }()); if (false) { /** * Label of the search placeholder * @type {?} */ MatSelectSearchComponent.prototype.placeholderLabel; /** @type {?} */ MatSelectSearchComponent.prototype.multiple; /** @type {?} */ MatSelectSearchComponent.prototype.showSearch; /** * Label to be shown when no entries are found. Set to null if no message should be shown. * @type {?} */ MatSelectSearchComponent.prototype.noEntriesFoundLabel; /** * Reference to the search input field * @type {?} */ MatSelectSearchComponent.prototype.searchSelectInput; /** @type {?} */ MatSelectSearchComponent.prototype.innerSelectSearch; /** * @type {?} * @private */ MatSelectSearchComponent.prototype._value; /** @type {?} */ MatSelectSearchComponent.prototype.onChange; /** @type {?} */ MatSelectSearchComponent.prototype.onTouched; /** * Reference to the MatSelect options * @type {?} */ MatSelectSearchComponent.prototype._options; /** * Previously selected values when using <mat-select [multiple]="true"> * @type {?} * @private */ MatSelectSearchComponent.prototype.previousSelectedValues; /** * Whether the backdrop class has been set * @type {?} * @private */ MatSelectSearchComponent.prototype.overlayClassSet; /** * Event that emits when the current value changes * @type {?} * @private */ MatSelectSearchComponent.prototype.change; /** * @type {?} * @private */ MatSelectSearchComponent.prototype.AllClicked; /** * Subject that emits when the component has been destroyed. * @type {?} * @private */ MatSelectSearchComponent.prototype._onDestroy; /** @type {?} */ MatSelectSearchComponent.prototype.matSelect; /** * @type {?} * @private */ MatSelectSearchComponent.prototype.changeDetectorRef; /** @type {?} */ MatSelectSearchComponent.prototype.matOption; } /** * @fileoverview added by tsickle * Generated from: lib/mat-dropdown.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MatDropdownModule = /** @class */ (function () { function MatDropdownModule() { } MatDropdownModule.decorators = [ { type: NgModule, args: [{ declarations: [MatDropdownComponent, MatSelectSearchComponent], imports: [ CommonModule, FormsModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatIconModule, MatCheckboxModule, MatSelectModule, MatTooltipModule ], exports: [MatDropdownComponent] },] } ]; return MatDropdownModule; }()); /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: ngx-mat-dropdown.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { DropdownSettingsModel, MatDropdownComponent, MatDropdownModule, MatDropdownService, MatSelectSearchComponent as ɵa }; //# sourceMappingURL=ngx-mat-dropdown.js.map