checkbox.d.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { FocusMonitor, FocusableOption, FocusOrigin } from '@angular/cdk/a11y';
  9. import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnDestroy, AfterViewChecked } from '@angular/core';
  10. import { ControlValueAccessor } from '@angular/forms';
  11. import { CanColor, CanColorCtor, CanDisable, CanDisableCtor, CanDisableRipple, CanDisableRippleCtor, HasTabIndex, HasTabIndexCtor, MatRipple } from '@angular/material/core';
  12. import { MatCheckboxClickAction } from './checkbox-config';
  13. /**
  14. * Provider Expression that allows mat-checkbox to register as a ControlValueAccessor.
  15. * This allows it to support [(ngModel)].
  16. * @docs-private
  17. */
  18. export declare const MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR: any;
  19. /**
  20. * Represents the different states that require custom transitions between them.
  21. * @docs-private
  22. */
  23. export declare enum TransitionCheckState {
  24. /** The initial state of the component before any user interaction. */
  25. Init = 0,
  26. /** The state representing the component when it's becoming checked. */
  27. Checked = 1,
  28. /** The state representing the component when it's becoming unchecked. */
  29. Unchecked = 2,
  30. /** The state representing the component when it's becoming indeterminate. */
  31. Indeterminate = 3
  32. }
  33. /** Change event object emitted by MatCheckbox. */
  34. export declare class MatCheckboxChange {
  35. /** The source MatCheckbox of the event. */
  36. source: MatCheckbox;
  37. /** The new `checked` value of the checkbox. */
  38. checked: boolean;
  39. }
  40. /** @docs-private */
  41. declare class MatCheckboxBase {
  42. _elementRef: ElementRef;
  43. constructor(_elementRef: ElementRef);
  44. }
  45. declare const _MatCheckboxMixinBase: HasTabIndexCtor & CanColorCtor & CanDisableRippleCtor & CanDisableCtor & typeof MatCheckboxBase;
  46. /**
  47. * A material design checkbox component. Supports all of the functionality of an HTML5 checkbox,
  48. * and exposes a similar API. A MatCheckbox can be either checked, unchecked, indeterminate, or
  49. * disabled. Note that all additional accessibility attributes are taken care of by the component,
  50. * so there is no need to provide them yourself. However, if you want to omit a label and still
  51. * have the checkbox be accessible, you may supply an [aria-label] input.
  52. * See: https://material.io/design/components/selection-controls.html
  53. */
  54. export declare class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAccessor, AfterViewChecked, OnDestroy, CanColor, CanDisable, HasTabIndex, CanDisableRipple, FocusableOption {
  55. private _changeDetectorRef;
  56. private _focusMonitor;
  57. private _ngZone;
  58. private _clickAction;
  59. _animationMode?: string | undefined;
  60. /**
  61. * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
  62. * take precedence so this may be omitted.
  63. */
  64. ariaLabel: string;
  65. /**
  66. * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
  67. */
  68. ariaLabelledby: string | null;
  69. private _uniqueId;
  70. /** A unique id for the checkbox input. If none is supplied, it will be auto-generated. */
  71. id: string;
  72. /** Returns the unique id for the visual hidden input. */
  73. readonly inputId: string;
  74. /** Whether the checkbox is required. */
  75. required: boolean;
  76. private _required;
  77. /** Whether the label should appear after or before the checkbox. Defaults to 'after' */
  78. labelPosition: 'before' | 'after';
  79. /** Name value will be applied to the input element if present */
  80. name: string | null;
  81. /** Event emitted when the checkbox's `checked` value changes. */
  82. readonly change: EventEmitter<MatCheckboxChange>;
  83. /** Event emitted when the checkbox's `indeterminate` value changes. */
  84. readonly indeterminateChange: EventEmitter<boolean>;
  85. /** The value attribute of the native input element */
  86. value: string;
  87. /** The native `<input type="checkbox">` element */
  88. _inputElement: ElementRef<HTMLInputElement>;
  89. /** Reference to the ripple instance of the checkbox. */
  90. ripple: MatRipple;
  91. /**
  92. * Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor.
  93. * @docs-private
  94. */
  95. _onTouched: () => any;
  96. private _currentAnimationClass;
  97. private _currentCheckState;
  98. private _controlValueAccessorChangeFn;
  99. constructor(elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _focusMonitor: FocusMonitor, _ngZone: NgZone, tabIndex: string, _clickAction: MatCheckboxClickAction, _animationMode?: string | undefined);
  100. ngAfterViewChecked(): void;
  101. ngOnDestroy(): void;
  102. /**
  103. * Whether the checkbox is checked.
  104. */
  105. checked: boolean;
  106. private _checked;
  107. /**
  108. * Whether the checkbox is disabled. This fully overrides the implementation provided by
  109. * mixinDisabled, but the mixin is still required because mixinTabIndex requires it.
  110. */
  111. disabled: any;
  112. private _disabled;
  113. /**
  114. * Whether the checkbox is indeterminate. This is also known as "mixed" mode and can be used to
  115. * represent a checkbox with three states, e.g. a checkbox that represents a nested list of
  116. * checkable items. Note that whenever checkbox is manually clicked, indeterminate is immediately
  117. * set to false.
  118. */
  119. indeterminate: boolean;
  120. private _indeterminate;
  121. _isRippleDisabled(): any;
  122. /** Method being called whenever the label text changes. */
  123. _onLabelTextChange(): void;
  124. writeValue(value: any): void;
  125. registerOnChange(fn: (value: any) => void): void;
  126. registerOnTouched(fn: any): void;
  127. setDisabledState(isDisabled: boolean): void;
  128. _getAriaChecked(): 'true' | 'false' | 'mixed';
  129. private _transitionCheckState;
  130. private _emitChangeEvent;
  131. /** Toggles the `checked` state of the checkbox. */
  132. toggle(): void;
  133. /**
  134. * Event handler for checkbox input element.
  135. * Toggles checked state if element is not disabled.
  136. * Do not toggle on (change) event since IE doesn't fire change event when
  137. * indeterminate checkbox is clicked.
  138. * @param event
  139. */
  140. _onInputClick(event: Event): void;
  141. /** Focuses the checkbox. */
  142. focus(origin?: FocusOrigin, options?: FocusOptions): void;
  143. _onInteractionEvent(event: Event): void;
  144. private _getAnimationClassForCheckStateTransition;
  145. }
  146. export {};