mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1186 lines
52 KiB
1186 lines
52 KiB
import { _countGroupLabelsBeforeOption, _getOptionScrollPosition, MAT_OPTION_PARENT_COMPONENT, MatOption, MAT_OPTGROUP } from './_option-chunk.mjs';
|
|
export { MatOptgroup } from './_option-chunk.mjs';
|
|
import { MAT_FORM_FIELD, MatFormFieldControl } from './_form-field-chunk.mjs';
|
|
export { MatError, MatFormField, MatHint, MatLabel, MatPrefix, MatSuffix } from './_form-field-chunk.mjs';
|
|
import { createRepositionScrollStrategy, OVERLAY_DEFAULT_CONFIG, CdkConnectedOverlay, CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay';
|
|
import * as i0 from '@angular/core';
|
|
import { InjectionToken, inject, Injector, ChangeDetectorRef, ElementRef, Renderer2, signal, EventEmitter, HostAttributeToken, booleanAttribute, numberAttribute, Component, ViewEncapsulation, ChangeDetectionStrategy, ContentChildren, ContentChild, Input, ViewChild, Output, Directive, NgModule } from '@angular/core';
|
|
import { ViewportRuler, CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
import { _IdGenerator, LiveAnnouncer, removeAriaReferencedId, addAriaReferencedId, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
|
|
import { Directionality, BidiModule } from '@angular/cdk/bidi';
|
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
import { hasModifierKey, ENTER, SPACE, A, ESCAPE, DOWN_ARROW, UP_ARROW, LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
|
|
import { NgControl, Validators, NgForm, FormGroupDirective } from '@angular/forms';
|
|
import { _getEventTarget } from '@angular/cdk/platform';
|
|
import { Subject, defer, merge } from 'rxjs';
|
|
import { startWith, switchMap, filter, map, takeUntil, take } from 'rxjs/operators';
|
|
import { NgClass } from '@angular/common';
|
|
import { _animationsDisabled } from './_animation-chunk.mjs';
|
|
import { ErrorStateMatcher } from './_error-options-chunk.mjs';
|
|
import { _ErrorStateTracker } from './_error-state-chunk.mjs';
|
|
import { MatOptionModule } from './_option-module-chunk.mjs';
|
|
import { MatFormFieldModule } from './form-field.mjs';
|
|
import './_ripple-chunk.mjs';
|
|
import '@angular/cdk/coercion';
|
|
import '@angular/cdk/private';
|
|
import './_pseudo-checkbox-chunk.mjs';
|
|
import './_structural-styles-chunk.mjs';
|
|
import '@angular/cdk/observers/private';
|
|
import '@angular/cdk/layout';
|
|
import './_ripple-module-chunk.mjs';
|
|
import './_pseudo-checkbox-module-chunk.mjs';
|
|
import '@angular/cdk/observers';
|
|
|
|
function getMatSelectDynamicMultipleError() {
|
|
return Error('Cannot change `multiple` mode of select after initialization.');
|
|
}
|
|
function getMatSelectNonArrayValueError() {
|
|
return Error('Value must be an array in multiple-selection mode.');
|
|
}
|
|
function getMatSelectNonFunctionValueError() {
|
|
return Error('`compareWith` must be a function.');
|
|
}
|
|
|
|
const MAT_SELECT_SCROLL_STRATEGY = new InjectionToken('mat-select-scroll-strategy', {
|
|
providedIn: 'root',
|
|
factory: () => {
|
|
const injector = inject(Injector);
|
|
return () => createRepositionScrollStrategy(injector);
|
|
}
|
|
});
|
|
const MAT_SELECT_CONFIG = new InjectionToken('MAT_SELECT_CONFIG');
|
|
const MAT_SELECT_TRIGGER = new InjectionToken('MatSelectTrigger');
|
|
class MatSelectChange {
|
|
source;
|
|
value;
|
|
constructor(source, value) {
|
|
this.source = source;
|
|
this.value = value;
|
|
}
|
|
}
|
|
class MatSelect {
|
|
_viewportRuler = inject(ViewportRuler);
|
|
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
_elementRef = inject(ElementRef);
|
|
_dir = inject(Directionality, {
|
|
optional: true
|
|
});
|
|
_idGenerator = inject(_IdGenerator);
|
|
_renderer = inject(Renderer2);
|
|
_parentFormField = inject(MAT_FORM_FIELD, {
|
|
optional: true
|
|
});
|
|
ngControl = inject(NgControl, {
|
|
self: true,
|
|
optional: true
|
|
});
|
|
_liveAnnouncer = inject(LiveAnnouncer);
|
|
_defaultOptions = inject(MAT_SELECT_CONFIG, {
|
|
optional: true
|
|
});
|
|
_animationsDisabled = _animationsDisabled();
|
|
_popoverLocation;
|
|
_initialized = new Subject();
|
|
_cleanupDetach;
|
|
options;
|
|
optionGroups;
|
|
customTrigger;
|
|
_positions = [{
|
|
originX: 'start',
|
|
originY: 'bottom',
|
|
overlayX: 'start',
|
|
overlayY: 'top'
|
|
}, {
|
|
originX: 'end',
|
|
originY: 'bottom',
|
|
overlayX: 'end',
|
|
overlayY: 'top'
|
|
}, {
|
|
originX: 'start',
|
|
originY: 'top',
|
|
overlayX: 'start',
|
|
overlayY: 'bottom',
|
|
panelClass: 'mat-mdc-select-panel-above'
|
|
}, {
|
|
originX: 'end',
|
|
originY: 'top',
|
|
overlayX: 'end',
|
|
overlayY: 'bottom',
|
|
panelClass: 'mat-mdc-select-panel-above'
|
|
}];
|
|
_scrollOptionIntoView(index) {
|
|
const option = this.options.toArray()[index];
|
|
if (option) {
|
|
const panel = this.panel.nativeElement;
|
|
const labelCount = _countGroupLabelsBeforeOption(index, this.options, this.optionGroups);
|
|
const element = option._getHostElement();
|
|
if (index === 0 && labelCount === 1) {
|
|
panel.scrollTop = 0;
|
|
} else {
|
|
panel.scrollTop = _getOptionScrollPosition(element.offsetTop, element.offsetHeight, panel.scrollTop, panel.offsetHeight);
|
|
}
|
|
}
|
|
}
|
|
_positioningSettled() {
|
|
this._scrollOptionIntoView(this._keyManager.activeItemIndex || 0);
|
|
}
|
|
_getChangeEvent(value) {
|
|
return new MatSelectChange(this, value);
|
|
}
|
|
_scrollStrategyFactory = inject(MAT_SELECT_SCROLL_STRATEGY);
|
|
_panelOpen = false;
|
|
_compareWith = (o1, o2) => o1 === o2;
|
|
_uid = this._idGenerator.getId('mat-select-');
|
|
_triggerAriaLabelledBy = null;
|
|
_previousControl;
|
|
_destroy = new Subject();
|
|
_errorStateTracker;
|
|
stateChanges = new Subject();
|
|
disableAutomaticLabeling = true;
|
|
userAriaDescribedBy;
|
|
_selectionModel;
|
|
_keyManager;
|
|
_preferredOverlayOrigin;
|
|
_overlayWidth;
|
|
_onChange = () => {};
|
|
_onTouched = () => {};
|
|
_valueId = this._idGenerator.getId('mat-select-value-');
|
|
_scrollStrategy;
|
|
_overlayPanelClass = this._defaultOptions?.overlayPanelClass || '';
|
|
get focused() {
|
|
return this._focused || this._panelOpen;
|
|
}
|
|
_focused = false;
|
|
controlType = 'mat-select';
|
|
trigger;
|
|
panel;
|
|
_overlayDir;
|
|
panelClass;
|
|
disabled = false;
|
|
get disableRipple() {
|
|
return this._disableRipple();
|
|
}
|
|
set disableRipple(value) {
|
|
this._disableRipple.set(value);
|
|
}
|
|
_disableRipple = signal(false, ...(ngDevMode ? [{
|
|
debugName: "_disableRipple"
|
|
}] : []));
|
|
tabIndex = 0;
|
|
get hideSingleSelectionIndicator() {
|
|
return this._hideSingleSelectionIndicator;
|
|
}
|
|
set hideSingleSelectionIndicator(value) {
|
|
this._hideSingleSelectionIndicator = value;
|
|
this._syncParentProperties();
|
|
}
|
|
_hideSingleSelectionIndicator = this._defaultOptions?.hideSingleSelectionIndicator ?? false;
|
|
get placeholder() {
|
|
return this._placeholder;
|
|
}
|
|
set placeholder(value) {
|
|
this._placeholder = value;
|
|
this.stateChanges.next();
|
|
}
|
|
_placeholder;
|
|
get required() {
|
|
return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false;
|
|
}
|
|
set required(value) {
|
|
this._required = value;
|
|
this.stateChanges.next();
|
|
}
|
|
_required;
|
|
get multiple() {
|
|
return this._multiple;
|
|
}
|
|
set multiple(value) {
|
|
if (this._selectionModel && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
throw getMatSelectDynamicMultipleError();
|
|
}
|
|
this._multiple = value;
|
|
}
|
|
_multiple = false;
|
|
disableOptionCentering = this._defaultOptions?.disableOptionCentering ?? false;
|
|
get compareWith() {
|
|
return this._compareWith;
|
|
}
|
|
set compareWith(fn) {
|
|
if (typeof fn !== 'function' && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
throw getMatSelectNonFunctionValueError();
|
|
}
|
|
this._compareWith = fn;
|
|
if (this._selectionModel) {
|
|
this._initializeSelection();
|
|
}
|
|
}
|
|
get value() {
|
|
return this._value;
|
|
}
|
|
set value(newValue) {
|
|
const hasAssigned = this._assignValue(newValue);
|
|
if (hasAssigned) {
|
|
this._onChange(newValue);
|
|
}
|
|
}
|
|
_value;
|
|
ariaLabel = '';
|
|
ariaLabelledby;
|
|
get errorStateMatcher() {
|
|
return this._errorStateTracker.matcher;
|
|
}
|
|
set errorStateMatcher(value) {
|
|
this._errorStateTracker.matcher = value;
|
|
}
|
|
typeaheadDebounceInterval;
|
|
sortComparator;
|
|
get id() {
|
|
return this._id;
|
|
}
|
|
set id(value) {
|
|
this._id = value || this._uid;
|
|
this.stateChanges.next();
|
|
}
|
|
_id;
|
|
get errorState() {
|
|
return this._errorStateTracker.errorState;
|
|
}
|
|
set errorState(value) {
|
|
this._errorStateTracker.errorState = value;
|
|
}
|
|
panelWidth = this._defaultOptions && typeof this._defaultOptions.panelWidth !== 'undefined' ? this._defaultOptions.panelWidth : 'auto';
|
|
canSelectNullableOptions = this._defaultOptions?.canSelectNullableOptions ?? false;
|
|
optionSelectionChanges = defer(() => {
|
|
const options = this.options;
|
|
if (options) {
|
|
return options.changes.pipe(startWith(options), switchMap(() => merge(...options.map(option => option.onSelectionChange))));
|
|
}
|
|
return this._initialized.pipe(switchMap(() => this.optionSelectionChanges));
|
|
});
|
|
openedChange = new EventEmitter();
|
|
_openedStream = this.openedChange.pipe(filter(o => o), map(() => {}));
|
|
_closedStream = this.openedChange.pipe(filter(o => !o), map(() => {}));
|
|
selectionChange = new EventEmitter();
|
|
valueChange = new EventEmitter();
|
|
constructor() {
|
|
const defaultErrorStateMatcher = inject(ErrorStateMatcher);
|
|
const parentForm = inject(NgForm, {
|
|
optional: true
|
|
});
|
|
const parentFormGroup = inject(FormGroupDirective, {
|
|
optional: true
|
|
});
|
|
const tabIndex = inject(new HostAttributeToken('tabindex'), {
|
|
optional: true
|
|
});
|
|
const defaultPopoverConfig = inject(OVERLAY_DEFAULT_CONFIG, {
|
|
optional: true
|
|
});
|
|
if (this.ngControl) {
|
|
this.ngControl.valueAccessor = this;
|
|
}
|
|
if (this._defaultOptions?.typeaheadDebounceInterval != null) {
|
|
this.typeaheadDebounceInterval = this._defaultOptions.typeaheadDebounceInterval;
|
|
}
|
|
this._errorStateTracker = new _ErrorStateTracker(defaultErrorStateMatcher, this.ngControl, parentFormGroup, parentForm, this.stateChanges);
|
|
this._scrollStrategy = this._scrollStrategyFactory();
|
|
this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0;
|
|
this._popoverLocation = defaultPopoverConfig?.usePopover === false ? null : 'inline';
|
|
this.id = this.id;
|
|
}
|
|
ngOnInit() {
|
|
this._selectionModel = new SelectionModel(this.multiple);
|
|
this.stateChanges.next();
|
|
this._viewportRuler.change().pipe(takeUntil(this._destroy)).subscribe(() => {
|
|
if (this.panelOpen) {
|
|
this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
|
|
this._changeDetectorRef.detectChanges();
|
|
}
|
|
});
|
|
}
|
|
ngAfterContentInit() {
|
|
this._initialized.next();
|
|
this._initialized.complete();
|
|
this._initKeyManager();
|
|
this._selectionModel.changed.pipe(takeUntil(this._destroy)).subscribe(event => {
|
|
event.added.forEach(option => option.select());
|
|
event.removed.forEach(option => option.deselect());
|
|
});
|
|
this.options.changes.pipe(startWith(null), takeUntil(this._destroy)).subscribe(() => {
|
|
this._resetOptions();
|
|
this._initializeSelection();
|
|
});
|
|
}
|
|
ngDoCheck() {
|
|
const newAriaLabelledby = this._getTriggerAriaLabelledby();
|
|
const ngControl = this.ngControl;
|
|
if (newAriaLabelledby !== this._triggerAriaLabelledBy) {
|
|
const element = this._elementRef.nativeElement;
|
|
this._triggerAriaLabelledBy = newAriaLabelledby;
|
|
if (newAriaLabelledby) {
|
|
element.setAttribute('aria-labelledby', newAriaLabelledby);
|
|
} else {
|
|
element.removeAttribute('aria-labelledby');
|
|
}
|
|
}
|
|
if (ngControl) {
|
|
if (this._previousControl !== ngControl.control) {
|
|
if (this._previousControl !== undefined && ngControl.disabled !== null && ngControl.disabled !== this.disabled) {
|
|
this.disabled = ngControl.disabled;
|
|
}
|
|
this._previousControl = ngControl.control;
|
|
}
|
|
this.updateErrorState();
|
|
}
|
|
}
|
|
ngOnChanges(changes) {
|
|
if (changes['disabled'] || changes['userAriaDescribedBy']) {
|
|
this.stateChanges.next();
|
|
}
|
|
if (changes['typeaheadDebounceInterval'] && this._keyManager) {
|
|
this._keyManager.withTypeAhead(this.typeaheadDebounceInterval);
|
|
}
|
|
}
|
|
ngOnDestroy() {
|
|
this._cleanupDetach?.();
|
|
this._keyManager?.destroy();
|
|
this._destroy.next();
|
|
this._destroy.complete();
|
|
this.stateChanges.complete();
|
|
this._clearFromModal();
|
|
}
|
|
toggle() {
|
|
this.panelOpen ? this.close() : this.open();
|
|
}
|
|
open() {
|
|
if (!this._canOpen()) {
|
|
return;
|
|
}
|
|
if (this._parentFormField) {
|
|
this._preferredOverlayOrigin = this._parentFormField.getConnectedOverlayOrigin();
|
|
}
|
|
this._cleanupDetach?.();
|
|
this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
|
|
this._applyModalPanelOwnership();
|
|
this._panelOpen = true;
|
|
this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
|
|
this._changeDetectorRef.detectChanges();
|
|
this._positioningSettled();
|
|
});
|
|
this._overlayDir.attachOverlay();
|
|
this._keyManager.withHorizontalOrientation(null);
|
|
this._highlightCorrectOption();
|
|
this._changeDetectorRef.markForCheck();
|
|
this.stateChanges.next();
|
|
Promise.resolve().then(() => this.openedChange.emit(true));
|
|
}
|
|
_trackedModal = null;
|
|
_applyModalPanelOwnership() {
|
|
const modal = this._elementRef.nativeElement.closest('body > .cdk-overlay-container [aria-modal="true"]');
|
|
if (!modal) {
|
|
return;
|
|
}
|
|
const panelId = `${this.id}-panel`;
|
|
if (this._trackedModal) {
|
|
removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
|
|
}
|
|
addAriaReferencedId(modal, 'aria-owns', panelId);
|
|
this._trackedModal = modal;
|
|
}
|
|
_clearFromModal() {
|
|
if (!this._trackedModal) {
|
|
return;
|
|
}
|
|
const panelId = `${this.id}-panel`;
|
|
removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
|
|
this._trackedModal = null;
|
|
}
|
|
close() {
|
|
if (this._panelOpen) {
|
|
this._panelOpen = false;
|
|
this._exitAndDetach();
|
|
this._keyManager.withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr');
|
|
this._changeDetectorRef.markForCheck();
|
|
this._onTouched();
|
|
this.stateChanges.next();
|
|
Promise.resolve().then(() => this.openedChange.emit(false));
|
|
}
|
|
}
|
|
_exitAndDetach() {
|
|
if (this._animationsDisabled || !this.panel) {
|
|
this._detachOverlay();
|
|
return;
|
|
}
|
|
this._cleanupDetach?.();
|
|
this._cleanupDetach = () => {
|
|
cleanupEvent();
|
|
clearTimeout(exitFallbackTimer);
|
|
this._cleanupDetach = undefined;
|
|
};
|
|
const panel = this.panel.nativeElement;
|
|
const cleanupEvent = this._renderer.listen(panel, 'animationend', event => {
|
|
if (event.animationName === '_mat-select-exit') {
|
|
this._cleanupDetach?.();
|
|
this._detachOverlay();
|
|
}
|
|
});
|
|
const exitFallbackTimer = setTimeout(() => {
|
|
this._cleanupDetach?.();
|
|
this._detachOverlay();
|
|
}, 200);
|
|
panel.classList.add('mat-select-panel-exit');
|
|
}
|
|
_detachOverlay() {
|
|
this._overlayDir.detachOverlay();
|
|
this._changeDetectorRef.markForCheck();
|
|
}
|
|
writeValue(value) {
|
|
this._assignValue(value);
|
|
}
|
|
registerOnChange(fn) {
|
|
this._onChange = fn;
|
|
}
|
|
registerOnTouched(fn) {
|
|
this._onTouched = fn;
|
|
}
|
|
setDisabledState(isDisabled) {
|
|
this.disabled = isDisabled;
|
|
this._changeDetectorRef.markForCheck();
|
|
this.stateChanges.next();
|
|
}
|
|
get panelOpen() {
|
|
return this._panelOpen;
|
|
}
|
|
get selected() {
|
|
return this.multiple ? this._selectionModel?.selected || [] : this._selectionModel?.selected[0];
|
|
}
|
|
get triggerValue() {
|
|
if (this.empty) {
|
|
return '';
|
|
}
|
|
if (this._multiple) {
|
|
const selectedOptions = this._selectionModel.selected.map(option => option.viewValue);
|
|
if (this._isRtl()) {
|
|
selectedOptions.reverse();
|
|
}
|
|
return selectedOptions.join(', ');
|
|
}
|
|
return this._selectionModel.selected[0].viewValue;
|
|
}
|
|
updateErrorState() {
|
|
this._errorStateTracker.updateErrorState();
|
|
}
|
|
_isRtl() {
|
|
return this._dir ? this._dir.value === 'rtl' : false;
|
|
}
|
|
_handleKeydown(event) {
|
|
if (!this.disabled) {
|
|
this.panelOpen ? this._handleOpenKeydown(event) : this._handleClosedKeydown(event);
|
|
}
|
|
}
|
|
_handleClosedKeydown(event) {
|
|
const keyCode = event.keyCode;
|
|
const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW || keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW;
|
|
const isOpenKey = keyCode === ENTER || keyCode === SPACE;
|
|
const manager = this._keyManager;
|
|
if (!manager.isTyping() && isOpenKey && !hasModifierKey(event) || (this.multiple || event.altKey) && isArrowKey) {
|
|
event.preventDefault();
|
|
this.open();
|
|
} else if (!this.multiple) {
|
|
const previouslySelectedOption = this.selected;
|
|
manager.onKeydown(event);
|
|
const selectedOption = this.selected;
|
|
if (selectedOption && previouslySelectedOption !== selectedOption) {
|
|
this._liveAnnouncer.announce(selectedOption.viewValue, 10000);
|
|
}
|
|
}
|
|
}
|
|
_handleOpenKeydown(event) {
|
|
const manager = this._keyManager;
|
|
const keyCode = event.keyCode;
|
|
const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW;
|
|
const isTyping = manager.isTyping();
|
|
if (isArrowKey && event.altKey) {
|
|
event.preventDefault();
|
|
this.close();
|
|
} else if (!isTyping && (keyCode === ENTER || keyCode === SPACE) && manager.activeItem && !hasModifierKey(event)) {
|
|
event.preventDefault();
|
|
manager.activeItem._selectViaInteraction();
|
|
} else if (!isTyping && this._multiple && keyCode === A && event.ctrlKey) {
|
|
event.preventDefault();
|
|
const hasDeselectedOptions = this.options.some(opt => !opt.disabled && !opt.selected);
|
|
this.options.forEach(option => {
|
|
if (!option.disabled) {
|
|
hasDeselectedOptions ? option.select() : option.deselect();
|
|
}
|
|
});
|
|
} else {
|
|
const previouslyFocusedIndex = manager.activeItemIndex;
|
|
manager.onKeydown(event);
|
|
if (this._multiple && isArrowKey && event.shiftKey && manager.activeItem && manager.activeItemIndex !== previouslyFocusedIndex) {
|
|
manager.activeItem._selectViaInteraction();
|
|
}
|
|
}
|
|
}
|
|
_handleOverlayKeydown(event) {
|
|
if (event.keyCode === ESCAPE && !hasModifierKey(event)) {
|
|
event.preventDefault();
|
|
this.close();
|
|
}
|
|
}
|
|
_onFocus() {
|
|
if (!this.disabled) {
|
|
this._focused = true;
|
|
this.stateChanges.next();
|
|
}
|
|
}
|
|
_onBlur() {
|
|
this._focused = false;
|
|
this._keyManager?.cancelTypeahead();
|
|
if (!this.disabled && !this.panelOpen) {
|
|
this._onTouched();
|
|
this._changeDetectorRef.markForCheck();
|
|
this.stateChanges.next();
|
|
}
|
|
}
|
|
_getPanelTheme() {
|
|
return this._parentFormField ? `mat-${this._parentFormField.color}` : '';
|
|
}
|
|
get empty() {
|
|
return !this._selectionModel || this._selectionModel.isEmpty();
|
|
}
|
|
_initializeSelection() {
|
|
Promise.resolve().then(() => {
|
|
if (this.ngControl) {
|
|
this._value = this.ngControl.value;
|
|
}
|
|
this._setSelectionByValue(this._value);
|
|
this.stateChanges.next();
|
|
});
|
|
}
|
|
_setSelectionByValue(value) {
|
|
this.options.forEach(option => option.setInactiveStyles());
|
|
this._selectionModel.clear();
|
|
if (this.multiple && value) {
|
|
if (!Array.isArray(value) && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
throw getMatSelectNonArrayValueError();
|
|
}
|
|
value.forEach(currentValue => this._selectOptionByValue(currentValue));
|
|
this._sortValues();
|
|
} else {
|
|
const correspondingOption = this._selectOptionByValue(value);
|
|
if (correspondingOption) {
|
|
this._keyManager.updateActiveItem(correspondingOption);
|
|
} else if (!this.panelOpen) {
|
|
this._keyManager.updateActiveItem(-1);
|
|
}
|
|
}
|
|
this._changeDetectorRef.markForCheck();
|
|
}
|
|
_selectOptionByValue(value) {
|
|
const correspondingOption = this.options.find(option => {
|
|
if (this._selectionModel.isSelected(option)) {
|
|
return false;
|
|
}
|
|
try {
|
|
return (option.value != null || this.canSelectNullableOptions) && this._compareWith(option.value, value);
|
|
} catch (error) {
|
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
console.warn(error);
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
if (correspondingOption) {
|
|
this._selectionModel.select(correspondingOption);
|
|
}
|
|
return correspondingOption;
|
|
}
|
|
_assignValue(newValue) {
|
|
if (newValue !== this._value || this._multiple && Array.isArray(newValue)) {
|
|
if (this.options) {
|
|
this._setSelectionByValue(newValue);
|
|
}
|
|
this._value = newValue;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
_skipPredicate = option => {
|
|
if (this.panelOpen) {
|
|
return false;
|
|
}
|
|
return option.disabled;
|
|
};
|
|
_getOverlayWidth(preferredOrigin) {
|
|
if (this.panelWidth === 'auto') {
|
|
const refToMeasure = preferredOrigin instanceof CdkOverlayOrigin ? preferredOrigin.elementRef : preferredOrigin || this._elementRef;
|
|
return refToMeasure.nativeElement.getBoundingClientRect().width;
|
|
}
|
|
return this.panelWidth === null ? '' : this.panelWidth;
|
|
}
|
|
_syncParentProperties() {
|
|
if (this.options) {
|
|
for (const option of this.options) {
|
|
option._changeDetectorRef.markForCheck();
|
|
}
|
|
}
|
|
}
|
|
_initKeyManager() {
|
|
this._keyManager = new ActiveDescendantKeyManager(this.options).withTypeAhead(this.typeaheadDebounceInterval).withVerticalOrientation().withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr').withHomeAndEnd().withPageUpDown().withAllowedModifierKeys(['shiftKey']).skipPredicate(this._skipPredicate);
|
|
this._keyManager.tabOut.subscribe(() => {
|
|
if (this.panelOpen) {
|
|
if (!this.multiple && this._keyManager.activeItem) {
|
|
this._keyManager.activeItem._selectViaInteraction();
|
|
}
|
|
this.focus();
|
|
this.close();
|
|
}
|
|
});
|
|
this._keyManager.change.subscribe(() => {
|
|
if (this._panelOpen && this.panel) {
|
|
this._scrollOptionIntoView(this._keyManager.activeItemIndex || 0);
|
|
} else if (!this._panelOpen && !this.multiple && this._keyManager.activeItem) {
|
|
this._keyManager.activeItem._selectViaInteraction();
|
|
}
|
|
});
|
|
}
|
|
_resetOptions() {
|
|
const changedOrDestroyed = merge(this.options.changes, this._destroy);
|
|
this.optionSelectionChanges.pipe(takeUntil(changedOrDestroyed)).subscribe(event => {
|
|
this._onSelect(event.source, event.isUserInput);
|
|
if (event.isUserInput && !this.multiple && this._panelOpen) {
|
|
this.close();
|
|
this.focus();
|
|
}
|
|
});
|
|
merge(...this.options.map(option => option._stateChanges)).pipe(takeUntil(changedOrDestroyed)).subscribe(() => {
|
|
this._changeDetectorRef.detectChanges();
|
|
this.stateChanges.next();
|
|
});
|
|
}
|
|
_onSelect(option, isUserInput) {
|
|
const wasSelected = this._selectionModel.isSelected(option);
|
|
if (!this.canSelectNullableOptions && option.value == null && !this._multiple) {
|
|
option.deselect();
|
|
this._selectionModel.clear();
|
|
if (this.value != null) {
|
|
this._propagateChanges(option.value);
|
|
}
|
|
} else {
|
|
if (wasSelected !== option.selected) {
|
|
option.selected ? this._selectionModel.select(option) : this._selectionModel.deselect(option);
|
|
}
|
|
if (isUserInput) {
|
|
this._keyManager.setActiveItem(option);
|
|
}
|
|
if (this.multiple) {
|
|
this._sortValues();
|
|
if (isUserInput) {
|
|
this.focus();
|
|
}
|
|
}
|
|
}
|
|
if (wasSelected !== this._selectionModel.isSelected(option)) {
|
|
this._propagateChanges();
|
|
}
|
|
this.stateChanges.next();
|
|
}
|
|
_sortValues() {
|
|
if (this.multiple) {
|
|
const options = this.options.toArray();
|
|
this._selectionModel.sort((a, b) => {
|
|
return this.sortComparator ? this.sortComparator(a, b, options) : options.indexOf(a) - options.indexOf(b);
|
|
});
|
|
this.stateChanges.next();
|
|
}
|
|
}
|
|
_propagateChanges(fallbackValue) {
|
|
let valueToEmit;
|
|
if (this.multiple) {
|
|
valueToEmit = this.selected.map(option => option.value);
|
|
} else {
|
|
valueToEmit = this.selected ? this.selected.value : fallbackValue;
|
|
}
|
|
this._value = valueToEmit;
|
|
this.valueChange.emit(valueToEmit);
|
|
this._onChange(valueToEmit);
|
|
this.selectionChange.emit(this._getChangeEvent(valueToEmit));
|
|
this._changeDetectorRef.markForCheck();
|
|
}
|
|
_highlightCorrectOption() {
|
|
if (this._keyManager) {
|
|
if (this.empty) {
|
|
let firstEnabledOptionIndex = -1;
|
|
for (let index = 0; index < this.options.length; index++) {
|
|
const option = this.options.get(index);
|
|
if (!option.disabled) {
|
|
firstEnabledOptionIndex = index;
|
|
break;
|
|
}
|
|
}
|
|
this._keyManager.setActiveItem(firstEnabledOptionIndex);
|
|
} else {
|
|
this._keyManager.setActiveItem(this._selectionModel.selected[0]);
|
|
}
|
|
}
|
|
}
|
|
_canOpen() {
|
|
return !this._panelOpen && !this.disabled && this.options?.length > 0 && !!this._overlayDir;
|
|
}
|
|
focus(options) {
|
|
this._elementRef.nativeElement.focus(options);
|
|
}
|
|
_getPanelAriaLabelledby() {
|
|
if (this.ariaLabel) {
|
|
return null;
|
|
}
|
|
const labelId = this._parentFormField?.getLabelId() || null;
|
|
const labelExpression = labelId ? labelId + ' ' : '';
|
|
return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId;
|
|
}
|
|
_getAriaActiveDescendant() {
|
|
if (this.panelOpen && this._keyManager && this._keyManager.activeItem) {
|
|
return this._keyManager.activeItem.id;
|
|
}
|
|
return null;
|
|
}
|
|
_getTriggerAriaLabelledby() {
|
|
if (this.ariaLabel) {
|
|
return null;
|
|
}
|
|
let value = this._parentFormField?.getLabelId() || '';
|
|
if (this.ariaLabelledby) {
|
|
value += ' ' + this.ariaLabelledby;
|
|
}
|
|
if (!value) {
|
|
value = this._valueId;
|
|
}
|
|
return value;
|
|
}
|
|
get describedByIds() {
|
|
const element = this._elementRef.nativeElement;
|
|
const existingDescribedBy = element.getAttribute('aria-describedby');
|
|
return existingDescribedBy?.split(' ') || [];
|
|
}
|
|
setDescribedByIds(ids) {
|
|
const element = this._elementRef.nativeElement;
|
|
if (ids.length) {
|
|
element.setAttribute('aria-describedby', ids.join(' '));
|
|
} else {
|
|
element.removeAttribute('aria-describedby');
|
|
}
|
|
}
|
|
onContainerClick(event) {
|
|
const target = _getEventTarget(event);
|
|
if (target && (target.tagName === 'MAT-OPTION' || target.classList.contains('cdk-overlay-backdrop') || target.closest('.mat-mdc-select-panel'))) {
|
|
return;
|
|
}
|
|
this.focus();
|
|
this.open();
|
|
}
|
|
get shouldLabelFloat() {
|
|
return this.panelOpen || !this.empty || this.focused && !!this.placeholder;
|
|
}
|
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelect,
|
|
deps: [],
|
|
target: i0.ɵɵFactoryTarget.Component
|
|
});
|
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
minVersion: "17.0.0",
|
|
version: "21.0.3",
|
|
type: MatSelect,
|
|
isStandalone: true,
|
|
selector: "mat-select",
|
|
inputs: {
|
|
userAriaDescribedBy: ["aria-describedby", "userAriaDescribedBy"],
|
|
panelClass: "panelClass",
|
|
disabled: ["disabled", "disabled", booleanAttribute],
|
|
disableRipple: ["disableRipple", "disableRipple", booleanAttribute],
|
|
tabIndex: ["tabIndex", "tabIndex", value => value == null ? 0 : numberAttribute(value)],
|
|
hideSingleSelectionIndicator: ["hideSingleSelectionIndicator", "hideSingleSelectionIndicator", booleanAttribute],
|
|
placeholder: "placeholder",
|
|
required: ["required", "required", booleanAttribute],
|
|
multiple: ["multiple", "multiple", booleanAttribute],
|
|
disableOptionCentering: ["disableOptionCentering", "disableOptionCentering", booleanAttribute],
|
|
compareWith: "compareWith",
|
|
value: "value",
|
|
ariaLabel: ["aria-label", "ariaLabel"],
|
|
ariaLabelledby: ["aria-labelledby", "ariaLabelledby"],
|
|
errorStateMatcher: "errorStateMatcher",
|
|
typeaheadDebounceInterval: ["typeaheadDebounceInterval", "typeaheadDebounceInterval", numberAttribute],
|
|
sortComparator: "sortComparator",
|
|
id: "id",
|
|
panelWidth: "panelWidth",
|
|
canSelectNullableOptions: ["canSelectNullableOptions", "canSelectNullableOptions", booleanAttribute]
|
|
},
|
|
outputs: {
|
|
openedChange: "openedChange",
|
|
_openedStream: "opened",
|
|
_closedStream: "closed",
|
|
selectionChange: "selectionChange",
|
|
valueChange: "valueChange"
|
|
},
|
|
host: {
|
|
attributes: {
|
|
"role": "combobox",
|
|
"aria-haspopup": "listbox"
|
|
},
|
|
listeners: {
|
|
"keydown": "_handleKeydown($event)",
|
|
"focus": "_onFocus()",
|
|
"blur": "_onBlur()"
|
|
},
|
|
properties: {
|
|
"attr.id": "id",
|
|
"attr.tabindex": "disabled ? -1 : tabIndex",
|
|
"attr.aria-controls": "panelOpen ? id + \"-panel\" : null",
|
|
"attr.aria-expanded": "panelOpen",
|
|
"attr.aria-label": "ariaLabel || null",
|
|
"attr.aria-required": "required.toString()",
|
|
"attr.aria-disabled": "disabled.toString()",
|
|
"attr.aria-invalid": "errorState",
|
|
"attr.aria-activedescendant": "_getAriaActiveDescendant()",
|
|
"class.mat-mdc-select-disabled": "disabled",
|
|
"class.mat-mdc-select-invalid": "errorState",
|
|
"class.mat-mdc-select-required": "required",
|
|
"class.mat-mdc-select-empty": "empty",
|
|
"class.mat-mdc-select-multiple": "multiple",
|
|
"class.mat-select-open": "panelOpen"
|
|
},
|
|
classAttribute: "mat-mdc-select"
|
|
},
|
|
providers: [{
|
|
provide: MatFormFieldControl,
|
|
useExisting: MatSelect
|
|
}, {
|
|
provide: MAT_OPTION_PARENT_COMPONENT,
|
|
useExisting: MatSelect
|
|
}],
|
|
queries: [{
|
|
propertyName: "customTrigger",
|
|
first: true,
|
|
predicate: MAT_SELECT_TRIGGER,
|
|
descendants: true
|
|
}, {
|
|
propertyName: "options",
|
|
predicate: MatOption,
|
|
descendants: true
|
|
}, {
|
|
propertyName: "optionGroups",
|
|
predicate: MAT_OPTGROUP,
|
|
descendants: true
|
|
}],
|
|
viewQueries: [{
|
|
propertyName: "trigger",
|
|
first: true,
|
|
predicate: ["trigger"],
|
|
descendants: true
|
|
}, {
|
|
propertyName: "panel",
|
|
first: true,
|
|
predicate: ["panel"],
|
|
descendants: true
|
|
}, {
|
|
propertyName: "_overlayDir",
|
|
first: true,
|
|
predicate: CdkConnectedOverlay,
|
|
descendants: true
|
|
}],
|
|
exportAs: ["matSelect"],
|
|
usesOnChanges: true,
|
|
ngImport: i0,
|
|
template: "<div\n cdk-overlay-origin\n class=\"mat-mdc-select-trigger\"\n (click)=\"open()\"\n #fallbackOverlayOrigin=\"cdkOverlayOrigin\"\n #trigger\n>\n <div class=\"mat-mdc-select-value\" [attr.id]=\"_valueId\">\n @if (empty) {\n <span class=\"mat-mdc-select-placeholder mat-mdc-select-min-line\">{{placeholder}}</span>\n } @else {\n <span class=\"mat-mdc-select-value-text\">\n @if (customTrigger) {\n <ng-content select=\"mat-select-trigger\"></ng-content>\n } @else {\n <span class=\"mat-mdc-select-min-line\">{{triggerValue}}</span>\n }\n </span>\n }\n </div>\n\n <div class=\"mat-mdc-select-arrow-wrapper\">\n <div class=\"mat-mdc-select-arrow\">\n <!-- Use an inline SVG, because it works better than a CSS triangle in high contrast mode. -->\n <svg viewBox=\"0 0 24 24\" width=\"24px\" height=\"24px\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M7 10l5 5 5-5z\" />\n </svg>\n </div>\n </div>\n</div>\n\n<ng-template\n cdk-connected-overlay\n cdkConnectedOverlayLockPosition\n cdkConnectedOverlayHasBackdrop\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n [cdkConnectedOverlayPanelClass]=\"_overlayPanelClass\"\n [cdkConnectedOverlayScrollStrategy]=\"_scrollStrategy\"\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\n [cdkConnectedOverlayPositions]=\"_positions\"\n [cdkConnectedOverlayWidth]=\"_overlayWidth\"\n [cdkConnectedOverlayFlexibleDimensions]=\"true\"\n [cdkConnectedOverlayUsePopover]=\"_popoverLocation\"\n (detach)=\"close()\"\n (backdropClick)=\"close()\"\n (overlayKeydown)=\"_handleOverlayKeydown($event)\"\n>\n <div\n #panel\n role=\"listbox\"\n tabindex=\"-1\"\n class=\"mat-mdc-select-panel mdc-menu-surface mdc-menu-surface--open {{ _getPanelTheme() }}\"\n [class.mat-select-panel-animations-enabled]=\"!_animationsDisabled\"\n [attr.id]=\"id + '-panel'\"\n [attr.aria-multiselectable]=\"multiple\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby()\"\n [ngClass]=\"panelClass\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <ng-content></ng-content>\n </div>\n</ng-template>\n",
|
|
styles: ["@keyframes _mat-select-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}@keyframes _mat-select-exit{from{opacity:1}to{opacity:0}}.mat-mdc-select{display:inline-block;width:100%;outline:none;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;color:var(--mat-select-enabled-trigger-text-color, var(--mat-sys-on-surface));font-family:var(--mat-select-trigger-text-font, var(--mat-sys-body-large-font));line-height:var(--mat-select-trigger-text-line-height, var(--mat-sys-body-large-line-height));font-size:var(--mat-select-trigger-text-size, var(--mat-sys-body-large-size));font-weight:var(--mat-select-trigger-text-weight, var(--mat-sys-body-large-weight));letter-spacing:var(--mat-select-trigger-text-tracking, var(--mat-sys-body-large-tracking))}div.mat-mdc-select-panel{box-shadow:var(--mat-select-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12))}.mat-mdc-select-disabled{color:var(--mat-select-disabled-trigger-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-mdc-select-disabled .mat-mdc-select-placeholder{color:var(--mat-select-disabled-trigger-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-mdc-select-trigger{display:inline-flex;align-items:center;cursor:pointer;position:relative;box-sizing:border-box;width:100%}.mat-mdc-select-disabled .mat-mdc-select-trigger{-webkit-user-select:none;user-select:none;cursor:default}.mat-mdc-select-value{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mat-mdc-select-value-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mat-mdc-select-arrow-wrapper{height:24px;flex-shrink:0;display:inline-flex;align-items:center}.mat-form-field-appearance-fill .mdc-text-field--no-label .mat-mdc-select-arrow-wrapper{transform:none}.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid .mat-mdc-select-arrow,.mat-form-field-invalid:not(.mat-form-field-disabled) .mat-mdc-form-field-infix::after{color:var(--mat-select-invalid-arrow-color, var(--mat-sys-error))}.mat-mdc-select-arrow{width:10px;height:5px;position:relative;color:var(--mat-select-enabled-arrow-color, var(--mat-sys-on-surface-variant))}.mat-mdc-form-field.mat-focused .mat-mdc-select-arrow{color:var(--mat-select-focused-arrow-color, var(--mat-sys-primary))}.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-disabled .mat-mdc-select-arrow{color:var(--mat-select-disabled-arrow-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-select-open .mat-mdc-select-arrow{transform:rotate(180deg)}.mat-form-field-animations-enabled .mat-mdc-select-arrow{transition:transform 80ms linear}.mat-mdc-select-arrow svg{fill:currentColor;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%)}@media(forced-colors: active){.mat-mdc-select-arrow svg{fill:CanvasText}.mat-mdc-select-disabled .mat-mdc-select-arrow svg{fill:GrayText}}div.mat-mdc-select-panel{width:100%;max-height:275px;outline:0;overflow:auto;padding:8px 0;border-radius:4px;box-sizing:border-box;position:relative;background-color:var(--mat-select-panel-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-select-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-select-panel-above) div.mat-mdc-select-panel{border-top-left-radius:0;border-top-right-radius:0;transform-origin:top center}.mat-mdc-select-panel-above div.mat-mdc-select-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:bottom center}.mat-select-panel-animations-enabled{animation:_mat-select-enter 120ms cubic-bezier(0, 0, 0.2, 1)}.mat-select-panel-animations-enabled.mat-select-panel-exit{animation:_mat-select-exit 100ms linear}.mat-mdc-select-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1);color:var(--mat-select-placeholder-text-color, var(--mat-sys-on-surface-variant))}.mat-mdc-form-field:not(.mat-form-field-animations-enabled) .mat-mdc-select-placeholder,._mat-animation-noopable .mat-mdc-select-placeholder{transition:none}.mat-form-field-hide-placeholder .mat-mdc-select-placeholder{color:rgba(0,0,0,0);-webkit-text-fill-color:rgba(0,0,0,0);transition:none;display:block}.mat-mdc-form-field-type-mat-select:not(.mat-form-field-disabled) .mat-mdc-text-field-wrapper{cursor:pointer}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-fill .mat-mdc-floating-label{max-width:calc(100% - 18px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-fill .mdc-floating-label--float-above{max-width:calc(100%/0.75 - 24px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-outline .mdc-notched-outline__notch{max-width:calc(100% - 60px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-outline .mdc-text-field--label-floating .mdc-notched-outline__notch{max-width:calc(100% - 24px)}.mat-mdc-select-min-line:empty::before{content:\" \";white-space:pre;width:1px;display:inline-block;visibility:hidden}.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper{transform:var(--mat-select-arrow-transform, translateY(-8px))}\n"],
|
|
dependencies: [{
|
|
kind: "directive",
|
|
type: CdkOverlayOrigin,
|
|
selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]",
|
|
exportAs: ["cdkOverlayOrigin"]
|
|
}, {
|
|
kind: "directive",
|
|
type: CdkConnectedOverlay,
|
|
selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]",
|
|
inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation", "cdkConnectedOverlayUsePopover", "cdkConnectedOverlayMatchWidth", "cdkConnectedOverlay"],
|
|
outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"],
|
|
exportAs: ["cdkConnectedOverlay"]
|
|
}, {
|
|
kind: "directive",
|
|
type: NgClass,
|
|
selector: "[ngClass]",
|
|
inputs: ["class", "ngClass"]
|
|
}],
|
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
encapsulation: i0.ViewEncapsulation.None
|
|
});
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelect,
|
|
decorators: [{
|
|
type: Component,
|
|
args: [{
|
|
selector: 'mat-select',
|
|
exportAs: 'matSelect',
|
|
encapsulation: ViewEncapsulation.None,
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
host: {
|
|
'role': 'combobox',
|
|
'aria-haspopup': 'listbox',
|
|
'class': 'mat-mdc-select',
|
|
'[attr.id]': 'id',
|
|
'[attr.tabindex]': 'disabled ? -1 : tabIndex',
|
|
'[attr.aria-controls]': 'panelOpen ? id + "-panel" : null',
|
|
'[attr.aria-expanded]': 'panelOpen',
|
|
'[attr.aria-label]': 'ariaLabel || null',
|
|
'[attr.aria-required]': 'required.toString()',
|
|
'[attr.aria-disabled]': 'disabled.toString()',
|
|
'[attr.aria-invalid]': 'errorState',
|
|
'[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
|
|
'[class.mat-mdc-select-disabled]': 'disabled',
|
|
'[class.mat-mdc-select-invalid]': 'errorState',
|
|
'[class.mat-mdc-select-required]': 'required',
|
|
'[class.mat-mdc-select-empty]': 'empty',
|
|
'[class.mat-mdc-select-multiple]': 'multiple',
|
|
'[class.mat-select-open]': 'panelOpen',
|
|
'(keydown)': '_handleKeydown($event)',
|
|
'(focus)': '_onFocus()',
|
|
'(blur)': '_onBlur()'
|
|
},
|
|
providers: [{
|
|
provide: MatFormFieldControl,
|
|
useExisting: MatSelect
|
|
}, {
|
|
provide: MAT_OPTION_PARENT_COMPONENT,
|
|
useExisting: MatSelect
|
|
}],
|
|
imports: [CdkOverlayOrigin, CdkConnectedOverlay, NgClass],
|
|
template: "<div\n cdk-overlay-origin\n class=\"mat-mdc-select-trigger\"\n (click)=\"open()\"\n #fallbackOverlayOrigin=\"cdkOverlayOrigin\"\n #trigger\n>\n <div class=\"mat-mdc-select-value\" [attr.id]=\"_valueId\">\n @if (empty) {\n <span class=\"mat-mdc-select-placeholder mat-mdc-select-min-line\">{{placeholder}}</span>\n } @else {\n <span class=\"mat-mdc-select-value-text\">\n @if (customTrigger) {\n <ng-content select=\"mat-select-trigger\"></ng-content>\n } @else {\n <span class=\"mat-mdc-select-min-line\">{{triggerValue}}</span>\n }\n </span>\n }\n </div>\n\n <div class=\"mat-mdc-select-arrow-wrapper\">\n <div class=\"mat-mdc-select-arrow\">\n <!-- Use an inline SVG, because it works better than a CSS triangle in high contrast mode. -->\n <svg viewBox=\"0 0 24 24\" width=\"24px\" height=\"24px\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M7 10l5 5 5-5z\" />\n </svg>\n </div>\n </div>\n</div>\n\n<ng-template\n cdk-connected-overlay\n cdkConnectedOverlayLockPosition\n cdkConnectedOverlayHasBackdrop\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n [cdkConnectedOverlayPanelClass]=\"_overlayPanelClass\"\n [cdkConnectedOverlayScrollStrategy]=\"_scrollStrategy\"\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\n [cdkConnectedOverlayPositions]=\"_positions\"\n [cdkConnectedOverlayWidth]=\"_overlayWidth\"\n [cdkConnectedOverlayFlexibleDimensions]=\"true\"\n [cdkConnectedOverlayUsePopover]=\"_popoverLocation\"\n (detach)=\"close()\"\n (backdropClick)=\"close()\"\n (overlayKeydown)=\"_handleOverlayKeydown($event)\"\n>\n <div\n #panel\n role=\"listbox\"\n tabindex=\"-1\"\n class=\"mat-mdc-select-panel mdc-menu-surface mdc-menu-surface--open {{ _getPanelTheme() }}\"\n [class.mat-select-panel-animations-enabled]=\"!_animationsDisabled\"\n [attr.id]=\"id + '-panel'\"\n [attr.aria-multiselectable]=\"multiple\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby()\"\n [ngClass]=\"panelClass\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <ng-content></ng-content>\n </div>\n</ng-template>\n",
|
|
styles: ["@keyframes _mat-select-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}@keyframes _mat-select-exit{from{opacity:1}to{opacity:0}}.mat-mdc-select{display:inline-block;width:100%;outline:none;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;color:var(--mat-select-enabled-trigger-text-color, var(--mat-sys-on-surface));font-family:var(--mat-select-trigger-text-font, var(--mat-sys-body-large-font));line-height:var(--mat-select-trigger-text-line-height, var(--mat-sys-body-large-line-height));font-size:var(--mat-select-trigger-text-size, var(--mat-sys-body-large-size));font-weight:var(--mat-select-trigger-text-weight, var(--mat-sys-body-large-weight));letter-spacing:var(--mat-select-trigger-text-tracking, var(--mat-sys-body-large-tracking))}div.mat-mdc-select-panel{box-shadow:var(--mat-select-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12))}.mat-mdc-select-disabled{color:var(--mat-select-disabled-trigger-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-mdc-select-disabled .mat-mdc-select-placeholder{color:var(--mat-select-disabled-trigger-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-mdc-select-trigger{display:inline-flex;align-items:center;cursor:pointer;position:relative;box-sizing:border-box;width:100%}.mat-mdc-select-disabled .mat-mdc-select-trigger{-webkit-user-select:none;user-select:none;cursor:default}.mat-mdc-select-value{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mat-mdc-select-value-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mat-mdc-select-arrow-wrapper{height:24px;flex-shrink:0;display:inline-flex;align-items:center}.mat-form-field-appearance-fill .mdc-text-field--no-label .mat-mdc-select-arrow-wrapper{transform:none}.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid .mat-mdc-select-arrow,.mat-form-field-invalid:not(.mat-form-field-disabled) .mat-mdc-form-field-infix::after{color:var(--mat-select-invalid-arrow-color, var(--mat-sys-error))}.mat-mdc-select-arrow{width:10px;height:5px;position:relative;color:var(--mat-select-enabled-arrow-color, var(--mat-sys-on-surface-variant))}.mat-mdc-form-field.mat-focused .mat-mdc-select-arrow{color:var(--mat-select-focused-arrow-color, var(--mat-sys-primary))}.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-disabled .mat-mdc-select-arrow{color:var(--mat-select-disabled-arrow-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-select-open .mat-mdc-select-arrow{transform:rotate(180deg)}.mat-form-field-animations-enabled .mat-mdc-select-arrow{transition:transform 80ms linear}.mat-mdc-select-arrow svg{fill:currentColor;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%)}@media(forced-colors: active){.mat-mdc-select-arrow svg{fill:CanvasText}.mat-mdc-select-disabled .mat-mdc-select-arrow svg{fill:GrayText}}div.mat-mdc-select-panel{width:100%;max-height:275px;outline:0;overflow:auto;padding:8px 0;border-radius:4px;box-sizing:border-box;position:relative;background-color:var(--mat-select-panel-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-select-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-select-panel-above) div.mat-mdc-select-panel{border-top-left-radius:0;border-top-right-radius:0;transform-origin:top center}.mat-mdc-select-panel-above div.mat-mdc-select-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:bottom center}.mat-select-panel-animations-enabled{animation:_mat-select-enter 120ms cubic-bezier(0, 0, 0.2, 1)}.mat-select-panel-animations-enabled.mat-select-panel-exit{animation:_mat-select-exit 100ms linear}.mat-mdc-select-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1);color:var(--mat-select-placeholder-text-color, var(--mat-sys-on-surface-variant))}.mat-mdc-form-field:not(.mat-form-field-animations-enabled) .mat-mdc-select-placeholder,._mat-animation-noopable .mat-mdc-select-placeholder{transition:none}.mat-form-field-hide-placeholder .mat-mdc-select-placeholder{color:rgba(0,0,0,0);-webkit-text-fill-color:rgba(0,0,0,0);transition:none;display:block}.mat-mdc-form-field-type-mat-select:not(.mat-form-field-disabled) .mat-mdc-text-field-wrapper{cursor:pointer}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-fill .mat-mdc-floating-label{max-width:calc(100% - 18px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-fill .mdc-floating-label--float-above{max-width:calc(100%/0.75 - 24px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-outline .mdc-notched-outline__notch{max-width:calc(100% - 60px)}.mat-mdc-form-field-type-mat-select.mat-form-field-appearance-outline .mdc-text-field--label-floating .mdc-notched-outline__notch{max-width:calc(100% - 24px)}.mat-mdc-select-min-line:empty::before{content:\" \";white-space:pre;width:1px;display:inline-block;visibility:hidden}.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper{transform:var(--mat-select-arrow-transform, translateY(-8px))}\n"]
|
|
}]
|
|
}],
|
|
ctorParameters: () => [],
|
|
propDecorators: {
|
|
options: [{
|
|
type: ContentChildren,
|
|
args: [MatOption, {
|
|
descendants: true
|
|
}]
|
|
}],
|
|
optionGroups: [{
|
|
type: ContentChildren,
|
|
args: [MAT_OPTGROUP, {
|
|
descendants: true
|
|
}]
|
|
}],
|
|
customTrigger: [{
|
|
type: ContentChild,
|
|
args: [MAT_SELECT_TRIGGER]
|
|
}],
|
|
userAriaDescribedBy: [{
|
|
type: Input,
|
|
args: ['aria-describedby']
|
|
}],
|
|
trigger: [{
|
|
type: ViewChild,
|
|
args: ['trigger']
|
|
}],
|
|
panel: [{
|
|
type: ViewChild,
|
|
args: ['panel']
|
|
}],
|
|
_overlayDir: [{
|
|
type: ViewChild,
|
|
args: [CdkConnectedOverlay]
|
|
}],
|
|
panelClass: [{
|
|
type: Input
|
|
}],
|
|
disabled: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
disableRipple: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
tabIndex: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: value => value == null ? 0 : numberAttribute(value)
|
|
}]
|
|
}],
|
|
hideSingleSelectionIndicator: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
placeholder: [{
|
|
type: Input
|
|
}],
|
|
required: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
multiple: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
disableOptionCentering: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
compareWith: [{
|
|
type: Input
|
|
}],
|
|
value: [{
|
|
type: Input
|
|
}],
|
|
ariaLabel: [{
|
|
type: Input,
|
|
args: ['aria-label']
|
|
}],
|
|
ariaLabelledby: [{
|
|
type: Input,
|
|
args: ['aria-labelledby']
|
|
}],
|
|
errorStateMatcher: [{
|
|
type: Input
|
|
}],
|
|
typeaheadDebounceInterval: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: numberAttribute
|
|
}]
|
|
}],
|
|
sortComparator: [{
|
|
type: Input
|
|
}],
|
|
id: [{
|
|
type: Input
|
|
}],
|
|
panelWidth: [{
|
|
type: Input
|
|
}],
|
|
canSelectNullableOptions: [{
|
|
type: Input,
|
|
args: [{
|
|
transform: booleanAttribute
|
|
}]
|
|
}],
|
|
openedChange: [{
|
|
type: Output
|
|
}],
|
|
_openedStream: [{
|
|
type: Output,
|
|
args: ['opened']
|
|
}],
|
|
_closedStream: [{
|
|
type: Output,
|
|
args: ['closed']
|
|
}],
|
|
selectionChange: [{
|
|
type: Output
|
|
}],
|
|
valueChange: [{
|
|
type: Output
|
|
}]
|
|
}
|
|
});
|
|
class MatSelectTrigger {
|
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectTrigger,
|
|
deps: [],
|
|
target: i0.ɵɵFactoryTarget.Directive
|
|
});
|
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
minVersion: "14.0.0",
|
|
version: "21.0.3",
|
|
type: MatSelectTrigger,
|
|
isStandalone: true,
|
|
selector: "mat-select-trigger",
|
|
providers: [{
|
|
provide: MAT_SELECT_TRIGGER,
|
|
useExisting: MatSelectTrigger
|
|
}],
|
|
ngImport: i0
|
|
});
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectTrigger,
|
|
decorators: [{
|
|
type: Directive,
|
|
args: [{
|
|
selector: 'mat-select-trigger',
|
|
providers: [{
|
|
provide: MAT_SELECT_TRIGGER,
|
|
useExisting: MatSelectTrigger
|
|
}]
|
|
}]
|
|
}]
|
|
});
|
|
|
|
class MatSelectModule {
|
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectModule,
|
|
deps: [],
|
|
target: i0.ɵɵFactoryTarget.NgModule
|
|
});
|
|
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
minVersion: "14.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectModule,
|
|
imports: [OverlayModule, MatOptionModule, MatSelect, MatSelectTrigger],
|
|
exports: [BidiModule, CdkScrollableModule, MatFormFieldModule, MatSelect, MatSelectTrigger, MatOptionModule]
|
|
});
|
|
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectModule,
|
|
imports: [OverlayModule, MatOptionModule, BidiModule, CdkScrollableModule, MatFormFieldModule, MatOptionModule]
|
|
});
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({
|
|
minVersion: "12.0.0",
|
|
version: "21.0.3",
|
|
ngImport: i0,
|
|
type: MatSelectModule,
|
|
decorators: [{
|
|
type: NgModule,
|
|
args: [{
|
|
imports: [OverlayModule, MatOptionModule, MatSelect, MatSelectTrigger],
|
|
exports: [BidiModule, CdkScrollableModule, MatFormFieldModule, MatSelect, MatSelectTrigger, MatOptionModule]
|
|
}]
|
|
}]
|
|
});
|
|
|
|
export { MAT_SELECT_CONFIG, MAT_SELECT_SCROLL_STRATEGY, MAT_SELECT_TRIGGER, MatOption, MatSelect, MatSelectChange, MatSelectModule, MatSelectTrigger };
|
|
//# sourceMappingURL=select.mjs.map
|
|
|