index.d.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import * as i0 from '@angular/core';
  2. import { OnDestroy, ElementRef, OnInit, EventEmitter, AfterViewInit, DoCheck } from '@angular/core';
  3. import { Observable } from 'rxjs';
  4. import { N as NumberInput } from '../number-property.d-CJVxXUcb.js';
  5. /** An event that is emitted when the autofill state of an input changes. */
  6. type AutofillEvent = {
  7. /** The element whose autofill state changes. */
  8. target: Element;
  9. /** Whether the element is currently autofilled. */
  10. isAutofilled: boolean;
  11. };
  12. /**
  13. * An injectable service that can be used to monitor the autofill state of an input.
  14. * Based on the following blog post:
  15. * https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7
  16. */
  17. declare class AutofillMonitor implements OnDestroy {
  18. private _platform;
  19. private _ngZone;
  20. private _renderer;
  21. private _styleLoader;
  22. private _monitoredElements;
  23. constructor(...args: unknown[]);
  24. /**
  25. * Monitor for changes in the autofill state of the given input element.
  26. * @param element The element to monitor.
  27. * @return A stream of autofill state changes.
  28. */
  29. monitor(element: Element): Observable<AutofillEvent>;
  30. /**
  31. * Monitor for changes in the autofill state of the given input element.
  32. * @param element The element to monitor.
  33. * @return A stream of autofill state changes.
  34. */
  35. monitor(element: ElementRef<Element>): Observable<AutofillEvent>;
  36. /**
  37. * Stop monitoring the autofill state of the given input element.
  38. * @param element The element to stop monitoring.
  39. */
  40. stopMonitoring(element: Element): void;
  41. /**
  42. * Stop monitoring the autofill state of the given input element.
  43. * @param element The element to stop monitoring.
  44. */
  45. stopMonitoring(element: ElementRef<Element>): void;
  46. ngOnDestroy(): void;
  47. static ɵfac: i0.ɵɵFactoryDeclaration<AutofillMonitor, never>;
  48. static ɵprov: i0.ɵɵInjectableDeclaration<AutofillMonitor>;
  49. }
  50. /** A directive that can be used to monitor the autofill state of an input. */
  51. declare class CdkAutofill implements OnDestroy, OnInit {
  52. private _elementRef;
  53. private _autofillMonitor;
  54. /** Emits when the autofill state of the element changes. */
  55. readonly cdkAutofill: EventEmitter<AutofillEvent>;
  56. constructor(...args: unknown[]);
  57. ngOnInit(): void;
  58. ngOnDestroy(): void;
  59. static ɵfac: i0.ɵɵFactoryDeclaration<CdkAutofill, never>;
  60. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAutofill, "[cdkAutofill]", never, {}, { "cdkAutofill": "cdkAutofill"; }, never, never, true, never>;
  61. }
  62. /** Directive to automatically resize a textarea to fit its content. */
  63. declare class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
  64. private _elementRef;
  65. private _platform;
  66. private _ngZone;
  67. private _renderer;
  68. private _resizeEvents;
  69. /** Keep track of the previous textarea value to avoid resizing when the value hasn't changed. */
  70. private _previousValue?;
  71. private _initialHeight;
  72. private readonly _destroyed;
  73. private _listenerCleanups;
  74. private _minRows;
  75. private _maxRows;
  76. private _enabled;
  77. /**
  78. * Value of minRows as of last resize. If the minRows has decreased, the
  79. * height of the textarea needs to be recomputed to reflect the new minimum. The maxHeight
  80. * does not have the same problem because it does not affect the textarea's scrollHeight.
  81. */
  82. private _previousMinRows;
  83. private _textareaElement;
  84. /** Minimum amount of rows in the textarea. */
  85. get minRows(): number;
  86. set minRows(value: NumberInput);
  87. /** Maximum amount of rows in the textarea. */
  88. get maxRows(): number;
  89. set maxRows(value: NumberInput);
  90. /** Whether autosizing is enabled or not */
  91. get enabled(): boolean;
  92. set enabled(value: boolean);
  93. get placeholder(): string;
  94. set placeholder(value: string);
  95. /** Cached height of a textarea with a single row. */
  96. private _cachedLineHeight?;
  97. /** Cached height of a textarea with only the placeholder. */
  98. private _cachedPlaceholderHeight?;
  99. /** Cached scroll top of a textarea */
  100. private _cachedScrollTop;
  101. /** Used to reference correct document/window */
  102. protected _document?: Document | null | undefined;
  103. private _hasFocus;
  104. private _isViewInited;
  105. constructor(...args: unknown[]);
  106. /** Sets the minimum height of the textarea as determined by minRows. */
  107. _setMinHeight(): void;
  108. /** Sets the maximum height of the textarea as determined by maxRows. */
  109. _setMaxHeight(): void;
  110. ngAfterViewInit(): void;
  111. ngOnDestroy(): void;
  112. /**
  113. * Cache the height of a single-row textarea if it has not already been cached.
  114. *
  115. * We need to know how large a single "row" of a textarea is in order to apply minRows and
  116. * maxRows. For the initial version, we will assume that the height of a single line in the
  117. * textarea does not ever change.
  118. */
  119. private _cacheTextareaLineHeight;
  120. private _measureScrollHeight;
  121. private _cacheTextareaPlaceholderHeight;
  122. /** Handles `focus` and `blur` events. */
  123. private _handleFocusEvent;
  124. ngDoCheck(): void;
  125. /**
  126. * Resize the textarea to fit its content.
  127. * @param force Whether to force a height recalculation. By default the height will be
  128. * recalculated only if the value changed since the last call.
  129. */
  130. resizeToFitContent(force?: boolean): void;
  131. /**
  132. * Resets the textarea to its original size
  133. */
  134. reset(): void;
  135. _noopInputHandler(): void;
  136. /**
  137. * Scrolls a textarea to the caret position. On Firefox resizing the textarea will
  138. * prevent it from scrolling to the caret position. We need to re-set the selection
  139. * in order for it to scroll to the proper position.
  140. */
  141. private _scrollToCaretPosition;
  142. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTextareaAutosize, never>;
  143. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTextareaAutosize, "textarea[cdkTextareaAutosize]", ["cdkTextareaAutosize"], { "minRows": { "alias": "cdkAutosizeMinRows"; "required": false; }; "maxRows": { "alias": "cdkAutosizeMaxRows"; "required": false; }; "enabled": { "alias": "cdkTextareaAutosize"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; }, {}, never, never, true, never>;
  144. static ngAcceptInputType_enabled: unknown;
  145. }
  146. declare class TextFieldModule {
  147. static ɵfac: i0.ɵɵFactoryDeclaration<TextFieldModule, never>;
  148. static ɵmod: i0.ɵɵNgModuleDeclaration<TextFieldModule, never, [typeof CdkAutofill, typeof CdkTextareaAutosize], [typeof CdkAutofill, typeof CdkTextareaAutosize]>;
  149. static ɵinj: i0.ɵɵInjectorDeclaration<TextFieldModule>;
  150. }
  151. export { AutofillMonitor, CdkAutofill, CdkTextareaAutosize, TextFieldModule };
  152. export type { AutofillEvent };