chore: merge conflict

This commit is contained in:
zombiej 2022-04-11 17:41:54 +08:00
commit a0d1440050
763 changed files with 2798 additions and 2206 deletions

View File

@ -9,8 +9,14 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: read
jobs: jobs:
compressed-size: compressed-size:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for preactjs/compressed-size-action to create PR comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CI_JOB_NUMBER: 1 CI_JOB_NUMBER: 1

View File

@ -4,8 +4,14 @@ on:
schedule: schedule:
- cron: "0 0 */15 * *" - cron: "0 0 */15 * *"
permissions:
contents: read
jobs: jobs:
issue-check-inactive: issue-check-inactive:
permissions:
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-inactive - name: check-inactive

View File

@ -4,8 +4,14 @@ on:
schedule: schedule:
- cron: "0 0 * * *" - cron: "0 0 * * *"
permissions:
contents: read
jobs: jobs:
issue-close-require: issue-close-require:
permissions:
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: need reproduce - name: need reproduce

View File

@ -6,8 +6,14 @@ on:
issues: issues:
types: [labeled] types: [labeled]
permissions:
contents: read
jobs: jobs:
issue-labeled: issue-labeled:
permissions:
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: help wanted - name: help wanted

View File

@ -4,8 +4,15 @@ on:
issues: issues:
types: [opened] types: [opened]
permissions:
contents: read
jobs: jobs:
issue-open-check: issue-open-check:
permissions:
contents: read # for visiky/dingtalk-release-notify to get latest release
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-cool/check-user-permission@v2 - uses: actions-cool/check-user-permission@v2

View File

@ -6,8 +6,14 @@ on:
issue_comment: issue_comment:
types: [created, edited] types: [created, edited]
permissions:
contents: read
jobs: jobs:
issue-remove-inactive: issue-remove-inactive:
permissions:
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: remove inactive - name: remove inactive

View File

@ -4,8 +4,13 @@ on:
issues: issues:
types: [opened, edited] types: [opened, edited]
permissions:
contents: read
jobs: jobs:
similarity-analysis: similarity-analysis:
permissions:
issues: write # for actions-cool/issues-similarity-analysis to create issue comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: analysis - name: analysis

View File

@ -5,8 +5,16 @@ on:
schedule: schedule:
- cron: "*/10 * * * *" - cron: "*/10 * * * *"
permissions:
contents: read
jobs: jobs:
pr-check-ci: pr-check-ci:
permissions:
checks: read # for actions-cool/check-pr-ci to get check reference
contents: write # for actions-cool/check-pr-ci to merge PRs
issues: write # for actions-cool/check-pr-ci to update issues
pull-requests: write # for actions-cool/check-pr-ci to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-cool/check-pr-ci@v1 - uses: actions-cool/check-pr-ci@v1

View File

@ -4,8 +4,14 @@ on:
pull_request_target: pull_request_target:
types: [opened] types: [opened]
permissions:
contents: read
jobs: jobs:
pr-check-merge: pr-check-merge:
permissions:
issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: (github.event.pull_request.head.ref == 'feature' || github.event.pull_request.head.ref == 'master') && github.event.pull_request.head.user.login == 'ant-design' if: (github.event.pull_request.head.ref == 'feature' || github.event.pull_request.head.ref == 'master') && github.event.pull_request.head.user.login == 'ant-design'
steps: steps:

View File

@ -4,8 +4,14 @@ on:
pull_request_target: pull_request_target:
types: [opened, edited, reopened, synchronize] types: [opened, edited, reopened, synchronize]
permissions:
contents: read
jobs: jobs:
refuse: refuse:
permissions:
issues: write # for actions-cool/pr-welcome to create, update & react on issues
pull-requests: write # for actions-cool/pr-welcome to request reviewer
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-cool/pr-welcome@v1 - uses: actions-cool/pr-welcome@v1
@ -19,6 +25,8 @@ jobs:
close: true close: true
check-changelog: check-changelog:
permissions:
pull-requests: write # for actions-cool/pr-check-fill to create or update PR comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check fill - name: check fill

View File

@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: read
jobs: jobs:
# Prepare node modules. Reuse cache if available # Prepare node modules. Reuse cache if available
setup: setup:

View File

@ -8,8 +8,15 @@ on:
types: types:
- completed - completed
permissions:
contents: read
jobs: jobs:
deploy-site: deploy-site:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
name: deploy preview name: deploy preview
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: >
@ -65,6 +72,10 @@ jobs:
number: ${{ steps.pr.outputs.id }} number: ${{ steps.pr.outputs.id }}
build-site-failed: build-site-failed:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
name: build preview failed name: build preview failed
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: >

View File

@ -10,8 +10,14 @@ on:
pull_request_target: pull_request_target:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
permissions:
contents: read
jobs: jobs:
preview-start: preview-start:
permissions:
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
name: start preview info name: start preview info
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -4,8 +4,14 @@ on:
issue_comment: issue_comment:
types: [created] types: [created]
permissions:
contents: read
jobs: jobs:
rebase: rebase:
permissions:
contents: write # for cirrus-actions/rebase to push code to rebase
pull-requests: read # for cirrus-actions/rebase to get info about PR
name: Rebase name: Rebase
if: github.event.issue.pull_request != '' && (contains(github.event.comment.body, '/rebase') || contains(github.event.comment.body, '\rebase')) if: github.event.issue.pull_request != '' && (contains(github.event.comment.body, '/rebase') || contains(github.event.comment.body, '\rebase'))
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -10,8 +10,13 @@ name: Release Helper
on: on:
create create
permissions:
contents: read
jobs: jobs:
release-helper: release-helper:
permissions:
contents: write # for actions-cool/release-helper to create releases
if: github.event.ref_type == 'tag' if: github.event.ref_type == 'tag'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -4,6 +4,9 @@ name: Deploy website
on: on:
create create
permissions:
contents: read
jobs: jobs:
setup: setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -10,8 +10,13 @@ on:
- 3.x-stable - 3.x-stable
create: create:
permissions:
contents: read
jobs: jobs:
mirror: mirror:
permissions:
contents: none
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'ant-design/ant-design' if: github.repository == 'ant-design/ant-design'
steps: steps:

View File

