index.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 { DoCheck } from '@angular/core';
  10. import { ElementRef } from '@angular/core';
  11. import { EventEmitter } from '@angular/core';
  12. import { FocusMonitor } from '@angular/cdk/a11y';
  13. import { FocusOrigin } from '@angular/cdk/a11y';
  14. import { HasTabIndex } from '@angular/material/core';
  15. import * as i0 from '@angular/core';
  16. import * as i2 from '@angular/material/core';
  17. import * as i3 from '@angular/common';
  18. import { InjectionToken } from '@angular/core';
  19. import { OnDestroy } from '@angular/core';
  20. import { OnInit } from '@angular/core';
  21. import { QueryList } from '@angular/core';
  22. import { ThemePalette } from '@angular/material/core';
  23. import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
  24. declare namespace i1 {
  25. export {
  26. MAT_RADIO_DEFAULT_OPTIONS_FACTORY,
  27. MatRadioChange,
  28. MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
  29. MAT_RADIO_GROUP,
  30. MatRadioDefaultOptions,
  31. MAT_RADIO_DEFAULT_OPTIONS,
  32. _MatRadioGroupBase,
  33. _MatRadioButtonBase,
  34. MatRadioGroup,
  35. MatRadioButton
  36. }
  37. }
  38. export declare const MAT_RADIO_DEFAULT_OPTIONS: InjectionToken<MatRadioDefaultOptions>;
  39. export declare function MAT_RADIO_DEFAULT_OPTIONS_FACTORY(): MatRadioDefaultOptions;
  40. /**
  41. * Injection token that can be used to inject instances of `MatRadioGroup`. It serves as
  42. * alternative token to the actual `MatRadioGroup` class which could cause unnecessary
  43. * retention of the class and its component metadata.
  44. */
  45. export declare const MAT_RADIO_GROUP: InjectionToken<_MatRadioGroupBase<_MatRadioButtonBase>>;
  46. /**
  47. * Provider Expression that allows mat-radio-group to register as a ControlValueAccessor. This
  48. * allows it to support [(ngModel)] and ngControl.
  49. * @docs-private
  50. */
  51. export declare const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any;
  52. export declare class MatRadioButton extends _MatRadioButtonBase {
  53. constructor(radioGroup: MatRadioGroup, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, animationMode?: string, _providerOverride?: MatRadioDefaultOptions, tabIndex?: string);
  54. static ɵfac: i0.ɵɵFactoryDeclaration<MatRadioButton, [{ optional: true; }, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
  55. static ɵcmp: i0.ɵɵComponentDeclaration<MatRadioButton, "mat-radio-button", ["matRadioButton"], { "disableRipple": { "alias": "disableRipple"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, never, ["*"], false, never>;
  56. }
  57. /** @docs-private */
  58. declare abstract class MatRadioButtonBase {
  59. _elementRef: ElementRef;
  60. abstract disabled: boolean;
  61. constructor(_elementRef: ElementRef);
  62. }
  63. /**
  64. * Base class with all of the `MatRadioButton` functionality.
  65. * @docs-private
  66. */
  67. export declare abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase implements OnInit, AfterViewInit, DoCheck, OnDestroy, CanDisableRipple, HasTabIndex {
  68. protected _changeDetector: ChangeDetectorRef;
  69. private _focusMonitor;
  70. private _radioDispatcher;
  71. private _providerOverride?;
  72. private _uniqueId;
  73. /** The unique ID for the radio button. */
  74. id: string;
  75. /** Analog to HTML 'name' attribute used to group radios for unique selection. */
  76. name: string;
  77. /** Used to set the 'aria-label' attribute on the underlying input element. */
  78. ariaLabel: string;
  79. /** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */
  80. ariaLabelledby: string;
  81. /** The 'aria-describedby' attribute is read after the element's label and field type. */
  82. ariaDescribedby: string;
  83. /** Whether this radio button is checked. */
  84. get checked(): boolean;
  85. set checked(value: BooleanInput);
  86. /** The value of this radio button. */
  87. get value(): any;
  88. set value(value: any);
  89. /** Whether the label should appear after or before the radio button. Defaults to 'after' */
  90. get labelPosition(): 'before' | 'after';
  91. set labelPosition(value: 'before' | 'after');
  92. private _labelPosition;
  93. /** Whether the radio button is disabled. */
  94. get disabled(): boolean;
  95. set disabled(value: BooleanInput);
  96. /** Whether the radio button is required. */
  97. get required(): boolean;
  98. set required(value: BooleanInput);
  99. /** Theme color of the radio button. */
  100. get color(): ThemePalette;
  101. set color(newValue: ThemePalette);
  102. private _color;
  103. /**
  104. * Event emitted when the checked state of this radio button changes.
  105. * Change events are only emitted when the value changes due to user interaction with
  106. * the radio button (the same behavior as `<input type-"radio">`).
  107. */
  108. readonly change: EventEmitter<MatRadioChange>;
  109. /** The parent radio group. May or may not be present. */
  110. radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>;
  111. /** ID of the native input element inside `<mat-radio-button>` */
  112. get inputId(): string;
  113. /** Whether this radio is checked. */
  114. private _checked;
  115. /** Whether this radio is disabled. */
  116. private _disabled;
  117. /** Whether this radio is required. */
  118. private _required;
  119. /** Value assigned to this radio. */
  120. private _value;
  121. /** Unregister function for _radioDispatcher */
  122. private _removeUniqueSelectionListener;
  123. /** Previous value of the input's tabindex. */
  124. private _previousTabIndex;
  125. /** The native `<input type=radio>` element */
  126. _inputElement: ElementRef<HTMLInputElement>;
  127. /** Whether animations are disabled. */
  128. _noopAnimations: boolean;
  129. constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, animationMode?: string, _providerOverride?: MatRadioDefaultOptions | undefined, tabIndex?: string);
  130. /** Focuses the radio button. */
  131. focus(options?: FocusOptions, origin?: FocusOrigin): void;
  132. /**
  133. * Marks the radio button as needing checking for change detection.
  134. * This method is exposed because the parent radio group will directly
  135. * update bound properties of the radio button.
  136. */
  137. _markForCheck(): void;
  138. ngOnInit(): void;
  139. ngDoCheck(): void;
  140. ngAfterViewInit(): void;
  141. ngOnDestroy(): void;
  142. /** Dispatch change event with current value. */
  143. private _emitChangeEvent;
  144. _isRippleDisabled(): boolean;
  145. _onInputClick(event: Event): void;
  146. /** Triggered when the radio button receives an interaction from the user. */
  147. _onInputInteraction(event: Event): void;
  148. /** Triggered when the user clicks on the touch target. */
  149. _onTouchTargetClick(event: Event): void;
  150. /** Sets the disabled state and marks for check if a change occurred. */
  151. protected _setDisabled(value: boolean): void;
  152. /** Gets the tabindex for the underlying input element. */
  153. private _updateTabIndex;
  154. static ɵfac: i0.ɵɵFactoryDeclaration<_MatRadioButtonBase, never>;
  155. static ɵdir: i0.ɵɵDirectiveDeclaration<_MatRadioButtonBase, never, never, { "id": { "alias": "id"; "required": false; }; "name": { "alias": "name"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; }; "checked": { "alias": "checked"; "required": false; }; "value": { "alias": "value"; "required": false; }; "labelPosition": { "alias": "labelPosition"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; "color": { "alias": "color"; "required": false; }; }, { "change": "change"; }, never, never, false, never>;
  156. }
  157. declare const _MatRadioButtonMixinBase: _Constructor<CanDisableRipple> & _AbstractConstructor<CanDisableRipple> & _Constructor<HasTabIndex> & _AbstractConstructor<HasTabIndex> & typeof MatRadioButtonBase;
  158. /** Change event object emitted by radio button and radio group. */
  159. export declare class MatRadioChange {
  160. /** The radio button that emits the change event. */
  161. source: _MatRadioButtonBase;
  162. /** The value of the radio button. */
  163. value: any;
  164. constructor(
  165. /** The radio button that emits the change event. */
  166. source: _MatRadioButtonBase,
  167. /** The value of the radio button. */
  168. value: any);
  169. }
  170. export declare interface MatRadioDefaultOptions {
  171. color: ThemePalette;
  172. }
  173. /**
  174. * A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
  175. */
  176. export declare class MatRadioGroup extends _MatRadioGroupBase<MatRadioButton> {
  177. /** Child radio buttons. */
  178. _radios: QueryList<MatRadioButton>;
  179. static ɵfac: i0.ɵɵFactoryDeclaration<MatRadioGroup, never>;
  180. static ɵdir: i0.ɵɵDirectiveDeclaration<MatRadioGroup, "mat-radio-group", ["matRadioGroup"], {}, {}, ["_radios"], never, false, never>;
  181. }
  182. /**
  183. * Base class with all of the `MatRadioGroup` functionality.
  184. * @docs-private
  185. */
  186. export declare abstract class _MatRadioGroupBase<T extends _MatRadioButtonBase> implements AfterContentInit, ControlValueAccessor {
  187. private _changeDetector;
  188. /** Selected value for the radio group. */
  189. private _value;
  190. /** The HTML name attribute applied to radio buttons in this group. */
  191. private _name;
  192. /** The currently selected radio button. Should match value. */
  193. private _selected;
  194. /** Whether the `value` has been set to its initial value. */
  195. private _isInitialized;
  196. /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
  197. private _labelPosition;
  198. /** Whether the radio group is disabled. */
  199. private _disabled;
  200. /** Whether the radio group is required. */
  201. private _required;
  202. /** The method to be called in order to update ngModel */
  203. _controlValueAccessorChangeFn: (value: any) => void;
  204. /**
  205. * onTouch function registered via registerOnTouch (ControlValueAccessor).
  206. * @docs-private
  207. */
  208. onTouched: () => any;
  209. /**
  210. * Event emitted when the group value changes.
  211. * Change events are only emitted when the value changes due to user interaction with
  212. * a radio button (the same behavior as `<input type-"radio">`).
  213. */
  214. readonly change: EventEmitter<MatRadioChange>;
  215. /** Child radio buttons. */
  216. abstract _radios: QueryList<T>;
  217. /** Theme color for all of the radio buttons in the group. */
  218. color: ThemePalette;
  219. /** Name of the radio button group. All radio buttons inside this group will use this name. */
  220. get name(): string;
  221. set name(value: string);
  222. /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
  223. get labelPosition(): 'before' | 'after';
  224. set labelPosition(v: 'before' | 'after');
  225. /**
  226. * Value for the radio-group. Should equal the value of the selected radio button if there is
  227. * a corresponding radio button with a matching value. If there is not such a corresponding
  228. * radio button, this value persists to be applied in case a new radio button is added with a
  229. * matching value.
  230. */
  231. get value(): any;
  232. set value(newValue: any);
  233. _checkSelectedRadioButton(): void;
  234. /**
  235. * The currently selected radio button. If set to a new radio button, the radio group value
  236. * will be updated to match the new selected button.
  237. */
  238. get selected(): T | null;
  239. set selected(selected: T | null);
  240. /** Whether the radio group is disabled */
  241. get disabled(): boolean;
  242. set disabled(value: BooleanInput);
  243. /** Whether the radio group is required */
  244. get required(): boolean;
  245. set required(value: BooleanInput);
  246. constructor(_changeDetector: ChangeDetectorRef);
  247. /**
  248. * Initialize properties once content children are available.
  249. * This allows us to propagate relevant attributes to associated buttons.
  250. */
  251. ngAfterContentInit(): void;
  252. /**
  253. * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
  254. * radio buttons upon their blur.
  255. */
  256. _touch(): void;
  257. private _updateRadioButtonNames;
  258. /** Updates the `selected` radio button from the internal _value state. */
  259. private _updateSelectedRadioFromValue;
  260. /** Dispatch change event with current selection and group value. */
  261. _emitChangeEvent(): void;
  262. _markRadiosForCheck(): void;
  263. /**
  264. * Sets the model value. Implemented as part of ControlValueAccessor.
  265. * @param value
  266. */
  267. writeValue(value: any): void;
  268. /**
  269. * Registers a callback to be triggered when the model value changes.
  270. * Implemented as part of ControlValueAccessor.
  271. * @param fn Callback to be registered.
  272. */
  273. registerOnChange(fn: (value: any) => void): void;
  274. /**
  275. * Registers a callback to be triggered when the control is touched.
  276. * Implemented as part of ControlValueAccessor.
  277. * @param fn Callback to be registered.
  278. */
  279. registerOnTouched(fn: any): void;
  280. /**
  281. * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
  282. * @param isDisabled Whether the control should be disabled.
  283. */
  284. setDisabledState(isDisabled: boolean): void;
  285. static ɵfac: i0.ɵɵFactoryDeclaration<_MatRadioGroupBase<any>, never>;
  286. static ɵdir: i0.ɵɵDirectiveDeclaration<_MatRadioGroupBase<any>, never, never, { "color": { "alias": "color"; "required": false; }; "name": { "alias": "name"; "required": false; }; "labelPosition": { "alias": "labelPosition"; "required": false; }; "value": { "alias": "value"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, { "change": "change"; }, never, never, false, never>;
  287. }
  288. export declare class MatRadioModule {
  289. static ɵfac: i0.ɵɵFactoryDeclaration<MatRadioModule, never>;
  290. static ɵmod: i0.ɵɵNgModuleDeclaration<MatRadioModule, [typeof i1.MatRadioGroup, typeof i1.MatRadioButton], [typeof i2.MatCommonModule, typeof i3.CommonModule, typeof i2.MatRippleModule], [typeof i2.MatCommonModule, typeof i1.MatRadioGroup, typeof i1.MatRadioButton]>;
  291. static ɵinj: i0.ɵɵInjectorDeclaration<MatRadioModule>;
  292. }
  293. export { }