diff --git a/.github/workflows/pr-check-ci.yml b/.github/workflows/pr-check-ci.yml
index 054c1e052270..b065fa90d9c6 100644
--- a/.github/workflows/pr-check-ci.yml
+++ b/.github/workflows/pr-check-ci.yml
@@ -28,4 +28,4 @@ jobs:
success-review: true
success-merge: true
merge-method: 'merge'
- merge-title: 'chore: auto merge branchs (#${number})'
+ merge-title: 'chore: auto merge branches (#${number})'
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 760f34640a0b..85a76bb0f2dd 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -138,7 +138,7 @@ jobs:
key: dist-${{ github.sha }}
- name: dist
- run: npm run dist
+ run: CI=1 npm run dist
env:
NODE_OPTIONS: --max_old_space_size=4096
needs: setup
@@ -236,6 +236,7 @@ jobs:
matrix:
react: ['16', '17', '18']
module: ['dom', 'node', 'dist']
+ shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
runs-on: ubuntu-latest
@@ -288,12 +289,11 @@ jobs:
# dom test
- name: dom test
if: ${{ matrix.module == 'dom' }}
- run: npm test -- -w 1 --coverage
+ run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage
- # > 17 only
- name: coverage
+ uses: codecov/codecov-action@v3
if: ${{ matrix.module == 'dom' && matrix.react == '17' }}
- run: bash <(curl -s https://codecov.io/bash)
# node test
- name: node test
@@ -353,6 +353,7 @@ jobs:
matrix:
react: ['16', '17', '18']
module: [lib, es]
+ shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
steps:
@@ -400,7 +401,7 @@ jobs:
- name: test
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
- run: npm test
+ run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}}
env:
LIB_DIR: ${{ matrix.module }}
needs: compile
diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md
index b1314909226b..1bb2a0cafbb8 100644
--- a/CHANGELOG.en-US.md
+++ b/CHANGELOG.en-US.md
@@ -9,7 +9,7 @@ timeline: true
| infrad version | antd version | update content | time |
| --- | --- | --- | --- |
-| 4.20.6 | 4.20.6 | Synchronize the update of antd 4.20.6 version | 2022-05-30 |
+| 4.21.0 | 4.21.0 | 1.Synchronize the update of antd 4.21.0 version
2.Modify a part of UI of table header | 2022-06-09 |
| 4.20.4 | 4.20.4 | Synchronize the update of antd 4.20.4 version | 2022-05-13 |
| 4.20.0 | 4.20.0 | Synchronize the update of antd 4.20.0 version | 2022-04-26 |
| 4.19.5 | 4.19.5 | Synchronize the update of antd 4.19.5 version | 2022-04-07 |
@@ -34,6 +34,62 @@ if you have some problem, welcome to connect `taofeng.yang@shopee.com` or `lay.z
---
+## 4.21.0
+
+`2022-06-06`
+
+- 🔥 Add Form level control input component `disabled`. [#35210](https://github.com/ant-design/ant-design/pull/35210) [@heiyu4585](https://github.com/heiyu4585)
+- 🆕 Tabs support `popupClassName` for more Dropdown. [#35892](https://github.com/ant-design/ant-design/pull/35892)
+- 🆕 Table `rowSelection.onChange` support `info.type` param. [#35598](https://github.com/ant-design/ant-design/pull/35598)
+- 🆕 The `copyable` prop of Typography.Paragraph supports to reset the mime type of the clipboardData by the `format`. [#35219](https://github.com/ant-design/ant-design/pull/35219) [@kanweiwei](https://github.com/kanweiwei)
+- 🆕 TreeSelect support `treeExpandAction`. [#35618](https://github.com/ant-design/ant-design/pull/35618) [@NE-SmallTown](https://github.com/NE-SmallTown)
+- ConfigProvider
+ - 🆕 ConfigProvider support config Pagination `showSizeChanger`. [#35750](https://github.com/ant-design/ant-design/pull/35750)
+ - 🆕 ConfigProvider support `componentDisabled` to config components `disabled` status. [#35718](https://github.com/ant-design/ant-design/pull/35718)
+ - 🛠 Refactor ConfigProvider removing default `renderEmpty` to resolve dist circle deps. [#35570](https://github.com/ant-design/ant-design/pull/35570)
+- Collapse
+ - 🛠 Refactor Collapse to keep stable dom structure with header content. [#35781](https://github.com/ant-design/ant-design/pull/35781)
+ - 🛠 Refactor Collapse `expandIconPosition` with logical position `start` or `end` to resolve RTL style issue. [#35770](https://github.com/ant-design/ant-design/pull/35770)
+- Progress
+ - 🆕 Progress steps support custom strokeColor for each step. [#35855](https://github.com/ant-design/ant-design/pull/35855)
+ - 🛠 Refactor Progress `type="circle"` and `type="dashboard"` for simpler dom structure and better rendering. [#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 🛠 Refactor Progress to React hooks. [#35393](https://github.com/ant-design/ant-design/pull/35393) [@shuaijiumei](https://github.com/shuaijiumei)
+ - 🐞 Fix Progress percent accuracy issue when near 100%. [#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 🐞 Fix Progress `gapDegree` displayed with wrong degree when `type="dashboard"`. [#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 💄 Fix Progress border radius style when `type="line"` and `strokeLinecap="butt"`. [#35822](https://github.com/ant-design/ant-design/pull/35822)
+- Dropdown
+ - 🆕 Dropdown support `autoFocus` to focus elements in `overlay` automaticly when opened. [#35391](https://github.com/ant-design/ant-design/pull/35391)
+ - 🛠 Fix Dropdown nesting menu injection logic. [#35810](https://github.com/ant-design/ant-design/pull/35810)
+- Card
+ - 🛠 Refactor Card `loading` with Skeleton. [#35525](https://github.com/ant-design/ant-design/pull/35525)
+ - 🛠 Refactor Card style to use flex instead of float. [#35236](https://github.com/ant-design/ant-design/pull/35236) [@miracles1919](https://github.com/miracles1919)
+- 🛠 DatePicker refactored to React hooks. [#35425](https://github.com/ant-design/ant-design/pull/35425) [@heiyu4585](https://github.com/heiyu4585)
+- 🛠 Rename className of Pagination `mini` mode with `ant-pagination-mini`. [#35881](https://github.com/ant-design/ant-design/pull/35881)
+- 🛠 Refactor Popconfirm internal realize with Popover component. [#35676](https://github.com/ant-design/ant-design/pull/35676)
+- 🛠 Change the implementation of the bottom button layout of the Modal confirm component. [#35530](https://github.com/ant-design/ant-design/pull/35530) [@foryuki](https://github.com/foryuki)
+- 🐞 Fix the Wave effect does not work in React 18 strict mode. [#35889](https://github.com/ant-design/ant-design/pull/35889) [@Carrotzpc](https://github.com/Carrotzpc)
+- 🐞 Fix Drawer close twice `children` will undefined. [#35853](https://github.com/ant-design/ant-design/pull/35853) [@crazyair](https://github.com/crazyair)
+- Skeleton
+ - 💄 Remove Skeleton default `margin-top` style. [#35848](https://github.com/ant-design/ant-design/pull/35848)
+ - 💄 Optimize Skeleton `active` animation perfermance. [#35836](https://github.com/ant-design/ant-design/pull/35836) [@slotDumpling](https://github.com/slotDumpling)
+- 💄 Remove `!important` in Radio style with `disabled`. [#35920](https://github.com/ant-design/ant-design/pull/35920)
+- TypeScript
+ - 🤖 Fix Form.List type `FormListFieldData` missing property `fieldKey`. [#35884](https://github.com/ant-design/ant-design/pull/35884) [@nanianlisao](https://github.com/nanianlisao)
+- 🌐 Localization
+ - 🇹🇲 Add a new locale `tk_TK`. [#35605](https://github.com/ant-design/ant-design/pull/35605)
+- RTL
+ - 💄 Fix the wrong direction of `border` and `border-radius` for InputNumber and Input in RTL mode. [#35876](https://github.com/ant-design/ant-design/pull/35876) [@yykoypj](https://github.com/yykoypj)
+
+## 4.20.7
+
+`2022-05-30`
+
+- 🐞 Fix Drawer form instance lost bug when opened. [#35706](https://github.com/ant-design/ant-design/pull/35706) [@crazyair](https://github.com/crazyair)
+- 🐞 Fix Segmented options invalid space between icon and text when using the icon prop. [#35701](https://github.com/ant-design/ant-design/pull/35701)
+- 💄 Optimize Popover arrow style. [#35717](https://github.com/ant-design/ant-design/pull/35717)
+- TypeScript
+ - 🤖 Fix Card type hints problem. [#35753](https://github.com/ant-design/ant-design/pull/35753)
+
## 4.20.6
`2022-05-22`
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index fb0d26c5621a..f1ae30f2f189 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -9,6 +9,7 @@ timeline: true
| infrad 版本号 | 对应 antd 版本号 | 更新内容 | 时间 |
| --- | --- | --- | --- |
+| 4.21.0 | 4.21.0 | 1.同步 antd 4.21.0 版本的更新
2.修改 table 表头部分 UI | 2022-06-09 |
| 4.20.6 | 4.20.6 | 同步 antd 4.20.6 版本的更新 | 2022-05-30 |
| 4.20.4 | 4.20.4 | 同步 antd 4.20.4 版本的更新 | 2022-05-13 |
| 4.20.0 | 4.20.0 | 同步 antd 4.20.0 版本的更新 | 2022-04-26 |
@@ -34,6 +35,62 @@ timeline: true
---
+## 4.21.0
+
+`2022-06-06`
+
+- 🔥 新增 Form 级别控制输入组件 `disabled`。[#35210](https://github.com/ant-design/ant-design/pull/35210) [@heiyu4585](https://github.com/heiyu4585)
+- 🆕 Tabs 组件支持 `popupClassName` 用于更多菜单。[#35892](https://github.com/ant-design/ant-design/pull/35892)
+- 🆕 Table 组件 `rowSelection.onChange` 新增 `info.type` 参数。[#35598](https://github.com/ant-design/ant-design/pull/35598)
+- 🆕 Typography.Paragraph 的 `copyable` 属性支持 `format` 以重置剪切板数据的 Mime Type。[#35219](https://github.com/ant-design/ant-design/pull/35219) [@kanweiwei](https://github.com/kanweiwei)
+- 🆕 TreeSelect 支持 `treeExpandAction` 定义展开操作。[#35618](https://github.com/ant-design/ant-design/pull/35618) [@NE-SmallTown](https://github.com/NE-SmallTown)
+- ConfigProvider
+ - 🆕 ConfigProvider 支持全局配置 Pagination `showSizeChanger` 属性。[#35750](https://github.com/ant-design/ant-design/pull/35750)
+ - 🆕 ConfigProvider 支持 `componentDisabled` 来配置组件禁用状态。[#35718](https://github.com/ant-design/ant-design/pull/35718)
+ - 🛠 重构 ConfigProvider 移除默认的 `renderEmpty` 方法以解决打包循环依赖的问题。[#35570](https://github.com/ant-design/ant-design/pull/35570)
+- Collapse
+ - 🛠 重构 Collapse 标题部分以确保其稳定的 DOM 结构易于样式选择。[#35781](https://github.com/ant-design/ant-design/pull/35781)
+ - 🛠 重构 Collapse `expandIconPosition` 为逻辑位置 `start` 与 `end` 以解决 RTL 下的样式问题。[#35770](https://github.com/ant-design/ant-design/pull/35770)
+- Progress
+ - 🆕 Progress 分步进度条支持单独自定义色彩。[#35855](https://github.com/ant-design/ant-design/pull/35855)
+ - 🛠 重构 Progress `type="circle"` 和 `type="dashboard"` 以简化 dom 结构和带来更好的渲染效果。[#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 🛠 重构 Progress 成 React hooks。[#35393](https://github.com/ant-design/ant-design/pull/35393) [@shuaijiumei](https://github.com/shuaijiumei)
+ - 🐞 修复 Progress 进度接近 100% 间距几乎消失的问题。[#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 🐞 修复 Progress `type="dashboard"` 的 `gapDegree` 角度不准确的问题。[#35433](https://github.com/ant-design/ant-design/pull/35433)
+ - 💄 修复 Progress `type="line"` 和 `strokeLinecap="butt"` 时的圆角样式。[#35822](https://github.com/ant-design/ant-design/pull/35822)
+- Dropdown
+ - 🆕 Dropdown 支持 `autoFocus` 属性,打开时自动聚焦下拉单。[#35391](https://github.com/ant-design/ant-design/pull/35391)
+ - 🛠 修复 Dropdown 嵌套菜单注入逻辑。[#35810](https://github.com/ant-design/ant-design/pull/35810)
+- Card
+ - 🛠 使用 Skeleton 重构 Card `loading` 属性。[#35525](https://github.com/ant-design/ant-design/pull/35525)
+ - 🛠 重构 Card 样式用 flex 代替 float。[#35236](https://github.com/ant-design/ant-design/pull/35236) [@miracles1919](https://github.com/miracles1919)
+- 🛠 DatePicker 重构成 React hooks。[#35425](https://github.com/ant-design/ant-design/pull/35425) [@heiyu4585](https://github.com/heiyu4585)
+- 🛠 将 Pagination `mini` 模式的 className 重命名为 `ant-pagination-mini`。[#35881](https://github.com/ant-design/ant-design/pull/35881)
+- 🛠 重构 Popconfirm 内部实现为 Popover 组件。[#35676](https://github.com/ant-design/ant-design/pull/35676)
+- 🛠 改变 Modal confirm 组件底部按钮布局实现方式。[#35530](https://github.com/ant-design/ant-design/pull/35530) [@foryuki](https://github.com/foryuki)
+- 🐞 修复波浪效果在 React 18 严格模式不生效的问题。[#35889](https://github.com/ant-design/ant-design/pull/35889) [@Carrotzpc](https://github.com/Carrotzpc)
+- 🐞 修复 Drawer 关闭 2 次后 `children` 为 undefined 的问题。[#35853](https://github.com/ant-design/ant-design/pull/35853) [@crazyair](https://github.com/crazyair)
+- Skeleton
+ - 💄 移除 Skeleton 默认的 `margin-top` 以便在默认情况下更对称。[#35848](https://github.com/ant-design/ant-design/pull/35848)
+ - 💄 优化 Skeleton `active` 的动画性能。[#35836](https://github.com/ant-design/ant-design/pull/35836) [@slotDumpling](https://github.com/slotDumpling)
+- 💄 移除 Radio 禁用状态时样式中的 `!important`。[#35920](https://github.com/ant-design/ant-design/pull/35920)
+- TypeScript
+ - 🤖 修复 Form.List 类型 `FormListFieldData` 缺失属性 `fieldKey`。[#35884](https://github.com/ant-design/ant-design/pull/35884) [@nanianlisao](https://github.com/nanianlisao)
+- 🌐 国际化
+ - 🇹🇲 添加土库曼语国际化。[#35605](https://github.com/ant-design/ant-design/pull/35605)
+- RTL
+ - 💄 修正 Input 和 InputNumber 的 `border` 和 `border-radius` 在 RTL 模式下的方向问题。[#35876](https://github.com/ant-design/ant-design/pull/35876) [@yykoypj](https://github.com/yykoypj)
+
+## 4.20.7
+
+`2022-05-30`
+
+- 🐞 修复 Drawer 打开时 form 实例为 null 的问题。[#35706](https://github.com/ant-design/ant-design/pull/35706) [@crazyair](https://github.com/crazyair)
+- 🐞 修复 Segmented 组件中选项使用 icon 属性时图标与文字之间的间距失效问题。[#35701](https://github.com/ant-design/ant-design/pull/35701)
+- 💄 优化 Popover 的箭头效果。[#35717](https://github.com/ant-design/ant-design/pull/35717)
+- TypeScript
+ - 🤖 修复 Card 组件的类型提示。[#35753](https://github.com/ant-design/ant-design/pull/35753)
+
## 4.20.6
`2022-05-22`
diff --git a/components/_util/wave.tsx b/components/_util/wave.tsx
index fe233bad9b33..5f7d6998509a 100644
--- a/components/_util/wave.tsx
+++ b/components/_util/wave.tsx
@@ -1,9 +1,9 @@
-import * as React from 'react';
import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
-import { supportRef, composeRef } from 'rc-util/lib/ref';
-import raf from './raf';
+import { composeRef, supportRef } from 'rc-util/lib/ref';
+import * as React from 'react';
import type { ConfigConsumerProps, CSPConfig } from '../config-provider';
import { ConfigConsumer, ConfigContext } from '../config-provider';
+import raf from './raf';
import { cloneElement } from './reactNode';
let styleForPseudo: HTMLStyleElement | null;
@@ -55,6 +55,7 @@ export default class Wave extends React.Component {
context: ConfigConsumerProps;
componentDidMount() {
+ this.destroyed = false;
const node = this.containerRef.current as HTMLDivElement;
if (!node || node.nodeType !== 1) {
return;
diff --git a/components/affix/__tests__/Affix.test.tsx b/components/affix/__tests__/Affix.test.tsx
index 4bee04c5eb00..5d3b0473d2b8 100644
--- a/components/affix/__tests__/Affix.test.tsx
+++ b/components/affix/__tests__/Affix.test.tsx
@@ -1,13 +1,13 @@
-import React from 'react';
import type { ReactWrapper } from 'enzyme';
import { mount } from 'enzyme';
-import type { AffixProps, AffixState } from '..';
+import React from 'react';
+import type { AffixProps, AffixState, InternalAffixClass } from '..';
import Affix from '..';
-import { getObserverEntities } from '../utils';
-import Button from '../../button';
-import rtlTest from '../../../tests/shared/rtlTest';
import accessibilityTest from '../../../tests/shared/accessibilityTest';
-import { sleep, render } from '../../../tests/utils';
+import rtlTest from '../../../tests/shared/rtlTest';
+import { render, sleep } from '../../../tests/utils';
+import Button from '../../button';
+import { getObserverEntities } from '../utils';
const events: Partial) => void>> = {};
@@ -60,7 +60,6 @@ describe('Affix Render', () => {
const domMock = jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect');
let affixMounterWrapper: ReactWrapper;
- let affixWrapper: ReactWrapper>;
const classRect: Record = {
container: {
@@ -143,15 +142,35 @@ describe('Affix Render', () => {
});
describe('updatePosition when target changed', () => {
- it('function change', () => {
+ it('function change', async () => {
document.body.innerHTML = '';
const container = document.querySelector('#id') as HTMLDivElement;
const getTarget = () => container;
- affixWrapper = mount({null});
- affixWrapper.setProps({ target: () => null });
- expect(affixWrapper.find('Affix').last().state().status).toBe(0);
- expect(affixWrapper.find('Affix').last().state().affixStyle).toBe(undefined);
- expect(affixWrapper.find('Affix').last().state().placeholderStyle).toBe(undefined);
+ let affixInstance: InternalAffixClass;
+ const { rerender } = render(
+ {
+ affixInstance = node as InternalAffixClass;
+ }}
+ target={getTarget}
+ >
+ {null}
+ ,
+ );
+ rerender(
+ {
+ affixInstance = node as InternalAffixClass;
+ }}
+ target={() => null}
+ >
+ {null}
+ ,
+ );
+ expect(affixInstance!.state.status).toBe(0);
+ expect(affixInstance!.state.affixStyle).toBe(undefined);
+ expect(affixInstance!.state.placeholderStyle).toBe(undefined);
+ await sleep(100);
});
it('instance change', async () => {
@@ -163,13 +182,12 @@ describe('Affix Render', () => {
const originLength = getObserverLength();
const getTarget = () => target;
- affixWrapper = mount({null});
+ const { rerender } = render({null});
await sleep(100);
expect(getObserverLength()).toBe(originLength + 1);
target = null;
- affixWrapper.setProps({});
- affixWrapper.update();
+ rerender({null});
await sleep(100);
expect(getObserverLength()).toBe(originLength);
});
diff --git a/components/affix/demo/basic.md b/components/affix/demo/basic.md
index a444582071e5..53b3cd7c67bf 100644
--- a/components/affix/demo/basic.md
+++ b/components/affix/demo/basic.md
@@ -14,8 +14,8 @@ title:
The simplest usage.
```tsx
-import React, { useState } from 'react';
import { Affix, Button } from 'infrad';
+import React, { useState } from 'react';
const App: React.FC = () => {
const [top, setTop] = useState(10);
diff --git a/components/affix/demo/debug.md b/components/affix/demo/debug.md
index 3b1464b05d5f..1eae61cd172a 100644
--- a/components/affix/demo/debug.md
+++ b/components/affix/demo/debug.md
@@ -15,8 +15,8 @@ DEBUG
DEBUG
```tsx
-import React, { useState } from 'react';
import { Affix, Button } from 'infrad';
+import React, { useState } from 'react';
const App: React.FC = () => {
const [top, setTop] = useState(10);
diff --git a/components/affix/demo/on-change.md b/components/affix/demo/on-change.md
index 888bfb2734d0..8bba52921170 100644
--- a/components/affix/demo/on-change.md
+++ b/components/affix/demo/on-change.md
@@ -14,8 +14,8 @@ title:
Callback with affixed state.
```tsx
-import React from 'react';
import { Affix, Button } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
console.log(affixed)}>
diff --git a/components/affix/demo/target.md b/components/affix/demo/target.md
index 7f10668a4fe0..3f5769fd6105 100644
--- a/components/affix/demo/target.md
+++ b/components/affix/demo/target.md
@@ -14,8 +14,8 @@ title:
Set a `target` for 'Affix', which is listen to scroll event of target element (default is `window`).
```tsx
-import React, { useState } from 'react';
import { Affix, Button } from 'infrad';
+import React, { useState } from 'react';
const App: React.FC = () => {
const [container, setContainer] = useState(null);
diff --git a/components/affix/index.tsx b/components/affix/index.tsx
index b0c7ee139c76..8de5817709d7 100644
--- a/components/affix/index.tsx
+++ b/components/affix/index.tsx
@@ -1,17 +1,17 @@
-import * as React from 'react';
import classNames from 'classnames';
-import omit from 'rc-util/lib/omit';
import ResizeObserver from 'rc-resize-observer';
+import omit from 'rc-util/lib/omit';
+import * as React from 'react';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';
import {
addObserveTarget,
- removeObserveTarget,
- getTargetRect,
- getFixedTop,
getFixedBottom,
+ getFixedTop,
+ getTargetRect,
+ removeObserveTarget,
} from './utils';
function getDefaultTarget() {
@@ -296,6 +296,8 @@ class Affix extends React.Component {
);
}
}
+// just use in test
+export type InternalAffixClass = Affix;
const AffixFC = React.forwardRef((props, ref) => {
const { prefixCls: customizePrefixCls } = props;
diff --git a/components/alert/demo/action.md b/components/alert/demo/action.md
index d22a048fedd2..6efaa4c50d71 100644
--- a/components/alert/demo/action.md
+++ b/components/alert/demo/action.md
@@ -14,8 +14,8 @@ title:
Custom action.
```tsx
-import React from 'react';
import { Alert, Button, Space } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/alert/demo/banner.md b/components/alert/demo/banner.md
index 12b457befeca..34768105541a 100644
--- a/components/alert/demo/banner.md
+++ b/components/alert/demo/banner.md
@@ -15,8 +15,8 @@ title:
Display Alert as a banner at top of page.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/alert/demo/basic.md b/components/alert/demo/basic.md
index e79f6fdd0b77..cf1b203e147b 100644
--- a/components/alert/demo/basic.md
+++ b/components/alert/demo/basic.md
@@ -14,8 +14,8 @@ title:
The simplest usage for short messages.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => ;
diff --git a/components/alert/demo/closable.md b/components/alert/demo/closable.md
index ba9038e3c163..474a06359188 100644
--- a/components/alert/demo/closable.md
+++ b/components/alert/demo/closable.md
@@ -14,8 +14,8 @@ title:
To show close button.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const onClose = (e: React.MouseEvent) => {
console.log(e, 'I was closed.');
diff --git a/components/alert/demo/close-text.md b/components/alert/demo/close-text.md
index a48c5c96cdc4..858a5660203d 100644
--- a/components/alert/demo/close-text.md
+++ b/components/alert/demo/close-text.md
@@ -14,8 +14,8 @@ title:
Replace the default icon with customized text.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => ;
diff --git a/components/alert/demo/custom-icon.md b/components/alert/demo/custom-icon.md
index d1421550d8f1..6b593cdf422c 100644
--- a/components/alert/demo/custom-icon.md
+++ b/components/alert/demo/custom-icon.md
@@ -15,9 +15,9 @@ title:
A relevant icon makes information clearer and more friendly.
```tsx
-import React from 'react';
-import { Alert } from 'infrad';
import { SmileOutlined } from 'infra-design-icons';
+import { Alert } from 'infrad';
+import React from 'react';
const icon = ;
diff --git a/components/alert/demo/description.md b/components/alert/demo/description.md
index b914f3848e66..a858d0f07900 100644
--- a/components/alert/demo/description.md
+++ b/components/alert/demo/description.md
@@ -14,8 +14,8 @@ title:
Additional description for alert message.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/alert/demo/error-boundary.md b/components/alert/demo/error-boundary.md
index 6b2dc78ecbd9..ca36249985bc 100644
--- a/components/alert/demo/error-boundary.md
+++ b/components/alert/demo/error-boundary.md
@@ -14,8 +14,8 @@ title:
ErrorBoundary Component for making error handling easier in [React](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html).
```tsx
+import { Alert, Button } from 'infrad';
import React, { useState } from 'react';
-import { Button, Alert } from 'infrad';
const { ErrorBoundary } = Alert;
const ThrowError: React.FC = () => {
diff --git a/components/alert/demo/icon.md b/components/alert/demo/icon.md
index faebfd19061b..294e2f6dbbe5 100644
--- a/components/alert/demo/icon.md
+++ b/components/alert/demo/icon.md
@@ -14,8 +14,8 @@ title:
A relevant icon will make information clearer and more friendly.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/alert/demo/loop-banner.md b/components/alert/demo/loop-banner.md
index 9587f2deeb06..dcb0375b8747 100644
--- a/components/alert/demo/loop-banner.md
+++ b/components/alert/demo/loop-banner.md
@@ -14,10 +14,10 @@ title:
Show a loop banner by using with [react-text-loop-next](https://npmjs.com/package/react-text-loop-next) or [react-fast-marquee](https://npmjs.com/package/react-fast-marquee).
```tsx
+import { Alert } from 'infrad';
import React from 'react';
-import { Alert } from 'antd';
-import { TextLoop } from 'react-text-loop-next';
import Marquee from 'react-fast-marquee';
+import { TextLoop } from 'react-text-loop-next';
const App: React.FC = () => (
<>
diff --git a/components/alert/demo/smooth-closed.md b/components/alert/demo/smooth-closed.md
index 9b5a93eec9bb..1ae5a20bdc30 100644
--- a/components/alert/demo/smooth-closed.md
+++ b/components/alert/demo/smooth-closed.md
@@ -14,8 +14,8 @@ title:
Smoothly unmount Alert upon close.
```tsx
-import React, { useState } from 'react';
import { Alert } from 'infrad';
+import React, { useState } from 'react';
const App: React.FC = () => {
const [visible, setVisible] = useState(true);
diff --git a/components/alert/demo/style.md b/components/alert/demo/style.md
index 32467a334cf3..fa1caed430f1 100644
--- a/components/alert/demo/style.md
+++ b/components/alert/demo/style.md
@@ -14,8 +14,8 @@ title:
There are 4 types of Alert: `success`, `info`, `warning`, `error`.
```tsx
-import React from 'react';
import { Alert } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/anchor/demo/basic.md b/components/anchor/demo/basic.md
index 1cdc3b0ca22a..e1f23727435b 100644
--- a/components/anchor/demo/basic.md
+++ b/components/anchor/demo/basic.md
@@ -14,8 +14,8 @@ title:
The simplest usage.
```tsx
-import React from 'react';
import { Anchor } from 'infrad';
+import React from 'react';
const { Link } = Anchor;
diff --git a/components/anchor/demo/customizeHighlight.md b/components/anchor/demo/customizeHighlight.md
index 3e3e8b3ea9f5..25a8bd87d8e5 100644
--- a/components/anchor/demo/customizeHighlight.md
+++ b/components/anchor/demo/customizeHighlight.md
@@ -14,8 +14,8 @@ title:
Customize the anchor highlight.
```tsx
-import React from 'react';
import { Anchor } from 'infrad';
+import React from 'react';
const { Link } = Anchor;
diff --git a/components/anchor/demo/onChange.md b/components/anchor/demo/onChange.md
index 29bea99a3554..451ae617919d 100644
--- a/components/anchor/demo/onChange.md
+++ b/components/anchor/demo/onChange.md
@@ -14,8 +14,8 @@ title:
Listening for anchor link change.
```tsx
-import React from 'react';
import { Anchor } from 'infrad';
+import React from 'react';
const { Link } = Anchor;
diff --git a/components/anchor/demo/onClick.md b/components/anchor/demo/onClick.md
index a03ae2092946..db0487bfbd99 100644
--- a/components/anchor/demo/onClick.md
+++ b/components/anchor/demo/onClick.md
@@ -14,8 +14,8 @@ title:
Clicking on an anchor does not record history.
```tsx
-import React from 'react';
import { Anchor } from 'infrad';
+import React from 'react';
const { Link } = Anchor;
diff --git a/components/anchor/demo/static.md b/components/anchor/demo/static.md
index 1c1f8b4a42d3..bec253aa677d 100644
--- a/components/anchor/demo/static.md
+++ b/components/anchor/demo/static.md
@@ -14,8 +14,8 @@ title:
Do not change state when page is scrolling.
```tsx
-import React from 'react';
import { Anchor } from 'infrad';
+import React from 'react';
const { Link } = Anchor;
diff --git a/components/anchor/demo/targetOffset.md b/components/anchor/demo/targetOffset.md
index 840ebe5702d2..35d46cc5dccc 100644
--- a/components/anchor/demo/targetOffset.md
+++ b/components/anchor/demo/targetOffset.md
@@ -14,8 +14,8 @@ title:
Anchor target scroll to screen center.
```tsx
-import React, { useState, useEffect } from 'react';
import { Anchor } from 'infrad';
+import React, { useEffect, useState } from 'react';
const { Link } = Anchor;
diff --git a/components/auto-complete/__tests__/focus.test.js b/components/auto-complete/__tests__/focus.test.js
index 2f4193f75f57..0a931765e727 100644
--- a/components/auto-complete/__tests__/focus.test.js
+++ b/components/auto-complete/__tests__/focus.test.js
@@ -1,6 +1,6 @@
-import React from 'react';
-import { mount } from 'enzyme';
+import { act } from 'react-dom/test-utils';
import AutoComplete from '..';
+import { render } from '../../../tests/utils';
describe('AutoComplete children could be focus', () => {
beforeAll(() => {
@@ -23,25 +23,35 @@ describe('AutoComplete children could be focus', () => {
it('focus() and onFocus', () => {
const handleFocus = jest.fn();
- const wrapper = mount(, { attachTo: container });
- wrapper.find('input').instance().focus();
- jest.runAllTimers();
+ const { container: wrapper } = render(, {
+ attachTo: container,
+ });
+ wrapper.querySelector('input').focus();
+ act(() => {
+ jest.runAllTimers();
+ });
expect(handleFocus).toHaveBeenCalled();
});
it('blur() and onBlur', () => {
const handleBlur = jest.fn();
- const wrapper = mount(, { attachTo: container });
- wrapper.find('input').instance().focus();
- jest.runAllTimers();
- wrapper.find('input').instance().blur();
- jest.runAllTimers();
+ const { container: wrapper } = render(, {
+ attachTo: container,
+ });
+ wrapper.querySelector('input').focus();
+ act(() => {
+ jest.runAllTimers();
+ });
+ wrapper.querySelector('input').blur();
+ act(() => {
+ jest.runAllTimers();
+ });
expect(handleBlur).toHaveBeenCalled();
});
it('child.ref should work', () => {
const mockRef = jest.fn();
- mount(
+ render(
,
@@ -51,7 +61,7 @@ describe('AutoComplete children could be focus', () => {
it('child.ref instance should support be focused and blured', () => {
let inputRef;
- mount(
+ render(
{
diff --git a/components/auto-complete/__tests__/index.test.js b/components/auto-complete/__tests__/index.test.js
index 702e885278a6..7c239bd800aa 100644
--- a/components/auto-complete/__tests__/index.test.js
+++ b/components/auto-complete/__tests__/index.test.js
@@ -1,30 +1,29 @@
-import React from 'react';
-import { mount } from 'enzyme';
import AutoComplete from '..';
-import Input from '../../input';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
+import { fireEvent, render } from '../../../tests/utils';
+import Input from '../../input';
describe('AutoComplete', () => {
mountTest(AutoComplete);
rtlTest(AutoComplete);
it('AutoComplete with custom Input render perfectly', () => {
- const wrapper = mount(
+ const { container } = render(
,
);
- expect(wrapper.find('textarea').length).toBe(1);
- wrapper.find('textarea').simulate('change', { target: { value: '123' } });
+ expect(container.querySelectorAll('textarea').length).toBe(1);
+ fireEvent.change(container.querySelector('textarea'), { target: { value: '123' } });
// should not filter data source defaultly
- expect(wrapper.find('.ant-select-item-option').length).toBe(3);
+ expect(container.querySelectorAll('.ant-select-item-option').length).toBe(3);
});
it('AutoComplete should work when dataSource is object array', () => {
- const wrapper = mount(
+ const { container } = render(
{
,
);
- expect(wrapper.find('input').length).toBe(1);
- wrapper.find('input').simulate('change', { target: { value: 'a' } });
+ expect(container.querySelectorAll('input').length).toBe(1);
+ fireEvent.change(container.querySelector('input'), { target: { value: 'a' } });
// should not filter data source defaultly
- expect(wrapper.find('.ant-select-item-option').length).toBe(2);
+ expect(container.querySelectorAll('.ant-select-item-option').length).toBe(2);
});
it('AutoComplete throws error when contains invalid dataSource', () => {
const spy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
- mount(
+ render(
{}]}>
,
@@ -54,25 +53,27 @@ describe('AutoComplete', () => {
});
it('legacy dataSource should accept react element option', () => {
- const wrapper = mount(ReactNode]} />);
- expect(wrapper.render()).toMatchSnapshot();
+ const { asFragment } = render(
+ ReactNode]} />,
+ );
+ expect(asFragment().firstChild).toMatchSnapshot();
});
it('legacy AutoComplete.Option should be compatiable', () => {
- const wrapper = mount(
+ const { container } = render(
111
222
,
);
- expect(wrapper.find('input').length).toBe(1);
- wrapper.find('input').simulate('change', { target: { value: '1' } });
- expect(wrapper.find('.ant-select-item-option').length).toBe(2);
+ expect(container.querySelectorAll('input').length).toBe(1);
+ fireEvent.change(container.querySelector('input'), { target: { value: '1' } });
+ expect(container.querySelectorAll('.ant-select-item-option').length).toBe(2);
});
it('should not warning when getInputElement is null', () => {
jest.spyOn(console, 'warn').mockImplementation(() => undefined);
- mount();
+ render();
// eslint-disable-next-line no-console
expect(console.warn).not.toBeCalled();
// eslint-disable-next-line no-console
@@ -80,11 +81,11 @@ describe('AutoComplete', () => {
});
it('should not override custom input className', () => {
- const wrapper = mount(
+ const { container } = render(
,
);
- expect(wrapper.find('input').hasClass('custom')).toBe(true);
+ expect(container.querySelector('input').classList.contains('custom')).toBeTruthy();
});
});
diff --git a/components/auto-complete/demo/basic.md b/components/auto-complete/demo/basic.md
index 7d40e4ccf0b6..9e934a519c9f 100644
--- a/components/auto-complete/demo/basic.md
+++ b/components/auto-complete/demo/basic.md
@@ -14,8 +14,8 @@ title:
Basic Usage, set data source of autocomplete with `options` property.
```tsx
-import React, { useState } from 'react';
import { AutoComplete } from 'infrad';
+import React, { useState } from 'react';
const mockVal = (str: string, repeat = 1) => ({
value: str.repeat(repeat),
diff --git a/components/auto-complete/demo/certain-category.md b/components/auto-complete/demo/certain-category.md
index c2b9c3611797..2b12bff915d0 100644
--- a/components/auto-complete/demo/certain-category.md
+++ b/components/auto-complete/demo/certain-category.md
@@ -14,9 +14,9 @@ title:
Demonstration of [Lookup Patterns: Certain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns). Basic Usage, set options of autocomplete with `options` property.
```tsx
-import React from 'react';
-import { Input, AutoComplete } from 'infrad';
import { UserOutlined } from 'infra-design-icons';
+import { AutoComplete, Input } from 'infrad';
+import React from 'react';
const renderTitle = (title: string) => (
diff --git a/components/auto-complete/demo/custom.md b/components/auto-complete/demo/custom.md
index bef809e67b1a..a568ce51e0b1 100644
--- a/components/auto-complete/demo/custom.md
+++ b/components/auto-complete/demo/custom.md
@@ -14,8 +14,8 @@ title:
Customize Input Component
```tsx
-import React, { useState } from 'react';
import { AutoComplete, Input } from 'infrad';
+import React, { useState } from 'react';
const { TextArea } = Input;
diff --git a/components/auto-complete/demo/form-debug.md b/components/auto-complete/demo/form-debug.md
index 499acf19751b..de130d3355fd 100644
--- a/components/auto-complete/demo/form-debug.md
+++ b/components/auto-complete/demo/form-debug.md
@@ -7,9 +7,9 @@ debug: true
---
```tsx
-import React from 'react';
-import { Input, AutoComplete, Form, TreeSelect, Button } from 'infrad';
import { SearchOutlined } from 'infra-design-icons';
+import { AutoComplete, Button, Form, Input, TreeSelect } from 'infrad';
+import React from 'react';
const formItemLayout = {
labelCol: {
diff --git a/components/auto-complete/demo/non-case-sensitive.md b/components/auto-complete/demo/non-case-sensitive.md
index 532d87750cf6..75f9fbdcd180 100644
--- a/components/auto-complete/demo/non-case-sensitive.md
+++ b/components/auto-complete/demo/non-case-sensitive.md
@@ -14,8 +14,8 @@ title:
A non-case-sensitive AutoComplete
```tsx
-import React from 'react';
import { AutoComplete } from 'infrad';
+import React from 'react';
const options = [
{ value: 'Burns Bay Road' },
diff --git a/components/auto-complete/demo/options.md b/components/auto-complete/demo/options.md
index 8f608385d06b..aef36b65a3d4 100644
--- a/components/auto-complete/demo/options.md
+++ b/components/auto-complete/demo/options.md
@@ -14,8 +14,8 @@ title:
You could pass `AutoComplete.Option` as children of `AutoComplete`, instead of using `options`。
```tsx
-import React, { useState } from 'react';
import { AutoComplete } from 'infrad';
+import React, { useState } from 'react';
const { Option } = AutoComplete;
diff --git a/components/auto-complete/demo/status.md b/components/auto-complete/demo/status.md
index 1e13295f1934..910b4c000dc4 100644
--- a/components/auto-complete/demo/status.md
+++ b/components/auto-complete/demo/status.md
@@ -15,8 +15,8 @@ title:
Add status to AutoComplete with `status`, which could be `error` or `warning`.
```tsx
-import React, { useState } from 'react';
import { AutoComplete, Space } from 'infrad';
+import React, { useState } from 'react';
const mockVal = (str: string, repeat = 1) => ({
value: str.repeat(repeat),
diff --git a/components/auto-complete/demo/uncertain-category.md b/components/auto-complete/demo/uncertain-category.md
index a404875394c0..84e78a55b970 100644
--- a/components/auto-complete/demo/uncertain-category.md
+++ b/components/auto-complete/demo/uncertain-category.md
@@ -14,9 +14,9 @@ title:
Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns).
```tsx
-import React, { useState } from 'react';
-import { Input, AutoComplete } from 'infrad';
+import { AutoComplete, Input } from 'infrad';
import type { SelectProps } from 'infrad/es/select';
+import React, { useState } from 'react';
const getRandomInt = (max: number, min = 0) => Math.floor(Math.random() * (max - min + 1)) + min;
diff --git a/components/avatar/demo/badge.md b/components/avatar/demo/badge.md
index afe2fc3f0195..35693e67b00a 100644
--- a/components/avatar/demo/badge.md
+++ b/components/avatar/demo/badge.md
@@ -14,9 +14,9 @@ title:
Usually used for reminders and notifications.
```tsx
-import React from 'react';
-import { Avatar, Badge } from 'infrad';
import { UserOutlined } from 'infra-design-icons';
+import { Avatar, Badge } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/avatar/demo/basic.md b/components/avatar/demo/basic.md
index d2bf16da0503..c4e10906a15a 100644
--- a/components/avatar/demo/basic.md
+++ b/components/avatar/demo/basic.md
@@ -14,9 +14,9 @@ title:
Three sizes and two shapes are available.
```tsx
-import React from 'react';
-import { Avatar } from 'infrad';
import { UserOutlined } from 'infra-design-icons';
+import { Avatar } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/avatar/demo/dynamic.md b/components/avatar/demo/dynamic.md
index db3bfde4144e..cb35db8fec9e 100644
--- a/components/avatar/demo/dynamic.md
+++ b/components/avatar/demo/dynamic.md
@@ -14,8 +14,8 @@ title:
For letter type Avatar, when the letters are too long to display, the font size can be automatically adjusted according to the width of the Avatar. You can also use `gap` to set the unit distance between left and right sides.
```tsx
-import React, { useState } from 'react';
import { Avatar, Button } from 'infrad';
+import React, { useState } from 'react';
const UserList = ['U', 'Lucy', 'Tom', 'Edward'];
const ColorList = ['#f56a00', '#7265e6', '#ffbf00', '#00a2ae'];
diff --git a/components/avatar/demo/fallback.md b/components/avatar/demo/fallback.md
index 0dd01b5f8673..385e786795e2 100644
--- a/components/avatar/demo/fallback.md
+++ b/components/avatar/demo/fallback.md
@@ -15,8 +15,8 @@ debug: true
图片不存在时,如果 `src` 本身是个 ReactElement,会尝试回退到 `src`,否则尝试回退到 `icon`,最后回退到显示 `children`。
```tsx
-import React from 'react';
import { Avatar } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/avatar/demo/group.md b/components/avatar/demo/group.md
index edc7a8244d1b..ebfa6362eba2 100644
--- a/components/avatar/demo/group.md
+++ b/components/avatar/demo/group.md
@@ -14,9 +14,9 @@ title:
Avatar group display.
```tsx
-import React from 'react';
+import { AntDesignOutlined, UserOutlined } from 'infra-design-icons';
import { Avatar, Divider, Tooltip } from 'infrad';
-import { UserOutlined, AntDesignOutlined } from 'infra-design-icons';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/avatar/demo/responsive.md b/components/avatar/demo/responsive.md
index f0c6a61347e3..c1652742a14c 100644
--- a/components/avatar/demo/responsive.md
+++ b/components/avatar/demo/responsive.md
@@ -14,9 +14,9 @@ title:
Avatar size can be automatically adjusted based on the screen size.
```tsx
-import React from 'react';
-import { Avatar } from 'infrad';
import { AntDesignOutlined } from 'infra-design-icons';
+import { Avatar } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
(
<>
diff --git a/components/back-top/__tests__/index.test.js b/components/back-top/__tests__/index.test.js
index 68bda50f06ba..605ded5dadbd 100644
--- a/components/back-top/__tests__/index.test.js
+++ b/components/back-top/__tests__/index.test.js
@@ -1,16 +1,14 @@
-import React from 'react';
-import { mount } from 'enzyme';
-import { sleep } from '../../../tests/utils';
+import BackTop from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
-import BackTop from '..';
+import { fireEvent, render, sleep } from '../../../tests/utils';
describe('BackTop', () => {
mountTest(BackTop);
rtlTest(BackTop);
it('should scroll to top after click it', async () => {
- const wrapper = mount();
+ const { container } = render();
const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => {
window.scrollY = y;
window.pageYOffset = y;
@@ -18,7 +16,7 @@ describe('BackTop', () => {
});
window.scrollTo(0, 400);
expect(document.documentElement.scrollTop).toBe(400);
- wrapper.find('.ant-back-top').simulate('click');
+ fireEvent.click(container.querySelector('.ant-back-top'));
await sleep(500);
expect(document.documentElement.scrollTop).toBe(0);
scrollToSpy.mockRestore();
@@ -26,24 +24,24 @@ describe('BackTop', () => {
it('support onClick', async () => {
const onClick = jest.fn();
- const wrapper = mount();
+ const { container } = render();
const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => {
window.scrollY = y;
window.pageYOffset = y;
});
document.dispatchEvent(new Event('scroll'));
window.scrollTo(0, 400);
- wrapper.find('.ant-back-top').simulate('click');
+ fireEvent.click(container.querySelector('.ant-back-top'));
expect(onClick).toHaveBeenCalled();
scrollToSpy.mockRestore();
});
it('invalid target', async () => {
const onClick = jest.fn();
- const wrapper = mount(
+ const { container } = render(
({ documentElement: {} })} />,
);
- wrapper.find('.ant-back-top').simulate('click');
+ fireEvent.click(container.querySelector('.ant-back-top'));
expect(onClick).toHaveBeenCalled();
});
});
diff --git a/components/back-top/demo/basic.md b/components/back-top/demo/basic.md
index 1e3b426d080e..b75263b0b475 100644
--- a/components/back-top/demo/basic.md
+++ b/components/back-top/demo/basic.md
@@ -14,8 +14,8 @@ title:
The most basic usage.
```tsx
-import React from 'react';
import { BackTop } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/back-top/demo/custom.md b/components/back-top/demo/custom.md
index 054332b1961d..e762319692c6 100644
--- a/components/back-top/demo/custom.md
+++ b/components/back-top/demo/custom.md
@@ -10,13 +10,17 @@ title:
可以自定义回到顶部按钮的样式,限制宽高:`40px * 40px`。
+> 注意:`BackTop` 需要一个可接受 `onClick` 事件的元素作为 `children`。 如果您直接将文本作为子项放置,则该组件将无法正常运行。
+
## en-US
You can customize the style of the button, just note the size limit: no more than `40px * 40px`.
+> Note: `BackTop` expects a element could accept `onClick` propety as children. If you put a text directly as children the component will not function properly.
+
```tsx
-import React from 'react';
import { BackTop } from 'infrad';
+import React from 'react';
const style: React.CSSProperties = {
height: 40,
diff --git a/components/badge/demo/basic.md b/components/badge/demo/basic.md
index 4eaf41d217d2..ad1fbcec263a 100644
--- a/components/badge/demo/basic.md
+++ b/components/badge/demo/basic.md
@@ -14,9 +14,9 @@ title:
Simplest Usage. Badge will be hidden when `count` is `0`, but we can use `showZero` to show it.
```tsx
-import React from 'react';
-import { Badge, Avatar } from 'infrad';
import { ClockCircleOutlined } from 'infra-design-icons';
+import { Avatar, Badge } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md
index b49cab0638c8..d254baf7cca4 100644
--- a/components/badge/demo/change.md
+++ b/components/badge/demo/change.md
@@ -14,9 +14,9 @@ title:
The count will be animated as it changes.
```tsx
-import React, { useState } from 'react';
-import { Badge, Button, Switch, Divider, Avatar } from 'infrad';
import { MinusOutlined, PlusOutlined, QuestionOutlined } from 'infra-design-icons';
+import { Avatar, Badge, Button, Divider, Switch } from 'infrad';
+import React, { useState } from 'react';
const ButtonGroup = Button.Group;
diff --git a/components/badge/demo/colorful.md b/components/badge/demo/colorful.md
index 1a1fee6caf2e..12aafba04bcf 100644
--- a/components/badge/demo/colorful.md
+++ b/components/badge/demo/colorful.md
@@ -14,8 +14,8 @@ title:
We preset a series of colorful Badge styles for use in different situations. You can also set it to a hex color string for custom color.
```tsx
-import React from 'react';
import { Badge, Divider } from 'infrad';
+import React from 'react';
const colors = [
'pink',
diff --git a/components/badge/demo/dot.md b/components/badge/demo/dot.md
index 947507d8e750..f9bc8307e42c 100644
--- a/components/badge/demo/dot.md
+++ b/components/badge/demo/dot.md
@@ -14,9 +14,9 @@ title:
This will simply display a red badge, without a specific count. If count equals 0, it won't display the dot.
```tsx
-import React from 'react';
-import { Badge } from 'infrad';
import { NotificationOutlined } from 'infra-design-icons';
+import { Badge } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/link.md b/components/badge/demo/link.md
index 54410ab500ea..5a03fad4506b 100644
--- a/components/badge/demo/link.md
+++ b/components/badge/demo/link.md
@@ -14,8 +14,8 @@ title:
The badge can be wrapped with `a` tag to make it linkable.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
diff --git a/components/badge/demo/mix.md b/components/badge/demo/mix.md
index 6cb21c257bd4..7cf2f4fbc868 100644
--- a/components/badge/demo/mix.md
+++ b/components/badge/demo/mix.md
@@ -15,8 +15,8 @@ debug: true
Using `count/dot` with custom `stauts/color`.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/no-wrapper.md b/components/badge/demo/no-wrapper.md
index 10b40e1e0fed..111cd4dded91 100644
--- a/components/badge/demo/no-wrapper.md
+++ b/components/badge/demo/no-wrapper.md
@@ -16,9 +16,9 @@ title:
Used in standalone when children is empty.
```tsx
-import React, { useState } from 'react';
-import { Badge, Space, Switch } from 'infrad';
import { ClockCircleOutlined } from 'infra-design-icons';
+import { Badge, Space, Switch } from 'infrad';
+import React, { useState } from 'react';
const App: React.FC = () => {
const [show, setShow] = useState(true);
diff --git a/components/badge/demo/offset.md b/components/badge/demo/offset.md
index e1d9846fd7e0..315f685ff9de 100644
--- a/components/badge/demo/offset.md
+++ b/components/badge/demo/offset.md
@@ -14,8 +14,8 @@ title:
Set offset of the badge dot, the format is `[left, top]`, which represents the offset of the status dot from the left and top of the default position.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
diff --git a/components/badge/demo/overflow.md b/components/badge/demo/overflow.md
index 44bc9f4df90b..8bc5faecd086 100644
--- a/components/badge/demo/overflow.md
+++ b/components/badge/demo/overflow.md
@@ -14,8 +14,8 @@ title:
`${overflowCount}+` is displayed when count is larger than `overflowCount`. The default value of `overflowCount` is `99`.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/ribbbon.md b/components/badge/demo/ribbbon.md
index 94c7788b24a6..e61fd7878231 100644
--- a/components/badge/demo/ribbbon.md
+++ b/components/badge/demo/ribbbon.md
@@ -14,8 +14,8 @@ title:
Use ribbon badge.
```tsx
-import React from 'react';
import { Badge, Card } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/ribbon-debug.md b/components/badge/demo/ribbon-debug.md
index aed9af900ddf..a25b4c4cb4a5 100644
--- a/components/badge/demo/ribbon-debug.md
+++ b/components/badge/demo/ribbon-debug.md
@@ -15,8 +15,8 @@ Buggy!
Buggy!
```tsx
-import React from 'react';
import { Badge, Card, Space } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
diff --git a/components/badge/demo/size.md b/components/badge/demo/size.md
index b3ab3108c38c..14020d30ec21 100644
--- a/components/badge/demo/size.md
+++ b/components/badge/demo/size.md
@@ -14,8 +14,8 @@ title:
Set size of numeral Badge.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/status.md b/components/badge/demo/status.md
index f5ee3ebc38be..289f3f1ba50e 100644
--- a/components/badge/demo/status.md
+++ b/components/badge/demo/status.md
@@ -14,8 +14,8 @@ title:
Standalone badge with status.
```tsx
-import React from 'react';
import { Badge } from 'infrad';
+import React from 'react';
const App: React.FC = () => (
<>
diff --git a/components/badge/demo/title.md b/components/badge/demo/title.md
index cb89153b785e..bdee705e9980 100644
--- a/components/badge/demo/title.md
+++ b/components/badge/demo/title.md
@@ -15,8 +15,8 @@ debug: true
The badge will display `title` when hovered over, instead of `count`.
```tsx
+import { Avatar, Badge } from 'infrad';
import React from 'react';
-import { Badge, Avatar } from 'infrad';
const App: React.FC = () => (
<>
diff --git a/components/breadcrumb/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/breadcrumb/__tests__/__snapshots__/demo-extend.test.ts.snap
index 1359ed174acd..96b8d3e1363f 100644
--- a/components/breadcrumb/__tests__/__snapshots__/demo-extend.test.ts.snap
+++ b/components/breadcrumb/__tests__/__snapshots__/demo-extend.test.ts.snap
@@ -138,7 +138,6 @@ exports[`renders ./components/breadcrumb/demo/overlay.md extend context correctl
>