import type { CSSProperties } from 'react'; import type { BaseTextInputProps } from '@pisell/utils'; /** * PisellUrl 组件 Props 类型定义 * * 继承 BaseTextInputProps,添加 URL 特有的配置 */ export interface PisellUrlProps extends BaseTextInputProps { /** * 状态模式 * @default 'edit' */ mode?: 'read' | 'edit'; /** * 是否禁用 * @default false */ disabled?: boolean; /** * 是否使用严格校验 * @default true */ strictValidation?: boolean; /** * 允许的协议列表 * @example ['http', 'https'] * @default ['http', 'https'] */ allowedProtocols?: string[]; /** * 是否要求必须有协议 * @default false */ requireProtocol?: boolean; /** * 是否自动补全协议 * @default true */ autoCompleteProtocol?: boolean; /** * 默认协议 * @default 'https://' */ defaultProtocol?: 'http://' | 'https://'; /** * 协议补全回调 * @param url 补全后的 URL */ onProtocolComplete?: (url: string) => void; /** * 是否启用链接跳转(只读态) * @default true */ enableLinkClick?: boolean; /** * 是否新窗口打开 * @default true */ openInNewWindow?: boolean; /** * 是否显示链接图标 * @default true */ showLinkIcon?: boolean; /** * 链接点击回调 * @param url URL 地址 */ onLinkClick?: (url: string) => void; /** * 是否显示协议(只读态) * @default false */ showProtocol?: boolean; /** * 是否显示 www 前缀(只读态) * @default false */ showWww?: boolean; /** * 是否显示路径(只读态) * @default true */ showPathname?: boolean; /** * 显示格式(只读态) * - full: 完整 URL * - domain: 仅域名 * - custom: 自定义格式 * @default 'full' */ displayFormat?: 'full' | 'domain' | 'custom'; /** * 自定义格式化函数(只读态) * @param url URL 地址 * @returns 格式化后的显示文本 */ customFormat?: (url: string) => string; /** * 字号 * @example '14px' 或 14 * @default 16 */ fontSize?: string | number; /** * 字重 * @example 'bold' 或 600 * @default 500 */ fontWeight?: string | number; /** * 文本颜色 * @example '#000000' * @default '#101828' */ color?: string; /** * 链接颜色(只读态) * @example '#1890ff' * @default '#7F56DA' */ linkColor?: string; /** * 占位文本 * @default '请输入 URL 地址' */ placeholder?: string; /** * 最大长度 * @default 2048 */ maxLength?: number; /** * 是否显示清空按钮 * @default false */ allowClear?: boolean; /** * 是否自动聚焦 * @default false */ autoFocus?: boolean; /** * 自定义类名 */ className?: string; /** * 自定义样式 */ style?: CSSProperties; /** * ARIA 标签 */ 'aria-label'?: string; /** * ARIA 描述 */ 'aria-describedby'?: string; } export type { DisplayState, ValidationResult, TextInputState } from '@pisell/utils';