select.js 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { animate, animateChild, query, state, style, transition, trigger } from '@angular/animations';
  9. import { ActiveDescendantKeyManager, LiveAnnouncer } from '@angular/cdk/a11y';
  10. import { Directionality } from '@angular/cdk/bidi';
  11. import { coerceBooleanProperty } from '@angular/cdk/coercion';
  12. import { SelectionModel } from '@angular/cdk/collections';
  13. import { A, DOWN_ARROW, END, ENTER, HOME, LEFT_ARROW, RIGHT_ARROW, SPACE, UP_ARROW, hasModifierKey } from '@angular/cdk/keycodes';
  14. import { CdkConnectedOverlay, Overlay, OverlayModule } from '@angular/cdk/overlay';
  15. import { ViewportRuler } from '@angular/cdk/scrolling';
  16. import { Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, Directive, ElementRef, EventEmitter, Inject, InjectionToken, Input, isDevMode, NgZone, Optional, Output, Self, ViewChild, ViewEncapsulation, NgModule } from '@angular/core';
  17. import { FormGroupDirective, NgControl, NgForm } from '@angular/forms';
  18. import { _countGroupLabelsBeforeOption, _getOptionScrollPosition, ErrorStateMatcher, MAT_OPTION_PARENT_COMPONENT, MatOptgroup, MatOption, mixinDisabled, mixinDisableRipple, mixinErrorState, mixinTabIndex, MatCommonModule, MatOptionModule } from '@angular/material/core';
  19. import { MatFormField, MatFormFieldControl, MatFormFieldModule } from '@angular/material/form-field';
  20. import { defer, merge, Subject } from 'rxjs';
  21. import { distinctUntilChanged, filter, map, startWith, switchMap, take, takeUntil } from 'rxjs/operators';
  22. import { CommonModule } from '@angular/common';
  23. /**
  24. * @fileoverview added by tsickle
  25. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  26. */
  27. /**
  28. * The following are all the animations for the mat-select component, with each
  29. * const containing the metadata for one animation.
  30. *
  31. * The values below match the implementation of the AngularJS Material mat-select animation.
  32. * \@docs-private
  33. * @type {?}
  34. */
  35. const matSelectAnimations = {
  36. /**
  37. * This animation ensures the select's overlay panel animation (transformPanel) is called when
  38. * closing the select.
  39. * This is needed due to https://github.com/angular/angular/issues/23302
  40. */
  41. transformPanelWrap: trigger('transformPanelWrap', [
  42. transition('* => void', query('@transformPanel', [animateChild()], { optional: true }))
  43. ]),
  44. /**
  45. * This animation transforms the select's overlay panel on and off the page.
  46. *
  47. * When the panel is attached to the DOM, it expands its width by the amount of padding, scales it
  48. * up to 100% on the Y axis, fades in its border, and translates slightly up and to the
  49. * side to ensure the option text correctly overlaps the trigger text.
  50. *
  51. * When the panel is removed from the DOM, it simply fades out linearly.
  52. */
  53. transformPanel: trigger('transformPanel', [
  54. state('void', style({
  55. transform: 'scaleY(0.8)',
  56. minWidth: '100%',
  57. opacity: 0
  58. })),
  59. state('showing', style({
  60. opacity: 1,
  61. minWidth: 'calc(100% + 32px)',
  62. // 32px = 2 * 16px padding
  63. transform: 'scaleY(1)'
  64. })),
  65. state('showing-multiple', style({
  66. opacity: 1,
  67. minWidth: 'calc(100% + 64px)',
  68. // 64px = 48px padding on the left + 16px padding on the right
  69. transform: 'scaleY(1)'
  70. })),
  71. transition('void => *', animate('120ms cubic-bezier(0, 0, 0.2, 1)')),
  72. transition('* => void', animate('100ms 25ms linear', style({ opacity: 0 })))
  73. ]),
  74. /**
  75. * This animation fades in the background color and text content of the
  76. * select's options. It is time delayed to occur 100ms after the overlay
  77. * panel has transformed in.
  78. * @deprecated Not used anymore. To be removed.
  79. * \@breaking-change 8.0.0
  80. */
  81. fadeInContent: trigger('fadeInContent', [
  82. state('showing', style({ opacity: 1 })),
  83. transition('void => showing', [
  84. style({ opacity: 0 }),
  85. animate('150ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)')
  86. ])
  87. ])
  88. };
  89. /**
  90. * @deprecated
  91. * \@breaking-change 8.0.0
  92. * \@docs-private
  93. * @type {?}
  94. */
  95. const transformPanel = matSelectAnimations.transformPanel;
  96. /**
  97. * @deprecated
  98. * \@breaking-change 8.0.0
  99. * \@docs-private
  100. * @type {?}
  101. */
  102. const fadeInContent = matSelectAnimations.fadeInContent;
  103. /**
  104. * @fileoverview added by tsickle
  105. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  106. */
  107. /**
  108. * Returns an exception to be thrown when attempting to change a select's `multiple` option
  109. * after initialization.
  110. * \@docs-private
  111. * @return {?}
  112. */
  113. function getMatSelectDynamicMultipleError() {
  114. return Error('Cannot change `multiple` mode of select after initialization.');
  115. }
  116. /**
  117. * Returns an exception to be thrown when attempting to assign a non-array value to a select
  118. * in `multiple` mode. Note that `undefined` and `null` are still valid values to allow for
  119. * resetting the value.
  120. * \@docs-private
  121. * @return {?}
  122. */
  123. function getMatSelectNonArrayValueError() {
  124. return Error('Value must be an array in multiple-selection mode.');
  125. }
  126. /**
  127. * Returns an exception to be thrown when assigning a non-function value to the comparator
  128. * used to determine if a value corresponds to an option. Note that whether the function
  129. * actually takes two values and returns a boolean is not checked.
  130. * @return {?}
  131. */
  132. function getMatSelectNonFunctionValueError() {
  133. return Error('`compareWith` must be a function.');
  134. }
  135. /**
  136. * @fileoverview added by tsickle
  137. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  138. */
  139. /** @type {?} */
  140. let nextUniqueId = 0;
  141. /**
  142. * The max height of the select's overlay panel
  143. * @type {?}
  144. */
  145. const SELECT_PANEL_MAX_HEIGHT = 256;
  146. /**
  147. * The panel's padding on the x-axis
  148. * @type {?}
  149. */
  150. const SELECT_PANEL_PADDING_X = 16;
  151. /**
  152. * The panel's x axis padding if it is indented (e.g. there is an option group).
  153. * @type {?}
  154. */
  155. const SELECT_PANEL_INDENT_PADDING_X = SELECT_PANEL_PADDING_X * 2;
  156. /**
  157. * The height of the select items in `em` units.
  158. * @type {?}
  159. */
  160. const SELECT_ITEM_HEIGHT_EM = 3;
  161. // TODO(josephperrott): Revert to a constant after 2018 spec updates are fully merged.
  162. /**
  163. * Distance between the panel edge and the option text in
  164. * multi-selection mode.
  165. *
  166. * Calculated as:
  167. * (SELECT_PANEL_PADDING_X * 1.5) + 16 = 40
  168. * The padding is multiplied by 1.5 because the checkbox's margin is half the padding.
  169. * The checkbox width is 16px.
  170. * @type {?}
  171. */
  172. const SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + 16;
  173. /**
  174. * The select panel will only "fit" inside the viewport if it is positioned at
  175. * this value or more away from the viewport boundary.
  176. * @type {?}
  177. */
  178. const SELECT_PANEL_VIEWPORT_PADDING = 8;
  179. /**
  180. * Injection token that determines the scroll handling while a select is open.
  181. * @type {?}
  182. */
  183. const MAT_SELECT_SCROLL_STRATEGY = new InjectionToken('mat-select-scroll-strategy');
  184. /**
  185. * \@docs-private
  186. * @param {?} overlay
  187. * @return {?}
  188. */
  189. function MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
  190. return (/**
  191. * @return {?}
  192. */
  193. () => overlay.scrollStrategies.reposition());
  194. }
  195. /**
  196. * \@docs-private
  197. * @type {?}
  198. */
  199. const MAT_SELECT_SCROLL_STRATEGY_PROVIDER = {
  200. provide: MAT_SELECT_SCROLL_STRATEGY,
  201. deps: [Overlay],
  202. useFactory: MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
  203. };
  204. /**
  205. * Change event object that is emitted when the select value has changed.
  206. */
  207. class MatSelectChange {
  208. /**
  209. * @param {?} source
  210. * @param {?} value
  211. */
  212. constructor(source, value) {
  213. this.source = source;
  214. this.value = value;
  215. }
  216. }
  217. // Boilerplate for applying mixins to MatSelect.
  218. /**
  219. * \@docs-private
  220. */
  221. class MatSelectBase {
  222. /**
  223. * @param {?} _elementRef
  224. * @param {?} _defaultErrorStateMatcher
  225. * @param {?} _parentForm
  226. * @param {?} _parentFormGroup
  227. * @param {?} ngControl
  228. */
  229. constructor(_elementRef, _defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl) {
  230. this._elementRef = _elementRef;
  231. this._defaultErrorStateMatcher = _defaultErrorStateMatcher;
  232. this._parentForm = _parentForm;
  233. this._parentFormGroup = _parentFormGroup;
  234. this.ngControl = ngControl;
  235. }
  236. }
  237. /** @type {?} */
  238. const _MatSelectMixinBase = mixinDisableRipple(mixinTabIndex(mixinDisabled(mixinErrorState(MatSelectBase))));
  239. /**
  240. * Allows the user to customize the trigger that is displayed when the select has a value.
  241. */
  242. class MatSelectTrigger {
  243. }
  244. MatSelectTrigger.decorators = [
  245. { type: Directive, args: [{
  246. selector: 'mat-select-trigger'
  247. },] },
  248. ];
  249. class MatSelect extends _MatSelectMixinBase {
  250. /**
  251. * @param {?} _viewportRuler
  252. * @param {?} _changeDetectorRef
  253. * @param {?} _ngZone
  254. * @param {?} _defaultErrorStateMatcher
  255. * @param {?} elementRef
  256. * @param {?} _dir
  257. * @param {?} _parentForm
  258. * @param {?} _parentFormGroup
  259. * @param {?} _parentFormField
  260. * @param {?} ngControl
  261. * @param {?} tabIndex
  262. * @param {?} scrollStrategyFactory
  263. * @param {?=} _liveAnnouncer
  264. */
  265. constructor(_viewportRuler, _changeDetectorRef, _ngZone, _defaultErrorStateMatcher, elementRef, _dir, _parentForm, _parentFormGroup, _parentFormField, ngControl, tabIndex, scrollStrategyFactory, _liveAnnouncer) {
  266. super(elementRef, _defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
  267. this._viewportRuler = _viewportRuler;
  268. this._changeDetectorRef = _changeDetectorRef;
  269. this._ngZone = _ngZone;
  270. this._dir = _dir;
  271. this._parentFormField = _parentFormField;
  272. this.ngControl = ngControl;
  273. this._liveAnnouncer = _liveAnnouncer;
  274. /**
  275. * Whether or not the overlay panel is open.
  276. */
  277. this._panelOpen = false;
  278. /**
  279. * Whether filling out the select is required in the form.
  280. */
  281. this._required = false;
  282. /**
  283. * The scroll position of the overlay panel, calculated to center the selected option.
  284. */
  285. this._scrollTop = 0;
  286. /**
  287. * Whether the component is in multiple selection mode.
  288. */
  289. this._multiple = false;
  290. /**
  291. * Comparison function to specify which option is displayed. Defaults to object equality.
  292. */
  293. this._compareWith = (/**
  294. * @param {?} o1
  295. * @param {?} o2
  296. * @return {?}
  297. */
  298. (o1, o2) => o1 === o2);
  299. /**
  300. * Unique id for this input.
  301. */
  302. this._uid = `mat-select-${nextUniqueId++}`;
  303. /**
  304. * Emits whenever the component is destroyed.
  305. */
  306. this._destroy = new Subject();
  307. /**
  308. * The cached font-size of the trigger element.
  309. */
  310. this._triggerFontSize = 0;
  311. /**
  312. * `View -> model callback called when value changes`
  313. */
  314. this._onChange = (/**
  315. * @return {?}
  316. */
  317. () => { });
  318. /**
  319. * `View -> model callback called when select has been touched`
  320. */
  321. this._onTouched = (/**
  322. * @return {?}
  323. */
  324. () => { });
  325. /**
  326. * The IDs of child options to be passed to the aria-owns attribute.
  327. */
  328. this._optionIds = '';
  329. /**
  330. * The value of the select panel's transform-origin property.
  331. */
  332. this._transformOrigin = 'top';
  333. /**
  334. * Emits when the panel element is finished transforming in.
  335. */
  336. this._panelDoneAnimatingStream = new Subject();
  337. /**
  338. * The y-offset of the overlay panel in relation to the trigger's top start corner.
  339. * This must be adjusted to align the selected option text over the trigger text.
  340. * when the panel opens. Will change based on the y-position of the selected option.
  341. */
  342. this._offsetY = 0;
  343. /**
  344. * This position config ensures that the top "start" corner of the overlay
  345. * is aligned with with the top "start" of the origin by default (overlapping
  346. * the trigger completely). If the panel cannot fit below the trigger, it
  347. * will fall back to a position above the trigger.
  348. */
  349. this._positions = [
  350. {
  351. originX: 'start',
  352. originY: 'top',
  353. overlayX: 'start',
  354. overlayY: 'top',
  355. },
  356. {
  357. originX: 'start',
  358. originY: 'bottom',
  359. overlayX: 'start',
  360. overlayY: 'bottom',
  361. },
  362. ];
  363. /**
  364. * Whether the component is disabling centering of the active option over the trigger.
  365. */
  366. this._disableOptionCentering = false;
  367. this._focused = false;
  368. /**
  369. * A name for this control that can be used by `mat-form-field`.
  370. */
  371. this.controlType = 'mat-select';
  372. /**
  373. * Aria label of the select. If not specified, the placeholder will be used as label.
  374. */
  375. this.ariaLabel = '';
  376. /**
  377. * Combined stream of all of the child options' change events.
  378. */
  379. this.optionSelectionChanges = (/** @type {?} */ (defer((/**
  380. * @return {?}
  381. */
  382. () => {
  383. /** @type {?} */
  384. const options = this.options;
  385. if (options) {
  386. return options.changes.pipe(startWith(options), switchMap((/**
  387. * @return {?}
  388. */
  389. () => merge(...options.map((/**
  390. * @param {?} option
  391. * @return {?}
  392. */
  393. option => option.onSelectionChange))))));
  394. }
  395. return this._ngZone.onStable
  396. .asObservable()
  397. .pipe(take(1), switchMap((/**
  398. * @return {?}
  399. */
  400. () => this.optionSelectionChanges)));
  401. }))));
  402. /**
  403. * Event emitted when the select panel has been toggled.
  404. */
  405. this.openedChange = new EventEmitter();
  406. /**
  407. * Event emitted when the select has been opened.
  408. */
  409. this._openedStream = this.openedChange.pipe(filter((/**
  410. * @param {?} o
  411. * @return {?}
  412. */
  413. o => o)), map((/**
  414. * @return {?}
  415. */
  416. () => { })));
  417. /**
  418. * Event emitted when the select has been closed.
  419. */
  420. this._closedStream = this.openedChange.pipe(filter((/**
  421. * @param {?} o
  422. * @return {?}
  423. */
  424. o => !o)), map((/**
  425. * @return {?}
  426. */
  427. () => { })));
  428. /**
  429. * Event emitted when the selected value has been changed by the user.
  430. */
  431. this.selectionChange = new EventEmitter();
  432. /**
  433. * Event that emits whenever the raw value of the select changes. This is here primarily
  434. * to facilitate the two-way binding for the `value` input.
  435. * \@docs-private
  436. */
  437. this.valueChange = new EventEmitter();
  438. if (this.ngControl) {
  439. // Note: we provide the value accessor through here, instead of
  440. // the `providers` to avoid running into a circular import.
  441. this.ngControl.valueAccessor = this;
  442. }
  443. this._scrollStrategyFactory = scrollStrategyFactory;
  444. this._scrollStrategy = this._scrollStrategyFactory();
  445. this.tabIndex = parseInt(tabIndex) || 0;
  446. // Force setter to be called in case id was not specified.
  447. this.id = this.id;
  448. }
  449. /**
  450. * Whether the select is focused.
  451. * @return {?}
  452. */
  453. get focused() {
  454. return this._focused || this._panelOpen;
  455. }
  456. /**
  457. * @deprecated Setter to be removed as this property is intended to be readonly.
  458. * \@breaking-change 8.0.0
  459. * @param {?} value
  460. * @return {?}
  461. */
  462. set focused(value) {
  463. this._focused = value;
  464. }
  465. /**
  466. * Placeholder to be shown if no value has been selected.
  467. * @return {?}
  468. */
  469. get placeholder() { return this._placeholder; }
  470. /**
  471. * @param {?} value
  472. * @return {?}
  473. */
  474. set placeholder(value) {
  475. this._placeholder = value;
  476. this.stateChanges.next();
  477. }
  478. /**
  479. * Whether the component is required.
  480. * @return {?}
  481. */
  482. get required() { return this._required; }
  483. /**
  484. * @param {?} value
  485. * @return {?}
  486. */
  487. set required(value) {
  488. this._required = coerceBooleanProperty(value);
  489. this.stateChanges.next();
  490. }
  491. /**
  492. * Whether the user should be allowed to select multiple options.
  493. * @return {?}
  494. */
  495. get multiple() { return this._multiple; }
  496. /**
  497. * @param {?} value
  498. * @return {?}
  499. */
  500. set multiple(value) {
  501. if (this._selectionModel) {
  502. throw getMatSelectDynamicMultipleError();
  503. }
  504. this._multiple = coerceBooleanProperty(value);
  505. }
  506. /**
  507. * Whether to center the active option over the trigger.
  508. * @return {?}
  509. */
  510. get disableOptionCentering() { return this._disableOptionCentering; }
  511. /**
  512. * @param {?} value
  513. * @return {?}
  514. */
  515. set disableOptionCentering(value) {
  516. this._disableOptionCentering = coerceBooleanProperty(value);
  517. }
  518. /**
  519. * Function to compare the option values with the selected values. The first argument
  520. * is a value from an option. The second is a value from the selection. A boolean
  521. * should be returned.
  522. * @return {?}
  523. */
  524. get compareWith() { return this._compareWith; }
  525. /**
  526. * @param {?} fn
  527. * @return {?}
  528. */
  529. set compareWith(fn) {
  530. if (typeof fn !== 'function') {
  531. throw getMatSelectNonFunctionValueError();
  532. }
  533. this._compareWith = fn;
  534. if (this._selectionModel) {
  535. // A different comparator means the selection could change.
  536. this._initializeSelection();
  537. }
  538. }
  539. /**
  540. * Value of the select control.
  541. * @return {?}
  542. */
  543. get value() { return this._value; }
  544. /**
  545. * @param {?} newValue
  546. * @return {?}
  547. */
  548. set value(newValue) {
  549. if (newValue !== this._value) {
  550. this.writeValue(newValue);
  551. this._value = newValue;
  552. }
  553. }
  554. /**
  555. * Unique id of the element.
  556. * @return {?}
  557. */
  558. get id() { return this._id; }
  559. /**
  560. * @param {?} value
  561. * @return {?}
  562. */
  563. set id(value) {
  564. this._id = value || this._uid;
  565. this.stateChanges.next();
  566. }
  567. /**
  568. * @return {?}
  569. */
  570. ngOnInit() {
  571. this._selectionModel = new SelectionModel(this.multiple);
  572. this.stateChanges.next();
  573. // We need `distinctUntilChanged` here, because some browsers will
  574. // fire the animation end event twice for the same animation. See:
  575. // https://github.com/angular/angular/issues/24084
  576. this._panelDoneAnimatingStream
  577. .pipe(distinctUntilChanged(), takeUntil(this._destroy))
  578. .subscribe((/**
  579. * @return {?}
  580. */
  581. () => {
  582. if (this.panelOpen) {
  583. this._scrollTop = 0;
  584. this.openedChange.emit(true);
  585. }
  586. else {
  587. this.openedChange.emit(false);
  588. this.overlayDir.offsetX = 0;
  589. this._changeDetectorRef.markForCheck();
  590. }
  591. }));
  592. this._viewportRuler.change()
  593. .pipe(takeUntil(this._destroy))
  594. .subscribe((/**
  595. * @return {?}
  596. */
  597. () => {
  598. if (this._panelOpen) {
  599. this._triggerRect = this.trigger.nativeElement.getBoundingClientRect();
  600. this._changeDetectorRef.markForCheck();
  601. }
  602. }));
  603. }
  604. /**
  605. * @return {?}
  606. */
  607. ngAfterContentInit() {
  608. this._initKeyManager();
  609. this._selectionModel.onChange.pipe(takeUntil(this._destroy)).subscribe((/**
  610. * @param {?} event
  611. * @return {?}
  612. */
  613. event => {
  614. event.added.forEach((/**
  615. * @param {?} option
  616. * @return {?}
  617. */
  618. option => option.select()));
  619. event.removed.forEach((/**
  620. * @param {?} option
  621. * @return {?}
  622. */
  623. option => option.deselect()));
  624. }));
  625. this.options.changes.pipe(startWith(null), takeUntil(this._destroy)).subscribe((/**
  626. * @return {?}
  627. */
  628. () => {
  629. this._resetOptions();
  630. this._initializeSelection();
  631. }));
  632. }
  633. /**
  634. * @return {?}
  635. */
  636. ngDoCheck() {
  637. if (this.ngControl) {
  638. this.updateErrorState();
  639. }
  640. }
  641. /**
  642. * @param {?} changes
  643. * @return {?}
  644. */
  645. ngOnChanges(changes) {
  646. // Updating the disabled state is handled by `mixinDisabled`, but we need to additionally let
  647. // the parent form field know to run change detection when the disabled state changes.
  648. if (changes['disabled']) {
  649. this.stateChanges.next();
  650. }
  651. }
  652. /**
  653. * @return {?}
  654. */
  655. ngOnDestroy() {
  656. this._destroy.next();
  657. this._destroy.complete();
  658. this.stateChanges.complete();
  659. }
  660. /**
  661. * Toggles the overlay panel open or closed.
  662. * @return {?}
  663. */
  664. toggle() {
  665. this.panelOpen ? this.close() : this.open();
  666. }
  667. /**
  668. * Opens the overlay panel.
  669. * @return {?}
  670. */
  671. open() {
  672. if (this.disabled || !this.options || !this.options.length || this._panelOpen) {
  673. return;
  674. }
  675. this._triggerRect = this.trigger.nativeElement.getBoundingClientRect();
  676. // Note: The computed font-size will be a string pixel value (e.g. "16px").
  677. // `parseInt` ignores the trailing 'px' and converts this to a number.
  678. this._triggerFontSize = parseInt(getComputedStyle(this.trigger.nativeElement).fontSize || '0');
  679. this._panelOpen = true;
  680. this._keyManager.withHorizontalOrientation(null);
  681. this._calculateOverlayPosition();
  682. this._highlightCorrectOption();
  683. this._changeDetectorRef.markForCheck();
  684. // Set the font size on the panel element once it exists.
  685. this._ngZone.onStable.asObservable().pipe(take(1)).subscribe((/**
  686. * @return {?}
  687. */
  688. () => {
  689. if (this._triggerFontSize && this.overlayDir.overlayRef &&
  690. this.overlayDir.overlayRef.overlayElement) {
  691. this.overlayDir.overlayRef.overlayElement.style.fontSize = `${this._triggerFontSize}px`;
  692. }
  693. }));
  694. }
  695. /**
  696. * Closes the overlay panel and focuses the host element.
  697. * @return {?}
  698. */
  699. close() {
  700. if (this._panelOpen) {
  701. this._panelOpen = false;
  702. this._keyManager.withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr');
  703. this._changeDetectorRef.markForCheck();
  704. this._onTouched();
  705. }
  706. }
  707. /**
  708. * Sets the select's value. Part of the ControlValueAccessor interface
  709. * required to integrate with Angular's core forms API.
  710. *
  711. * @param {?} value New value to be written to the model.
  712. * @return {?}
  713. */
  714. writeValue(value) {
  715. if (this.options) {
  716. this._setSelectionByValue(value);
  717. }
  718. }
  719. /**
  720. * Saves a callback function to be invoked when the select's value
  721. * changes from user input. Part of the ControlValueAccessor interface
  722. * required to integrate with Angular's core forms API.
  723. *
  724. * @param {?} fn Callback to be triggered when the value changes.
  725. * @return {?}
  726. */
  727. registerOnChange(fn) {
  728. this._onChange = fn;
  729. }
  730. /**
  731. * Saves a callback function to be invoked when the select is blurred
  732. * by the user. Part of the ControlValueAccessor interface required
  733. * to integrate with Angular's core forms API.
  734. *
  735. * @param {?} fn Callback to be triggered when the component has been touched.
  736. * @return {?}
  737. */
  738. registerOnTouched(fn) {
  739. this._onTouched = fn;
  740. }
  741. /**
  742. * Disables the select. Part of the ControlValueAccessor interface required
  743. * to integrate with Angular's core forms API.
  744. *
  745. * @param {?} isDisabled Sets whether the component is disabled.
  746. * @return {?}
  747. */
  748. setDisabledState(isDisabled) {
  749. this.disabled = isDisabled;
  750. this._changeDetectorRef.markForCheck();
  751. this.stateChanges.next();
  752. }
  753. /**
  754. * Whether or not the overlay panel is open.
  755. * @return {?}
  756. */
  757. get panelOpen() {
  758. return this._panelOpen;
  759. }
  760. /**
  761. * The currently selected option.
  762. * @return {?}
  763. */
  764. get selected() {
  765. return this.multiple ? this._selectionModel.selected : this._selectionModel.selected[0];
  766. }
  767. /**
  768. * The value displayed in the trigger.
  769. * @return {?}
  770. */
  771. get triggerValue() {
  772. if (this.empty) {
  773. return '';
  774. }
  775. if (this._multiple) {
  776. /** @type {?} */
  777. const selectedOptions = this._selectionModel.selected.map((/**
  778. * @param {?} option
  779. * @return {?}
  780. */
  781. option => option.viewValue));
  782. if (this._isRtl()) {
  783. selectedOptions.reverse();
  784. }
  785. // TODO(crisbeto): delimiter should be configurable for proper localization.
  786. return selectedOptions.join(', ');
  787. }
  788. return this._selectionModel.selected[0].viewValue;
  789. }
  790. /**
  791. * Whether the element is in RTL mode.
  792. * @return {?}
  793. */
  794. _isRtl() {
  795. return this._dir ? this._dir.value === 'rtl' : false;
  796. }
  797. /**
  798. * Handles all keydown events on the select.
  799. * @param {?} event
  800. * @return {?}
  801. */
  802. _handleKeydown(event) {
  803. if (!this.disabled) {
  804. this.panelOpen ? this._handleOpenKeydown(event) : this._handleClosedKeydown(event);
  805. }
  806. }
  807. /**
  808. * Handles keyboard events while the select is closed.
  809. * @private
  810. * @param {?} event
  811. * @return {?}
  812. */
  813. _handleClosedKeydown(event) {
  814. /** @type {?} */
  815. const keyCode = event.keyCode;
  816. /** @type {?} */
  817. const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW ||
  818. keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW;
  819. /** @type {?} */
  820. const isOpenKey = keyCode === ENTER || keyCode === SPACE;
  821. /** @type {?} */
  822. const manager = this._keyManager;
  823. // Open the select on ALT + arrow key to match the native <select>
  824. if ((isOpenKey && !hasModifierKey(event)) || ((this.multiple || event.altKey) && isArrowKey)) {
  825. event.preventDefault(); // prevents the page from scrolling down when pressing space
  826. this.open();
  827. }
  828. else if (!this.multiple) {
  829. /** @type {?} */
  830. const previouslySelectedOption = this.selected;
  831. if (keyCode === HOME || keyCode === END) {
  832. keyCode === HOME ? manager.setFirstItemActive() : manager.setLastItemActive();
  833. event.preventDefault();
  834. }
  835. else {
  836. manager.onKeydown(event);
  837. }
  838. /** @type {?} */
  839. const selectedOption = this.selected;
  840. // Since the value has changed, we need to announce it ourselves.
  841. // @breaking-change 8.0.0 remove null check for _liveAnnouncer.
  842. if (this._liveAnnouncer && selectedOption && previouslySelectedOption !== selectedOption) {
  843. // We set a duration on the live announcement, because we want the live element to be
  844. // cleared after a while so that users can't navigate to it using the arrow keys.
  845. this._liveAnnouncer.announce(((/** @type {?} */ (selectedOption))).viewValue, 10000);
  846. }
  847. }
  848. }
  849. /**
  850. * Handles keyboard events when the selected is open.
  851. * @private
  852. * @param {?} event
  853. * @return {?}
  854. */
  855. _handleOpenKeydown(event) {
  856. /** @type {?} */
  857. const keyCode = event.keyCode;
  858. /** @type {?} */
  859. const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW;
  860. /** @type {?} */
  861. const manager = this._keyManager;
  862. if (keyCode === HOME || keyCode === END) {
  863. event.preventDefault();
  864. keyCode === HOME ? manager.setFirstItemActive() : manager.setLastItemActive();
  865. }
  866. else if (isArrowKey && event.altKey) {
  867. // Close the select on ALT + arrow key to match the native <select>
  868. event.preventDefault();
  869. this.close();
  870. }
  871. else if ((keyCode === ENTER || keyCode === SPACE) && manager.activeItem &&
  872. !hasModifierKey(event)) {
  873. event.preventDefault();
  874. manager.activeItem._selectViaInteraction();
  875. }
  876. else if (this._multiple && keyCode === A && event.ctrlKey) {
  877. event.preventDefault();
  878. /** @type {?} */
  879. const hasDeselectedOptions = this.options.some((/**
  880. * @param {?} opt
  881. * @return {?}
  882. */
  883. opt => !opt.disabled && !opt.selected));
  884. this.options.forEach((/**
  885. * @param {?} option
  886. * @return {?}
  887. */
  888. option => {
  889. if (!option.disabled) {
  890. hasDeselectedOptions ? option.select() : option.deselect();
  891. }
  892. }));
  893. }
  894. else {
  895. /** @type {?} */
  896. const previouslyFocusedIndex = manager.activeItemIndex;
  897. manager.onKeydown(event);
  898. if (this._multiple && isArrowKey && event.shiftKey && manager.activeItem &&
  899. manager.activeItemIndex !== previouslyFocusedIndex) {
  900. manager.activeItem._selectViaInteraction();
  901. }
  902. }
  903. }
  904. /**
  905. * @return {?}
  906. */
  907. _onFocus() {
  908. if (!this.disabled) {
  909. this._focused = true;
  910. this.stateChanges.next();
  911. }
  912. }
  913. /**
  914. * Calls the touched callback only if the panel is closed. Otherwise, the trigger will
  915. * "blur" to the panel when it opens, causing a false positive.
  916. * @return {?}
  917. */
  918. _onBlur() {
  919. this._focused = false;
  920. if (!this.disabled && !this.panelOpen) {
  921. this._onTouched();
  922. this._changeDetectorRef.markForCheck();
  923. this.stateChanges.next();
  924. }
  925. }
  926. /**
  927. * Callback that is invoked when the overlay panel has been attached.
  928. * @return {?}
  929. */
  930. _onAttached() {
  931. this.overlayDir.positionChange.pipe(take(1)).subscribe((/**
  932. * @return {?}
  933. */
  934. () => {
  935. this._changeDetectorRef.detectChanges();
  936. this._calculateOverlayOffsetX();
  937. this.panel.nativeElement.scrollTop = this._scrollTop;
  938. }));
  939. }
  940. /**
  941. * Returns the theme to be used on the panel.
  942. * @return {?}
  943. */
  944. _getPanelTheme() {
  945. return this._parentFormField ? `mat-${this._parentFormField.color}` : '';
  946. }
  947. /**
  948. * Whether the select has a value.
  949. * @return {?}
  950. */
  951. get empty() {
  952. return !this._selectionModel || this._selectionModel.isEmpty();
  953. }
  954. /**
  955. * @private
  956. * @return {?}
  957. */
  958. _initializeSelection() {
  959. // Defer setting the value in order to avoid the "Expression
  960. // has changed after it was checked" errors from Angular.
  961. Promise.resolve().then((/**
  962. * @return {?}
  963. */
  964. () => {
  965. this._setSelectionByValue(this.ngControl ? this.ngControl.value : this._value);
  966. this.stateChanges.next();
  967. }));
  968. }
  969. /**
  970. * Sets the selected option based on a value. If no option can be
  971. * found with the designated value, the select trigger is cleared.
  972. * @private
  973. * @param {?} value
  974. * @return {?}
  975. */
  976. _setSelectionByValue(value) {
  977. if (this.multiple && value) {
  978. if (!Array.isArray(value)) {
  979. throw getMatSelectNonArrayValueError();
  980. }
  981. this._selectionModel.clear();
  982. value.forEach((/**
  983. * @param {?} currentValue
  984. * @return {?}
  985. */
  986. (currentValue) => this._selectValue(currentValue)));
  987. this._sortValues();
  988. }
  989. else {
  990. this._selectionModel.clear();
  991. /** @type {?} */
  992. const correspondingOption = this._selectValue(value);
  993. // Shift focus to the active item. Note that we shouldn't do this in multiple
  994. // mode, because we don't know what option the user interacted with last.
  995. if (correspondingOption) {
  996. this._keyManager.setActiveItem(correspondingOption);
  997. }
  998. }
  999. this._changeDetectorRef.markForCheck();
  1000. }
  1001. /**
  1002. * Finds and selects and option based on its value.
  1003. * @private
  1004. * @param {?} value
  1005. * @return {?} Option that has the corresponding value.
  1006. */
  1007. _selectValue(value) {
  1008. /** @type {?} */
  1009. const correspondingOption = this.options.find((/**
  1010. * @param {?} option
  1011. * @return {?}
  1012. */
  1013. (option) => {
  1014. try {
  1015. // Treat null as a special reset value.
  1016. return option.value != null && this._compareWith(option.value, value);
  1017. }
  1018. catch (error) {
  1019. if (isDevMode()) {
  1020. // Notify developers of errors in their comparator.
  1021. console.warn(error);
  1022. }
  1023. return false;
  1024. }
  1025. }));
  1026. if (correspondingOption) {
  1027. this._selectionModel.select(correspondingOption);
  1028. }
  1029. return correspondingOption;
  1030. }
  1031. /**
  1032. * Sets up a key manager to listen to keyboard events on the overlay panel.
  1033. * @private
  1034. * @return {?}
  1035. */
  1036. _initKeyManager() {
  1037. this._keyManager = new ActiveDescendantKeyManager(this.options)
  1038. .withTypeAhead()
  1039. .withVerticalOrientation()
  1040. .withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr')
  1041. .withAllowedModifierKeys(['shiftKey']);
  1042. this._keyManager.tabOut.pipe(takeUntil(this._destroy)).subscribe((/**
  1043. * @return {?}
  1044. */
  1045. () => {
  1046. // Restore focus to the trigger before closing. Ensures that the focus
  1047. // position won't be lost if the user got focus into the overlay.
  1048. this.focus();
  1049. this.close();
  1050. }));
  1051. this._keyManager.change.pipe(takeUntil(this._destroy)).subscribe((/**
  1052. * @return {?}
  1053. */
  1054. () => {
  1055. if (this._panelOpen && this.panel) {
  1056. this._scrollActiveOptionIntoView();
  1057. }
  1058. else if (!this._panelOpen && !this.multiple && this._keyManager.activeItem) {
  1059. this._keyManager.activeItem._selectViaInteraction();
  1060. }
  1061. }));
  1062. }
  1063. /**
  1064. * Drops current option subscriptions and IDs and resets from scratch.
  1065. * @private
  1066. * @return {?}
  1067. */
  1068. _resetOptions() {
  1069. /** @type {?} */
  1070. const changedOrDestroyed = merge(this.options.changes, this._destroy);
  1071. this.optionSelectionChanges.pipe(takeUntil(changedOrDestroyed)).subscribe((/**
  1072. * @param {?} event
  1073. * @return {?}
  1074. */
  1075. event => {
  1076. this._onSelect(event.source, event.isUserInput);
  1077. if (event.isUserInput && !this.multiple && this._panelOpen) {
  1078. this.close();
  1079. this.focus();
  1080. }
  1081. }));
  1082. // Listen to changes in the internal state of the options and react accordingly.
  1083. // Handles cases like the labels of the selected options changing.
  1084. merge(...this.options.map((/**
  1085. * @param {?} option
  1086. * @return {?}
  1087. */
  1088. option => option._stateChanges)))
  1089. .pipe(takeUntil(changedOrDestroyed))
  1090. .subscribe((/**
  1091. * @return {?}
  1092. */
  1093. () => {
  1094. this._changeDetectorRef.markForCheck();
  1095. this.stateChanges.next();
  1096. }));
  1097. this._setOptionIds();
  1098. }
  1099. /**
  1100. * Invoked when an option is clicked.
  1101. * @private
  1102. * @param {?} option
  1103. * @param {?} isUserInput
  1104. * @return {?}
  1105. */
  1106. _onSelect(option, isUserInput) {
  1107. /** @type {?} */
  1108. const wasSelected = this._selectionModel.isSelected(option);
  1109. if (option.value == null && !this._multiple) {
  1110. option.deselect();
  1111. this._selectionModel.clear();
  1112. this._propagateChanges(option.value);
  1113. }
  1114. else {
  1115. option.selected ? this._selectionModel.select(option) : this._selectionModel.deselect(option);
  1116. if (isUserInput) {
  1117. this._keyManager.setActiveItem(option);
  1118. }
  1119. if (this.multiple) {
  1120. this._sortValues();
  1121. if (isUserInput) {
  1122. // In case the user selected the option with their mouse, we
  1123. // want to restore focus back to the trigger, in order to
  1124. // prevent the select keyboard controls from clashing with
  1125. // the ones from `mat-option`.
  1126. this.focus();
  1127. }
  1128. }
  1129. }
  1130. if (wasSelected !== this._selectionModel.isSelected(option)) {
  1131. this._propagateChanges();
  1132. }
  1133. this.stateChanges.next();
  1134. }
  1135. /**
  1136. * Sorts the selected values in the selected based on their order in the panel.
  1137. * @private
  1138. * @return {?}
  1139. */
  1140. _sortValues() {
  1141. if (this.multiple) {
  1142. /** @type {?} */
  1143. const options = this.options.toArray();
  1144. this._selectionModel.sort((/**
  1145. * @param {?} a
  1146. * @param {?} b
  1147. * @return {?}
  1148. */
  1149. (a, b) => {
  1150. return this.sortComparator ? this.sortComparator(a, b, options) :
  1151. options.indexOf(a) - options.indexOf(b);
  1152. }));
  1153. this.stateChanges.next();
  1154. }
  1155. }
  1156. /**
  1157. * Emits change event to set the model value.
  1158. * @private
  1159. * @param {?=} fallbackValue
  1160. * @return {?}
  1161. */
  1162. _propagateChanges(fallbackValue) {
  1163. /** @type {?} */
  1164. let valueToEmit = null;
  1165. if (this.multiple) {
  1166. valueToEmit = ((/** @type {?} */ (this.selected))).map((/**
  1167. * @param {?} option
  1168. * @return {?}
  1169. */
  1170. option => option.value));
  1171. }
  1172. else {
  1173. valueToEmit = this.selected ? ((/** @type {?} */ (this.selected))).value : fallbackValue;
  1174. }
  1175. this._value = valueToEmit;
  1176. this.valueChange.emit(valueToEmit);
  1177. this._onChange(valueToEmit);
  1178. this.selectionChange.emit(new MatSelectChange(this, valueToEmit));
  1179. this._changeDetectorRef.markForCheck();
  1180. }
  1181. /**
  1182. * Records option IDs to pass to the aria-owns property.
  1183. * @private
  1184. * @return {?}
  1185. */
  1186. _setOptionIds() {
  1187. this._optionIds = this.options.map((/**
  1188. * @param {?} option
  1189. * @return {?}
  1190. */
  1191. option => option.id)).join(' ');
  1192. }
  1193. /**
  1194. * Highlights the selected item. If no option is selected, it will highlight
  1195. * the first item instead.
  1196. * @private
  1197. * @return {?}
  1198. */
  1199. _highlightCorrectOption() {
  1200. if (this._keyManager) {
  1201. if (this.empty) {
  1202. this._keyManager.setFirstItemActive();
  1203. }
  1204. else {
  1205. this._keyManager.setActiveItem(this._selectionModel.selected[0]);
  1206. }
  1207. }
  1208. }
  1209. /**
  1210. * Scrolls the active option into view.
  1211. * @private
  1212. * @return {?}
  1213. */
  1214. _scrollActiveOptionIntoView() {
  1215. /** @type {?} */
  1216. const activeOptionIndex = this._keyManager.activeItemIndex || 0;
  1217. /** @type {?} */
  1218. const labelCount = _countGroupLabelsBeforeOption(activeOptionIndex, this.options, this.optionGroups);
  1219. this.panel.nativeElement.scrollTop = _getOptionScrollPosition(activeOptionIndex + labelCount, this._getItemHeight(), this.panel.nativeElement.scrollTop, SELECT_PANEL_MAX_HEIGHT);
  1220. }
  1221. /**
  1222. * Focuses the select element.
  1223. * @param {?=} options
  1224. * @return {?}
  1225. */
  1226. focus(options) {
  1227. this._elementRef.nativeElement.focus(options);
  1228. }
  1229. /**
  1230. * Gets the index of the provided option in the option list.
  1231. * @private
  1232. * @param {?} option
  1233. * @return {?}
  1234. */
  1235. _getOptionIndex(option) {
  1236. return this.options.reduce((/**
  1237. * @param {?} result
  1238. * @param {?} current
  1239. * @param {?} index
  1240. * @return {?}
  1241. */
  1242. (result, current, index) => {
  1243. return result === undefined ? (option === current ? index : undefined) : result;
  1244. }), undefined);
  1245. }
  1246. /**
  1247. * Calculates the scroll position and x- and y-offsets of the overlay panel.
  1248. * @private
  1249. * @return {?}
  1250. */
  1251. _calculateOverlayPosition() {
  1252. /** @type {?} */
  1253. const itemHeight = this._getItemHeight();
  1254. /** @type {?} */
  1255. const items = this._getItemCount();
  1256. /** @type {?} */
  1257. const panelHeight = Math.min(items * itemHeight, SELECT_PANEL_MAX_HEIGHT);
  1258. /** @type {?} */
  1259. const scrollContainerHeight = items * itemHeight;
  1260. // The farthest the panel can be scrolled before it hits the bottom
  1261. /** @type {?} */
  1262. const maxScroll = scrollContainerHeight - panelHeight;
  1263. // If no value is selected we open the popup to the first item.
  1264. /** @type {?} */
  1265. let selectedOptionOffset = this.empty ? 0 : (/** @type {?} */ (this._getOptionIndex(this._selectionModel.selected[0])));
  1266. selectedOptionOffset += _countGroupLabelsBeforeOption(selectedOptionOffset, this.options, this.optionGroups);
  1267. // We must maintain a scroll buffer so the selected option will be scrolled to the
  1268. // center of the overlay panel rather than the top.
  1269. /** @type {?} */
  1270. const scrollBuffer = panelHeight / 2;
  1271. this._scrollTop = this._calculateOverlayScroll(selectedOptionOffset, scrollBuffer, maxScroll);
  1272. this._offsetY = this._calculateOverlayOffsetY(selectedOptionOffset, scrollBuffer, maxScroll);
  1273. this._checkOverlayWithinViewport(maxScroll);
  1274. }
  1275. /**
  1276. * Calculates the scroll position of the select's overlay panel.
  1277. *
  1278. * Attempts to center the selected option in the panel. If the option is
  1279. * too high or too low in the panel to be scrolled to the center, it clamps the
  1280. * scroll position to the min or max scroll positions respectively.
  1281. * @param {?} selectedIndex
  1282. * @param {?} scrollBuffer
  1283. * @param {?} maxScroll
  1284. * @return {?}
  1285. */
  1286. _calculateOverlayScroll(selectedIndex, scrollBuffer, maxScroll) {
  1287. /** @type {?} */
  1288. const itemHeight = this._getItemHeight();
  1289. /** @type {?} */
  1290. const optionOffsetFromScrollTop = itemHeight * selectedIndex;
  1291. /** @type {?} */
  1292. const halfOptionHeight = itemHeight / 2;
  1293. // Starts at the optionOffsetFromScrollTop, which scrolls the option to the top of the
  1294. // scroll container, then subtracts the scroll buffer to scroll the option down to
  1295. // the center of the overlay panel. Half the option height must be re-added to the
  1296. // scrollTop so the option is centered based on its middle, not its top edge.
  1297. /** @type {?} */
  1298. const optimalScrollPosition = optionOffsetFromScrollTop - scrollBuffer + halfOptionHeight;
  1299. return Math.min(Math.max(0, optimalScrollPosition), maxScroll);
  1300. }
  1301. /**
  1302. * Returns the aria-label of the select component.
  1303. * @return {?}
  1304. */
  1305. _getAriaLabel() {
  1306. // If an ariaLabelledby value has been set by the consumer, the select should not overwrite the
  1307. // `aria-labelledby` value by setting the ariaLabel to the placeholder.
  1308. return this.ariaLabelledby ? null : this.ariaLabel || this.placeholder;
  1309. }
  1310. /**
  1311. * Returns the aria-labelledby of the select component.
  1312. * @return {?}
  1313. */
  1314. _getAriaLabelledby() {
  1315. if (this.ariaLabelledby) {
  1316. return this.ariaLabelledby;
  1317. }
  1318. // Note: we use `_getAriaLabel` here, because we want to check whether there's a
  1319. // computed label. `this.ariaLabel` is only the user-specified label.
  1320. if (!this._parentFormField || !this._parentFormField._hasFloatingLabel() ||
  1321. this._getAriaLabel()) {
  1322. return null;
  1323. }
  1324. return this._parentFormField._labelId || null;
  1325. }
  1326. /**
  1327. * Determines the `aria-activedescendant` to be set on the host.
  1328. * @return {?}
  1329. */
  1330. _getAriaActiveDescendant() {
  1331. if (this.panelOpen && this._keyManager && this._keyManager.activeItem) {
  1332. return this._keyManager.activeItem.id;
  1333. }
  1334. return null;
  1335. }
  1336. /**
  1337. * Sets the x-offset of the overlay panel in relation to the trigger's top start corner.
  1338. * This must be adjusted to align the selected option text over the trigger text when
  1339. * the panel opens. Will change based on LTR or RTL text direction. Note that the offset
  1340. * can't be calculated until the panel has been attached, because we need to know the
  1341. * content width in order to constrain the panel within the viewport.
  1342. * @private
  1343. * @return {?}
  1344. */
  1345. _calculateOverlayOffsetX() {
  1346. /** @type {?} */
  1347. const overlayRect = this.overlayDir.overlayRef.overlayElement.getBoundingClientRect();
  1348. /** @type {?} */
  1349. const viewportSize = this._viewportRuler.getViewportSize();
  1350. /** @type {?} */
  1351. const isRtl = this._isRtl();
  1352. /** @type {?} */
  1353. const paddingWidth = this.multiple ? SELECT_MULTIPLE_PANEL_PADDING_X + SELECT_PANEL_PADDING_X :
  1354. SELECT_PANEL_PADDING_X * 2;
  1355. /** @type {?} */
  1356. let offsetX;
  1357. // Adjust the offset, depending on the option padding.
  1358. if (this.multiple) {
  1359. offsetX = SELECT_MULTIPLE_PANEL_PADDING_X;
  1360. }
  1361. else {
  1362. /** @type {?} */
  1363. let selected = this._selectionModel.selected[0] || this.options.first;
  1364. offsetX = selected && selected.group ? SELECT_PANEL_INDENT_PADDING_X : SELECT_PANEL_PADDING_X;
  1365. }
  1366. // Invert the offset in LTR.
  1367. if (!isRtl) {
  1368. offsetX *= -1;
  1369. }
  1370. // Determine how much the select overflows on each side.
  1371. /** @type {?} */
  1372. const leftOverflow = 0 - (overlayRect.left + offsetX - (isRtl ? paddingWidth : 0));
  1373. /** @type {?} */
  1374. const rightOverflow = overlayRect.right + offsetX - viewportSize.width
  1375. + (isRtl ? 0 : paddingWidth);
  1376. // If the element overflows on either side, reduce the offset to allow it to fit.
  1377. if (leftOverflow > 0) {
  1378. offsetX += leftOverflow + SELECT_PANEL_VIEWPORT_PADDING;
  1379. }
  1380. else if (rightOverflow > 0) {
  1381. offsetX -= rightOverflow + SELECT_PANEL_VIEWPORT_PADDING;
  1382. }
  1383. // Set the offset directly in order to avoid having to go through change detection and
  1384. // potentially triggering "changed after it was checked" errors. Round the value to avoid
  1385. // blurry content in some browsers.
  1386. this.overlayDir.offsetX = Math.round(offsetX);
  1387. this.overlayDir.overlayRef.updatePosition();
  1388. }
  1389. /**
  1390. * Calculates the y-offset of the select's overlay panel in relation to the
  1391. * top start corner of the trigger. It has to be adjusted in order for the
  1392. * selected option to be aligned over the trigger when the panel opens.
  1393. * @private
  1394. * @param {?} selectedIndex
  1395. * @param {?} scrollBuffer
  1396. * @param {?} maxScroll
  1397. * @return {?}
  1398. */
  1399. _calculateOverlayOffsetY(selectedIndex, scrollBuffer, maxScroll) {
  1400. /** @type {?} */
  1401. const itemHeight = this._getItemHeight();
  1402. /** @type {?} */
  1403. const optionHeightAdjustment = (itemHeight - this._triggerRect.height) / 2;
  1404. /** @type {?} */
  1405. const maxOptionsDisplayed = Math.floor(SELECT_PANEL_MAX_HEIGHT / itemHeight);
  1406. /** @type {?} */
  1407. let optionOffsetFromPanelTop;
  1408. // Disable offset if requested by user by returning 0 as value to offset
  1409. if (this._disableOptionCentering) {
  1410. return 0;
  1411. }
  1412. if (this._scrollTop === 0) {
  1413. optionOffsetFromPanelTop = selectedIndex * itemHeight;
  1414. }
  1415. else if (this._scrollTop === maxScroll) {
  1416. /** @type {?} */
  1417. const firstDisplayedIndex = this._getItemCount() - maxOptionsDisplayed;
  1418. /** @type {?} */
  1419. const selectedDisplayIndex = selectedIndex - firstDisplayedIndex;
  1420. // The first item is partially out of the viewport. Therefore we need to calculate what
  1421. // portion of it is shown in the viewport and account for it in our offset.
  1422. /** @type {?} */
  1423. let partialItemHeight = itemHeight - (this._getItemCount() * itemHeight - SELECT_PANEL_MAX_HEIGHT) % itemHeight;
  1424. // Because the panel height is longer than the height of the options alone,
  1425. // there is always extra padding at the top or bottom of the panel. When
  1426. // scrolled to the very bottom, this padding is at the top of the panel and
  1427. // must be added to the offset.
  1428. optionOffsetFromPanelTop = selectedDisplayIndex * itemHeight + partialItemHeight;
  1429. }
  1430. else {
  1431. // If the option was scrolled to the middle of the panel using a scroll buffer,
  1432. // its offset will be the scroll buffer minus the half height that was added to
  1433. // center it.
  1434. optionOffsetFromPanelTop = scrollBuffer - itemHeight / 2;
  1435. }
  1436. // The final offset is the option's offset from the top, adjusted for the height difference,
  1437. // multiplied by -1 to ensure that the overlay moves in the correct direction up the page.
  1438. // The value is rounded to prevent some browsers from blurring the content.
  1439. return Math.round(optionOffsetFromPanelTop * -1 - optionHeightAdjustment);
  1440. }
  1441. /**
  1442. * Checks that the attempted overlay position will fit within the viewport.
  1443. * If it will not fit, tries to adjust the scroll position and the associated
  1444. * y-offset so the panel can open fully on-screen. If it still won't fit,
  1445. * sets the offset back to 0 to allow the fallback position to take over.
  1446. * @private
  1447. * @param {?} maxScroll
  1448. * @return {?}
  1449. */
  1450. _checkOverlayWithinViewport(maxScroll) {
  1451. /** @type {?} */
  1452. const itemHeight = this._getItemHeight();
  1453. /** @type {?} */
  1454. const viewportSize = this._viewportRuler.getViewportSize();
  1455. /** @type {?} */
  1456. const topSpaceAvailable = this._triggerRect.top - SELECT_PANEL_VIEWPORT_PADDING;
  1457. /** @type {?} */
  1458. const bottomSpaceAvailable = viewportSize.height - this._triggerRect.bottom - SELECT_PANEL_VIEWPORT_PADDING;
  1459. /** @type {?} */
  1460. const panelHeightTop = Math.abs(this._offsetY);
  1461. /** @type {?} */
  1462. const totalPanelHeight = Math.min(this._getItemCount() * itemHeight, SELECT_PANEL_MAX_HEIGHT);
  1463. /** @type {?} */
  1464. const panelHeightBottom = totalPanelHeight - panelHeightTop - this._triggerRect.height;
  1465. if (panelHeightBottom > bottomSpaceAvailable) {
  1466. this._adjustPanelUp(panelHeightBottom, bottomSpaceAvailable);
  1467. }
  1468. else if (panelHeightTop > topSpaceAvailable) {
  1469. this._adjustPanelDown(panelHeightTop, topSpaceAvailable, maxScroll);
  1470. }
  1471. else {
  1472. this._transformOrigin = this._getOriginBasedOnOption();
  1473. }
  1474. }
  1475. /**
  1476. * Adjusts the overlay panel up to fit in the viewport.
  1477. * @private
  1478. * @param {?} panelHeightBottom
  1479. * @param {?} bottomSpaceAvailable
  1480. * @return {?}
  1481. */
  1482. _adjustPanelUp(panelHeightBottom, bottomSpaceAvailable) {
  1483. // Browsers ignore fractional scroll offsets, so we need to round.
  1484. /** @type {?} */
  1485. const distanceBelowViewport = Math.round(panelHeightBottom - bottomSpaceAvailable);
  1486. // Scrolls the panel up by the distance it was extending past the boundary, then
  1487. // adjusts the offset by that amount to move the panel up into the viewport.
  1488. this._scrollTop -= distanceBelowViewport;
  1489. this._offsetY -= distanceBelowViewport;
  1490. this._transformOrigin = this._getOriginBasedOnOption();
  1491. // If the panel is scrolled to the very top, it won't be able to fit the panel
  1492. // by scrolling, so set the offset to 0 to allow the fallback position to take
  1493. // effect.
  1494. if (this._scrollTop <= 0) {
  1495. this._scrollTop = 0;
  1496. this._offsetY = 0;
  1497. this._transformOrigin = `50% bottom 0px`;
  1498. }
  1499. }
  1500. /**
  1501. * Adjusts the overlay panel down to fit in the viewport.
  1502. * @private
  1503. * @param {?} panelHeightTop
  1504. * @param {?} topSpaceAvailable
  1505. * @param {?} maxScroll
  1506. * @return {?}
  1507. */
  1508. _adjustPanelDown(panelHeightTop, topSpaceAvailable, maxScroll) {
  1509. // Browsers ignore fractional scroll offsets, so we need to round.
  1510. /** @type {?} */
  1511. const distanceAboveViewport = Math.round(panelHeightTop - topSpaceAvailable);
  1512. // Scrolls the panel down by the distance it was extending past the boundary, then
  1513. // adjusts the offset by that amount to move the panel down into the viewport.
  1514. this._scrollTop += distanceAboveViewport;
  1515. this._offsetY += distanceAboveViewport;
  1516. this._transformOrigin = this._getOriginBasedOnOption();
  1517. // If the panel is scrolled to the very bottom, it won't be able to fit the
  1518. // panel by scrolling, so set the offset to 0 to allow the fallback position
  1519. // to take effect.
  1520. if (this._scrollTop >= maxScroll) {
  1521. this._scrollTop = maxScroll;
  1522. this._offsetY = 0;
  1523. this._transformOrigin = `50% top 0px`;
  1524. return;
  1525. }
  1526. }
  1527. /**
  1528. * Sets the transform origin point based on the selected option.
  1529. * @private
  1530. * @return {?}
  1531. */
  1532. _getOriginBasedOnOption() {
  1533. /** @type {?} */
  1534. const itemHeight = this._getItemHeight();
  1535. /** @type {?} */
  1536. const optionHeightAdjustment = (itemHeight - this._triggerRect.height) / 2;
  1537. /** @type {?} */
  1538. const originY = Math.abs(this._offsetY) - optionHeightAdjustment + itemHeight / 2;
  1539. return `50% ${originY}px 0px`;
  1540. }
  1541. /**
  1542. * Calculates the amount of items in the select. This includes options and group labels.
  1543. * @private
  1544. * @return {?}
  1545. */
  1546. _getItemCount() {
  1547. return this.options.length + this.optionGroups.length;
  1548. }
  1549. /**
  1550. * Calculates the height of the select's options.
  1551. * @private
  1552. * @return {?}
  1553. */
  1554. _getItemHeight() {
  1555. return this._triggerFontSize * SELECT_ITEM_HEIGHT_EM;
  1556. }
  1557. /**
  1558. * Implemented as part of MatFormFieldControl.
  1559. * \@docs-private
  1560. * @param {?} ids
  1561. * @return {?}
  1562. */
  1563. setDescribedByIds(ids) {
  1564. this._ariaDescribedby = ids.join(' ');
  1565. }
  1566. /**
  1567. * Implemented as part of MatFormFieldControl.
  1568. * \@docs-private
  1569. * @return {?}
  1570. */
  1571. onContainerClick() {
  1572. this.focus();
  1573. this.open();
  1574. }
  1575. /**
  1576. * Implemented as part of MatFormFieldControl.
  1577. * \@docs-private
  1578. * @return {?}
  1579. */
  1580. get shouldLabelFloat() {
  1581. return this._panelOpen || !this.empty;
  1582. }
  1583. }
  1584. MatSelect.decorators = [
  1585. { type: Component, args: [{selector: 'mat-select',
  1586. exportAs: 'matSelect',
  1587. template: "<div cdk-overlay-origin class=\"mat-select-trigger\" aria-hidden=\"true\" (click)=\"toggle()\" #origin=\"cdkOverlayOrigin\" #trigger><div class=\"mat-select-value\" [ngSwitch]=\"empty\"><span class=\"mat-select-placeholder\" *ngSwitchCase=\"true\">{{placeholder || '\u00A0'}}</span> <span class=\"mat-select-value-text\" *ngSwitchCase=\"false\" [ngSwitch]=\"!!customTrigger\"><span *ngSwitchDefault>{{triggerValue || '\u00A0'}}</span><ng-content select=\"mat-select-trigger\" *ngSwitchCase=\"true\"></ng-content></span></div><div class=\"mat-select-arrow-wrapper\"><div class=\"mat-select-arrow\"></div></div></div><ng-template cdk-connected-overlay cdkConnectedOverlayLockPosition cdkConnectedOverlayHasBackdrop cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\" [cdkConnectedOverlayScrollStrategy]=\"_scrollStrategy\" [cdkConnectedOverlayOrigin]=\"origin\" [cdkConnectedOverlayOpen]=\"panelOpen\" [cdkConnectedOverlayPositions]=\"_positions\" [cdkConnectedOverlayMinWidth]=\"_triggerRect?.width\" [cdkConnectedOverlayOffsetY]=\"_offsetY\" (backdropClick)=\"close()\" (attach)=\"_onAttached()\" (detach)=\"close()\"><div class=\"mat-select-panel-wrap\" [@transformPanelWrap]><div #panel class=\"mat-select-panel {{ _getPanelTheme() }}\" [ngClass]=\"panelClass\" [@transformPanel]=\"multiple ? 'showing-multiple' : 'showing'\" (@transformPanel.done)=\"_panelDoneAnimatingStream.next($event.toState)\" [style.transformOrigin]=\"_transformOrigin\" [style.font-size.px]=\"_triggerFontSize\" (keydown)=\"_handleKeydown($event)\"><ng-content></ng-content></div></div></ng-template>",
  1588. styles: [".mat-select{display:inline-block;width:100%;outline:0}.mat-select-trigger{display:inline-table;cursor:pointer;position:relative;box-sizing:border-box}.mat-select-disabled .mat-select-trigger{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.mat-select-value{display:table-cell;max-width:0;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mat-select-value-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mat-select-arrow-wrapper{display:table-cell;vertical-align:middle}.mat-form-field-appearance-fill .mat-select-arrow-wrapper{transform:translateY(-50%)}.mat-form-field-appearance-outline .mat-select-arrow-wrapper{transform:translateY(-25%)}.mat-form-field-appearance-standard.mat-form-field-has-label .mat-select:not(.mat-select-empty) .mat-select-arrow-wrapper{transform:translateY(-50%)}.mat-form-field-appearance-standard .mat-select.mat-select-empty .mat-select-arrow-wrapper{transition:transform .4s cubic-bezier(.25,.8,.25,1)}._mat-animation-noopable.mat-form-field-appearance-standard .mat-select.mat-select-empty .mat-select-arrow-wrapper{transition:none}.mat-select-arrow{width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid;margin:0 4px}.mat-select-panel-wrap{flex-basis:100%}.mat-select-panel{min-width:112px;max-width:280px;overflow:auto;-webkit-overflow-scrolling:touch;padding-top:0;padding-bottom:0;max-height:256px;min-width:100%;border-radius:4px}@media (-ms-high-contrast:active){.mat-select-panel{outline:solid 1px}}.mat-select-panel .mat-optgroup-label,.mat-select-panel .mat-option{font-size:inherit;line-height:3em;height:3em}.mat-form-field-type-mat-select:not(.mat-form-field-disabled) .mat-form-field-flex{cursor:pointer}.mat-form-field-type-mat-select .mat-form-field-label{width:calc(100% - 18px)}.mat-select-placeholder{transition:color .4s .133s cubic-bezier(.25,.8,.25,1)}._mat-animation-noopable .mat-select-placeholder{transition:none}.mat-form-field-hide-placeholder .mat-select-placeholder{color:transparent;-webkit-text-fill-color:transparent;transition:none;display:block}"],
  1589. inputs: ['disabled', 'disableRipple', 'tabIndex'],
  1590. encapsulation: ViewEncapsulation.None,
  1591. changeDetection: ChangeDetectionStrategy.OnPush,
  1592. host: {
  1593. 'role': 'listbox',
  1594. '[attr.id]': 'id',
  1595. '[attr.tabindex]': 'tabIndex',
  1596. '[attr.aria-label]': '_getAriaLabel()',
  1597. '[attr.aria-labelledby]': '_getAriaLabelledby()',
  1598. '[attr.aria-required]': 'required.toString()',
  1599. '[attr.aria-disabled]': 'disabled.toString()',
  1600. '[attr.aria-invalid]': 'errorState',
  1601. '[attr.aria-owns]': 'panelOpen ? _optionIds : null',
  1602. '[attr.aria-multiselectable]': 'multiple',
  1603. '[attr.aria-describedby]': '_ariaDescribedby || null',
  1604. '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
  1605. '[class.mat-select-disabled]': 'disabled',
  1606. '[class.mat-select-invalid]': 'errorState',
  1607. '[class.mat-select-required]': 'required',
  1608. '[class.mat-select-empty]': 'empty',
  1609. 'class': 'mat-select',
  1610. '(keydown)': '_handleKeydown($event)',
  1611. '(focus)': '_onFocus()',
  1612. '(blur)': '_onBlur()',
  1613. },
  1614. animations: [
  1615. matSelectAnimations.transformPanelWrap,
  1616. matSelectAnimations.transformPanel
  1617. ],
  1618. providers: [
  1619. { provide: MatFormFieldControl, useExisting: MatSelect },
  1620. { provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatSelect }
  1621. ],
  1622. },] },
  1623. ];
  1624. /** @nocollapse */
  1625. MatSelect.ctorParameters = () => [
  1626. { type: ViewportRuler },
  1627. { type: ChangeDetectorRef },
  1628. { type: NgZone },
  1629. { type: ErrorStateMatcher },
  1630. { type: ElementRef },
  1631. { type: Directionality, decorators: [{ type: Optional }] },
  1632. { type: NgForm, decorators: [{ type: Optional }] },
  1633. { type: FormGroupDirective, decorators: [{ type: Optional }] },
  1634. { type: MatFormField, decorators: [{ type: Optional }] },
  1635. { type: NgControl, decorators: [{ type: Self }, { type: Optional }] },
  1636. { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
  1637. { type: undefined, decorators: [{ type: Inject, args: [MAT_SELECT_SCROLL_STRATEGY,] }] },
  1638. { type: LiveAnnouncer }
  1639. ];
  1640. MatSelect.propDecorators = {
  1641. trigger: [{ type: ViewChild, args: ['trigger', { static: false },] }],
  1642. panel: [{ type: ViewChild, args: ['panel', { static: false },] }],
  1643. overlayDir: [{ type: ViewChild, args: [CdkConnectedOverlay, { static: false },] }],
  1644. options: [{ type: ContentChildren, args: [MatOption, { descendants: true },] }],
  1645. optionGroups: [{ type: ContentChildren, args: [MatOptgroup,] }],
  1646. panelClass: [{ type: Input }],
  1647. customTrigger: [{ type: ContentChild, args: [MatSelectTrigger, { static: false },] }],
  1648. placeholder: [{ type: Input }],
  1649. required: [{ type: Input }],
  1650. multiple: [{ type: Input }],
  1651. disableOptionCentering: [{ type: Input }],
  1652. compareWith: [{ type: Input }],
  1653. value: [{ type: Input }],
  1654. ariaLabel: [{ type: Input, args: ['aria-label',] }],
  1655. ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
  1656. errorStateMatcher: [{ type: Input }],
  1657. sortComparator: [{ type: Input }],
  1658. id: [{ type: Input }],
  1659. openedChange: [{ type: Output }],
  1660. _openedStream: [{ type: Output, args: ['opened',] }],
  1661. _closedStream: [{ type: Output, args: ['closed',] }],
  1662. selectionChange: [{ type: Output }],
  1663. valueChange: [{ type: Output }]
  1664. };
  1665. /**
  1666. * @fileoverview added by tsickle
  1667. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1668. */
  1669. class MatSelectModule {
  1670. }
  1671. MatSelectModule.decorators = [
  1672. { type: NgModule, args: [{
  1673. imports: [
  1674. CommonModule,
  1675. OverlayModule,
  1676. MatOptionModule,
  1677. MatCommonModule,
  1678. ],
  1679. exports: [MatFormFieldModule, MatSelect, MatSelectTrigger, MatOptionModule, MatCommonModule],
  1680. declarations: [MatSelect, MatSelectTrigger],
  1681. providers: [MAT_SELECT_SCROLL_STRATEGY_PROVIDER]
  1682. },] },
  1683. ];
  1684. /**
  1685. * @fileoverview added by tsickle
  1686. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1687. */
  1688. /**
  1689. * @fileoverview added by tsickle
  1690. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1691. */
  1692. export { MatSelectModule, MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY, SELECT_PANEL_MAX_HEIGHT, SELECT_PANEL_PADDING_X, SELECT_PANEL_INDENT_PADDING_X, SELECT_ITEM_HEIGHT_EM, SELECT_MULTIPLE_PANEL_PADDING_X, SELECT_PANEL_VIEWPORT_PADDING, MAT_SELECT_SCROLL_STRATEGY, MAT_SELECT_SCROLL_STRATEGY_PROVIDER, MatSelectChange, MatSelectTrigger, MatSelect, matSelectAnimations, transformPanel, fadeInContent };
  1693. //# sourceMappingURL=select.js.map