module-Cbt8Fcmv.mjs 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. import { Overlay, CdkConnectedOverlay, CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay';
  2. import * as i0 from '@angular/core';
  3. import { InjectionToken, inject, ChangeDetectorRef, ElementRef, Renderer2, ANIMATION_MODULE_TYPE, EventEmitter, HostAttributeToken, booleanAttribute, numberAttribute, Component, ViewEncapsulation, ChangeDetectionStrategy, ContentChildren, ContentChild, Input, ViewChild, Output, Directive, NgModule } from '@angular/core';
  4. import { ViewportRuler, CdkScrollableModule } from '@angular/cdk/scrolling';
  5. import { _IdGenerator, LiveAnnouncer, removeAriaReferencedId, addAriaReferencedId, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
  6. import { Directionality } from '@angular/cdk/bidi';
  7. import { SelectionModel } from '@angular/cdk/collections';
  8. import { hasModifierKey, ENTER, SPACE, A, ESCAPE, DOWN_ARROW, UP_ARROW, LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
  9. import { NgControl, Validators, NgForm, FormGroupDirective } from '@angular/forms';
  10. import { Subject, defer, merge } from 'rxjs';
  11. import { startWith, switchMap, filter, map, takeUntil, take } from 'rxjs/operators';
  12. import { NgClass } from '@angular/common';
  13. import { h as MAT_FORM_FIELD, k as MatFormFieldControl } from './form-field-DqPi4knt.mjs';
  14. import { _ as _countGroupLabelsBeforeOption, b as _getOptionScrollPosition, c as MAT_OPTION_PARENT_COMPONENT, M as MatOption, d as MAT_OPTGROUP } from './option-ChV6uQgD.mjs';
  15. import { E as ErrorStateMatcher } from './error-options-Dm2JJUbF.mjs';
  16. import { _ as _ErrorStateTracker } from './error-state-Dtb1IHM-.mjs';
  17. import { M as MatOptionModule } from './index-DOxJc1m4.mjs';
  18. import { M as MatCommonModule } from './common-module-WayjW0Pb.mjs';
  19. import { M as MatFormFieldModule } from './module-BXZhw7pQ.mjs';
  20. // Note that these have been copied over verbatim from
  21. // `material/select` so that we don't have to expose them publicly.
  22. /**
  23. * Returns an exception to be thrown when attempting to change a select's `multiple` option
  24. * after initialization.
  25. * @docs-private
  26. */
  27. function getMatSelectDynamicMultipleError() {
  28. return Error('Cannot change `multiple` mode of select after initialization.');
  29. }
  30. /**
  31. * Returns an exception to be thrown when attempting to assign a non-array value to a select
  32. * in `multiple` mode. Note that `undefined` and `null` are still valid values to allow for
  33. * resetting the value.
  34. * @docs-private
  35. */
  36. function getMatSelectNonArrayValueError() {
  37. return Error('Value must be an array in multiple-selection mode.');
  38. }
  39. /**
  40. * Returns an exception to be thrown when assigning a non-function value to the comparator
  41. * used to determine if a value corresponds to an option. Note that whether the function
  42. * actually takes two values and returns a boolean is not checked.
  43. */
  44. function getMatSelectNonFunctionValueError() {
  45. return Error('`compareWith` must be a function.');
  46. }
  47. /** Injection token that determines the scroll handling while a select is open. */
  48. const MAT_SELECT_SCROLL_STRATEGY = new InjectionToken('mat-select-scroll-strategy', {
  49. providedIn: 'root',
  50. factory: () => {
  51. const overlay = inject(Overlay);
  52. return () => overlay.scrollStrategies.reposition();
  53. },
  54. });
  55. /**
  56. * @docs-private
  57. * @deprecated No longer used, will be removed.
  58. * @breaking-change 21.0.0
  59. */
  60. function MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
  61. return () => overlay.scrollStrategies.reposition();
  62. }
  63. /** Injection token that can be used to provide the default options the select module. */
  64. const MAT_SELECT_CONFIG = new InjectionToken('MAT_SELECT_CONFIG');
  65. /**
  66. * @docs-private
  67. * @deprecated No longer used, will be removed.
  68. * @breaking-change 21.0.0
  69. */
  70. const MAT_SELECT_SCROLL_STRATEGY_PROVIDER = {
  71. provide: MAT_SELECT_SCROLL_STRATEGY,
  72. deps: [Overlay],
  73. useFactory: MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
  74. };
  75. /**
  76. * Injection token that can be used to reference instances of `MatSelectTrigger`. It serves as
  77. * alternative token to the actual `MatSelectTrigger` class which could cause unnecessary
  78. * retention of the class and its directive metadata.
  79. */
  80. const MAT_SELECT_TRIGGER = new InjectionToken('MatSelectTrigger');
  81. /** Change event object that is emitted when the select value has changed. */
  82. class MatSelectChange {
  83. source;
  84. value;
  85. constructor(
  86. /** Reference to the select that emitted the change event. */
  87. source,
  88. /** Current value of the select that emitted the event. */
  89. value) {
  90. this.source = source;
  91. this.value = value;
  92. }
  93. }
  94. class MatSelect {
  95. _viewportRuler = inject(ViewportRuler);
  96. _changeDetectorRef = inject(ChangeDetectorRef);
  97. _elementRef = inject(ElementRef);
  98. _dir = inject(Directionality, { optional: true });
  99. _idGenerator = inject(_IdGenerator);
  100. _renderer = inject(Renderer2);
  101. _parentFormField = inject(MAT_FORM_FIELD, { optional: true });
  102. ngControl = inject(NgControl, { self: true, optional: true });
  103. _liveAnnouncer = inject(LiveAnnouncer);
  104. _defaultOptions = inject(MAT_SELECT_CONFIG, { optional: true });
  105. _animationsDisabled = inject(ANIMATION_MODULE_TYPE, { optional: true }) === 'NoopAnimations';
  106. _initialized = new Subject();
  107. _cleanupDetach;
  108. /** All of the defined select options. */
  109. options;
  110. // TODO(crisbeto): this is only necessary for the non-MDC select, but it's technically a
  111. // public API so we have to keep it. It should be deprecated and removed eventually.
  112. /** All of the defined groups of options. */
  113. optionGroups;
  114. /** User-supplied override of the trigger element. */
  115. customTrigger;
  116. /**
  117. * This position config ensures that the top "start" corner of the overlay
  118. * is aligned with with the top "start" of the origin by default (overlapping
  119. * the trigger completely). If the panel cannot fit below the trigger, it
  120. * will fall back to a position above the trigger.
  121. */
  122. _positions = [
  123. {
  124. originX: 'start',
  125. originY: 'bottom',
  126. overlayX: 'start',
  127. overlayY: 'top',
  128. },
  129. {
  130. originX: 'end',
  131. originY: 'bottom',
  132. overlayX: 'end',
  133. overlayY: 'top',
  134. },
  135. {
  136. originX: 'start',
  137. originY: 'top',
  138. overlayX: 'start',
  139. overlayY: 'bottom',
  140. panelClass: 'mat-mdc-select-panel-above',
  141. },
  142. {
  143. originX: 'end',
  144. originY: 'top',
  145. overlayX: 'end',
  146. overlayY: 'bottom',
  147. panelClass: 'mat-mdc-select-panel-above',
  148. },
  149. ];
  150. /** Scrolls a particular option into the view. */
  151. _scrollOptionIntoView(index) {
  152. const option = this.options.toArray()[index];
  153. if (option) {
  154. const panel = this.panel.nativeElement;
  155. const labelCount = _countGroupLabelsBeforeOption(index, this.options, this.optionGroups);
  156. const element = option._getHostElement();
  157. if (index === 0 && labelCount === 1) {
  158. // If we've got one group label before the option and we're at the top option,
  159. // scroll the list to the top. This is better UX than scrolling the list to the
  160. // top of the option, because it allows the user to read the top group's label.
  161. panel.scrollTop = 0;
  162. }
  163. else {
  164. panel.scrollTop = _getOptionScrollPosition(element.offsetTop, element.offsetHeight, panel.scrollTop, panel.offsetHeight);
  165. }
  166. }
  167. }
  168. /** Called when the panel has been opened and the overlay has settled on its final position. */
  169. _positioningSettled() {
  170. this._scrollOptionIntoView(this._keyManager.activeItemIndex || 0);
  171. }
  172. /** Creates a change event object that should be emitted by the select. */
  173. _getChangeEvent(value) {
  174. return new MatSelectChange(this, value);
  175. }
  176. /** Factory function used to create a scroll strategy for this select. */
  177. _scrollStrategyFactory = inject(MAT_SELECT_SCROLL_STRATEGY);
  178. /** Whether or not the overlay panel is open. */
  179. _panelOpen = false;
  180. /** Comparison function to specify which option is displayed. Defaults to object equality. */
  181. _compareWith = (o1, o2) => o1 === o2;
  182. /** Unique id for this input. */
  183. _uid = this._idGenerator.getId('mat-select-');
  184. /** Current `aria-labelledby` value for the select trigger. */
  185. _triggerAriaLabelledBy = null;
  186. /**
  187. * Keeps track of the previous form control assigned to the select.
  188. * Used to detect if it has changed.
  189. */
  190. _previousControl;
  191. /** Emits whenever the component is destroyed. */
  192. _destroy = new Subject();
  193. /** Tracks the error state of the select. */
  194. _errorStateTracker;
  195. /**
  196. * Emits whenever the component state changes and should cause the parent
  197. * form-field to update. Implemented as part of `MatFormFieldControl`.
  198. * @docs-private
  199. */
  200. stateChanges = new Subject();
  201. /**
  202. * Disable the automatic labeling to avoid issues like #27241.
  203. * @docs-private
  204. */
  205. disableAutomaticLabeling = true;
  206. /**
  207. * Implemented as part of MatFormFieldControl.
  208. * @docs-private
  209. */
  210. userAriaDescribedBy;
  211. /** Deals with the selection logic. */
  212. _selectionModel;
  213. /** Manages keyboard events for options in the panel. */
  214. _keyManager;
  215. /** Ideal origin for the overlay panel. */
  216. _preferredOverlayOrigin;
  217. /** Width of the overlay panel. */
  218. _overlayWidth;
  219. /** `View -> model callback called when value changes` */
  220. _onChange = () => { };
  221. /** `View -> model callback called when select has been touched` */
  222. _onTouched = () => { };
  223. /** ID for the DOM node containing the select's value. */
  224. _valueId = this._idGenerator.getId('mat-select-value-');
  225. /** Strategy that will be used to handle scrolling while the select panel is open. */
  226. _scrollStrategy;
  227. _overlayPanelClass = this._defaultOptions?.overlayPanelClass || '';
  228. /** Whether the select is focused. */
  229. get focused() {
  230. return this._focused || this._panelOpen;
  231. }
  232. _focused = false;
  233. /** A name for this control that can be used by `mat-form-field`. */
  234. controlType = 'mat-select';
  235. /** Trigger that opens the select. */
  236. trigger;
  237. /** Panel containing the select options. */
  238. panel;
  239. /** Overlay pane containing the options. */
  240. _overlayDir;
  241. /** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */
  242. panelClass;
  243. /** Whether the select is disabled. */
  244. disabled = false;
  245. /** Whether ripples in the select are disabled. */
  246. disableRipple = false;
  247. /** Tab index of the select. */
  248. tabIndex = 0;
  249. /** Whether checkmark indicator for single-selection options is hidden. */
  250. get hideSingleSelectionIndicator() {
  251. return this._hideSingleSelectionIndicator;
  252. }
  253. set hideSingleSelectionIndicator(value) {
  254. this._hideSingleSelectionIndicator = value;
  255. this._syncParentProperties();
  256. }
  257. _hideSingleSelectionIndicator = this._defaultOptions?.hideSingleSelectionIndicator ?? false;
  258. /** Placeholder to be shown if no value has been selected. */
  259. get placeholder() {
  260. return this._placeholder;
  261. }
  262. set placeholder(value) {
  263. this._placeholder = value;
  264. this.stateChanges.next();
  265. }
  266. _placeholder;
  267. /** Whether the component is required. */
  268. get required() {
  269. return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false;
  270. }
  271. set required(value) {
  272. this._required = value;
  273. this.stateChanges.next();
  274. }
  275. _required;
  276. /** Whether the user should be allowed to select multiple options. */
  277. get multiple() {
  278. return this._multiple;
  279. }
  280. set multiple(value) {
  281. if (this._selectionModel && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  282. throw getMatSelectDynamicMultipleError();
  283. }
  284. this._multiple = value;
  285. }
  286. _multiple = false;
  287. /** Whether to center the active option over the trigger. */
  288. disableOptionCentering = this._defaultOptions?.disableOptionCentering ?? false;
  289. /**
  290. * Function to compare the option values with the selected values. The first argument
  291. * is a value from an option. The second is a value from the selection. A boolean
  292. * should be returned.
  293. */
  294. get compareWith() {
  295. return this._compareWith;
  296. }
  297. set compareWith(fn) {
  298. if (typeof fn !== 'function' && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  299. throw getMatSelectNonFunctionValueError();
  300. }
  301. this._compareWith = fn;
  302. if (this._selectionModel) {
  303. // A different comparator means the selection could change.
  304. this._initializeSelection();
  305. }
  306. }
  307. /** Value of the select control. */
  308. get value() {
  309. return this._value;
  310. }
  311. set value(newValue) {
  312. const hasAssigned = this._assignValue(newValue);
  313. if (hasAssigned) {
  314. this._onChange(newValue);
  315. }
  316. }
  317. _value;
  318. /** Aria label of the select. */
  319. ariaLabel = '';
  320. /** Input that can be used to specify the `aria-labelledby` attribute. */
  321. ariaLabelledby;
  322. /** Object used to control when error messages are shown. */
  323. get errorStateMatcher() {
  324. return this._errorStateTracker.matcher;
  325. }
  326. set errorStateMatcher(value) {
  327. this._errorStateTracker.matcher = value;
  328. }
  329. /** Time to wait in milliseconds after the last keystroke before moving focus to an item. */
  330. typeaheadDebounceInterval;
  331. /**
  332. * Function used to sort the values in a select in multiple mode.
  333. * Follows the same logic as `Array.prototype.sort`.
  334. */
  335. sortComparator;
  336. /** Unique id of the element. */
  337. get id() {
  338. return this._id;
  339. }
  340. set id(value) {
  341. this._id = value || this._uid;
  342. this.stateChanges.next();
  343. }
  344. _id;
  345. /** Whether the select is in an error state. */
  346. get errorState() {
  347. return this._errorStateTracker.errorState;
  348. }
  349. set errorState(value) {
  350. this._errorStateTracker.errorState = value;
  351. }
  352. /**
  353. * Width of the panel. If set to `auto`, the panel will match the trigger width.
  354. * If set to null or an empty string, the panel will grow to match the longest option's text.
  355. */
  356. panelWidth = this._defaultOptions && typeof this._defaultOptions.panelWidth !== 'undefined'
  357. ? this._defaultOptions.panelWidth
  358. : 'auto';
  359. /**
  360. * By default selecting an option with a `null` or `undefined` value will reset the select's
  361. * value. Enable this option if the reset behavior doesn't match your requirements and instead
  362. * the nullable options should become selected. The value of this input can be controlled app-wide
  363. * using the `MAT_SELECT_CONFIG` injection token.
  364. */
  365. canSelectNullableOptions = this._defaultOptions?.canSelectNullableOptions ?? false;
  366. /** Combined stream of all of the child options' change events. */
  367. optionSelectionChanges = defer(() => {
  368. const options = this.options;
  369. if (options) {
  370. return options.changes.pipe(startWith(options), switchMap(() => merge(...options.map(option => option.onSelectionChange))));
  371. }
  372. return this._initialized.pipe(switchMap(() => this.optionSelectionChanges));
  373. });
  374. /** Event emitted when the select panel has been toggled. */
  375. openedChange = new EventEmitter();
  376. /** Event emitted when the select has been opened. */
  377. _openedStream = this.openedChange.pipe(filter(o => o), map(() => { }));
  378. /** Event emitted when the select has been closed. */
  379. _closedStream = this.openedChange.pipe(filter(o => !o), map(() => { }));
  380. /** Event emitted when the selected value has been changed by the user. */
  381. selectionChange = new EventEmitter();
  382. /**
  383. * Event that emits whenever the raw value of the select changes. This is here primarily
  384. * to facilitate the two-way binding for the `value` input.
  385. * @docs-private
  386. */
  387. valueChange = new EventEmitter();
  388. constructor() {
  389. const defaultErrorStateMatcher = inject(ErrorStateMatcher);
  390. const parentForm = inject(NgForm, { optional: true });
  391. const parentFormGroup = inject(FormGroupDirective, { optional: true });
  392. const tabIndex = inject(new HostAttributeToken('tabindex'), { optional: true });
  393. if (this.ngControl) {
  394. // Note: we provide the value accessor through here, instead of
  395. // the `providers` to avoid running into a circular import.
  396. this.ngControl.valueAccessor = this;
  397. }
  398. // Note that we only want to set this when the defaults pass it in, otherwise it should
  399. // stay as `undefined` so that it falls back to the default in the key manager.
  400. if (this._defaultOptions?.typeaheadDebounceInterval != null) {
  401. this.typeaheadDebounceInterval = this._defaultOptions.typeaheadDebounceInterval;
  402. }
  403. this._errorStateTracker = new _ErrorStateTracker(defaultErrorStateMatcher, this.ngControl, parentFormGroup, parentForm, this.stateChanges);
  404. this._scrollStrategy = this._scrollStrategyFactory();
  405. this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0;
  406. // Force setter to be called in case id was not specified.
  407. this.id = this.id;
  408. }
  409. ngOnInit() {
  410. this._selectionModel = new SelectionModel(this.multiple);
  411. this.stateChanges.next();
  412. this._viewportRuler
  413. .change()
  414. .pipe(takeUntil(this._destroy))
  415. .subscribe(() => {
  416. if (this.panelOpen) {
  417. this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
  418. this._changeDetectorRef.detectChanges();
  419. }
  420. });
  421. }
  422. ngAfterContentInit() {
  423. this._initialized.next();
  424. this._initialized.complete();
  425. this._initKeyManager();
  426. this._selectionModel.changed.pipe(takeUntil(this._destroy)).subscribe(event => {
  427. event.added.forEach(option => option.select());
  428. event.removed.forEach(option => option.deselect());
  429. });
  430. this.options.changes.pipe(startWith(null), takeUntil(this._destroy)).subscribe(() => {
  431. this._resetOptions();
  432. this._initializeSelection();
  433. });
  434. }
  435. ngDoCheck() {
  436. const newAriaLabelledby = this._getTriggerAriaLabelledby();
  437. const ngControl = this.ngControl;
  438. // We have to manage setting the `aria-labelledby` ourselves, because part of its value
  439. // is computed as a result of a content query which can cause this binding to trigger a
  440. // "changed after checked" error.
  441. if (newAriaLabelledby !== this._triggerAriaLabelledBy) {
  442. const element = this._elementRef.nativeElement;
  443. this._triggerAriaLabelledBy = newAriaLabelledby;
  444. if (newAriaLabelledby) {
  445. element.setAttribute('aria-labelledby', newAriaLabelledby);
  446. }
  447. else {
  448. element.removeAttribute('aria-labelledby');
  449. }
  450. }
  451. if (ngControl) {
  452. // The disabled state might go out of sync if the form group is swapped out. See #17860.
  453. if (this._previousControl !== ngControl.control) {
  454. if (this._previousControl !== undefined &&
  455. ngControl.disabled !== null &&
  456. ngControl.disabled !== this.disabled) {
  457. this.disabled = ngControl.disabled;
  458. }
  459. this._previousControl = ngControl.control;
  460. }
  461. this.updateErrorState();
  462. }
  463. }
  464. ngOnChanges(changes) {
  465. // Updating the disabled state is handled by the input, but we need to additionally let
  466. // the parent form field know to run change detection when the disabled state changes.
  467. if (changes['disabled'] || changes['userAriaDescribedBy']) {
  468. this.stateChanges.next();
  469. }
  470. if (changes['typeaheadDebounceInterval'] && this._keyManager) {
  471. this._keyManager.withTypeAhead(this.typeaheadDebounceInterval);
  472. }
  473. }
  474. ngOnDestroy() {
  475. this._cleanupDetach?.();
  476. this._keyManager?.destroy();
  477. this._destroy.next();
  478. this._destroy.complete();
  479. this.stateChanges.complete();
  480. this._clearFromModal();
  481. }
  482. /** Toggles the overlay panel open or closed. */
  483. toggle() {
  484. this.panelOpen ? this.close() : this.open();
  485. }
  486. /** Opens the overlay panel. */
  487. open() {
  488. if (!this._canOpen()) {
  489. return;
  490. }
  491. // It's important that we read this as late as possible, because doing so earlier will
  492. // return a different element since it's based on queries in the form field which may
  493. // not have run yet. Also this needs to be assigned before we measure the overlay width.
  494. if (this._parentFormField) {
  495. this._preferredOverlayOrigin = this._parentFormField.getConnectedOverlayOrigin();
  496. }
  497. this._cleanupDetach?.();
  498. this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
  499. this._applyModalPanelOwnership();
  500. this._panelOpen = true;
  501. this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
  502. this._changeDetectorRef.detectChanges();
  503. this._positioningSettled();
  504. });
  505. this._overlayDir.attachOverlay();
  506. this._keyManager.withHorizontalOrientation(null);
  507. this._highlightCorrectOption();
  508. this._changeDetectorRef.markForCheck();
  509. // Required for the MDC form field to pick up when the overlay has been opened.
  510. this.stateChanges.next();
  511. // Simulate the animation event before we moved away from `@angular/animations`.
  512. Promise.resolve().then(() => this.openedChange.emit(true));
  513. }
  514. /**
  515. * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is
  516. * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options
  517. * panel. Track the modal we have changed so we can undo the changes on destroy.
  518. */
  519. _trackedModal = null;
  520. /**
  521. * If the autocomplete trigger is inside of an `aria-modal` element, connect
  522. * that modal to the options panel with `aria-owns`.
  523. *
  524. * For some browser + screen reader combinations, when navigation is inside
  525. * of an `aria-modal` element, the screen reader treats everything outside
  526. * of that modal as hidden or invisible.
  527. *
  528. * This causes a problem when the combobox trigger is _inside_ of a modal, because the
  529. * options panel is rendered _outside_ of that modal, preventing screen reader navigation
  530. * from reaching the panel.
  531. *
  532. * We can work around this issue by applying `aria-owns` to the modal with the `id` of
  533. * the options panel. This effectively communicates to assistive technology that the
  534. * options panel is part of the same interaction as the modal.
  535. *
  536. * At time of this writing, this issue is present in VoiceOver.
  537. * See https://github.com/angular/components/issues/20694
  538. */
  539. _applyModalPanelOwnership() {
  540. // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with
  541. // the `LiveAnnouncer` and any other usages.
  542. //
  543. // Note that the selector here is limited to CDK overlays at the moment in order to reduce the
  544. // section of the DOM we need to look through. This should cover all the cases we support, but
  545. // the selector can be expanded if it turns out to be too narrow.
  546. const modal = this._elementRef.nativeElement.closest('body > .cdk-overlay-container [aria-modal="true"]');
  547. if (!modal) {
  548. // Most commonly, the autocomplete trigger is not inside a modal.
  549. return;
  550. }
  551. const panelId = `${this.id}-panel`;
  552. if (this._trackedModal) {
  553. removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
  554. }
  555. addAriaReferencedId(modal, 'aria-owns', panelId);
  556. this._trackedModal = modal;
  557. }
  558. /** Clears the reference to the listbox overlay element from the modal it was added to. */
  559. _clearFromModal() {
  560. if (!this._trackedModal) {
  561. // Most commonly, the autocomplete trigger is not used inside a modal.
  562. return;
  563. }
  564. const panelId = `${this.id}-panel`;
  565. removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
  566. this._trackedModal = null;
  567. }
  568. /** Closes the overlay panel and focuses the host element. */
  569. close() {
  570. if (this._panelOpen) {
  571. this._panelOpen = false;
  572. this._exitAndDetach();
  573. this._keyManager.withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr');
  574. this._changeDetectorRef.markForCheck();
  575. this._onTouched();
  576. // Required for the MDC form field to pick up when the overlay has been closed.
  577. this.stateChanges.next();
  578. // Simulate the animation event before we moved away from `@angular/animations`.
  579. Promise.resolve().then(() => this.openedChange.emit(false));
  580. }
  581. }
  582. /** Triggers the exit animation and detaches the overlay at the end. */
  583. _exitAndDetach() {
  584. if (this._animationsDisabled || !this.panel) {
  585. this._detachOverlay();
  586. return;
  587. }
  588. this._cleanupDetach?.();
  589. this._cleanupDetach = () => {
  590. cleanupEvent();
  591. clearTimeout(exitFallbackTimer);
  592. this._cleanupDetach = undefined;
  593. };
  594. const panel = this.panel.nativeElement;
  595. const cleanupEvent = this._renderer.listen(panel, 'animationend', (event) => {
  596. if (event.animationName === '_mat-select-exit') {
  597. this._cleanupDetach?.();
  598. this._detachOverlay();
  599. }
  600. });
  601. // Since closing the overlay depends on the animation, we have a fallback in case the panel
  602. // doesn't animate. This can happen in some internal tests that do `* {animation: none}`.
  603. const exitFallbackTimer = setTimeout(() => {
  604. this._cleanupDetach?.();
  605. this._detachOverlay();
  606. }, 200);
  607. panel.classList.add('mat-select-panel-exit');
  608. }
  609. /** Detaches the current overlay directive. */
  610. _detachOverlay() {
  611. this._overlayDir.detachOverlay();
  612. // Some of the overlay detachment logic depends on change detection.
  613. // Mark for check to ensure that things get picked up in a timely manner.
  614. this._changeDetectorRef.markForCheck();
  615. }
  616. /**
  617. * Sets the select's value. Part of the ControlValueAccessor interface
  618. * required to integrate with Angular's core forms API.
  619. *
  620. * @param value New value to be written to the model.
  621. */
  622. writeValue(value) {
  623. this._assignValue(value);
  624. }
  625. /**
  626. * Saves a callback function to be invoked when the select's value
  627. * changes from user input. Part of the ControlValueAccessor interface
  628. * required to integrate with Angular's core forms API.
  629. *
  630. * @param fn Callback to be triggered when the value changes.
  631. */
  632. registerOnChange(fn) {
  633. this._onChange = fn;
  634. }
  635. /**
  636. * Saves a callback function to be invoked when the select is blurred
  637. * by the user. Part of the ControlValueAccessor interface required
  638. * to integrate with Angular's core forms API.
  639. *
  640. * @param fn Callback to be triggered when the component has been touched.
  641. */
  642. registerOnTouched(fn) {
  643. this._onTouched = fn;
  644. }
  645. /**
  646. * Disables the select. Part of the ControlValueAccessor interface required
  647. * to integrate with Angular's core forms API.
  648. *
  649. * @param isDisabled Sets whether the component is disabled.
  650. */
  651. setDisabledState(isDisabled) {
  652. this.disabled = isDisabled;
  653. this._changeDetectorRef.markForCheck();
  654. this.stateChanges.next();
  655. }
  656. /** Whether or not the overlay panel is open. */
  657. get panelOpen() {
  658. return this._panelOpen;
  659. }
  660. /** The currently selected option. */
  661. get selected() {
  662. return this.multiple ? this._selectionModel?.selected || [] : this._selectionModel?.selected[0];
  663. }
  664. /** The value displayed in the trigger. */
  665. get triggerValue() {
  666. if (this.empty) {
  667. return '';
  668. }
  669. if (this._multiple) {
  670. const selectedOptions = this._selectionModel.selected.map(option => option.viewValue);
  671. if (this._isRtl()) {
  672. selectedOptions.reverse();
  673. }
  674. // TODO(crisbeto): delimiter should be configurable for proper localization.
  675. return selectedOptions.join(', ');
  676. }
  677. return this._selectionModel.selected[0].viewValue;
  678. }
  679. /** Refreshes the error state of the select. */
  680. updateErrorState() {
  681. this._errorStateTracker.updateErrorState();
  682. }
  683. /** Whether the element is in RTL mode. */
  684. _isRtl() {
  685. return this._dir ? this._dir.value === 'rtl' : false;
  686. }
  687. /** Handles all keydown events on the select. */
  688. _handleKeydown(event) {
  689. if (!this.disabled) {
  690. this.panelOpen ? this._handleOpenKeydown(event) : this._handleClosedKeydown(event);
  691. }
  692. }
  693. /** Handles keyboard events while the select is closed. */
  694. _handleClosedKeydown(event) {
  695. const keyCode = event.keyCode;
  696. const isArrowKey = keyCode === DOWN_ARROW ||
  697. keyCode === UP_ARROW ||
  698. keyCode === LEFT_ARROW ||
  699. keyCode === RIGHT_ARROW;
  700. const isOpenKey = keyCode === ENTER || keyCode === SPACE;
  701. const manager = this._keyManager;
  702. // Open the select on ALT + arrow key to match the native <select>
  703. if ((!manager.isTyping() && isOpenKey && !hasModifierKey(event)) ||
  704. ((this.multiple || event.altKey) && isArrowKey)) {
  705. event.preventDefault(); // prevents the page from scrolling down when pressing space
  706. this.open();
  707. }
  708. else if (!this.multiple) {
  709. const previouslySelectedOption = this.selected;
  710. manager.onKeydown(event);
  711. const selectedOption = this.selected;
  712. // Since the value has changed, we need to announce it ourselves.
  713. if (selectedOption && previouslySelectedOption !== selectedOption) {
  714. // We set a duration on the live announcement, because we want the live element to be
  715. // cleared after a while so that users can't navigate to it using the arrow keys.
  716. this._liveAnnouncer.announce(selectedOption.viewValue, 10000);
  717. }
  718. }
  719. }
  720. /** Handles keyboard events when the selected is open. */
  721. _handleOpenKeydown(event) {
  722. const manager = this._keyManager;
  723. const keyCode = event.keyCode;
  724. const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW;
  725. const isTyping = manager.isTyping();
  726. if (isArrowKey && event.altKey) {
  727. // Close the select on ALT + arrow key to match the native <select>
  728. event.preventDefault();
  729. this.close();
  730. // Don't do anything in this case if the user is typing,
  731. // because the typing sequence can include the space key.
  732. }
  733. else if (!isTyping &&
  734. (keyCode === ENTER || keyCode === SPACE) &&
  735. manager.activeItem &&
  736. !hasModifierKey(event)) {
  737. event.preventDefault();
  738. manager.activeItem._selectViaInteraction();
  739. }
  740. else if (!isTyping && this._multiple && keyCode === A && event.ctrlKey) {
  741. event.preventDefault();
  742. const hasDeselectedOptions = this.options.some(opt => !opt.disabled && !opt.selected);
  743. this.options.forEach(option => {
  744. if (!option.disabled) {
  745. hasDeselectedOptions ? option.select() : option.deselect();
  746. }
  747. });
  748. }
  749. else {
  750. const previouslyFocusedIndex = manager.activeItemIndex;
  751. manager.onKeydown(event);
  752. if (this._multiple &&
  753. isArrowKey &&
  754. event.shiftKey &&
  755. manager.activeItem &&
  756. manager.activeItemIndex !== previouslyFocusedIndex) {
  757. manager.activeItem._selectViaInteraction();
  758. }
  759. }
  760. }
  761. /** Handles keyboard events coming from the overlay. */
  762. _handleOverlayKeydown(event) {
  763. // TODO(crisbeto): prior to #30363 this was being handled inside the overlay directive, but we
  764. // need control over the animation timing so we do it manually. We should remove the `keydown`
  765. // listener from `.mat-mdc-select-panel` and handle all the events here. That may cause
  766. // further test breakages so it's left for a follow-up.
  767. if (event.keyCode === ESCAPE && !hasModifierKey(event)) {
  768. event.preventDefault();
  769. this.close();
  770. }
  771. }
  772. _onFocus() {
  773. if (!this.disabled) {
  774. this._focused = true;
  775. this.stateChanges.next();
  776. }
  777. }
  778. /**
  779. * Calls the touched callback only if the panel is closed. Otherwise, the trigger will
  780. * "blur" to the panel when it opens, causing a false positive.
  781. */
  782. _onBlur() {
  783. this._focused = false;
  784. this._keyManager?.cancelTypeahead();
  785. if (!this.disabled && !this.panelOpen) {
  786. this._onTouched();
  787. this._changeDetectorRef.markForCheck();
  788. this.stateChanges.next();
  789. }
  790. }
  791. /** Returns the theme to be used on the panel. */
  792. _getPanelTheme() {
  793. return this._parentFormField ? `mat-${this._parentFormField.color}` : '';
  794. }
  795. /** Whether the select has a value. */
  796. get empty() {
  797. return !this._selectionModel || this._selectionModel.isEmpty();
  798. }
  799. _initializeSelection() {
  800. // Defer setting the value in order to avoid the "Expression
  801. // has changed after it was checked" errors from Angular.
  802. Promise.resolve().then(() => {
  803. if (this.ngControl) {
  804. this._value = this.ngControl.value;
  805. }
  806. this._setSelectionByValue(this._value);
  807. this.stateChanges.next();
  808. });
  809. }
  810. /**
  811. * Sets the selected option based on a value. If no option can be
  812. * found with the designated value, the select trigger is cleared.
  813. */
  814. _setSelectionByValue(value) {
  815. this.options.forEach(option => option.setInactiveStyles());
  816. this._selectionModel.clear();
  817. if (this.multiple && value) {
  818. if (!Array.isArray(value) && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  819. throw getMatSelectNonArrayValueError();
  820. }
  821. value.forEach((currentValue) => this._selectOptionByValue(currentValue));
  822. this._sortValues();
  823. }
  824. else {
  825. const correspondingOption = this._selectOptionByValue(value);
  826. // Shift focus to the active item. Note that we shouldn't do this in multiple
  827. // mode, because we don't know what option the user interacted with last.
  828. if (correspondingOption) {
  829. this._keyManager.updateActiveItem(correspondingOption);
  830. }
  831. else if (!this.panelOpen) {
  832. // Otherwise reset the highlighted option. Note that we only want to do this while
  833. // closed, because doing it while open can shift the user's focus unnecessarily.
  834. this._keyManager.updateActiveItem(-1);
  835. }
  836. }
  837. this._changeDetectorRef.markForCheck();
  838. }
  839. /**
  840. * Finds and selects and option based on its value.
  841. * @returns Option that has the corresponding value.
  842. */
  843. _selectOptionByValue(value) {
  844. const correspondingOption = this.options.find((option) => {
  845. // Skip options that are already in the model. This allows us to handle cases
  846. // where the same primitive value is selected multiple times.
  847. if (this._selectionModel.isSelected(option)) {
  848. return false;
  849. }
  850. try {
  851. // Treat null as a special reset value.
  852. return ((option.value != null || this.canSelectNullableOptions) &&
  853. this._compareWith(option.value, value));
  854. }
  855. catch (error) {
  856. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  857. // Notify developers of errors in their comparator.
  858. console.warn(error);
  859. }
  860. return false;
  861. }
  862. });
  863. if (correspondingOption) {
  864. this._selectionModel.select(correspondingOption);
  865. }
  866. return correspondingOption;
  867. }
  868. /** Assigns a specific value to the select. Returns whether the value has changed. */
  869. _assignValue(newValue) {
  870. // Always re-assign an array, because it might have been mutated.
  871. if (newValue !== this._value || (this._multiple && Array.isArray(newValue))) {
  872. if (this.options) {
  873. this._setSelectionByValue(newValue);
  874. }
  875. this._value = newValue;
  876. return true;
  877. }
  878. return false;
  879. }
  880. // `skipPredicate` determines if key manager should avoid putting a given option in the tab
  881. // order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA
  882. // recommendation.
  883. //
  884. // Normally WAI ARIA's instructions are to exclude disabled items from the tab order, but it
  885. // makes a few exceptions for compound widgets.
  886. //
  887. // From [Developing a Keyboard Interface](
  888. // https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/):
  889. // "For the following composite widget elements, keep them focusable when disabled: Options in a
  890. // Listbox..."
  891. //
  892. // The user can focus disabled options using the keyboard, but the user cannot click disabled
  893. // options.
  894. _skipPredicate = (option) => {
  895. if (this.panelOpen) {
  896. // Support keyboard focusing disabled options in an ARIA listbox.
  897. return false;
  898. }
  899. // When the panel is closed, skip over disabled options. Support options via the UP/DOWN arrow
  900. // keys on a closed select. ARIA listbox interaction pattern is less relevant when the panel is
  901. // closed.
  902. return option.disabled;
  903. };
  904. /** Gets how wide the overlay panel should be. */
  905. _getOverlayWidth(preferredOrigin) {
  906. if (this.panelWidth === 'auto') {
  907. const refToMeasure = preferredOrigin instanceof CdkOverlayOrigin
  908. ? preferredOrigin.elementRef
  909. : preferredOrigin || this._elementRef;
  910. return refToMeasure.nativeElement.getBoundingClientRect().width;
  911. }
  912. return this.panelWidth === null ? '' : this.panelWidth;
  913. }
  914. /** Syncs the parent state with the individual options. */
  915. _syncParentProperties() {
  916. if (this.options) {
  917. for (const option of this.options) {
  918. option._changeDetectorRef.markForCheck();
  919. }
  920. }
  921. }
  922. /** Sets up a key manager to listen to keyboard events on the overlay panel. */
  923. _initKeyManager() {
  924. this._keyManager = new ActiveDescendantKeyManager(this.options)
  925. .withTypeAhead(this.typeaheadDebounceInterval)
  926. .withVerticalOrientation()
  927. .withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr')
  928. .withHomeAndEnd()
  929. .withPageUpDown()
  930. .withAllowedModifierKeys(['shiftKey'])
  931. .skipPredicate(this._skipPredicate);
  932. this._keyManager.tabOut.subscribe(() => {
  933. if (this.panelOpen) {
  934. // Select the active item when tabbing away. This is consistent with how the native
  935. // select behaves. Note that we only want to do this in single selection mode.
  936. if (!this.multiple && this._keyManager.activeItem) {
  937. this._keyManager.activeItem._selectViaInteraction();
  938. }
  939. // Restore focus to the trigger before closing. Ensures that the focus
  940. // position won't be lost if the user got focus into the overlay.
  941. this.focus();
  942. this.close();
  943. }
  944. });
  945. this._keyManager.change.subscribe(() => {
  946. if (this._panelOpen && this.panel) {
  947. this._scrollOptionIntoView(this._keyManager.activeItemIndex || 0);
  948. }
  949. else if (!this._panelOpen && !this.multiple && this._keyManager.activeItem) {
  950. this._keyManager.activeItem._selectViaInteraction();
  951. }
  952. });
  953. }
  954. /** Drops current option subscriptions and IDs and resets from scratch. */
  955. _resetOptions() {
  956. const changedOrDestroyed = merge(this.options.changes, this._destroy);
  957. this.optionSelectionChanges.pipe(takeUntil(changedOrDestroyed)).subscribe(event => {
  958. this._onSelect(event.source, event.isUserInput);
  959. if (event.isUserInput && !this.multiple && this._panelOpen) {
  960. this.close();
  961. this.focus();
  962. }
  963. });
  964. // Listen to changes in the internal state of the options and react accordingly.
  965. // Handles cases like the labels of the selected options changing.
  966. merge(...this.options.map(option => option._stateChanges))
  967. .pipe(takeUntil(changedOrDestroyed))
  968. .subscribe(() => {
  969. // `_stateChanges` can fire as a result of a change in the label's DOM value which may
  970. // be the result of an expression changing. We have to use `detectChanges` in order
  971. // to avoid "changed after checked" errors (see #14793).
  972. this._changeDetectorRef.detectChanges();
  973. this.stateChanges.next();
  974. });
  975. }
  976. /** Invoked when an option is clicked. */
  977. _onSelect(option, isUserInput) {
  978. const wasSelected = this._selectionModel.isSelected(option);
  979. if (!this.canSelectNullableOptions && option.value == null && !this._multiple) {
  980. option.deselect();
  981. this._selectionModel.clear();
  982. if (this.value != null) {
  983. this._propagateChanges(option.value);
  984. }
  985. }
  986. else {
  987. if (wasSelected !== option.selected) {
  988. option.selected
  989. ? this._selectionModel.select(option)
  990. : this._selectionModel.deselect(option);
  991. }
  992. if (isUserInput) {
  993. this._keyManager.setActiveItem(option);
  994. }
  995. if (this.multiple) {
  996. this._sortValues();
  997. if (isUserInput) {
  998. // In case the user selected the option with their mouse, we
  999. // want to restore focus back to the trigger, in order to
  1000. // prevent the select keyboard controls from clashing with
  1001. // the ones from `mat-option`.
  1002. this.focus();
  1003. }
  1004. }
  1005. }
  1006. if (wasSelected !== this._selectionModel.isSelected(option)) {
  1007. this._propagateChanges();
  1008. }
  1009. this.stateChanges.next();
  1010. }
  1011. /** Sorts the selected values in the selected based on their order in the panel. */
  1012. _sortValues() {
  1013. if (this.multiple) {
  1014. const options = this.options.toArray();
  1015. this._selectionModel.sort((a, b) => {
  1016. return this.sortComparator
  1017. ? this.sortComparator(a, b, options)
  1018. : options.indexOf(a) - options.indexOf(b);
  1019. });
  1020. this.stateChanges.next();
  1021. }
  1022. }
  1023. /** Emits change event to set the model value. */
  1024. _propagateChanges(fallbackValue) {
  1025. let valueToEmit;
  1026. if (this.multiple) {
  1027. valueToEmit = this.selected.map(option => option.value);
  1028. }
  1029. else {
  1030. valueToEmit = this.selected ? this.selected.value : fallbackValue;
  1031. }
  1032. this._value = valueToEmit;
  1033. this.valueChange.emit(valueToEmit);
  1034. this._onChange(valueToEmit);
  1035. this.selectionChange.emit(this._getChangeEvent(valueToEmit));
  1036. this._changeDetectorRef.markForCheck();
  1037. }
  1038. /**
  1039. * Highlights the selected item. If no option is selected, it will highlight
  1040. * the first *enabled* option.
  1041. */
  1042. _highlightCorrectOption() {
  1043. if (this._keyManager) {
  1044. if (this.empty) {
  1045. // Find the index of the first *enabled* option. Avoid calling `_keyManager.setActiveItem`
  1046. // because it activates the first option that passes the skip predicate, rather than the
  1047. // first *enabled* option.
  1048. let firstEnabledOptionIndex = -1;
  1049. for (let index = 0; index < this.options.length; index++) {
  1050. const option = this.options.get(index);
  1051. if (!option.disabled) {
  1052. firstEnabledOptionIndex = index;
  1053. break;
  1054. }
  1055. }
  1056. this._keyManager.setActiveItem(firstEnabledOptionIndex);
  1057. }
  1058. else {
  1059. this._keyManager.setActiveItem(this._selectionModel.selected[0]);
  1060. }
  1061. }
  1062. }
  1063. /** Whether the panel is allowed to open. */
  1064. _canOpen() {
  1065. return !this._panelOpen && !this.disabled && this.options?.length > 0 && !!this._overlayDir;
  1066. }
  1067. /** Focuses the select element. */
  1068. focus(options) {
  1069. this._elementRef.nativeElement.focus(options);
  1070. }
  1071. /** Gets the aria-labelledby for the select panel. */
  1072. _getPanelAriaLabelledby() {
  1073. if (this.ariaLabel) {
  1074. return null;
  1075. }
  1076. const labelId = this._parentFormField?.getLabelId() || null;
  1077. const labelExpression = labelId ? labelId + ' ' : '';
  1078. return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId;
  1079. }
  1080. /** Determines the `aria-activedescendant` to be set on the host. */
  1081. _getAriaActiveDescendant() {
  1082. if (this.panelOpen && this._keyManager && this._keyManager.activeItem) {
  1083. return this._keyManager.activeItem.id;
  1084. }
  1085. return null;
  1086. }
  1087. /** Gets the aria-labelledby of the select component trigger. */
  1088. _getTriggerAriaLabelledby() {
  1089. if (this.ariaLabel) {
  1090. return null;
  1091. }
  1092. let value = this._parentFormField?.getLabelId() || '';
  1093. if (this.ariaLabelledby) {
  1094. value += ' ' + this.ariaLabelledby;
  1095. }
  1096. // The value should not be used for the trigger's aria-labelledby,
  1097. // but this currently "breaks" accessibility tests since they complain
  1098. // there is no aria-labelledby. This is because they are not setting an
  1099. // appropriate label on the form field or select.
  1100. // TODO: remove this conditional after fixing clients by ensuring their
  1101. // selects have a label applied.
  1102. if (!value) {
  1103. value = this._valueId;
  1104. }
  1105. return value;
  1106. }
  1107. /**
  1108. * Implemented as part of MatFormFieldControl.
  1109. * @docs-private
  1110. */
  1111. setDescribedByIds(ids) {
  1112. if (ids.length) {
  1113. this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
  1114. }
  1115. else {
  1116. this._elementRef.nativeElement.removeAttribute('aria-describedby');
  1117. }
  1118. }
  1119. /**
  1120. * Implemented as part of MatFormFieldControl.
  1121. * @docs-private
  1122. */
  1123. onContainerClick() {
  1124. this.focus();
  1125. this.open();
  1126. }
  1127. /**
  1128. * Implemented as part of MatFormFieldControl.
  1129. * @docs-private
  1130. */
  1131. get shouldLabelFloat() {
  1132. // Since the panel doesn't overlap the trigger, we
  1133. // want the label to only float when there's a value.
  1134. return this.panelOpen || !this.empty || (this.focused && !!this.placeholder);
  1135. }
  1136. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
  1137. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", 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" }, classAttribute: "mat-mdc-select" }, providers: [
  1138. { provide: MatFormFieldControl, useExisting: MatSelect },
  1139. { provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatSelect },
  1140. ], 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 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 (detach)=\"close()\"\n (backdropClick)=\"close()\"\n (overlayKeydown)=\"_handleOverlayKeydown($event)\">\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 <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-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"], 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 });
  1141. }
  1142. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelect, decorators: [{
  1143. type: Component,
  1144. args: [{ selector: 'mat-select', exportAs: 'matSelect', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
  1145. 'role': 'combobox',
  1146. 'aria-haspopup': 'listbox',
  1147. 'class': 'mat-mdc-select',
  1148. '[attr.id]': 'id',
  1149. '[attr.tabindex]': 'disabled ? -1 : tabIndex',
  1150. '[attr.aria-controls]': 'panelOpen ? id + "-panel" : null',
  1151. '[attr.aria-expanded]': 'panelOpen',
  1152. '[attr.aria-label]': 'ariaLabel || null',
  1153. '[attr.aria-required]': 'required.toString()',
  1154. '[attr.aria-disabled]': 'disabled.toString()',
  1155. '[attr.aria-invalid]': 'errorState',
  1156. '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
  1157. '[class.mat-mdc-select-disabled]': 'disabled',
  1158. '[class.mat-mdc-select-invalid]': 'errorState',
  1159. '[class.mat-mdc-select-required]': 'required',
  1160. '[class.mat-mdc-select-empty]': 'empty',
  1161. '[class.mat-mdc-select-multiple]': 'multiple',
  1162. '(keydown)': '_handleKeydown($event)',
  1163. '(focus)': '_onFocus()',
  1164. '(blur)': '_onBlur()',
  1165. }, providers: [
  1166. { provide: MatFormFieldControl, useExisting: MatSelect },
  1167. { provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatSelect },
  1168. ], imports: [CdkOverlayOrigin, CdkConnectedOverlay, NgClass], template: "<div 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 (detach)=\"close()\"\n (backdropClick)=\"close()\"\n (overlayKeydown)=\"_handleOverlayKeydown($event)\">\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 <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-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"] }]
  1169. }], ctorParameters: () => [], propDecorators: { options: [{
  1170. type: ContentChildren,
  1171. args: [MatOption, { descendants: true }]
  1172. }], optionGroups: [{
  1173. type: ContentChildren,
  1174. args: [MAT_OPTGROUP, { descendants: true }]
  1175. }], customTrigger: [{
  1176. type: ContentChild,
  1177. args: [MAT_SELECT_TRIGGER]
  1178. }], userAriaDescribedBy: [{
  1179. type: Input,
  1180. args: ['aria-describedby']
  1181. }], trigger: [{
  1182. type: ViewChild,
  1183. args: ['trigger']
  1184. }], panel: [{
  1185. type: ViewChild,
  1186. args: ['panel']
  1187. }], _overlayDir: [{
  1188. type: ViewChild,
  1189. args: [CdkConnectedOverlay]
  1190. }], panelClass: [{
  1191. type: Input
  1192. }], disabled: [{
  1193. type: Input,
  1194. args: [{ transform: booleanAttribute }]
  1195. }], disableRipple: [{
  1196. type: Input,
  1197. args: [{ transform: booleanAttribute }]
  1198. }], tabIndex: [{
  1199. type: Input,
  1200. args: [{
  1201. transform: (value) => (value == null ? 0 : numberAttribute(value)),
  1202. }]
  1203. }], hideSingleSelectionIndicator: [{
  1204. type: Input,
  1205. args: [{ transform: booleanAttribute }]
  1206. }], placeholder: [{
  1207. type: Input
  1208. }], required: [{
  1209. type: Input,
  1210. args: [{ transform: booleanAttribute }]
  1211. }], multiple: [{
  1212. type: Input,
  1213. args: [{ transform: booleanAttribute }]
  1214. }], disableOptionCentering: [{
  1215. type: Input,
  1216. args: [{ transform: booleanAttribute }]
  1217. }], compareWith: [{
  1218. type: Input
  1219. }], value: [{
  1220. type: Input
  1221. }], ariaLabel: [{
  1222. type: Input,
  1223. args: ['aria-label']
  1224. }], ariaLabelledby: [{
  1225. type: Input,
  1226. args: ['aria-labelledby']
  1227. }], errorStateMatcher: [{
  1228. type: Input
  1229. }], typeaheadDebounceInterval: [{
  1230. type: Input,
  1231. args: [{ transform: numberAttribute }]
  1232. }], sortComparator: [{
  1233. type: Input
  1234. }], id: [{
  1235. type: Input
  1236. }], panelWidth: [{
  1237. type: Input
  1238. }], canSelectNullableOptions: [{
  1239. type: Input,
  1240. args: [{ transform: booleanAttribute }]
  1241. }], openedChange: [{
  1242. type: Output
  1243. }], _openedStream: [{
  1244. type: Output,
  1245. args: ['opened']
  1246. }], _closedStream: [{
  1247. type: Output,
  1248. args: ['closed']
  1249. }], selectionChange: [{
  1250. type: Output
  1251. }], valueChange: [{
  1252. type: Output
  1253. }] } });
  1254. /**
  1255. * Allows the user to customize the trigger that is displayed when the select has a value.
  1256. */
  1257. class MatSelectTrigger {
  1258. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelectTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  1259. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatSelectTrigger, isStandalone: true, selector: "mat-select-trigger", providers: [{ provide: MAT_SELECT_TRIGGER, useExisting: MatSelectTrigger }], ngImport: i0 });
  1260. }
  1261. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelectTrigger, decorators: [{
  1262. type: Directive,
  1263. args: [{
  1264. selector: 'mat-select-trigger',
  1265. providers: [{ provide: MAT_SELECT_TRIGGER, useExisting: MatSelectTrigger }],
  1266. }]
  1267. }] });
  1268. class MatSelectModule {
  1269. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  1270. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: MatSelectModule, imports: [OverlayModule, MatOptionModule, MatCommonModule, MatSelect, MatSelectTrigger], exports: [CdkScrollableModule,
  1271. MatFormFieldModule,
  1272. MatSelect,
  1273. MatSelectTrigger,
  1274. MatOptionModule,
  1275. MatCommonModule] });
  1276. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelectModule, providers: [MAT_SELECT_SCROLL_STRATEGY_PROVIDER], imports: [OverlayModule, MatOptionModule, MatCommonModule, CdkScrollableModule,
  1277. MatFormFieldModule,
  1278. MatOptionModule,
  1279. MatCommonModule] });
  1280. }
  1281. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSelectModule, decorators: [{
  1282. type: NgModule,
  1283. args: [{
  1284. imports: [OverlayModule, MatOptionModule, MatCommonModule, MatSelect, MatSelectTrigger],
  1285. exports: [
  1286. CdkScrollableModule,
  1287. MatFormFieldModule,
  1288. MatSelect,
  1289. MatSelectTrigger,
  1290. MatOptionModule,
  1291. MatCommonModule,
  1292. ],
  1293. providers: [MAT_SELECT_SCROLL_STRATEGY_PROVIDER],
  1294. }]
  1295. }] });
  1296. export { MatSelectModule as M, MAT_SELECT_SCROLL_STRATEGY as a, MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY as b, MAT_SELECT_CONFIG as c, MAT_SELECT_SCROLL_STRATEGY_PROVIDER as d, MAT_SELECT_TRIGGER as e, MatSelectChange as f, MatSelect as g, MatSelectTrigger as h };
  1297. //# sourceMappingURL=module-Cbt8Fcmv.mjs.map