UNPKG

use-truncate-from-middle

Version:

React hook which dynamically calculates the maximum number of characters that fit into an HTML element and truncates the text from middle with given middle chars.

7 lines (6 loc) 436 B
import { MutableRefObject } from 'react'; declare type TargetValue<T> = T | undefined | null; declare type TargetType = HTMLElement | Element | Window | Document; export declare type Target<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>; export declare function getTargetElement<T extends TargetType>(target: Target<T>, defaultElement?: T): TargetValue<T>; export {};