Merge pull request #19586 from ant-design/master

chore: Merge master into feature
This commit is contained in:
二货机器人 2019-11-06 09:16:52 +08:00 committed by GitHub
commit 42592bafcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 447 additions and 90 deletions

View File

@ -84,6 +84,8 @@ const eslintrc = {
'no-restricted-globals': 0,
'max-classes-per-file': 0,
'react/static-property-placement': 0,
'jest/no-test-callback': 0,
'jest/expect-expect': 0,
},
globals: {
gtag: true,

View File

@ -15,6 +15,28 @@ timeline: true
---
## 3.25.0
`2019-11-04`
- 🌟 Transfer `listStyle` support function callback. [#19330](https://github.com/ant-design/ant-design/pull/19330) [@lxnxbnq](https://github.com/lxnxbnq)
- 🌟 `icon` of Avatar support ReactNode. [#19368](https://github.com/ant-design/ant-design/pull/19368)
- 🌟 TextArea support `allowClear`. [#19310](https://github.com/ant-design/ant-design/pull/19310) [@Rustin-Liu](https://github.com/Rustin-Liu)
- 🌟 Upload support to custom `method` for request. [#19533](https://github.com/ant-design/ant-design/pull/19533)
- 🌟 Upload `onChange` add `XMLHttpRequest` as additional param. [#19539](https://github.com/ant-design/ant-design/pull/19539) [@hahmadia](https://github.com/hahmadia)
- 🐞 Fix WeekPicker `defaultPickerValue` not works. [#19141](https://github.com/ant-design/ant-design/pull/19141) [@NightFox7](https://github.com/NightFox7)
- 🐞 Fix DatePicker `onEsc is not a function` TypeError. [#19474](https://github.com/ant-design/ant-design/pull/19474)
- 🐞 Fix table does not automatically scroll to the top when change page size. [#19474](https://github.com/ant-design/ant-design/pull/19474) [@MrHeer](https://github.com/MrHeer)
- 💄 Fix Icon Button not aligned well in Button.Group. [#19453](https://github.com/ant-design/ant-design/pull/19453)
- 💄 Fix Checkbox not aligned center of some cases in Chrome. [#19452](https://github.com/ant-design/ant-design/pull/19452)
- 💄 Fix Menu `margin` collapsed issue. [#19476](https://github.com/ant-design/ant-design/pull/19476) [@wangweijun0418](https://github.com/wangweijun0418)
- 💄 Remove useless style in Select. [#19510](https://github.com/ant-design/ant-design/pull/19510) [@jacklee814](https://github.com/jacklee814)
- 💄 Added less variables `@input-number-hover-border-color`, `@select-background`. [#19546](https://github.com/ant-design/ant-design/pull/19546)
- 🌍 Add `downloadFile` in all locale files. [#19361](https://github.com/ant-design/ant-design/pull/19361) [@DemetriusHR](https://github.com/DemetriusHR)
- 🇹🇭 Add missing translations in Thai (th_TH) locale. [#19378](https://github.com/ant-design/ant-design/pull/19378) [@anawinwz](https://github.com/anawinwz)
- Typescript
- 🐞 Add Upload missing `preview` type. [#19496](https://github.com/ant-design/ant-design/pull/19496) [@chnliquan](https://github.com/chnliquan)
## 3.24.3
`2019-10-26`

View File

@ -15,6 +15,28 @@ timeline: true
---
## 3.25.0
`2019-11-04`
- 🌟 Transfer `listStyle` 支持回调函数。[#19330](https://github.com/ant-design/ant-design/pull/19330) [@lxnxbnq](https://github.com/lxnxbnq)
- 🌟 Avatar 的 `icon` 属性支持传递 ReactNode。[#19368](https://github.com/ant-design/ant-design/pull/19368)
- 🌟 TextArea 支持 `allowClear`。[#19310](https://github.com/ant-design/ant-design/pull/19310) [@Rustin-Liu](https://github.com/Rustin-Liu)
- 🌟 Upload 新增 `method` 属性用于修改请求方式。[#19533](https://github.com/ant-design/ant-design/pull/19533)
- 🌟 Upload `onChange` 新增 `XMLHttpRequest` 作为额外参数。[#19539](https://github.com/ant-design/ant-design/pull/19539) [@hahmadia](https://github.com/hahmadia)
- 🐞 修复 WeekPicker 中 `defaultPickerValue` 不生效的问题。[#19141](https://github.com/ant-design/ant-design/pull/19141) [@NightFox7](https://github.com/NightFox7)
- 🐞 修复 DatePicker 抛出 `onEsc is not a function` 错误。[#19474](https://github.com/ant-design/ant-design/pull/19474)
- 🐞 修复 Table 改变每页大小时不滚动到第一行的问题。[#19474](https://github.com/ant-design/ant-design/pull/19474) [@MrHeer](https://github.com/MrHeer)
- 💄 修复 Button.Group 下图标按钮没有对齐的问题。[#19453](https://github.com/ant-design/ant-design/pull/19453)
- 💄 修复 Checkbox 对勾在 Chrome 下有时没有居中的问题。[#19452](https://github.com/ant-design/ant-design/pull/19452)
- 💄 修复 Menu `margin` 样式重合的问题。[#19476](https://github.com/ant-design/ant-design/pull/19476) [@wangweijun0418](https://github.com/wangweijun0418)
- 💄 移除 Select 中没有必要的样式。[#19510](https://github.com/ant-design/ant-design/pull/19510) [@jacklee814](https://github.com/jacklee814)
- 💄 新增 less 变量 `@input-number-hover-border-color`, `@select-background`。[#19546](https://github.com/ant-design/ant-design/pull/19546)
- 🌍 国际化添加缺失的 `downloadFile` 支持。[#19361](https://github.com/ant-design/ant-design/pull/19361) [@DemetriusHR](https://github.com/DemetriusHR)
- 🇹🇭 添加丢失的泰文国际化 (th_TH)。[#19378](https://github.com/ant-design/ant-design/pull/19378) [@anawinwz](https://github.com/anawinwz)
- Typescript
- 🐞 修复 Upload 丢失的 `preview` 定义。[#19496](https://github.com/ant-design/ant-design/pull/19496) [@chnliquan](https://github.com/chnliquan)
## 3.24.3
`2019-10-26`

View File

@ -30,8 +30,12 @@ describe('react router', () => {
afterAll(() => {
jest.useRealTimers();
});
// https://github.com/airbnb/enzyme/issues/875
(process.env.REACT === '15' ? it.skip : it)('react router 4', () => {
it('react router 4', () => {
if (process.env.REACT === '15') {
return;
}
const Home = withRouter(props => {
const { location, history } = props;
const pathSnippets = location.pathname.split('/').filter(i => i);

View File

@ -72,9 +72,3 @@ interface Option {
| ------- | ------------ | ------- |
| blur() | remove focus | |
| focus() | get focus | |
<style>
.ant-cascader-picker {
width: 300px;
}
</style>

View File

@ -74,10 +74,4 @@ interface Option {
| blur() | 移除焦点 | |
| focus() | 获取焦点 | |
<style>
.ant-cascader-picker {
width: 300px;
}
</style>
> 注意,如果需要获得中国省市区数据,可以参考 [china-division](https://gist.github.com/afc163/7582f35654fd03d5be7009444345ea17)。

View File

@ -143,6 +143,7 @@ class WeekPicker extends React.Component<any, WeekPickerState> {
onBlur,
id,
suffixIcon,
defaultPickerValue,
} = this.props;
const prefixCls = getPrefixCls('calendar', customizePrefixCls);
@ -170,6 +171,7 @@ class WeekPicker extends React.Component<any, WeekPickerState> {
showToday={false}
disabledDate={disabledDate}
renderFooter={this.renderFooter}
defaultValue={defaultPickerValue}
/>
);
const clearIcon =

View File

@ -192,6 +192,7 @@ export default function wrapPicker(Picker: React.ComponentClass<any>, pickerType
className={timePickerCls}
placeholder={locale.timePickerLocale.placeholder}
transitionName="slide-up"
onEsc={() => {}}
/>
) : null;

View File

@ -8,11 +8,15 @@ debug: true
## zh-CN
此演示需要注意查看 Dropdown 内 Menu 的样式是否正常。[#19150](https://github.com/ant-design/ant-design/pull/19150)
此演示需要注意去掉 Reset 样式后查看 Dropdown 内 Menu 的样式是否正常。
[#19150](https://github.com/ant-design/ant-design/pull/19150)
## en-US
This demo was created for debugging Menu styles inside Dropdown. [#19150](https://github.com/ant-design/ant-design/pull/19150)
This demo was created for debugging Menu styles inside Dropdown.
[#19150](https://github.com/ant-design/ant-design/pull/19150)
```jsx
import { Menu, Dropdown, Icon } from 'antd';
@ -21,6 +25,10 @@ const { SubMenu } = Menu;
const menu = (
<Menu selectedKeys={['1']} openKeys={['sub1']}>
<Menu.ItemGroup key="group" title="Item Group">
<Menu.Item key="01">Option 0</Menu.Item>
<Menu.Item key="02">Option 0</Menu.Item>
</Menu.ItemGroup>
<SubMenu
key="sub1"
title={

View File

@ -81,6 +81,7 @@
ul {
margin-right: 0.3em;
margin-left: 0.3em;
padding: 0;
}
}
@ -139,6 +140,7 @@
line-height: 0;
background-color: @border-color-split;
}
.@{dropdown-prefix-cls}-menu-submenu-arrow {
position: absolute;
right: @padding-xs;
@ -150,6 +152,12 @@
}
}
&-item-group-list {
margin: 0 8px;
padding: 0;
list-style: none;
}
&-submenu-title {
padding-right: 26px;
}

View File

@ -14,7 +14,9 @@ import FormContext, { FormContextProps } from './context';
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
export type FormLabelAlign = 'left' | 'right';
const FormLabelAligns = tuple('left', 'right');
export type FormLabelAlign = (typeof FormLabelAligns)[number];
export interface FormItemProps {
prefixCls?: string;
@ -46,7 +48,6 @@ export default class FormItem extends React.Component<FormItemProps, any> {
static propTypes = {
prefixCls: PropTypes.string,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
labelAlign: PropTypes.string,
labelCol: PropTypes.object,
help: PropTypes.oneOfType([PropTypes.node, PropTypes.bool]),
validateStatus: PropTypes.oneOf(ValidateStatuses),

View File

@ -44,7 +44,7 @@ export default function create(options: CustomIconOptions = {}): React.SFC<IconP
content = children;
}
return (
<Icon {...restProps} {...extraCommonProps}>
<Icon {...extraCommonProps} {...restProps}>
{content}
</Icon>
);

View File

@ -370,12 +370,12 @@ exports[`Icon support render svg as component 1`] = `
</i>
`;
exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
exports[`Icon.createFromIconfontCN() extraCommonProps should works fine and can be overwritten 1`] = `
<div
class="icons-list"
>
<i
class="anticon"
class="anticon bcd"
>
<svg
aria-hidden="true"
@ -391,7 +391,7 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
@ -407,7 +407,62 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon efg"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-twitter"
/>
</svg>
</i>
</div>
`;
exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
<div
class="icons-list"
>
<i
class="anticon abc"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-tuichu"
/>
</svg>
</i>
<i
class="anticon abc"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-facebook"
/>
</svg>
</i>
<i
class="anticon abc"
>
<svg
aria-hidden="true"

View File

@ -180,6 +180,9 @@ describe('Icon', () => {
describe('Icon.createFromIconfontCN()', () => {
const IconFont = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js',
extraCommonProps: {
className: 'abc',
},
});
it('should support iconfont.cn', () => {
@ -192,6 +195,17 @@ describe('Icon.createFromIconfontCN()', () => {
);
expect(wrapper).toMatchSnapshot();
});
it('extraCommonProps should works fine and can be overwritten', () => {
const wrapper = render(
<div className="icons-list">
<IconFont type="icon-tuichu" className="bcd" />
<IconFont type="icon-facebook" />
<IconFont type="icon-twitter" className="efg" />
</div>,
);
expect(wrapper).toMatchSnapshot();
});
});
describe('utils', () => {

View File

@ -50,7 +50,7 @@
}
&:hover {
.hover();
.hover(@input-number-hover-border-color);
}
&-focused {

View File

@ -1980,7 +1980,7 @@ exports[`renders ./components/input/demo/textarea-resize.md correctly 1`] = `
class="ant-input"
rows="4"
>
autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。ending
The autoSize property applies to textarea nodes, and only the height changes automatically. In addition, autoSize can be set to an object, specifying the minimum number of rows and the maximum number of rows. The autoSize property applies to textarea nodes, and only the height changes automatically. In addition, autoSize can be set to an object, specifying the minimum number of rows and the maximum number of rows.
</textarea>
</div>
`;

View File

@ -20,7 +20,7 @@ import { Input, Button } from 'antd';
const { TextArea } = Input;
const defaultValue =
'autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。autoSize 属性适用于 textarea 节点,并且只有高度会自动变化。另外 autoSize 可以设定为一个对象指定最小行数和最大行数。ending';
'The autoSize property applies to textarea nodes, and only the height changes automatically. In addition, autoSize can be set to an object, specifying the minimum number of rows and the maximum number of rows. The autoSize property applies to textarea nodes, and only the height changes automatically. In addition, autoSize can be set to an object, specifying the minimum number of rows and the maximum number of rows.';
class Demo extends React.Component {
state = {

View File

@ -87,7 +87,7 @@ The sidebar.
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| breakpoint | [breakpoints](/components/grid#api) of the responsive layout | Enum { 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' } | - | |
| breakpoint | [breakpoints](/components/grid#Col) of the responsive layout | Enum { 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' } | - | |
| className | container className | string | - | |
| collapsed | to set the current status | boolean | - | |
| collapsedWidth | width of the collapsed sidebar, by setting to `0` a special trigger will appear | number | 80 | |
@ -99,7 +99,7 @@ The sidebar.
| trigger | specify the customized trigger, set to null to hide the trigger | string\|ReactNode | - | |
| width | width of the sidebar | number\|string | 200 | |
| onCollapse | the callback function, executed by clicking the trigger or activating the responsive layout | (collapsed, type) => {} | - | |
| onBreakpoint | the callback function, executed when [breakpoints](/components/grid#api) changed | (broken) => {} | - | 3.7.0 |
| onBreakpoint | the callback function, executed when [breakpoints](/components/grid#API) changed | (broken) => {} | - | 3.7.0 |
| zeroWidthTriggerStyle | to customize the styles of the special trigger that appears when `collapsedWidth` is 0 | object | - | 3.24.0 |
#### breakpoint width

View File

@ -88,7 +88,7 @@ title: Layout
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| breakpoint | 触发响应式布局的[断点](/components/grid#api) | Enum { 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' } | - | |
| breakpoint | 触发响应式布局的[断点](/components/grid-cn/#Col) | Enum { 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' } | - | |
| className | 容器 className | string | - | |
| collapsed | 当前收起状态 | boolean | - | |
| collapsedWidth | 收缩宽度,设置为 0 会出现特殊 trigger | number | 80 | |
@ -100,7 +100,7 @@ title: Layout
| trigger | 自定义 trigger设置为 null 时隐藏 trigger | string\|ReactNode | - | |
| width | 宽度 | number\|string | 200 | |
| onCollapse | 展开-收起时的回调函数,有点击 trigger 以及响应式反馈两种方式可以触发 | (collapsed, type) => {} | - | |
| onBreakpoint | 触发响应式布局[断点](/components/grid#api)时的回调 | (broken) => {} | - | 3.7.0 |
| onBreakpoint | 触发响应式布局[断点](/components/grid#API)时的回调 | (broken) => {} | - | 3.7.0 |
| zeroWidthTriggerStyle | 指定当 `collapsedWidth` 为 0 时出现的特殊 trigger 的样式 | object | - | 3.24.0 |
#### breakpoint width

View File

@ -160,7 +160,7 @@
.@{iconfont-css-prefix} {
min-width: 14px;
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;
+ span {
opacity: 1;
@ -364,7 +364,7 @@
// disable margin collapsed
.@{menu-prefix-cls}-submenu {
padding-bottom: 0.01px;
padding-bottom: 0.02px;
}
.@{menu-prefix-cls}-item:not(:last-child) {
@ -411,14 +411,14 @@
> .@{menu-prefix-cls}-submenu-title,
> .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
left: 0;
padding: 0 (@menu-collapsed-width - 16px) / 2 !important;
padding: 0 (@menu-collapsed-width - @menu-icon-size-lg) / 2 !important;
text-overflow: clip;
.@{menu-prefix-cls}-submenu-arrow {
display: none;
}
.@{iconfont-css-prefix} {
margin: 0;
font-size: 16px;
font-size: @menu-icon-size-lg;
line-height: @menu-item-height;
+ span {
display: inline-block;

View File

@ -1775,7 +1775,7 @@ exports[`renders ./components/pagination/demo/simple.md correctly 1`] = `
<span
class="ant-pagination-slash"
>
/
</span>
5
</li>

View File

@ -72,7 +72,7 @@
&-selection {
display: block;
box-sizing: border-box;
background-color: @component-background;
background-color: @select-background;
border: @border-width-base @border-style-base @select-border-color;
// strange align fix for chrome but works
// https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
@ -382,10 +382,6 @@
}
}
&-allow-clear &-selection--single &-selection-selected-value {
padding-right: 16px;
}
&-allow-clear &-selection--multiple &-selection__rendered,
&-show-arrow &-selection--multiple &-selection__rendered {
margin-right: 20px; // In case that clear button will overlap content

View File

@ -1032,11 +1032,9 @@ exports[`renders ./components/slider/demo/tip-formatter.md correctly 1`] = `
`;
exports[`renders ./components/slider/demo/vertical.md correctly 1`] = `
<div
style="height:300px"
>
<div>
<div
style="float:left;height:300px;margin-left:70px"
style="display:inline-block;height:300px;margin-left:70px"
>
<div
class="ant-slider ant-slider-vertical"
@ -1067,7 +1065,7 @@ exports[`renders ./components/slider/demo/vertical.md correctly 1`] = `
</div>
</div>
<div
style="float:left;height:300px;margin-left:70px"
style="display:inline-block;height:300px;margin-left:70px"
>
<div
class="ant-slider ant-slider-vertical"
@ -1108,7 +1106,7 @@ exports[`renders ./components/slider/demo/vertical.md correctly 1`] = `
</div>
</div>
<div
style="float:left;height:300px;margin-left:70px"
style="display:inline-block;height:300px;margin-left:70px"
>
<div
class="ant-slider ant-slider-with-marks ant-slider-vertical"

View File

@ -17,7 +17,7 @@ The vertical Slider.
import { Slider } from 'antd';
const style = {
float: 'left',
display: 'inline-block',
height: 300,
marginLeft: 70,
};
@ -35,7 +35,7 @@ const marks = {
};
ReactDOM.render(
<div style={{ height: 300 }}>
<div>
<div style={style}>
<Slider vertical defaultValue={30} />
</div>

View File

@ -322,6 +322,7 @@
@input-color: @text-color;
@input-border-color: @border-color-base;
@input-bg: @component-background;
@input-number-hover-border-color: @input-hover-border-color;
@input-number-handler-active-bg: #f4f4f4;
@input-number-handler-hover-bg: @primary-5;
@input-number-handler-bg: @component-background;
@ -338,6 +339,7 @@
@select-dropdown-bg: @component-background;
@select-item-selected-bg: @background-color-light;
@select-item-active-bg: @item-active-bg;
@select-background: @component-background;
// Anchor
// ---
@ -410,11 +412,6 @@
@menu-item-vertical-margin: 4px;
@menu-item-font-size: @font-size-base;
@menu-item-boundary-margin: 8px;
@menu-icon-size: @font-size-base;
@menu-icon-size-lg: @font-size-lg;
@menu-dark-selected-item-icon-color: @white;
@menu-dark-selected-item-text-color: @white;
@dark-menu-item-hover-bg: transparent;
// dark theme
@menu-dark-color: @text-color-secondary-dark;

View File

@ -249,7 +249,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
constructor(props: InternalTableProps<T>) {
super(props);
const { expandedRowRender, columns: columnsProp = [] } = props;
const { expandedRowRender, columns: columnsProp } = props;
warning(
!('columnsPageRange' in props || 'columnsPageSize' in props),
@ -258,7 +258,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
'fixed columns instead, see: https://u.ant.design/fixed-columns.',
);
if (expandedRowRender && columnsProp.some(({ fixed }) => !!fixed)) {
if (expandedRowRender && (columnsProp || []).some(({ fixed }) => !!fixed)) {
warning(
false,
'Table',
@ -269,7 +269,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
const columns = columnsProp || normalizeColumns(props.children as React.ReactChildren);
this.state = {
...this.getDefaultSortOrder(columns),
...this.getDefaultSortOrder(columns || []),
// 减少状态
filters: getFiltersFromColumns<T>(),
pagination: this.getDefaultPagination(props),
@ -284,7 +284,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
const { columns, sortColumn, sortOrder } = this.state;
if (this.getSortOrderColumns(columns).length > 0) {
const sortState = this.getSortStateFromColumns(columns);
if (sortState.sortColumn !== sortColumn || sortState.sortOrder !== sortOrder) {
if (!isSameColumn(sortState.sortColumn, sortColumn) || sortState.sortOrder !== sortOrder) {
this.setState(sortState);
}
}
@ -358,10 +358,9 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
getDefaultSortOrder(columns?: ColumnProps<T>[]) {
const definedSortState = this.getSortStateFromColumns(columns);
const defaultSortedColumn = flatFilter(
columns || [],
(column: ColumnProps<T>) => column.defaultSortOrder != null,
)[0];
const defaultSortedColumn = flatFilter(columns || [], (column: ColumnProps<T>) => {
return column.defaultSortOrder != null;
})[0];
if (defaultSortedColumn && !definedSortState.sortColumn) {
return {
@ -807,7 +806,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
current: this.state.pagination.current,
};
}
this.setState(newState, () => this.scrollToFirstRow());
this.setState(newState, this.scrollToFirstRow);
this.props.store.setState({
selectionDirty: false,
@ -834,7 +833,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
pageSize,
current,
};
this.setState({ pagination: nextPagination });
this.setState({ pagination: nextPagination }, this.scrollToFirstRow);
const { onChange } = this.props;
if (onChange) {
@ -878,7 +877,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
// Controlled
if (this.getSortOrderColumns().length === 0) {
this.setState(newState, () => this.scrollToFirstRow());
this.setState(newState, this.scrollToFirstRow);
}
const { onChange } = this.props;

View File

@ -79,14 +79,32 @@ describe('Table.pagination', () => {
expect(wrapper.find('.ant-pagination.mini')).toHaveLength(1);
});
// TODO
it('should scroll to first row when page change', () => {
const wrapper = mount(createTable({ scroll: { y: 20 } }));
const wrapper = mount(
createTable({ scroll: { y: 20 }, pagination: { showSizeChanger: true, pageSize: 2 } }),
);
const scrollToSpy = jest.spyOn(
wrapper
.find('Table')
.first()
.instance(),
'scrollToFirstRow',
);
expect(scrollToSpy).toHaveBeenCalledTimes(0);
wrapper
.find('Pager')
.last()
.simulate('click');
expect(scrollToSpy).toHaveBeenCalledTimes(1);
wrapper.find('.ant-select').simulate('click');
wrapper
.find('MenuItem')
.find('li')
.last()
.simulate('click');
expect(scrollToSpy).toHaveBeenCalledTimes(2);
});
it('fires change event', () => {

View File

@ -676,4 +676,33 @@ describe('Table.sorter', () => {
expect(renderedNames(wrapper)).toEqual(['Brown', 'Green', 'Mike', 'Alex', 'Petter', 'Zoe']);
});
// https://github.com/ant-design/ant-design/issues/19443
it('should not being inifinite loop when using Table.Column with sortOrder', () => {
class Demo extends React.Component {
componentDidMount() {
this.setState({});
}
render() {
return (
<Table dataSource={[]}>
<Table.Column title="Age" dataIndex="age" sorter sortOrder="ascend" key="age" />
</Table>
);
}
}
expect(() => {
mount(<Demo />);
}).not.toThrow();
});
it('should support defaultOrder in Column', () => {
const wrapper = mount(
<Table dataSource={[{ key: '1', age: 1 }]}>
<Table.Column title="Age" dataIndex="age" sorter defaultSortOrder="ascend" key="age" />
</Table>,
);
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -72,3 +72,193 @@ exports[`Table.sorter renders sorter icon correctly 1`] = `
</tr>
</thead>
`;
exports[`Table.sorter should support defaultOrder in Column 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-sorters ant-table-column-sort"
>
<span
class="ant-table-header-column"
>
<div
class="ant-table-column-sorters"
>
<span
class="ant-table-column-title"
>
Age
</span>
<span
class="ant-table-column-sorter"
>
<div
class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full"
title="Sort"
>
<i
aria-label="icon: caret-up"
class="anticon anticon-caret-up ant-table-column-sorter-up on"
>
<svg
aria-hidden="true"
class=""
data-icon="caret-up"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z"
/>
</svg>
</i>
<i
aria-label="icon: caret-down"
class="anticon anticon-caret-down ant-table-column-sorter-down off"
>
<svg
aria-hidden="true"
class=""
data-icon="caret-down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"
/>
</svg>
</i>
</div>
</span>
</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="ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
>
1
</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

@ -9,7 +9,7 @@ title:
适合同时展示有大量数据和数据列。
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`。如果指定 `width` 不生效,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`。如果指定 `width` 不生效或出现白色垂直空隙,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
>
> 建议指定 `scroll.x` 为大于表格宽度的固定值或百分比。注意,且非固定列宽度之和不要超过 `scroll.x`
@ -17,7 +17,7 @@ title:
A Solution for displaying large amounts of data with long columns.
> Specify the width of columns if header and cell do not align properly. If specified width is not working, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
> Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
>
> A fixed value which is greater than table width for `scroll.x` is recommended. The sum of unfixed columns should not greater than `scroll.x`.

View File

@ -9,7 +9,7 @@ title:
对于列数很多的数据,可以固定前后的列,横向滚动查看其它数据,需要和 `scroll.x` 配合使用。
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`。如果指定 `width` 不生效,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`。如果指定 `width` 不生效或出现白色垂直空隙,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
>
> 建议指定 `scroll.x` 为大于表格宽度的固定值或百分比。注意,且非固定列宽度之和不要超过 `scroll.x`
@ -17,7 +17,7 @@ title:
To fix some columns and scroll inside other columns, and you must set `scroll.x` meanwhile.
> Specify the width of columns if header and cell do not align properly. If specified width is not working, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
> Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
>
> A fixed value which is greater than table width for `scroll.x` is recommended. The sum of unfixed columns should not greater than `scroll.x`.

View File

@ -9,13 +9,13 @@ title:
方便一页内展示大量数据。
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。如果指定 `width` 不生效,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。如果指定 `width` 不生效或出现白色垂直空隙,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
## en-US
Display large amounts of data in scrollable view.
> Specify width of columns if header and cell do not align properly. If specified width is not working, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
> Specify width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
```jsx
import { Table } from 'antd';

View File

@ -621,7 +621,8 @@
min-width: 100%;
// https://github.com/ant-design/ant-design/issues/14545
.@{table-prefix-cls}-fixed-columns-in-body {
// https://github.com/ant-design/ant-design/issues/19491
.@{table-prefix-cls}-fixed-columns-in-body:not([colspan]) {
visibility: hidden;
}
}

View File

@ -49,7 +49,7 @@ export interface TransferProps {
onChange?: (targetKeys: string[], direction: string, moveKeys: string[]) => void;
onSelectChange?: (sourceSelectedKeys: string[], targetSelectedKeys: string[]) => void;
style?: React.CSSProperties;
listStyle: (style: ListStyle) => React.CSSProperties | React.CSSProperties;
listStyle: ((style: ListStyle) => React.CSSProperties) | React.CSSProperties;
operationStyle?: React.CSSProperties;
titles?: string[];
operations?: string[];
@ -353,7 +353,7 @@ class Transfer extends React.Component<TransferProps, any> {
}
handleListStyle = (
listStyle: (style: ListStyle) => React.CSSProperties | React.CSSProperties,
listStyle: ((style: ListStyle) => React.CSSProperties) | React.CSSProperties,
direction: TransferDirection,
) => {
if (typeof listStyle === 'function') {

View File

@ -5,7 +5,7 @@ exports[`renders ./components/tree-select/demo/async.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="0"
>
<span
@ -53,7 +53,7 @@ exports[`renders ./components/tree-select/demo/basic.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled ant-select-allow-clear"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="0"
>
<span
@ -101,7 +101,7 @@ exports[`renders ./components/tree-select/demo/checkable.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="-1"
>
<span
@ -184,7 +184,7 @@ exports[`renders ./components/tree-select/demo/multiple.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled ant-select-allow-clear"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="-1"
>
<span
@ -231,7 +231,7 @@ exports[`renders ./components/tree-select/demo/suffix.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled ant-select-allow-clear"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="0"
>
<span
@ -279,7 +279,7 @@ exports[`renders ./components/tree-select/demo/treeData.md correctly 1`] = `
aria-haspopup="listbox"
class="ant-select ant-select-enabled"
role="combobox"
style="width:300px"
style="width:100%"
tabindex="0"
>
<span

View File

@ -63,7 +63,7 @@ class Demo extends React.Component {
return (
<TreeSelect
treeDataSimpleMode
style={{ width: 300 }}
style={{ width: '100%' }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"

View File

@ -32,7 +32,7 @@ class Demo extends React.Component {
return (
<TreeSelect
showSearch
style={{ width: 300 }}
style={{ width: '100%' }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"

View File

@ -74,7 +74,7 @@ class Demo extends React.Component {
showCheckedStrategy: SHOW_PARENT,
searchPlaceholder: 'Please select',
style: {
width: 300,
width: '100%',
},
};
return <TreeSelect {...tProps} />;

View File

@ -32,7 +32,7 @@ class Demo extends React.Component {
return (
<TreeSelect
showSearch
style={{ width: 300 }}
style={{ width: '100%' }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"

View File

@ -35,7 +35,7 @@ class Demo extends React.Component {
<TreeSelect
showSearch
suffixIcon={icon}
style={{ width: 300 }}
style={{ width: '100%' }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"

View File

@ -54,7 +54,7 @@ class Demo extends React.Component {
render() {
return (
<TreeSelect
style={{ width: 300 }}
style={{ width: '100%' }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={treeData}

View File

@ -232,6 +232,7 @@ describe('Typography', () => {
wrapper.find('TextArea').simulate('keyUp', { keyCode: KeyCode.ESC });
},
onChange => {
// eslint-disable-next-line
expect(onChange).not.toHaveBeenCalled();
},
);

View File

@ -41,6 +41,7 @@ export interface UploadFile<T = any> {
linkProps?: any;
type: string;
xhr?: T;
preview?: string;
}
export interface UploadChangeParam<T extends object = UploadFile> {

View File

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "3.24.3",
"version": "3.25.0",
"description": "An enterprise-class UI design language and React components implementation",
"keywords": [
"ant",
@ -158,7 +158,6 @@
"@types/warning": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "~2.4.0",
"@yesmeck/offline-plugin": "^5.0.5",
"antd-theme-generator": "^1.1.6",
"babel-eslint": "^10.0.1",
"babel-plugin-add-react-displayname": "^0.0.5",
@ -183,7 +182,7 @@
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-react": "^7.14.2",

View File

@ -89,7 +89,6 @@
h4,
section& p {
width: 98%;
margin: 0;
}

View File

@ -1,6 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
// eslint-disable-next-line jest/no-export
export default function focusTest(Component) {
describe('focus and blur', () => {
beforeAll(() => {

View File

@ -1,6 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
// eslint-disable-next-line jest/no-export
export default function mountTest(Component) {
describe(`mount and unmount`, () => {
// https://github.com/ant-design/ant-design/pull/18441