diff --git a/.dumi/hooks/useLocalStorage.ts b/.dumi/hooks/useLocalStorage.ts index 4ebc0c331e..c4e71d2be5 100644 --- a/.dumi/hooks/useLocalStorage.ts +++ b/.dumi/hooks/useLocalStorage.ts @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useEffectEvent } from 'react'; +import React, { useCallback, useEffect } from 'react'; const ANT_SYNC_STORAGE_EVENT_KEY = 'ANT_SYNC_STORAGE_EVENT_KEY'; @@ -95,7 +95,7 @@ const useLocalStorage = (key: string, options: Options = {}) => { }; }, [key, onNativeStorage, onCustomStorage]); - return [state, useEffectEvent(updateState)] as const; + return [state, updateState] as const; }; export default useLocalStorage; diff --git a/components/color-picker/components/ColorTrigger.tsx b/components/color-picker/components/ColorTrigger.tsx index b6d2b62956..829cde6e88 100644 --- a/components/color-picker/components/ColorTrigger.tsx +++ b/components/color-picker/components/ColorTrigger.tsx @@ -79,7 +79,7 @@ const ColorTrigger = forwardRef((props, ref) default: return alpha < 100 ? `${hexString.slice(0, 7)},${alpha}%` : hexString; } - }, [color, format, showText, activeIndex]); + }, [color, format, showText, activeIndex, locale.transparent, colorTextCellPrefixCls]); // ============================= Render ============================= const containerNode = useMemo( diff --git a/components/color-picker/hooks/useModeColor.ts b/components/color-picker/hooks/useModeColor.ts index eba09a546c..704f4297e8 100644 --- a/components/color-picker/hooks/useModeColor.ts +++ b/components/color-picker/hooks/useModeColor.ts @@ -56,7 +56,7 @@ export default function useModeColor( pushOption('gradient', locale.gradientColor); return [optionList, modes]; - }, [mode]); + }, [mode, locale.singleColor, locale.gradientColor]); // ======================== Post ======================== // We need align `mode` with `color` state diff --git a/components/date-picker/__tests__/utils.ts b/components/date-picker/__tests__/utils.ts index 55435884c9..8b5dc8ebab 100644 --- a/components/date-picker/__tests__/utils.ts +++ b/components/date-picker/__tests__/utils.ts @@ -2,14 +2,14 @@ import type { render } from '../../../tests/utils'; import { fireEvent } from '../../../tests/utils'; export function openPicker(wrapper: ReturnType, index = 0) { - const inputEle = wrapper.container?.querySelectorAll('input')?.[index]!; + const inputEle = wrapper.container?.querySelectorAll('input')?.[index]; fireEvent.mouseDown(inputEle); fireEvent.focus(inputEle); fireEvent.click(inputEle); } export function closePicker(wrapper: ReturnType, index = 0) { - fireEvent.blur(wrapper.container?.querySelectorAll('input')[index]!); + fireEvent.blur(wrapper.container?.querySelectorAll('input')[index]); } export function selectCell(wrapper: ReturnType, text: string | number, index = 0) { diff --git a/components/pagination/demo/component-token.tsx b/components/pagination/demo/component-token.tsx index fe72c62607..f84b68788a 100644 --- a/components/pagination/demo/component-token.tsx +++ b/components/pagination/demo/component-token.tsx @@ -19,6 +19,8 @@ const App: React.FC = () => ( itemSize: 20, itemSizeSM: 12, itemActiveBg: '#e7cc87', + itemActiveColor: '#eee', + itemActiveColorHover: '#fff', itemLinkBg: '#344324', itemActiveBgDisabled: '#9c1515', itemInputBg: '#9c1515', diff --git a/components/pagination/style/index.ts b/components/pagination/style/index.ts index 26e0e8fafd..a1a758429c 100644 --- a/components/pagination/style/index.ts +++ b/components/pagination/style/index.ts @@ -29,6 +29,16 @@ export interface ComponentToken { * @descEN Background color of active Pagination item */ itemActiveBg: string; + /** + * @desc 页码激活态文字颜色 + * @descEN Text color of active Pagination item + */ + itemActiveColor: string; + /** + * @desc 页码激活态文字颜色悬停态 + * @descEN Text color of active Pagination item hover + */ + itemActiveColorHover: string; /** * @desc 小号页码尺寸 * @descEN Size of small Pagination item @@ -594,7 +604,7 @@ const genPaginationItemStyle: GenerateStyle = (token borderColor: token.colorPrimary, a: { - color: token.colorPrimary, + color: token.itemActiveColor, }, '&:hover': { @@ -602,7 +612,7 @@ const genPaginationItemStyle: GenerateStyle = (token }, '&:hover a': { - color: token.colorPrimaryHover, + color: token.itemActiveColorHover, }, }, }, @@ -723,6 +733,8 @@ export const prepareComponentToken: GetDefaultToken<'Pagination'> = (token) => ( itemSize: token.controlHeight, itemSizeSM: token.controlHeightSM, itemActiveBg: token.colorBgContainer, + itemActiveColor: token.colorPrimary, + itemActiveColorHover: token.colorPrimaryHover, itemLinkBg: token.colorBgContainer, itemActiveColorDisabled: token.colorTextDisabled, itemActiveBgDisabled: token.controlItemBgActiveDisabled, diff --git a/components/space/index.tsx b/components/space/index.tsx index 5973a96f95..529b484cbd 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -133,15 +133,18 @@ const InternalSpace = React.forwardRef((props, ref) const itemClassName = clsx(`${prefixCls}-item`, mergedClassNames.item); + const memoizedLatestIndex = React.useMemo(() => { + return childNodes.reduce((latest, child, i) => { + if (child !== null && child !== undefined) { + return i; + } + return latest; + }, 0); + }, [childNodes]); + // Calculate latest one - let latestIndex = 0; const nodes = childNodes.map((child, i) => { - if (child !== null && child !== undefined) { - latestIndex = i; - } - const key = child?.key || `${itemClassName}-${i}`; - return ( ((props, ref) }); } - const spaceContext = React.useMemo(() => ({ latestIndex }), [latestIndex]); + const spaceContext = React.useMemo( + () => ({ latestIndex: memoizedLatestIndex }), + [memoizedLatestIndex], + ); // =========================== Render =========================== if (childNodes.length === 0) { diff --git a/components/typography/Link.tsx b/components/typography/Link.tsx index 1b9575dc42..a39dbf255a 100644 --- a/components/typography/Link.tsx +++ b/components/typography/Link.tsx @@ -10,22 +10,31 @@ export interface LinkProps ellipsis?: boolean; } -const Link = React.forwardRef(({ ellipsis, rel, ...restProps }, ref) => { +const Link = React.forwardRef((props, ref) => { + const { + ellipsis, + rel, + children, + // @ts-expect-error: https://github.com/ant-design/ant-design/issues/26622 + navigate: _navigate, + ...restProps + } = props; + if (process.env.NODE_ENV !== 'production') { const warning = devUseWarning('Typography.Link'); - warning(typeof ellipsis !== 'object', 'usage', '`ellipsis` only supports boolean value.'); } - const mergedProps = { + const mergedProps: LinkProps = { ...restProps, rel: rel === undefined && restProps.target === '_blank' ? 'noopener noreferrer' : rel, }; - // @ts-expect-error: https://github.com/ant-design/ant-design/issues/26622 - delete mergedProps.navigate; - - return ; + return ( + + {children} + + ); }); export default Link; diff --git a/components/typography/Paragraph.tsx b/components/typography/Paragraph.tsx index 2911e90fff..58eb8f6ddd 100644 --- a/components/typography/Paragraph.tsx +++ b/components/typography/Paragraph.tsx @@ -7,8 +7,13 @@ export interface ParagraphProps extends BlockProps<'div'>, Omit, 'type' | keyof BlockProps<'div'>> {} -const Paragraph = React.forwardRef((props, ref) => ( - -)); +const Paragraph = React.forwardRef((props, ref) => { + const { children, ...restProps } = props; + return ( + + {children} + + ); +}); export default Paragraph; diff --git a/components/typography/Text.tsx b/components/typography/Text.tsx index 3aecd6840b..4fe1722ac4 100644 --- a/components/typography/Text.tsx +++ b/components/typography/Text.tsx @@ -11,10 +11,8 @@ export interface TextProps ellipsis?: boolean | Omit; } -const Text: React.ForwardRefRenderFunction = ( - { ellipsis, ...restProps }, - ref, -) => { +const Text: React.ForwardRefRenderFunction = (props, ref) => { + const { ellipsis, children, ...restProps } = props; const mergedEllipsis = React.useMemo(() => { if (ellipsis && typeof ellipsis === 'object') { return omit(ellipsis as EllipsisConfig, ['expandable', 'rows']); @@ -34,7 +32,11 @@ const Text: React.ForwardRefRenderFunction = ( ); } - return ; + return ( + + {children} + + ); }; export default React.forwardRef(Text); diff --git a/components/typography/Title.tsx b/components/typography/Title.tsx index 0f74134a1a..63d0e04732 100644 --- a/components/typography/Title.tsx +++ b/components/typography/Title.tsx @@ -17,7 +17,7 @@ export interface TitleProps } const Title = React.forwardRef((props, ref) => { - const { level = 1, ...restProps } = props; + const { level = 1, children, ...restProps } = props; if (process.env.NODE_ENV !== 'production') { const warning = devUseWarning('Typography.Title'); @@ -30,7 +30,11 @@ const Title = React.forwardRef((props, ref) => { const component: keyof JSX.IntrinsicElements = TITLE_ELE_LIST.includes(level) ? `h${level}` : `h1`; - return ; + return ( + + {children} + + ); }); export default Title; diff --git a/components/upload/Dragger.tsx b/components/upload/Dragger.tsx index 27eaa400e8..f194e6e628 100644 --- a/components/upload/Dragger.tsx +++ b/components/upload/Dragger.tsx @@ -6,17 +6,21 @@ import Upload from './Upload'; export type DraggerProps = UploadProps & { height?: number }; -const Dragger = React.forwardRef( - ({ style, height, hasControlInside = false, ...restProps }, ref) => ( +const Dragger = React.forwardRef>((props, ref) => { + const { style, height, hasControlInside = false, children, ...restProps } = props; + const mergedStyle: React.CSSProperties = { ...style, height }; + return ( - ), -); + > + {children} + + ); +}); if (process.env.NODE_ENV !== 'production') { Dragger.displayName = 'Dragger'; diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 0dafd2dbeb..4226b43d7d 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -103,8 +103,8 @@ const InternalUpload: React.ForwardRefRenderFunction = ( // Control mode will auto fill file uid if not provided React.useMemo(() => { + // eslint-disable-next-line react-hooks/purity const timestamp = Date.now(); - (fileList || []).forEach((file, index) => { if (!file.uid && !Object.isFrozen(file)) { file.uid = `__AUTO__${timestamp}_${index}__`;