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