[6a3a178] | 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 { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
---|
| 9 | import { ElementRef, AfterViewInit, DoCheck, OnDestroy, NgZone } from '@angular/core';
|
---|
| 10 | import { Platform } from '@angular/cdk/platform';
|
---|
| 11 | /** Directive to automatically resize a textarea to fit its content. */
|
---|
| 12 | export declare class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
|
---|
| 13 | private _elementRef;
|
---|
| 14 | private _platform;
|
---|
| 15 | private _ngZone;
|
---|
| 16 | /** Keep track of the previous textarea value to avoid resizing when the value hasn't changed. */
|
---|
| 17 | private _previousValue?;
|
---|
| 18 | private _initialHeight;
|
---|
| 19 | private readonly _destroyed;
|
---|
| 20 | private _minRows;
|
---|
| 21 | private _maxRows;
|
---|
| 22 | private _enabled;
|
---|
| 23 | /**
|
---|
| 24 | * Value of minRows as of last resize. If the minRows has decreased, the
|
---|
| 25 | * height of the textarea needs to be recomputed to reflect the new minimum. The maxHeight
|
---|
| 26 | * does not have the same problem because it does not affect the textarea's scrollHeight.
|
---|
| 27 | */
|
---|
| 28 | private _previousMinRows;
|
---|
| 29 | private _textareaElement;
|
---|
| 30 | /** Minimum amount of rows in the textarea. */
|
---|
| 31 | get minRows(): number;
|
---|
| 32 | set minRows(value: number);
|
---|
| 33 | /** Maximum amount of rows in the textarea. */
|
---|
| 34 | get maxRows(): number;
|
---|
| 35 | set maxRows(value: number);
|
---|
| 36 | /** Whether autosizing is enabled or not */
|
---|
| 37 | get enabled(): boolean;
|
---|
| 38 | set enabled(value: boolean);
|
---|
| 39 | get placeholder(): string;
|
---|
| 40 | set placeholder(value: string);
|
---|
| 41 | /** Cached height of a textarea with a single row. */
|
---|
| 42 | private _cachedLineHeight;
|
---|
| 43 | /** Cached height of a textarea with only the placeholder. */
|
---|
| 44 | private _cachedPlaceholderHeight?;
|
---|
| 45 | /** Used to reference correct document/window */
|
---|
| 46 | protected _document?: Document;
|
---|
| 47 | private _hasFocus;
|
---|
| 48 | private _isViewInited;
|
---|
| 49 | constructor(_elementRef: ElementRef<HTMLElement>, _platform: Platform, _ngZone: NgZone,
|
---|
| 50 | /** @breaking-change 11.0.0 make document required */
|
---|
| 51 | document?: any);
|
---|
| 52 | /** Sets the minimum height of the textarea as determined by minRows. */
|
---|
| 53 | _setMinHeight(): void;
|
---|
| 54 | /** Sets the maximum height of the textarea as determined by maxRows. */
|
---|
| 55 | _setMaxHeight(): void;
|
---|
| 56 | ngAfterViewInit(): void;
|
---|
| 57 | ngOnDestroy(): void;
|
---|
| 58 | /**
|
---|
| 59 | * Cache the height of a single-row textarea if it has not already been cached.
|
---|
| 60 | *
|
---|
| 61 | * We need to know how large a single "row" of a textarea is in order to apply minRows and
|
---|
| 62 | * maxRows. For the initial version, we will assume that the height of a single line in the
|
---|
| 63 | * textarea does not ever change.
|
---|
| 64 | */
|
---|
| 65 | private _cacheTextareaLineHeight;
|
---|
| 66 | private _measureScrollHeight;
|
---|
| 67 | private _cacheTextareaPlaceholderHeight;
|
---|
| 68 | /** Handles `focus` and `blur` events. */
|
---|
| 69 | private _handleFocusEvent;
|
---|
| 70 | ngDoCheck(): void;
|
---|
| 71 | /**
|
---|
| 72 | * Resize the textarea to fit its content.
|
---|
| 73 | * @param force Whether to force a height recalculation. By default the height will be
|
---|
| 74 | * recalculated only if the value changed since the last call.
|
---|
| 75 | */
|
---|
| 76 | resizeToFitContent(force?: boolean): void;
|
---|
| 77 | /**
|
---|
| 78 | * Resets the textarea to its original size
|
---|
| 79 | */
|
---|
| 80 | reset(): void;
|
---|
| 81 | _noopInputHandler(): void;
|
---|
| 82 | /** Access injected document if available or fallback to global document reference */
|
---|
| 83 | private _getDocument;
|
---|
| 84 | /** Use defaultView of injected document if available or fallback to global window reference */
|
---|
| 85 | private _getWindow;
|
---|
| 86 | /**
|
---|
| 87 | * Scrolls a textarea to the caret position. On Firefox resizing the textarea will
|
---|
| 88 | * prevent it from scrolling to the caret position. We need to re-set the selection
|
---|
| 89 | * in order for it to scroll to the proper position.
|
---|
| 90 | */
|
---|
| 91 | private _scrollToCaretPosition;
|
---|
| 92 | static ngAcceptInputType_minRows: NumberInput;
|
---|
| 93 | static ngAcceptInputType_maxRows: NumberInput;
|
---|
| 94 | static ngAcceptInputType_enabled: BooleanInput;
|
---|
| 95 | }
|
---|