feat: add host actions visibility control in KefuChatShell
This commit is contained in:
@@ -29,6 +29,7 @@ export function KefuChatShell() {
|
||||
const [isMaximized, setIsMaximized] = useState(false)
|
||||
const [isCloseDialogOpen, setIsCloseDialogOpen] = useState(false)
|
||||
const [isClosingConversation, setIsClosingConversation] = useState(false)
|
||||
const [showHostActions, setShowHostActions] = useState(false)
|
||||
|
||||
const {
|
||||
title,
|
||||
@@ -95,6 +96,9 @@ export function KefuChatShell() {
|
||||
|
||||
useEffect(() => {
|
||||
return bindKefuHostBridge({
|
||||
onInit: () => {
|
||||
setShowHostActions(true)
|
||||
},
|
||||
onOpen: () => {
|
||||
setIsOpen(true)
|
||||
setIsVisible(true)
|
||||
@@ -214,6 +218,7 @@ export function KefuChatShell() {
|
||||
>
|
||||
<RotateCwIcon className="size-3.75 transition duration-200 group-hover:rotate-[-20deg]" />
|
||||
</button>
|
||||
{showHostActions ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleMinimize}
|
||||
@@ -223,6 +228,8 @@ export function KefuChatShell() {
|
||||
>
|
||||
<MinusIcon className="size-3.75 transition duration-200 group-hover:scale-x-[0.88]" />
|
||||
</button>
|
||||
) : null}
|
||||
{showHostActions ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleToggleMaximize}
|
||||
@@ -236,6 +243,7 @@ export function KefuChatShell() {
|
||||
<Maximize2Icon className="size-3.75 transition duration-200 group-hover:scale-[1.04]" />
|
||||
)}
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsCloseDialogOpen(true)}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
} from "@/lib/kefu-widget-config"
|
||||
|
||||
type HostBridgeOptions = {
|
||||
onInit?: () => void
|
||||
onOpen?: () => void
|
||||
onMinimize?: () => void
|
||||
onMaximizedChange?: (isMaximized: boolean) => void
|
||||
@@ -40,6 +41,7 @@ export function bindKefuHostBridge(options: HostBridgeOptions = {}) {
|
||||
|
||||
if (data.type === INIT_MESSAGE_TYPE && data.payload) {
|
||||
setKefuWidgetConfig(data.payload as KefuWidgetHostConfig)
|
||||
options.onInit?.()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user