index.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import { _AbstractConstructor } from '@angular/material/core';
  2. import { AfterViewInit } from '@angular/core';
  3. import { BooleanInput } from '@angular/cdk/coercion';
  4. import { CanColor } from '@angular/material/core';
  5. import { CanDisable } from '@angular/material/core';
  6. import { CanDisableRipple } from '@angular/material/core';
  7. import { ChangeDetectorRef } from '@angular/core';
  8. import { CheckboxRequiredValidator } from '@angular/forms';
  9. import { _Constructor } from '@angular/material/core';
  10. import { ControlValueAccessor } from '@angular/forms';
  11. import { ElementRef } from '@angular/core';
  12. import { EventEmitter } from '@angular/core';
  13. import { FocusableOption } from '@angular/cdk/a11y';
  14. import { FocusOrigin } from '@angular/cdk/a11y';
  15. import { HasTabIndex } from '@angular/material/core';
  16. import * as i0 from '@angular/core';
  17. import * as i3 from '@angular/material/core';
  18. import { InjectionToken } from '@angular/core';
  19. import { MatRipple } from '@angular/material/core';
  20. import { NgZone } from '@angular/core';
  21. import { Provider } from '@angular/core';
  22. import { ThemePalette } from '@angular/material/core';
  23. declare namespace i1 {
  24. export {
  25. MAT_CHECKBOX_REQUIRED_VALIDATOR,
  26. MatCheckboxRequiredValidator
  27. }
  28. }
  29. declare namespace i2 {
  30. export {
  31. TransitionCheckState,
  32. MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR,
  33. MatCheckboxChange,
  34. _MatCheckboxBase,
  35. MatCheckbox
  36. }
  37. }
  38. export declare const MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR: any;
  39. /** Injection token to be used to override the default options for `mat-checkbox`. */
  40. export declare const MAT_CHECKBOX_DEFAULT_OPTIONS: InjectionToken<MatCheckboxDefaultOptions>;
  41. /** @docs-private */
  42. export declare function MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY(): MatCheckboxDefaultOptions;
  43. export declare const MAT_CHECKBOX_REQUIRED_VALIDATOR: Provider;
  44. export declare class MatCheckbox extends _MatCheckboxBase<MatCheckboxChange> implements ControlValueAccessor, CanColor, CanDisable {
  45. protected _animationClasses: {
  46. uncheckedToChecked: string;
  47. uncheckedToIndeterminate: string;
  48. checkedToUnchecked: string;
  49. checkedToIndeterminate: string;
  50. indeterminateToChecked: string;
  51. indeterminateToUnchecked: string;
  52. };
  53. constructor(elementRef: ElementRef<HTMLElement>, changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, tabIndex: string, animationMode?: string, options?: MatCheckboxDefaultOptions);
  54. /** Focuses the checkbox. */
  55. focus(): void;
  56. protected _createChangeEvent(isChecked: boolean): MatCheckboxChange;
  57. protected _getAnimationTargetElement(): HTMLInputElement;
  58. _onInputClick(): void;
  59. _onTouchTargetClick(): void;
  60. /**
  61. * Prevent click events that come from the `<label/>` element from bubbling. This prevents the
  62. * click handler on the host from triggering twice when clicking on the `<label/>` element. After
  63. * the click event on the `<label/>` propagates, the browsers dispatches click on the associated
  64. * `<input/>`. By preventing clicks on the label by bubbling, we ensure only one click event
  65. * bubbles when the label is clicked.
  66. */
  67. _preventBubblingFromLabel(event: MouseEvent): void;
  68. static ɵfac: i0.ɵɵFactoryDeclaration<MatCheckbox, [null, null, null, { attribute: "tabindex"; }, { optional: true; }, { optional: true; }]>;
  69. static ɵcmp: i0.ɵɵComponentDeclaration<MatCheckbox, "mat-checkbox", ["matCheckbox"], { "disableRipple": { "alias": "disableRipple"; "required": false; }; "color": { "alias": "color"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, never, ["*"], false, never>;
  70. }
  71. export declare abstract class _MatCheckboxBase<E> extends _MatCheckboxMixinBase implements AfterViewInit, ControlValueAccessor, CanColor, CanDisable, HasTabIndex, CanDisableRipple, FocusableOption {
  72. protected _changeDetectorRef: ChangeDetectorRef;
  73. protected _ngZone: NgZone;
  74. _animationMode?: string | undefined;
  75. protected _options?: MatCheckboxDefaultOptions | undefined;
  76. /** Focuses the checkbox. */
  77. abstract focus(origin?: FocusOrigin): void;
  78. /** Creates the change event that will be emitted by the checkbox. */
  79. protected abstract _createChangeEvent(isChecked: boolean): E;
  80. /** Gets the element on which to add the animation CSS classes. */
  81. protected abstract _getAnimationTargetElement(): HTMLElement | null;
  82. /** CSS classes to add when transitioning between the different checkbox states. */
  83. protected abstract _animationClasses: {
  84. uncheckedToChecked: string;
  85. uncheckedToIndeterminate: string;
  86. checkedToUnchecked: string;
  87. checkedToIndeterminate: string;
  88. indeterminateToChecked: string;
  89. indeterminateToUnchecked: string;
  90. };
  91. /**
  92. * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
  93. * take precedence so this may be omitted.
  94. */
  95. ariaLabel: string;
  96. /**
  97. * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
  98. */
  99. ariaLabelledby: string | null;
  100. /** The 'aria-describedby' attribute is read after the element's label and field type. */
  101. ariaDescribedby: string;
  102. private _uniqueId;
  103. /** A unique id for the checkbox input. If none is supplied, it will be auto-generated. */
  104. id: string;
  105. /** Returns the unique id for the visual hidden input. */
  106. get inputId(): string;
  107. /** Whether the checkbox is required. */
  108. get required(): boolean;
  109. set required(value: BooleanInput);
  110. private _required;
  111. /** Whether the label should appear after or before the checkbox. Defaults to 'after' */
  112. labelPosition: 'before' | 'after';
  113. /** Name value will be applied to the input element if present */
  114. name: string | null;
  115. /** Event emitted when the checkbox's `checked` value changes. */
  116. readonly change: EventEmitter<E>;
  117. /** Event emitted when the checkbox's `indeterminate` value changes. */
  118. readonly indeterminateChange: EventEmitter<boolean>;
  119. /** The value attribute of the native input element */
  120. value: string;
  121. /** The native `<input type="checkbox">` element */
  122. _inputElement: ElementRef<HTMLInputElement>;
  123. /** The native `<label>` element */
  124. _labelElement: ElementRef<HTMLInputElement>;
  125. /**
  126. * Reference to the MatRipple instance of the checkbox.
  127. * @deprecated Considered an implementation detail. To be removed.
  128. * @breaking-change 17.0.0
  129. */
  130. ripple: MatRipple;
  131. /**
  132. * Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor.
  133. * @docs-private
  134. */
  135. _onTouched: () => any;
  136. private _currentAnimationClass;
  137. private _currentCheckState;
  138. private _controlValueAccessorChangeFn;
  139. constructor(idPrefix: string, elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _ngZone: NgZone, tabIndex: string, _animationMode?: string | undefined, _options?: MatCheckboxDefaultOptions | undefined);
  140. ngAfterViewInit(): void;
  141. /** Whether the checkbox is checked. */
  142. get checked(): boolean;
  143. set checked(value: BooleanInput);
  144. private _checked;
  145. /**
  146. * Whether the checkbox is disabled. This fully overrides the implementation provided by
  147. * mixinDisabled, but the mixin is still required because mixinTabIndex requires it.
  148. */
  149. get disabled(): boolean;
  150. set disabled(value: BooleanInput);
  151. private _disabled;
  152. /**
  153. * Whether the checkbox is indeterminate. This is also known as "mixed" mode and can be used to
  154. * represent a checkbox with three states, e.g. a checkbox that represents a nested list of
  155. * checkable items. Note that whenever checkbox is manually clicked, indeterminate is immediately
  156. * set to false.
  157. */
  158. get indeterminate(): boolean;
  159. set indeterminate(value: BooleanInput);
  160. private _indeterminate;
  161. _isRippleDisabled(): boolean;
  162. /** Method being called whenever the label text changes. */
  163. _onLabelTextChange(): void;
  164. writeValue(value: any): void;
  165. registerOnChange(fn: (value: any) => void): void;
  166. registerOnTouched(fn: any): void;
  167. setDisabledState(isDisabled: boolean): void;
  168. private _transitionCheckState;
  169. private _emitChangeEvent;
  170. /** Toggles the `checked` state of the checkbox. */
  171. toggle(): void;
  172. protected _handleInputClick(): void;
  173. _onInteractionEvent(event: Event): void;
  174. _onBlur(): void;
  175. private _getAnimationClassForCheckStateTransition;
  176. /**
  177. * Syncs the indeterminate value with the checkbox DOM node.
  178. *
  179. * We sync `indeterminate` directly on the DOM node, because in Ivy the check for whether a
  180. * property is supported on an element boils down to `if (propName in element)`. Domino's
  181. * HTMLInputElement doesn't have an `indeterminate` property so Ivy will warn during
  182. * server-side rendering.
  183. */
  184. private _syncIndeterminate;
  185. static ɵfac: i0.ɵɵFactoryDeclaration<_MatCheckboxBase<any>, never>;
  186. static ɵdir: i0.ɵɵDirectiveDeclaration<_MatCheckboxBase<any>, never, never, { "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; }; "id": { "alias": "id"; "required": false; }; "required": { "alias": "required"; "required": false; }; "labelPosition": { "alias": "labelPosition"; "required": false; }; "name": { "alias": "name"; "required": false; }; "value": { "alias": "value"; "required": false; }; "checked": { "alias": "checked"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "indeterminate": { "alias": "indeterminate"; "required": false; }; }, { "change": "change"; "indeterminateChange": "indeterminateChange"; }, never, never, false, never>;
  187. }
  188. /** Change event object emitted by checkbox. */
  189. export declare class MatCheckboxChange {
  190. /** The source checkbox of the event. */
  191. source: MatCheckbox;
  192. /** The new `checked` value of the checkbox. */
  193. checked: boolean;
  194. }
  195. /**
  196. * Checkbox click action when user click on input element.
  197. * noop: Do not toggle checked or indeterminate.
  198. * check: Only toggle checked status, ignore indeterminate.
  199. * check-indeterminate: Toggle checked status, set indeterminate to false. Default behavior.
  200. * undefined: Same as `check-indeterminate`.
  201. */
  202. export declare type MatCheckboxClickAction = 'noop' | 'check' | 'check-indeterminate' | undefined;
  203. /** Default `mat-checkbox` options that can be overridden. */
  204. export declare interface MatCheckboxDefaultOptions {
  205. /** Default theme color palette to be used for checkboxes. */
  206. color?: ThemePalette;
  207. /** Default checkbox click action for checkboxes. */
  208. clickAction?: MatCheckboxClickAction;
  209. }
  210. /** @docs-private */
  211. declare const _MatCheckboxMixinBase: _Constructor<HasTabIndex> & _AbstractConstructor<HasTabIndex> & _Constructor<CanColor> & _AbstractConstructor<CanColor> & _Constructor<CanDisableRipple> & _AbstractConstructor<CanDisableRipple> & _Constructor<CanDisable> & _AbstractConstructor<CanDisable> & {
  212. new (_elementRef: ElementRef): {
  213. _elementRef: ElementRef;
  214. };
  215. };
  216. export declare class MatCheckboxModule {
  217. static ɵfac: i0.ɵɵFactoryDeclaration<MatCheckboxModule, never>;
  218. static ɵmod: i0.ɵɵNgModuleDeclaration<MatCheckboxModule, [typeof i2.MatCheckbox], [typeof i3.MatCommonModule, typeof i3.MatRippleModule, typeof _MatCheckboxRequiredValidatorModule], [typeof i2.MatCheckbox, typeof i3.MatCommonModule, typeof _MatCheckboxRequiredValidatorModule]>;
  219. static ɵinj: i0.ɵɵInjectorDeclaration<MatCheckboxModule>;
  220. }
  221. /**
  222. * Validator for Material checkbox's required attribute in template-driven checkbox.
  223. * Current CheckboxRequiredValidator only work with `input type=checkbox` and does not
  224. * work with `mat-checkbox`.
  225. */
  226. export declare class MatCheckboxRequiredValidator extends CheckboxRequiredValidator {
  227. static ɵfac: i0.ɵɵFactoryDeclaration<MatCheckboxRequiredValidator, never>;
  228. static ɵdir: i0.ɵɵDirectiveDeclaration<MatCheckboxRequiredValidator, "mat-checkbox[required][formControlName], mat-checkbox[required][formControl], mat-checkbox[required][ngModel]", never, {}, {}, never, never, false, never>;
  229. }
  230. /** This module is used by both original and MDC-based checkbox implementations. */
  231. export declare class _MatCheckboxRequiredValidatorModule {
  232. static ɵfac: i0.ɵɵFactoryDeclaration<_MatCheckboxRequiredValidatorModule, never>;
  233. static ɵmod: i0.ɵɵNgModuleDeclaration<_MatCheckboxRequiredValidatorModule, [typeof i1.MatCheckboxRequiredValidator], never, [typeof i1.MatCheckboxRequiredValidator]>;
  234. static ɵinj: i0.ɵɵInjectorDeclaration<_MatCheckboxRequiredValidatorModule>;
  235. }
  236. /**
  237. * Represents the different states that require custom transitions between them.
  238. * @docs-private
  239. */
  240. export declare const enum TransitionCheckState {
  241. /** The initial state of the component before any user interaction. */
  242. Init = 0,
  243. /** The state representing the component when it's becoming checked. */
  244. Checked = 1,
  245. /** The state representing the component when it's becoming unchecked. */
  246. Unchecked = 2,
  247. /** The state representing the component when it's becoming indeterminate. */
  248. Indeterminate = 3
  249. }
  250. export { }