mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-01 21:37:06 +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 * 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 { WarningContextProps } from '../_util/warning';
|
||||||
import type { ShowWaveEffect } from '../_util/wave/interface';
|
import type { ShowWaveEffect } from '../_util/wave/interface';
|
||||||
@ -8,15 +6,16 @@ import type { BadgeProps } from '../badge';
|
|||||||
import type { ButtonProps } from '../button';
|
import type { ButtonProps } from '../button';
|
||||||
import type { DrawerProps } from '../drawer';
|
import type { DrawerProps } from '../drawer';
|
||||||
import type { FlexProps } from '../flex/interface';
|
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 { InputProps } from '../input';
|
||||||
import type { Locale } from '../locale';
|
import type { Locale } from '../locale';
|
||||||
import type { ModalProps } from '../modal';
|
import type { ModalProps } from '../modal';
|
||||||
|
import type { PaginationProps } from '../pagination';
|
||||||
|
import type { SelectProps } from '../select';
|
||||||
import type { SpaceProps } from '../space';
|
import type { SpaceProps } from '../space';
|
||||||
import type { TabsProps } from '../tabs';
|
import type { TabsProps } from '../tabs';
|
||||||
import type { AliasToken, MappingAlgorithm, OverrideToken } from '../theme/interface';
|
import type { AliasToken, MappingAlgorithm, OverrideToken } from '../theme/interface';
|
||||||
import type { RenderEmptyHandler } from './defaultRenderEmpty';
|
import type { RenderEmptyHandler } from './defaultRenderEmpty';
|
||||||
import type { SizeType } from './SizeContext';
|
|
||||||
|
|
||||||
export const defaultIconPrefixCls = 'anticon';
|
export const defaultIconPrefixCls = 'anticon';
|
||||||
|
|
||||||
@ -66,29 +65,15 @@ export interface ComponentStyleConfig {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModalConfig extends ComponentStyleConfig {
|
export type ModalConfig = ComponentStyleConfig & Pick<ModalProps, 'classNames' | 'styles'>;
|
||||||
classNames?: ModalProps['classNames'];
|
|
||||||
styles?: ModalProps['styles'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BadgeConfig extends ComponentStyleConfig {
|
export type BadgeConfig = ComponentStyleConfig & Pick<BadgeProps, 'classNames' | 'styles'>;
|
||||||
classNames?: BadgeProps['classNames'];
|
|
||||||
styles?: BadgeProps['styles'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ButtonConfig extends ComponentStyleConfig {
|
export type ButtonConfig = ComponentStyleConfig & Pick<ButtonProps, 'classNames' | 'styles'>;
|
||||||
classNames?: ButtonProps['classNames'];
|
|
||||||
styles?: ButtonProps['styles'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DrawerConfig extends ComponentStyleConfig {
|
export type DrawerConfig = ComponentStyleConfig & Pick<DrawerProps, 'classNames' | 'styles'>;
|
||||||
classNames?: DrawerProps['classNames'];
|
|
||||||
styles?: DrawerProps['styles'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FlexConfig extends ComponentStyleConfig {
|
export type FlexConfig = ComponentStyleConfig & Pick<FlexProps, 'vertical'>;
|
||||||
vertical?: FlexProps['vertical'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PopupOverflow = 'viewport' | 'scroll';
|
export type PopupOverflow = 'viewport' | 'scroll';
|
||||||
|
|
||||||
@ -106,37 +91,19 @@ export interface ConfigConsumerProps {
|
|||||||
renderEmpty?: RenderEmptyHandler;
|
renderEmpty?: RenderEmptyHandler;
|
||||||
csp?: CSPConfig;
|
csp?: CSPConfig;
|
||||||
autoInsertSpaceInButton?: boolean;
|
autoInsertSpaceInButton?: boolean;
|
||||||
input?: ComponentStyleConfig & {
|
input?: ComponentStyleConfig & Pick<InputProps, 'autoComplete' | 'classNames' | 'styles'>;
|
||||||
autoComplete?: string;
|
pagination?: ComponentStyleConfig & Pick<PaginationProps, 'showSizeChanger'>;
|
||||||
classNames?: InputProps['classNames'];
|
|
||||||
styles?: InputProps['styles'];
|
|
||||||
};
|
|
||||||
pagination?: ComponentStyleConfig & { showSizeChanger?: boolean };
|
|
||||||
locale?: Locale;
|
locale?: Locale;
|
||||||
pageHeader?: {
|
pageHeader?: Record<'ghost', boolean>;
|
||||||
ghost: boolean;
|
|
||||||
};
|
|
||||||
direction?: DirectionType;
|
direction?: DirectionType;
|
||||||
space?: {
|
space?: Pick<SpaceProps, 'size' | 'className' | 'classNames' | 'style' | 'styles'>;
|
||||||
size?: SizeType | number;
|
|
||||||
className?: SpaceProps['className'];
|
|
||||||
classNames?: SpaceProps['classNames'];
|
|
||||||
style?: SpaceProps['style'];
|
|
||||||
styles?: SpaceProps['styles'];
|
|
||||||
};
|
|
||||||
virtual?: boolean;
|
virtual?: boolean;
|
||||||
popupMatchSelectWidth?: boolean;
|
popupMatchSelectWidth?: boolean;
|
||||||
popupOverflow?: PopupOverflow;
|
popupOverflow?: PopupOverflow;
|
||||||
form?: ComponentStyleConfig & {
|
form?: ComponentStyleConfig &
|
||||||
requiredMark?: RequiredMark;
|
Pick<FormProps, 'requiredMark' | 'colon' | 'scrollToFirstError' | 'validateMessages'>;
|
||||||
colon?: boolean;
|
|
||||||
scrollToFirstError?: Options | boolean;
|
|
||||||
validateMessages?: ValidateMessages;
|
|
||||||
};
|
|
||||||
theme?: ThemeConfig;
|
theme?: ThemeConfig;
|
||||||
select?: ComponentStyleConfig & {
|
select?: ComponentStyleConfig & Pick<SelectProps, 'showSearch'>;
|
||||||
showSearch?: boolean;
|
|
||||||
};
|
|
||||||
alert?: ComponentStyleConfig;
|
alert?: ComponentStyleConfig;
|
||||||
anchor?: ComponentStyleConfig;
|
anchor?: ComponentStyleConfig;
|
||||||
button?: ButtonConfig;
|
button?: ButtonConfig;
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { createTheme } from '@ant-design/cssinjs';
|
import { createTheme } from '@ant-design/cssinjs';
|
||||||
import IconContext from '@ant-design/icons/lib/components/Context';
|
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 useMemo from 'rc-util/lib/hooks/useMemo';
|
||||||
import { merge } from 'rc-util/lib/utils/set';
|
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 warning, { WarningContext } from '../_util/warning';
|
||||||
import type { RequiredMark } from '../form/Form';
|
import type { WarningContextProps } from '../_util/warning';
|
||||||
|
import type { FormProps } from '../form/Form';
|
||||||
import ValidateMessagesContext from '../form/validateMessagesContext';
|
import ValidateMessagesContext from '../form/validateMessagesContext';
|
||||||
import type { InputProps } from '../input';
|
import type { InputProps } from '../input';
|
||||||
import type { Locale } from '../locale';
|
import type { Locale } from '../locale';
|
||||||
@ -15,6 +14,8 @@ import LocaleProvider, { ANT_MARK } from '../locale';
|
|||||||
import type { LocaleContextProps } from '../locale/context';
|
import type { LocaleContextProps } from '../locale/context';
|
||||||
import LocaleContext from '../locale/context';
|
import LocaleContext from '../locale/context';
|
||||||
import defaultLocale from '../locale/en_US';
|
import defaultLocale from '../locale/en_US';
|
||||||
|
import type { PaginationProps } from '../pagination';
|
||||||
|
import type { SelectProps } from '../select';
|
||||||
import type { SpaceProps } from '../space';
|
import type { SpaceProps } from '../space';
|
||||||
import type { TabsProps } from '../tabs';
|
import type { TabsProps } from '../tabs';
|
||||||
import { defaultTheme, DesignTokenContext } from '../theme/context';
|
import { defaultTheme, DesignTokenContext } from '../theme/context';
|
||||||
@ -112,44 +113,24 @@ export interface ConfigProviderProps {
|
|||||||
renderEmpty?: RenderEmptyHandler;
|
renderEmpty?: RenderEmptyHandler;
|
||||||
csp?: CSPConfig;
|
csp?: CSPConfig;
|
||||||
autoInsertSpaceInButton?: boolean;
|
autoInsertSpaceInButton?: boolean;
|
||||||
form?: ComponentStyleConfig & {
|
form?: ComponentStyleConfig &
|
||||||
validateMessages?: ValidateMessages;
|
Pick<FormProps, 'requiredMark' | 'colon' | 'scrollToFirstError' | 'validateMessages'>;
|
||||||
requiredMark?: RequiredMark;
|
input?: ComponentStyleConfig & Pick<InputProps, 'autoComplete' | 'classNames' | 'styles'>;
|
||||||
colon?: boolean;
|
select?: ComponentStyleConfig & Pick<SelectProps, 'showSearch'>;
|
||||||
scrollToFirstError?: Options | boolean;
|
pagination?: ComponentStyleConfig & Pick<PaginationProps, 'showSizeChanger'>;
|
||||||
};
|
|
||||||
input?: ComponentStyleConfig & {
|
|
||||||
classNames?: InputProps['classNames'];
|
|
||||||
styles?: InputProps['styles'];
|
|
||||||
autoComplete?: string;
|
|
||||||
};
|
|
||||||
select?: ComponentStyleConfig & {
|
|
||||||
showSearch?: boolean;
|
|
||||||
};
|
|
||||||
pagination?: ComponentStyleConfig & { showSizeChanger?: boolean };
|
|
||||||
locale?: Locale;
|
locale?: Locale;
|
||||||
pageHeader?: {
|
pageHeader?: Record<'ghost', boolean>;
|
||||||
ghost: boolean;
|
|
||||||
};
|
|
||||||
componentSize?: SizeType;
|
componentSize?: SizeType;
|
||||||
componentDisabled?: boolean;
|
componentDisabled?: boolean;
|
||||||
direction?: DirectionType;
|
direction?: DirectionType;
|
||||||
space?: {
|
space?: Pick<SpaceProps, 'size' | 'className' | 'classNames' | 'style' | 'styles'>;
|
||||||
size?: SizeType | number;
|
|
||||||
className?: SpaceProps['className'];
|
|
||||||
classNames?: SpaceProps['classNames'];
|
|
||||||
style?: SpaceProps['style'];
|
|
||||||
styles?: SpaceProps['styles'];
|
|
||||||
};
|
|
||||||
virtual?: boolean;
|
virtual?: boolean;
|
||||||
/** @deprecated Please use `popupMatchSelectWidth` instead */
|
/** @deprecated Please use `popupMatchSelectWidth` instead */
|
||||||
dropdownMatchSelectWidth?: boolean;
|
dropdownMatchSelectWidth?: boolean;
|
||||||
popupMatchSelectWidth?: boolean;
|
popupMatchSelectWidth?: boolean;
|
||||||
popupOverflow?: PopupOverflow;
|
popupOverflow?: PopupOverflow;
|
||||||
theme?: ThemeConfig;
|
theme?: ThemeConfig;
|
||||||
|
|
||||||
warning?: WarningContextProps;
|
warning?: WarningContextProps;
|
||||||
|
|
||||||
alert?: ComponentStyleConfig;
|
alert?: ComponentStyleConfig;
|
||||||
anchor?: ComponentStyleConfig;
|
anchor?: ComponentStyleConfig;
|
||||||
button?: ButtonConfig;
|
button?: ButtonConfig;
|
||||||
|
@ -215,7 +215,8 @@ const InternalForm: React.ForwardRefRenderFunction<FormInstance, FormProps> = (p
|
|||||||
|
|
||||||
const Form = React.forwardRef<FormInstance, FormProps>(InternalForm) as (<Values = any>(
|
const Form = React.forwardRef<FormInstance, FormProps>(InternalForm) as (<Values = any>(
|
||||||
props: React.PropsWithChildren<FormProps<Values>> & React.RefAttributes<FormInstance<Values>>,
|
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') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
Form.displayName = 'Form';
|
Form.displayName = 'Form';
|
||||||
|
@ -22,7 +22,8 @@ export interface DirectoryTreeProps<T extends BasicDataNode = DataNode> extends
|
|||||||
|
|
||||||
type DirectoryTreeCompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
|
type DirectoryTreeCompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
|
||||||
props: React.PropsWithChildren<DirectoryTreeProps<T>> & React.RefAttributes<RcTree>,
|
props: React.PropsWithChildren<DirectoryTreeProps<T>> & React.RefAttributes<RcTree>,
|
||||||
) => React.ReactElement) & { displayName?: string };
|
) => React.ReactElement) &
|
||||||
|
Pick<React.FC, 'displayName'>;
|
||||||
|
|
||||||
export interface DirectoryTreeState {
|
export interface DirectoryTreeState {
|
||||||
expandedKeys?: Key[];
|
expandedKeys?: Key[];
|
||||||
|
Loading…
Reference in New Issue
Block a user