Skip to content

Commit f5c0fe3

Browse files
authored
Merge branch 'master' into update_date_picker_props
2 parents 73970a9 + 30299ce commit f5c0fe3

19 files changed

Lines changed: 49 additions & 39 deletions

File tree

.dumi/theme/builtins/Previewer/CodePreviewer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
108108
}, [demoUrl, isDark]);
109109

110110
const iframePreview = useMemo(() => {
111-
if (!iframe) return null;
111+
if (!iframe) {
112+
return null;
113+
}
112114
return (
113115
<BrowserFrame>
114116
<iframe
@@ -120,6 +122,7 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
120122
</BrowserFrame>
121123
);
122124
}, [demoUrlWithTheme, iframe]);
125+
123126
const previewContent = iframePreview ?? mergedChildren;
124127

125128
const codeBoxClass = clsx('code-box', {

.dumi/theme/slots/SiteContext.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ export interface SiteContextProps {
1515
direction: DirectionType;
1616
theme: ThemeName[];
1717
// 主题存在跟随系统模式,解耦实际生效主题
18-
// 应使用isDark而非theme.includes('dark')等来判断当前主题
19-
isDark: boolean;
18+
// 应使用 isDark 而非 theme.includes('dark') 等来判断当前主题
19+
isDark?: boolean;
2020
updateSiteConfig: (props: Partial<SiteContextProps>) => void;
21-
2221
dynamicTheme?: {
2322
algorithm?: 'light' | 'dark';
2423
token: Record<string, string | number>;

CHANGELOG.en-US.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ tag: vVERSION
164164
- 🛠 MISC: Remove React 19 compatibility code, antd now supports React 19 by default. [#55274](https://github.com/ant-design/ant-design/pull/55274) [@li-jia-nan](https://github.com/li-jia-nan)
165165
- 🛠 MISC: Remove `copy-to-clipboard` deps. [#54448](https://github.com/ant-design/ant-design/pull/54448) [@765477020](https://github.com/765477020)
166166
- 🔥 MISC: Raise build target which will not support IE anymore. [#53390](https://github.com/ant-design/ant-design/pull/53390) [@zombieJ](https://github.com/zombieJ)
167-
- 🆕 MISC: Color-related components now support preset color names (e.g., `red`, `blue`, `green`, etc.). [#53241](https://github.com/ant-design/ant-design/pull/53241) [@zombieJ](https://github.com/zombieJ)
167+
- 🔥 MISC: Enabled `React Compiler` in the bundled outputs `antd.js` and `antd.min.js` to improve performance. Users in CJS/ESM environments can choose to enable it as needed. For more details, refer to the [React documentation](https://react.dev/learn/react-compiler). [#55781](https://github.com/ant-design/ant-design/pull/55781) [@li-jia-nan](https://github.com/li-jia-nan)
168+
- 🔥 MISC: Color-related components now support preset color names (e.g., `red`, `blue`, `green`, etc.). [#53241](https://github.com/ant-design/ant-design/pull/53241) [@zombieJ](https://github.com/zombieJ)
168169
- 🌐 Add Marathi locale translation. [#55179](https://github.com/ant-design/ant-design/pull/55179) [@divyeshagrawal](https://github.com/divyeshagrawal)
169170
- TypeScript
170171
- 🤖 Optimize Notification `duration` definition, now disable close is `false`. [#55580](https://github.com/ant-design/ant-design/pull/55580) [@wanpan11](https://github.com/wanpan11)

CHANGELOG.zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ tag: vVERSION
164164
- 🛠 杂项:移除 React 19 兼容代码,现在 antd 默认支持 React 19。[#55274](https://github.com/ant-design/ant-design/pull/55274) [@li-jia-nan](https://github.com/li-jia-nan)
165165
- 🛠 杂项:移除 `copy-to-clipboard` 依赖。[#54448](https://github.com/ant-design/ant-design/pull/54448) [@765477020](https://github.com/765477020)
166166
- 🔥 杂项:提升构建目标版本,不再支持 IE。[#53390](https://github.com/ant-design/ant-design/pull/53390) [@zombieJ](https://github.com/zombieJ)
167-
- 🆕 杂项:颜色相关组件现在支持预设颜色名(如 `red`, `blue`, `green` 等等)。[#53241](https://github.com/ant-design/ant-design/pull/53241) [@zombieJ](https://github.com/zombieJ)
167+
- 🔥 杂项:在打包产物 `antd.js` 以及 `antd.min.js` 中启用了 `React Compiler` 以优化性能,对使用 CJS/ESM 场景的用户可自行选择开启,参考[React 官方文档](https://zh-hans.react.dev/learn/react-compiler)[#55781](https://github.com/ant-design/ant-design/pull/55781) [@li-jia-nan](https://github.com/li-jia-nan)
168+
- 🔥 杂项:颜色相关组件现在支持预设颜色名(如 `red`, `blue`, `green` 等等)。[#53241](https://github.com/ant-design/ant-design/pull/53241) [@zombieJ](https://github.com/zombieJ)
168169
- 🌐 添加马拉地语国际化翻译。[#55179](https://github.com/ant-design/ant-design/pull/55179) [@divyeshagrawal](https://github.com/divyeshagrawal)
169170
- TypeScript
170171
- 🤖 优化 Notification `duration` 定义,现在禁止关闭为 `false`[#55580](https://github.com/ant-design/ant-design/pull/55580) [@wanpan11](https://github.com/wanpan11)

components/_util/ContextIsolator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import React from 'react';
22

33
import { NoFormStyle } from '../form/context';
44
import { NoCompactStyle } from '../space/Compact';
5+
import isNonNullable from './isNonNullable';
56

67
const ContextIsolator: React.FC<
78
Readonly<React.PropsWithChildren<Partial<Record<'space' | 'form', boolean>>>>
89
> = (props) => {
910
const { space, form, children } = props;
10-
if (children === undefined || children === null) {
11+
if (!isNonNullable(children)) {
1112
return null;
1213
}
1314
let result: React.ReactNode = children;
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import type { ReactNode } from 'react';
22
import { isValidElement } from 'react';
3+
34
import type { TooltipProps } from '../tooltip';
5+
import isNonNullable from './isNonNullable';
46

5-
function convertToTooltipProps<P extends TooltipProps>(tooltip: P | ReactNode): P | null {
6-
// isNil
7-
if (tooltip === undefined || tooltip === null) {
7+
const convertToTooltipProps = <P extends TooltipProps>(tooltip: P | ReactNode) => {
8+
if (!isNonNullable(tooltip)) {
89
return null;
910
}
1011

1112
if (typeof tooltip === 'object' && !isValidElement(tooltip)) {
1213
return tooltip as P;
1314
}
1415

15-
return {
16-
title: tooltip,
17-
} as P;
18-
}
16+
return { title: tooltip } as P;
17+
};
1918

2019
export default convertToTooltipProps;

components/_util/isNonNullable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// \b([A-Za-z_$][\w$]*)\s*!==\s*(?:undefined\s*&&\s*\1\s*!==\s*null|null\s*&&\s*\1\s*!==\s*undefined)\b
2+
// \b([A-Za-z_$][\w$\.]*)\s*===\s*(?:undefined|null)\s*\|\|\s*\1\s*===\s*(?:undefined|null)\b
13
const isNonNullable = <T>(val: T): val is NonNullable<T> => {
24
return val !== undefined && val !== null;
35
};

components/_util/toList.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import isNonNullable from './isNonNullable';
2+
13
const toList = <T>(candidate: T | T[], skipEmpty = false): T[] => {
2-
if (skipEmpty && (candidate === undefined || candidate === null)) {
4+
if (skipEmpty && !isNonNullable(candidate)) {
35
return [];
46
}
57
return Array.isArray(candidate) ? candidate : [candidate];

components/badge/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ const InternalBadge = React.forwardRef<HTMLSpanElement, BadgeProps>((props, ref)
118118

119119
const isHidden = useMemo(() => {
120120
const isEmpty =
121-
(mergedCount === null || mergedCount === undefined || mergedCount === '') &&
122-
(text === undefined || text === null || text === '');
121+
(!isNonNullable(mergedCount) || mergedCount === '') && (!isNonNullable(text) || text === '');
123122
return (isEmpty || (isZero && !showZero)) && !showAsDot;
124123
}, [mergedCount, isZero, showZero, showAsDot, text]);
125124

components/breadcrumb/useItemRender.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import pickAttrs from '@rc-component/util/lib/pickAttrs';
33
import { clsx } from 'clsx';
44

5+
import isNonNullable from '../_util/isNonNullable';
56
import type { BreadcrumbProps, InternalRouteType, ItemType } from './Breadcrumb';
67

78
type AddParameters<TFunction extends (...args: any) => any, TParameters extends [...args: any]> = (
@@ -12,7 +13,7 @@ type ItemRender = NonNullable<BreadcrumbProps['itemRender']>;
1213
type InternalItemRenderParams = AddParameters<ItemRender, [href?: string]>;
1314

1415
function getBreadcrumbName(route: InternalRouteType, params: any) {
15-
if (route.title === undefined || route.title === null) {
16+
if (!isNonNullable(route.title)) {
1617
return null;
1718
}
1819
const paramsKeys = Object.keys(params).join('|');
@@ -30,17 +31,14 @@ export function renderItem(
3031
children: React.ReactNode,
3132
href?: string,
3233
) {
33-
if (children === null || children === undefined) {
34+
if (!isNonNullable(children)) {
3435
return null;
3536
}
3637

3738
const { className, onClick, ...restItem } = item;
3839

3940
const passedProps = {
40-
...pickAttrs(restItem, {
41-
data: true,
42-
aria: true,
43-
}),
41+
...pickAttrs(restItem, { data: true, aria: true }),
4442
onClick,
4543
};
4644

0 commit comments

Comments
 (0)