import React, { PropsWithChildren, useContext } from 'react'; import { TUIChatHeaderDefaultProps } from '../components'; import type{ EmptyStateIndicatorProps } from '../components/EmptyStateIndicator'; import { MessageContextProps, TUIMessageProps } from '../components/TUIMessage'; export interface UnknowPorps { [propsName: string]: any } export interface ComponentContextValue { TUIMessage?: React.ComponentType, TUIChatHeader?: React.ComponentType, EmptyStateIndicator?: React.ComponentType, TUIMessageInput?: React.ComponentType, MessageContext?: React.ComponentType, InputPlugins?: React.ComponentType, MessagePlugins?: React.ComponentType, InputQuote?: React.ComponentType, } export const ComponentContext = React.createContext(undefined); export function ComponentProvider({ children, value, }: PropsWithChildren<{ value: ComponentContextValue; }>) { return ( {children} ); } export function useComponentContext( componentName?: string, ) { const contextValue = useContext(ComponentContext); if (!contextValue) { return {} as ComponentContextValue; } return contextValue as ComponentContextValue; }