Interface
ts
const widgetType = 'history' | 'comments' | 'files' | 'gallery' | 'descriptionList' | 'card';
// Common types for all widgets
export interface BaseWidgetProps {
id?: string
className?: string
style?: Record<string, any>
}
// Card widget types
export interface ICardItem {
name?: string
label?: string
component?: string
slot?: string
col?: number
width?: string | number
html?: string
title?: string
type?: string
count?: number
}
export interface ICard {
panels?: ICardItem[]
data?: any
view?: 'tab' | 'plain'
}
export interface CardProps extends BaseWidgetProps {
panels?: ICardItem[]
data?: any
view?: 'tab' | 'plain'
}
export interface CardItemProps extends BaseWidgetProps {
name?: string
label?: string
component?: string
slot?: string
col?: number
html?: string
title?: string
}
// Comments widget types
export interface Comment {
id: string;
entityId: string;
entityType: 'post' | 'file' | 'product' | 'custom';
author: string;
text: string;
createdAt: Date;
updatedAt?: Date;
parentId?: string;
replies?: Comment[];
status: 'visible' | 'hidden' | 'deleted';
keywords?: string[];
likes?: number;
}
export interface CommentsWidgetProps extends BaseWidgetProps {
title?: string,
comments: Comment[],
maxHeight?: number,
onAddComment?: (content: string) => void
onReply?: (commentId: string, content: string) => void
onLike?: (commentId: string, action: "add" | "delete") => void
onDelete?: (commentId: string) => void
onEdit?: (commentId: string, content: string) => void
}
// History widget types
export interface HistoryItem {
id: string;
entityId: string;
entityType: 'file' | 'post' | 'user' | 'custom';
action: 'created' | 'updated' | 'deleted' | 'moved' | 'renamed' | string;
userId: string;
userName: string;
timestamp: Date;
description?: string;
changes?: Record<string, { old: any; new: any }>;
status: 'success' | 'error' | 'pending';
}
export interface HistoryWidgetProps extends BaseWidgetProps {
data: HistoryItem[],
title?: string,
maxHeight?: number
}
// Files widget types
export interface FileItem {
id: string;
entityId: string;
entityType: 'post' | 'file' | 'product' | 'custom';
name: string;
path: string;
size: number;
type: string;
author: string;
description?: string;
keywords?: string[];
version: number;
status: 'active' | 'archived' | 'deleted';
createdAt: Date;
updatedAt?: Date;
}
export interface FileListType {
title?: string,
view?: 'grid' | 'list'| 'compact';
files: FileItem[];
maxHeight?: number;
}
export interface GalleryWidgetProps extends BaseWidgetProps {
title?: string,
items: FileItem[]
columns?: number
maxHeight?: number
}
// DescriptionList widget types
export interface DescriptionItem {
id?: string // optional unique ID
label: string // display name
value: string | number | boolean | Date
icon?: string // optional icon (for UI)
tooltip?: string // hover info
keywords?: string[] // for search/filter
type?: 'text' | 'link' | 'date' | 'status' | 'custom'
view?: 'inline' | 'block' | 'badge' // UI presentation style
}
export interface DescriptionList {
title?: string // optional section title
items: DescriptionItem[]
view?: 'table' | 'grid' // overall view mode for the list
}
export interface DescriptionListWidgetProps extends BaseWidgetProps {
title?: string
items: DescriptionItem[]
view?: 'table' | 'grid'
}