(val: T | T[]): T[] {
+ if (val === false) {
+ return [false, false] as T[];
+ }
+ return Array.isArray(val) ? val : [val];
+}
+
+export function getNode(dom: React.ReactNode, defaultNode: React.ReactNode, needDom?: boolean) {
+ if (dom === true || dom === undefined) {
+ return defaultNode;
+ }
+ return dom || (needDom && defaultNode);
+}
diff --git a/components/typography/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/typography/__tests__/__snapshots__/demo-extend.test.ts.snap
index a1cdfc273b..688a799537 100644
--- a/components/typography/__tests__/__snapshots__/demo-extend.test.ts.snap
+++ b/components/typography/__tests__/__snapshots__/demo-extend.test.ts.snap
@@ -797,69 +797,6 @@ Array [
-
- lg
-
-
-
- ...
-
- with suffix.
-
-
-
,
Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
- ...
-
-
- more
-
-
,
-
- lg
-
-
-
- ...
-
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
-
,
[Before]
@@ -2251,6 +1918,18 @@ Array [
,
+
+ In the process of internal desktop applications development,
+
+ ANTD
+
+ many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of development.
+
,
]
`;
@@ -2258,28 +1937,11 @@ exports[`renders components/typography/demo/ellipsis-debug.tsx extend context co
exports[`renders components/typography/demo/ellipsis-middle.tsx extend context correctly 1`] = `
- In the process of internal desktop applications development, many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency ofdevelopment.
-
- lg
-
-
-
- ...
-
- development.
-
+ In the process of internal desktop applications development, many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of development.
`;
@@ -2540,29 +2202,6 @@ Array [
title="To be, or not to be, that is a question: Whether it is nobler in the mind to suffer. The slings and arrows of outrageous fortune Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, 'tis a consummation Devoutly to be wish'd. To die, to sleep To sleep- perchance to dream: ay, there's the rub! For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause. There 's the respect That makes calamity of so long life--William Shakespeare"
>
To be, or not to be, that is a question: Whether it is nobler in the mind to suffer. The slings and arrows of outrageous fortune Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, 'tis a consummation Devoutly to be wish'd. To die, to sleep To sleep- perchance to dream: ay, there's the rub! For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause. There 's the respect That makes calamity of so long life--William Shakespeare
-
- lg
-
-
-
- ...
-
- --William Shakespeare
-
- Expand
-
-
,
]
`;
diff --git a/components/typography/__tests__/__snapshots__/demo.test.tsx.snap b/components/typography/__tests__/__snapshots__/demo.test.tsx.snap
index 4af69f9872..7aa38cda04 100644
--- a/components/typography/__tests__/__snapshots__/demo.test.tsx.snap
+++ b/components/typography/__tests__/__snapshots__/demo.test.tsx.snap
@@ -664,50 +664,6 @@ Array [
-
- lg
-
-
-
- ...
-
- with suffix.
-
-
,
Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
- ...
-
-
,
Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
- ...
-
-
- more
-
-
,
Ant Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
- ...
-
-
,
Ant Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
-
- ...
-
-
-
,
]
`;
@@ -1386,22 +1270,6 @@ Array [
case. Bnt Design, a design language for background applications, is refined by Ant UED Team. Cnt Design, a design language for background applications, is refined by Ant UED Team. Dnt Design, a design language for background applications, is refined by Ant UED Team. Ent Design, a design language for background applications, is refined by Ant UED Team.
-
- lg
-
-
-
- ...
-
-
,
-
- lg
-
-
-
- ...
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
,
,
-
- lg
-
-
-
- ...
-
-
-
,
[Before]
@@ -1721,22 +1417,6 @@ Array [
class="ant-typography ant-typography-ellipsis ant-typography-single-line"
>
not ellipsis
-
- lg
-
-
-
- ...
-
-
[After]
,
@@ -1749,53 +1429,32 @@ Array [
style="width:100px"
>
默认display none 样式的超长文字, 悬停tooltip失效了
-
- lg
-
-
-
- ...
-
-
,
+
+ In the process of internal desktop applications development,
+
+ ANTD
+
+ many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of development.
+
,
]
`;
exports[`renders components/typography/demo/ellipsis-middle.tsx correctly 1`] = `
In the process of internal desktop applications development, many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of
development.
-
- lg
-
-
-
- ...
-
- development.
-
`;
@@ -2035,29 +1694,6 @@ Array [
To be, or not to be, that is a question: Whether it is nobler in the mind to suffer. The slings and arrows of outrageous fortune Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, 'tis a consummation Devoutly to be wish'd. To die, to sleep To sleep- perchance to dream: ay, there's the rub! For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause. There 's the respect That makes calamity of so long life
--William Shakespeare
-
- lg
-
-
-
- ...
-
- --William Shakespeare
-
- Expand
-
-
,
]
`;
diff --git a/components/typography/__tests__/ellipsis.test.tsx b/components/typography/__tests__/ellipsis.test.tsx
index f6c8feb140..e8de3d364b 100644
--- a/components/typography/__tests__/ellipsis.test.tsx
+++ b/components/typography/__tests__/ellipsis.test.tsx
@@ -14,38 +14,39 @@ jest.mock('../../_util/styleChecker', () => ({
describe('Typography.Ellipsis', () => {
const LINE_STR_COUNT = 20;
+ const LINE_HEIGHT = 16;
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
let mockRectSpy: ReturnType;
- let getWidthTimes = 0;
let computeSpy: jest.SpyInstance;
let offsetWidth: number;
let scrollWidth: number;
+ function getContentHeight(elem?: HTMLElement) {
+ const regex = /<[^>]*>/g;
+
+ let html = (elem || this).innerHTML;
+ html = html.replace(regex, '');
+ const lines = Math.ceil(html.length / LINE_STR_COUNT);
+ return lines * LINE_HEIGHT;
+ }
+
beforeAll(() => {
jest.useFakeTimers();
mockRectSpy = spyElementPrototypes(HTMLElement, {
- offsetHeight: {
- get() {
- let html = this.innerHTML;
- html = html.replace(/<[^>]*>/g, '');
- const lines = Math.ceil(html.length / LINE_STR_COUNT);
- return lines * 16;
- },
- },
- offsetWidth: {
- get: () => {
- getWidthTimes += 1;
- return offsetWidth;
- },
- },
scrollWidth: {
get: () => scrollWidth,
},
- getBoundingClientRect() {
- let html = this.innerHTML;
- html = html.replace(/<[^>]*>/g, '');
- const lines = Math.ceil(html.length / LINE_STR_COUNT);
- return { height: lines * 16 };
+ offsetWidth: {
+ get: () => offsetWidth,
+ },
+ scrollHeight: {
+ get: getContentHeight,
+ },
+ clientHeight: {
+ get() {
+ const { WebkitLineClamp } = this.style;
+ return WebkitLineClamp ? Number(WebkitLineClamp) * LINE_HEIGHT : getContentHeight(this);
+ },
},
});
@@ -61,7 +62,6 @@ describe('Typography.Ellipsis', () => {
afterEach(() => {
errorSpy.mockReset();
- getWidthTimes = 0;
});
afterAll(() => {
@@ -234,24 +234,33 @@ describe('Typography.Ellipsis', () => {
it('should expandable work', async () => {
const onExpand = jest.fn();
- const { container: wrapper } = render(
-
+ const ref = React.createRef();
+ const { container } = render(
+
{fullStr}
,
);
- fireEvent.click(wrapper.querySelector('.ant-typography-expand')!);
+ triggerResize(ref.current!);
+ await waitFakeTimer();
+
+ fireEvent.click(container.querySelector('.ant-typography-expand')!);
expect(onExpand).toHaveBeenCalled();
- expect(wrapper.querySelector('p')?.textContent).toEqual(fullStr);
+ expect(container.querySelector('p')?.textContent).toEqual(fullStr);
});
it('should have custom expand style', async () => {
+ const ref = React.createRef();
const symbol = 'more';
const { container } = render(
-
+
{fullStr}
,
);
+
+ triggerResize(ref.current!);
+ await waitFakeTimer();
+
expect(container.querySelector('.ant-typography-expand')?.textContent).toEqual('more');
});
@@ -289,15 +298,18 @@ describe('Typography.Ellipsis', () => {
});
// Trigger visible should trigger recheck
- getWidthTimes = 0;
+ let getOffsetParent = false;
Object.defineProperty(container.querySelector('.ant-typography'), 'offsetParent', {
- get: () => document.body,
+ get: () => {
+ getOffsetParent = true;
+ return document.body;
+ },
});
act(() => {
elementChangeCallback?.();
});
- expect(getWidthTimes).toBeGreaterThan(0);
+ expect(getOffsetParent).toBeTruthy();
unmount();
expect(disconnectFn).toHaveBeenCalled();
@@ -445,80 +457,6 @@ describe('Typography.Ellipsis', () => {
mockRectSpy.mockRestore();
});
- it('should not throw default dom nodes', async () => {
- let currentWidth = 100;
- // string count is different with different width
- const getLineStrCount = (width: number) => {
- const res = width === 100 ? 20 : 17;
- return res;
- };
-
- const ref = React.createRef();
- const resize = (width: number) => {
- currentWidth = width;
- if (ref.current) triggerResize(ref.current);
- };
-
- mockRectSpy = spyElementPrototypes(HTMLElement, {
- offsetHeight: {
- get() {
- let html = this.innerHTML;
- html = html.replace(/<[^>]*>/g, '');
- const lines = Math.ceil(html.length / getLineStrCount(currentWidth));
-
- return lines * 16;
- },
- },
- offsetWidth: {
- get: () => currentWidth,
- },
- getBoundingClientRect() {
- let html = this.innerHTML;
- html = html.replace(/<[^>]*>/g, '');
- const lines = Math.ceil(html.length / getLineStrCount(currentWidth));
- return { height: lines * 16 };
- },
- });
-
- const { container } = render(
-
- {fullStr}
- ,
- );
-
- // hijackings Math.ceil
- const originalCeil = Math.ceil;
- let hasDefaultStr = false;
-
- // Math.ceil will be used for ellipsis's calculations;
- Math.ceil = (value) => {
- const text = container.querySelector('p')?.innerHTML.replace(/<[^>]*>/g, '');
- if (text && !text.includes('...')) {
- hasDefaultStr = true;
- }
- return originalCeil.call(Math, value);
- };
-
- resize(50);
- await waitFakeTimer(20, 1);
- // ignore last result
- hasDefaultStr = false;
- resize(100);
- await waitFakeTimer();
-
- expect(hasDefaultStr).not.toBeTruthy();
- // reset
- mockRectSpy.mockRestore();
- Math.ceil = originalCeil;
- });
-
// https://github.com/ant-design/ant-design/issues/46580
it('dynamic to be ellipsis should show tooltip', async () => {
const ref = React.createRef();
diff --git a/components/typography/demo/ellipsis-debug.tsx b/components/typography/demo/ellipsis-debug.tsx
index 6c4f7d3c32..da27c4cbb9 100644
--- a/components/typography/demo/ellipsis-debug.tsx
+++ b/components/typography/demo/ellipsis-debug.tsx
@@ -3,6 +3,9 @@ import { Slider, Switch, Typography } from 'antd';
const { Text, Paragraph } = Typography;
+const templateStr =
+ 'In the process of internal desktop applications development, many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of development.';
+
const App: React.FC = () => {
const [rows, setRows] = useState(1);
const [longText, setLongText] = useState(true);
@@ -44,25 +47,19 @@ const App: React.FC = () => {
)}
- In the process of internal desktop applications development, many different design specs and
- implementations would be involved, which might cause designers and developers difficulties
- and duplication and reduce the efficiency of development.
+ {templateStr}
- In the process of internal desktop applications development, many different design specs and
- implementations would be involved, which might cause designers and developers difficulties
- and duplication and reduce the efficiency of development.
+ {templateStr}
- In the process of internal desktop applications development, many different design specs and
- implementations would be involved, which might cause designers and developers difficulties
- and duplication and reduce the efficiency of development.
+ {templateStr}
@@ -80,6 +77,12 @@ const App: React.FC = () => {
默认display none 样式的超长文字, 悬停tooltip失效了
+
+
+ {templateStr.slice(0, 60)}
+ ANTD
+ {templateStr.slice(60)}
+
>
);
};
diff --git a/components/typography/demo/ellipsis-middle.tsx b/components/typography/demo/ellipsis-middle.tsx
index f24354007a..b1e92f2f41 100644
--- a/components/typography/demo/ellipsis-middle.tsx
+++ b/components/typography/demo/ellipsis-middle.tsx
@@ -7,7 +7,7 @@ const EllipsisMiddle: React.FC<{ suffixCount: number; children: string }> = ({
suffixCount,
children,
}) => {
- const start = children.slice(0, children.length - suffixCount).trim();
+ const start = children.slice(0, children.length - suffixCount);
const suffix = children.slice(-suffixCount).trim();
return (
diff --git a/docs/blog/v4-ood.en-US.md b/docs/blog/v4-ood.en-US.md
new file mode 100644
index 0000000000..9181eba279
--- /dev/null
+++ b/docs/blog/v4-ood.en-US.md
@@ -0,0 +1,17 @@
+---
+title: 📢 v4 surpassed maintenance period
+date: 2024-02-28
+author: zombieJ
+---
+
+For our release schedule, the maintenance period for Ant Design v4 has officially ended at the end of 2023. This means that we will not release any new updates or patches for v4 unless significant defects or other serious issues are discovered. We strongly recommend that users upgrade to Ant Design v5 as soon as possible.
+
+You will get a series of benefits from upgrading to v5, including more powerful design system theme capabilities, richer component functionality, performance optimization, and more. In addition, v5 also includes many issue fixes and user experience improvements based on community feedback. We will continue to provide continuous support and updates on v5 to ensure that developers can get the best user experience.
+
+For a smooth transition to v5, we provide detailed upgrade guides and documentation. We understand that the upgrade process may involve a lot of work, so our team is also working hard to make this process as seamless and simple as possible. If you encounter any problems during the upgrade process, please feel free to submit an issue on GitHub.
+
+Please visit our official website or view the v5 upgrade documentation directly to start your upgrade journey and enjoy the latest Ant Design experience.
+
+- [v4 to v5](https://ant.design/docs/react/migration-v5)
+- [Less variables to Component Token](https://ant.design/docs/react/migrate-less-variables)
+- [CSS Compatible](https://ant.design/docs/react/compatible-style)
diff --git a/docs/blog/v4-ood.zh-CN.md b/docs/blog/v4-ood.zh-CN.md
new file mode 100644
index 0000000000..dc279233f3
--- /dev/null
+++ b/docs/blog/v4-ood.zh-CN.md
@@ -0,0 +1,17 @@
+---
+title: 📢 v4 维护周期截止
+date: 2024-02-28
+author: zombieJ
+---
+
+根据我们的发布时间表,Ant Design v4 版本的维护期已于 2023 年年底正式结束。这意味着,除非发现了重大的缺陷或其他严重问题,我们不会再为 v4 推出任何新的更新或补丁版本。我们强烈建议用户尽快升级到 Ant Design v5 版本。
+
+升级至 v5 将为您带来一系列的好处:包括对更强大的设计系统主题能力、更为丰富的组件功能、性能优化等等。此外,v5 还包含了许多社区反馈的问题修复和用户体验的改进。我们将继续在 v5 上提供持续的支持和更新,确保开发者可以获得最佳的使用体验。
+
+为了帮助您平滑迁移到 v5,我们提供了详尽的升级指南和文档。我们了解升级过程可能会涉及到不少工作量,因此我们的团队也在努力使这个过程尽可能无缝和简便。如果你在升级过程中遇到任何问题,欢迎在 GitHub 中提交 issue 反馈。
+
+请访问我们的官方网站或直接查看 v5 的升级文档,开始您的升级之旅,享受最新的 Ant Design 体验。
+
+- [从 v4 到 v5](https://ant.design/docs/react/migration-v5-cn)
+- [从 Less 变量到 Design Token](https://ant.design/docs/react/migrate-less-variables-cn)
+- [样式兼容](https://ant.design/docs/react/compatible-style-cn)
diff --git a/docs/react/use-with-next.zh-CN.md b/docs/react/use-with-next.zh-CN.md
index fe96742aef..16bef1e574 100644
--- a/docs/react/use-with-next.zh-CN.md
+++ b/docs/react/use-with-next.zh-CN.md
@@ -14,7 +14,7 @@ tag: Updated
-工具会自动初始化一个脚手架并安装项目的各种必要依赖,在安装过程中,有一些配置项需要自行选择,如果在过程中出现网络问题,请尝试配置代理,或使用其他 npm registry。
+工具会自动初始化一个脚手架并安装项目的各种必要依赖,在安装过程中,有一些配置项需要自行选择,如果在过程中出现网络问题,请尝试配置代理,或使用其他 npm registry,例如,你可以切换到淘宝镜像源:`npm config set registry https://registry.npmmirror.com`。
初始化完成后,我们进入项目并启动。
diff --git a/package.json b/package.json
index 99bd0afca7..93b345d53f 100644
--- a/package.json
+++ b/package.json
@@ -119,6 +119,7 @@
"@ant-design/cssinjs": "^1.18.4",
"@ant-design/icons": "^5.3.0",
"@ant-design/react-slick": "~1.0.2",
+ "@babel/runtime": "^7.23.9",
"@ctrl/tinycolor": "^3.6.1",
"@rc-component/color-picker": "~1.5.2",
"@rc-component/mutate-observer": "^1.1.0",
@@ -143,7 +144,7 @@
"rc-motion": "^2.9.0",
"rc-notification": "~5.3.0",
"rc-pagination": "~4.0.4",
- "rc-picker": "~4.1.4",
+ "rc-picker": "~4.1.5",
"rc-progress": "~3.5.1",
"rc-rate": "~2.12.0",
"rc-resize-observer": "^1.4.0",
@@ -170,7 +171,7 @@
"@antv/g6": "^4.8.24",
"@babel/eslint-plugin": "^7.23.5",
"@biomejs/biome": "^1.5.3",
- "@codesandbox/sandpack-react": "^2.13.0",
+ "@codesandbox/sandpack-react": "^2.13.2",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
@@ -207,17 +208,17 @@
"@types/prismjs": "^1.26.3",
"@types/progress": "^2.0.7",
"@types/qs": "^6.9.11",
- "@types/react": "^18.2.58",
+ "@types/react": "^18.2.60",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.2.19",
"@types/react-highlight-words": "^0.16.7",
"@types/react-resizable": "^3.0.7",
- "@types/semver": "^7.5.7",
+ "@types/semver": "^7.5.8",
"@types/tar": "^6.1.11",
"@types/throttle-debounce": "^5.0.2",
"@types/warning": "^3.0.3",
- "@typescript-eslint/eslint-plugin": "^7.0.2",
- "@typescript-eslint/parser": "^7.0.2",
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
+ "@typescript-eslint/parser": "^7.1.0",
"ali-oss": "^6.20.0",
"antd-img-crop": "^4.21.0",
"antd-style": "^3.6.1",
@@ -232,7 +233,7 @@
"dumi": "^2.3.0-beta.7",
"dumi-plugin-color-chunk": "^1.1.0",
"esbuild-loader": "^4.0.3",
- "eslint": "^8.56.0",
+ "eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
@@ -278,7 +279,7 @@
"node-fetch": "^3.3.2",
"node-notifier": "^10.0.1",
"nprogress": "^0.2.0",
- "open": "^10.0.3",
+ "open": "^10.0.4",
"pixelmatch": "^5.3.0",
"pngjs": "^7.0.0",
"prettier": "^3.2.5",
@@ -286,7 +287,7 @@
"pretty-format": "^29.7.0",
"prismjs": "^1.29.0",
"progress": "^2.0.3",
- "puppeteer": "^22.2.0",
+ "puppeteer": "^22.3.0",
"qs": "^6.11.2",
"rc-footer": "^0.6.8",
"rc-tween-one": "^3.0.6",
@@ -323,9 +324,9 @@
"sylvanas": "^0.6.1",
"tar": "^6.2.0",
"tar-fs": "^3.0.5",
- "terser": "^5.28.0",
+ "terser": "^5.28.1",
"tsx": "^4.7.1",
- "typedoc": "^0.25.8",
+ "typedoc": "^0.25.9",
"typescript": "~5.3.3",
"vanilla-jsoneditor": "^0.21.6",
"vanilla-tilt": "^1.8.1",
diff --git a/tests/dekko/use-client.test.js b/tests/dekko/use-client.test.js
index 99f6aae9fd..3f8997c05d 100644
--- a/tests/dekko/use-client.test.js
+++ b/tests/dekko/use-client.test.js
@@ -25,6 +25,7 @@ if (process.env.LIB_DIR === 'dist') {
$('{es,lib}/typography/Base/*.js')
.isFile()
+ .filter((filename) => !filename.endsWith('/util.js'))
.assert('contain use client', (filename) => includeUseClient(filename));
}