diff --git a/.github/workflows/pr-check-ci.yml b/.github/workflows/pr-check-ci.yml index 73c2810b17..95a9cb14ee 100644 --- a/.github/workflows/pr-check-ci.yml +++ b/.github/workflows/pr-check-ci.yml @@ -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 diff --git a/.github/workflows/suggest-related-links.yml b/.github/workflows/suggest-related-links.yml index 2b3677e990..ff0bc7d640 100644 --- a/.github/workflows/suggest-related-links.yml +++ b/.github/workflows/suggest-related-links.yml @@ -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 \ No newline at end of file + unclickable: true diff --git a/components/_util/styleChecker.tsx b/components/_util/styleChecker.tsx index d45a0f7a6f..0c291d4f30 100644 --- a/components/_util/styleChecker.tsx +++ b/components/_util/styleChecker.tsx @@ -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): 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 = () => { diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.js index de3b9e67d4..b741fbc473 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.js @@ -873,4 +873,61 @@ describe('Form', () => { expect(tooltipProps.title).toEqual('Bamboo'); }); }); + + it('warningOnly validate', async () => { + jest.useFakeTimers(); + + const wrapper = mount( +
+ + + + + +
, + ); + + 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( +
+ + + new Promise((_, reject) => { + rejectFn = reject; + }), + }, + ]} + > + + + +
, + ); + + await change(wrapper, 0, '', true); + + wrapper.unmount(); + + // Delay validate failed + rejectFn(new Error('delay failed')); + + expect(errorSpy).not.toHaveBeenCalled(); + + jest.useRealTimers(); + }); }); diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 3be5dfc427..e47aebac7a 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -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 | | diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index ab2bd24671..c136af1b7a 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -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 | | diff --git a/components/grid/col.tsx b/components/grid/col.tsx index 11816cceae..dacf1e1655 100644 --- a/components/grid/col.tsx +++ b/components/grid/col.tsx @@ -122,7 +122,7 @@ const Col = React.forwardRef((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; } } diff --git a/components/select/index.en-US.md b/components/select/index.en-US.md index 715aaf9015..bb9cbdd940 100644 --- a/components/select/index.en-US.md +++ b/components/select/index.en-US.md @@ -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\[]
number \| number\[]
LabeledValue \| LabeledValue\[] | - | | | virtual | Disable virtual scroll when set to false | boolean | true | 4.1.0 | diff --git a/components/select/index.zh-CN.md b/components/select/index.zh-CN.md index f400a39eb5..f72d469137 100644 --- a/components/select/index.zh-CN.md +++ b/components/select/index.zh-CN.md @@ -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\[]
number \| number\[]
LabeledValue \| LabeledValue\[] | - | | | virtual | 设置 false 时关闭虚拟滚动 | boolean | true | 4.1.0 | diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 576c7ff45c..3c9ef4db69 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -99,7 +99,10 @@ export interface TableProps showSorterTooltip?: boolean | TooltipProps; } -function Table(props: TableProps) { +function InternalTable( + props: TableProps, + ref: React.MutableRefObject, +) { const { prefixCls: customizePrefixCls, className, @@ -483,7 +486,7 @@ function Table(props: TableProps) { className, ); return ( -
+
{topPaginationNode} @@ -513,6 +516,21 @@ function Table(props: TableProps) { ); } +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', }; diff --git a/components/table/__tests__/Table.test.js b/components/table/__tests__/Table.test.js index 8c4988e431..299724a105 100644 --- a/components/table/__tests__/Table.test.js +++ b/components/table/__tests__/Table.test.js @@ -261,4 +261,21 @@ describe('Table', () => { mount( 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
; + }; + mount(); + expect(warnSpy).not.toBeCalled(); + }); }); diff --git a/components/typography/index.zh-CN.md b/components/typography/index.zh-CN.md index a545a83819..0191198026 100644 --- a/components/typography/index.zh-CN.md +++ b/components/typography/index.zh-CN.md @@ -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 diff --git a/package.json b/package.json index 92ecd7b3d0..3fc14ef3d4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/site/theme/template/Layout/Header/Navigation.tsx b/site/theme/template/Layout/Header/Navigation.tsx index e38fe48c7c..9ffc3cb8c1 100644 --- a/site/theme/template/Layout/Header/Navigation.tsx +++ b/site/theme/template/Layout/Header/Navigation.tsx @@ -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 ( )} - {isZhCN && !isGitee && ( + {isZhCN && typeof window !== 'undefined' && window.location.host.indexOf('gitee') === -1 && ( 国内镜像