option.d-BVGX3edu.d.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { FocusableOption, FocusOrigin } from '@angular/cdk/a11y';
  2. import * as i0 from '@angular/core';
  3. import { InjectionToken, AfterViewChecked, OnDestroy, ChangeDetectorRef, EventEmitter, ElementRef, QueryList } from '@angular/core';
  4. import { Subject } from 'rxjs';
  5. /**
  6. * Injection token that can be used to reference instances of `MatOptgroup`. It serves as
  7. * alternative token to the actual `MatOptgroup` class which could cause unnecessary
  8. * retention of the class and its component metadata.
  9. */
  10. declare const MAT_OPTGROUP: InjectionToken<MatOptgroup>;
  11. /**
  12. * Component that is used to group instances of `mat-option`.
  13. */
  14. declare class MatOptgroup {
  15. /** Label for the option group. */
  16. label: string;
  17. /** whether the option group is disabled. */
  18. disabled: boolean;
  19. /** Unique id for the underlying label. */
  20. _labelId: string;
  21. /** Whether the group is in inert a11y mode. */
  22. _inert: boolean;
  23. constructor(...args: unknown[]);
  24. static ɵfac: i0.ɵɵFactoryDeclaration<MatOptgroup, never>;
  25. static ɵcmp: i0.ɵɵComponentDeclaration<MatOptgroup, "mat-optgroup", ["matOptgroup"], { "label": { "alias": "label"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, {}, never, ["*", "mat-option, ng-container"], true, never>;
  26. static ngAcceptInputType_disabled: unknown;
  27. }
  28. /** Event object emitted by MatOption when selected or deselected. */
  29. declare class MatOptionSelectionChange<T = any> {
  30. /** Reference to the option that emitted the event. */
  31. source: MatOption<T>;
  32. /** Whether the change in the option's value was a result of a user action. */
  33. isUserInput: boolean;
  34. constructor(
  35. /** Reference to the option that emitted the event. */
  36. source: MatOption<T>,
  37. /** Whether the change in the option's value was a result of a user action. */
  38. isUserInput?: boolean);
  39. }
  40. /**
  41. * Single option inside of a `<mat-select>` element.
  42. */
  43. declare class MatOption<T = any> implements FocusableOption, AfterViewChecked, OnDestroy {
  44. private _element;
  45. _changeDetectorRef: ChangeDetectorRef;
  46. private _parent;
  47. group: MatOptgroup | null;
  48. private _signalDisableRipple;
  49. private _selected;
  50. private _active;
  51. private _disabled;
  52. private _mostRecentViewValue;
  53. /** Whether the wrapping component is in multiple selection mode. */
  54. get multiple(): boolean | null | undefined;
  55. /** Whether or not the option is currently selected. */
  56. get selected(): boolean;
  57. /** The form value of the option. */
  58. value: T;
  59. /** The unique ID of the option. */
  60. id: string;
  61. /** Whether the option is disabled. */
  62. get disabled(): boolean;
  63. set disabled(value: boolean);
  64. /** Whether ripples for the option are disabled. */
  65. get disableRipple(): boolean;
  66. /** Whether to display checkmark for single-selection. */
  67. get hideSingleSelectionIndicator(): boolean;
  68. /** Event emitted when the option is selected or deselected. */
  69. readonly onSelectionChange: EventEmitter<MatOptionSelectionChange<T>>;
  70. /** Element containing the option's text. */
  71. _text: ElementRef<HTMLElement> | undefined;
  72. /** Emits when the state of the option changes and any parents have to be notified. */
  73. readonly _stateChanges: Subject<void>;
  74. constructor(...args: unknown[]);
  75. /**
  76. * Whether or not the option is currently active and ready to be selected.
  77. * An active option displays styles as if it is focused, but the
  78. * focus is actually retained somewhere else. This comes in handy
  79. * for components like autocomplete where focus must remain on the input.
  80. */
  81. get active(): boolean;
  82. /**
  83. * The displayed value of the option. It is necessary to show the selected option in the
  84. * select's trigger.
  85. */
  86. get viewValue(): string;
  87. /** Selects the option. */
  88. select(emitEvent?: boolean): void;
  89. /** Deselects the option. */
  90. deselect(emitEvent?: boolean): void;
  91. /** Sets focus onto this option. */
  92. focus(_origin?: FocusOrigin, options?: FocusOptions): void;
  93. /**
  94. * This method sets display styles on the option to make it appear
  95. * active. This is used by the ActiveDescendantKeyManager so key
  96. * events will display the proper options as active on arrow key events.
  97. */
  98. setActiveStyles(): void;
  99. /**
  100. * This method removes display styles on the option that made it appear
  101. * active. This is used by the ActiveDescendantKeyManager so key
  102. * events will display the proper options as active on arrow key events.
  103. */
  104. setInactiveStyles(): void;
  105. /** Gets the label to be used when determining whether the option should be focused. */
  106. getLabel(): string;
  107. /** Ensures the option is selected when activated from the keyboard. */
  108. _handleKeydown(event: KeyboardEvent): void;
  109. /**
  110. * `Selects the option while indicating the selection came from the user. Used to
  111. * determine if the select's view -> model callback should be invoked.`
  112. */
  113. _selectViaInteraction(): void;
  114. /** Returns the correct tabindex for the option depending on disabled state. */
  115. _getTabIndex(): string;
  116. /** Gets the host DOM element. */
  117. _getHostElement(): HTMLElement;
  118. ngAfterViewChecked(): void;
  119. ngOnDestroy(): void;
  120. /** Emits the selection change event. */
  121. private _emitSelectionChangeEvent;
  122. static ɵfac: i0.ɵɵFactoryDeclaration<MatOption<any>, never>;
  123. static ɵcmp: i0.ɵɵComponentDeclaration<MatOption<any>, "mat-option", ["matOption"], { "value": { "alias": "value"; "required": false; }; "id": { "alias": "id"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "onSelectionChange": "onSelectionChange"; }, never, ["mat-icon", "*"], true, never>;
  124. static ngAcceptInputType_disabled: unknown;
  125. }
  126. /**
  127. * Counts the amount of option group labels that precede the specified option.
  128. * @param optionIndex Index of the option at which to start counting.
  129. * @param options Flat list of all of the options.
  130. * @param optionGroups Flat list of all of the option groups.
  131. * @docs-private
  132. */
  133. declare function _countGroupLabelsBeforeOption(optionIndex: number, options: QueryList<MatOption>, optionGroups: QueryList<MatOptgroup>): number;
  134. /**
  135. * Determines the position to which to scroll a panel in order for an option to be into view.
  136. * @param optionOffset Offset of the option from the top of the panel.
  137. * @param optionHeight Height of the options.
  138. * @param currentScrollPosition Current scroll position of the panel.
  139. * @param panelHeight Height of the panel.
  140. * @docs-private
  141. */
  142. declare function _getOptionScrollPosition(optionOffset: number, optionHeight: number, currentScrollPosition: number, panelHeight: number): number;
  143. export { MatOption as M, _countGroupLabelsBeforeOption as _, MatOptgroup as a, MatOptionSelectionChange as b, _getOptionScrollPosition as c, MAT_OPTGROUP as d };