@ -9,6 +9,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: read
jobs: jobs:
setup: setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -23,7 +26,7 @@ jobs:
key: lock-${{ github.sha }} key: lock-${{ github.sha }}
- name: create package-lock.json - name: create package-lock.json
run: npm i --package-lock-only --ignore-scripts --force run: npm i --package-lock-only --ignore-scripts
- name: hack for single file - name: hack for single file
run: | run: |
@ -40,7 +43,7 @@ jobs:
- name: install - name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true' if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci --force run: npm ci
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -231,8 +234,7 @@ jobs:
name: test name: test
strategy: strategy:
matrix: matrix:
react: ['16', '17'] react: ['16', '17', '18']
# react: ['17', '18']
module: ['dom', 'node', 'dist'] module: ['dom', 'node', 'dist']
env: env:
REACT: ${{ matrix.react }} REACT: ${{ matrix.react }}
@ -349,8 +351,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
react: ['16', '17'] react: ['16', '17', '18']
# react: ['17', '18']
module: [lib, es] module: [lib, es]
env: env:
REACT: ${{ matrix.react }} REACT: ${{ matrix.react }}
@ -402,4 +403,4 @@ jobs:
run: npm test run: npm test
env: env:
LIB_DIR: ${{ matrix.module }} LIB_DIR: ${{ matrix.module }}
needs: compile needs: compile

View File

@ -8,8 +8,14 @@ on:
types: types:
- completed - completed
permissions:
contents: read
jobs: jobs:
upload-ui: upload-ui:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
pull-requests: read # for dawidd6/action-download-artifact to query commit hash
name: deploy preview name: deploy preview
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: >

View File

@ -12,6 +12,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: read
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -4,8 +4,13 @@ on:
pull_request_target: pull_request_target:
types: [opened, synchronize] types: [opened, synchronize]
permissions:
contents: read
jobs: jobs:
verify: verify:
permissions:
pull-requests: write # for actions-cool/verify-files-modify to update status of PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: verify-version - name: verify-version

View File

@ -4,8 +4,14 @@ on:
pull_request: pull_request:
types: [opened, edited, reopened, synchronize, ready_for_review] types: [opened, edited, reopened, synchronize, ready_for_review]
permissions:
contents: read
jobs: jobs:
verify: verify:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for actions-cool/verify-package-version to comment on PR
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: contains(github.event.pull_request.title, 'changelog') || contains(github.event.pull_request.title, 'release') if: contains(github.event.pull_request.title, 'changelog') || contains(github.event.pull_request.title, 'release')
steps: steps:

View File

