diff --git a/components/_util/hooks/useClosable.tsx b/components/_util/hooks/useClosable.tsx index d6fc240168..4b1bd0b8a2 100644 --- a/components/_util/hooks/useClosable.tsx +++ b/components/_util/hooks/useClosable.tsx @@ -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 = , defaultClosable = false, @@ -41,3 +37,5 @@ export default function useClosable( : closeIcon; return [true, customCloseIconRender ? customCloseIconRender(mergedCloseIcon) : mergedCloseIcon]; } + +export default useClosable; diff --git a/components/alert/Alert.tsx b/components/alert/Alert.tsx index 00a7a2e4a2..ede1855a7d 100644 --- a/components/alert/Alert.tsx +++ b/components/alert/Alert.tsx @@ -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; onMouseLeave?: React.MouseEventHandler; diff --git a/components/drawer/DrawerPanel.tsx b/components/drawer/DrawerPanel.tsx index 01fca83cb6..57f5fd2475 100644 --- a/components/drawer/DrawerPanel.tsx +++ b/components/drawer/DrawerPanel.tsx @@ -31,7 +31,7 @@ export interface DrawerPanelProps { * `` */ closable?: boolean; - closeIcon?: boolean | React.ReactNode; + closeIcon?: React.ReactNode; onClose?: RCDrawerProps['onClose']; children?: React.ReactNode; diff --git a/components/form/__tests__/index.test.tsx b/components/form/__tests__/index.test.tsx index 1163695dd2..da48269de2 100644 --- a/components/form/__tests__/index.test.tsx +++ b/components/form/__tests__/index.test.tsx @@ -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 (
diff --git a/components/modal/interface.ts b/components/modal/interface.ts index 9e4e2b4b0e..cc2596c1ac 100644 --- a/components/modal/interface.ts +++ b/components/modal/interface.ts @@ -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; diff --git a/components/notification/interface.ts b/components/notification/interface.ts index 3d71ce7fca..b5171338cb 100644 --- a/components/notification/interface.ts +++ b/components/notification/interface.ts @@ -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'; } diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 25456f7bbf..6aacad1d4c 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -23,7 +23,7 @@ export interface TagProps extends React.HTMLAttributes { color?: LiteralUnion; 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) => void; diff --git a/components/tree/demo/line.tsx b/components/tree/demo/line.tsx index 2adfff1731..4cbf0cbf16 100644 --- a/components/tree/demo/line.tsx +++ b/components/tree/demo/line.tsx @@ -71,7 +71,7 @@ const treeData: DataNode[] = [ const App: React.FC = () => { const [showLine, setShowLine] = useState(true); const [showIcon, setShowIcon] = useState(false); - const [showLeafIcon, setShowLeafIcon] = useState(true); + const [showLeafIcon, setShowLeafIcon] = useState(true); const onSelect = (selectedKeys: React.Key[], info: any) => { console.log('selected', selectedKeys, info); diff --git a/components/typography/Base/index.tsx b/components/typography/Base/index.tsx index a776a8c555..5c4845a3f8 100644 --- a/components/typography/Base/index.tsx +++ b/components/typography/Base/index.tsx @@ -32,7 +32,7 @@ interface CopyConfig { text?: string; onCopy?: (event?: React.MouseEvent) => 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; diff --git a/components/typography/__tests__/copy.test.tsx b/components/typography/__tests__/copy.test.tsx index 35012084d9..251a3e63b9 100644 --- a/components/typography/__tests__/copy.test.tsx +++ b/components/typography/__tests__/copy.test.tsx @@ -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[]; diff --git a/package.json b/package.json index 1c7d57e004..4e951922d5 100644 --- a/package.json +++ b/package.json @@ -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",