diff --git a/components/config-provider/context.ts b/components/config-provider/context.ts index 36f9ddf77e..226025c30b 100644 --- a/components/config-provider/context.ts +++ b/components/config-provider/context.ts @@ -1,6 +1,4 @@ import * as React from 'react'; -import type { ValidateMessages } from 'rc-field-form/lib/interface'; -import type { Options } from 'scroll-into-view-if-needed'; import type { WarningContextProps } from '../_util/warning'; import type { ShowWaveEffect } from '../_util/wave/interface'; @@ -8,15 +6,16 @@ import type { BadgeProps } from '../badge'; import type { ButtonProps } from '../button'; import type { DrawerProps } from '../drawer'; import type { FlexProps } from '../flex/interface'; -import type { RequiredMark } from '../form/Form'; +import type { FormProps } from '../form/Form'; import type { InputProps } from '../input'; import type { Locale } from '../locale'; import type { ModalProps } from '../modal'; +import type { PaginationProps } from '../pagination'; +import type { SelectProps } from '../select'; import type { SpaceProps } from '../space'; import type { TabsProps } from '../tabs'; import type { AliasToken, MappingAlgorithm, OverrideToken } from '../theme/interface'; import type { RenderEmptyHandler } from './defaultRenderEmpty'; -import type { SizeType } from './SizeContext'; export const defaultIconPrefixCls = 'anticon'; @@ -66,29 +65,15 @@ export interface ComponentStyleConfig { style?: React.CSSProperties; } -export interface ModalConfig extends ComponentStyleConfig { - classNames?: ModalProps['classNames']; - styles?: ModalProps['styles']; -} +export type ModalConfig = ComponentStyleConfig & Pick; -export interface BadgeConfig extends ComponentStyleConfig { - classNames?: BadgeProps['classNames']; - styles?: BadgeProps['styles']; -} +export type BadgeConfig = ComponentStyleConfig & Pick; -export interface ButtonConfig extends ComponentStyleConfig { - classNames?: ButtonProps['classNames']; - styles?: ButtonProps['styles']; -} +export type ButtonConfig = ComponentStyleConfig & Pick; -export interface DrawerConfig extends ComponentStyleConfig { - classNames?: DrawerProps['classNames']; - styles?: DrawerProps['styles']; -} +export type DrawerConfig = ComponentStyleConfig & Pick; -export interface FlexConfig extends ComponentStyleConfig { - vertical?: FlexProps['vertical']; -} +export type FlexConfig = ComponentStyleConfig & Pick; export type PopupOverflow = 'viewport' | 'scroll'; @@ -106,37 +91,19 @@ export interface ConfigConsumerProps { renderEmpty?: RenderEmptyHandler; csp?: CSPConfig; autoInsertSpaceInButton?: boolean; - input?: ComponentStyleConfig & { - autoComplete?: string; - classNames?: InputProps['classNames']; - styles?: InputProps['styles']; - }; - pagination?: ComponentStyleConfig & { showSizeChanger?: boolean }; + input?: ComponentStyleConfig & Pick; + pagination?: ComponentStyleConfig & Pick; locale?: Locale; - pageHeader?: { - ghost: boolean; - }; + pageHeader?: Record<'ghost', boolean>; direction?: DirectionType; - space?: { - size?: SizeType | number; - className?: SpaceProps['className']; - classNames?: SpaceProps['classNames']; - style?: SpaceProps['style']; - styles?: SpaceProps['styles']; - }; + space?: Pick; virtual?: boolean; popupMatchSelectWidth?: boolean; popupOverflow?: PopupOverflow; - form?: ComponentStyleConfig & { - requiredMark?: RequiredMark; - colon?: boolean; - scrollToFirstError?: Options | boolean; - validateMessages?: ValidateMessages; - }; + form?: ComponentStyleConfig & + Pick; theme?: ThemeConfig; - select?: ComponentStyleConfig & { - showSearch?: boolean; - }; + select?: ComponentStyleConfig & Pick; alert?: ComponentStyleConfig; anchor?: ComponentStyleConfig; button?: ButtonConfig; diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 3b217e8231..6a86c0185d 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -1,13 +1,12 @@ import * as React from 'react'; import { createTheme } from '@ant-design/cssinjs'; import IconContext from '@ant-design/icons/lib/components/Context'; -import type { ValidateMessages } from 'rc-field-form/lib/interface'; import useMemo from 'rc-util/lib/hooks/useMemo'; import { merge } from 'rc-util/lib/utils/set'; -import type { Options } from 'scroll-into-view-if-needed'; -import warning, { WarningContext, type WarningContextProps } from '../_util/warning'; -import type { RequiredMark } from '../form/Form'; +import warning, { WarningContext } from '../_util/warning'; +import type { WarningContextProps } from '../_util/warning'; +import type { FormProps } from '../form/Form'; import ValidateMessagesContext from '../form/validateMessagesContext'; import type { InputProps } from '../input'; import type { Locale } from '../locale'; @@ -15,6 +14,8 @@ import LocaleProvider, { ANT_MARK } from '../locale'; import type { LocaleContextProps } from '../locale/context'; import LocaleContext from '../locale/context'; import defaultLocale from '../locale/en_US'; +import type { PaginationProps } from '../pagination'; +import type { SelectProps } from '../select'; import type { SpaceProps } from '../space'; import type { TabsProps } from '../tabs'; import { defaultTheme, DesignTokenContext } from '../theme/context'; @@ -112,44 +113,24 @@ export interface ConfigProviderProps { renderEmpty?: RenderEmptyHandler; csp?: CSPConfig; autoInsertSpaceInButton?: boolean; - form?: ComponentStyleConfig & { - validateMessages?: ValidateMessages; - requiredMark?: RequiredMark; - colon?: boolean; - scrollToFirstError?: Options | boolean; - }; - input?: ComponentStyleConfig & { - classNames?: InputProps['classNames']; - styles?: InputProps['styles']; - autoComplete?: string; - }; - select?: ComponentStyleConfig & { - showSearch?: boolean; - }; - pagination?: ComponentStyleConfig & { showSizeChanger?: boolean }; + form?: ComponentStyleConfig & + Pick; + input?: ComponentStyleConfig & Pick; + select?: ComponentStyleConfig & Pick; + pagination?: ComponentStyleConfig & Pick; locale?: Locale; - pageHeader?: { - ghost: boolean; - }; + pageHeader?: Record<'ghost', boolean>; componentSize?: SizeType; componentDisabled?: boolean; direction?: DirectionType; - space?: { - size?: SizeType | number; - className?: SpaceProps['className']; - classNames?: SpaceProps['classNames']; - style?: SpaceProps['style']; - styles?: SpaceProps['styles']; - }; + space?: Pick; virtual?: boolean; /** @deprecated Please use `popupMatchSelectWidth` instead */ dropdownMatchSelectWidth?: boolean; popupMatchSelectWidth?: boolean; popupOverflow?: PopupOverflow; theme?: ThemeConfig; - warning?: WarningContextProps; - alert?: ComponentStyleConfig; anchor?: ComponentStyleConfig; button?: ButtonConfig; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index e355f26b4d..1b39e023c8 100644 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -215,7 +215,8 @@ const InternalForm: React.ForwardRefRenderFunction = (p const Form = React.forwardRef(InternalForm) as (( props: React.PropsWithChildren> & React.RefAttributes>, -) => React.ReactElement) & { displayName?: string }; +) => React.ReactElement) & + Pick; if (process.env.NODE_ENV !== 'production') { Form.displayName = 'Form'; diff --git a/components/tree/DirectoryTree.tsx b/components/tree/DirectoryTree.tsx index 07a810763d..85ad8b7233 100644 --- a/components/tree/DirectoryTree.tsx +++ b/components/tree/DirectoryTree.tsx @@ -22,7 +22,8 @@ export interface DirectoryTreeProps extends type DirectoryTreeCompoundedComponent = (( props: React.PropsWithChildren> & React.RefAttributes, -) => React.ReactElement) & { displayName?: string }; +) => React.ReactElement) & + Pick; export interface DirectoryTreeState { expandedKeys?: Key[];