chore: auto merge branchs (#32225)

chore: sync master into feature
This commit is contained in:
github-actions[bot] 2021-09-18 08:15:36 +00:00 committed by GitHub
commit 44b5a1f168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 107 additions and 28 deletions

View File

@ -15,7 +15,7 @@ jobs:
filter-creator-authority: 'write'
filter-head-ref: 'master, feature, master-merge-feature, feature-merge-master'
filter-support-fork: false
skip-run-names: 'deploy preview, pr-check-ci, build preview failed'
skip-run-names: 'deploy preview, pr-check-ci, build preview failed, suggest-related-links'
conflict-review-body: '😅 This branch has conflicts that must be resolved!'
success-review: true
success-merge: true

View File

@ -10,7 +10,7 @@ on:
- cron: '13 13 * * */7'
jobs:
action:
suggest-related-links:
runs-on: ubuntu-18.04
steps:
- name: Cache dependencies
@ -30,4 +30,4 @@ jobs:
with:
mode: 'suggest'
repository: 'peaceiris/actions-gh-pages'
unclickable: true
unclickable: true

View File

@ -1,16 +1,9 @@
import canUseDom from 'rc-util/lib/Dom/canUseDom';
import { isStyleSupport } from 'rc-util/lib/Dom/styleChecker';
export const canUseDocElement = () => canUseDom() && window.document.documentElement;
export const isStyleSupport = (styleName: string | Array<string>): boolean => {
if (canUseDocElement()) {
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
const { documentElement } = window.document;
return styleNameList.some(name => name in documentElement.style);
}
return false;
};
export { isStyleSupport };
let flexGapSupported: boolean | undefined;
export const detectFlexGapSupported = () => {

View File

@ -873,4 +873,61 @@ describe('Form', () => {
expect(tooltipProps.title).toEqual('Bamboo');
});
});
it('warningOnly validate', async () => {
jest.useFakeTimers();
const wrapper = mount(
<Form>
<Form.Item>
<Form.Item name="test" rules={[{ required: true, warningOnly: true }]}>
<Input />
</Form.Item>
</Form.Item>
</Form>,
);
await change(wrapper, 0, '', true);
expect(wrapper.find('.ant-form-item-with-help').length).toBeTruthy();
expect(wrapper.find('.ant-form-item-has-warning').length).toBeTruthy();
jest.useRealTimers();
});
it('not warning when remove on validate', async () => {
jest.useFakeTimers();
let rejectFn = null;
const wrapper = mount(
<Form>
<Form.Item>
<Form.Item
noStyle
name="test"
rules={[
{
validator: () =>
new Promise((_, reject) => {
rejectFn = reject;
}),
},
]}
>
<Input />
</Form.Item>
</Form.Item>
</Form>,
);
await change(wrapper, 0, '', true);
wrapper.unmount();
// Delay validate failed
rejectFn(new Error('delay failed'));
expect(errorSpy).not.toHaveBeenCalled();
jest.useRealTimers();
});
});

View File

