chore: merge master

This commit is contained in:
zombiej 2022-05-21 22:14:15 +08:00
commit cd0ace3d40
705 changed files with 9007 additions and 8478 deletions

View File

@ -20,6 +20,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Automatic Rebase - name: Automatic Rebase
uses: cirrus-actions/rebase@1.6 uses: cirrus-actions/rebase@1.7
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -17,7 +17,7 @@ timeline: true
## 4.20.5 ## 4.20.5
`2022-05-15 `2022-05-15`
- 🤖 在 TypeScript 定义中废弃 Table `rowSelection.onSelectNone``rowSelection.onSelectMultiple`。[#35545](https://github.com/ant-design/ant-design/pull/35545) - 🤖 在 TypeScript 定义中废弃 Table `rowSelection.onSelectNone``rowSelection.onSelectMultiple`。[#35545](https://github.com/ant-design/ant-design/pull/35545)
- 🐞 InputNumber 当精度为负数时忽略小数部分。[#35520](https://github.com/ant-design/ant-design/pull/35520) [@ty888](https://github.com/ty888)` - 🐞 InputNumber 当精度为负数时忽略小数部分。[#35520](https://github.com/ant-design/ant-design/pull/35520) [@ty888](https://github.com/ty888)`

View File

@ -14,10 +14,10 @@ title:
The simplest usage. The simplest usage.
```tsx ```tsx
import React, { useState } from 'react';
import { Affix, Button } from 'antd'; import { Affix, Button } from 'antd';
import React, { useState } from 'react';
const Demo: React.FC = () => { const App: React.FC = () => {
const [top, setTop] = useState(10); const [top, setTop] = useState(10);
const [bottom, setBottom] = useState(10); const [bottom, setBottom] = useState(10);
@ -38,5 +38,5 @@ const Demo: React.FC = () => {
); );
}; };
export default Demo; export default App;
``` ```

View File

@ -15,11 +15,12 @@ DEBUG
DEBUG DEBUG
```tsx ```tsx
import React, { useState } from 'react';
import { Affix, Button } from 'antd'; import { Affix, Button } from 'antd';
import React, { useState } from 'react';
const Demo: React.FC = () => { const App: React.FC = () => {
const [top, setTop] = useState(10); const [top, setTop] = useState(10);
return ( return (
<div style={{ height: 10000 }}> <div style={{ height: 10000 }}>
<div>Top</div> <div>Top</div>
@ -35,5 +36,5 @@ const Demo: React.FC = () => {
); );
}; };
export default Demo; export default App;
``` ```

View File

@ -15,10 +15,13 @@ Callback with affixed state.
```tsx ```tsx
import { Affix, Button } from 'antd'; import { Affix, Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<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>
); );
export default App;
``` ```

View File

@ -14,11 +14,12 @@ title:
Set a `target` for 'Affix', which is listen to scroll event of target element (default is `window`). Set a `target` for 'Affix', which is listen to scroll event of target element (default is `window`).
```tsx ```tsx
import React, { useState } from 'react';
import { Affix, Button } from 'antd'; import { Affix, Button } from 'antd';
import React, { useState } from 'react';
const Demo: React.FC = () => { const App: React.FC = () => {
const [container, setContainer] = useState<HTMLDivElement | null>(null); const [container, setContainer] = useState<HTMLDivElement | null>(null);
return ( return (
<div className="scrollable-container" ref={setContainer}> <div className="scrollable-container" ref={setContainer}>
<div className="background"> <div className="background">
@ -30,7 +31,7 @@ const Demo: React.FC = () => {
); );
}; };
export default Demo; export default App;
``` ```
<style> <style>

View File

@ -14,10 +14,10 @@ title:
Custom action. Custom action.
```tsx ```tsx
import React from 'react';
import { Alert, Button, Space } from 'antd'; import { Alert, Button, Space } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Alert <Alert
message="Success Tips" message="Success Tips"
@ -71,6 +71,8 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -16,8 +16,9 @@ Display Alert as a banner at top of page.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Alert message="Warning text" banner /> <Alert message="Warning text" banner />
<br /> <br />
@ -32,4 +33,6 @@ export default () => (
<Alert type="error" message="Error text" banner /> <Alert type="error" message="Error text" banner />
</> </>
); );
export default App;
``` ```

View File

@ -15,8 +15,11 @@ The simplest usage for short messages.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => <Alert message="Success Text" type="success" />; const App: React.FC = () => <Alert message="Success Text" type="success" />;
export default App;
``` ```
<style> <style>

View File

