mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-31 12:18:42 +08:00
type: TS define optimal (#47153)
This commit is contained in:
parent
5e96d6bdf8
commit
aa137e96af
@ -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<ModalProps, 'classNames' | 'styles'>;
|
||||
|
||||
export interface BadgeConfig extends ComponentStyleConfig {
|
||||
classNames?: BadgeProps['classNames'];
|
||||
styles?: BadgeProps['styles'];
|
||||
}
|
||||
export type BadgeConfig = ComponentStyleConfig & Pick<BadgeProps, 'classNames' | 'styles'>;
|
||||
|
||||
export interface ButtonConfig extends ComponentStyleConfig {
|
||||
classNames?: ButtonProps['classNames'];
|
||||
styles?: ButtonProps['styles'];
|
||||
}
|
||||
export type ButtonConfig = ComponentStyleConfig & Pick<ButtonProps, 'classNames' | 'styles'>;
|
||||
|
||||
export interface DrawerConfig extends ComponentStyleConfig {
|
||||
classNames?: DrawerProps['classNames'];
|
||||
styles?: DrawerProps['styles'];
|
||||
}
|
||||
export type DrawerConfig = ComponentStyleConfig & Pick<DrawerProps, 'classNames' | 'styles'>;
|
||||
|
||||
export interface FlexConfig extends ComponentStyleConfig {
|
||||
vertical?: FlexProps['vertical'];
|
||||
}
|
||||
export type FlexConfig = ComponentStyleConfig & Pick<FlexProps, 'vertical'>;
|
||||
|
||||
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<InputProps, 'autoComplete' | 'classNames' | 'styles'>;
|
||||
pagination?: ComponentStyleConfig & Pick<PaginationProps, 'showSizeChanger'>;
|
||||
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<SpaceProps, 'size' | 'className' | 'classNames' | 'style' | 'styles'>;
|
||||
virtual?: boolean;
|
||||
popupMatchSelectWidth?: boolean;
|
||||
popupOverflow?: PopupOverflow;
|
||||
form?: ComponentStyleConfig & {
|
||||
requiredMark?: RequiredMark;
|
||||
colon?: boolean;
|
||||
scrollToFirstError?: Options | boolean;
|
||||
validateMessages?: ValidateMessages;
|
||||
};
|
||||
form?: ComponentStyleConfig &
|
||||
Pick<FormProps, 'requiredMark' | 'colon' | 'scrollToFirstError' | 'validateMessages'>;
|
||||
theme?: ThemeConfig;
|
||||
select?: ComponentStyleConfig & {
|
||||
showSearch?: boolean;
|
||||
};
|
||||
select?: ComponentStyleConfig & Pick<SelectProps, 'showSearch'>;
|
||||
alert?: ComponentStyleConfig;
|
||||
anchor?: ComponentStyleConfig;
|
||||
button?: ButtonConfig;
|
||||
|
@ -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<FormProps, 'requiredMark' | 'colon' | 'scrollToFirstError' | 'validateMessages'>;
|
||||
input?: ComponentStyleConfig & Pick<InputProps, 'autoComplete' | 'classNames' | 'styles'>;
|
||||
select?: ComponentStyleConfig & Pick<SelectProps, 'showSearch'>;
|
||||
pagination?: ComponentStyleConfig & Pick<PaginationProps, 'showSizeChanger'>;
|
||||
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<SpaceProps, 'size' | 'className' | 'classNames' | 'style' | 'styles'>;
|
||||
virtual?: boolean;
|
||||
/** @deprecated Please use `popupMatchSelectWidth` instead */
|
||||
dropdownMatchSelectWidth?: boolean;
|
||||
popupMatchSelectWidth?: boolean;
|
||||
popupOverflow?: PopupOverflow;
|
||||
theme?: ThemeConfig;
|
||||
|
||||
warning?: WarningContextProps;
|
||||
|
||||
alert?: ComponentStyleConfig;
|
||||
anchor?: ComponentStyleConfig;
|
||||
button?: ButtonConfig;
|
||||
|
@ -215,7 +215,8 @@ const InternalForm: React.ForwardRefRenderFunction<FormInstance, FormProps> = (p
|
||||
|
||||
const Form = React.forwardRef<FormInstance, FormProps>(InternalForm) as (<Values = any>(
|
||||
props: React.PropsWithChildren<FormProps<Values>> & React.RefAttributes<FormInstance<Values>>,
|
||||
) => React.ReactElement) & { displayName?: string };
|
||||
) => React.ReactElement) &
|
||||
Pick<React.FC, 'displayName'>;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Form.displayName = 'Form';
|
||||
|
@ -22,7 +22,8 @@ export interface DirectoryTreeProps<T extends BasicDataNode = DataNode> extends
|
||||
|
||||
type DirectoryTreeCompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
|
||||
props: React.PropsWithChildren<DirectoryTreeProps<T>> & React.RefAttributes<RcTree>,
|
||||
) => React.ReactElement) & { displayName?: string };
|
||||
) => React.ReactElement) &
|
||||
Pick<React.FC, 'displayName'>;
|
||||
|
||||
export interface DirectoryTreeState {
|
||||
expandedKeys?: Key[];
|
||||
|
Loading…
Reference in New Issue
Block a user