Merge remote-tracking branch 'upstream/feature' into feat-anchor-getCurrentAnchor

This commit is contained in:
shao 2019-07-23 18:10:44 +08:00
commit ab796e60dd
46 changed files with 7128 additions and 1302 deletions

View File

@ -7,6 +7,7 @@ import KeyCode from 'rc-util/lib/KeyCode';
interface TransButtonProps extends React.HTMLAttributes<HTMLDivElement> { interface TransButtonProps extends React.HTMLAttributes<HTMLDivElement> {
onClick?: (e?: React.MouseEvent<HTMLDivElement>) => void; onClick?: (e?: React.MouseEvent<HTMLDivElement>) => void;
noStyle?: boolean;
} }
const inlineStyle: React.CSSProperties = { const inlineStyle: React.CSSProperties = {
@ -53,7 +54,8 @@ class TransButton extends React.Component<TransButtonProps> {
} }
render() { render() {
const { style } = this.props; const { style, noStyle } = this.props;
return ( return (
<div <div
role="button" role="button"
@ -62,7 +64,7 @@ class TransButton extends React.Component<TransButtonProps> {
{...this.props} {...this.props}
onKeyDown={this.onKeyDown} onKeyDown={this.onKeyDown}
onKeyUp={this.onKeyUp} onKeyUp={this.onKeyUp}
style={{ ...inlineStyle, ...style }} style={{ ...(!noStyle ? inlineStyle : null), ...style }}
/> />
); );
} }

View File

@ -0,0 +1,2 @@
import ms_MY from '../../date-picker/locale/ms_MY';
export default ms_MY;

View File

@ -35,6 +35,6 @@ cols: 1
| disabled | 禁用后的面板展开与否将无法通过用户交互改变 | boolean | false | | | disabled | 禁用后的面板展开与否将无法通过用户交互改变 | boolean | false | |
| forceRender | 被隐藏时是否渲染 DOM 结构 | boolean | false | 3.2.0 | | forceRender | 被隐藏时是否渲染 DOM 结构 | boolean | false | 3.2.0 |
| header | 面板头内容 | string\|ReactNode | 无 | | | header | 面板头内容 | string\|ReactNode | 无 | |
| key | 对应 activeKey | string\|number | 无 | | | key | 对应 activeKey | string\|number | 无 | |
| showArrow | 是否展示当前面板上的箭头 | boolean | `true` | 3.13.0 | | showArrow | 是否展示当前面板上的箭头 | boolean | `true` | 3.13.0 |
| extra | 自定义渲染每个面板右上角的内容 | ReactNode | - | 3.14.0 | | extra | 自定义渲染每个面板右上角的内容 | ReactNode | - | 3.14.0 |

View File

@ -0,0 +1,19 @@
import CalendarLocale from 'rc-calendar/lib/locale/ms_MY';
import TimePickerLocale from '../../time-picker/locale/ms_MY';
// Merge into a locale object
const locale = {
lang: {
placeholder: 'Pilih tarikh',
rangePlaceholder: ['Tarikh mula', 'Tarikh akhir'],
...CalendarLocale,
},
timePickerLocale: {
...TimePickerLocale,
},
};
// All settings at:
// https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json
export default locale;

View File

@ -0,0 +1,72 @@
import * as React from 'react';
import classNames from 'classnames';
import { DescriptionsItemProps } from './index';
interface ColProps {
child: React.ReactElement<DescriptionsItemProps>;
bordered: boolean;
colon: boolean;
type?: 'label' | 'content';
layout?: 'horizontal' | 'vertical';
}
const Col: React.SFC<ColProps> = props => {
const { child, bordered, colon, type, layout } = props;
const { prefixCls, label, className, children, span = 1 } = child.props;
const labelProps: any = {
className: classNames(`${prefixCls}-item-label`, className, {
[`${prefixCls}-item-colon`]: colon,
[`${prefixCls}-item-no-label`]: !label,
}),
key: 'label',
};
if (layout === 'vertical') {
labelProps.colSpan = span * 2 - 1;
}
if (bordered) {
if (type === 'label') {
return <th {...labelProps}>{label}</th>;
}
return (
<td
className={classNames(`${prefixCls}-item-content`, className)}
key="content"
colSpan={span * 2 - 1}
>
{children}
</td>
);
}
if (layout === 'vertical') {
if (type === 'content') {
return (
<td colSpan={span} className={classNames(`${prefixCls}-item`, className)}>
<span className={`${prefixCls}-item-content`} key="content">
{children}
</span>
</td>
);
}
return (
<td colSpan={span} className={classNames(`${prefixCls}-item`, className)}>
<span
className={classNames(`${prefixCls}-item-label`, { [`${prefixCls}-item-colon`]: colon })}
key="label"
>
{label}
</span>
</td>
);
}
return (
<td colSpan={span} className={classNames(`${prefixCls}-item`, className)}>
<span {...labelProps}>{label}</span>
<span className={`${prefixCls}-item-content`} key="content">
{children}
</span>
</td>
);
};
export default Col;

View File

@ -22,7 +22,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
UserName UserName
</span> </span>
@ -37,7 +37,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Telephone Telephone
</span> </span>
@ -52,7 +52,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Live Live
</span> </span>
@ -71,7 +71,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Remark Remark
</span> </span>
@ -86,7 +86,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `
colspan="2" colspan="2"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Address Address
</span> </span>
@ -121,7 +121,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Product Product
</th> </th>
@ -132,7 +132,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
Cloud Database Cloud Database
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Billing Mode Billing Mode
</th> </th>
@ -143,7 +143,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
Prepaid Prepaid
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Automatic Renewal Automatic Renewal
</th> </th>
@ -158,7 +158,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Order time Order time
</th> </th>
@ -169,7 +169,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
2018-04-24 18:00:00 2018-04-24 18:00:00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Usage Time Usage Time
</th> </th>
@ -184,7 +184,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Status Status
</th> </th>
@ -210,7 +210,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Negotiated Amount Negotiated Amount
</th> </th>
@ -221,7 +221,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
$80.00 $80.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Discount Discount
</th> </th>
@ -232,7 +232,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
$20.00 $20.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Official Receipts Official Receipts
</th> </th>
@ -247,7 +247,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Config Info Config Info
</th> </th>
@ -294,7 +294,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Product Product
</th> </th>
@ -305,7 +305,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
Cloud Database Cloud Database
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Billing Billing
</th> </th>
@ -316,7 +316,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
Prepaid Prepaid
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
time time
</th> </th>
@ -331,7 +331,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Amount Amount
</th> </th>
@ -342,7 +342,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
$80.00 $80.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Discount Discount
</th> </th>
@ -353,7 +353,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
$20.00 $20.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Official Official
</th> </th>
@ -368,7 +368,7 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Config Info Config Info
</th> </th>
@ -479,7 +479,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Product Product
</th> </th>
@ -490,7 +490,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
Cloud Database Cloud Database
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Billing Billing
</th> </th>
@ -501,7 +501,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
Prepaid Prepaid
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
time time
</th> </th>
@ -516,7 +516,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Amount Amount
</th> </th>
@ -527,7 +527,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
$80.00 $80.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Discount Discount
</th> </th>
@ -538,7 +538,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
$20.00 $20.00
</td> </td>
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Official Official
</th> </th>
@ -553,7 +553,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<th <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Config Info Config Info
</th> </th>
@ -604,7 +604,7 @@ exports[`renders ./components/descriptions/demo/vertical.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
UserName UserName
</span> </span>
@ -614,7 +614,7 @@ exports[`renders ./components/descriptions/demo/vertical.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Telephone Telephone
</span> </span>
@ -624,7 +624,7 @@ exports[`renders ./components/descriptions/demo/vertical.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Live Live
</span> </span>
@ -672,7 +672,7 @@ exports[`renders ./components/descriptions/demo/vertical.md correctly 1`] = `
colspan="1" colspan="1"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Remark Remark
</span> </span>
@ -682,7 +682,7 @@ exports[`renders ./components/descriptions/demo/vertical.md correctly 1`] = `
colspan="2" colspan="2"
> >
<span <span
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
> >
Address Address
</span> </span>
@ -735,24 +735,24 @@ exports[`renders ./components/descriptions/demo/vertical-border.md correctly 1`]
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Product Product
</td> </th>
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Billing Mode Billing Mode
</td> </th>
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Automatic Renewal Automatic Renewal
</td> </th>
</tr> </tr>
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
@ -779,18 +779,18 @@ exports[`renders ./components/descriptions/demo/vertical-border.md correctly 1`]
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Order time Order time
</td> </th>
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="5" colspan="5"
> >
Usage Time Usage Time
</td> </th>
</tr> </tr>
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
@ -811,12 +811,12 @@ exports[`renders ./components/descriptions/demo/vertical-border.md correctly 1`]
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="5" colspan="5"
> >
Status Status
</td> </th>
</tr> </tr>
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
@ -842,24 +842,24 @@ exports[`renders ./components/descriptions/demo/vertical-border.md correctly 1`]
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Negotiated Amount Negotiated Amount
</td> </th>
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Discount Discount
</td> </th>
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="1" colspan="1"
> >
Official Receipts Official Receipts
</td> </th>
</tr> </tr>
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
@ -886,12 +886,12 @@ exports[`renders ./components/descriptions/demo/vertical-border.md correctly 1`]
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"
> >
<td <th
class="ant-descriptions-item-label" class="ant-descriptions-item-label ant-descriptions-item-colon"
colspan="5" colspan="5"
> >
Config Info Config Info
</td> </th>
</tr> </tr>
<tr <tr
class="ant-descriptions-row" class="ant-descriptions-row"

View File

@ -1,5 +1,74 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Descriptions Descriptions support colon 1`] = `
<Descriptions
colon={false}
column={
Object {
"lg": 3,
"md": 3,
"sm": 2,
"xl": 3,
"xs": 1,
"xxl": 3,
}
}
size="default"
>
<div
className="ant-descriptions"
>
<div
className="ant-descriptions-view"
>
<table>
<tbody>
<tr
className="ant-descriptions-row"
key="0"
>
<Col
bordered={false}
child={
<DescriptionsItem
label="Product"
prefixCls="ant-descriptions"
span={1}
>
Cloud Database
</DescriptionsItem>
}
colon={false}
key="label-0"
layout="horizontal"
type="label"
>
<td
className="ant-descriptions-item"
colSpan={1}
>
<span
className="ant-descriptions-item-label"
key="label"
>
Product
</span>
<span
className="ant-descriptions-item-content"
key="content"
>
Cloud Database
</span>
</td>
</Col>
</tr>
</tbody>
</table>
</div>
</div>
</Descriptions>
`;
exports[`Descriptions Descriptions support style 1`] = ` exports[`Descriptions Descriptions support style 1`] = `
<Descriptions <Descriptions
column={ column={
@ -36,21 +105,37 @@ exports[`Descriptions Descriptions support style 1`] = `
className="ant-descriptions-row" className="ant-descriptions-row"
key="0" key="0"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
prefixCls="ant-descriptions"
span={1}
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label ant-descriptions-item-no-label" className="ant-descriptions-item"
key="label" colSpan={1}
/>
<span
className="ant-descriptions-item-content"
key="content"
> >
Cloud Database <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon ant-descriptions-item-no-label"
</td> key="label"
/>
<span
className="ant-descriptions-item-content"
key="content"
>
Cloud Database
</span>
</td>
</Col>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -85,23 +170,41 @@ exports[`Descriptions Descriptions.Item support className 1`] = `
className="ant-descriptions-row" className="ant-descriptions-row"
key="0" key="0"
> >
<td <Col
className="ant-descriptions-item my-class" bordered={false}
colSpan={1} child={
<DescriptionsItem
className="my-class"
label="Product"
prefixCls="ant-descriptions"
span={1}
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item my-class"
key="label" colSpan={1}
> >
Product <span
</span> className="ant-descriptions-item-label my-class ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Product
> </span>
Cloud Database <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
Cloud Database
</span>
</td>
</Col>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -127,81 +230,144 @@ exports[`Descriptions column is number 1`] = `
className="ant-descriptions-row" className="ant-descriptions-row"
key="0" key="0"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
key=".$.0" <DescriptionsItem
label="Product"
prefixCls="ant-descriptions"
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Product <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Product
> </span>
Cloud Database <span
</span> className="ant-descriptions-item-content"
</td> key="content"
<td >
className="ant-descriptions-item" Cloud Database
colSpan={1} </span>
key=".$.1" </td>
</Col>
<Col
bordered={false}
child={
<DescriptionsItem
label="Billing"
prefixCls="ant-descriptions"
>
Prepaid
</DescriptionsItem>
}
colon={true}
key="label-1"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Billing <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Billing
> </span>
Prepaid <span
</span> className="ant-descriptions-item-content"
</td> key="content"
<td >
className="ant-descriptions-item" Prepaid
colSpan={1} </span>
</td>
</Col>
<Col
bordered={false}
child={
<DescriptionsItem
label="time"
prefixCls="ant-descriptions"
>
18:00:00
</DescriptionsItem>
}
colon={true}
key="label-2"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
time <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" time
> </span>
18:00:00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
18:00:00
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="1" key="1"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={3} child={
<DescriptionsItem
label="Amount"
prefixCls="ant-descriptions"
span={3}
>
$80.00
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={3}
> >
Amount <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Amount
> </span>
$80.00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
$80.00
</span>
</td>
</Col>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -237,129 +403,259 @@ exports[`Descriptions vertical layout 1`] = `
className="ant-descriptions-row" className="ant-descriptions-row"
key="label-0" key="label-0"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Product"
prefixCls="ant-descriptions"
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="vertical"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Product <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
</td> key="label"
>
Product
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="content-0" key="content-0"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Product"
prefixCls="ant-descriptions"
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="content-0"
layout="vertical"
type="content"
> >
<span <td
className="ant-descriptions-item-content" className="ant-descriptions-item"
key="content" colSpan={1}
> >
Cloud Database <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
Cloud Database
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="label-1" key="label-1"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Billing"
prefixCls="ant-descriptions"
>
Prepaid
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="vertical"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Billing <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
</td> key="label"
>
Billing
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="content-1" key="content-1"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Billing"
prefixCls="ant-descriptions"
>
Prepaid
</DescriptionsItem>
}
colon={true}
key="content-0"
layout="vertical"
type="content"
> >
<span <td
className="ant-descriptions-item-content" className="ant-descriptions-item"
key="content" colSpan={1}
> >
Prepaid <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
Prepaid
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="label-2" key="label-2"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="time"
prefixCls="ant-descriptions"
>
18:00:00
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="vertical"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
time <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
</td> key="label"
>
time
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="content-2" key="content-2"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="time"
prefixCls="ant-descriptions"
>
18:00:00
</DescriptionsItem>
}
colon={true}
key="content-0"
layout="vertical"
type="content"
> >
<span <td
className="ant-descriptions-item-content" className="ant-descriptions-item"
key="content" colSpan={1}
> >
18:00:00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
18:00:00
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="label-3" key="label-3"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Amount"
prefixCls="ant-descriptions"
span={1}
>
$80.00
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="vertical"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Amount <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
</td> key="label"
>
Amount
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="content-3" key="content-3"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Amount"
prefixCls="ant-descriptions"
span={1}
>
$80.00
</DescriptionsItem>
}
colon={true}
key="content-0"
layout="vertical"
type="content"
> >
<span <td
className="ant-descriptions-item-content" className="ant-descriptions-item"
key="content" colSpan={1}
> >
$80.00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
$80.00
</span>
</td>
</Col>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -394,89 +690,154 @@ exports[`Descriptions when item is rendered conditionally 1`] = `
className="ant-descriptions-row" className="ant-descriptions-row"
key="0" key="0"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Product"
prefixCls="ant-descriptions"
>
Cloud Database
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Product <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Product
> </span>
Cloud Database <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
Cloud Database
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="1" key="1"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Billing"
prefixCls="ant-descriptions"
>
Prepaid
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Billing <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Billing
> </span>
Prepaid <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
Prepaid
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="2" key="2"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="time"
prefixCls="ant-descriptions"
>
18:00:00
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
time <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" time
> </span>
18:00:00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
18:00:00
</span>
</td>
</Col>
</tr> </tr>
<tr <tr
className="ant-descriptions-row" className="ant-descriptions-row"
key="3" key="3"
> >
<td <Col
className="ant-descriptions-item" bordered={false}
colSpan={1} child={
<DescriptionsItem
label="Amount"
prefixCls="ant-descriptions"
span={1}
>
$80.00
</DescriptionsItem>
}
colon={true}
key="label-0"
layout="horizontal"
type="label"
> >
<span <td
className="ant-descriptions-item-label" className="ant-descriptions-item"
key="label" colSpan={1}
> >
Amount <span
</span> className="ant-descriptions-item-label ant-descriptions-item-colon"
<span key="label"
className="ant-descriptions-item-content" >
key="content" Amount
> </span>
$80.00 <span
</span> className="ant-descriptions-item-content"
</td> key="content"
>
$80.00
</span>
</td>
</Col>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -152,6 +152,15 @@ describe('Descriptions', () => {
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
}); });
it('Descriptions support colon', () => {
const wrapper = mount(
<Descriptions colon={false}>
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
</Descriptions>,
);
expect(wrapper).toMatchSnapshot();
});
it('Descriptions support style', () => { it('Descriptions support style', () => {
const wrapper = mount( const wrapper = mount(
<Descriptions style={{ backgroundColor: '#e8e8e8' }}> <Descriptions style={{ backgroundColor: '#e8e8e8' }}>

View File

@ -22,6 +22,7 @@ Commonly displayed on the details page.
| column | the number of `DescriptionItems` in a row,could be a number or a object like `{ xs: 8, sm: 16, md: 24}`,(Only set `bordered={true}` to take effect) | number | 3 | 3.19.0 | | column | the number of `DescriptionItems` in a row,could be a number or a object like `{ xs: 8, sm: 16, md: 24}`,(Only set `bordered={true}` to take effect) | number | 3 | 3.19.0 |
| size | set the size of the list. Can be set to `middle`,`small`, or not filled | `default | middle | small` | false | 3.19.0 | | size | set the size of the list. Can be set to `middle`,`small`, or not filled | `default | middle | small` | false | 3.19.0 |
| layout | Define description layout | `horizontal | vertical` | `horizontal` | 3.19.8 | | layout | Define description layout | `horizontal | vertical` | `horizontal` | 3.19.8 |
| colon | change default props `colon` value of `Descriptions.Item` | boolean | true | 3.21.0 |
### DescriptionItem ### DescriptionItem

View File

@ -7,6 +7,7 @@ import ResponsiveObserve, {
responsiveArray, responsiveArray,
} from '../_util/responsiveObserve'; } from '../_util/responsiveObserve';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import Col from './Col';
export interface DescriptionsItemProps { export interface DescriptionsItemProps {
prefixCls?: string; prefixCls?: string;
@ -29,6 +30,7 @@ export interface DescriptionsProps {
title?: React.ReactNode; title?: React.ReactNode;
column?: number | Partial<Record<Breakpoint, number>>; column?: number | Partial<Record<Breakpoint, number>>;
layout?: 'horizontal' | 'vertical'; layout?: 'horizontal' | 'vertical';
colon?: boolean;
} }
/** /**
@ -69,96 +71,13 @@ const generateChildrenRows = (
return childrenArray; return childrenArray;
}; };
/**
* This code is for handling react15 does not support returning an array,
* It can convert a children into th and td
* @param child DescriptionsItem
* @returns
* <>
* <th>{DescriptionsItem.label}</th>
* <td>{DescriptionsItem.children}</td>
* </>
*/
const renderCol = (child: React.ReactElement<DescriptionsItemProps>, bordered: boolean) => {
const { prefixCls, label, className, children, span = 1 } = child.props;
if (bordered) {
return [
<th
className={classNames(`${prefixCls}-item-label`, className, {
[`${prefixCls}-item-no-label`]: !label,
})}
key="label"
>
{label}
</th>,
<td
className={classNames(`${prefixCls}-item-content`, className)}
key="content"
colSpan={span * 2 - 1}
>
{children}
</td>,
];
}
return (
<td colSpan={span} className={classNames(`${prefixCls}-item`, className)}>
<span
className={classNames(`${prefixCls}-item-label`, {
[`${prefixCls}-item-no-label`]: !label,
})}
key="label"
>
{label}
</span>
<span className={`${prefixCls}-item-content`} key="content">
{children}
</span>
</td>
);
};
const renderLabelCol = (child: React.ReactElement<DescriptionsItemProps>, bordered: boolean) => {
const { prefixCls, label, span = 1 } = child.props;
if (bordered) {
return (
<td className={`${prefixCls}-item-label`} key="label" colSpan={span * 2 - 1}>
{label}
</td>
);
}
return (
<td colSpan={span} className={`${prefixCls}-item`}>
<span className={`${prefixCls}-item-label`} key="label">
{label}
</span>
</td>
);
};
const renderContentCol = (child: React.ReactElement<DescriptionsItemProps>, bordered: boolean) => {
const { prefixCls, children, span = 1 } = child.props;
if (bordered) {
return (
<td className={`${prefixCls}-item-content`} key="content" colSpan={span * 2 - 1}>
{children}
</td>
);
}
return (
<td colSpan={span} className={`${prefixCls}-item`}>
<span className={`${prefixCls}-item-content`} key="content">
{children}
</span>
</td>
);
};
const renderRow = ( const renderRow = (
children: React.ReactElement<DescriptionsItemProps>[], children: React.ReactElement<DescriptionsItemProps>[],
index: number, index: number,
{ prefixCls, column, isLast }: { prefixCls: string; column: number; isLast: boolean }, { prefixCls, column, isLast }: { prefixCls: string; column: number; isLast: boolean },
bordered: boolean, bordered: boolean,
layout: string, layout: 'horizontal' | 'vertical',
colon: boolean,
) => { ) => {
// copy children,prevent changes to incoming parameters // copy children,prevent changes to incoming parameters
const childrenArray = [...children]; const childrenArray = [...children];
@ -169,41 +88,51 @@ const renderRow = (
span, span,
}); });
} }
childrenArray.push(lastChildren);
const renderCol = (
childrenItem: React.ReactElement<DescriptionsItemProps>,
type: 'label' | 'content',
idx: number,
) => (
<Col
child={childrenItem}
bordered={bordered}
colon={colon}
type={type}
key={`${type}-${idx}`}
layout={layout}
/>
);
const cloneChildren: JSX.Element[] = [];
const cloneContentChildren: JSX.Element[] = [];
React.Children.forEach(
childrenArray,
(childrenItem: React.ReactElement<DescriptionsItemProps>, idx: number) => {
cloneChildren.push(renderCol(childrenItem, 'label', idx));
if (layout === 'vertical') {
cloneContentChildren.push(renderCol(childrenItem, 'content', idx));
} else if (bordered) {
cloneChildren.push(renderCol(childrenItem, 'content', idx));
}
},
);
if (layout === 'vertical') { if (layout === 'vertical') {
const cloneLabelChildren = React.Children.map(
childrenArray,
(childrenItem: React.ReactElement<DescriptionsItemProps>) => {
return renderLabelCol(childrenItem, bordered);
},
);
const cloneContentChildren = React.Children.map(
childrenArray,
(childrenItem: React.ReactElement<DescriptionsItemProps>) => {
return renderContentCol(childrenItem, bordered);
},
);
return [ return [
<tr className={`${prefixCls}-row`} key={`label-${index}`}> <tr className={`${prefixCls}-row`} key={`label-${index}`}>
{cloneLabelChildren} {cloneChildren}
{renderLabelCol(lastChildren, bordered)}
</tr>, </tr>,
<tr className={`${prefixCls}-row`} key={`content-${index}`}> <tr className={`${prefixCls}-row`} key={`content-${index}`}>
{cloneContentChildren} {cloneContentChildren}
{renderContentCol(lastChildren, bordered)}
</tr>, </tr>,
]; ];
} }
const cloneChildren = React.Children.map(
childrenArray,
(childrenItem: React.ReactElement<DescriptionsItemProps>) => {
return renderCol(childrenItem, bordered);
},
);
return ( return (
<tr className={`${prefixCls}-row`} key={index}> <tr className={`${prefixCls}-row`} key={index}>
{cloneChildren} {cloneChildren}
{renderCol(lastChildren, bordered)}
</tr> </tr>
); );
}; };
@ -281,6 +210,7 @@ class Descriptions extends React.Component<
children, children,
bordered = false, bordered = false,
layout = 'horizontal', layout = 'horizontal',
colon = true,
style, style,
} = this.props; } = this.props;
const prefixCls = getPrefixCls('descriptions', customizePrefixCls); const prefixCls = getPrefixCls('descriptions', customizePrefixCls);
@ -324,6 +254,7 @@ class Descriptions extends React.Component<
}, },
bordered, bordered,
layout, layout,
colon,
), ),
)} )}
</tbody> </tbody>