@ -15,12 +15,13 @@ To show close button.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
const onClose = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { const onClose = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
console.log(e, 'I was closed.'); console.log(e, 'I was closed.');
}; };
export default () => ( const App: React.FC = () => (
<> <>
<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"
@ -37,4 +38,6 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```

View File

@ -15,6 +15,9 @@ Replace the default icon with customized text.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => <Alert message="Info Text" type="info" closeText="Close Now" />; const App: React.FC = () => <Alert message="Info Text" type="info" closeText="Close Now" />;
export default App;
``` ```

View File

@ -15,12 +15,13 @@ title:
A relevant icon makes information clearer and more friendly. A relevant icon makes information clearer and more friendly.
```tsx ```tsx
import { Alert } from 'antd';
import { SmileOutlined } from '@ant-design/icons'; import { SmileOutlined } from '@ant-design/icons';
import { Alert } from 'antd';
import React from 'react';
const icon = <SmileOutlined />; const icon = <SmileOutlined />;
export default () => ( const App: React.FC = () => (
<> <>
<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 />
@ -57,4 +58,6 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```

View File

@ -15,8 +15,9 @@ Additional description for alert message.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Alert <Alert
message="Success Text" message="Success Text"
@ -40,4 +41,6 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```

View File

@ -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). ErrorBoundary Component for making error handling easier in [React](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html).
```tsx ```tsx
import { Alert, Button } from 'antd';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Button, Alert } from 'antd';
const { ErrorBoundary } = Alert; const { ErrorBoundary } = Alert;
const ThrowError: React.FC = () => { const ThrowError: React.FC = () => {
@ -34,9 +34,11 @@ const ThrowError: React.FC = () => {
); );
}; };
export default () => ( const App: React.FC = () => (
<ErrorBoundary> <ErrorBoundary>
<ThrowError /> <ThrowError />
</ErrorBoundary> </ErrorBoundary>
); );
export default App;
``` ```

View File

@ -15,8 +15,9 @@ A relevant icon will make information clearer and more friendly.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<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 />
@ -49,4 +50,6 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```

View File

@ -15,10 +15,11 @@ Show a loop banner by using with [react-text-loop-next](https://npmjs.com/packag
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import { TextLoop } from 'react-text-loop-next'; import React from 'react';
import Marquee from 'react-fast-marquee'; import Marquee from 'react-fast-marquee';
import { TextLoop } from 'react-text-loop-next';
export default () => ( const App: React.FC = () => (
<> <>
<Alert <Alert
banner banner
@ -41,4 +42,6 @@ export default () => (
/> />
</> </>
); );
export default App;
``` ```

View File

@ -14,14 +14,16 @@ title:
Smoothly unmount Alert upon close. Smoothly unmount Alert upon close.
```tsx ```tsx
import React, { useState } from 'react';
import { Alert } from 'antd'; import { Alert } from 'antd';
import React, { useState } from 'react';
const App: React.FC = () => { const App: React.FC = () => {
const [visible, setVisible] = useState(true); const [visible, setVisible] = useState(true);
const handleClose = () => { const handleClose = () => {
setVisible(false); setVisible(false);
}; };
return ( return (
<div> <div>
{visible ? ( {visible ? (

View File

@ -15,8 +15,9 @@ There are 4 types of Alert: `success`, `info`, `warning`, `error`.
```tsx ```tsx
import { Alert } from 'antd'; import { Alert } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Alert message="Success Text" type="success" /> <Alert message="Success Text" type="success" />
<Alert message="Info Text" type="info" /> <Alert message="Info Text" type="info" />
@ -24,6 +25,8 @@ export default () => (
<Alert message="Error Text" type="error" /> <Alert message="Error Text" type="error" />
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -15,10 +15,11 @@ The simplest usage.
```tsx ```tsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React from 'react';
const { Link } = Anchor; const { Link } = Anchor;
export default () => ( const App: React.FC = () => (
<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" />
@ -28,6 +29,8 @@ export default () => (
</Link> </Link>
</Anchor> </Anchor>
); );
export default App;
``` ```
<style> <style>

View File

@ -15,12 +15,13 @@ Customize the anchor highlight.
```tsx ```tsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React from 'react';
const { Link } = Anchor; const { Link } = Anchor;
const getCurrentAnchor = () => '#components-anchor-demo-static'; const getCurrentAnchor = () => '#components-anchor-demo-static';
export default () => ( const App: React.FC = () => (
<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" />
@ -30,4 +31,6 @@ export default () => (
</Link> </Link>
</Anchor> </Anchor>
); );
export default App;
``` ```

View File

@ -15,6 +15,7 @@ Listening for anchor link change.
```tsx ```tsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React from 'react';
const { Link } = Anchor; const { Link } = Anchor;
@ -22,7 +23,7 @@ const onChange = (link: string) => {
console.log('Anchor:OnChange', link); console.log('Anchor:OnChange', link);
}; };
export default () => ( const App: React.FC = () => (
<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" />
@ -32,4 +33,6 @@ export default () => (
</Link> </Link>
</Anchor> </Anchor>
); );
export default App;
``` ```

View File

@ -15,6 +15,7 @@ Clicking on an anchor does not record history.
```tsx ```tsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React from 'react';
const { Link } = Anchor; const { Link } = Anchor;
@ -29,7 +30,7 @@ const handleClick = (
console.log(link); console.log(link);
}; };
export default () => ( const App: React.FC = () => (
<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" />
@ -39,4 +40,6 @@ export default () => (
</Link> </Link>
</Anchor> </Anchor>
); );
export default App;
``` ```

View File

@ -15,10 +15,11 @@ Do not change state when page is scrolling.
```tsx ```tsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React from 'react';
const { Link } = Anchor; const { Link } = Anchor;
export default () => ( const App: React.FC = () => (
<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" />
@ -28,4 +29,6 @@ export default () => (
</Link> </Link>
</Anchor> </Anchor>
); );
export default App;
``` ```

View File

@ -14,16 +14,18 @@ title:
Anchor target scroll to screen center. Anchor target scroll to screen center.
```tsx ```tsx
import React, { useState, useEffect } from 'react';
import { Anchor } from 'antd'; import { Anchor } from 'antd';
import React, { useEffect, useState } from 'react';
const { Link } = Anchor; const { Link } = Anchor;
const AnchorExample: React.FC = () => { const App: React.FC = () => {
const [targetOffset, setTargetOffset] = useState<number | undefined>(undefined); const [targetOffset, setTargetOffset] = useState<number | undefined>(undefined);
useEffect(() => { useEffect(() => {
setTargetOffset(window.innerHeight / 2); setTargetOffset(window.innerHeight / 2);
}, []); }, []);
return ( return (
<Anchor targetOffset={targetOffset}> <Anchor targetOffset={targetOffset}>
<Link href="#components-anchor-demo-basic" title="Basic demo" /> <Link href="#components-anchor-demo-basic" title="Basic demo" />
@ -36,5 +38,5 @@ const AnchorExample: React.FC = () => {
); );
}; };
export default () => <AnchorExample />; export default App;
``` ```

View File

@ -56,12 +56,11 @@
// &-link { // &-link {
// padding: @anchor-link-padding; // padding: @anchor-link-padding;
// line-height: 1.143;
// &-title { // &-title {
// position: relative; // position: relative;
// display: block; // display: block;
// margin-bottom: 6px; // margin-bottom: 3px;
// overflow: hidden; // overflow: hidden;
// color: @text-color; // color: @text-color;
// white-space: nowrap; // white-space: nowrap;
@ -79,8 +78,8 @@
// } // }
// &-link &-link { // &-link &-link {
// padding-top: 5px; // padding-top: 2px;
// padding-bottom: 5px; // padding-bottom: 2px;
// } // }
// } // }

View File

@ -522,11 +522,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
> >
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -537,7 +535,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -592,11 +589,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -607,7 +602,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -735,11 +729,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -750,7 +742,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -924,11 +915,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -939,7 +928,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -1021,11 +1009,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -1036,7 +1022,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -1237,11 +1222,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -1252,7 +1235,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -1462,11 +1444,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -1477,7 +1457,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md extend context co
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"

View File

@ -174,11 +174,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
> >
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -189,7 +187,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -230,11 +227,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -245,7 +240,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -314,11 +308,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -329,7 +321,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -430,11 +421,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -445,7 +434,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -513,11 +501,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -528,7 +514,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -656,11 +641,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -671,7 +654,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"
@ -808,11 +790,9 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-row ant-form-item" class="ant-row ant-form-item"
role="row"
> >
<div <div
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8" class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
role="cell"
> >
<label <label
class="" class=""
@ -823,7 +803,6 @@ exports[`renders ./components/auto-complete/demo/form-debug.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16" class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
role="cell"
> >
<div <div
class="ant-form-item-control-input" class="ant-form-item-control-input"

View File

@ -14,26 +14,31 @@ title:
Basic Usage, set data source of autocomplete with `options` property. Basic Usage, set data source of autocomplete with `options` property.
```tsx ```tsx
import React, { useState } from 'react';
import { AutoComplete } from 'antd'; import { AutoComplete } from 'antd';
import React, { useState } from 'react';
const mockVal = (str: string, repeat: number = 1) => ({ const mockVal = (str: string, repeat = 1) => ({
value: str.repeat(repeat), value: str.repeat(repeat),
}); });
const Complete: React.FC = () => {
const App: React.FC = () => {
const [value, setValue] = useState(''); const [value, setValue] = useState('');
const [options, setOptions] = useState<{ value: string }[]>([]); const [options, setOptions] = useState<{ value: string }[]>([]);
const onSearch = (searchText: string) => { const onSearch = (searchText: string) => {
setOptions( setOptions(
!searchText ? [] : [mockVal(searchText), mockVal(searchText, 2), mockVal(searchText, 3)], !searchText ? [] : [mockVal(searchText), mockVal(searchText, 2), mockVal(searchText, 3)],
); );
}; };
const onSelect = (data: string) => { const onSelect = (data: string) => {
console.log('onSelect', data); console.log('onSelect', data);
}; };
const onChange = (data: string) => { const onChange = (data: string) => {
setValue(data); setValue(data);
}; };
return ( return (
<> <>
<AutoComplete <AutoComplete
@ -58,5 +63,5 @@ const Complete: React.FC = () => {
); );
}; };
export default () => <Complete />; export default App;
``` ```

View File

@ -14,8 +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. Demonstration of [Lookup Patterns: Certain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns). Basic Usage, set options of autocomplete with `options` property.
```tsx ```tsx
import { Input, AutoComplete } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { AutoComplete, Input } from 'antd';
import React from 'react';
const renderTitle = (title: string) => ( const renderTitle = (title: string) => (
<span> <span>
@ -63,7 +64,7 @@ const options = [
}, },
]; ];
const Complete: React.FC = () => ( const App: React.FC = () => (
<AutoComplete <AutoComplete
dropdownClassName="certain-category-search-dropdown" dropdownClassName="certain-category-search-dropdown"
dropdownMatchSelectWidth={500} dropdownMatchSelectWidth={500}
@ -74,7 +75,7 @@ const Complete: React.FC = () => (
</AutoComplete> </AutoComplete>
); );
export default () => <Complete />; export default App;
``` ```
```css ```css

View File

@ -14,13 +14,14 @@ title:
Customize Input Component Customize Input Component
```tsx ```tsx
import React, { useState } from 'react';
import { AutoComplete, Input } from 'antd'; import { AutoComplete, Input } from 'antd';
import React, { useState } from 'react';
const { TextArea } = Input; const { TextArea } = Input;
const Complete: React.FC = () => { const App: React.FC = () => {
const [options, setOptions] = useState<{ value: string }[]>([]); const [options, setOptions] = useState<{ value: string }[]>([]);
const handleSearch = (value: string) => { const handleSearch = (value: string) => {
setOptions( setOptions(
!value ? [] : [{ value }, { value: value + value }, { value: value + value + value }], !value ? [] : [{ value }, { value: value + value }, { value: value + value + value }],
@ -52,5 +53,5 @@ const Complete: React.FC = () => {
); );
}; };
export default () => <Complete />; export default App;
``` ```

View File

@ -7,8 +7,9 @@ debug: true
--- ---
```tsx ```tsx
import { Input, AutoComplete, Form, TreeSelect, Button } from 'antd';
import { SearchOutlined } from '@ant-design/icons'; import { SearchOutlined } from '@ant-design/icons';
import { AutoComplete, Button, Form, Input, TreeSelect } from 'antd';
import React from 'react';
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
@ -21,7 +22,7 @@ const formItemLayout = {
}, },
}; };
export default () => ( const App: React.FC = () => (
<Form style={{ margin: '0 auto' }} {...formItemLayout}> <Form style={{ margin: '0 auto' }} {...formItemLayout}>
<Form.Item label="单独 AutoComplete"> <Form.Item label="单独 AutoComplete">
<AutoComplete /> <AutoComplete />
@ -69,4 +70,6 @@ export default () => (
</Form.Item> </Form.Item>
</Form> </Form>
); );
export default App;
``` ```

View File

@ -15,6 +15,7 @@ A non-case-sensitive AutoComplete
```tsx ```tsx
import { AutoComplete } from 'antd'; import { AutoComplete } from 'antd';
import React from 'react';
const options = [ const options = [
{ value: 'Burns Bay Road' }, { value: 'Burns Bay Road' },
@ -22,7 +23,7 @@ const options = [
{ value: 'Wall Street' }, { value: 'Wall Street' },
]; ];
const Complete: React.FC = () => ( const App: React.FC = () => (
<AutoComplete <AutoComplete
style={{ width: 200 }} style={{ width: 200 }}
options={options} options={options}
@ -33,5 +34,5 @@ const Complete: React.FC = () => (
/> />
); );
export default () => <Complete />; export default App;
``` ```

View File

@ -14,13 +14,14 @@ title:
You could pass `AutoComplete.Option` as children of `AutoComplete`, instead of using `options` You could pass `AutoComplete.Option` as children of `AutoComplete`, instead of using `options`
```tsx ```tsx
import React, { useState } from 'react';
import { AutoComplete } from 'antd'; import { AutoComplete } from 'antd';
import React, { useState } from 'react';
const { Option } = AutoComplete; const { Option } = AutoComplete;
const Complete: React.FC = () => { const App: React.FC = () => {
const [result, setResult] = useState<string[]>([]); const [result, setResult] = useState<string[]>([]);
const handleSearch = (value: string) => { const handleSearch = (value: string) => {
let res: string[] = []; let res: string[] = [];
if (!value || value.indexOf('@') >= 0) { if (!value || value.indexOf('@') >= 0) {
@ -30,6 +31,7 @@ const Complete: React.FC = () => {
} }
setResult(res); setResult(res);
}; };
return ( return (
<AutoComplete style={{ width: 200 }} onSearch={handleSearch} placeholder="input here"> <AutoComplete style={{ width: 200 }} onSearch={handleSearch} placeholder="input here">
{result.map((email: string) => ( {result.map((email: string) => (
@ -41,5 +43,5 @@ const Complete: React.FC = () => {
); );
}; };
export default () => <Complete />; export default App;
``` ```

View File

@ -15,13 +15,14 @@ title:
Add status to AutoComplete with `status`, which could be `error` or `warning`. Add status to AutoComplete with `status`, which could be `error` or `warning`.
```tsx ```tsx
import React, { useState } from 'react';
import { AutoComplete, Space } from 'antd'; import { AutoComplete, Space } from 'antd';
import React, { useState } from 'react';
const mockVal = (str: string, repeat: number = 1) => ({ const mockVal = (str: string, repeat = 1) => ({
value: str.repeat(repeat), value: str.repeat(repeat),
}); });
const ValidateInputs: React.FC = () => {
const App: React.FC = () => {
const [options, setOptions] = useState<{ value: string }[]>([]); const [options, setOptions] = useState<{ value: string }[]>([]);
const onSearch = (searchText: string) => { const onSearch = (searchText: string) => {
@ -38,5 +39,5 @@ const ValidateInputs: React.FC = () => {
); );
}; };
export default () => <ValidateInputs />; export default App;
``` ```

View File

@ -14,13 +14,11 @@ title:
Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns). Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns).
```tsx ```tsx
import React, { useState } from 'react'; import { AutoComplete, Input } from 'antd';
import { Input, AutoComplete } from 'antd';
import type { SelectProps } from 'antd/es/select'; import type { SelectProps } from 'antd/es/select';
import React, { useState } from 'react';
function getRandomInt(max: number, min: number = 0) { const getRandomInt = (max: number, min = 0) => Math.floor(Math.random() * (max - min + 1)) + min;
return Math.floor(Math.random() * (max - min + 1)) + min; // eslint-disable-line no-mixed-operators
}
const searchResult = (query: string) => const searchResult = (query: string) =>
new Array(getRandomInt(5)) new Array(getRandomInt(5))
@ -53,7 +51,7 @@ const searchResult = (query: string) =>
}; };
}); });
const Complete: React.FC = () => { const App: React.FC = () => {
const [options, setOptions] = useState<SelectProps<object>['options']>([]); const [options, setOptions] = useState<SelectProps<object>['options']>([]);
const handleSearch = (value: string) => { const handleSearch = (value: string) => {
@ -77,5 +75,5 @@ const Complete: React.FC = () => {
); );
}; };
export default () => <Complete />; export default App;
``` ```

View File

@ -14,10 +14,11 @@ title:
Usually used for reminders and notifications. Usually used for reminders and notifications.
```tsx ```tsx
import { Avatar, Badge } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<span className="avatar-item"> <span className="avatar-item">
<Badge count={1}> <Badge count={1}>
@ -31,6 +32,8 @@ export default () => (
</span> </span>
</> </>
); );
export default App;
``` ```
```css ```css

View File

@ -14,10 +14,11 @@ title:
Three sizes and two shapes are available. Three sizes and two shapes are available.
```tsx ```tsx
import { Avatar } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { Avatar } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<div> <div>
<Avatar size={64} icon={<UserOutlined />} /> <Avatar size={64} icon={<UserOutlined />} />
@ -33,6 +34,8 @@ export default () => (
</div> </div>
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -14,26 +14,29 @@ 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. 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 ```tsx
import React, { useState } from 'react';
import { Avatar, Button } from 'antd'; import { Avatar, Button } from 'antd';
import React, { useState } from 'react';
const UserList = ['U', 'Lucy', 'Tom', 'Edward']; const UserList = ['U', 'Lucy', 'Tom', 'Edward'];
const ColorList = ['#f56a00', '#7265e6', '#ffbf00', '#00a2ae']; const ColorList = ['#f56a00', '#7265e6', '#ffbf00', '#00a2ae'];
const GapList = [4, 3, 2, 1]; const GapList = [4, 3, 2, 1];
const Autoset: React.FC = () => { const App: React.FC = () => {
const [user, setUser] = useState(UserList[0]); const [user, setUser] = useState(UserList[0]);
const [color, setColor] = useState(ColorList[0]); const [color, setColor] = useState(ColorList[0]);
const [gap, setGap] = useState(GapList[0]); const [gap, setGap] = useState(GapList[0]);
const changeUser = () => { const changeUser = () => {
const index = UserList.indexOf(user); const index = UserList.indexOf(user);
setUser(index < UserList.length - 1 ? UserList[index + 1] : UserList[0]); setUser(index < UserList.length - 1 ? UserList[index + 1] : UserList[0]);
setColor(index < ColorList.length - 1 ? ColorList[index + 1] : ColorList[0]); setColor(index < ColorList.length - 1 ? ColorList[index + 1] : ColorList[0]);
}; };
const changeGap = () => { const changeGap = () => {
const index = GapList.indexOf(gap); const index = GapList.indexOf(gap);
setGap(index < GapList.length - 1 ? GapList[index + 1] : GapList[0]); setGap(index < GapList.length - 1 ? GapList[index + 1] : GapList[0]);
}; };
return ( return (
<> <>
<Avatar style={{ backgroundColor: color, verticalAlign: 'middle' }} size="large" gap={gap}> <Avatar style={{ backgroundColor: color, verticalAlign: 'middle' }} size="large" gap={gap}>
@ -53,5 +56,5 @@ const Autoset: React.FC = () => {
); );
}; };
export default () => <Autoset />; export default App;
``` ```

View File

@ -16,8 +16,9 @@ debug: true
```tsx ```tsx
import { Avatar } from 'antd'; import { Avatar } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Avatar shape="circle" src="http://abc.com/not-exist.jpg"> <Avatar shape="circle" src="http://abc.com/not-exist.jpg">
A A
@ -27,4 +28,6 @@ export default () => (
</Avatar> </Avatar>
</> </>
); );
export default App;
``` ```

View File

@ -14,10 +14,11 @@ title:
Avatar group display. Avatar group display.
```tsx ```tsx
import { AntDesignOutlined, UserOutlined } from '@ant-design/icons';
import { Avatar, Divider, Tooltip } from 'antd'; import { Avatar, Divider, Tooltip } from 'antd';
import { UserOutlined, AntDesignOutlined } from '@ant-design/icons'; import React from 'react';
const Demo = () => ( const App: React.FC = () => (
<> <>
<Avatar.Group> <Avatar.Group>
<Avatar src="https://joeschmoe.io/api/v1/random" /> <Avatar src="https://joeschmoe.io/api/v1/random" />
@ -66,5 +67,5 @@ const Demo = () => (
</> </>
); );
export default Demo; export default App;
``` ```

View File

@ -14,13 +14,16 @@ title:
Avatar size can be automatically adjusted based on the screen size. Avatar size can be automatically adjusted based on the screen size.
```tsx ```tsx
import { Avatar } from 'antd';
import { AntDesignOutlined } from '@ant-design/icons'; import { AntDesignOutlined } from '@ant-design/icons';
import { Avatar } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<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 />}
/> />
); );
export default App;
``` ```

View File

@ -15,14 +15,16 @@ debug: true
Text inside Avatar should be set a proper font size when toggle it's visibility. Text inside Avatar should be set a proper font size when toggle it's visibility.
```tsx ```tsx
import React, { useState } from 'react';
import { Avatar, Button } from 'antd'; import { Avatar, Button } from 'antd';
import React, { useState } from 'react';
type SizeType = 'large' | 'small' | 'default' | number; type SizeType = 'large' | 'small' | 'default' | number;
const App: React.FC = () => { const App: React.FC = () => {
const [hide, setHide] = useState(true); const [hide, setHide] = useState(true);
const [size, setSize] = useState<SizeType>('large'); const [size, setSize] = useState<SizeType>('large');
const [scale, setScale] = useState(1); const [scale, setScale] = useState(1);
const toggle = () => { const toggle = () => {
setHide(!hide); setHide(!hide);
}; };

View File

@ -14,10 +14,11 @@ title:
Image, Icon and letter are supported, and the latter two kinds of avatar can have custom colors and background colors. Image, Icon and letter are supported, and the latter two kinds of avatar can have custom colors and background colors.
```tsx ```tsx
import { Avatar, Image } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { Avatar, Image } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Avatar icon={<UserOutlined />} /> <Avatar icon={<UserOutlined />} />
<Avatar>U</Avatar> <Avatar>U</Avatar>
@ -28,6 +29,8 @@ export default () => (
<Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} /> <Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} />
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -13,10 +13,11 @@ title:
The most basic usage. The most basic usage.
```jsx ```tsx
import { BackTop } from 'antd'; import { BackTop } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<BackTop /> <BackTop />
Scroll down to see the bottom-right Scroll down to see the bottom-right
@ -24,6 +25,8 @@ export default () => (
button. button.
</> </>
); );
export default App;
``` ```
```css ```css

View File

@ -14,10 +14,11 @@ title:
You can customize the style of the button, just note the size limit: no more than `40px * 40px`. You can customize the style of the button, just note the size limit: no more than `40px * 40px`.
```jsx ```tsx
import { BackTop } from 'antd'; import { BackTop } from 'antd';
import React from 'react';
const style = { const style: React.CSSProperties = {
height: 40, height: 40,
width: 40, width: 40,
lineHeight: '40px', lineHeight: '40px',
@ -28,7 +29,7 @@ const style = {
fontSize: 14, fontSize: 14,
}; };
export default () => ( const App: React.FC = () => (
<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>
@ -42,4 +43,6 @@ export default () => (
</BackTop> </BackTop>
</div> </div>
); );
export default App;
``` ```

View File

@ -13,11 +13,12 @@ title:
Simplest Usage. Badge will be hidden when `count` is `0`, but we can use `showZero` to show it. Simplest Usage. Badge will be hidden when `count` is `0`, but we can use `showZero` to show it.
```jsx ```tsx
import { Badge, Avatar } from 'antd';
import { ClockCircleOutlined } from '@ant-design/icons'; import { ClockCircleOutlined } from '@ant-design/icons';
import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge count={5}> <Badge count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -30,6 +31,8 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -13,14 +13,14 @@ title:
The count will be animated as it changes. The count will be animated as it changes.
```jsx ```tsx
import React, { useState } from 'react';
import { Badge, Button, Switch, Divider, Avatar } from 'antd';
import { MinusOutlined, PlusOutlined, QuestionOutlined } from '@ant-design/icons'; import { MinusOutlined, PlusOutlined, QuestionOutlined } from '@ant-design/icons';
import { Avatar, Badge, Button, Divider, Switch } from 'antd';
import React, { useState } from 'react';
const ButtonGroup = Button.Group; const ButtonGroup = Button.Group;
export default () => { const App: React.FC = () => {
const [count, setCount] = useState(5); const [count, setCount] = useState(5);
const [show, setShow] = useState(true); const [show, setShow] = useState(true);
@ -29,20 +29,20 @@ export default () => {
}; };
const decline = () => { const decline = () => {
let countValue = count - 1; let newCount = count - 1;
if (countValue < 0) { if (newCount < 0) {
countValue = 0; newCount = 0;
} }
setCount(countValue); setCount(newCount);
}; };
const random = () => { const random = () => {
const countValue = Math.floor(Math.random() * 100); const newCount = Math.floor(Math.random() * 100);
setCount(countValue); setCount(newCount);
}; };
const onChange = isShow => { const onChange = (checked: boolean) => {
setShow(isShow); setShow(checked);
}; };
return ( return (
@ -69,4 +69,6 @@ export default () => {
</> </>
); );
}; };
export default App;
``` ```

View File

@ -13,8 +13,9 @@ 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. 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.
```jsx ```tsx
import { Badge, Divider } from 'antd'; import { Badge, Divider } from 'antd';
import React from 'react';
const colors = [ const colors = [
'pink', 'pink',
@ -32,7 +33,7 @@ const colors = [
'lime', 'lime',
]; ];
export default () => ( const App: React.FC = () => (
<> <>
<Divider orientation="left">Presets</Divider> <Divider orientation="left">Presets</Divider>
<div> <div>
@ -54,6 +55,8 @@ export default () => (
</> </>
</> </>
); );
export default App;
``` ```
```css ```css

View File

@ -13,11 +13,12 @@ title:
This will simply display a red badge, without a specific count. If count equals 0, it won't display the dot. This will simply display a red badge, without a specific count. If count equals 0, it won't display the dot.
```jsx ```tsx
import { Badge } from 'antd';
import { NotificationOutlined } from '@ant-design/icons'; import { NotificationOutlined } from '@ant-design/icons';
import { Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge dot> <Badge dot>
<NotificationOutlined style={{ fontSize: 16 }} /> <NotificationOutlined style={{ fontSize: 16 }} />
@ -27,4 +28,6 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```

View File

@ -13,14 +13,17 @@ title:
The badge can be wrapped with `a` tag to make it linkable. The badge can be wrapped with `a` tag to make it linkable.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<a href="#"> <a href="#">
<Badge count={5}> <Badge count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
</a> </a>
); );
export default App;
``` ```

View File

@ -14,10 +14,11 @@ debug: true
Using `count/dot` with custom `stauts/color`. Using `count/dot` with custom `stauts/color`.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge count={5} status="success"> <Badge count={5} status="success">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -45,4 +46,6 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```

View File

@ -15,12 +15,13 @@ title:
Used in standalone when children is empty. Used in standalone when children is empty.
```jsx ```tsx
import { Badge, Space, Switch } from 'antd';
import { ClockCircleOutlined } from '@ant-design/icons'; import { ClockCircleOutlined } from '@ant-design/icons';
import { Badge, Space, Switch } from 'antd';
import React, { useState } from 'react';
const Demo = () => { const App: React.FC = () => {
const [show, setShow] = React.useState(true); const [show, setShow] = useState(true);
return ( return (
<Space> <Space>
@ -36,5 +37,5 @@ const Demo = () => {
); );
}; };
export default Demo; export default App;
``` ```

View File

@ -13,12 +13,15 @@ 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. 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.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Badge count={5} offset={[10, 10]}> <Badge count={5} offset={[10, 10]}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
</Badge> </Badge>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
`${overflowCount}+` is displayed when count is larger than `overflowCount`. The default value of `overflowCount` is `99`. `${overflowCount}+` is displayed when count is larger than `overflowCount`. The default value of `overflowCount` is `99`.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge count={99}> <Badge count={99}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -32,4 +33,6 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Use ribbon badge. Use ribbon badge.
```jsx ```tsx
import { Badge, Card } from 'antd'; import { Badge, Card } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge.Ribbon text="Hippies"> <Badge.Ribbon text="Hippies">
<Card title="Pushes open the window" size="small"> <Card title="Pushes open the window" size="small">
@ -60,6 +61,8 @@ export default () => (
</Badge.Ribbon> </Badge.Ribbon>
</> </>
); );
export default App;
``` ```
```css ```css

View File

@ -14,10 +14,11 @@ Buggy!
Buggy! Buggy!
```jsx ```tsx
import { Badge, Card, Space } from 'antd'; import { Badge, Card, Space } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Space direction="vertical" style={{ width: '100%' }}> <Space direction="vertical" style={{ width: '100%' }}>
<Badge.Ribbon text="啦啦啦啦"> <Badge.Ribbon text="啦啦啦啦">
<Card>推开窗户举起望远镜</Card> <Card>推开窗户举起望远镜</Card>
@ -36,4 +37,6 @@ export default () => (
</Badge.Ribbon> </Badge.Ribbon>
</Space> </Space>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Set size of numeral Badge. Set size of numeral Badge.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge size="default" count={5}> <Badge size="default" count={5}>
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -26,4 +27,6 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Standalone badge with status. Standalone badge with status.
```jsx ```tsx
import { Badge } from 'antd'; import { Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge status="success" /> <Badge status="success" />
<Badge status="error" /> <Badge status="error" />
@ -35,4 +36,6 @@ export default () => (
<Badge status="warning" text="Warning" /> <Badge status="warning" text="Warning" />
</> </>
); );
export default App;
``` ```

View File

@ -14,10 +14,11 @@ debug: true
The badge will display `title` when hovered over, instead of `count`. The badge will display `title` when hovered over, instead of `count`.
```jsx ```tsx
import { Badge, Avatar } from 'antd'; import { Avatar, Badge } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Badge count={5} title="Custom hover text"> <Badge count={5} title="Custom hover text">
<Avatar shape="square" size="large" /> <Avatar shape="square" size="large" />
@ -27,4 +28,6 @@ export default () => (
</Badge> </Badge>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
The simplest use. The simplest use.
```jsx ```tsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item>Home</Breadcrumb.Item> <Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item> <Breadcrumb.Item>
@ -28,4 +29,6 @@ export default () => (
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>
); );
export default App;
``` ```

View File

@ -13,13 +13,15 @@ title:
Breadcrumbs support drop down menu. Breadcrumbs support drop down menu.
```jsx ```tsx
import { Breadcrumb, Menu } from 'antd'; import { Breadcrumb, Menu } from 'antd';
import React from 'react';
const menu = ( const menu = (
<Menu <Menu
items={[ items={[
{ {
key: '1',
label: ( label: (
<a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/"> <a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/">
General General
@ -27,6 +29,7 @@ const menu = (
), ),
}, },
{ {
key: '2',
label: ( label: (
<a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/"> <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">
Layout Layout
@ -34,6 +37,7 @@ const menu = (
), ),
}, },
{ {
key: '3',
label: ( label: (
<a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/"> <a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">
Navigation Navigation
@ -44,7 +48,7 @@ const menu = (
/> />
); );
export default () => ( const App: React.FC = () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item>Ant Design</Breadcrumb.Item> <Breadcrumb.Item>Ant Design</Breadcrumb.Item>
<Breadcrumb.Item> <Breadcrumb.Item>
@ -56,4 +60,6 @@ export default () => (
<Breadcrumb.Item>Button</Breadcrumb.Item> <Breadcrumb.Item>Button</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>
); );
export default App;
``` ```

View File

@ -15,9 +15,10 @@ title:
Used together with `react-router@6+`. Used together with `react-router@6+`.
```jsx ```tsx
import { HashRouter, Route, Routes, Link, useLocation } from 'react-router-dom'; import { Alert, Breadcrumb } from 'antd';
import { Breadcrumb, Alert } from 'antd'; import React from 'react';
import { HashRouter, Link, Route, Routes, useLocation } from 'react-router-dom';
const Apps = () => ( const Apps = () => (
<ul className="app-list"> <ul className="app-list">
@ -30,16 +31,18 @@ const Apps = () => (
</ul> </ul>
); );
const breadcrumbNameMap = { const breadcrumbNameMap: Record<string, string> = {
'/apps': 'Application List', '/apps': 'Application List',
'/apps/1': 'Application1', '/apps/1': 'Application1',
'/apps/2': 'Application2', '/apps/2': 'Application2',
'/apps/1/detail': 'Detail', '/apps/1/detail': 'Detail',
'/apps/2/detail': 'Detail', '/apps/2/detail': 'Detail',
}; };
const Home = props => {
const Home = () => {
const location = useLocation(); const location = useLocation();
const pathSnippets = location.pathname.split('/').filter(i => i); const pathSnippets = location.pathname.split('/').filter(i => i);
const extraBreadcrumbItems = pathSnippets.map((_, index) => { const extraBreadcrumbItems = pathSnippets.map((_, index) => {
const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; const url = `/${pathSnippets.slice(0, index + 1).join('/')}`;
return ( return (
@ -48,11 +51,13 @@ const Home = props => {
</Breadcrumb.Item> </Breadcrumb.Item>
); );
}); });
const breadcrumbItems = [ const breadcrumbItems = [
<Breadcrumb.Item key="home"> <Breadcrumb.Item key="home">
<Link to="/">Home</Link> <Link to="/">Home</Link>
</Breadcrumb.Item>, </Breadcrumb.Item>,
].concat(extraBreadcrumbItems); ].concat(extraBreadcrumbItems);
return ( return (
<div className="demo"> <div className="demo">
<div className="demo-nav"> <div className="demo-nav">
@ -69,11 +74,13 @@ const Home = props => {
); );
}; };
export default () => ( const App: React.FC = () => (
<HashRouter> <HashRouter>
<Home /> <Home />
</HashRouter> </HashRouter>
); );
export default App;
``` ```
```css ```css

View File

@ -13,10 +13,11 @@ title:
The separator can be customized by setting the separator property: `Breadcrumb.Separator`. The separator can be customized by setting the separator property: `Breadcrumb.Separator`.
```jsx ```tsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Breadcrumb separator=""> <Breadcrumb separator="">
<Breadcrumb.Item>Location</Breadcrumb.Item> <Breadcrumb.Item>Location</Breadcrumb.Item>
<Breadcrumb.Separator>:</Breadcrumb.Separator> <Breadcrumb.Separator>:</Breadcrumb.Separator>
@ -27,4 +28,6 @@ export default () => (
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
The separator can be customized by setting the separator property: `separator=">"`. The separator can be customized by setting the separator property: `separator=">"`.
```jsx ```tsx
import { Breadcrumb } from 'antd'; import { Breadcrumb } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<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>
@ -24,4 +25,6 @@ export default () => (
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>
); );
export default App;
``` ```

View File

@ -13,11 +13,12 @@ title:
The icon should be placed in front of the text. The icon should be placed in front of the text.
```jsx ```tsx
import { Breadcrumb } from 'antd';
import { HomeOutlined, UserOutlined } from '@ant-design/icons'; import { HomeOutlined, UserOutlined } from '@ant-design/icons';
import { Breadcrumb } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Breadcrumb> <Breadcrumb>
<Breadcrumb.Item href=""> <Breadcrumb.Item href="">
<HomeOutlined /> <HomeOutlined />
@ -29,4 +30,6 @@ export default () => (
<Breadcrumb.Item>Application</Breadcrumb.Item> <Breadcrumb.Item>Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
There are `primary` button, `default` button, `dashed` button, `text` button and `link` button in antd. There are `primary` button, `default` button, `dashed` button, `text` button and `link` button in antd.
```jsx ```tsx
import { Button } from 'antd'; import { Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Button type="primary">Primary Button</Button> <Button type="primary">Primary Button</Button>
<Button>Default Button</Button> <Button>Default Button</Button>
@ -26,4 +27,6 @@ export default () => (
<Button type="link">Link Button</Button> <Button type="link">Link Button</Button>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
`block` property will make the button fit to its parent width. `block` property will make the button fit to its parent width.
```jsx ```tsx
import { Button } from 'antd'; import { Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Button type="primary" block> <Button type="primary" block>
Primary Primary
@ -30,4 +31,6 @@ export default () => (
</Button> </Button>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
`danger` is a property of button after antd 4.0. `danger` is a property of button after antd 4.0.
```jsx ```tsx
import { Button } from 'antd'; import { Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Button type="primary" danger> <Button type="primary" danger>
Primary Primary
@ -33,4 +34,6 @@ export default () => (
</Button> </Button>
</> </>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
To mark a button as disabled, add the `disabled` property to the `Button`. To mark a button as disabled, add the `disabled` property to the `Button`.
```jsx ```tsx
import { Button } from 'antd'; import { Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Button type="primary">Primary</Button> <Button type="primary">Primary</Button>
<Button type="primary" disabled> <Button type="primary" disabled>
@ -67,6 +68,8 @@ export default () => (
</div> </div>
</> </>
); );
export default App;
``` ```
```css ```css

View File

@ -13,10 +13,11 @@ title:
`ghost` property will make button's background transparent, it is commonly used in colored background. `ghost` property will make button's background transparent, it is commonly used in colored background.
```jsx ```tsx
import { Button } from 'antd'; import { Button } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<div className="site-button-ghost-wrapper"> <div className="site-button-ghost-wrapper">
<Button type="primary" ghost> <Button type="primary" ghost>
Primary Primary
@ -30,6 +31,8 @@ export default () => (
</Button> </Button>
</div> </div>
); );
export default App;
``` ```
```css ```css

View File

@ -17,11 +17,12 @@ title:
If you want specific control over the positioning and placement of the `Icon`, then that should be done by placing the `Icon` component within the `Button` rather than using the `icon` property. If you want specific control over the positioning and placement of the `Icon`, then that should be done by placing the `Icon` component within the `Button` rather than using the `icon` property.
```jsx ```tsx
import { Button, Tooltip } from 'antd';
import { SearchOutlined } from '@ant-design/icons'; import { SearchOutlined } from '@ant-design/icons';
import { Button, Tooltip } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Tooltip title="search"> <Tooltip title="search">
<Button type="primary" shape="circle" icon={<SearchOutlined />} /> <Button type="primary" shape="circle" icon={<SearchOutlined />} />
@ -81,4 +82,6 @@ export default () => (
<Button icon={<SearchOutlined />} size="large" href="https://www.google.com" /> <Button icon={<SearchOutlined />} size="large" href="https://www.google.com" />
</> </>
); );
export default App;
``` ```

View File

@ -14,12 +14,13 @@ Debug usage
Debug usage Debug usage
```jsx ```tsx
import { Button, Tooltip } from 'antd';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { Button, Tooltip } from 'antd';
import type { ButtonGroupProps } from 'antd/es/button';
import React from 'react';
function getGroup(props) { const getGroup = (props?: ButtonGroupProps) => (
return (
<div> <div>
<Button.Group {...props}> <Button.Group {...props}>
<Button type="primary">Button 1</Button> <Button type="primary">Button 1</Button>
@ -32,10 +33,9 @@ function getGroup(props) {
</Tooltip> </Tooltip>
</Button.Group> </Button.Group>
</div> </div>
); );
}
export default () => ( const App: React.FC = () => (
<> <>
{getGroup({ size: 'small' })} {getGroup({ size: 'small' })}
<br /> <br />
@ -44,4 +44,6 @@ export default () => (
{getGroup({ size: 'large' })} {getGroup({ size: 'large' })}
</> </>
); );
export default App;
``` ```

View File

@ -13,15 +13,15 @@ title:
A loading indicator can be added to a button by setting the `loading` property on the `Button`. A loading indicator can be added to a button by setting the `loading` property on the `Button`.
```jsx ```tsx
import React, { useEffect, useState, useRef } from 'react';
import { Button, Space } from 'antd';
import { PoweroffOutlined } from '@ant-design/icons'; import { PoweroffOutlined } from '@ant-design/icons';
import { Button, Space } from 'antd';
import React, { useState } from 'react';
export default () => { const App: React.FC = () => {
const [loadings, setLoadings] = useState([]); const [loadings, setLoadings] = useState<boolean[]>([]);
const enterLoading = index => { const enterLoading = (index: number) => {
setLoadings(prevLoadings => { setLoadings(prevLoadings => {
const newLoadings = [...prevLoadings]; const newLoadings = [...prevLoadings];
newLoadings[index] = true; newLoadings[index] = true;
@ -71,4 +71,6 @@ export default () => {
</> </>
); );
}; };
export default App;
``` ```

View File

@ -15,7 +15,8 @@ If you need several buttons, we recommend that you use 1 primary button + n seco
```tsx ```tsx
import type { MenuProps } from 'antd'; import type { MenuProps } from 'antd';
import { Button, Menu, Dropdown } from 'antd'; import { Button, Dropdown, Menu } from 'antd';
import React from 'react';
const onMenuClick: MenuProps['onClick'] = e => { const onMenuClick: MenuProps['onClick'] = e => {
console.log('click', e); console.log('click', e);
@ -41,11 +42,13 @@ const menu = (
/> />
); );
export default () => ( const App: React.FC = () => (
<> <>
<Button type="primary">primary</Button> <Button type="primary">primary</Button>
<Button>secondary</Button> <Button>secondary</Button>
<Dropdown.Button overlay={menu}>Actions</Dropdown.Button> <Dropdown.Button overlay={menu}>Actions</Dropdown.Button>
</> </>
); );
export default App;
``` ```

View File

@ -17,20 +17,18 @@ Ant Design supports a default button size as well as a large and small size.
If a large or small button is desired, set the `size` property to either `large` or `small` respectively. Omit the `size` property for a button with the default size. If a large or small button is desired, set the `size` property to either `large` or `small` respectively. Omit the `size` property for a button with the default size.
```jsx ```tsx
import React, { useState } from 'react';
import { Button, Radio } from 'antd';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { Button, Radio } from 'antd';
import type { SizeType } from 'antd/es/config-provider/SizeContext';
import React, { useState } from 'react';
export default () => { const App: React.FC = () => {
const [size, setSize] = useState('large'); const [size, setSize] = useState<SizeType>('large');
const handleSizeChange = e => {
setSize(e.target.value);
};
return ( return (
<> <>
<Radio.Group value={size} onChange={handleSizeChange}> <Radio.Group value={size} onChange={e => setSize(e.target.value)}>
<Radio.Button value="large">Large</Radio.Button> <Radio.Button value="large">Large</Radio.Button>
<Radio.Button value="default">Default</Radio.Button> <Radio.Button value="default">Default</Radio.Button>
<Radio.Button value="small">Small</Radio.Button> <Radio.Button value="small">Small</Radio.Button>
@ -61,4 +59,6 @@ export default () => {
</> </>
); );
}; };
export default App;
``` ```

View File

@ -3185,12 +3185,10 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
</h4> </h4>
<div <div
class="ant-row" class="ant-row"
role="row"
style="margin-left:-4px;margin-right:-4px" style="margin-left:-4px;margin-right:-4px"
> >
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div
@ -3239,7 +3237,6 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
</div> </div>
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div
@ -3690,7 +3687,6 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
</div> </div>
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div

View File

@ -1905,12 +1905,10 @@ exports[`renders ./components/calendar/demo/customize-header.md correctly 1`] =
</h4> </h4>
<div <div
class="ant-row" class="ant-row"
role="row"
style="margin-left:-4px;margin-right:-4px" style="margin-left:-4px;margin-right:-4px"
> >
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div
@ -1959,7 +1957,6 @@ exports[`renders ./components/calendar/demo/customize-header.md correctly 1`] =
</div> </div>
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div
@ -2024,7 +2021,6 @@ exports[`renders ./components/calendar/demo/customize-header.md correctly 1`] =
</div> </div>
<div <div
class="ant-col" class="ant-col"
role="cell"
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<div <div

View File

@ -13,12 +13,19 @@ title:
A basic calendar component with Year/Month switch. A basic calendar component with Year/Month switch.
```jsx ```tsx
import { Calendar } from 'antd'; import { Calendar } from 'antd';
import type { CalendarMode } from 'antd/lib/calendar/generateCalendar';
import type { Moment } from 'moment';
import React from 'react';
function onPanelChange(value, mode) { const App: React.FC = () => {
const onPanelChange = (value: Moment, mode: CalendarMode) => {
console.log(value.format('YYYY-MM-DD'), mode); console.log(value.format('YYYY-MM-DD'), mode);
} };
export default () => <Calendar onPanelChange={onPanelChange} />; return <Calendar onPanelChange={onPanelChange} />;
};
export default App;
``` ```

View File

@ -13,18 +13,25 @@ title:
Nested inside a container element for rendering in limited space. Nested inside a container element for rendering in limited space.
```jsx ```tsx
import { Calendar } from 'antd'; import { Calendar } from 'antd';
import type { CalendarMode } from 'antd/lib/calendar/generateCalendar';
import type { Moment } from 'moment';
import React from 'react';
function onPanelChange(value, mode) { const App: React.FC = () => {
console.log(value, mode); const onPanelChange = (value: Moment, mode: CalendarMode) => {
} console.log(value.format('YYYY-MM-DD'), mode);
};
export default () => ( return (
<div className="site-calendar-demo-card"> <div className="site-calendar-demo-card">
<Calendar fullscreen={false} onPanelChange={onPanelChange} /> <Calendar fullscreen={false} onPanelChange={onPanelChange} />
</div> </div>
); );
};
export default App;
``` ```
```css ```css

View File

@ -13,15 +13,18 @@ title:
Customize Calendar header content. Customize Calendar header content.
```jsx ```tsx
import { Calendar, Select, Radio, Col, Row, Typography } from 'antd'; import { Calendar, Col, Radio, Row, Select, Typography } from 'antd';
import type { CalendarMode } from 'antd/lib/calendar/generateCalendar';
import 'dayjs/locale/zh-cn'; import 'dayjs/locale/zh-cn';
import React from 'react';
function onPanelChange(value, mode) { const App: React.FC = () => {
console.log(value, mode); const onPanelChange = (value: Moment, mode: CalendarMode) => {
} console.log(value.format('YYYY-MM-DD'), mode);
};
export default () => ( return (
<div className="site-calendar-customize-header-wrapper"> <div className="site-calendar-customize-header-wrapper">
<Calendar <Calendar
fullscreen={false} fullscreen={false}
@ -61,7 +64,11 @@ export default () => (
<Typography.Title level={4}>Custom header</Typography.Title> <Typography.Title level={4}>Custom header</Typography.Title>
<Row gutter={8}> <Row gutter={8}>
<Col> <Col>
<Radio.Group size="small" onChange={e => onTypeChange(e.target.value)} value={type}> <Radio.Group
size="small"
onChange={e => onTypeChange(e.target.value)}
value={type}
>
<Radio.Button value="month">Month</Radio.Button> <Radio.Button value="month">Month</Radio.Button>
<Radio.Button value="year">Year</Radio.Button> <Radio.Button value="year">Year</Radio.Button>
</Radio.Group> </Radio.Group>
@ -72,7 +79,7 @@ export default () => (
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
className="my-year-select" className="my-year-select"
onChange={newYear => { onChange={newYear => {
const now = value.clone().year(newYear); const now = value.clone().year(Number(newYear));
onChange(now); onChange(now);
}} }}
value={String(year)} value={String(year)}
@ -101,7 +108,10 @@ export default () => (
onPanelChange={onPanelChange} onPanelChange={onPanelChange}
/> />
</div> </div>
); );
};
export default App;
``` ```
```css ```css

View File

@ -13,10 +13,13 @@ title:
This component can be rendered by using `dateCellRender` and `monthCellRender` with the data you need. This component can be rendered by using `dateCellRender` and `monthCellRender` with the data you need.
```jsx ```tsx
import { Calendar, Badge } from 'antd'; import type { BadgeProps } from 'antd';
import { Badge, Calendar } from 'antd';
import type { Moment } from 'moment';
import React from 'react';
function getListData(value) { const getListData = (value: Moment) => {
let listData; let listData;
switch (value.date()) { switch (value.date()) {
case 8: case 8:
@ -45,28 +48,16 @@ function getListData(value) {
default: default:
} }
return listData || []; return listData || [];
} };
function dateCellRender(value) { const getMonthData = (value: Moment) => {
const listData = getListData(value);
return (
<ul className="events">
{listData.map(item => (
<li key={item.content}>
<Badge status={item.type} text={item.content} />
</li>
))}
</ul>
);
}
function getMonthData(value) {
if (value.month() === 8) { if (value.month() === 8) {
return 1394; return 1394;
} }
} };
function monthCellRender(value) { const App: React.FC = () => {
const monthCellRender = (value: Moment) => {
const num = getMonthData(value); const num = getMonthData(value);
return num ? ( return num ? (
<div className="notes-month"> <div className="notes-month">
@ -74,9 +65,25 @@ function monthCellRender(value) {
<span>Backlog number</span> <span>Backlog number</span>
</div> </div>
) : null; ) : null;
} };
export default () => <Calendar dateCellRender={dateCellRender} monthCellRender={monthCellRender} />; const dateCellRender = (value: Moment) => {
const listData = getListData(value);
return (
<ul className="events">
{listData.map(item => (
<li key={item.content}>
<Badge status={item.type as BadgeProps['status']} text={item.content} />
</li>
))}
</ul>
);
};
return <Calendar dateCellRender={dateCellRender} monthCellRender={monthCellRender} />;
};
export default App;
``` ```
```css ```css

View File

@ -13,40 +13,31 @@ title:
A basic calendar component with Year/Month switch. A basic calendar component with Year/Month switch.
```jsx ```tsx
import React, { useState } from 'react'; import { Alert, Calendar } from 'antd';
import { Calendar, Alert } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import React, { useState } from 'react';
export default () => { const App: React.FC = () => {
const [calendar, setCalendar] = useState({ const [value, setValue] = useState(dayjs('2017-01-25'));
value: dayjs('2017-01-25'), const [selectedValue, setSelectedValue] = useState(dayjs('2017-01-25'));
selectedValue: dayjs('2017-01-25'),
});
const onSelect = value => { const onSelect = (newValue: Moment) => {
setCalendar({ setValue(newValue);
value, setSelectedValue(newValue);
selectedValue: value,
});
}; };
const onPanelChange = value => { const onPanelChange = (newValue: Moment) => {
setCalendar({ setValue(newValue);
...calendar,
value,
});
}; };
return ( return (
<> <>
<Alert <Alert message={`You selected date: ${selectedValue?.format('YYYY-MM-DD')}`} />
message={`You selected date: ${ <Calendar value={value} onSelect={onSelect} onPanelChange={onPanelChange} />
calendar.selectedValue && calendar.selectedValue.format('YYYY-MM-DD')
}`}
/>
<Calendar value={calendar.value} onSelect={onSelect} onPanelChange={onPanelChange} />
</> </>
); );
}; };
export default App;
``` ```

View File

@ -233,12 +233,10 @@ exports[`renders ./components/card/demo/in-column.md extend context correctly 1`
> >
<div <div
class="ant-row" class="ant-row"
role="row"
style="margin-left:-8px;margin-right:-8px" style="margin-left:-8px;margin-right:-8px"
> >
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -266,7 +264,6 @@ exports[`renders ./components/card/demo/in-column.md extend context correctly 1`
</div> </div>
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -294,7 +291,6 @@ exports[`renders ./components/card/demo/in-column.md extend context correctly 1`
</div> </div>
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -437,10 +433,111 @@ Array [
class="ant-skeleton ant-skeleton-active" class="ant-skeleton ant-skeleton-active"
> >
<div <div
<<<<<<< HEAD
class="ant-skeleton-content" class="ant-skeleton-content"
> >
<ul <ul
class="ant-skeleton-paragraph" class="ant-skeleton-paragraph"
=======
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-22"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-8"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-15"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-6"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-18"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-13"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-9"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-4"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-3"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-16"
style="padding-left:4px;padding-right:4px"
>>>>>>> origin/master
> >
<li /> <li />
<li /> <li />

View File

@ -233,12 +233,10 @@ exports[`renders ./components/card/demo/in-column.md correctly 1`] = `
> >
<div <div
class="ant-row" class="ant-row"
role="row"
style="margin-left:-8px;margin-right:-8px" style="margin-left:-8px;margin-right:-8px"
> >
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -266,7 +264,6 @@ exports[`renders ./components/card/demo/in-column.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -294,7 +291,6 @@ exports[`renders ./components/card/demo/in-column.md correctly 1`] = `
</div> </div>
<div <div
class="ant-col ant-col-8" class="ant-col ant-col-8"
role="cell"
style="padding-left:8px;padding-right:8px" style="padding-left:8px;padding-right:8px"
> >
<div <div
@ -437,10 +433,111 @@ Array [
class="ant-skeleton ant-skeleton-active" class="ant-skeleton ant-skeleton-active"
> >
<div <div
<<<<<<< HEAD
class="ant-skeleton-content" class="ant-skeleton-content"
> >
<ul <ul
class="ant-skeleton-paragraph" class="ant-skeleton-paragraph"
=======
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-22"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-8"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-15"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-6"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-18"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-13"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-9"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left:-4px;margin-right:-4px"
>
<div
class="ant-col ant-col-4"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-3"
style="padding-left:4px;padding-right:4px"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-16"
style="padding-left:4px;padding-right:4px"
>>>>>>> origin/master
> >
<li /> <li />
<li /> <li />

View File

@ -22,10 +22,19 @@ exports[`Card should still have padding when card which set padding to 0 is load
class="ant-skeleton ant-skeleton-active" class="ant-skeleton ant-skeleton-active"
> >
<div <div
<<<<<<< HEAD
class="ant-skeleton-content" class="ant-skeleton-content"
> >
<ul <ul
class="ant-skeleton-paragraph" class="ant-skeleton-paragraph"
=======
class="ant-row"
style="margin-left: -4px; margin-right: -4px;"
>
<div
class="ant-col ant-col-22"
style="padding-left: 4px; padding-right: 4px;"
>>>>>>> origin/master
> >
<li /> <li />
<li /> <li />
@ -33,7 +42,103 @@ exports[`Card should still have padding when card which set padding to 0 is load
<li <li
style="width: 61%;" style="width: 61%;"
/> />
<<<<<<< HEAD
</ul> </ul>
=======
</div>
</div>
<div
class="ant-row"
style="margin-left: -4px; margin-right: -4px;"
>
<div
class="ant-col ant-col-8"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-15"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left: -4px; margin-right: -4px;"
>
<div
class="ant-col ant-col-6"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-18"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left: -4px; margin-right: -4px;"
>
<div
class="ant-col ant-col-13"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-9"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
</div>
<div
class="ant-row"
style="margin-left: -4px; margin-right: -4px;"
>
<div
class="ant-col ant-col-4"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-3"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
<div
class="ant-col ant-col-16"
style="padding-left: 4px; padding-right: 4px;"
>
<div
class="ant-card-loading-block"
/>
</div>
>>>>>>> origin/master
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,10 +13,11 @@ title:
A basic card containing a title, content and an extra corner content. Supports two sizes: `default` and `small`. A basic card containing a title, content and an extra corner content. Supports two sizes: `default` and `small`.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<> <>
<Card title="Default size card" extra={<a href="#">More</a>} style={{ width: 300 }}> <Card title="Default size card" extra={<a href="#">More</a>} style={{ width: 300 }}>
<p>Card content</p> <p>Card content</p>
@ -30,6 +31,8 @@ export default () => (
</Card> </Card>
</> </>
); );
export default App;
``` ```
<style> <style>

View File

@ -13,10 +13,11 @@ title:
A borderless card on a gray background. A borderless card on a gray background.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<div className="site-card-border-less-wrapper"> <div className="site-card-border-less-wrapper">
<Card title="Card title" bordered={false} style={{ width: 300 }}> <Card title="Card title" bordered={false} style={{ width: 300 }}>
<p>Card content</p> <p>Card content</p>
@ -25,6 +26,8 @@ export default () => (
</Card> </Card>
</div> </div>
); );
export default App;
``` ```
```css ```css

View File

@ -13,12 +13,13 @@ title:
You can use `Card.Meta` to support more flexible content. You can use `Card.Meta` to support more flexible content.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
const { Meta } = Card; const { Meta } = Card;
export default () => ( const App: React.FC = () => (
<Card <Card
hoverable hoverable
style={{ width: 240 }} style={{ width: 240 }}
@ -27,4 +28,6 @@ export default () => (
<Meta title="Europe Street beat" description="www.instagram.com" /> <Meta title="Europe Street beat" description="www.instagram.com" />
</Card> </Card>
); );
export default App;
``` ```

View File

@ -13,15 +13,16 @@ title:
Grid style card content. Grid style card content.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
const gridStyle = { const gridStyle: React.CSSProperties = {
width: '25%', width: '25%',
textAlign: 'center', textAlign: 'center',
}; };
export default () => ( const App: React.FC = () => (
<Card title="Card Title"> <Card title="Card Title">
<Card.Grid style={gridStyle}>Content</Card.Grid> <Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid hoverable={false} style={gridStyle}> <Card.Grid hoverable={false} style={gridStyle}>
@ -34,4 +35,6 @@ export default () => (
<Card.Grid style={gridStyle}>Content</Card.Grid> <Card.Grid style={gridStyle}>Content</Card.Grid>
</Card> </Card>
); );
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Cards usually cooperate with grid column layout in overview page. Cards usually cooperate with grid column layout in overview page.
```jsx ```tsx
import { Card, Col, Row } from 'antd'; import { Card, Col, Row } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<div className="site-card-wrapper"> <div className="site-card-wrapper">
<Row gutter={16}> <Row gutter={16}>
<Col span={8}> <Col span={8}>
@ -37,6 +38,8 @@ export default () => (
</Row> </Row>
</div> </div>
); );
export default App;
``` ```
<style> <style>

View File

@ -13,10 +13,11 @@ title:
It can be placed inside the ordinary card to display the information of the multilevel structure. It can be placed inside the ordinary card to display the information of the multilevel structure.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Card title="Card title"> <Card title="Card title">
<Card type="inner" title="Inner Card title" extra={<a href="#">More</a>}> <Card type="inner" title="Inner Card title" extra={<a href="#">More</a>}>
Inner Card content Inner Card content
@ -31,4 +32,6 @@ export default () => (
</Card> </Card>
</Card> </Card>
); );
export default App;
``` ```

View File

@ -13,17 +13,17 @@ title:
Shows a loading indicator while the contents of the card is being fetched. Shows a loading indicator while the contents of the card is being fetched.
```jsx ```tsx
import React, { useState } from 'react';
import { Skeleton, Switch, Card, Avatar } from 'antd';
import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons'; import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons';
import { Avatar, Card, Skeleton, Switch } from 'antd';
import React, { useState } from 'react';
const { Meta } = Card; const { Meta } = Card;
export default () => { const App: React.FC = () => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const onChange = checked => { const onChange = (checked: boolean) => {
setLoading(!checked); setLoading(!checked);
}; };
@ -58,4 +58,6 @@ export default () => {
</> </>
); );
}; };
export default App;
``` ```

View File

@ -13,13 +13,14 @@ title:
A Card that supports `cover`, `avatar`, `title` and `description`. A Card that supports `cover`, `avatar`, `title` and `description`.
```jsx ```tsx
import { Card, Avatar } from 'antd';
import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons'; import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons';
import { Avatar, Card } from 'antd';
import React from 'react';
const { Meta } = Card; const { Meta } = Card;
export default () => ( const App: React.FC = () => (
<Card <Card
style={{ width: 300 }} style={{ width: 300 }}
cover={ cover={
@ -41,4 +42,6 @@ export default () => (
/> />
</Card> </Card>
); );
export default App;
``` ```

View File

@ -13,14 +13,17 @@ title:
A simple card only containing a content area. A simple card only containing a content area.
```jsx ```tsx
import { Card } from 'antd'; import { Card } from 'antd';
import React from 'react';
export default () => ( const App: React.FC = () => (
<Card style={{ width: 300 }}> <Card style={{ width: 300 }}>
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
</Card> </Card>
); );
export default App;
``` ```

View File

@ -13,9 +13,9 @@ title:
More content can be hosted. More content can be hosted.
```jsx ```tsx
import React, { useState } from 'react';
import { Card } from 'antd'; import { Card } from 'antd';
import React, { useState } from 'react';
const tabList = [ const tabList = [
{ {
@ -28,7 +28,7 @@ const tabList = [
}, },
]; ];
const contentList = { const contentList: Record<string, React.ReactNode> = {
tab1: <p>content1</p>, tab1: <p>content1</p>,
tab2: <p>content2</p>, tab2: <p>content2</p>,
}; };
@ -48,20 +48,20 @@ const tabListNoTitle = [
}, },
]; ];
const contentListNoTitle = { const contentListNoTitle: Record<string, React.ReactNode> = {
article: <p>article content</p>, article: <p>article content</p>,
app: <p>app content</p>, app: <p>app content</p>,
project: <p>project content</p>, project: <p>project content</p>,
}; };
const TabsCard = () => { const App: React.FC = () => {
const [activeTabKey1, setActiveTabKey1] = useState('tab1'); const [activeTabKey1, setActiveTabKey1] = useState<string>('tab1');
const [activeTabKey2, setActiveTabKey2] = useState('app'); const [activeTabKey2, setActiveTabKey2] = useState<string>('app');
const onTab1Change = key => { const onTab1Change = (key: string) => {
setActiveTabKey1(key); setActiveTabKey1(key);
}; };
const onTab2Change = key => { const onTab2Change = (key: string) => {
setActiveTabKey2(key); setActiveTabKey2(key);
}; };
@ -96,5 +96,5 @@ const TabsCard = () => {
); );
}; };
export default () => <TabsCard />; export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Timing of scrolling to the next card/picture. Timing of scrolling to the next card/picture.
```jsx ```tsx
import { Carousel } from 'antd'; import { Carousel } from 'antd';
import React from 'react';
const contentStyle = { const contentStyle: React.CSSProperties = {
height: '160px', height: '160px',
color: '#fff', color: '#fff',
lineHeight: '160px', lineHeight: '160px',
@ -24,7 +25,7 @@ const contentStyle = {
background: '#364d79', background: '#364d79',
}; };
export default () => ( const App: React.FC = () => (
<Carousel autoplay> <Carousel autoplay>
<div> <div>
<h3 style={contentStyle}>1</h3> <h3 style={contentStyle}>1</h3>
@ -40,4 +41,6 @@ export default () => (
</div> </div>
</Carousel> </Carousel>
); );
export default App;
``` ```

View File

@ -13,14 +13,11 @@ title:
Basic usage. Basic usage.
```jsx ```tsx
import { Carousel } from 'antd'; import { Carousel } from 'antd';
import React from 'react';
function onChange(a, b, c) { const contentStyle: React.CSSProperties = {
console.log(a, b, c);
}
const contentStyle = {
height: '160px', height: '160px',
color: '#fff', color: '#fff',
lineHeight: '160px', lineHeight: '160px',
@ -28,7 +25,12 @@ const contentStyle = {
background: '#364d79', background: '#364d79',
}; };
export default () => ( const App: React.FC = () => {
const onChange = (currentSlide: number) => {
console.log(currentSlide);
};
return (
<Carousel afterChange={onChange}> <Carousel afterChange={onChange}>
<div> <div>
<h3 style={contentStyle}>1</h3> <h3 style={contentStyle}>1</h3>
@ -43,5 +45,8 @@ export default () => (
<h3 style={contentStyle}>4</h3> <h3 style={contentStyle}>4</h3>
</div> </div>
</Carousel> </Carousel>
); );
};
export default App;
``` ```

View File

@ -13,10 +13,11 @@ title:
Slides use fade for transition. Slides use fade for transition.
```jsx ```tsx
import { Carousel } from 'antd'; import { Carousel } from 'antd';
import React from 'react';
const contentStyle = { const contentStyle: React.CSSProperties = {
height: '160px', height: '160px',
color: '#fff', color: '#fff',
lineHeight: '160px', lineHeight: '160px',
@ -24,7 +25,7 @@ const contentStyle = {
background: '#364d79', background: '#364d79',
}; };
export default () => ( const App: React.FC = () => (
<Carousel effect="fade"> <Carousel effect="fade">
<div> <div>
<h3 style={contentStyle}>1</h3> <h3 style={contentStyle}>1</h3>
@ -40,4 +41,6 @@ export default () => (
</div> </div>
</Carousel> </Carousel>
); );
export default App;
``` ```

View File

@ -13,10 +13,13 @@ title:
There are 4 position options available. There are 4 position options available.
```jsx ```tsx
import type { RadioChangeEvent } from 'antd';
import { Carousel, Radio } from 'antd'; import { Carousel, Radio } from 'antd';
import type { DotPosition } from 'antd/lib/carousel';
import React, { useState } from 'react';
const contentStyle = { const contentStyle: React.CSSProperties = {
height: '160px', height: '160px',
color: '#fff', color: '#fff',
lineHeight: '160px', lineHeight: '160px',
@ -24,10 +27,10 @@ const contentStyle = {
background: '#364d79', background: '#364d79',
}; };
const PositionCarouselDemo = () => { const App: React.FC = () => {
const [dotPosition, setDotPosition] = React.useState('top'); const [dotPosition, setDotPosition] = useState<DotPosition>('top');
const handlePositionChange = ({ target: { value } }) => { const handlePositionChange = ({ target: { value } }: RadioChangeEvent) => {
setDotPosition(value); setDotPosition(value);
}; };
@ -57,5 +60,5 @@ const PositionCarouselDemo = () => {
); );
}; };
export default () => <PositionCarouselDemo />; export default App;
``` ```

View File

@ -13,10 +13,17 @@ title:
Cascade selection box for selecting province/city/district. Cascade selection box for selecting province/city/district.
```jsx ```tsx
import { Cascader } from 'antd'; import { Cascader } from 'antd';
import React from 'react';
const options = [ interface Option {
value: string | number;
label: string;
children?: Option[];
}
const options: Option[] = [
{ {
value: 'zhejiang', value: 'zhejiang',
label: 'Zhejiang', label: 'Zhejiang',
@ -51,9 +58,13 @@ const options = [
}, },
]; ];
function onChange(value) { const onChange = (value: string[]) => {
console.log(value); console.log(value);
} };
export default () => <Cascader options={options} onChange={onChange} placeholder="Please select" />; const App: React.FC = () => (
<Cascader options={options} onChange={onChange} placeholder="Please select" />
);
export default App;
``` ```

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