index.d.ts 7.3 KB

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