autocomplete.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
  9. import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, InjectionToken, QueryList, TemplateRef } from '@angular/core';
  10. import { CanDisableRipple, CanDisableRippleCtor, MatOptgroup, MatOption } from '@angular/material/core';
  11. /** Event object that is emitted when an autocomplete option is selected. */
  12. export declare class MatAutocompleteSelectedEvent {
  13. /** Reference to the autocomplete panel that emitted the event. */
  14. source: MatAutocomplete;
  15. /** Option that was selected. */
  16. option: MatOption;
  17. constructor(
  18. /** Reference to the autocomplete panel that emitted the event. */
  19. source: MatAutocomplete,
  20. /** Option that was selected. */
  21. option: MatOption);
  22. }
  23. /** @docs-private */
  24. declare class MatAutocompleteBase {
  25. }
  26. declare const _MatAutocompleteMixinBase: CanDisableRippleCtor & typeof MatAutocompleteBase;
  27. /** Default `mat-autocomplete` options that can be overridden. */
  28. export interface MatAutocompleteDefaultOptions {
  29. /** Whether the first option should be highlighted when an autocomplete panel is opened. */
  30. autoActiveFirstOption?: boolean;
  31. }
  32. /** Injection token to be used to override the default options for `mat-autocomplete`. */
  33. export declare const MAT_AUTOCOMPLETE_DEFAULT_OPTIONS: InjectionToken<MatAutocompleteDefaultOptions>;
  34. /** @docs-private */
  35. export declare function MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY(): MatAutocompleteDefaultOptions;
  36. export declare class MatAutocomplete extends _MatAutocompleteMixinBase implements AfterContentInit, CanDisableRipple {
  37. private _changeDetectorRef;
  38. private _elementRef;
  39. /** Manages active item in option list based on key events. */
  40. _keyManager: ActiveDescendantKeyManager<MatOption>;
  41. /** Whether the autocomplete panel should be visible, depending on option length. */
  42. showPanel: boolean;
  43. /** Whether the autocomplete panel is open. */
  44. readonly isOpen: boolean;
  45. _isOpen: boolean;
  46. /** @docs-private */
  47. template: TemplateRef<any>;
  48. /** Element for the panel containing the autocomplete options. */
  49. panel: ElementRef;
  50. /** @docs-private */
  51. options: QueryList<MatOption>;
  52. /** @docs-private */
  53. optionGroups: QueryList<MatOptgroup>;
  54. /** Function that maps an option's control value to its display value in the trigger. */
  55. displayWith: ((value: any) => string) | null;
  56. /**
  57. * Whether the first option should be highlighted when the autocomplete panel is opened.
  58. * Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.
  59. */
  60. autoActiveFirstOption: boolean;
  61. private _autoActiveFirstOption;
  62. /**
  63. * Specify the width of the autocomplete panel. Can be any CSS sizing value, otherwise it will
  64. * match the width of its host.
  65. */
  66. panelWidth: string | number;
  67. /** Event that is emitted whenever an option from the list is selected. */
  68. readonly optionSelected: EventEmitter<MatAutocompleteSelectedEvent>;
  69. /** Event that is emitted when the autocomplete panel is opened. */
  70. readonly opened: EventEmitter<void>;
  71. /** Event that is emitted when the autocomplete panel is closed. */
  72. readonly closed: EventEmitter<void>;
  73. /**
  74. * Takes classes set on the host mat-autocomplete element and applies them to the panel
  75. * inside the overlay container to allow for easy styling.
  76. */
  77. classList: string;
  78. _classList: {
  79. [key: string]: boolean;
  80. };
  81. /** Unique ID to be used by autocomplete trigger's "aria-owns" property. */
  82. id: string;
  83. constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, defaults: MatAutocompleteDefaultOptions);
  84. ngAfterContentInit(): void;
  85. /**
  86. * Sets the panel scrollTop. This allows us to manually scroll to display options
  87. * above or below the fold, as they are not actually being focused when active.
  88. */
  89. _setScrollTop(scrollTop: number): void;
  90. /** Returns the panel's scrollTop. */
  91. _getScrollTop(): number;
  92. /** Panel should hide itself when the option list is empty. */
  93. _setVisibility(): void;
  94. /** Emits the `select` event. */
  95. _emitSelectEvent(option: MatOption): void;
  96. /** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
  97. private _setVisibilityClasses;
  98. }
  99. export {};