type: rm useless type (#46920)

* type: rm useless type"

* update size-limit
This commit is contained in:
lijianan 2024-01-11 15:11:55 +08:00 committed by GitHub
parent 213723a2e8
commit 1b2362a425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 26 deletions

View File

@ -1,12 +1,8 @@
import CloseOutlined from '@ant-design/icons/CloseOutlined';
import type { ReactNode } from 'react';
import React from 'react';
import CloseOutlined from '@ant-design/icons/CloseOutlined';
function useInnerClosable(
closable?: boolean,
closeIcon?: boolean | ReactNode,
defaultClosable?: boolean,
): boolean {
function useInnerClosable(closable?: boolean, closeIcon?: ReactNode, defaultClosable?: boolean) {
if (typeof closable === 'boolean') {
return closable;
}
@ -18,15 +14,15 @@ function useInnerClosable(
export type UseClosableParams = {
closable?: boolean;
closeIcon?: boolean | ReactNode;
closeIcon?: ReactNode;
defaultClosable?: boolean;
defaultCloseIcon?: ReactNode;
customCloseIconRender?: (closeIcon: ReactNode) => ReactNode;
};
export default function useClosable(
function useClosable(
closable?: boolean,
closeIcon?: boolean | ReactNode,
closeIcon?: ReactNode,
customCloseIconRender?: (closeIcon: ReactNode) => ReactNode,
defaultCloseIcon: ReactNode = <CloseOutlined />,
defaultClosable = false,
@ -41,3 +37,5 @@ export default function useClosable(
: closeIcon;
return [true, customCloseIconRender ? customCloseIconRender(mergedCloseIcon) : mergedCloseIcon];
}
export default useClosable;

View File

@ -43,7 +43,7 @@ export interface AlertProps {
banner?: boolean;
icon?: React.ReactNode;
/** Custom closeIcon */
closeIcon?: boolean | React.ReactNode;
closeIcon?: React.ReactNode;
action?: React.ReactNode;
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;

View File

@ -31,7 +31,7 @@ export interface DrawerPanelProps {
* `<Drawer closeIcon={false} />`
*/
closable?: boolean;
closeIcon?: boolean | React.ReactNode;
closeIcon?: React.ReactNode;
onClose?: RCDrawerProps['onClose'];
children?: React.ReactNode;

View File

@ -179,7 +179,7 @@ describe('Form', () => {
// https://github.com/ant-design/ant-design/issues/41620
it('should not throw error when `help=false` and `noStyle=true`', async () => {
const App = (props: { help?: boolean | React.ReactNode }) => {
const App: React.FC<{ help?: React.ReactNode }> = (props) => {
const { help = false } = props || {};
return (
<Form>

View File

@ -1,8 +1,8 @@
import type { FC } from 'react';
import type { DialogProps } from 'rc-dialog';
import type { ButtonProps, LegacyButtonType } from '../button/button';
import type { DirectionType } from '../config-provider';
import type { DialogProps } from 'rc-dialog';
export type ModalFooterRender = (
originNode: React.ReactNode,
@ -63,7 +63,7 @@ export interface ModalProps extends ModalCommonProps {
keyboard?: boolean;
wrapProps?: any;
prefixCls?: string;
closeIcon?: boolean | React.ReactNode;
closeIcon?: React.ReactNode;
modalRender?: (node: React.ReactNode) => React.ReactNode;
focusTriggerAfterClose?: boolean;
children?: React.ReactNode;

View File

@ -12,7 +12,7 @@ export const NotificationPlacements = [
'bottomLeft',
'bottomRight',
] as const;
export type NotificationPlacement = typeof NotificationPlacements[number];
export type NotificationPlacement = (typeof NotificationPlacements)[number];
export type IconType = 'success' | 'info' | 'error' | 'warning';
@ -29,7 +29,7 @@ export interface ArgsProps {
className?: string;
readonly type?: IconType;
onClick?: () => void;
closeIcon?: boolean | React.ReactNode;
closeIcon?: React.ReactNode;
props?: DivProps;
role?: 'alert' | 'status';
}

View File

@ -23,7 +23,7 @@ export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
color?: LiteralUnion<PresetColorType | PresetStatusColorType>;
closable?: boolean;
/** Advised to use closeIcon instead. */
closeIcon?: boolean | React.ReactNode;
closeIcon?: React.ReactNode;
/** @deprecated `visible` will be removed in next major version. */
visible?: boolean;
onClose?: (e: React.MouseEvent<HTMLElement>) => void;

View File

@ -71,7 +71,7 @@ const treeData: DataNode[] = [
const App: React.FC = () => {
const [showLine, setShowLine] = useState<boolean>(true);
const [showIcon, setShowIcon] = useState<boolean>(false);
const [showLeafIcon, setShowLeafIcon] = useState<boolean | React.ReactNode>(true);
const [showLeafIcon, setShowLeafIcon] = useState<React.ReactNode>(true);
const onSelect = (selectedKeys: React.Key[], info: any) => {
console.log('selected', selectedKeys, info);

View File

@ -32,7 +32,7 @@ interface CopyConfig {
text?: string;
onCopy?: (event?: React.MouseEvent<HTMLDivElement>) => void;
icon?: React.ReactNode;
tooltips?: boolean | React.ReactNode;
tooltips?: React.ReactNode;
format?: 'text/plain' | 'text/html';
}
@ -40,7 +40,7 @@ interface EditConfig {
text?: string;
editing?: boolean;
icon?: React.ReactNode;
tooltip?: boolean | React.ReactNode;
tooltip?: React.ReactNode;
onStart?: () => void;
onChange?: (value: string) => void;
onCancel?: () => void;

View File

@ -1,8 +1,8 @@
import React from 'react';
import { LikeOutlined, SmileOutlined } from '@ant-design/icons';
import * as copyObj from 'copy-to-clipboard';
import React from 'react';
import { fireEvent, render, waitFakeTimer, waitFor } from '../../../tests/utils';
import { fireEvent, render, waitFakeTimer, waitFor } from '../../../tests/utils';
import Base from '../Base';
describe('Typography copy', () => {
@ -24,8 +24,8 @@ describe('Typography copy', () => {
tooltipLength,
}: {
name: string;
icon?: boolean | React.ReactNode;
tooltips?: boolean | React.ReactNode;
icon?: React.ReactNode;
tooltips?: React.ReactNode;
iconClassNames?: string[];
iconTexts?: string[];
tooltipTexts?: string[];

View File

@ -349,11 +349,11 @@
"size-limit": [
{
"path": "./dist/antd.min.js",
"limit": "333 KiB"
"limit": "334 KiB"
},
{
"path": "./dist/antd-with-locales.min.js",
"limit": "377 KiB"
"limit": "378 KiB"
}
],
"title": "Ant Design",