View File

@ -23,6 +23,7 @@ cols: 1
| column | 一行的 `DescriptionItems` 数量,可以写成像素值或支持响应式的对象写法 `{ xs: 8, sm: 16, md: 24}` | number | 3 | 3.19.0 | | column | 一行的 `DescriptionItems` 数量,可以写成像素值或支持响应式的对象写法 `{ xs: 8, sm: 16, md: 24}` | number | 3 | 3.19.0 |
| size | 设置列表的大小。可以设置为 `middle` 、`small`, 或不填(只有设置 `bordered={true}` 生效) | `default | middle | small` | false | 3.19.0 | | size | 设置列表的大小。可以设置为 `middle` 、`small`, 或不填(只有设置 `bordered={true}` 生效) | `default | middle | small` | false | 3.19.0 |
| layout | 描述布局 | `horizontal | vertical` | `horizontal` | 3.19.8 | | layout | 描述布局 | `horizontal | vertical` | `horizontal` | 3.19.8 |
| colon | 配置 `Descriptions.Item``colon` 的默认值 | boolean | true | 3.21.0 |
### DescriptionItem ### DescriptionItem

View File

@ -47,6 +47,12 @@
position: relative; position: relative;
top: -0.5px; top: -0.5px;
margin: 0 8px 0 2px; margin: 0 8px 0 2px;
content: ' ';
}
}
&-item-colon {
&::after {
content: ':'; content: ':';
} }
} }