@ -244,7 +244,7 @@ Provide linkage between forms. If a sub form with `name` prop update, it will au
| resetFields | Reset fields to `initialValues` | (fields?: [FieldData](#FieldData)\[]) => void | |
| scrollToField | Scroll to field position | (name: [NamePath](#NamePath), options: \[[ScrollOptions](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options)]) => void | |
| setFields | Set fields status | (fields: [FieldData](#FieldData)\[]) => void | |
| setFieldsValue | Set fields value | (values) => void | |
| setFieldsValue | Set fields value(Will directly pass to form store. If you do not want to modify passed object, please clone first) | (values) => void | |
| submit | Submit the form. It's same as click `submit` button | () => void | |
| validateFields | Validate fields | (nameList?: [NamePath](#NamePath)\[]) => Promise | |

View File

@ -243,7 +243,7 @@ Form.List 渲染表单相关操作函数。
| resetFields | 重置一组字段到 `initialValues` | (fields?: [FieldData](#FieldData)\[]) => void | |
| scrollToField | 滚动到对应字段位置 | (name: [NamePath](#NamePath), options: \[[ScrollOptions](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options)]) => void | |
| setFields | 设置一组字段状态 | (fields: [FieldData](#FieldData)\[]) => void | |
| setFieldsValue | 设置表单的值 | (values) => void | |
| setFieldsValue | 设置表单的值(该值将直接传入 form store 中。如果你不希望传入对象被修改,请克隆后传入) | (values) => void | |
| submit | 提交表单,与点击 `submit` 按钮效果相同 | () => void | |
| validateFields | 触发表单验证 | (nameList?: [NamePath](#NamePath)\[]) => Promise | |

View File

@ -122,7 +122,7 @@ const Col = React.forwardRef<HTMLDivElement, ColProps>((props, ref) => {
// Hack for Firefox to avoid size issue
// https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553
if (flex && wrap === false && !mergedStyle.minWidth) {
if (wrap === false && !mergedStyle.minWidth) {
mergedStyle.minWidth = 0;
}
}

View File

@ -61,7 +61,7 @@ Select component to select value from options.
| showSearch | Whether show search input in single mode | boolean | false | |
| size | Size of Select input | `large` \| `middle` \| `small` | `middle` | |
| suffixIcon | The custom suffix icon | ReactNode | - | |
| tagRender | Customize tag render | (props) => ReactNode | - | |
| tagRender | Customize tag render, only applies when `mode` is set to `multiple` or `tags` | (props) => ReactNode | - | |
| tokenSeparators | Separator used to tokenize on `tag` and `multiple` mode | string\[] | - | |
| value | Current selected option (considered as a immutable array) | string \| string\[]<br />number \| number\[]<br />LabeledValue \| LabeledValue\[] | - | |
| virtual | Disable virtual scroll when set to false | boolean | true | 4.1.0 |

View File

@ -62,7 +62,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/_0XzgOis7/Select.svg
| showSearch | 使单选模式可搜索 | boolean | false | |
| size | 选择框大小 | `large` \| `middle` \| `small` | `middle` | |
| suffixIcon | 自定义的选择框后缀图标 | ReactNode | - | |
| tagRender | 自定义 tag 内容 render | (props) => ReactNode | - | |
| tagRender | 自定义 tag 内容 render,仅在 `mode``multiple``tags` 时生效 | (props) => ReactNode | - | |
| tokenSeparators | 在 `tags``multiple` 模式下自动分词的分隔符 | string\[] | - | |
| value | 指定当前选中的条目多选时为一个数组。value 数组引用未变化时Select 不会更新) | string \| string\[]<br />number \| number\[]<br />LabeledValue \| LabeledValue\[] | - | |
| virtual | 设置 false 时关闭虚拟滚动 | boolean | true | 4.1.0 |

View File

@ -99,7 +99,10 @@ export interface TableProps<RecordType>
showSorterTooltip?: boolean | TooltipProps;
}
function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
function InternalTable<RecordType extends object = any>(
props: TableProps<RecordType>,
ref: React.MutableRefObject<HTMLDivElement>,
) {
const {
prefixCls: customizePrefixCls,
className,
@ -483,7 +486,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
className,
);
return (
<div className={wrapperClassNames} style={style}>
<div ref={ref} className={wrapperClassNames} style={style}>
<Spin spinning={false} {...spinProps}>
{topPaginationNode}
<RcTable<RecordType>
@ -513,6 +516,21 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
);
}
const TableRef = React.forwardRef(InternalTable);
type InternalTableType = typeof TableRef;
interface TableInterface extends InternalTableType {
SELECTION_ALL: 'SELECT_ALL';
SELECTION_INVERT: 'SELECT_INVERT';
SELECTION_NONE: 'SELECT_NONE';
Column: typeof Column;
ColumnGroup: typeof ColumnGroup;
Summary: typeof Summary;
}
const Table = TableRef as TableInterface;
Table.defaultProps = {
rowKey: 'key',
};

View File

@ -261,4 +261,21 @@ describe('Table', () => {
mount(<Table columns={columns} rowKey={record => record.key} />);
expect(warnSpy).not.toBeCalled();
});
it('should support ref', () => {
warnSpy.mockReset();
const columns = [
{
title: 'Name',
key: 'name',
dataIndex: 'name',
},
];
const Wrapper = () => {
const ref = React.useRef();
return <Table ref={ref} columns={columns} />;
};
mount(<Wrapper />);
expect(warnSpy).not.toBeCalled();
});
});

View File

@ -109,7 +109,6 @@ cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
| onChange | 文本域编辑时触发 | function(event) | - | |
| onEnd | 按 ENTER 结束编辑状态时触发 | function | - | 4.14.0 |
| onStart | 进入编辑中状态时触发 | function | - | |
| onCancel | 按 ESC 退出编辑状态时触发 | function | - | |
### ellipsis

View File

@ -140,7 +140,7 @@
"rc-slider": "~9.7.1",
"rc-steps": "~4.1.0",
"rc-switch": "~3.2.0",
"rc-table": "~7.17.0",
"rc-table": "~7.18.0",
"rc-tabs": "~11.10.0",
"rc-textarea": "~0.3.0",
"rc-tooltip": "~5.1.1",
@ -148,7 +148,7 @@
"rc-tree-select": "~4.5.0-alpha.0",
"rc-trigger": "^5.2.10",
"rc-upload": "~4.3.0",
"rc-util": "^5.13.1",
"rc-util": "^5.14.0",
"scroll-into-view-if-needed": "^2.2.25"
},
"devDependencies": {

View File

@ -33,7 +33,6 @@ export default ({
onLangChange,
onDirectionChange,
}: NavigationProps) => {
const [isGitee, setIsGitee] = React.useState(false);
const menuMode = isMobile ? 'inline' : 'horizontal';
const module = pathname.split('/').slice(0, -1).join('/');
@ -70,10 +69,6 @@ export default ({
);
}
React.useEffect(() => {
setIsGitee(document.location.host.indexOf('gitee') !== -1);
}, []);
return (
<Menu
className={classNames('menu-site')}
@ -109,7 +104,7 @@ export default ({
</a>
</Menu.Item>
)}
{isZhCN && !isGitee && (
{isZhCN && typeof window !== 'undefined' && window.location.host.indexOf('gitee') === -1 && (
<Menu.Item key="mirror">
<a href="https://ant-design.gitee.io"></a>
</Menu.Item>