index.d.ts 13 KB

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