View File

@ -41,6 +41,7 @@ import knIN from '../kn_IN';
import koKR from '../ko_KR'; import koKR from '../ko_KR';
import kuIQ from '../ku_IQ'; import kuIQ from '../ku_IQ';
import mnMN from '../mn_MN'; import mnMN from '../mn_MN';
import msMY from '../ms_MY';
import nbNO from '../nb_NO'; import nbNO from '../nb_NO';
import neNP from '../ne-NP'; import neNP from '../ne-NP';
import nlBE from '../nl_BE'; import nlBE from '../nl_BE';
@ -87,6 +88,7 @@ const locales = [
knIN, knIN,
koKR, koKR,
kuIQ, kuIQ,
msMY,
mnMN, mnMN,
nbNO, nbNO,
neNP, neNP,

View File

@ -19,6 +19,8 @@ export default {
selectAll: 'Select current page', selectAll: 'Select current page',
selectInvert: 'Invert current page', selectInvert: 'Invert current page',
sortTitle: 'Sort', sortTitle: 'Sort',
expand: 'Expand row',
collapse: 'Collapse row',
}, },
Modal: { Modal: {
okText: 'OK', okText: 'OK',

View File

@ -31,4 +31,10 @@ export default {
Empty: { Empty: {
description: 'Aucune donnée', description: 'Aucune donnée',
}, },
Text: {
edit: 'éditer',
copy: 'copier',
copied: 'copie effectuée',
expand: 'développer',
},
}; };

View File

@ -31,4 +31,10 @@ export default {
Empty: { Empty: {
description: 'Aucune donnée', description: 'Aucune donnée',
}, },
Text: {
edit: 'éditer',
copy: 'copier',
copied: 'copie effectuée',
expand: 'développer',
},
}; };

