index.d.ts 15 KB

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