/**
 * UI 積木 - 介面元件介面
 * 用途: Card, Chart, Timeline, Status Indicators
 */

import type { LeWOOOgoPlugin } from './plugin'

/**
 * Widget 屬性
 */
export interface WidgetProps {
  id: string
  config: Record<string, unknown>
  data?: unknown
  className?: string
}

/**
 * Widget 配置 Schema (JSON Schema)
 */
export interface WidgetConfigSchema {
  type: 'object'
  properties: Record<string, unknown>
  required?: string[]
}

/**
 * Widget 預覽資訊
 */
export interface WidgetPreview {
  name: string
  description?: string
  thumbnail?: string
  defaultConfig: Record<string, unknown>
}

/**
 * UI Widget Plugin
 * 注意: React 元件在實作時透過泛型注入
 */
export interface WidgetComponent<RenderResult = unknown> extends LeWOOOgoPlugin {
  category: 'UI'

  /**
   * 渲染元件
   */
  render(props: WidgetProps): RenderResult

  /**
   * 取得配置 Schema
   */
  getConfigSchema(): WidgetConfigSchema

  /**
   * 取得預覽資訊
   */
  getPreview(): WidgetPreview
}