View File

@ -0,0 +1,62 @@
import Pagination from 'rc-pagination/lib/locale/ms_MY';
import DatePicker from '../date-picker/locale/ms_MY';
import TimePicker from '../time-picker/locale/ms_MY';
import Calendar from '../calendar/locale/ms_MY';
export default {
locale: 'ms-my',
Pagination,
DatePicker,
TimePicker,
Calendar,
global: {
placeholder: 'Sila pilih',
},
PageHeader: {
back: 'Kembali',
},
Text: {
edit: 'Sunting',
copy: 'Salin',
copied: 'Berjaya menyalin',
expand: 'Kembang',
},
Empty: {
description: 'Tiada data',
},
Table: {
filterTitle: 'Cari dengan tajuk',
filterConfirm: 'Ok',
filterReset: 'Menetapkan semula',
emptyText: 'Tiada data',
selectAll: 'Pilih semua',
selectInvert: 'Terbalikkan',
},
Modal: {
okText: 'OK',
cancelText: 'Batal',
justOkText: 'OK',
},
Popconfirm: {
okText: 'OK',
cancelText: 'Batal',
},
Transfer: {
notFoundContent: 'Tidak dijumpai',
searchPlaceholder: 'Carian di sini',
itemUnit: 'item',
itemsUnit: 'item',
},
Icon: {
icon: 'ikon',
},
Select: {
notFoundContent: 'Tidak Dijumpai',
},
Upload: {
uploading: 'Sedang memuat naik...',
removeFile: 'Buang fail',
uploadError: 'Masalah muat naik',
previewFile: 'Tengok fail',
},
};

View File

