Repository navigation
Expand file tree
/
Copy pathui.ts
More file actions
101 lines (90 loc) · 2.66 KB
/
Copy pathui.ts
File metadata and controls
101 lines (90 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
export type UIWidgetAction = {
id: string;
label: string;
value?: unknown;
variant?: 'primary' | 'secondary' | 'danger';
disabled?: boolean;
};
export type UIWidgetField = {
id: string;
label: string;
type: 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date' | 'password';
description?: string;
placeholder?: string;
required?: boolean;
options?: Array<{ label: string; value: string }>;
defaultValue?: unknown;
};
export type UIWidgetListItem = {
id: string;
label: string;
description?: string;
/** URL for a thumbnail or an icon name */
image?: string;
/** Optional badge text (e.g., "New", "Sale", "10") */
badge?: string;
/** Actions specific to this list item */
actions?: UIWidgetAction[];
/** Optional status label shown on the item (e.g. "Pending", "Shipped") */
status?: string;
/** Optional semantic hint for status coloring in the client */
statusVariant?: 'default' | 'success' | 'warning' | 'danger' | 'info';
metadata?: Record<string, unknown>;
};
export type UIMediaItem = {
type: 'image' | 'video' | 'audio' | 'file';
url: string;
title?: string;
alt?: string;
thumbnailUrl?: string;
metadata?: Record<string, unknown>;
};
export type UIWidgetBase = {
widgetId: string;
title?: string;
description?: string;
/** Optional hero media for the widget */
media?: UIMediaItem;
/** Optional actions for the widget */
actions?: UIWidgetAction[];
state?: 'open' | 'submitted' | 'cancelled' | 'error';
display?: 'expanded' | 'collapsed';
size?: 'small' | 'medium' | 'large' | 'full';
metadata?: Record<string, unknown>;
variant?: "default" | "basic",
};
export type UIMessageWidget = UIWidgetBase & {
kind: 'message';
body?: string;
};
export type UIChoiceWidget = UIWidgetBase & {
kind: 'choice';
/** Choice widgets require at least one action */
actions: UIWidgetAction[];
};
export type UIFormWidget = UIWidgetBase & {
kind: 'form';
fields: UIWidgetField[];
submitLabel?: string;
};
export type UIListWidget = UIWidgetBase & {
kind: 'list';
items: UIWidgetListItem[];
};
export type UIMediaWidget = UIWidgetBase & {
kind: 'media';
items: UIMediaItem[];
layout?: 'single' | 'grid' | 'carousel';
};
export type UIWidgetSpec =
| UIMessageWidget
| UIChoiceWidget
| UIFormWidget
| UIListWidget
| UIMediaWidget;
export type RenderUIWidgetData =
| (Omit<UIMessageWidget, 'widgetId'> & { widgetId?: string })
| (Omit<UIChoiceWidget, 'widgetId'> & { widgetId?: string })
| (Omit<UIFormWidget, 'widgetId'> & { widgetId?: string })
| (Omit<UIListWidget, 'widgetId'> & { widgetId?: string })
| (Omit<UIMediaWidget, 'widgetId'> & { widgetId?: string });