@codrstudio/openclaude-chat 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/components/StreamingIndicator.js +5 -5
  2. package/dist/display/DisplayReactRenderer.js +12 -12
  3. package/dist/display/react-sandbox/bootstrap.js +150 -150
  4. package/dist/styles.css +1 -2
  5. package/package.json +64 -61
  6. package/src/components/Chat.tsx +107 -107
  7. package/src/components/ErrorNote.tsx +35 -35
  8. package/src/components/LazyRender.tsx +42 -42
  9. package/src/components/Markdown.tsx +114 -114
  10. package/src/components/MessageBubble.tsx +107 -107
  11. package/src/components/MessageInput.tsx +421 -421
  12. package/src/components/MessageList.tsx +153 -153
  13. package/src/components/StreamingIndicator.tsx +19 -19
  14. package/src/display/AlertRenderer.tsx +23 -23
  15. package/src/display/CarouselRenderer.tsx +141 -141
  16. package/src/display/ChartRenderer.tsx +195 -195
  17. package/src/display/ChoiceButtonsRenderer.tsx +114 -114
  18. package/src/display/CodeBlockRenderer.tsx +49 -49
  19. package/src/display/ComparisonTableRenderer.tsx +132 -132
  20. package/src/display/DataTableRenderer.tsx +144 -144
  21. package/src/display/DisplayReactRenderer.tsx +269 -269
  22. package/src/display/FileCardRenderer.tsx +55 -55
  23. package/src/display/GalleryRenderer.tsx +65 -65
  24. package/src/display/ImageViewerRenderer.tsx +114 -114
  25. package/src/display/LinkPreviewRenderer.tsx +74 -74
  26. package/src/display/MapViewRenderer.tsx +75 -75
  27. package/src/display/MetricCardRenderer.tsx +29 -29
  28. package/src/display/PriceHighlightRenderer.tsx +62 -62
  29. package/src/display/ProductCardRenderer.tsx +112 -112
  30. package/src/display/ProgressStepsRenderer.tsx +59 -59
  31. package/src/display/SourcesListRenderer.tsx +47 -47
  32. package/src/display/SpreadsheetRenderer.tsx +86 -86
  33. package/src/display/StepTimelineRenderer.tsx +75 -75
  34. package/src/display/index.ts +21 -21
  35. package/src/display/react-sandbox/bootstrap.ts +155 -155
  36. package/src/display/registry.ts +84 -84
  37. package/src/display/sdk-types.ts +217 -217
  38. package/src/hooks/ChatProvider.tsx +21 -21
  39. package/src/hooks/useIsMobile.ts +15 -15
  40. package/src/hooks/useOpenClaudeChat.ts +476 -476
  41. package/src/index.ts +76 -76
  42. package/src/lib/utils.ts +6 -6
  43. package/src/parts/PartErrorBoundary.tsx +51 -51
  44. package/src/parts/PartRenderer.tsx +145 -145
  45. package/src/parts/ReasoningBlock.tsx +41 -41
  46. package/src/parts/ToolActivity.tsx +78 -78
  47. package/src/parts/ToolResult.tsx +79 -79
  48. package/src/styles.css +2 -2
  49. package/src/types.ts +41 -41
  50. package/src/ui/alert.tsx +77 -77
  51. package/src/ui/badge.tsx +36 -36
  52. package/src/ui/button.tsx +54 -54
  53. package/src/ui/card.tsx +68 -68
  54. package/src/ui/collapsible.tsx +7 -7
  55. package/src/ui/dialog.tsx +122 -122
  56. package/src/ui/dropdown-menu.tsx +76 -76
  57. package/src/ui/input.tsx +24 -24
  58. package/src/ui/progress.tsx +36 -36
  59. package/src/ui/scroll-area.tsx +48 -48
  60. package/src/ui/separator.tsx +31 -31
  61. package/src/ui/skeleton.tsx +9 -9
  62. package/src/ui/table.tsx +114 -114
