-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwidget.tsx
More file actions
32 lines (27 loc) · 857 Bytes
/
widget.tsx
File metadata and controls
32 lines (27 loc) · 857 Bytes
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
"use client"
import { forwardRef, useMemo } from "react"
import "./app/globals.css"
import Home from "./app/page"
import { WidgetContextProvider } from "./lib/widgetContext"
import type { ChatInputHandle } from "./components/ChatInput"
export type { ChatInputHandle }
export interface ChatWidgetProps {
wsUrl?: string
className?: string
demo?: boolean
}
export const ChatWidget = forwardRef<ChatInputHandle, ChatWidgetProps>(
function ChatWidget({ wsUrl, className, demo }, ref) {
const modeValue = useMemo(
() => ({ isDetached: true, noBorder: true, wsUrl: wsUrl ?? null, demo: demo ?? false }),
[wsUrl, demo],
)
return (
<div className={className} data-mobileclaw-embedded>
<WidgetContextProvider value={modeValue}>
<Home ref={ref} />
</WidgetContextProvider>
</div>
)
},
)