@ -15,6 +15,15 @@ timeline: true
--- ---
## 4.19.5
`2022-04-02`
- 🐞 Fix Form that not keep store value when unmount and mount again. [#34845](https://github.com/ant-design/ant-design/pull/34845)
- 🐞 Fix Pagination under `<ConfigProvider componentSize="large" />` should display middle size Select. [#34756](https://github.com/ant-design/ant-design/pull/34756)
- 🐞 fix Skeleton to unable to render `childten` of non-react element. [#34751](https://github.com/ant-design/ant-design/pull/34751) [@1247748612](https://github.com/1247748612)
- 💄 Fix Tag `@tag-border-radius` less variable not work. [#34741](https://github.com/ant-design/ant-design/pull/34741)
## 4.19.4 ## 4.19.4
`2022-03-27` `2022-03-27`
@ -38,7 +47,8 @@ timeline: true
- 💄 Fix missing `status` style in RangePicker. [#34509](https://github.com/ant-design/ant-design/pull/34509) - 💄 Fix missing `status` style in RangePicker. [#34509](https://github.com/ant-design/ant-design/pull/34509)
- 🛎 Add warning for Input getting blurred when dynamically add `hasFeedback`. [#34475](https://github.com/ant-design/ant-design/pull/34475) - 🛎 Add warning for Input getting blurred when dynamically add `hasFeedback`. [#34475](https://github.com/ant-design/ant-design/pull/34475)
- 🐞 Fix missing classname in input when Input has `prefix` or `suffix`. [#34474](https://github.com/ant-design/ant-design/pull/34474) - 🐞 Fix missing classname in input when Input has `prefix` or `suffix`. [#34474](https://github.com/ant-design/ant-design/pull/34474)
- 🌐 Updated it_LT locale for `typeTemplate`. [#34567](https://github.com/ant-design/ant-design/pull/34567) [@Anizcus](https://gitit_LTit_LThub.com/Anizcus) - 🇱🇹 Updated lt_LT locale for `typeTemplate`. [#34567](https://github.com/ant-design/ant-design/pull/34567) [@Anizcus](https://gitit_LTit_LThub.com/Anizcus)
- 🇮🇹 Updated it_iT locale for `Table`. [#34566](https://github.com/ant-design/ant-design/pull/34566) [@freshgiammi](https://gitit_LTit_LThub.com/freshgiammi)
## 4.19.2 ## 4.19.2

View File

@ -15,6 +15,15 @@ timeline: true
--- ---
## 4.19.5
`2022-04-02`
- 🐞 修复 Form 在整个被 unmount 后再次 mount原 Form 的值会被重置的问题。[#34845](https://github.com/ant-design/ant-design/pull/34845)
- 🐞 修复 Pagination 在 `<ConfigProvider componentSize="large" />` 下的 Select 大小问题。[#34756](https://github.com/ant-design/ant-design/pull/34756)
- 🐞 修复 Skeleton 不渲染非 react element 类型的 `children` 问题。[#34751](https://github.com/ant-design/ant-design/pull/34751) [@1247748612](https://github.com/1247748612)
- 💄 修复 Tag `@tag-border-radius` less 变量不生效的问题。[#34741](https://github.com/ant-design/ant-design/pull/34741)
## 4.19.4 ## 4.19.4
`2022-03-27` `2022-03-27`
@ -38,7 +47,8 @@ timeline: true
- 💄 修复 RangePicker `status` 相关样式丢失的问题。[#34509](https://github.com/ant-design/ant-design/pull/34509) - 💄 修复 RangePicker `status` 相关样式丢失的问题。[#34509](https://github.com/ant-design/ant-design/pull/34509)
- 🛎 为动态改变 Form.Item 的 `hasFeedback` 时 Input 焦点丢失添加警告。[#34475](https://github.com/ant-design/ant-design/pull/34475) - 🛎 为动态改变 Form.Item 的 `hasFeedback` 时 Input 焦点丢失添加警告。[#34475](https://github.com/ant-design/ant-design/pull/34475)
- 🐞 修复 Input 有 `prefix` 或者 `suffix` 时 input 缺少某些 className 的问题。[#34474](https://github.com/ant-design/ant-design/pull/34474) - 🐞 修复 Input 有 `prefix` 或者 `suffix` 时 input 缺少某些 className 的问题。[#34474](https://github.com/ant-design/ant-design/pull/34474)
- 🌐 更新 it_LT 的 locale。[#34567](https://github.com/ant-desin/ant-design/pull/34567) [@Anizcus](https://github.com/Anizcus) - 🇱🇹 更新 lt_LT 的 locale。[#34567](https://github.com/ant-design/ant-design/pull/34567) [@Anizcus](https://github.com/Anizcus)
- 🇮🇹 更新 it_iT 的 locale。[#34566](https://github.com/ant-design/ant-design/pull/34566) [@freshgiammi](https://gitit_LTit_LThub.com/freshgiammi)
## 4.19.2 ## 4.19.2

View File

@ -12,6 +12,7 @@ export interface ActionButtonProps {
buttonProps?: ButtonProps; buttonProps?: ButtonProps;
emitEvent?: boolean; emitEvent?: boolean;
quitOnNullishReturnValue?: boolean; quitOnNullishReturnValue?: boolean;
children?: React.ReactNode;
} }
function isThenable(thing?: PromiseLike<any>): boolean { function isThenable(thing?: PromiseLike<any>): boolean {

View File

@ -1,20 +1,26 @@
import raf from 'rc-util/lib/raf'; import raf from 'rc-util/lib/raf';
export function throttleByAnimationFrame(fn: (...args: any[]) => void) { export function throttleByAnimationFrame<T extends unknown[]>(fn: (...args: T) => void) {
let requestId: number | null; let requestId: number | null;
const later = (args: any[]) => () => { const later = (args: T) => () => {
requestId = null; requestId = null;
fn(...args); fn(...args);
}; };
const throttled = (...args: any[]) => { const throttled: {
(...args: T): void;
cancel: () => void;
} = (...args: T) => {
if (requestId == null) { if (requestId == null) {
requestId = raf(later(args)); requestId = raf(later(args));
} }
}; };
(throttled as any).cancel = () => raf.cancel(requestId!); throttled.cancel = () => {
raf.cancel(requestId!);
requestId = null;
};
return throttled; return throttled;
} }

View File

@ -27,6 +27,7 @@ function isNotGrey(color: string) {
export interface WaveProps { export interface WaveProps {
insertExtraNode?: boolean; insertExtraNode?: boolean;
disabled?: boolean; disabled?: boolean;
children?: React.ReactNode;
} }
export default class Wave extends React.Component<WaveProps> { export default class Wave extends React.Component<WaveProps> {

View File

@ -38,5 +38,5 @@ const Demo: React.FC = () => {
); );
}; };
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```

View File

@ -35,5 +35,5 @@ const Demo: React.FC = () => {
); );
}; };
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```

View File

@ -16,10 +16,9 @@ Callback with affixed state.
```tsx ```tsx
import { Affix, Button } from 'antd'; import { Affix, Button } from 'antd';
ReactDOM.render( export default () => (
<Affix offsetTop={120} onChange={affixed => console.log(affixed)}> <Affix offsetTop={120} onChange={affixed => console.log(affixed)}>
<Button>120px to affix top</Button> <Button>120px to affix top</Button>
</Affix>, </Affix>
mountNode,
); );
``` ```

View File

@ -30,7 +30,7 @@ const Demo: React.FC = () => {
); );
}; };
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```
<style> <style>

View File

@ -4,6 +4,7 @@ import Alert from '.';
interface ErrorBoundaryProps { interface ErrorBoundaryProps {
message?: React.ReactNode; message?: React.ReactNode;
description?: React.ReactNode; description?: React.ReactNode;
children?: React.ReactNode;
} }
export default class ErrorBoundary extends React.Component< export default class ErrorBoundary extends React.Component<

View File

@ -17,7 +17,7 @@ Custom action.
import React from 'react'; import React from 'react';
import { Alert, Button, Space } from 'antd'; import { Alert, Button, Space } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Alert <Alert
message="Success Tips" message="Success Tips"
@ -69,8 +69,7 @@ ReactDOM.render(
} }
closable closable
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ Display Alert as a banner at top of page.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Alert message="Warning text" banner /> <Alert message="Warning text" banner />
<br /> <br />
@ -30,7 +30,6 @@ ReactDOM.render(
<Alert showIcon={false} message="Warning text without icon" banner /> <Alert showIcon={false} message="Warning text without icon" banner />
<br /> <br />
<Alert type="error" message="Error text" banner /> <Alert type="error" message="Error text" banner />
</>, </>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ The simplest usage for short messages.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render(<Alert message="Success Text" type="success" />, mountNode); export default () => <Alert message="Success Text" type="success" />;
``` ```
<style> <style>

View File

@ -20,7 +20,7 @@ const onClose = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
console.log(e, 'I was closed.'); console.log(e, 'I was closed.');
}; };
ReactDOM.render( export default () => (
<> <>
<Alert <Alert
message="Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text" message="Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text"
@ -35,7 +35,6 @@ ReactDOM.render(
closable closable
onClose={onClose} onClose={onClose}
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -16,5 +16,5 @@ Replace the default icon with customized text.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render(<Alert message="Info Text" type="info" closeText="Close Now" />, mountNode); export default () => <Alert message="Info Text" type="info" closeText="Close Now" />;
``` ```

View File

@ -20,7 +20,7 @@ import { SmileOutlined } from '@ant-design/icons';
const icon = <SmileOutlined />; const icon = <SmileOutlined />;
ReactDOM.render( export default () => (
<> <>
<Alert icon={icon} message="showIcon = false" type="success" /> <Alert icon={icon} message="showIcon = false" type="success" />
<Alert icon={icon} message="Success Tips" type="success" showIcon /> <Alert icon={icon} message="Success Tips" type="success" showIcon />
@ -55,7 +55,6 @@ ReactDOM.render(
type="error" type="error"
showIcon showIcon
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ Additional description for alert message.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Alert <Alert
message="Success Text" message="Success Text"
@ -38,7 +38,6 @@ ReactDOM.render(
description="Error Description Error Description Error Description Error Description" description="Error Description Error Description Error Description Error Description"
type="error" type="error"
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -34,10 +34,9 @@ const ThrowError: React.FC = () => {
); );
}; };
ReactDOM.render( export default () => (
<ErrorBoundary> <ErrorBoundary>
<ThrowError /> <ThrowError />
</ErrorBoundary>, </ErrorBoundary>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ A relevant icon will make information clearer and more friendly.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Alert message="Success Tips" type="success" showIcon /> <Alert message="Success Tips" type="success" showIcon />
<Alert message="Informational Notes" type="info" showIcon /> <Alert message="Informational Notes" type="info" showIcon />
@ -47,7 +47,6 @@ ReactDOM.render(
type="error" type="error"
showIcon showIcon
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -18,7 +18,7 @@ import { Alert } from 'antd';
import { TextLoop } from 'react-text-loop-next'; import { TextLoop } from 'react-text-loop-next';
import Marquee from 'react-fast-marquee'; import Marquee from 'react-fast-marquee';
ReactDOM.render( export default () => (
<> <>
<Alert <Alert
banner banner
@ -39,7 +39,6 @@ ReactDOM.render(
</Marquee> </Marquee>
} }
/> />
</>, </>
mountNode,
); );
``` ```

View File

@ -32,5 +32,5 @@ const App: React.FC = () => {
); );
}; };
ReactDOM.render(<App />, mountNode); export default () => <App />;
``` ```

View File

@ -16,14 +16,13 @@ There are 4 types of Alert: `success`, `info`, `warning`, `error`.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Alert message="Success Text" type="success" /> <Alert message="Success Text" type="success" />
<Alert message="Info Text" type="info" /> <Alert message="Info Text" type="info" />
<Alert message="Warning Text" type="warning" /> <Alert message="Warning Text" type="warning" />
<Alert message="Error Text" type="error" /> <Alert message="Error Text" type="error" />
</>, </>
mountNode,
); );
``` ```

View File

@ -98,7 +98,7 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState, Co
activeLink: null, activeLink: null,
}; };
content: ConfigConsumerProps; context: ConfigConsumerProps;
private wrapperRef = React.createRef<HTMLDivElement>(); private wrapperRef = React.createRef<HTMLDivElement>();

View File

@ -18,7 +18,7 @@ import { Anchor } from 'antd';
const { Link } = Anchor; const { Link } = Anchor;
ReactDOM.render( export default () => (
<Anchor> <Anchor>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" /> <Link href="#components-anchor-demo-static" title="Static demo" />
@ -26,8 +26,7 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>
mountNode,
); );
``` ```

View File

@ -20,7 +20,7 @@ const { Link } = Anchor;
const getCurrentAnchor = () => '#components-anchor-demo-static'; const getCurrentAnchor = () => '#components-anchor-demo-static';
ReactDOM.render( export default () => (
<Anchor affix={false} getCurrentAnchor={getCurrentAnchor}> <Anchor affix={false} getCurrentAnchor={getCurrentAnchor}>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" /> <Link href="#components-anchor-demo-static" title="Static demo" />
@ -28,7 +28,6 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>
mountNode,
); );
``` ```

View File

@ -22,7 +22,7 @@ const onChange = (link: string) => {
console.log('Anchor:OnChange', link); console.log('Anchor:OnChange', link);
}; };
ReactDOM.render( export default () => (
<Anchor affix={false} onChange={onChange}> <Anchor affix={false} onChange={onChange}>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" /> <Link href="#components-anchor-demo-static" title="Static demo" />
@ -30,7 +30,6 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>
mountNode,
); );
``` ```

View File

@ -29,7 +29,7 @@ const handleClick = (
console.log(link); console.log(link);
}; };
ReactDOM.render( export default () => (
<Anchor affix={false} onClick={handleClick}> <Anchor affix={false} onClick={handleClick}>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" /> <Link href="#components-anchor-demo-static" title="Static demo" />
@ -37,7 +37,6 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>
mountNode,
); );
``` ```

View File

@ -18,7 +18,7 @@ import { Anchor } from 'antd';
const { Link } = Anchor; const { Link } = Anchor;
ReactDOM.render( export default () => (
<Anchor affix={false}> <Anchor affix={false}>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" /> <Link href="#components-anchor-demo-static" title="Static demo" />
@ -26,7 +26,6 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>
mountNode,
); );
``` ```

View File

@ -36,5 +36,5 @@ const AnchorExample: React.FC = () => {
); );
}; };
ReactDOM.render(<AnchorExample />, mountNode); export default () => <AnchorExample />;
``` ```

View File

@ -58,5 +58,5 @@ const Complete: React.FC = () => {
); );
}; };
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```

View File

@ -74,7 +74,7 @@ const Complete: React.FC = () => (
</AutoComplete> </AutoComplete>
); );
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```
```css ```css

View File

@ -52,5 +52,5 @@ const Complete: React.FC = () => {
); );
}; };
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```

View File

@ -21,7 +21,7 @@ const formItemLayout = {
}, },
}; };
ReactDOM.render( export default () => (
<Form style={{ margin: '0 auto' }} {...formItemLayout}> <Form style={{ margin: '0 auto' }} {...formItemLayout}>
<Form.Item label="单独 AutoComplete"> <Form.Item label="单独 AutoComplete">
<AutoComplete /> <AutoComplete />
@ -67,7 +67,6 @@ ReactDOM.render(
</Button> </Button>
</Input.Group> </Input.Group>
</Form.Item> </Form.Item>
</Form>, </Form>
mountNode,
); );
``` ```

View File

@ -33,5 +33,5 @@ const Complete: React.FC = () => (
/> />
); );
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```

View File

@ -41,5 +41,5 @@ const Complete: React.FC = () => {
); );
}; };
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```

View File

@ -38,5 +38,5 @@ const ValidateInputs: React.FC = () => {
); );
}; };
ReactDOM.render(<ValidateInputs />, mountNode); export default () => <ValidateInputs />;
``` ```

View File

@ -77,5 +77,5 @@ const Complete: React.FC = () => {
); );
}; };
ReactDOM.render(<Complete />, mountNode); export default () => <Complete />;
``` ```

View File

@ -7,6 +7,7 @@ const SizeContext = React.createContext<AvatarSize>('default');
export interface SizeContextProps { export interface SizeContextProps {
size?: AvatarSize; size?: AvatarSize;
children?: React.ReactNode;
} }
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => ( export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (

View File

@ -2,6 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import Avatar from '..'; import Avatar from '..';
import mountTest from '../../../tests/shared/mountTest'; import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest'; import rtlTest from '../../../tests/shared/rtlTest';
@ -144,9 +146,10 @@ describe('Avatar Render', () => {
it('should warning when pass a string as icon props', () => { it('should warning when pass a string as icon props', () => {
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(<Avatar size={64} icon="aa" />); render(<Avatar size={64} icon="aa" />);
expect(warnSpy).not.toHaveBeenCalled(); expect(warnSpy).not.toHaveBeenCalled();
mount(<Avatar size={64} icon="user" />);
render(<Avatar size={64} icon="user" />);
expect(warnSpy).toHaveBeenCalledWith( expect(warnSpy).toHaveBeenCalledWith(
`Warning: [antd: Avatar] \`icon\` is using ReactNode instead of string naming in v4. Please check \`user\` at https://ant.design/components/icon`, `Warning: [antd: Avatar] \`icon\` is using ReactNode instead of string naming in v4. Please check \`user\` at https://ant.design/components/icon`,
); );

View File

@ -17,7 +17,7 @@ Usually used for reminders and notifications.
import { Avatar, Badge } from 'antd'; import { Avatar, Badge } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<> <>
<span className="avatar-item"> <span className="avatar-item">
<Badge count={1}> <Badge count={1}>
@ -29,8 +29,7 @@ ReactDOM.render(
<Avatar shape="square" icon={<UserOutlined />} /> <Avatar shape="square" icon={<UserOutlined />} />
</Badge> </Badge>
</span> </span>
</>, </>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ Three sizes and two shapes are available.
import { Avatar } from 'antd'; import { Avatar } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<> <>
<div> <div>
<Avatar size={64} icon={<UserOutlined />} /> <Avatar size={64} icon={<UserOutlined />} />
@ -31,8 +31,7 @@ ReactDOM.render(
<Avatar shape="square" icon={<UserOutlined />} /> <Avatar shape="square" icon={<UserOutlined />} />
<Avatar shape="square" size="small" icon={<UserOutlined />} /> <Avatar shape="square" size="small" icon={<UserOutlined />} />
</div> </div>
</>, </>
mountNode,
); );
``` ```

View File

@ -53,5 +53,5 @@ const Autoset: React.FC = () => {
); );
}; };
ReactDOM.render(<Autoset />, mountNode); export default () => <Autoset />;
``` ```

View File

@ -17,7 +17,7 @@ debug: true
```tsx ```tsx
import { Avatar } from 'antd'; import { Avatar } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Avatar shape="circle" src="http://abc.com/not-exist.jpg"> <Avatar shape="circle" src="http://abc.com/not-exist.jpg">
A A
@ -25,7 +25,6 @@ ReactDOM.render(
<Avatar shape="circle" src="http://abc.com/not-exist.jpg"> <Avatar shape="circle" src="http://abc.com/not-exist.jpg">
ABC ABC
</Avatar> </Avatar>
</>, </>
mountNode,
); );
``` ```

View File

@ -66,5 +66,5 @@ const Demo = () => (
</> </>
); );
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```

View File

@ -17,11 +17,10 @@ Avatar size can be automatically adjusted based on the screen size.
import { Avatar } from 'antd'; import { Avatar } from 'antd';
import { AntDesignOutlined } from '@ant-design/icons'; import { AntDesignOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<Avatar <Avatar
size={{ xs: 24, sm: 32, md: 40, lg: 64, xl: 80, xxl: 100 }} size={{ xs: 24, sm: 32, md: 40, lg: 64, xl: 80, xxl: 100 }}
icon={<AntDesignOutlined />} icon={<AntDesignOutlined />}
/>, />
mountNode,
); );
``` ```

View File

@ -71,5 +71,5 @@ const App: React.FC = () => {
); );
}; };
ReactDOM.render(<App />, mountNode); export default () => <App />;
``` ```

View File

@ -17,7 +17,7 @@ Image, Icon and letter are supported, and the latter two kinds of avatar can hav
import { Avatar, Image } from 'antd'; import { Avatar, Image } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<> <>
<Avatar icon={<UserOutlined />} /> <Avatar icon={<UserOutlined />} />
<Avatar>U</Avatar> <Avatar>U</Avatar>
@ -26,8 +26,7 @@ ReactDOM.render(
<Avatar src={<Image src="https://joeschmoe.io/api/v1/random" style={{ width: 32 }} />} /> <Avatar src={<Image src="https://joeschmoe.io/api/v1/random" style={{ width: 32 }} />} />
<Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf' }}>U</Avatar> <Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf' }}>U</Avatar>
<Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} /> <Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} />
</>, </>
mountNode,
); );
``` ```

View File

@ -16,14 +16,13 @@ The most basic usage.
```jsx ```jsx
import { BackTop } from 'antd'; import { BackTop } from 'antd';
ReactDOM.render( export default () => (
<> <>
<BackTop /> <BackTop />
Scroll down to see the bottom-right Scroll down to see the bottom-right
<strong className="site-back-top-basic"> gray </strong> <strong className="site-back-top-basic"> gray </strong>
button. button.
</>, </>
mountNode,
); );
``` ```

View File

@ -28,7 +28,7 @@ const style = {
fontSize: 14, fontSize: 14,
}; };
ReactDOM.render( export default () => (
<div style={{ height: '600vh', padding: 8 }}> <div style={{ height: '600vh', padding: 8 }}>
<div>Scroll to bottom</div> <div>Scroll to bottom</div>
<div>Scroll to bottom</div> <div>Scroll to bottom</div>
@ -40,7 +40,6 @@ ReactDOM.render(
<BackTop> <BackTop>
<div style={style}>UP</div> <div style={style}>UP</div>
</BackTop> </BackTop>
</div>, </div>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ Simplest Usage. Badge will be hidden when `count` is `0`, but we can use `showZe
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
import { ClockCircleOutlined } from '@ant-design/icons'; import { ClockCircleOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<> <>
<Badge count={5}> <Badge count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -28,8 +28,7 @@ ReactDOM.render(
<Badge count={<ClockCircleOutlined style={{ color: '#f5222d' }} />}> <Badge count={<ClockCircleOutlined style={{ color: '#f5222d' }} />}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -74,5 +74,5 @@ class Demo extends React.Component {
} }
} }
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```

View File

@ -32,7 +32,7 @@ const colors = [
'lime', 'lime',
]; ];
ReactDOM.render( export default () => (
<> <>
<Divider orientation="left">Presets</Divider> <Divider orientation="left">Presets</Divider>
<div> <div>
@ -52,8 +52,7 @@ ReactDOM.render(
<br /> <br />
<Badge color="#108ee9" text="#108ee9" /> <Badge color="#108ee9" text="#108ee9" />
</> </>
</>, </>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ This will simply display a red badge, without a specific count. If count equals
import { Badge } from 'antd'; import { Badge } from 'antd';
import { NotificationOutlined } from '@ant-design/icons'; import { NotificationOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<> <>
<Badge dot> <Badge dot>
<NotificationOutlined style={{ fontSize: 16 }} /> <NotificationOutlined style={{ fontSize: 16 }} />
@ -25,7 +25,6 @@ ReactDOM.render(
<Badge dot> <Badge dot>
<a href="#">Link something</a> <a href="#">Link something</a>
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -16,12 +16,11 @@ The badge can be wrapped with `a` tag to make it linkable.
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<a href="#"> <a href="#">
<Badge count={5}> <Badge count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</a>, </a>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ Using `count/dot` with custom `stauts/color`.
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge count={5} status="success"> <Badge count={5} status="success">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -43,7 +43,6 @@ ReactDOM.render(
<Badge dot color="#fa541c"> <Badge dot color="#fa541c">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -36,5 +36,5 @@ const Demo = () => {
); );
}; };
ReactDOM.render(<Demo />, mountNode); export default () => <Demo />;
``` ```

View File

@ -16,10 +16,9 @@ Set offset of the badge dot, the format is `[left, top]`, which represents the o
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<Badge count={5} offset={[10, 10]}> <Badge count={5} offset={[10, 10]}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge>, </Badge>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ title:
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge count={99}> <Badge count={99}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -30,7 +30,6 @@ ReactDOM.render(
<Badge count={1000} overflowCount={999}> <Badge count={1000} overflowCount={999}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ Use ribbon badge.
```jsx ```jsx
import { Badge, Card } from 'antd'; import { Badge, Card } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge.Ribbon text="Hippies"> <Badge.Ribbon text="Hippies">
<Card title="Pushes open the window" size="small"> <Card title="Pushes open the window" size="small">
@ -58,8 +58,7 @@ ReactDOM.render(
and raises the spyglass. and raises the spyglass.
</Card> </Card>
</Badge.Ribbon> </Badge.Ribbon>
</>, </>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ Buggy!
```jsx ```jsx
import { Badge, Card, Space } from 'antd'; import { Badge, Card, Space } from 'antd';
ReactDOM.render( export default () => (
<Space direction="vertical" style={{ width: '100%' }}> <Space direction="vertical" style={{ width: '100%' }}>
<Badge.Ribbon text="啦啦啦啦"> <Badge.Ribbon text="啦啦啦啦">
<Card>推开窗户举起望远镜</Card> <Card>推开窗户举起望远镜</Card>
@ -34,7 +34,6 @@ ReactDOM.render(
<Badge.Ribbon text="啦啦啦啦" color="#2db7f5" placement="end"> <Badge.Ribbon text="啦啦啦啦" color="#2db7f5" placement="end">
<Card>推开窗户举起望远镜</Card> <Card>推开窗户举起望远镜</Card>
</Badge.Ribbon> </Badge.Ribbon>
</Space>, </Space>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ Set size of numeral Badge.
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge size="default" count={5}> <Badge size="default" count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -24,7 +24,6 @@ ReactDOM.render(
<Badge size="small" count={5}> <Badge size="small" count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ Standalone badge with status.
```jsx ```jsx
import { Badge } from 'antd'; import { Badge } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge status="success" /> <Badge status="success" />
<Badge status="error" /> <Badge status="error" />
@ -33,7 +33,6 @@ ReactDOM.render(
<Badge status="processing" text="Processing" /> <Badge status="processing" text="Processing" />
<br /> <br />
<Badge status="warning" text="Warning" /> <Badge status="warning" text="Warning" />
</>, </>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ The badge will display `title` when hovered over, instead of `count`.
```jsx ```jsx
import { Badge, Avatar } from 'antd'; import { Badge, Avatar } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Badge count={5} title="Custom hover text"> <Badge count={5} title="Custom hover text">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -25,7 +25,6 @@ ReactDOM.render(
<Badge count={-5} title="Negative"> <Badge count={-5} title="Negative">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</>, </>
mountNode,
); );
``` ```

View File

@ -34,6 +34,7 @@ export interface BadgeProps {
size?: 'default' | 'small'; size?: 'default' | 'small';
offset?: [number | string, number | string]; offset?: [number | string, number | string];
title?: string; title?: string;
children?: React.ReactNode;
} }
const Badge: CompoundedComponent = ({ const Badge: CompoundedComponent = ({

View File

@ -31,15 +31,13 @@
} }
} }
&-zoom-appear, &:not(&-not-a-wrapper).@{badge-prefix-cls}-rtl {
&-zoom-enter { .@{badge-prefix-cls}-zoom-appear,
.@{badge-prefix-cls}-rtl & { .@{badge-prefix-cls}-zoom-enter {
animation-name: antZoomBadgeInRtl; animation-name: antZoomBadgeInRtl;
} }
}
&-zoom-leave { .@{badge-prefix-cls}-zoom-leave {
.@{badge-prefix-cls}-rtl & {
animation-name: antZoomBadgeOutRtl; animation-name: antZoomBadgeOutRtl;
} }
} }
@ -79,7 +77,6 @@
} }
} }
@keyframes antZoomBadgeInRtl { @keyframes antZoomBadgeInRtl {
0% { 0% {
transform: scale(0) translate(-50%, -50%); transform: scale(0) translate(-50%, -50%);

View File

@ -27,6 +27,7 @@ export interface BreadcrumbProps {
) => React.ReactNode; ) => React.ReactNode;
style?: React.CSSProperties; style?: React.CSSProperties;
className?: string; className?: string;
children?: React.ReactNode;
} }
function getBreadcrumbName(route: Route, params: any) { function getBreadcrumbName(route: Route, params: any) {

View File

@ -12,6 +12,7 @@ export interface BreadcrumbItemProps {
dropdownProps?: DropDownProps; dropdownProps?: DropDownProps;
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>; onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
className?: string; className?: string;
children?: React.ReactNode;
} }
interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> { interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> {
__ANT_BREADCRUMB_ITEM: boolean; __ANT_BREADCRUMB_ITEM: boolean;

View File

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { ConfigContext } from '../config-provider'; import { ConfigContext } from '../config-provider';
interface BreadcrumbSeparatorInterface extends React.FC { interface BreadcrumbSeparatorInterface extends React.FC<{ children?: React.ReactNode }> {
__ANT_BREADCRUMB_SEPARATOR: boolean; __ANT_BREADCRUMB_SEPARATOR: boolean;
} }

View File

@ -1,5 +1,7 @@
import React from 'react'; import React from 'react';
import { mount, render } from 'enzyme'; import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import Breadcrumb from '../index'; import Breadcrumb from '../index';
import mountTest from '../../../tests/shared/mountTest'; import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest'; import rtlTest from '../../../tests/shared/rtlTest';
@ -23,7 +25,7 @@ describe('Breadcrumb', () => {
// https://github.com/airbnb/enzyme/issues/875 // https://github.com/airbnb/enzyme/issues/875
it('warns on non-Breadcrumb.Item and non-Breadcrumb.Separator children', () => { it('warns on non-Breadcrumb.Item and non-Breadcrumb.Separator children', () => {
const MyCom = () => <div>foo</div>; const MyCom = () => <div>foo</div>;
mount( render(
<Breadcrumb> <Breadcrumb>
<MyCom /> <MyCom />
</Breadcrumb>, </Breadcrumb>,
@ -36,7 +38,7 @@ describe('Breadcrumb', () => {
// https://github.com/ant-design/ant-design/issues/5015 // https://github.com/ant-design/ant-design/issues/5015
it('should allow Breadcrumb.Item is null or undefined', () => { it('should allow Breadcrumb.Item is null or undefined', () => {
const wrapper = render( const { asFragment } = render(
<Breadcrumb> <Breadcrumb>
{null} {null}
<Breadcrumb.Item>Home</Breadcrumb.Item> <Breadcrumb.Item>Home</Breadcrumb.Item>
@ -44,24 +46,24 @@ describe('Breadcrumb', () => {
</Breadcrumb>, </Breadcrumb>,
); );
expect(errorSpy).not.toHaveBeenCalled(); expect(errorSpy).not.toHaveBeenCalled();
expect(wrapper).toMatchSnapshot(); expect(asFragment().firstChild).toMatchSnapshot();
}); });
// https://github.com/ant-design/ant-design/issues/5542 // https://github.com/ant-design/ant-design/issues/5542
it('should not display Breadcrumb Item when its children is falsy', () => { it('should not display Breadcrumb Item when its children is falsy', () => {
const wrapper = render( const wrapper = mount(
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item /> <Breadcrumb.Item />
<Breadcrumb.Item>xxx</Breadcrumb.Item> <Breadcrumb.Item>xxx</Breadcrumb.Item>
<Breadcrumb.Item>yyy</Breadcrumb.Item> <Breadcrumb.Item>yyy</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>,
); );
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
// https://github.com/ant-design/ant-design/issues/18260 // https://github.com/ant-design/ant-design/issues/18260
it('filter React.Fragment', () => { it('filter React.Fragment', () => {
const wrapper = render( const wrapper = mount(
<Breadcrumb separator=""> <Breadcrumb separator="">
<Breadcrumb.Item>Location</Breadcrumb.Item> <Breadcrumb.Item>Location</Breadcrumb.Item>
<Breadcrumb.Separator>:</Breadcrumb.Separator> <Breadcrumb.Separator>:</Breadcrumb.Separator>
@ -71,7 +73,7 @@ describe('Breadcrumb', () => {
</> </>
</Breadcrumb>, </Breadcrumb>,
); );
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
it('should render a menu', () => { it('should render a menu', () => {
@ -106,27 +108,27 @@ describe('Breadcrumb', () => {
path: 'third', path: 'third',
}, },
]; ];
const wrapper = render(<Breadcrumb routes={routes} />); const wrapper = mount(<Breadcrumb routes={routes} />);
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
it('should accept undefined routes', () => { it('should accept undefined routes', () => {
const wrapper = render(<Breadcrumb routes={undefined} />); const wrapper = mount(<Breadcrumb routes={undefined} />);
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
it('should support custom attribute', () => { it('should support custom attribute', () => {
const wrapper = render( const wrapper = mount(
<Breadcrumb data-custom="custom"> <Breadcrumb data-custom="custom">
<Breadcrumb.Item data-custom="custom-item">xxx</Breadcrumb.Item> <Breadcrumb.Item data-custom="custom-item">xxx</Breadcrumb.Item>
<Breadcrumb.Item>yyy</Breadcrumb.Item> <Breadcrumb.Item>yyy</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>,
); );
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
it('should support React.Fragment and falsy children', () => { it('should support React.Fragment and falsy children', () => {
const wrapper = render( const wrapper = mount(
<Breadcrumb> <Breadcrumb>
<> <>
<Breadcrumb.Item>yyy</Breadcrumb.Item> <Breadcrumb.Item>yyy</Breadcrumb.Item>
@ -138,7 +140,7 @@ describe('Breadcrumb', () => {
{undefined} {undefined}
</Breadcrumb>, </Breadcrumb>,
); );
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
// https://github.com/ant-design/ant-design/issues/25975 // https://github.com/ant-design/ant-design/issues/25975
@ -148,13 +150,13 @@ describe('Breadcrumb', () => {
<Breadcrumb.Item>Mock Node</Breadcrumb.Item> <Breadcrumb.Item>Mock Node</Breadcrumb.Item>
</span> </span>
); );
const wrapper = render( const wrapper = mount(
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item>Location</Breadcrumb.Item> <Breadcrumb.Item>Location</Breadcrumb.Item>
<MockComponent /> <MockComponent />
<Breadcrumb.Item>Application Center</Breadcrumb.Item> <Breadcrumb.Item>Application Center</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>,
); );
expect(wrapper).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
}); });

View File

@ -16,7 +16,7 @@ The simplest use.
```jsx ```jsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
ReactDOM.render( export default () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item>Home</Breadcrumb.Item> <Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item> <Breadcrumb.Item>
@ -26,7 +26,6 @@ ReactDOM.render(
<a href="">Application List</a> <a href="">Application List</a>
</Breadcrumb.Item> </Breadcrumb.Item>
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>
mountNode,
); );
``` ```

View File

@ -44,7 +44,7 @@ const menu = (
/> />
); );
ReactDOM.render( export default () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item>Ant Design</Breadcrumb.Item> <Breadcrumb.Item>Ant Design</Breadcrumb.Item>
<Breadcrumb.Item> <Breadcrumb.Item>
@ -54,7 +54,6 @@ ReactDOM.render(
<a href="">General</a> <a href="">General</a>
</Breadcrumb.Item> </Breadcrumb.Item>
<Breadcrumb.Item>Button</Breadcrumb.Item> <Breadcrumb.Item>Button</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>
mountNode,
); );
``` ```

View File

@ -69,11 +69,10 @@ const Home = props => {
); );
}; };
ReactDOM.render( export default () => (
<HashRouter> <HashRouter>
<Home /> <Home />
</HashRouter>, </HashRouter>
mountNode,
); );
``` ```

View File

@ -16,7 +16,7 @@ The separator can be customized by setting the separator property: `Breadcrumb.S
```jsx ```jsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
ReactDOM.render( export default () => (
<Breadcrumb separator=""> <Breadcrumb separator="">
<Breadcrumb.Item>Location</Breadcrumb.Item> <Breadcrumb.Item>Location</Breadcrumb.Item>
<Breadcrumb.Separator>:</Breadcrumb.Separator> <Breadcrumb.Separator>:</Breadcrumb.Separator>
@ -25,7 +25,6 @@ ReactDOM.render(
<Breadcrumb.Item href="">Application List</Breadcrumb.Item> <Breadcrumb.Item href="">Application List</Breadcrumb.Item>
<Breadcrumb.Separator /> <Breadcrumb.Separator />
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>
mountNode,
); );
``` ```

View File

@ -16,13 +16,12 @@ The separator can be customized by setting the separator property: `separator=">
```jsx ```jsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
ReactDOM.render( export default () => (
<Breadcrumb separator=">"> <Breadcrumb separator=">">
<Breadcrumb.Item>Home</Breadcrumb.Item> <Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item href="">Application Center</Breadcrumb.Item> <Breadcrumb.Item href="">Application Center</Breadcrumb.Item>
<Breadcrumb.Item href="">Application List</Breadcrumb.Item> <Breadcrumb.Item href="">Application List</Breadcrumb.Item>
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>
mountNode,
); );
``` ```

View File

@ -17,7 +17,7 @@ The icon should be placed in front of the text.
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
import { HomeOutlined, UserOutlined } from '@ant-design/icons'; import { HomeOutlined, UserOutlined } from '@ant-design/icons';
ReactDOM.render( export default () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item href=""> <Breadcrumb.Item href="">
<HomeOutlined /> <HomeOutlined />
@ -27,7 +27,6 @@ ReactDOM.render(
<span>Application List</span> <span>Application List</span>
</Breadcrumb.Item> </Breadcrumb.Item>
<Breadcrumb.Item>Application</Breadcrumb.Item> <Breadcrumb.Item>Application</Breadcrumb.Item>
</Breadcrumb>, </Breadcrumb>
mountNode,
); );
``` ```

View File

@ -1,5 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { mount, render } from 'enzyme'; import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { SearchOutlined } from '@ant-design/icons'; import { SearchOutlined } from '@ant-design/icons';
import { resetWarned } from 'rc-util/lib/warning'; import { resetWarned } from 'rc-util/lib/warning';
@ -39,7 +41,7 @@ describe('Button', () => {
const mockWarn = jest.fn(); const mockWarn = jest.fn();
jest.spyOn(console, 'warn').mockImplementation(mockWarn); jest.spyOn(console, 'warn').mockImplementation(mockWarn);
const size = 'who am I' as any as SizeType; const size = 'who am I' as any as SizeType;
render(<Button.Group size={size} />); mount(<Button.Group size={size} />);
expect(mockWarn).toHaveBeenCalledTimes(1); expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0][0]).toMatchObject({ expect(mockWarn.mock.calls[0][0]).toMatchObject({
message: 'unreachable case: "who am I"', message: 'unreachable case: "who am I"',
@ -51,12 +53,14 @@ describe('Button', () => {
// should not insert space when there is icon // should not insert space when there is icon
expect(mount(<Button icon={<SearchOutlined />}></Button>).render()).toMatchSnapshot(); expect(mount(<Button icon={<SearchOutlined />}></Button>).render()).toMatchSnapshot();
// should not insert space when there is icon // should not insert space when there is icon
expect(mount( expect(
<Button> mount(
<SearchOutlined /> <Button>
<SearchOutlined />
</Button>,
).render()).toMatchSnapshot(); </Button>,
).render(),
).toMatchSnapshot();
// should not insert space when there is icon // should not insert space when there is icon
expect(mount(<Button icon={<SearchOutlined />}></Button>).render()).toMatchSnapshot(); expect(mount(<Button icon={<SearchOutlined />}></Button>).render()).toMatchSnapshot();
// should not insert space when there is icon while loading // should not insert space when there is icon while loading
@ -261,12 +265,15 @@ describe('Button', () => {
it('should warning when pass a string as icon props', () => { it('should warning when pass a string as icon props', () => {
resetWarned(); resetWarned();
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(<Button type="primary" icon="ab" />);
render(<Button type="primary" icon="ab" />);
expect(warnSpy).not.toHaveBeenCalled(); expect(warnSpy).not.toHaveBeenCalled();
mount(<Button type="primary" icon="search" />);
render(<Button type="primary" icon="search" />);
expect(warnSpy).toHaveBeenCalledWith( expect(warnSpy).toHaveBeenCalledWith(
`Warning: [antd: Button] \`icon\` is using ReactNode instead of string naming in v4. Please check \`search\` at https://ant.design/components/icon`, `Warning: [antd: Button] \`icon\` is using ReactNode instead of string naming in v4. Please check \`search\` at https://ant.design/components/icon`,
); );
warnSpy.mockRestore(); warnSpy.mockRestore();
}); });

View File

@ -9,6 +9,7 @@ export interface ButtonGroupProps {
style?: React.CSSProperties; style?: React.CSSProperties;
className?: string; className?: string;
prefixCls?: string; prefixCls?: string;
children?: React.ReactNode;
} }
const ButtonGroup: React.FC<ButtonGroupProps> = props => ( const ButtonGroup: React.FC<ButtonGroupProps> = props => (

View File

@ -16,7 +16,7 @@ There are `primary` button, `default` button, `dashed` button, `text` button and
```jsx ```jsx
import { Button } from 'antd'; import { Button } from 'antd';
ReactDOM.render( export default () => (
<> <>
<Button type="primary">Primary Button</Button> <Button type="primary">Primary Button</Button>
<Button>Default Button</Button> <Button>Default Button</Button>
@ -24,7 +24,6 @@ ReactDOM.render(
<br /> <br />
<Button type="text">Text Button</Button> <Button type="text">Text Button</Button>
<Button type="link">Link Button</Button> <Button type="link">Link Button</Button>
</>, </>
mountNode,
); );
``` ```

Some files were not shown because too many files have changed in this diff Show More