import { Selection as Selection$1, EnterElement } from 'd3-selection'; import { Props as Props$1 } from 'tippy.js'; import { ScaleLinear } from 'd3-scale'; import React$1 from 'react'; /** * Utility Types */ /** * Make all properties in T optional */ type Optional = { [P in keyof T]?: T[P]; }; /** * Min-max value pair [min, max] */ type MinMaxPair = [number, number]; /** * D3 scale type for word sizing */ type Scale = 'linear' | 'log' | 'sqrt'; /** * Spiral layout pattern type */ type Spiral = 'archimedean' | 'rectangular'; /** * Attribute value can be a string or a callback function */ type AttributeValue = string | WordToStringCallback; /** * D3 selection types for internal use */ type Selection = Selection$1; type Enter = Selection$1; /** * Callback Types */ /** * Callback that returns a string based on word object */ type WordToStringCallback = (word: Word) => string; /** * Callback for word events (click, mouseover, mouseout) */ type WordEventCallback = (word: Word, event?: MouseEvent) => void; /** * Core Interfaces */ /** * Word object interface * Must contain text and value, can have additional custom properties */ interface Word { /** The text content of the word */ text: string; /** The numeric value/weight of the word */ value: number; /** Allow additional custom properties */ [key: string]: unknown; } /** * Callback functions for word interactions and customization */ interface Callbacks { /** * Set the word color using the word object. */ getWordColor?: WordToStringCallback; /** * Set the word tooltip using the word object. */ getWordTooltip?: WordToStringCallback; /** * Capture the word and mouse event on click. */ onWordClick?: WordEventCallback; /** * Capture the word and mouse event on mouse-out. */ onWordMouseOut?: WordEventCallback; /** * Capture the word and mouse event on mouse over. */ onWordMouseOver?: WordEventCallback; } /** * Optional callbacks prop type */ type CallbacksProp = Optional; /** * Configuration options for wordcloud appearance and behavior */ interface Options { /** * Allows the wordcloud to randomly apply colors in the provided values. */ colors: string[]; /** * By default, words are randomly positioned and rotated. * If true, the wordcloud will produce the same rendering output for any input. */ deterministic: boolean; /** * (BETA) This feature is not formally supported. For more details, refer to the docs. * Enables optimizations for rendering larger wordclouds. * Note that this uses a custom cloud layout that batches the data into smaller subsets. */ enableOptimizations: boolean; /** * Enables/disables the tooltip feature. */ enableTooltip: boolean; /** * Customize the font family. */ fontFamily: string; /** * Specify the minimum and maximum font size as a tuple. * Tweak these numbers to control the best visual appearance for the wordcloud. */ fontSizes: MinMaxPair; /** * Accepts CSS values for font-styles (e.g. italic, oblique) */ fontStyle: string; /** * Accepts CSS values for font-weights (e.g. bold, 400, 700) */ fontWeight: string; /** * Controls the padding between words */ padding: number; /** * Set an optional random seed when `deterministic` option is set to `true`. */ randomSeed?: string; /** * Provide the minimum and maximum angles that words can be rotated. */ rotationAngles: MinMaxPair; /** * By default, the wordcloud will apply random rotations if this is not specified. * When provided, it will use evenly-divided angles from the provided min/max rotation angles. */ rotations?: number; /** * Control how words are spaced and laid out. */ scale: Scale; /** * Control the spiral pattern on how words are laid out. */ spiral: Spiral; /** * Customizable attributes to set on the rendered svg node */ svgAttributes: Record; /** * Customizable attributes to set on the rendered text nodes */ textAttributes: Record; /** * Additional props object to pass to the tooltip library. For more details, * refer to the documentation for * [Tippy.js Props](https://atomiks.github.io/tippyjs/v6/all-props/). */ tooltipOptions: Optional; /** * Sets the animation transition time in milliseconds. */ transitionDuration: number; } /** * Optional options prop type */ type OptionsProp = Optional; /** * React component props interface */ interface Props { /** * Callbacks to control various word properties and behaviors. */ callbacks?: CallbacksProp; /** * Maximum number of words to display. */ maxWords?: number; /** * Set minimum [width, height] values for the SVG container. */ minSize?: MinMaxPair; /** * Configure the wordcloud with various options. */ options?: OptionsProp; /** * Set explicit [width, height] values for the SVG container. * This will disable responsive resizing. * If undefined, the wordcloud will responsively size to its parent container. */ size?: MinMaxPair; /** * CSS styles for the container div. */ style?: React.CSSProperties; /** * An array of words. A word is an object that must contain the 'text' and 'value' keys. */ words: Word[]; } /** * Extended Word interface with layout properties * These properties are added by d3-cloud during layout calculation */ interface LayoutWord extends Word { size?: number; x?: number; y?: number; rotate?: number; } /** * Random number generator function type */ type RandomFunction = () => number; /** * Choose a random element from an array * @param array - Array to choose from * @param random - Random number generator function * @returns Randomly selected element */ declare function choose(array: T[], random: RandomFunction): T; /** * Get default color scheme (D3 Category10 with 20 colors) * @returns Array of 20 colors */ declare function getDefaultColors(): string[]; /** * Create a D3 scale function for font sizes based on word values * @param words - Array of words * @param fontSizes - Min and max font sizes [min, max] * @param scale - Scale type ('linear', 'log', or 'sqrt') * @returns D3 scale function */ declare function getFontScale(words: Word[], fontSizes: MinMaxPair, scale: Scale): ScaleLinear; /** * Get font size CSS string from word * @param word - Word with size property set by layout * @returns Font size string (e.g., "24px") */ declare function getFontSize(word: LayoutWord): string; /** * Get text content from word * @param word - Word object * @returns Text content */ declare function getText(word: Word): string; /** * Get SVG transform attribute value for word positioning * @param word - Word with x, y, and rotate properties set by layout * @returns Transform string (e.g., "translate(100, 50)rotate(45)") */ declare function getTransform(word: LayoutWord): string; /** * Calculate rotation angle for a word * @param rotations - Number of rotation angles to generate * @param rotationAngles - Min and max rotation angles [min, max] * @param random - Random number generator function * @returns Rotation angle in degrees */ declare function rotate(rotations: number, rotationAngles: MinMaxPair, random: RandomFunction): number; /** * Custom hook for creating a responsive SVG with D3 selection * Handles SVG creation, responsive resizing, and cleanup * * @param minSize - Minimum [width, height] for the SVG * @param initialSize - Optional fixed [width, height]. If undefined, SVG is responsive * @param svgAttributes - Optional SVG attributes to apply * @returns Tuple of [elementRef, d3Selection, currentSize] * elementRef.current는 마운트 전 null이므로 React 19 타입 규칙에 맞춰 null을 포함한다 */ declare function useResponsiveSvgSelection(minSize: MinMaxPair, initialSize: MinMaxPair | undefined, svgAttributes: Record | undefined): [React.RefObject, Selection | null, MinMaxPair]; /** * ReactWordcloud component * Renders an interactive word cloud visualization using D3 */ declare function ReactWordcloud({ callbacks, maxWords, minSize, options, size, style, words, }: Props): React$1.JSX.Element; /** * Default callback functions */ declare const defaultCallbacks: Callbacks; /** * Default options for wordcloud */ declare const defaultOptions: Options; export { type AttributeValue, type Callbacks, type CallbacksProp, type Enter, type LayoutWord, type MinMaxPair, type Optional, type Options, type OptionsProp, type Props, ReactWordcloud, type Scale, type Selection, type Spiral, type Word, type WordEventCallback, type WordToStringCallback, choose, ReactWordcloud as default, defaultCallbacks, defaultOptions, getDefaultColors, getFontScale, getFontSize, getText, getTransform, rotate, useResponsiveSvgSelection };