Merge pull request #19366 from ant-design/master

chore: Merge master into feature
This commit is contained in:
偏右 2019-10-23 14:44:58 +08:00 committed by GitHub
commit 4fd5dda8d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 276 additions and 120 deletions

View File

@ -1720,7 +1720,7 @@ timeline: true
- Upload 组件升级 `rc-upload``2.5.0`
- 🌟 新增 `directory` 属性,支持上传一个文件夹。[#7315](https://github.com/ant-design/ant-design/issues/7315)
- 🌟 `action` 属性支持作为一个返回 `Promise` 对象的函数,使用更加灵活。[fd96967](https://github.com/ant-design/ant-design/commit/fd96967c872600b79bb608e9ddf9f8c38814a704)
- Dropdown 增加新特性, 可以做为右键菜单来使用。
- Dropdown 增加新特性,可以做为右键菜单来使用。
- 🌟 给菜单项的 icon 提供默认的外间距样式。[8e60a59](https://github.com/ant-design/ant-design/commit/8e60a591fd24f644de4f67d69c2210e9270be9cc)
- 🌟 触发方式为 `contextMenu` 时自动调整菜单的位置。[16e4260](https://github.com/ant-design/ant-design/commit/16e42601d6772fc0830ee237a1e751a38a118676)
- Table 组件升级 `rc-table``6.2.2`。[f2fddff](https://github.com/ant-design/ant-design/commit/f2fddff3fd0d6b36e8e6d8ee06bfcbcc85ead4f0)
@ -1851,7 +1851,7 @@ timeline: true
- 💄 统一 less 的变量命名 [12d3046](https://github.com/ant-design/ant-design/commit/12d3046687a0dcdb51fece08dd2bea64f185cc40)
- 💄 微调了 `Dropdown` 的样式 [8e2f72f](https://github.com/ant-design/ant-design/commit/8e2f72ffe0eb300f5997296726b02246bf990c8f)
- 💄 现在中文文档的组件会用中文语言包进行演示。[9b17a94](https://github.com/ant-design/ant-design/commit/9b17a943f5d57d40d65041b7b0c247add09d2851)
- 💄 主站主题切换 修改为 `antd-theme-generato` ,感谢 [@mzohaibqc](https://github.com/mzohaibqc) 的工作.
- 💄 主站主题切换 修改为 `antd-theme-generator` ,感谢 [@mzohaibqc](https://github.com/mzohaibqc) 的工作.
- TypeScript
- 🐞 修复了 `Row` 中 gutter 属性的类型问题 [b7d508e](https://github.com/ant-design/ant-design/commit/b7d508e1662bf20a0cacbe6440a2ce31a65a8a59)
- 💄 改进了 `Form` 组件类型 [#10564](https://github.com/ant-design/ant-design/pull/10564)
@ -1862,7 +1862,7 @@ timeline: true
`2018-05-13`
- 🐞 修复 `Table` 过滤器和 `Transfer` 复选框无法点击的问题。[#10452](https://github.com/ant-design/ant-design/issues/10452)
- 🐞 修复 `Cascader` `displayRender` 里的链接无法点击的问题。[#10433](https://github.com/ant-design/ant-design/issues/10433)
- 🐞 修复 `Cascader``displayRender` 里的链接无法点击的问题。[#10433](https://github.com/ant-design/ant-design/issues/10433)
- 🐞 修复 `Button` ref 不兼容问题。[#10405](https://github.com/ant-design/ant-design/issues/10405)
- 🐞 修复 `Form` 表单项校验位置高度时出现抖动问题。[#10445](https://github.com/ant-design/ant-design/issues/10445)
- 🌟 设置 `Layout` 宽度时,允许使用任何的 CSS 单位。[#10479](https://github.com/ant-design/ant-design/pull/10479)
@ -1984,7 +1984,7 @@ timeline: true
- 🌟 新增 `defaultExpandParent` 用于在第一次渲染时自动展开父节点。
- 🌟 新增 `disabled` 用于禁用整棵树。
- 🌟 TreeNode 新增 `icon` 用于设置自定义图标。
- 🌟 优化了 TreeNode 设置 `disabled` 时的  勾选逻辑。
- 🌟 优化了 TreeNode 设置 `disabled` 时的勾选逻辑。
- 🌟 Anchor 新增 `getContainer` 用于指定内容滚动的容器。
- 🌟 Table 新增 less 变量 `@table-expanded-row-bg`。[#9789](https://github.com/ant-design/ant-design/pull/9789)
- 🐞 修复一处 less 语法错误。[#9832](https://github.com/ant-design/ant-design/pull/9832) [@jojoLockLock](https://github.com/jojoLockLock)

View File

@ -68,7 +68,7 @@ export default class Search extends React.Component<SearchProps, any> {
</Button>
);
}
return <Icon className={`${prefixCls}-icon`} type="loading" />;
return <Icon className={`${prefixCls}-icon`} type="loading" key="loadingIcon" />;
};
renderSuffix = (prefixCls: string) => {
@ -80,7 +80,7 @@ export default class Search extends React.Component<SearchProps, any> {
if (enterButton) return suffix;
const node = (
const icon = (
<Icon
className={`${prefixCls}-icon`}
type="search"
@ -90,16 +90,17 @@ export default class Search extends React.Component<SearchProps, any> {
);
if (suffix) {
let cloneSuffix = suffix;
if (React.isValidElement(cloneSuffix) && !cloneSuffix.key) {
cloneSuffix = React.cloneElement(cloneSuffix, {
key: 'originSuffix',
});
}
return [cloneSuffix, node];
return [
React.isValidElement(suffix)
? React.cloneElement(suffix, {
key: 'suffix',
})
: null,
icon,
];
}
return node;
return icon;
};
renderAddonAfter = (prefixCls: string) => {
@ -144,7 +145,14 @@ export default class Search extends React.Component<SearchProps, any> {
}
if (addonAfter) {
return [button, addonAfter];
return [
button,
React.isValidElement(addonAfter)
? React.cloneElement(addonAfter, {
key: 'addonAfter',
})
: null,
];
}
return button;
@ -161,6 +169,7 @@ export default class Search extends React.Component<SearchProps, any> {
} = this.props;
delete (restProps as any).onSearch;
delete (restProps as any).loading;
const prefixCls = getPrefixCls('input-search', customizePrefixCls);
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);

View File

@ -166,4 +166,21 @@ describe('Input.Search', () => {
expect(wrapper.render()).toMatchSnapshot();
expect(wrapperWithEnterButton.render()).toMatchSnapshot();
});
it('should support addonAfter and suffix for loading', () => {
const wrapper = mount(<Search loading suffix="suffix" addonAfter="addonAfter" />);
const wrapperWithEnterButton = mount(<Search loading enterButton suffix="suffix" addonAfter="addonAfter" />);
expect(wrapper.render()).toMatchSnapshot();
expect(wrapperWithEnterButton.render()).toMatchSnapshot();
});
it('should support invalid suffix', () => {
const wrapper = mount(<Search suffix={[]} />);
expect(wrapper.render()).toMatchSnapshot();
});
it('should support invalid addonAfter', () => {
const wrapper = mount(<Search addonAfter={[]} enterButton />);
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@ -98,6 +98,109 @@ exports[`Input.Search should support addonAfter 2`] = `
</span>
`;
exports[`Input.Search should support addonAfter and suffix for loading 1`] = `
<span
class="ant-input-search ant-input-group-wrapper"
>
<span
class="ant-input-wrapper ant-input-group"
>
<span
class="ant-input-search ant-input-affix-wrapper"
>
<input
class="ant-input"
type="text"
value=""
/>
<span
class="ant-input-suffix"
>
suffix
<i
aria-label="icon: loading"
class="anticon anticon-loading ant-input-search-icon"
>
<svg
aria-hidden="true"
class="anticon-spin"
data-icon="loading"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
/>
</svg>
</i>
</span>
</span>
<span
class="ant-input-group-addon"
>
addonAfter
</span>
</span>
</span>
`;
exports[`Input.Search should support addonAfter and suffix for loading 2`] = `
<span
class="ant-input-search ant-input-search-enter-button ant-input-group-wrapper"
>
<span
class="ant-input-wrapper ant-input-group"
>
<span
class="ant-input-search ant-input-search-enter-button ant-input-affix-wrapper"
>
<input
class="ant-input"
type="text"
value=""
/>
<span
class="ant-input-suffix"
>
suffix
</span>
</span>
<span
class="ant-input-group-addon"
>
<button
class="ant-btn ant-input-search-button ant-btn-primary"
type="button"
>
<i
aria-label="icon: loading"
class="anticon anticon-loading"
>
<svg
aria-hidden="true"
class="anticon-spin"
data-icon="loading"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
/>
</svg>
</i>
</button>
addonAfter
</span>
</span>
</span>
`;
exports[`Input.Search should support custom Button 1`] = `
<span
class="ant-input-search ant-input-search-enter-button ant-input-group-wrapper"
@ -151,6 +254,86 @@ exports[`Input.Search should support custom button 1`] = `
</span>
`;
exports[`Input.Search should support invalid addonAfter 1`] = `
<span
class="ant-input-search ant-input-search-enter-button ant-input-group-wrapper"
>
<span
class="ant-input-wrapper ant-input-group"
>
<input
class="ant-input"
type="text"
value=""
/>
<span
class="ant-input-group-addon"
>
<button
class="ant-btn ant-input-search-button ant-btn-primary"
type="button"
>
<i
aria-label="icon: search"
class="anticon anticon-search"
>
<svg
aria-hidden="true"
class=""
data-icon="search"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0 0 11.6 0l43.6-43.5a8.2 8.2 0 0 0 0-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"
/>
</svg>
</i>
</button>
</span>
</span>
</span>
`;
exports[`Input.Search should support invalid suffix 1`] = `
<span
class="ant-input-search ant-input-affix-wrapper"
>
<input
class="ant-input"
type="text"
value=""
/>
<span
class="ant-input-suffix"
>
<i
aria-label="icon: search"
class="anticon anticon-search ant-input-search-icon"
tabindex="-1"
>
<svg
aria-hidden="true"
class=""
data-icon="search"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0 0 11.6 0l43.6-43.5a8.2 8.2 0 0 0 0-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"
/>
</svg>
</i>
</span>
</span>
`;
exports[`Input.Search should support loading 1`] = `
<span
class="ant-input-search ant-input-affix-wrapper"

View File

@ -234,6 +234,34 @@ exports[`renders ./components/input/demo/align.md correctly 1`] = `
class="ant-typography"
>
Ant Design
<div
aria-label="Copy"
class="ant-typography-copy"
role="button"
style="border:0;background:transparent;padding:0;line-height:inherit;display:inline-block"
tabindex="0"
>
<i
aria-label="icon: copy"
class="anticon anticon-copy"
role="button"
>
<svg
aria-hidden="true"
class=""
data-icon="copy"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"
/>
</svg>
</i>
</div>
</span>
<span
class="ant-input-affix-wrapper"
@ -1848,42 +1876,6 @@ exports[`renders ./components/input/demo/search-input-loading.md correctly 1`] =
</span>
<br />
<br />
<span
class="ant-input-search ant-input-affix-wrapper"
>
<input
class="ant-input"
placeholder="input search loading with suffix"
type="text"
value=""
/>
<span
class="ant-input-suffix"
>
suffix
<i
aria-label="icon: loading"
class="anticon anticon-loading ant-input-search-icon"
>
<svg
aria-hidden="true"
class="anticon-spin"
data-icon="loading"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
/>
</svg>
</i>
</span>
</span>
<br />
<br />
<span
class="ant-input-search ant-input-search-enter-button ant-input-group-wrapper"
>
@ -1926,51 +1918,6 @@ exports[`renders ./components/input/demo/search-input-loading.md correctly 1`] =
</span>
</span>
</span>
<br />
<br />
<span
class="ant-input-search ant-input-search-enter-button ant-input-group-wrapper"
>
<span
class="ant-input-wrapper ant-input-group"
>
<input
class="ant-input"
placeholder="input search loading with enterButton and addonAfter"
type="text"
value=""
/>
<span
class="ant-input-group-addon"
>
<button
class="ant-btn ant-input-search-button ant-btn-primary"
type="button"
>
<i
aria-label="icon: loading"
class="anticon anticon-loading"
>
<svg
aria-hidden="true"
class="anticon-spin"
data-icon="loading"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
/>
</svg>
</i>
</button>
addonAfter
</span>
</span>
</span>
</div>
`;

View File

@ -258,7 +258,7 @@ exports[`Input.Search should support suffix 1`] = `
prefixCls="ant-input"
suffix={
Array [
"suffix",
null,
<Icon
className="ant-input-search-icon"
onClick={[Function]}
@ -282,7 +282,6 @@ exports[`Input.Search should support suffix 1`] = `
<span
className="ant-input-suffix"
>
suffix
<Icon
className="ant-input-search-icon"
key="searchIcon"

View File

@ -69,7 +69,7 @@ ReactDOM.render(
<Input.TextArea rows={1} style={{ width: 100 }} />
<Button type="primary">Button</Button>
<Input style={{ width: 100 }} />
<Text copiable>Ant Design</Text>
<Text copyable>Ant Design</Text>
<Input prefix="1" suffix="2" style={{ width: 100 }} />
<Input addonBefore="1" addonAfter="2" style={{ width: 100 }} />
<InputNumber style={{ width: 100 }} />

View File

@ -23,18 +23,7 @@ ReactDOM.render(
<Search placeholder="input search loading deault" loading />
<br />
<br />
<Search placeholder="input search loading with suffix" loading suffix="suffix" />
<br />
<br />
<Search placeholder="input search loading with enterButton" loading enterButton />
<br />
<br />
<Search
placeholder="input search loading with enterButton and addonAfter"
loading
enterButton
addonAfter="addonAfter"
/>
</div>,
mountNode,
);

View File

@ -17,6 +17,7 @@ import { flatArray, treeMap, flatFilter, normalizeColumns } from './util';
import scrollTo from '../_util/scrollTo';
import {
TableProps,
InternalTableProps,
TableSize,
TableState,
TableComponents,
@ -34,7 +35,6 @@ import {
PaginationConfig,
PrepareParamsArgumentsReturn,
ExpandIconProps,
WithStore,
CheckboxPropsCache,
} from './interface';
import Pagination from '../pagination';
@ -133,7 +133,7 @@ function isFiltersChanged<T>(state: TableState<T>, filters: TableStateFilters):
return Object.keys(filters).some(columnKey => filters[columnKey] !== state.filters[columnKey]);
}
class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
static propTypes = {
dataSource: PropTypes.array,
columns: PropTypes.array,
@ -166,7 +166,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
childrenColumnName: 'children',
};
static getDerivedStateFromProps(nextProps: TableProps<any>, prevState: TableState<any>) {
static getDerivedStateFromProps(nextProps: InternalTableProps<any>, prevState: TableState<any>) {
const { prevProps } = prevState;
const columns =
nextProps.columns || normalizeColumns(nextProps.children as React.ReactChildren);
@ -241,7 +241,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
rcTable: any;
constructor(props: TableProps<T>) {
constructor(props: InternalTableProps<T>) {
super(props);
const { expandedRowRender, columns: columnsProp = [] } = props;
@ -1366,7 +1366,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
polyfill(Table);
class StoreTable<T> extends React.Component<Omit<TableProps<T>, keyof WithStore>> {
class StoreTable<T> extends React.Component<TableProps<T>> {
static displayName = 'withStore(Table)';
static Column = Column;

View File

@ -161,7 +161,7 @@ export interface WithStore {
setCheckboxPropsCache: (cache: CheckboxPropsCache) => void;
}
export interface TableProps<T> extends WithStore {
export interface TableProps<T> {
prefixCls?: string;
dropdownPrefixCls?: string;
rowSelection?: TableRowSelection<T>;
@ -219,6 +219,8 @@ export interface TableProps<T> extends WithStore {
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
}
export type InternalTableProps<T> = TableProps<T> & WithStore;
export interface TableStateFilters {
[key: string]: string[];
}

View File

@ -102,7 +102,7 @@
.@{table-prefix-cls}-header {
background-color: @component-background;
border-radius: @border-radius-base @border-radius-base 0 0;
border-radius: @table-border-radius-base @table-border-radius-base 0 0;
}
.@{table-prefix-cls}-placeholder,
@ -161,4 +161,12 @@
margin: -@table-padding-vertical-sm -@table-padding-horizontal / 2 -@table-padding-vertical-sm -
1px;
}
// https://github.com/ant-design/ant-design/issues/19287#issuecomment-544368967
&.@{table-prefix-cls}-fixed-header
> .@{table-prefix-cls}-content
> .@{table-prefix-cls}-scroll
> .@{table-prefix-cls}-body {
border-radius: 0 0 @table-border-radius-base @table-border-radius-base;
}
}

View File

@ -24,7 +24,7 @@ export interface RcCustomRequestOptions {
headers: object;
}
export interface UploadFile {
export interface UploadFile<T = any> {
uid: string;
size: number;
name: string;
@ -36,7 +36,7 @@ export interface UploadFile {
percent?: number;
thumbUrl?: string;
originFileObj?: File | Blob;
response?: any;
response?: T;
error?: any;
linkProps?: any;
type: string;

View File

@ -157,7 +157,7 @@
"@types/shallowequal": "^1.1.1",
"@types/warning": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^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",

View File

@ -59,6 +59,7 @@ describe('site test', () => {
root: join(process.cwd(), '_site'),
});
server.listen(host);
// eslint-disable-next-line no-console
console.log('site static server run: http://localhost:3000');
});

View File

@ -1,5 +1,6 @@
const React = require('react');
// eslint-disable-next-line no-console
console.log('Current React Version:', React.version);
/* eslint-disable global-require */