analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
59 lines • 2.64 kB
TypeScript
import type { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
/**
* Text size variants — matches the `Text` component.
*/
export type TruncatedTextSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';
/**
* Font weight variants — matches the `Text` component.
*/
export type TruncatedTextWeight = 'hairline' | 'light' | 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black';
/**
* Tooltip position relative to the truncated element.
*/
export type TruncatedTextTooltipPosition = 'top' | 'bottom' | 'left' | 'right';
/**
* Base props for the TruncatedText component.
*/
type BaseProps = {
/** Text content rendered with `truncate`. Tooltip falls back to this when it's a string. */
children: ReactNode;
/** Optional override for the tooltip content. */
tooltipContent?: ReactNode;
/** Tooltip position relative to the text (default: 'top'). */
tooltipPosition?: TruncatedTextTooltipPosition;
/** Text size variant (default: 'md'). */
size?: TruncatedTextSize;
/** Font weight variant (default: 'normal'). */
weight?: TruncatedTextWeight;
/** Tailwind color class (default: 'text-text-950'). */
color?: string;
/** Additional class names for the text element. */
className?: string;
/** Additional class names for the tooltip wrapper. */
wrapperClassName?: string;
};
/**
* Polymorphic props — uses `as` to choose the underlying HTML element.
*/
export type TruncatedTextProps<T extends ElementType = 'span'> = BaseProps & {
/** HTML tag for the text element (default: 'span'). */
as?: T;
} & Omit<ComponentPropsWithoutRef<T>, keyof BaseProps | 'as' | 'ref'>;
/**
* Text that visually truncates on overflow (via Tailwind `truncate`) and
* always shows the design-system `Tooltip` with the full text on hover/focus.
*
* No JS overflow detection is performed: when the text fits, the tooltip
* still appears at hover but with the same visible content — an acceptable
* trade-off equivalent to the previously used HTML `title=` attribute,
* and the only approach that works across every container (table-layout
* auto/fixed, grid, flex) without changing existing layout.
*
* @example
* ```tsx
* <TruncatedText size="sm">{subject.name}</TruncatedText>
* ```
*/
export declare const TruncatedText: <T extends ElementType = "span">({ children, tooltipContent, tooltipPosition, size, weight, color, className, wrapperClassName, as, ...rest }: TruncatedTextProps<T>) => import("react/jsx-runtime").JSX.Element;
export default TruncatedText;
//# sourceMappingURL=TruncatedText.d.ts.map