import { Renderer2, EventEmitter, NgZone, OnDestroy, TemplateRef, ViewContainerRef, AfterViewChecked, OnInit } from '@angular/core'; import { EllipsisResizeDetectionEnum } from '../enums/ellipsis-resize-detection.enum'; import * as i0 from "@angular/core"; /** * Directive to truncate the contained text, if it exceeds the element's boundaries * and append characters (configurable, default '...') if so. */ export declare class NestedEllipsisDirective implements OnInit, OnDestroy, AfterViewChecked { private readonly templateRef; private readonly viewContainer; private readonly renderer; private readonly ngZone; private platformId; /** * The referenced element */ private elem?; /** * ViewRef of the main template (the one to be truncated) */ private templateView; /** * ViewRef of the indicator template */ private indicatorView; /** * Concatenated template html at the time of the last time the ellipsis has been applied */ private previousTemplateHtml; /** * Text length before truncating */ private initialTextLength; /** * Subject triggered when resize listeners should be removed */ private removeResizeListeners$; private previousDimensions; /** * The ngxNestedEllipsis html attribute * Passing true (default) will perform the directive's task, * otherwise the template will be rendered without truncating its contents. */ active?: boolean | string; /** * The ellipsisIndicator html attribute * Passing a string (default: '...') will append it when the passed template has been truncated * Passing a template will append that template instead */ indicator: string | TemplateRef; /** * The ellipsisWordBoundaries html attribute * Each character passed to this input will be interpreted * as a word boundary at which the text may be truncated. * Else the text may be truncated at any character. */ wordBoundaries: string; /** * The ellipsisMayTruncateAtFn html attribute * Function that lets you specify whether the contents may be truncated at a specific point or not: * `(node: CharacterData, position: number) => boolean` * `node` Text node that is being truncated * `position` String position the text would be truncated at * Should return true, if the text may be truncated here, else false */ mayTruncateAtFn: (node: CharacterData, position: number) => boolean; /** * The ellipsisResizeDetection html attribute * Algorithm to use to detect element/window resize - any value of `EllipsisResizeDetectionEnum` */ resizeDetection: EllipsisResizeDetectionEnum; /** * The ellipsisChange html attribute * This emits after which index the text has been truncated. * If it hasn't been truncated, null is emitted. */ readonly ellipsisChange: EventEmitter; /** * Utility method to quickly find the largest number for * which `callback(number)` still returns true. * @param max Highest possible number * @param callback Should return true as long as the passed number is valid * @returns Largest possible number */ private static numericBinarySearch; private flattenTextAndElementNodes; /** * The directive's constructor */ constructor(templateRef: TemplateRef, viewContainer: ViewContainerRef, renderer: Renderer2, ngZone: NgZone, platformId: Object); /** * Angular's onInit life cycle hook. * Initializes the element for displaying the ellipsis. */ ngOnInit(): void; /** * Angular's destroy life cycle hook. * Remove event listeners */ ngOnDestroy(): void; /** * Angular's afterViewChecked life cycle hook. * Reapply ellipsis, if any of the templates have changed */ ngAfterViewChecked(): void; /** * Convert a list of Nodes to html * @param nodes Nodes to convert * @returns html code */ private nodesToHtml; /** * Convert the passed templates to html * @param templateView the main template view ref * @param indicatorView the indicator template view ref * @returns concatenated template html */ private templatesToHtml; /** * Whether any of the passed templates have changed since the last time * the ellipsis has been applied */ private get templatesHaveChanged(); /** * Restore the view from the templates (non-truncated) */ private restoreView; /** * Set up an event listener to call applyEllipsis() whenever a resize has been registered. * The type of the listener (window/element) depends on the `ellipsisResizeDetection`. */ private addResizeListener; /** * Set up an event listener to call applyEllipsis() whenever the window gets resized. */ private addWindowResizeListener; /** * Set up an event listener to call applyEllipsis() whenever ResizeObserver is triggered for the element. */ private addResizeObserver; /** * Get the original text's truncated version. If the text really needed to * be truncated, this.ellipsisCharacters will be appended. * @param max the maximum length the text may have * @returns the text node that has been truncated or null if truncating wasn't required */ private truncateContents; private get currentLength(); /** * Set the truncated text to be displayed in the inner div * @param max the maximum length the text may have * @param addMoreListener=false listen for click on the ellipsisCharacters anchor tag if the text has been truncated */ private truncateText; /** * Display ellipsis in the EllipsisContentComponent if the text would exceed the boundaries */ applyEllipsis(): void; /** * Whether the text is exceeding the element's boundaries or not */ private get isOverflowing(); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; }