import { Selection } from 'd3-selection'; import { TextAlign, TrimMode, UnovisText, UnovisTextFrameOptions, UnovisTextOptions, UnovisWrappedText, VerticalAlign } from '../types/text'; import { Rect } from '../types/misc'; export declare const textAlignToAnchor: (textAlign: TextAlign) => string | null; /** * Converts a kebab-case string to camelCase. * * @param {string} str - The kebab-case string to be converted. * @returns {string} The resulting camelCase string. */ export declare function kebabCaseToCamel(str: string): string; /** * Converts a given string to kebab-case. * @param {string} str - The input string to be converted to kebab-case. * @returns {string} - The kebab-cased string. */ export declare function kebabCase(str: string): string; export declare function escapeStringKeepHash(str: string): string; /** * Trims the input string from the start, leaving only the specified maximum length. * @param {string} str - The input string to be trimmed. * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string. * @returns {string} - The trimmed string. */ export declare function trimStringStart(str: string | undefined, maxLength?: number): string; /** * Trims the input string from the middle, leaving only the specified maximum length. * @param {string} str - The input string to be trimmed. * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string. * @returns {string} - The trimmed string. */ export declare function trimStringMiddle(str: string | undefined, maxLength?: number): string; /** * Trims the input string from the end, leaving only the specified maximum length. * @param {string} str - The input string to be trimmed. * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string. * @returns {string} - The trimmed string. */ export declare function trimStringEnd(str: string | undefined, maxLength?: number): string; /** * Trims the input string according to the specified trim mode. * @param {string} str - The input string to be trimmed. * @param {number} [length=15] - The maximum allowed length of the trimmed string. * @param {TrimMode} [type=TrimMode.Middle] - The trim mode to be applied. * @returns {string} - The trimmed string. */ export declare function trimString(str: string | undefined, length?: number, type?: TrimMode): string; /** * Splits the input string according to the specified separators. * @param {string} text - The input string to be split. * @param {string[]} [separators=[' ']] - The array of separators to be used for splitting. * @returns {string[]} - The array of split words. */ export declare function splitString(text: string, separators?: string[]): string[]; /** * Wraps an SVG text element to fit within the specified width. * @param {Selection} textElement - The SVG text element to be wrapped. * @param {number} width - The maximum allowed width for the text element. * @param {(string | string[])} [separator=[' ', '-', '.', ',']] - The separator(s) to be used for wrapping. */ export declare function wrapSVGText(textElement: Selection, width: number, separator?: string | string[]): void; /** * Trims an SVG text element based on the specified max width, trim type, and other options. * @param {Selection} svgTextSelection - The D3 selection of the SVG text element to be trimmed. * @param {number} [maxWidth=50] - The maximum width of the text element. * @param {TrimMode} [trimType=TrimMode.Middle] - The type of trim (start, middle, or end). * @param {boolean} [fastMode=false] - Whether to use a fast estimation method for text length calculation. * @param {number} [fontSize=0] - The font size of the text. * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio. * @returns {boolean} True if the text was trimmed, false otherwise. */ export declare function trimSVGText(svgTextSelection: Selection, maxWidth?: number, trimType?: TrimMode, fastMode?: boolean, fontSize?: number, fontWidthToHeightRatio?: number): boolean; /** * Estimates the dimensions of an SVG text element. * * @export * @param {Selection} svgTextSelection - The D3 selection of the SVG text element. * @param {number} fontSize - The font size. * @param {number} [dy=0.32] - The line height scaling factor. * @param {boolean} [fastMode=false] - Whether to use a fast estimation method or a more accurate one. * @param {number} [fontWidthToHeightRatio] - The font width-to-height ratio. * @returns {{width: number, height: number}} - The estimated dimensions of the text element. */ export declare function estimateTextSize(svgTextSelection: Selection, fontSize: number, dy?: number, fastMode?: boolean, fontWidthToHeightRatio?: number): { width: number; height: number; }; /** * Wraps a text or array of texts to fit within specified width and height, if provided. * * @export * @param {UnovisText | UnovisText[]} text - The text or array of texts to wrap. * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels. * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one. * @param {string | string[]} [separator] - The word separators. * @returns {UnovisWrappedText[]} - The wrapped texts. */ export declare function getWrappedText(text: UnovisText | UnovisText[], width?: number | undefined, height?: number | undefined, fastMode?: boolean, separator?: string | string[], wordBreak?: boolean): UnovisWrappedText[]; /** * Estimates the height of wrapped text blocks. * * @export * @param {UnovisWrappedText[]} blocks - The wrapped text blocks. * @returns {number} - The estimated height of the wrapped text blocks. */ export declare function estimateWrappedTextHeight(blocks: UnovisWrappedText[]): number; /** * Estimates the overall bounds of wrapped text blocks without touching the DOM. * * @export * @param {UnovisWrappedText[]} blocks - The wrapped text blocks. * @returns {{ width: number; height: number }} - The estimated width and height of the wrapped text blocks. */ export declare function getWrappedTextBounds(blocks: UnovisWrappedText[]): { width: number; height: number; }; /** * Computes the axis-aligned bounding box of wrapped text blocks as they would be rendered * by `renderTextToSvgTextElement`, relative to the text's anchor point. * * @export * @param {UnovisWrappedText[]} blocks - The wrapped text blocks. * @param {TextAlign | string} textAlign - The horizontal text alignment. * @param {VerticalAlign | string} verticalAlign - The vertical alignment of the text. * @param {number} [rotationDeg=0] - Text rotation in degrees, applied around the anchor point. * @returns {Rect} - The bounding box, in the coordinate system of the anchor point. */ export declare function getWrappedTextAabb(blocks: UnovisWrappedText[], textAlign: TextAlign | string, verticalAlign: VerticalAlign | string, rotationDeg?: number): Rect; export declare const allowedSvgTextTags: string[]; /** * Renders a text or array of texts to an SVG text element. * Calling this function will replace the contents of the specified SVG text element. * * @export * @param {SVGTextElement} textElement - The SVG text element to render the text into. * @param {UnovisText | UnovisText[]} text - The text or array of texts to render. * @param {UnovisTextOptions} options - The text options. * @returns {UnovisWrappedText[]} - The wrapped text blocks that were rendered. */ export declare function renderTextToSvgTextElement(textElement: SVGTextElement, text: UnovisText | UnovisText[], options: UnovisTextOptions, dominantBaseline?: string): UnovisWrappedText[]; /** * Renders a text or array of texts into a frame. * Calling this function will replace the contents of the specified SVG group. * * @export * @param {SVGGElement} group - The SVG group element to render the text into. * @param {UnovisText | UnovisText[]} text - The text or array of texts to render. * @param {UnovisTextFrameOptions} frameOptions - The text frame options. */ export declare function renderTextIntoFrame(group: SVGGElement, text: UnovisText | UnovisText[], frameOptions: UnovisTextFrameOptions): void;