index.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import { _AbstractConstructor } from '@angular/material/core';
  2. import { AfterContentInit } from '@angular/core';
  3. import { AfterViewInit } from '@angular/core';
  4. import { BooleanInput } from '@angular/cdk/coercion';
  5. import { CanDisableRipple } from '@angular/material/core';
  6. import { ChangeDetectorRef } from '@angular/core';
  7. import { _Constructor } from '@angular/material/core';
  8. import { ControlValueAccessor } from '@angular/forms';
  9. import { ElementRef } from '@angular/core';
  10. import { EventEmitter } from '@angular/core';
  11. import { FocusMonitor } from '@angular/cdk/a11y';
  12. import * as i0 from '@angular/core';
  13. import * as i2 from '@angular/material/core';
  14. import { InjectionToken } from '@angular/core';
  15. import { OnDestroy } from '@angular/core';
  16. import { OnInit } from '@angular/core';
  17. import { QueryList } from '@angular/core';
  18. declare namespace i1 {
  19. export {
  20. ToggleType,
  21. MatButtonToggleAppearance,
  22. MatButtonToggleDefaultOptions,
  23. MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS,
  24. MAT_BUTTON_TOGGLE_GROUP,
  25. MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,
  26. MatButtonToggleChange,
  27. MatButtonToggleGroup,
  28. MatButtonToggle
  29. }
  30. }
  31. /**
  32. * Injection token that can be used to configure the
  33. * default options for all button toggles within an app.
  34. */
  35. export declare const MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS: InjectionToken<MatButtonToggleDefaultOptions>;
  36. /**
  37. * Injection token that can be used to reference instances of `MatButtonToggleGroup`.
  38. * It serves as alternative token to the actual `MatButtonToggleGroup` class which
  39. * could cause unnecessary retention of the class and its component metadata.
  40. */
  41. export declare const MAT_BUTTON_TOGGLE_GROUP: InjectionToken<MatButtonToggleGroup>;
  42. /**
  43. * Provider Expression that allows mat-button-toggle-group to register as a ControlValueAccessor.
  44. * This allows it to support [(ngModel)].
  45. * @docs-private
  46. */
  47. export declare const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any;
  48. /** Single button inside of a toggle group. */
  49. export declare class MatButtonToggle extends _MatButtonToggleBase implements OnInit, AfterViewInit, CanDisableRipple, OnDestroy {
  50. private _changeDetectorRef;
  51. private _elementRef;
  52. private _focusMonitor;
  53. private _checked;
  54. /**
  55. * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
  56. * take precedence so this may be omitted.
  57. */
  58. ariaLabel: string;
  59. /**
  60. * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
  61. */
  62. ariaLabelledby: string | null;
  63. /** Underlying native `button` element. */
  64. _buttonElement: ElementRef<HTMLButtonElement>;
  65. /** The parent button toggle group (exclusive selection). Optional. */
  66. buttonToggleGroup: MatButtonToggleGroup;
  67. /** Unique ID for the underlying `button` element. */
  68. get buttonId(): string;
  69. /** The unique ID for this button toggle. */
  70. id: string;
  71. /** HTML's 'name' attribute used to group radios for unique selection. */
  72. name: string;
  73. /** MatButtonToggleGroup reads this to assign its own value. */
  74. value: any;
  75. /** Tabindex for the toggle. */
  76. tabIndex: number | null;
  77. /** The appearance style of the button. */
  78. get appearance(): MatButtonToggleAppearance;
  79. set appearance(value: MatButtonToggleAppearance);
  80. private _appearance;
  81. /** Whether the button is checked. */
  82. get checked(): boolean;
  83. set checked(value: BooleanInput);
  84. /** Whether the button is disabled. */
  85. get disabled(): boolean;
  86. set disabled(value: BooleanInput);
  87. private _disabled;
  88. /** Event emitted when the group value changes. */
  89. readonly change: EventEmitter<MatButtonToggleChange>;
  90. constructor(toggleGroup: MatButtonToggleGroup, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, _focusMonitor: FocusMonitor, defaultTabIndex: string, defaultOptions?: MatButtonToggleDefaultOptions);
  91. ngOnInit(): void;
  92. ngAfterViewInit(): void;
  93. ngOnDestroy(): void;
  94. /** Focuses the button. */
  95. focus(options?: FocusOptions): void;
  96. /** Checks the button toggle due to an interaction with the underlying native button. */
  97. _onButtonClick(): void;
  98. /**
  99. * Marks the button toggle as needing checking for change detection.
  100. * This method is exposed because the parent button toggle group will directly
  101. * update bound properties of the radio button.
  102. */
  103. _markForCheck(): void;
  104. /** Gets the name that should be assigned to the inner DOM node. */
  105. _getButtonName(): string | null;
  106. /** Whether the toggle is in single selection mode. */
  107. private _isSingleSelector;
  108. static ɵfac: i0.ɵɵFactoryDeclaration<MatButtonToggle, [{ optional: true; }, null, null, null, { attribute: "tabindex"; }, { optional: true; }]>;
  109. static ɵcmp: i0.ɵɵComponentDeclaration<MatButtonToggle, "mat-button-toggle", ["matButtonToggle"], { "disableRipple": { "alias": "disableRipple"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "id": { "alias": "id"; "required": false; }; "name": { "alias": "name"; "required": false; }; "value": { "alias": "value"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; "checked": { "alias": "checked"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "change": "change"; }, never, ["*"], false, never>;
  110. }
  111. /** Possible appearance styles for the button toggle. */
  112. export declare type MatButtonToggleAppearance = 'legacy' | 'standard';
  113. /** @docs-private */
  114. declare const _MatButtonToggleBase: _Constructor<CanDisableRipple> & _AbstractConstructor<CanDisableRipple> & {
  115. new (): {};
  116. };
  117. /** Change event object emitted by button toggle. */
  118. export declare class MatButtonToggleChange {
  119. /** The button toggle that emits the event. */
  120. source: MatButtonToggle;
  121. /** The value assigned to the button toggle. */
  122. value: any;
  123. constructor(
  124. /** The button toggle that emits the event. */
  125. source: MatButtonToggle,
  126. /** The value assigned to the button toggle. */
  127. value: any);
  128. }
  129. /**
  130. * Represents the default options for the button toggle that can be configured
  131. * using the `MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS` injection token.
  132. */
  133. export declare interface MatButtonToggleDefaultOptions {
  134. /**
  135. * Default appearance to be used by button toggles. Can be overridden by explicitly
  136. * setting an appearance on a button toggle or group.
  137. */
  138. appearance?: MatButtonToggleAppearance;
  139. }
  140. /** Exclusive selection button toggle group that behaves like a radio-button group. */
  141. export declare class MatButtonToggleGroup implements ControlValueAccessor, OnInit, AfterContentInit {
  142. private _changeDetector;
  143. private _vertical;
  144. private _multiple;
  145. private _disabled;
  146. private _selectionModel;
  147. /**
  148. * Reference to the raw value that the consumer tried to assign. The real
  149. * value will exclude any values from this one that don't correspond to a
  150. * toggle. Useful for the cases where the value is assigned before the toggles
  151. * have been initialized or at the same that they're being swapped out.
  152. */
  153. private _rawValue;
  154. /**
  155. * The method to be called in order to update ngModel.
  156. * Now `ngModel` binding is not supported in multiple selection mode.
  157. */
  158. _controlValueAccessorChangeFn: (value: any) => void;
  159. /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
  160. _onTouched: () => any;
  161. /** Child button toggle buttons. */
  162. _buttonToggles: QueryList<MatButtonToggle>;
  163. /** The appearance for all the buttons in the group. */
  164. appearance: MatButtonToggleAppearance;
  165. /** `name` attribute for the underlying `input` element. */
  166. get name(): string;
  167. set name(value: string);
  168. private _name;
  169. /** Whether the toggle group is vertical. */
  170. get vertical(): boolean;
  171. set vertical(value: BooleanInput);
  172. /** Value of the toggle group. */
  173. get value(): any;
  174. set value(newValue: any);
  175. /**
  176. * Event that emits whenever the value of the group changes.
  177. * Used to facilitate two-way data binding.
  178. * @docs-private
  179. */
  180. readonly valueChange: EventEmitter<any>;
  181. /** Selected button toggles in the group. */
  182. get selected(): MatButtonToggle | MatButtonToggle[];
  183. /** Whether multiple button toggles can be selected. */
  184. get multiple(): boolean;
  185. set multiple(value: BooleanInput);
  186. /** Whether multiple button toggle group is disabled. */
  187. get disabled(): boolean;
  188. set disabled(value: BooleanInput);
  189. /** Event emitted when the group's value changes. */
  190. readonly change: EventEmitter<MatButtonToggleChange>;
  191. constructor(_changeDetector: ChangeDetectorRef, defaultOptions?: MatButtonToggleDefaultOptions);
  192. ngOnInit(): void;
  193. ngAfterContentInit(): void;
  194. /**
  195. * Sets the model value. Implemented as part of ControlValueAccessor.
  196. * @param value Value to be set to the model.
  197. */
  198. writeValue(value: any): void;
  199. registerOnChange(fn: (value: any) => void): void;
  200. registerOnTouched(fn: any): void;
  201. setDisabledState(isDisabled: boolean): void;
  202. /** Dispatch change event with current selection and group value. */
  203. _emitChangeEvent(toggle: MatButtonToggle): void;
  204. /**
  205. * Syncs a button toggle's selected state with the model value.
  206. * @param toggle Toggle to be synced.
  207. * @param select Whether the toggle should be selected.
  208. * @param isUserInput Whether the change was a result of a user interaction.
  209. * @param deferEvents Whether to defer emitting the change events.
  210. */
  211. _syncButtonToggle(toggle: MatButtonToggle, select: boolean, isUserInput?: boolean, deferEvents?: boolean): void;
  212. /** Checks whether a button toggle is selected. */
  213. _isSelected(toggle: MatButtonToggle): boolean;
  214. /** Determines whether a button toggle should be checked on init. */
  215. _isPrechecked(toggle: MatButtonToggle): boolean;
  216. /** Updates the selection state of the toggles in the group based on a value. */
  217. private _setSelectionByValue;
  218. /** Clears the selected toggles. */
  219. private _clearSelection;
  220. /** Selects a value if there's a toggle that corresponds to it. */
  221. private _selectValue;
  222. /** Syncs up the group's value with the model and emits the change event. */
  223. private _updateModelValue;
  224. /** Marks all of the child button toggles to be checked. */
  225. private _markButtonsForCheck;
  226. static ɵfac: i0.ɵɵFactoryDeclaration<MatButtonToggleGroup, [null, { optional: true; }]>;
  227. static ɵdir: i0.ɵɵDirectiveDeclaration<MatButtonToggleGroup, "mat-button-toggle-group", ["matButtonToggleGroup"], { "appearance": { "alias": "appearance"; "required": false; }; "name": { "alias": "name"; "required": false; }; "vertical": { "alias": "vertical"; "required": false; }; "value": { "alias": "value"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "valueChange": "valueChange"; "change": "change"; }, ["_buttonToggles"], never, false, never>;
  228. }
  229. export declare class MatButtonToggleModule {
  230. static ɵfac: i0.ɵɵFactoryDeclaration<MatButtonToggleModule, never>;
  231. static ɵmod: i0.ɵɵNgModuleDeclaration<MatButtonToggleModule, [typeof i1.MatButtonToggleGroup, typeof i1.MatButtonToggle], [typeof i2.MatCommonModule, typeof i2.MatRippleModule], [typeof i2.MatCommonModule, typeof i1.MatButtonToggleGroup, typeof i1.MatButtonToggle]>;
  232. static ɵinj: i0.ɵɵInjectorDeclaration<MatButtonToggleModule>;
  233. }
  234. /**
  235. * @deprecated No longer used.
  236. * @breaking-change 11.0.0
  237. */
  238. export declare type ToggleType = 'checkbox' | 'radio';
  239. export { }