UNPKG

@gulibs/vgrove-ui

Version:

VGrove UI component library built with HeroUI and React

49 lines 1.88 kB
import React from 'react'; import type { ReactNode, ComponentType } from 'react'; export type I18nMessageFormat = 'text' | 'html' | 'markdown' | 'component'; export interface I18nMessageProps<Keys extends string = string> { /** 翻译键 - 类型安全,与 @gulibs/vgrove-i18n 生成的类型兼容 */ id: Keys; /** 插值参数 - 支持嵌套对象 */ params?: Record<string, unknown>; /** 默认值(当翻译不存在时使用) */ defaultValue?: string; /** 渲染格式 */ format?: I18nMessageFormat; /** 自定义渲染函数 */ render?: (text: string) => ReactNode; /** 包装元素 */ as?: keyof React.JSX.IntrinsicElements | ComponentType<Record<string, unknown>>; /** 自定义类名 */ className?: string; } /** * 国际化消息组件 * * 支持泛型语法: <I18nMessage<KeyType> id="key" /> * * @example * // 基本使用 * <I18nMessage id="welcome" /> * * // 带泛型类型约束 * <I18nMessage<'home.title' | 'home.subtitle'> id="home.title" /> * * // 带参数 * <I18nMessage id="user.greeting" params={{ name: 'John' }} /> */ export declare const I18nMessage: (<Keys extends string = string>(props: I18nMessageProps<Keys>) => React.ReactElement) & { displayName?: string; }; export declare const I18nTitle: (<Keys extends string = string>(props: Omit<I18nMessageProps<Keys>, "as" | "format"> & { level?: 1 | 2 | 3 | 4 | 5 | 6; }) => React.ReactElement) & { displayName?: string; }; export declare const I18nParagraph: (<Keys extends string = string>(props: Omit<I18nMessageProps<Keys>, "as" | "format">) => React.ReactElement) & { displayName?: string; }; export declare const I18nText: (<Keys extends string = string>(props: Omit<I18nMessageProps<Keys>, "as" | "format">) => React.ReactElement) & { displayName?: string; }; //# sourceMappingURL=I18nMessage.d.ts.map