import React from "react"; import { TestableComponent } from "../../components/interfaces"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; export interface OverflowTextProps extends React.HTMLAttributes, TestableComponent { /** * How is ellipsis used to cut text overflows. * Use `reverse`to use the ellipis on text start and display the end of the text. */ ellipsis?: "add" | "reverse" | "none"; /** * Display component as inline element. */ inline?: boolean; /** * Using text overflow on all children elements. */ passDown?: boolean; /** * Additional CSS class name. */ className?: string; /** * HTML element that is used for the component. */ useHtmlElement?: "p" | "div" | "span"; } /** Prevents text from overflowing. */ export const OverflowText = ({ className = "", children, ellipsis = "add", inline = false, passDown = false, useHtmlElement, ...otherProps }: OverflowTextProps) => { const defaultHtmlElement = inline ? "span" : "div"; const overflowtextElement = useHtmlElement ? React.createElement(useHtmlElement) : React.createElement(defaultHtmlElement); return ( {children} ); }; export default OverflowText;