@@ -1,217 +1,217 @@
1
- // Tipos dos display widgets — espelham os schemas em
2
- // D:\aw\context\workspaces\openclaude-sdk\repo\src\display\schemas.ts
3
- // Mantemos local para nao ter dependencia dura em typings da SDK.
4
-
5
- export type Money = {
6
- value: number;
7
- currency?: string;
8
- };
9
-
10
- export type SourceRef = {
11
- name: string;
12
- url: string;
13
- favicon?: string;
14
- };
15
-
16
- export type DisplayBadge = {
17
- label: string;
18
- variant?: "default" | "success" | "warning" | "error" | "info";
19
- };
20
-
21
- // 1. METRICAS E DADOS ────────────────────────────────────────────
22
-
23
- export type DisplayMetric = {
24
- label: string;
25
- value: string | number;
26
- unit?: string;
27
- trend?: {
28
- direction: "up" | "down" | "neutral";
29
- value: string;
30
- };
31
- icon?: string;
32
- };
33
-
34
- export type DisplayChart = {
35
- type: "bar" | "line" | "pie" | "area" | "donut";
36
- title: string;
37
- data: Array<{
38
- label: string;
39
- value: number;
40
- color?: string;
41
- }>;
42
- format?: {
43
- prefix?: string;
44
- suffix?: string;
45
- locale?: string;
46
- };
47
- };
48
-
49
- export type DisplayTable = {
50
- title?: string;
51
- columns: Array<{
52
- key: string;
53
- label: string;
54
- type?: "text" | "number" | "money" | "image" | "link" | "badge";
55
- align?: "left" | "center" | "right";
56
- }>;
57
- rows: Array<Record<string, unknown>>;
58
- sortable?: boolean;
59
- };
60
-
61
- export type DisplayProgress = {
62
- title?: string;
63
- steps: Array<{
64
- label: string;
65
- status: "completed" | "current" | "pending";
66
- description?: string;
67
- }>;
68
- };
69
-
70
- // 2. PRODUTOS E COMERCIO ─────────────────────────────────────────
71
-
72
- export type DisplayProduct = {
73
- title: string;
74
- image?: string;
75
- price?: Money;
76
- originalPrice?: Money;
77
- rating?: {
78
- score: number;
79
- count: number;
80
- };
81
- source?: SourceRef;
82
- badges?: DisplayBadge[];
83
- url?: string;
84
- description?: string;
85
- };
86
-
87
- export type DisplayComparison = {
88
- title?: string;
89
- items: DisplayProduct[];
90
- attributes?: Array<{ key: string; label: string }>;
91
- };
92
-
93
- export type DisplayPrice = {
94
- value: Money;
95
- label: string;
96
- context?: string;
97
- source?: SourceRef;
98
- badge?: DisplayBadge;
99
- };
100
-
101
- // 3. MIDIA ───────────────────────────────────────────────────────
102
-
103
- export type DisplayImage = {
104
- url: string;
105
- alt?: string;
106
- caption?: string;
107
- width?: number;
108
- height?: number;
109
- };
110
-
111
- export type DisplayGallery = {
112
- title?: string;
113
- images: Array<{ url: string; alt?: string; caption?: string }>;
114
- layout?: "grid" | "masonry";
115
- columns?: number;
116
- };
117
-
118
- export type DisplayCarousel = {
119
- title?: string;
120
- items: Array<{
121
- image?: string;
122
- title: string;
123
- subtitle?: string;
124
- price?: Money;
125
- url?: string;
126
- badges?: DisplayBadge[];
127
- }>;
128
- };
129
-
130
- // 4. REFERENCIAS E NAVEGACAO ─────────────────────────────────────
131
-
132
- export type DisplaySources = {
133
- label?: string;
134
- sources: Array<{
135
- title: string;
136
- url: string;
137
- favicon?: string;
138
- snippet?: string;
139
- }>;
140
- };
141
-
142
- export type DisplayLink = {
143
- url: string;
144
- title: string;
145
- description?: string;
146
- image?: string;
147
- favicon?: string;
148
- domain?: string;
149
- };
150
-
151
- export type DisplayMap = {
152
- title?: string;
153
- pins: Array<{
154
- lat: number;
155
- lng: number;
156
- label?: string;
157
- address?: string;
158
- }>;
159
- zoom?: number;
160
- };
161
-
162
- // 5. DOCUMENTOS E ARQUIVOS ───────────────────────────────────────
163
-
164
- export type DisplayFile = {
165
- name: string;
166
- type: string;
167
- size?: number;
168
- url?: string;
169
- preview?: string;
170
- };
171
-
172
- export type DisplayCode = {
173
- language: string;
174
- code: string;
175
- title?: string;
176
- lineNumbers?: boolean;
177
- };
178
-
179
- export type DisplaySpreadsheet = {
180
- title?: string;
181
- headers: string[];
182
- rows: Array<Array<string | number | null>>;
183
- format?: {
184
- moneyColumns?: number[];
185
- percentColumns?: number[];
186
- };
187
- };
188
-
189
- // 6. INTERATIVO ──────────────────────────────────────────────────
190
-
191
- export type DisplaySteps = {
192
- title?: string;
193
- steps: Array<{
194
- title: string;
195
- description?: string;
196
- status?: "completed" | "current" | "pending";
197
- }>;
198
- orientation?: "vertical" | "horizontal";
199
- };
200
-
201
- export type DisplayAlert = {
202
- variant: "info" | "warning" | "error" | "success";
203
- title?: string;
204
- message: string;
205
- icon?: string;
206
- };
207
-
208
- export type DisplayChoices = {
209
- question?: string;
210
- choices: Array<{
211
- id: string;
212
- label: string;
213
- description?: string;
214
- icon?: string;
215
- }>;
216
- layout?: "buttons" | "cards" | "list";
217
- };
1
+ // Tipos dos display widgets — espelham os schemas em
2
+ // D:\aw\context\workspaces\openclaude-sdk\repo\src\display\schemas.ts
3
+ // Mantemos local para nao ter dependencia dura em typings da SDK.
4
+
5
+ export type Money = {
6
+ value: number;
7
+ currency?: string;
8
+ };
9
+
10
+ export type SourceRef = {
11
+ name: string;
12
+ url: string;
13
+ favicon?: string;
14
+ };
15
+
16
+ export type DisplayBadge = {
17
+ label: string;
18
+ variant?: "default" | "success" | "warning" | "error" | "info";
19
+ };
20
+
21
+ // 1. METRICAS E DADOS ────────────────────────────────────────────
22
+
23
+ export type DisplayMetric = {
24
+ label: string;
25
+ value: string | number;
26
+ unit?: string;
27
+ trend?: {
28
+ direction: "up" | "down" | "neutral";
29
+ value: string;
30
+ };
31
+ icon?: string;
32
+ };
33
+
34
+ export type DisplayChart = {
35
+ type: "bar" | "line" | "pie" | "area" | "donut";
36
+ title: string;
37
+ data: Array<{
38
+ label: string;
39
+ value: number;
40
+ color?: string;
41
+ }>;
42
+ format?: {
43
+ prefix?: string;
44
+ suffix?: string;
45
+ locale?: string;
46
+ };
47
+ };
48
+
49
+ export type DisplayTable = {
50
+ title?: string;
51
+ columns: Array<{
52
+ key: string;
53
+ label: string;
54
+ type?: "text" | "number" | "money" | "image" | "link" | "badge";
55
+ align?: "left" | "center" | "right";
56
+ }>;
57
+ rows: Array<Record<string, unknown>>;
58
+ sortable?: boolean;
59
+ };
60
+
61
+ export type DisplayProgress = {
62
+ title?: string;
63
+ steps: Array<{
64
+ label: string;
65
+ status: "completed" | "current" | "pending";
66
+ description?: string;
67
+ }>;
68
+ };
69
+
70
+ // 2. PRODUTOS E COMERCIO ─────────────────────────────────────────
71
+
72
+ export type DisplayProduct = {
73
+ title: string;
74
+ image?: string;
75
+ price?: Money;
76
+ originalPrice?: Money;
77
+ rating?: {
78
+ score: number;
79
+ count: number;
80
+ };
81
+ source?: SourceRef;
82
+ badges?: DisplayBadge[];
83
+ url?: string;
84
+ description?: string;
85
+ };
86
+
87
+ export type DisplayComparison = {
88
+ title?: string;
89
+ items: DisplayProduct[];
90
+ attributes?: Array<{ key: string; label: string }>;
91
+ };
92
+
93
+ export type DisplayPrice = {
94
+ value: Money;
95
+ label: string;
96
+ context?: string;
97
+ source?: SourceRef;
98
+ badge?: DisplayBadge;
99
+ };
100
+
101
+ // 3. MIDIA ───────────────────────────────────────────────────────
102
+
103
+ export type DisplayImage = {
104
+ url: string;
105
+ alt?: string;
106
+ caption?: string;
107
+ width?: number;
108
+ height?: number;
109
+ };
110
+
111
+ export type DisplayGallery = {
112
+ title?: string;
113
+ images: Array<{ url: string; alt?: string; caption?: string }>;
114
+ layout?: "grid" | "masonry";
115
+ columns?: number;
116
+ };
117
+
118
+ export type DisplayCarousel = {
119
+ title?: string;
120
+ items: Array<{
121
+ image?: string;
122
+ title: string;
123
+ subtitle?: string;
124
+ price?: Money;
125
+ url?: string;
126
+ badges?: DisplayBadge[];
127
+ }>;
128
+ };
129
+
130
+ // 4. REFERENCIAS E NAVEGACAO ─────────────────────────────────────
131
+
132
+ export type DisplaySources = {
133
+ label?: string;
134
+ sources: Array<{
135
+ title: string;
136
+ url: string;
137
+ favicon?: string;
138
+ snippet?: string;
139
+ }>;
140
+ };
141
+
142
+ export type DisplayLink = {
143
+ url: string;
144
+ title: string;
145
+ description?: string;
146
+ image?: string;
147
+ favicon?: string;
148
+ domain?: string;
149
+ };
150
+
151
+ export type DisplayMap = {
152
+ title?: string;
153
+ pins: Array<{
154
+ lat: number;
155
+ lng: number;
156
+ label?: string;
157
+ address?: string;
158
+ }>;
159
+ zoom?: number;
160
+ };
161
+
162
+ // 5. DOCUMENTOS E ARQUIVOS ───────────────────────────────────────
163
+
164
+ export type DisplayFile = {
165
+ name: string;
166
+ type: string;
167
+ size?: number;
168
+ url?: string;
169
+ preview?: string;
170
+ };
171
+
172
+ export type DisplayCode = {
173
+ language: string;
174
+ code: string;
175
+ title?: string;
176
+ lineNumbers?: boolean;
177
+ };
178
+
179
+ export type DisplaySpreadsheet = {
180
+ title?: string;
181
+ headers: string[];
182
+ rows: Array<Array<string | number | null>>;
183
+ format?: {
184
+ moneyColumns?: number[];
185
+ percentColumns?: number[];
186
+ };
187
+ };
188
+
189
+ // 6. INTERATIVO ──────────────────────────────────────────────────
190
+
191
+ export type DisplaySteps = {
192
+ title?: string;
193
+ steps: Array<{
194
+ title: string;
195
+ description?: string;
196
+ status?: "completed" | "current" | "pending";
197
+ }>;
198
+ orientation?: "vertical" | "horizontal";
199
+ };
200
+
201
+ export type DisplayAlert = {
202
+ variant: "info" | "warning" | "error" | "success";
203
+ title?: string;
204
+ message: string;
205
+ icon?: string;
206
+ };
207
+
208
+ export type DisplayChoices = {
209
+ question?: string;
210
+ choices: Array<{
211
+ id: string;
212
+ label: string;
213
+ description?: string;
214
+ icon?: string;
215
+ }>;
216
+ layout?: "buttons" | "cards" | "list";
217
+ };
@@ -1,21 +1,21 @@
1
- import React, { createContext, useContext } from "react";
2
- import { useOpenClaudeChat, type UseOpenClaudeChatOptions } from "./useOpenClaudeChat.js";
3
-
4
- type ChatContextValue = ReturnType<typeof useOpenClaudeChat>;
5
-
6
- const ChatContext = createContext<ChatContextValue | null>(null);
7
-
8
- export interface ChatProviderProps extends UseOpenClaudeChatOptions {
9
- children: React.ReactNode;
10
- }
11
-
12
- export function ChatProvider({ children, ...options }: ChatProviderProps) {
13
- const chat = useOpenClaudeChat(options);
14
- return <ChatContext.Provider value={chat}>{children}</ChatContext.Provider>;
15
- }
16
-
17
- export function useChatContext(): ChatContextValue {
18
- const ctx = useContext(ChatContext);
19
- if (!ctx) throw new Error("useChatContext must be used within ChatProvider");
20
- return ctx;
21
- }
1
+ import React, { createContext, useContext } from "react";
2
+ import { useOpenClaudeChat, type UseOpenClaudeChatOptions } from "./useOpenClaudeChat.js";
3
+
4
+ type ChatContextValue = ReturnType<typeof useOpenClaudeChat>;
5
+
6
+ const ChatContext = createContext<ChatContextValue | null>(null);
7
+
8
+ export interface ChatProviderProps extends UseOpenClaudeChatOptions {
9
+ children: React.ReactNode;
10
+ }
11
+
12
+ export function ChatProvider({ children, ...options }: ChatProviderProps) {
13
+ const chat = useOpenClaudeChat(options);
14
+ return <ChatContext.Provider value={chat}>{children}</ChatContext.Provider>;
15
+ }
16
+
17
+ export function useChatContext(): ChatContextValue {
18
+ const ctx = useContext(ChatContext);
19
+ if (!ctx) throw new Error("useChatContext must be used within ChatProvider");
20
+ return ctx;
21
+ }
@@ -1,15 +1,15 @@
1
- import { useState, useEffect } from "react";
2
-
3
- export function useIsMobile(breakpoint = 768): boolean {
4
- const [isMobile, setIsMobile] = useState(false);
5
-
6
- useEffect(() => {
7
- const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
8
- const onChange = () => setIsMobile(mql.matches);
9
- onChange();
10
- mql.addEventListener("change", onChange);
11
- return () => mql.removeEventListener("change", onChange);
12
- }, [breakpoint]);
13
-
14
- return isMobile;
15
- }
1
+ import { useState, useEffect } from "react";
2
+
3
+ export function useIsMobile(breakpoint = 768): boolean {
4
+ const [isMobile, setIsMobile] = useState(false);
5
+
6
+ useEffect(() => {
7
+ const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
8
+ const onChange = () => setIsMobile(mql.matches);
9
+ onChange();
10
+ mql.addEventListener("change", onChange);
11
+ return () => mql.removeEventListener("change", onChange);
12
+ }, [breakpoint]);
13
+
14
+ return isMobile;
15
+ }