diff --git a/components/_util/hooks/use-x-component-config.ts b/components/_util/hooks/use-x-component-config.ts index cee7fbdb..2250ae79 100644 --- a/components/_util/hooks/use-x-component-config.ts +++ b/components/_util/hooks/use-x-component-config.ts @@ -1,16 +1,23 @@ import React from 'react'; -import XProviderContext, { defaultXComponentConfig } from '../../x-provider/context'; +import XProviderContext from '../../x-provider/context'; -import type { DefaultXComponentConfig, XComponentsConfig } from '../../x-provider/context'; +import type { XComponentStyleConfig, XComponentsConfig } from '../../x-provider/context'; + +const defaultXComponentStyleConfig: XComponentStyleConfig = { + classNames: {}, + styles: {}, + className: '', + style: {}, +}; const useXComponentConfig = ( component: C, -): Required[C] & DefaultXComponentConfig => { +): Required[C] & XComponentStyleConfig => { const xProviderContext = React.useContext(XProviderContext); return React.useMemo( () => ({ - ...defaultXComponentConfig, + ...defaultXComponentStyleConfig, ...xProviderContext[component], }), [xProviderContext[component]], diff --git a/components/x-provider/context.ts b/components/x-provider/context.ts index cd7fa0c7..679a036e 100644 --- a/components/x-provider/context.ts +++ b/components/x-provider/context.ts @@ -1,7 +1,5 @@ import React from 'react'; -import type { ComponentStyleConfig as AntdComponentStyleConfig } from 'antd/es/config-provider/context'; - import type { AnyObject } from '../_util/type'; import type { BubbleProps } from '../bubble'; import type { ConversationsProps } from '../conversations'; @@ -10,26 +8,19 @@ import type { SenderProps } from '../sender'; import type { SuggestionProps } from '../suggestion'; import type { ThoughtChainProps } from '../thought-chain'; -export interface DefaultXComponentConfig { +export interface XComponentStyleConfig { classNames: Record; styles: Record; className: string; style: React.CSSProperties; } -export const defaultXComponentConfig: DefaultXComponentConfig = { - classNames: {}, - styles: {}, - className: '', - style: {}, -}; - -type DefaultPickType = keyof DefaultXComponentConfig; +type DefaultPickType = keyof XComponentStyleConfig; type ComponentStyleConfig< CompProps extends AnyObject, PickType extends keyof CompProps = DefaultPickType, -> = AntdComponentStyleConfig & Pick; +> = Pick; export interface XComponentsConfig { bubble?: ComponentStyleConfig;