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(