@ -20,6 +20,8 @@ export default {
selectAll: '全选当页', selectAll: '全选当页',
selectInvert: '反选当页', selectInvert: '反选当页',
sortTitle: '排序', sortTitle: '排序',
expand: '展开行',
collapse: '关闭行',
}, },
Modal: { Modal: {
okText: '确定', okText: '确定',

View File

@ -16,12 +16,12 @@ More layouts with navigation: [layout](/components/layout).
## API ## API
```html ```html
<Menu> <menu>
<Menu.Item>Menu</Menu.Item> <Menu.Item>Menu</Menu.Item>
<SubMenu title="SubMenu"> <SubMenu title="SubMenu">
<Menu.Item>SubMenuItem</Menu.Item> <Menu.Item>SubMenuItem</Menu.Item>
</SubMenu> </SubMenu>
</Menu> </menu>
``` ```
### Menu ### Menu

View File

@ -17,12 +17,12 @@ subtitle: 导航菜单
## API ## API
```html ```html
<Menu> <menu>
<Menu.Item>菜单项</Menu.Item> <Menu.Item>菜单项</Menu.Item>
<SubMenu title="子菜单"> <SubMenu title="子菜单">
<Menu.Item>子菜单项</Menu.Item> <Menu.Item>子菜单项</Menu.Item>
</SubMenu> </SubMenu>
</Menu> </menu>
``` ```
### Menu ### Menu

View File

@ -160,7 +160,7 @@
.@{iconfont-css-prefix} { .@{iconfont-css-prefix} {
min-width: 14px; min-width: 14px;
margin-right: 10px; margin-right: 10px;
font-size: @font-size-base; font-size: @menu-icon-size;
transition: font-size 0.15s @ease-out, margin 0.3s @ease-in-out; transition: font-size 0.15s @ease-out, margin 0.3s @ease-in-out;
+ span { + span {
opacity: 1; opacity: 1;
@ -418,7 +418,7 @@
} }
.@{iconfont-css-prefix} { .@{iconfont-css-prefix} {
margin: 0; margin: 0;
font-size: 16px; font-size: @menu-icon-size-lg;
line-height: @menu-item-height; line-height: @menu-item-height;
+ span { + span {
display: inline-block; display: inline-block;

View File

@ -384,6 +384,8 @@
@menu-item-active-bg: @item-active-bg; @menu-item-active-bg: @item-active-bg;
@menu-item-active-border-width: 3px; @menu-item-active-border-width: 3px;
@menu-item-group-title-color: @text-color-secondary; @menu-item-group-title-color: @text-color-secondary;
@menu-icon-size: @font-size-base;
@menu-icon-size-lg: @font-size-lg;
// dark theme // dark theme
@menu-dark-color: @text-color-secondary-dark; @menu-dark-color: @text-color-secondary-dark;

View File

@ -30,11 +30,13 @@ import {
TableRowSelection, TableRowSelection,
PaginationConfig, PaginationConfig,
PrepareParamsArgumentsReturn, PrepareParamsArgumentsReturn,
ExpandIconProps,
} from './interface'; } from './interface';
import Pagination from '../pagination'; import Pagination from '../pagination';
import Icon from '../icon'; import Icon from '../icon';
import Spin, { SpinProps } from '../spin'; import Spin, { SpinProps } from '../spin';
import { RadioChangeEvent } from '../radio'; import { RadioChangeEvent } from '../radio';
import TransButton from '../_util/transButton';
import { CheckboxChangeEvent } from '../checkbox'; import { CheckboxChangeEvent } from '../checkbox';
import LocaleReceiver from '../locale-provider/LocaleReceiver'; import LocaleReceiver from '../locale-provider/LocaleReceiver';
import defaultLocale from '../locale-provider/default'; import defaultLocale from '../locale-provider/default';
@ -83,6 +85,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
locale: PropTypes.object, locale: PropTypes.object,
dropdownPrefixCls: PropTypes.string, dropdownPrefixCls: PropTypes.string,
sortDirections: PropTypes.array, sortDirections: PropTypes.array,
getPopupContainer: PropTypes.func,
}; };
static defaultProps = { static defaultProps = {
@ -760,18 +763,24 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
return recordKey === undefined ? index : recordKey; return recordKey === undefined ? index : recordKey;
}; };
getPopupContainer = () => { generatePopupContainerFunc = (getPopupContainer: TableProps<T>['getPopupContainer']) => {
return ReactDOM.findDOMNode(this) as HTMLElement;
};
generatePopupContainerFunc = () => {
const { scroll } = this.props; const { scroll } = this.props;
if (getPopupContainer) {
return getPopupContainer;
}
// Use undefined to let rc component use default logic. // Use undefined to let rc component use default logic.
return scroll ? this.getPopupContainer : undefined; return scroll ? () => ReactDOM.findDOMNode(this) as HTMLElement : undefined;
}; };
renderRowSelection(prefixCls: string, locale: TableLocale) { renderRowSelection({
prefixCls,
locale,
getPopupContainer,
}: {
prefixCls: string;
locale: TableLocale;
getPopupContainer: TableProps<T>['getPopupContainer'];
}) {
const { rowSelection } = this.props; const { rowSelection } = this.props;
const columns = this.columns.concat(); const columns = this.columns.concat();
if (rowSelection) { if (rowSelection) {
@ -811,7 +820,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
onSelect={this.handleSelectRow} onSelect={this.handleSelectRow}
selections={rowSelection.selections} selections={rowSelection.selections}
hideDefaultSelections={rowSelection.hideDefaultSelections} hideDefaultSelections={rowSelection.hideDefaultSelections}
getPopupContainer={this.generatePopupContainerFunc()} getPopupContainer={this.generatePopupContainerFunc(getPopupContainer)}
/> />
); );
} }
@ -851,12 +860,19 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
return this.getColumnKey(sortColumn) === this.getColumnKey(column); return this.getColumnKey(sortColumn) === this.getColumnKey(column);
} }
renderColumnsDropdown( renderColumnsDropdown({
prefixCls: string, prefixCls,
dropdownPrefixCls: string, dropdownPrefixCls,
columns: ColumnProps<T>[], columns,
locale: TableLocale, locale,
) { getPopupContainer,
}: {
prefixCls: string;
dropdownPrefixCls: string;
columns: ColumnProps<T>[];
locale: TableLocale;
getPopupContainer: TableProps<T>['getPopupContainer'];
}) {
const { sortOrder, filters } = this.state; const { sortOrder, filters } = this.state;
return treeMap(columns, (column, i) => { return treeMap(columns, (column, i) => {
const key = this.getColumnKey(column, i) as string; const key = this.getColumnKey(column, i) as string;
@ -874,7 +890,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
confirmFilter={this.handleFilter} confirmFilter={this.handleFilter}
prefixCls={`${prefixCls}-filter`} prefixCls={`${prefixCls}-filter`}
dropdownPrefixCls={dropdownPrefixCls || 'ant-dropdown'} dropdownPrefixCls={dropdownPrefixCls || 'ant-dropdown'}
getPopupContainer={this.generatePopupContainerFunc()} getPopupContainer={this.generatePopupContainerFunc(getPopupContainer)}
key="filter-dropdown" key="filter-dropdown"
/> />
); );
@ -1146,16 +1162,61 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
}; };
} }
renderTable = ( renderExpandIcon = (prefixCls: string) => ({
prefixCls: string, expandable,
renderEmpty: RenderEmptyHandler, expanded,
dropdownPrefixCls: string, needIndentSpaced,
contextLocale: TableLocale, record,
) => { onExpand,
const { style, className, showHeader, locale, ...restProps } = this.props; }: ExpandIconProps<T>) => {
if (expandable) {
return (
<LocaleReceiver componentName="Table" defaultLocale={defaultLocale.Table}>
{(locale: TableLocale) => (
<TransButton
className={classNames(`${prefixCls}-row-expand-icon`, {
[`${prefixCls}-row-collapsed`]: !expanded,
[`${prefixCls}-row-expanded`]: expanded,
})}
onClick={event => {
onExpand(record, event);
}}
aria-label={expanded ? locale.collapse : locale.expand}
noStyle
/>
)}
</LocaleReceiver>
);
}
if (needIndentSpaced) {
return <span className={`${prefixCls}-row-expand-icon ${prefixCls}-row-spaced`} />;
}
return null;
};
renderTable = ({
prefixCls,
renderEmpty,
dropdownPrefixCls,
contextLocale,
getPopupContainer: contextGetPopupContainer,
}: {
prefixCls: string;
renderEmpty: RenderEmptyHandler;
dropdownPrefixCls: string;
contextLocale: TableLocale;
getPopupContainer: TableProps<T>['getPopupContainer'];
}) => {
const { style, className, showHeader, locale, getPopupContainer, ...restProps } = this.props;
const data = this.getCurrentPageData(); const data = this.getCurrentPageData();
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false; const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;
// use props.getPopupContainer first
const realGetPopupContainer = getPopupContainer || contextGetPopupContainer;
// Merge too locales
const mergedLocale = { ...contextLocale, ...locale }; const mergedLocale = { ...contextLocale, ...locale };
if (!locale || !locale.emptyText) { if (!locale || !locale.emptyText) {
mergedLocale.emptyText = renderEmpty('Table'); mergedLocale.emptyText = renderEmpty('Table');
@ -1168,13 +1229,23 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
[`${prefixCls}-without-column-header`]: !showHeader, [`${prefixCls}-without-column-header`]: !showHeader,
}); });
let columns = this.renderRowSelection(prefixCls, mergedLocale); const columnsWithRowSelection = this.renderRowSelection({
columns = this.renderColumnsDropdown(prefixCls, dropdownPrefixCls, columns, mergedLocale); prefixCls,
columns = columns.map((column, i) => { locale: mergedLocale,
getPopupContainer: realGetPopupContainer,
});
const columns = this.renderColumnsDropdown({
columns: columnsWithRowSelection,
prefixCls,
dropdownPrefixCls,
locale: mergedLocale,
getPopupContainer: realGetPopupContainer,
}).map((column, i) => {
const newColumn = { ...column }; const newColumn = { ...column };
newColumn.key = this.getColumnKey(newColumn, i); newColumn.key = this.getColumnKey(newColumn, i);
return newColumn; return newColumn;
}); });
let expandIconColumnIndex = columns[0] && columns[0].key === 'selection-column' ? 1 : 0; let expandIconColumnIndex = columns[0] && columns[0].key === 'selection-column' ? 1 : 0;
if ('expandIconColumnIndex' in restProps) { if ('expandIconColumnIndex' in restProps) {
expandIconColumnIndex = restProps.expandIconColumnIndex as number; expandIconColumnIndex = restProps.expandIconColumnIndex as number;
@ -1183,6 +1254,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
return ( return (
<RcTable <RcTable
key="table" key="table"
expandIcon={this.renderExpandIcon(prefixCls)}
{...restProps} {...restProps}
onRow={(record: T, index: number) => this.onRow(prefixCls, record, index)} onRow={(record: T, index: number) => this.onRow(prefixCls, record, index)}
components={this.components} components={this.components}
@ -1198,7 +1270,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
); );
}; };
renderComponent = ({ getPrefixCls, renderEmpty }: ConfigConsumerProps) => { renderComponent = ({ getPrefixCls, renderEmpty, getPopupContainer }: ConfigConsumerProps) => {
const { const {
prefixCls: customizePrefixCls, prefixCls: customizePrefixCls,
dropdownPrefixCls: customizeDropdownPrefixCls, dropdownPrefixCls: customizeDropdownPrefixCls,
@ -1218,7 +1290,15 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls); const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls);
const table = ( const table = (
<LocaleReceiver componentName="Table" defaultLocale={defaultLocale.Table}> <LocaleReceiver componentName="Table" defaultLocale={defaultLocale.Table}>
{locale => this.renderTable(prefixCls, renderEmpty, dropdownPrefixCls, locale)} {locale =>
this.renderTable({
prefixCls,
renderEmpty,
dropdownPrefixCls,
contextLocale: locale,
getPopupContainer,
})
}
</LocaleReceiver> </LocaleReceiver>
); );

View File

@ -0,0 +1,41 @@
/* eslint-disable react/no-multi-comp */
import React from 'react';
import { mount } from 'enzyme';
import Table from '..';
describe('Table.expand', () => {
it('click to expand', () => {
const columns = [
{
title: 'Name',
key: 'name',
dataIndex: 'name',
},
];
const data = [
{
key: '1',
firstName: 'John',
lastName: 'Brown',
age: 32,
children: [
{
key: '2',
firstName: 'Jim',
lastName: 'Green',
age: 42,
},
],
},
];
const wrapper = mount(<Table columns={columns} dataSource={data} />);
wrapper
.find('.ant-table-row-expand-icon')
.last()
.simulate('click');
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -4,6 +4,7 @@ import { render, mount } from 'enzyme';
import Table from '..'; import Table from '..';
import Input from '../../input'; import Input from '../../input';
import Button from '../../button'; import Button from '../../button';
import ConfigProvider from '../../config-provider';
function getDropdownWrapper(wrapper) { function getDropdownWrapper(wrapper) {
return mount( return mount(
@ -686,4 +687,35 @@ describe('Table.filter', () => {
dropdownWrapper2.find('.confirm').simulate('click'); dropdownWrapper2.find('.confirm').simulate('click');
expect(onChange).toHaveBeenCalled(); expect(onChange).toHaveBeenCalled();
}); });
it('should support getPopupContainer', () => {
const wrapper = mount(
createTable({
columns: [
{
...column,
filterDropdownVisible: true,
},
],
getPopupContainer: node => node.parentNode,
}),
);
expect(wrapper.render()).toMatchSnapshot();
});
it('should support getPopupContainer from ConfigProvider', () => {
const wrapper = mount(
<ConfigProvider getPopupContainer={node => node.parentNode}>
{createTable({
columns: [
{
...column,
filterDropdownVisible: true,
},
],
})}
</ConfigProvider>
);
expect(wrapper.render()).toMatchSnapshot();
});
}); });

View File

@ -0,0 +1,170 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Table.expand click to expand 1`] = `
<div
class="ant-table-wrapper"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-scroll-position-left"
>
<div
class="ant-table-content"
>
<div
class="ant-table-body"
>
<table
class=""
>
<colgroup>
<col />
</colgroup>
<thead
class="ant-table-thead"
>
<tr>
<th
class=""
>
<span
class="ant-table-header-column"
>
<div>
<span
class="ant-table-column-title"
>
Name
</span>
<span
class="ant-table-column-sorter"
/>
</div>
</span>
</th>
</tr>
</thead>
<tbody
class="ant-table-tbody"
>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="1"
>
<td
class=""
>
<span
class="ant-table-row-indent indent-level-0"
style="padding-left: 0px;"
/>
<div
aria-label="Collapse row"
class="ant-table-row-expand-icon ant-table-row-expanded"
role="button"
tabindex="0"
/>
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-1"
data-row-key="2"
>
<td
class=""
>
<span
class="ant-table-row-indent indent-level-1"
style="padding-left: 20px;"
/>
<span
class="ant-table-row-expand-icon ant-table-row-spaced"
/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<ul
class="ant-pagination ant-table-pagination"
unselectable="unselectable"
>
<li
aria-disabled="true"
class="ant-pagination-disabled ant-pagination-prev"
title="Previous Page"
>
<a
class="ant-pagination-item-link"
>
<i
aria-label="icon: left"
class="anticon anticon-left"
>
<svg
aria-hidden="true"
class=""
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 0 0 0 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</i>
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a>
1
</a>
</li>
<li
aria-disabled="true"
class="ant-pagination-disabled ant-pagination-next"
title="Next Page"
>
<a
class="ant-pagination-item-link"
>
<i
aria-label="icon: right"
class="anticon anticon-right"
>
<svg
aria-hidden="true"
class=""
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4z"
/>
</svg>
</i>
</a>
</li>
</ul>
</div>
</div>
</div>
`;

View File

@ -144,10 +144,6 @@ exports[`Table.filter renders filter correctly 1`] = `
<td <td
class="ant-table-column-has-actions ant-table-column-has-filters" class="ant-table-column-has-actions ant-table-column-has-filters"
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jack Jack
</td> </td>
</tr> </tr>
@ -158,10 +154,6 @@ exports[`Table.filter renders filter correctly 1`] = `
<td <td
class="ant-table-column-has-actions ant-table-column-has-filters" class="ant-table-column-has-actions ant-table-column-has-filters"
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Lucy Lucy
</td> </td>
</tr> </tr>
@ -172,10 +164,6 @@ exports[`Table.filter renders filter correctly 1`] = `
<td <td
class="ant-table-column-has-actions ant-table-column-has-filters" class="ant-table-column-has-actions ant-table-column-has-filters"
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Tom Tom
</td> </td>
</tr> </tr>
@ -186,10 +174,6 @@ exports[`Table.filter renders filter correctly 1`] = `
<td <td
class="ant-table-column-has-actions ant-table-column-has-filters" class="ant-table-column-has-actions ant-table-column-has-filters"
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jerry Jerry
</td> </td>
</tr> </tr>
@ -392,3 +376,441 @@ exports[`Table.filter renders radio filter correctly 1`] = `
</div> </div>
</div> </div>
`; `;
exports[`Table.filter should support getPopupContainer 1`] = `
<div
class="ant-table-wrapper"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-scroll-position-left"
>
<div
class="ant-table-content"
>
<div
class="ant-table-body"
>
<table
class=""
>
<colgroup>
<col />
</colgroup>
<thead
class="ant-table-thead"
>
<tr>
<th
class="ant-table-column-has-actions ant-table-column-has-filters"
>
<span
class="ant-table-header-column"
>
<div>
<span
class="ant-table-column-title"
>
Name
</span>
<span
class="ant-table-column-sorter"
/>
</div>
</span>
<i
aria-label="icon: filter"
class="anticon anticon-filter ant-table-filter-open ant-dropdown-trigger ant-dropdown-open"
style=""
tabindex="-1"
title="Filter menu"
>
<svg
aria-hidden="true"
class=""
data-icon="filter"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M349 838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V642H349v196zm531.1-684H143.9c-24.5 0-39.8 26.7-27.5 48l221.3 376h348.8l221.3-376c12.1-21.3-3.2-48-27.7-48z"
/>
</svg>
</i>
<div>
<div
class="ant-dropdown ant-dropdown-placement-bottomRight slide-up-appear"
style="left: -999px; top: -995px;"
>
<div
class="ant-table-filter-dropdown"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical"
role="menu"
tabindex="0"
>
<li
class="ant-dropdown-menu-item"
role="menuitem"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Boy
</span>
</li>
<li
class="ant-dropdown-menu-item"
role="menuitem"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Girl
</span>
</li>
<li
class="ant-dropdown-menu-submenu ant-dropdown-menu-submenu-vertical"
role="menuitem"
>
<div
aria-expanded="false"
aria-haspopup="true"
class="ant-dropdown-menu-submenu-title"
title="Title"
>
Title
<i
class="ant-dropdown-menu-submenu-arrow"
/>
</div>
</li>
</ul>
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
>
Reset
</a>
</div>
</div>
</div>
</div>
</th>
</tr>
</thead>
<tbody
class="ant-table-tbody"
>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="0"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Jack
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="1"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Lucy
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="2"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Tom
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="3"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Jerry
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Table.filter should support getPopupContainer from ConfigProvider 1`] = `
<div
class="ant-table-wrapper"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-scroll-position-left"
>
<div
class="ant-table-content"
>
<div
class="ant-table-body"
>
<table
class=""
>
<colgroup>
<col />
</colgroup>
<thead
class="ant-table-thead"
>
<tr>
<th
class="ant-table-column-has-actions ant-table-column-has-filters"
>
<span
class="ant-table-header-column"
>
<div>
<span
class="ant-table-column-title"
>
Name
</span>
<span
class="ant-table-column-sorter"
/>
</div>
</span>
<i
aria-label="icon: filter"
class="anticon anticon-filter ant-table-filter-open ant-dropdown-trigger ant-dropdown-open"
style=""
tabindex="-1"
title="Filter menu"
>
<svg
aria-hidden="true"
class=""
data-icon="filter"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M349 838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V642H349v196zm531.1-684H143.9c-24.5 0-39.8 26.7-27.5 48l221.3 376h348.8l221.3-376c12.1-21.3-3.2-48-27.7-48z"
/>
</svg>
</i>
<div>
<div
class="ant-dropdown ant-dropdown-placement-bottomRight slide-up-appear"
style="left: -999px; top: -995px;"
>
<div
class="ant-table-filter-dropdown"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical"
role="menu"
tabindex="0"
>
<li
class="ant-dropdown-menu-item"
role="menuitem"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Boy
</span>
</li>
<li
class="ant-dropdown-menu-item"
role="menuitem"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Girl
</span>
</li>
<li
class="ant-dropdown-menu-submenu ant-dropdown-menu-submenu-vertical"
role="menuitem"
>
<div
aria-expanded="false"
aria-haspopup="true"
class="ant-dropdown-menu-submenu-title"
title="Title"
>
Title
<i
class="ant-dropdown-menu-submenu-arrow"
/>
</div>
</li>
</ul>
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
>
Reset
</a>
</div>
</div>
</div>
</div>
</th>
</tr>
</thead>
<tbody
class="ant-table-tbody"
>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="0"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Jack
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="1"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Lucy
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="2"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Tom
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="3"
>
<td
class="ant-table-column-has-actions ant-table-column-has-filters"
>
Jerry
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@ -59,10 +59,6 @@ exports[`Table.pagination Accepts pagination as true 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jack Jack
</td> </td>
</tr> </tr>
@ -73,10 +69,6 @@ exports[`Table.pagination Accepts pagination as true 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Lucy Lucy
</td> </td>
</tr> </tr>
@ -87,10 +79,6 @@ exports[`Table.pagination Accepts pagination as true 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Tom Tom
</td> </td>
</tr> </tr>
@ -101,10 +89,6 @@ exports[`Table.pagination Accepts pagination as true 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jerry Jerry
</td> </td>
</tr> </tr>
@ -249,10 +233,6 @@ exports[`Table.pagination renders pagination correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jack Jack
</td> </td>
</tr> </tr>
@ -263,10 +243,6 @@ exports[`Table.pagination renders pagination correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Lucy Lucy
</td> </td>
</tr> </tr>

View File

@ -122,10 +122,6 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jack Jack
</td> </td>
</tr> </tr>
@ -157,10 +153,6 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Lucy Lucy
</td> </td>
</tr> </tr>
@ -192,10 +184,6 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Tom Tom
</td> </td>
</tr> </tr>
@ -227,10 +215,6 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jerry Jerry
</td> </td>
</tr> </tr>

View File

@ -119,10 +119,6 @@ exports[`Table renders JSX correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
John John
</td> </td>
<td <td
@ -143,10 +139,6 @@ exports[`Table renders JSX correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
Jim Jim
</td> </td>
<td <td

File diff suppressed because it is too large Load Diff

View File

@ -263,7 +263,6 @@ class FilterMenu<T> extends React.Component<FilterMenuProps<T>, FilterMenuState<
confirm: this.handleConfirm, confirm: this.handleConfirm,
clearFilters: this.handleClearFilters, clearFilters: this.handleClearFilters,
filters: column.filters, filters: column.filters,
getPopupContainer: (triggerNode: HTMLElement) => triggerNode.parentNode as HTMLElement,
}); });
} }
@ -281,7 +280,7 @@ class FilterMenu<T> extends React.Component<FilterMenuProps<T>, FilterMenuState<
onSelect={this.setSelectedKeys} onSelect={this.setSelectedKeys}
onDeselect={this.setSelectedKeys} onDeselect={this.setSelectedKeys}
selectedKeys={originSelectedKeys && originSelectedKeys.map(val => val.toString())} selectedKeys={originSelectedKeys && originSelectedKeys.map(val => val.toString())}
getPopupContainer={(triggerNode: HTMLElement) => triggerNode.parentNode} getPopupContainer={getPopupContainer}
> >
{this.renderMenus(column.filters!)} {this.renderMenus(column.filters!)}
</Menu> </Menu>

View File

@ -87,6 +87,7 @@ const columns = [
| onExpandedRowsChange | Callback executed when the expanded rows change | Function(expandedRows) | | | | onExpandedRowsChange | Callback executed when the expanded rows change | Function(expandedRows) | | |
| onHeaderRow | Set props on per header row | Function(column, index) | - | | | onHeaderRow | Set props on per header row | Function(column, index) | - | |
| onRow | Set props on per row | Function(record, index) | - | | | onRow | Set props on per row | Function(record, index) | - | |
| getPopupContainer | the render container of dropdowns in table | (triggerNode) => HTMLElement | `() => TableHtmlElement` | 3.21.0 |
#### onRow usage #### onRow usage

View File

@ -92,6 +92,7 @@ const columns = [
| onExpandedRowsChange | 展开的行变化时触发 | Function(expandedRows) | | | | onExpandedRowsChange | 展开的行变化时触发 | Function(expandedRows) | | |
| onHeaderRow | 设置头部行属性 | Function(column, index) | - | | | onHeaderRow | 设置头部行属性 | Function(column, index) | - | |
| onRow | 设置行属性 | Function(record, index) | - | | | onRow | 设置行属性 | Function(record, index) | - | |
| getPopupContainer | 设置表格内各类浮层的渲染节点,如筛选菜单 | (triggerNode) => HTMLElement | `() => TableHtmlElement` | 3.21.0 |
#### onRow 用法 #### onRow 用法

View File

@ -80,6 +80,8 @@ export interface TableLocale {
selectAll?: React.ReactNode; selectAll?: React.ReactNode;
selectInvert?: React.ReactNode; selectInvert?: React.ReactNode;
sortTitle?: string; sortTitle?: string;
expand?: string;
collapse?: string;
} }
export type RowSelectionType = 'checkbox' | 'radio'; export type RowSelectionType = 'checkbox' | 'radio';
@ -122,7 +124,7 @@ export interface ExpandIconProps<T> {
record: T; record: T;
needIndentSpaced: boolean; needIndentSpaced: boolean;
expandable: boolean; expandable: boolean;
onExpand: (record: T, event: MouseEvent) => void; onExpand: (record: T, event?: React.MouseEvent) => void;
} }
export interface TableCurrentDataSource<T> { export interface TableCurrentDataSource<T> {
@ -188,6 +190,7 @@ export interface TableProps<T> {
style?: React.CSSProperties; style?: React.CSSProperties;
children?: React.ReactNode; children?: React.ReactNode;
sortDirections?: SortOrder[]; sortDirections?: SortOrder[];
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
} }
export interface TableStateFilters { export interface TableStateFilters {

View File

@ -545,15 +545,25 @@
&-row { &-row {
&-expand-icon { &-expand-icon {
.operation-unit();
display: inline-block; display: inline-block;
width: 17px; width: 17px;
height: 17px; height: 17px;
color: inherit;
line-height: 14px; line-height: 14px;
text-align: center; text-align: center;
background: @component-background; background: @component-background;
border: @border-width-base @border-style-base @border-color-split; border: @border-width-base @border-style-base @border-color-split;
cursor: pointer; outline: none;
transition: all 0.3s;
user-select: none; user-select: none;
&:focus,
&:hover,
&:active {
border-color: currentColor;
}
} }
&-expanded::after { &-expanded::after {

View File

@ -0,0 +1,5 @@
const locale = {
placeholder: 'Sila pilih masa',
};
export default locale;

View File

@ -46,7 +46,7 @@ const TimelineItem: React.SFC<TimeLineItemProps> = props => (
<div className={`${prefixCls}-item-tail`} /> <div className={`${prefixCls}-item-tail`} />
<div <div
className={dotClassName} className={dotClassName}
style={{ borderColor: /blue|red|green/.test(color) ? undefined : color }} style={{ borderColor: /blue|red|green|gray/.test(color) ? undefined : color }}
> >
{dot} {dot}
</div> </div>

View File

@ -270,7 +270,7 @@ exports[`renders ./components/timeline/demo/color.md correctly 1`] = `
</div> </div>
</li> </li>
<li <li
class="ant-timeline-item ant-timeline-item-last" class="ant-timeline-item"
> >
<div <div
class="ant-timeline-item-tail" class="ant-timeline-item-tail"
@ -292,6 +292,52 @@ exports[`renders ./components/timeline/demo/color.md correctly 1`] = `
</p> </p>
</div> </div>
</li> </li>
<li
class="ant-timeline-item"
>
<div
class="ant-timeline-item-tail"
/>
<div
class="ant-timeline-item-head ant-timeline-item-head-gray"
/>
<div
class="ant-timeline-item-content"
>
<p>
Technical testing 1
</p>
<p>
Technical testing 2
</p>
<p>
Technical testing 3 2015-09-01
</p>
</div>
</li>
<li
class="ant-timeline-item ant-timeline-item-last"
>
<div
class="ant-timeline-item-tail"
/>
<div
class="ant-timeline-item-head ant-timeline-item-head-gray"
/>
<div
class="ant-timeline-item-content"
>
<p>
Technical testing 1
</p>
<p>
Technical testing 2
</p>
<p>
Technical testing 3 2015-09-01
</p>
</div>
</li>
</ul> </ul>
`; `;

View File

@ -7,11 +7,11 @@ title:
## zh-CN ## zh-CN
圆圈颜色,绿色用于已完成、成功状态,红色表示告警或错误状态,蓝色可表示正在进行或其他默认状态。 圆圈颜色,绿色用于已完成、成功状态,红色表示告警或错误状态,蓝色可表示正在进行或其他默认状态,灰色表示未完成或失效状态
## en-US ## en-US
Set the color of circles. `green` means completed or success status, `red` means warning or error, and `blue` means ongoing or other default status. Set the color of circles. `green` means completed or success status, `red` means warning or error, and `blue` means ongoing or other default status, `gray` for unfinished or disabled status.
```jsx ```jsx
import { Timeline } from 'antd'; import { Timeline } from 'antd';
@ -30,6 +30,16 @@ ReactDOM.render(
<p>Technical testing 2</p> <p>Technical testing 2</p>
<p>Technical testing 3 2015-09-01</p> <p>Technical testing 3 2015-09-01</p>
</Timeline.Item> </Timeline.Item>
<Timeline.Item color="gray">
<p>Technical testing 1</p>
<p>Technical testing 2</p>
<p>Technical testing 3 2015-09-01</p>
</Timeline.Item>
<Timeline.Item color="gray">
<p>Technical testing 1</p>
<p>Technical testing 2</p>
<p>Technical testing 3 2015-09-01</p>
</Timeline.Item>
</Timeline>, </Timeline>,
mountNode, mountNode,
); );

View File

@ -39,6 +39,6 @@ Node of timeline
| Property | Description | Type | Default | Version | | Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| color | Set the circle's color to `blue`, `red`, `green` or other custom colors | string | `blue` | | | color | Set the circle's color to `blue`, `red`, `green`, `gray` or other custom colors | string | `blue` | |
| dot | Customize timeline dot | string\|ReactNode | - | | | dot | Customize timeline dot | string\|ReactNode | - | |
| position | Customize node position | `left` \| `right` | - | 3.17.0 | | position | Customize node position | `left` \| `right` | - | 3.17.0 |

View File

@ -38,8 +38,8 @@ title: Timeline
时间轴的每一个节点。 时间轴的每一个节点。
| 参数 | 说明 | 类型 | 默认值 | 版本 | | 参数 | 说明 | 类型 | 默认值 | 版本 |
| -------- | ----------------------------------------------- | ----------------- | ------ | ------ | | --- | --- | --- | --- | --- |
| color | 指定圆圈颜色 `blue, red, green`,或自定义的色值 | string | blue | | | color | 指定圆圈颜色 `blue, red, green, gray`,或自定义的色值 | string | blue | |
| dot | 自定义时间轴点 | string\|ReactNode | - | | | dot | 自定义时间轴点 | string\|ReactNode | - | |
| position | 自定义节点位置 | `left` \| `right` | - | 3.17.0 | | position | 自定义节点位置 | `left` \| `right` | - | 3.17.0 |

View File

@ -55,6 +55,11 @@
color: @success-color; color: @success-color;
border-color: @success-color; border-color: @success-color;
} }
&-gray {
color: @disabled-color;
border-color: @disabled-color;
}
} }
&-head-custom { &-head-custom {

View File

@ -1311,10 +1311,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content1 content1
</td> </td>
<td <td
@ -1360,10 +1356,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content2 content2
</td> </td>
<td <td
@ -1409,10 +1401,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content4 content4
</td> </td>
<td <td
@ -1459,10 +1447,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content5 content5
</td> </td>
<td <td
@ -1508,10 +1492,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content7 content7
</td> </td>
<td <td
@ -1557,10 +1537,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content8 content8
</td> </td>
<td <td
@ -1606,10 +1582,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content10 content10
</td> </td>
<td <td
@ -1655,10 +1627,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content11 content11
</td> </td>
<td <td
@ -1705,10 +1673,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content13 content13
</td> </td>
<td <td
@ -1754,10 +1718,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content14 content14
</td> </td>
<td <td
@ -2063,10 +2023,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content3 content3
</td> </td>
</tr> </tr>
@ -2098,10 +2054,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content6 content6
</td> </td>
</tr> </tr>
@ -2134,10 +2086,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content9 content9
</td> </td>
</tr> </tr>
@ -2169,10 +2117,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content12 content12
</td> </td>
</tr> </tr>
@ -2204,10 +2148,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content15 content15
</td> </td>
</tr> </tr>
@ -2239,10 +2179,6 @@ exports[`renders ./components/transfer/demo/table-transfer.md correctly 1`] = `
<td <td
class="" class=""
> >
<span
class="ant-table-row-indent indent-level-0"
style="padding-left:0px"
/>
content18 content18
</td> </td>
</tr> </tr>

View File

@ -79,7 +79,7 @@
"rc-slider": "~8.6.11", "rc-slider": "~8.6.11",
"rc-steps": "~3.4.1", "rc-steps": "~3.4.1",
"rc-switch": "~1.9.0", "rc-switch": "~1.9.0",
"rc-table": "~6.6.0", "rc-table": "~6.7.0",
"rc-tabs": "~9.6.4", "rc-tabs": "~9.6.4",
"rc-time-picker": "~3.7.1", "rc-time-picker": "~3.7.1",
"rc-tooltip": "~3.7.3", "rc-tooltip": "~3.7.3",