@artmate/chat
Version:
借鉴字节开源react库AntX,通过vue实现的版本
93 lines (92 loc) • 2.36 kB
TypeScript
import { DropDownItemProps } from '../dropdown/interface';
import { Component, CSSProperties, VNode } from 'vue';
type GroupType = string;
export interface MenuProps {
items: DropDownItemProps[];
onClick?: (value: Conversation) => void;
}
/**
* @desc 会话数据
* @descEN Conversation data
*/
export interface Conversation extends Record<PropertyKey, any> {
/**
* @desc 唯一标识
* @descEN Unique identifier
*/
key: string;
/**
* @desc 会话名称
* @descEN Conversation name
*/
label?: string;
/**
* @desc 会话时间戳
* @descEN Conversation timestamp
*/
timestamp?: number;
/**
* @desc 会话分组类型,与 {@link ConversationsProps.groupable} 联动
* @descEN Conversation type
*/
group?: GroupType;
/**
* @desc 会话图标
* @descEN conversation icon
*/
icon?: string | VNode;
/**
* @desc 是否禁用
* @descEN Whether to disable
*/
disabled?: boolean;
}
export interface ItemProps {
direction?: 'ltr' | 'rtl';
className?: string;
active?: boolean;
info?: Conversation;
menu?: MenuProps | DropDownItemProps[];
inEllipsis?: boolean;
line?: number;
}
export type GroupSorter = Parameters<GroupType[]['sort']>[0];
export type GroupTitleRenderComponents = {
components: {
GroupTitle: Component<any>;
};
};
export type GroupTitleRender = ((group: GroupType, info: GroupTitleRenderComponents | string) => number | string | VNode) | undefined;
export interface Groupable {
/**
* @desc 分组排序函数
* @descEN Group sorter
*/
sort?: GroupSorter;
/**
* @desc 自定义分组标签渲染
* @descEN Semantic custom rendering
*/
title?: GroupTitleRender;
}
export interface ConversationsProps {
style?: CSSProperties;
className?: string;
direction?: 'ltr' | 'rtl';
groupable?: boolean | Groupable;
items?: Conversation[];
defaultActiveKey?: string;
activeKey?: string;
onActiveChange?: (value: string) => boolean;
classNames?: {
item: string;
};
styles?: {
item: CSSProperties;
};
menu?: ((value: Conversation) => MenuProps) | DropDownItemProps[];
}
export interface GroupTitleProps {
direction?: ItemProps['direction'];
}
export {};