starchild-widget
Version:
Starchild Widget
76 lines • 2.44 kB
TypeScript
import { StarChildWidget } from '../index';
import { WidgetConfig, ThemeMode, Locale, Position } from '../../types';
export interface UseStarChildWidgetReturn {
/** Widget instance */
widget: StarChildWidget | null;
/** Whether the widget is initialized */
isInitialized: boolean;
/** Initialize the Widget */
init: (config: WidgetConfig) => void;
/** Destroy the Widget */
destroy: () => void;
/** Update Widget config */
updateConfig: (config: Partial<WidgetConfig>) => void;
/** Get the current Widget config */
getConfig: () => WidgetConfig | null;
/** Set theme mode */
setThemeMode: (themeMode: ThemeMode) => void;
/** Set language */
setLocale: (locale: Locale) => void;
/** Set environment */
setEnvironment: (environment: 'testnet' | 'mainnet') => void;
/** Set Chat component visibility */
setChatVisible: (visible: boolean) => void;
/** Set Chat component disabled state */
setChatDisabled: (disabled: boolean) => void;
/** Set Chat component position */
setChatPosition: (position: Position) => void;
/** Show Chat modal */
showChatModal: (containerId?: string) => void;
/** Set Search component visibility */
setSearchVisible: (visible: boolean) => void;
/** Set Search component disabled state */
setSearchDisabled: (disabled: boolean) => void;
/** Set Search component value */
setSearchValue: (value: string) => void;
/** Set Search component placeholder */
setSearchPlaceholder: (placeholder: string) => void;
/** Reset Chat component position */
resetChatPosition: () => void;
}
/**
* StarChild Widget React Hook
* Unified React Hook API to control widget instance
*
* @example
* ```tsx
* function App() {
* const {
* widget,
* isInitialized,
* setThemeMode,
* setChatVisible,
* showChatModal,
* } = useStarChildWidget({
* config: {
* themeMode: ThemeMode.DARK,
* locale: Locale.ZH_CN,
* },
* autoInit: true,
* })
*
* return (
* <div>
* <button onClick={() => setThemeMode(ThemeMode.LIGHT)}>
* Switch to light mode
* </button>
* <button onClick={() => showChatModal()}>
* Open Chat
* </button>
* </div>
* )
* }
* ```
*/
export declare function useStarChildWidget(): UseStarChildWidgetReturn;
//# sourceMappingURL=useStarChildWidget.d.ts.map