From dc100b17c53609980db3a429dff27a40396c9693 Mon Sep 17 00:00:00 2001 From: mumiao Date: Sat, 20 Feb 2021 16:32:59 +0800 Subject: [PATCH 01/13] fix(table): optimize type declaration about filter (#29385) --- components/table/Table.tsx | 15 ++++++++------- .../table/hooks/useFilter/FilterDropdown.tsx | 2 +- components/table/hooks/useFilter/index.tsx | 19 +++++++++++-------- components/table/interface.tsx | 6 ++++-- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 3ad6d08572..e0c2da89ca 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -18,7 +18,6 @@ import { ColumnsType, TableCurrentDataSource, SorterResult, - Key, GetPopupContainer, ExpandableConfig, ExpandType, @@ -26,6 +25,7 @@ import { SortOrder, TableLocale, TableAction, + FilterValue, } from './interface'; import useSelection, { SELECTION_ALL, @@ -54,7 +54,7 @@ interface ChangeEventInfo { pageSize?: number; total?: number; }; - filters: Record; + filters: Record; sorter: SorterResult | SorterResult[]; filterStates: FilterState[]; @@ -85,7 +85,7 @@ export interface TableProps onChange?: ( pagination: TablePaginationConfig, - filters: Record, + filters: Record, sorter: SorterResult | SorterResult[], extra: TableCurrentDataSource, ) => void; @@ -236,9 +236,10 @@ function Table(props: TableProps) { }; /** - * Controlled state in `columns` is not a good idea that makes too many code (1000+ line?) to read - * state out and then put it back to title render. Move these code into `hooks` but still too - * complex. We should provides Table props like `sorter` & `filter` to handle control in next big version. + * Controlled state in `columns` is not a good idea that makes too many code (1000+ line?) to + * read state out and then put it back to title render. Move these code into `hooks` but still + * too complex. We should provides Table props like `sorter` & `filter` to handle control in next + * big version. */ // ============================ Sorter ============================= @@ -273,7 +274,7 @@ function Table(props: TableProps) { // ============================ Filter ============================ const onFilterChange = ( - filters: Record, + filters: Record, filterStates: FilterState[], ) => { triggerOnChange( diff --git a/components/table/hooks/useFilter/FilterDropdown.tsx b/components/table/hooks/useFilter/FilterDropdown.tsx index 5a0358c144..044e4c99a7 100644 --- a/components/table/hooks/useFilter/FilterDropdown.tsx +++ b/components/table/hooks/useFilter/FilterDropdown.tsx @@ -134,7 +134,7 @@ function FilterDropdown(props: FilterDropdownProps) { typeof filterDropdownVisible === 'boolean' ? filterDropdownVisible : visible; // ===================== Select Keys ===================== - const propFilteredKeys = filterState && filterState.filteredKeys; + const propFilteredKeys = filterState?.filteredKeys; const [getFilteredKeysSync, setFilteredKeysSync] = useSyncState(propFilteredKeys || []); const onSelectKeys = ({ selectedKeys }: { selectedKeys?: Key[] }) => { diff --git a/components/table/hooks/useFilter/index.tsx b/components/table/hooks/useFilter/index.tsx index 09d0f65443..a0208de9c8 100644 --- a/components/table/hooks/useFilter/index.tsx +++ b/components/table/hooks/useFilter/index.tsx @@ -6,6 +6,8 @@ import { ColumnTitleProps, Key, TableLocale, + FilterValue, + FilterKey, GetPopupContainer, ColumnFilterItem, } from '../../interface'; @@ -15,7 +17,7 @@ import FilterDropdown from './FilterDropdown'; export interface FilterState { column: ColumnType; key: Key; - filteredKeys?: Key[] | null; + filteredKeys?: FilterKey; forceFiltered?: boolean; } @@ -41,7 +43,7 @@ function collectFilterStates( filterStates.push({ column, key: getColumnKey(column, columnPos), - filteredKeys: filteredValues, + filteredKeys: filteredValues as FilterKey, forceFiltered: column.filtered, }); } else { @@ -49,8 +51,9 @@ function collectFilterStates( filterStates.push({ column, key: getColumnKey(column, columnPos), - filteredKeys: - init && column.defaultFilteredValue ? column.defaultFilteredValue! : undefined, + filteredKeys: (init && column.defaultFilteredValue + ? column.defaultFilteredValue! + : undefined) as FilterKey, forceFiltered: column.filtered, }); } @@ -121,7 +124,7 @@ function injectFilter( } function flattenKeys(filters?: ColumnFilterItem[]) { - let keys: (string | number | boolean)[] = []; + let keys: FilterValue = []; (filters || []).forEach(({ value, children }) => { keys.push(value); if (children) { @@ -132,7 +135,7 @@ function flattenKeys(filters?: ColumnFilterItem[]) { } function generateFilterInfo(filterStates: FilterState[]) { - const currentFilters: Record = {}; + const currentFilters: Record = {}; filterStates.forEach(({ key, filteredKeys, column }) => { const { filters, filterDropdown } = column; @@ -178,7 +181,7 @@ interface FilterConfig { mergedColumns: ColumnsType; locale: TableLocale; onFilterChange: ( - filters: Record, + filters: Record, filterStates: FilterState[], ) => void; getPopupContainer?: GetPopupContainer; @@ -194,7 +197,7 @@ function useFilter({ }: FilterConfig): [ TransformColumns, FilterState[], - () => Record, + () => Record, ] { const [filterStates, setFilterStates] = React.useState[]>( collectFilterStates(mergedColumns, true), diff --git a/components/table/interface.tsx b/components/table/interface.tsx index 5652bb01fc..bc01c9bc8e 100644 --- a/components/table/interface.tsx +++ b/components/table/interface.tsx @@ -68,6 +68,8 @@ export type ColumnTitle = | React.ReactNode | ((props: ColumnTitleProps) => React.ReactNode); +export type FilterValue = (Key | boolean)[]; +export type FilterKey = Key[] | null; export interface FilterConfirmProps { closeDropdown: boolean; } @@ -103,8 +105,8 @@ export interface ColumnType extends RcColumnType { filters?: ColumnFilterItem[]; filterDropdown?: React.ReactNode | ((props: FilterDropdownProps) => React.ReactNode); filterMultiple?: boolean; - filteredValue?: Key[] | null; - defaultFilteredValue?: Key[] | null; + filteredValue?: FilterValue | null; + defaultFilteredValue?: FilterValue | null; filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode); onFilter?: (value: string | number | boolean, record: RecordType) => boolean; filterDropdownVisible?: boolean; From 4c3898ebf3b8ca5e2e1c22cbcd790dee92d33b4e Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Sat, 20 Feb 2021 17:10:12 +0800 Subject: [PATCH 02/13] docs: improve table api (#29391) --- components/table/index.en-US.md | 2 +- components/table/index.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/table/index.en-US.md b/components/table/index.en-US.md index 09168d5675..39796c0374 100644 --- a/components/table/index.en-US.md +++ b/components/table/index.en-US.md @@ -67,7 +67,7 @@ const columns = [ | expandable | Config expandable content | [expandable](#expandable) | - | | | footer | Table footer renderer | function(currentPageData) | - | | | getPopupContainer | The render container of dropdowns in table | (triggerNode) => HTMLElement | () => TableHtmlElement | | -| loading | Loading status of table | boolean \| [object](/components/spin/#API) ([more](https://github.com/ant-design/ant-design/issues/4544#issuecomment-271533135)) | false | | +| loading | Loading status of table | boolean \| [Spin Props](/components/spin/#API) | false | | | locale | The i18n text including filter, sort, empty text, etc | object | filterConfirm: `Ok`
filterReset: `Reset`
emptyText: `No Data`
[Default](https://github.com/ant-design/ant-design/blob/4ad1ccac277782d7ed14f7e5d02d6346aae0db67/components/locale/default.tsx#L19) | | | pagination | Config of pagination. You can ref table pagination [config](#pagination) or full [`pagination`](/components/pagination/) document, hide it by setting it to `false` | object | - | | | rowClassName | Row's className | function(record, index): string | - | | diff --git a/components/table/index.zh-CN.md b/components/table/index.zh-CN.md index c6806cb048..b93f2c8266 100644 --- a/components/table/index.zh-CN.md +++ b/components/table/index.zh-CN.md @@ -74,7 +74,7 @@ const columns = [ | expandable | 配置展开属性 | [expandable](#expandable) | - | | | footer | 表格尾部 | function(currentPageData) | - | | | getPopupContainer | 设置表格内各类浮层的渲染节点,如筛选菜单 | (triggerNode) => HTMLElement | () => TableHtmlElement | | -| loading | 页面是否加载中 | boolean \| [object](/components/spin/#API) ([更多](https://github.com/ant-design/ant-design/issues/4544#issuecomment-271533135)) | false | | +| loading | 页面是否加载中 | boolean \| [Spin Props](/components/spin/#API) | false | | | locale | 默认文案设置,目前包括排序、过滤、空数据文案 | object | filterConfirm: `确定`
filterReset: `重置`
emptyText: `暂无数据`
[默认值](https://github.com/ant-design/ant-design/blob/4ad1ccac277782d7ed14f7e5d02d6346aae0db67/components/locale/default.tsx#L19) | | | pagination | 分页器,参考[配置项](#pagination)或 [pagination](/components/pagination/) 文档,设为 false 时不展示和进行分页 | object | - | | | rowClassName | 表格行的类名 | function(record, index): string | - | | From 0c7d955734047782fa1bdab7ab525706a1b928bc Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Sat, 20 Feb 2021 17:56:03 +0800 Subject: [PATCH 03/13] docs: improve table api (#29393) --- components/table/index.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/table/index.zh-CN.md b/components/table/index.zh-CN.md index b93f2c8266..f91b3974c4 100644 --- a/components/table/index.zh-CN.md +++ b/components/table/index.zh-CN.md @@ -205,7 +205,7 @@ const columns = [ | renderCell | 渲染勾选框,用法与 Column 的 `render` 相同 | function(checked, record, index, originNode) {} | - | 4.1.0 | | selectedRowKeys | 指定选中项的 key 数组,需要和 onChange 进行配合 | string\[] \| number\[] | \[] | | | selections | 自定义选择项 [配置项](#selection), 设为 `true` 时使用默认选择项 | object\[] \| boolean | true | | -| type | 多选/单选,`checkbox` or `radio` | string | `checkbox` | | +| type | 多选/单选 | `checkbox` \| `radio` | `checkbox` | | | onChange | 选中项发生变化时的回调 | function(selectedRowKeys, selectedRows) | - | | | onSelect | 用户手动选择/取消选择某行的回调 | function(record, selected, selectedRows, nativeEvent) | - | | | onSelectAll | 用户手动选择/取消选择所有行的回调 | function(selected, selectedRows, changeRows) | - | | From 19c8c426e5a8b914c7b9b846dfb84fb2693f0a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <7971419+crazyair@users.noreply.github.com> Date: Sat, 20 Feb 2021 22:24:44 +0800 Subject: [PATCH 04/13] fix: image prefix (#29394) * fix: image * fix: image group * fix: image package * chore: test --- components/image/PreviewGroup.tsx | 26 +++++++++++++- components/image/__tests__/index.test.js | 43 ++++++++++++++++++++++++ components/image/index.tsx | 7 +++- package.json | 2 +- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/components/image/PreviewGroup.tsx b/components/image/PreviewGroup.tsx index c854c0ba92..f92064164d 100644 --- a/components/image/PreviewGroup.tsx +++ b/components/image/PreviewGroup.tsx @@ -9,6 +9,7 @@ import LeftOutlined from '@ant-design/icons/LeftOutlined'; import RightOutlined from '@ant-design/icons/RightOutlined'; import { GroupConsumerProps } from 'rc-image/lib/PreviewGroup'; import { ConfigContext } from '../config-provider'; +import { getTransitionName } from '../_util/motion'; export const icons = { rotateLeft: , @@ -22,11 +23,34 @@ export const icons = { const InternalPreviewGroup: React.FC = ({ previewPrefixCls: customizePrefixCls, + preview, ...props }) => { const { getPrefixCls } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('image-preview', customizePrefixCls); - return ; + const rootPrefixCls = getPrefixCls(); + + const mergedPreview = React.useMemo(() => { + if (preview === false) { + return preview; + } + const _preview = typeof preview === 'object' ? preview : {}; + + return { + ..._preview, + transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName), + maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName), + }; + }, [preview]); + + return ( + + ); }; export default InternalPreviewGroup; diff --git a/components/image/__tests__/index.test.js b/components/image/__tests__/index.test.js index edcd3eba6e..f2217d7894 100644 --- a/components/image/__tests__/index.test.js +++ b/components/image/__tests__/index.test.js @@ -1,8 +1,51 @@ +import React from 'react'; +import { mount } from 'enzyme'; import Image from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; +const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'; + describe('Image', () => { mountTest(Image); rtlTest(Image); + it('Default preview props', () => { + const wrapper = mount(); + + expect(wrapper.find('Preview').prop('transitionName')).toBe('ant-zoom'); + expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('ant-fade'); + }); + it('Default Group preview props', () => { + const wrapper = mount( + + + , + ); + + expect(wrapper.find('Preview').prop('transitionName')).toBe('ant-zoom'); + expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('ant-fade'); + }); + it('Customize preview props', () => { + const wrapper = mount( + , + ); + + expect(wrapper.find('Preview').prop('transitionName')).toBe('abc'); + expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('def'); + }); + it('Customize Group preview props', () => { + const wrapper = mount( + + + , + ); + + expect(wrapper.find('Preview').prop('transitionName')).toBe('abc'); + expect(wrapper.find('Preview').prop('maskTransitionName')).toBe('def'); + }); }); diff --git a/components/image/index.tsx b/components/image/index.tsx index 0e00dd5d8f..dab9efcc70 100644 --- a/components/image/index.tsx +++ b/components/image/index.tsx @@ -5,6 +5,7 @@ import RcImage, { ImageProps } from 'rc-image'; import defaultLocale from '../locale/en_US'; import PreviewGroup, { icons } from './PreviewGroup'; import { ConfigContext } from '../config-provider'; +import { getTransitionName } from '../_util/motion'; export interface CompositionImage

extends React.FC

{ PreviewGroup: typeof PreviewGroup; @@ -17,6 +18,7 @@ const Image: CompositionImage = ({ }) => { const { getPrefixCls } = useContext(ConfigContext); const prefixCls = getPrefixCls('image', customizePrefixCls); + const rootPrefixCls = getPrefixCls(); const { locale: contextLocale = defaultLocale } = useContext(ConfigContext); const imageLocale = contextLocale.Image || defaultLocale.Image; @@ -25,6 +27,7 @@ const Image: CompositionImage = ({ if (preview === false) { return preview; } + const _preview = typeof preview === 'object' ? preview : {}; return { mask: ( @@ -34,7 +37,9 @@ const Image: CompositionImage = ({ ), icons, - ...(typeof preview === 'object' ? preview : null), + ..._preview, + transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName), + maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName), }; }, [preview, imageLocale]); diff --git a/package.json b/package.json index fdc709b060..a4fcefebbe 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "rc-drawer": "~4.3.0", "rc-dropdown": "~3.2.0", "rc-field-form": "~1.19.0", - "rc-image": "~5.2.0", + "rc-image": "~5.2.3", "rc-input-number": "~6.2.0", "rc-mentions": "~1.5.0", "rc-menu": "~8.10.0", From d9cc4c2af9b088621e9297cbac3c83d400016d3c Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Sun, 21 Feb 2021 22:33:09 +0800 Subject: [PATCH 05/13] docs: improve custom theme by umi (#29382) * docs: improve custom theme by umi * Update customize-theme.zh-CN.md * improve --- docs/react/customize-theme.en-US.md | 2 +- docs/react/customize-theme.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/react/customize-theme.en-US.md b/docs/react/customize-theme.en-US.md index 56b19e8383..3b2cca6b4b 100644 --- a/docs/react/customize-theme.en-US.md +++ b/docs/react/customize-theme.en-US.md @@ -75,7 +75,7 @@ Note: ### Customize in Umi -You can easily use [theme](https://umijs.org/config/#theme) field in [config/config.js](https://github.com/ant-design/ant-design-pro/blob/56e648ec14bdb9f6724169fd64830447e224ccb1/config/config.js#L45) (Umi) file of your project root directory if you are using [Umi](http://umijs.org/), which could be an object or a javascript file path. +You can easily use [theme](https://umijs.org/config/#theme) field in `.umirc.ts` or [config/config.ts](https://github.com/ant-design/ant-design-pro/blob/v5/config/config.ts) file of your project root directory if you are using [Umi](http://umijs.org/), which could be an object or a javascript file path. ```js "theme": { diff --git a/docs/react/customize-theme.zh-CN.md b/docs/react/customize-theme.zh-CN.md index b19fc54b8f..9483d05bf0 100644 --- a/docs/react/customize-theme.zh-CN.md +++ b/docs/react/customize-theme.zh-CN.md @@ -75,7 +75,7 @@ module.exports = { ### 在 Umi 里配置主题 -如果你在使用 [Umi](http://umijs.org/zh/),那么可以很方便地在项目根目录的 [config/config.js](https://github.com/ant-design/ant-design-pro/blob/56e648ec14bdb9f6724169fd64830447e224ccb1/config/config.js#L45)(Umi)文件中 [theme](https://umijs.org/zh/config/#theme) 字段进行主题配置。`theme` 可以配置为一个对象或文件路径。 +如果你在使用 [Umi](http://umijs.org/zh/),那么可以很方便地在项目根目录的 `.umirc.ts` 或 [config/config.ts](https://github.com/ant-design/ant-design-pro/blob/v5/config/config.ts) 文件中 [theme](https://umijs.org/zh-CN/config#theme) 字段进行主题配置。`theme` 可以配置为一个对象或文件路径。 ```js "theme": { From 7f68a8e347d5e56325c5948227bcffc513301db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 22 Feb 2021 15:55:17 +0800 Subject: [PATCH 06/13] docs: Update Select debounce demo (#29414) * docs: Update debounce demo * fix: ts definition --- components/select/demo/select-users.md | 132 ++++++++++++++----------- 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/components/select/demo/select-users.md b/components/select/demo/select-users.md index df9a9f080e..f8efd900ce 100644 --- a/components/select/demo/select-users.md +++ b/components/select/demo/select-users.md @@ -13,74 +13,94 @@ title: A complete multiple select sample with remote search, debounce fetch, ajax callback order flow, and loading state. -```jsx +```tsx import { Select, Spin } from 'antd'; +import { SelectProps } from 'antd/es/select'; import debounce from 'lodash/debounce'; -const { Option } = Select; +export interface DebounceSelectProps + extends Omit, 'options' | 'children'> { + fetchOptions: (search: string) => Promise; + debounceTimeout?: number; +} -class UserRemoteSelect extends React.Component { - constructor(props) { - super(props); - this.lastFetchId = 0; - this.fetchUser = debounce(this.fetchUser, 800); - } +function DebounceSelect< + ValueType extends { key?: string; label: React.ReactNode; value: string | number } = any +>({ fetchOptions, debounceTimeout = 800, ...props }: DebounceSelectProps) { + const [fetching, setFetching] = React.useState(false); + const [options, setOptions] = React.useState([]); + const fetchRef = React.useRef(0); - state = { - data: [], - value: [], - fetching: false, - }; + const debounceFetcher = React.useMemo(() => { + const loadOptions = (value: string) => { + fetchRef.current += 1; + const fetchId = fetchRef.current; + setOptions([]); + setFetching(true); - fetchUser = value => { - console.log('fetching user', value); - this.lastFetchId += 1; - const fetchId = this.lastFetchId; - this.setState({ data: [], fetching: true }); - fetch('https://randomuser.me/api/?results=5') - .then(response => response.json()) - .then(body => { - if (fetchId !== this.lastFetchId) { + fetchOptions(value).then(newOptions => { + if (fetchId !== fetchRef.current) { // for fetch callback order return; } - const data = body.results.map(user => ({ - text: `${user.name.first} ${user.name.last}`, - value: user.login.username, - })); - this.setState({ data, fetching: false }); + + setOptions(newOptions); + setFetching(false); }); - }; + }; - handleChange = value => { - this.setState({ - value, - data: [], - fetching: false, - }); - }; + return debounce(loadOptions, debounceTimeout); + }, [fetchOptions, debounceTimeout]); - render() { - const { fetching, data, value } = this.state; - return ( - - ); - } + return ( + + labelInValue + filterOption={false} + onSearch={debounceFetcher} + notFoundContent={fetching ? : null} + {...props} + options={options} + /> + ); } -ReactDOM.render(, mountNode); +// Usage of DebounceSelect +interface UserValue { + label: string; + value: string; +} + +async function fetchUserList(username: string): Promise { + console.log('fetching user', username); + + return fetch('https://randomuser.me/api/?results=5') + .then(response => response.json()) + .then(body => + body.results.map( + (user: { name: { first: string; last: string }; login: { username: string } }) => ({ + label: `${user.name.first} ${user.name.last}`, + value: user.login.username, + }), + ), + ); +} + +const Demo = () => { + const [value, setValue] = React.useState([]); + + return ( + { + setValue(newValue); + }} + style={{ width: '100%' }} + /> + ); +}; + +ReactDOM.render(, mountNode); ``` From 31ea9c3c1ddac48f20d54e3d7255cdf195ae34b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <7971419+crazyair@users.noreply.github.com> Date: Mon, 22 Feb 2021 16:03:04 +0800 Subject: [PATCH 07/13] fix: image-test (#29410) * fix: image-test * chore: text --- components/image/__tests__/index.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/image/__tests__/index.test.js b/components/image/__tests__/index.test.js index f2217d7894..39028231b5 100644 --- a/components/image/__tests__/index.test.js +++ b/components/image/__tests__/index.test.js @@ -9,6 +9,21 @@ const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWP describe('Image', () => { mountTest(Image); rtlTest(Image); + it('Image preview props set false', () => { + const wrapper = mount(); + + expect(wrapper.find('Image').at(0).prop('preview')).toBe(false); + expect(wrapper.find('Image').at(1).prop('preview')).toBe(false); + }); + it('Group preview props set false', () => { + const wrapper = mount( + + + , + ); + expect(wrapper.find('Group').prop('preview')).toBe(false); + }); + it('Default preview props', () => { const wrapper = mount(); From 0fc8a6302aec590deac2ade437d17ffa3c1fb921 Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Mon, 22 Feb 2021 16:50:46 +0800 Subject: [PATCH 08/13] docs: fix umi link (#29408) --- docs/react/customize-theme.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react/customize-theme.zh-CN.md b/docs/react/customize-theme.zh-CN.md index 9483d05bf0..02b64cd137 100644 --- a/docs/react/customize-theme.zh-CN.md +++ b/docs/react/customize-theme.zh-CN.md @@ -126,7 +126,7 @@ module.exports = { 方式一:使用 Umi 3 -如果你在使用 [Umi 3](http://umijs.org/zh/),仅需两步: +如果你在使用 [Umi 3](http://umijs.org/zh-CN),仅需两步: 1. 安装 `@umijs/plugin-antd` 插件; From dede79736a52220a73ada95da4c7d0615840d7e6 Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Mon, 22 Feb 2021 18:24:15 +0800 Subject: [PATCH 09/13] docs: fix en umi link (#29416) --- docs/react/customize-theme.en-US.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react/customize-theme.en-US.md b/docs/react/customize-theme.en-US.md index 3b2cca6b4b..90afb67f3d 100644 --- a/docs/react/customize-theme.en-US.md +++ b/docs/react/customize-theme.en-US.md @@ -148,7 +148,7 @@ We have some official themes, try them out and give us some feedback! Method 1: using Umi 3 -If you're using [Umi 3](http://umijs.org/zh/), which only need two steps: +If you're using [Umi 3](http://umijs.org), which only need two steps: 1. Install `@umijs/plugin-antd` plugin; From 1c8a88b2d7631129d0c6707e85fd451dd50b9a3e Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Mon, 22 Feb 2021 20:05:55 +0800 Subject: [PATCH 10/13] ci: create sync-gitee.yml (#29405) * Create sync-gitee.yml * Update sync-gitee.yml --- .github/workflows/sync-gitee.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/sync-gitee.yml diff --git a/.github/workflows/sync-gitee.yml b/.github/workflows/sync-gitee.yml new file mode 100644 index 0000000000..4b62ef4245 --- /dev/null +++ b/.github/workflows/sync-gitee.yml @@ -0,0 +1,26 @@ +name: 🔀 Sync mirror to Gitee + +on: + push: + branches: + - master + - gh-pages + - feature + - 2.x-stable + - 3.x-stable + create: + +jobs: + mirror: + runs-on: ubuntu-latest + if: github.repository == 'ant-design/ant-design' + steps: + - name: mirror + continue-on-error: true + if: github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag') + uses: wearerequired/git-mirror-action@v1 + env: + SSH_PRIVATE_KEY: ${{ secrets.GITEE_SSH_PRIVATE_KEY }} + with: + source-repo: 'git@github.com:ant-design/ant-design.git' + destination-repo: 'git@gitee.com:ant-design/ant-design.git' From 76434a15dfe54e30c6a662349849a0aa2a355d78 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 23 Feb 2021 10:45:11 +0800 Subject: [PATCH 11/13] =?UTF-8?q?chore(=F0=9F=86=99):=20upgrade=20devDeps?= =?UTF-8?q?=20(#29418)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(:up:): upgrade devDeps * prettier code * fix dnd demo * fix react-dnd demo * fix npm start and demo tsx compile * fix snapshot --- .eslintrc.js | 29 +++++++- components/anchor/demo/customizeHighlight.md | 4 +- components/auto-complete/demo/basic.md | 8 +-- .../auto-complete/demo/certain-category.md | 62 ++++++++-------- .../auto-complete/demo/uncertain-category.md | 5 +- components/avatar/demo/group.md | 72 +++++++++---------- components/config-provider/index.tsx | 2 +- components/drawer/demo/config-provider.md | 6 +- components/form/ErrorList.tsx | 4 +- components/form/FormItemInput.tsx | 2 +- components/form/demo/control-hooks.md | 9 ++- components/form/demo/control-ref.md | 9 ++- .../form/demo/customized-form-controls.md | 2 +- components/form/demo/dep-debug.md | 6 +- components/form/demo/global-state.md | 36 +++++----- components/form/demo/inline-login.md | 2 +- components/form/demo/nest-messages.md | 2 + components/form/demo/register.md | 4 +- components/form/demo/required-mark.md | 6 +- components/form/demo/validate-other.md | 4 +- components/input/ClearableLabeledInput.tsx | 2 +- components/list/index.zh-CN.md | 2 +- components/message/index.tsx | 2 +- components/notification/index.tsx | 2 +- components/notification/style/index.less | 2 +- components/table/Table.tsx | 7 +- .../table/__tests__/Table.pagination.test.js | 4 +- components/table/demo/drag-sorting.md | 56 ++++++++------- components/tree/demo/basic-controlled.md | 16 ++--- components/tree/demo/dynamic.md | 3 +- components/tree/demo/line.md | 6 +- .../__tests__/__snapshots__/demo.test.js.snap | 2 +- components/upload/demo/drag-sorting.md | 60 ++++++++-------- package.json | 15 ++-- scripts/check-version-md.js | 1 + site/bisheng.config.js | 6 +- 36 files changed, 233 insertions(+), 227 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0f5a827617..f1948ee36b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,7 +5,7 @@ module.exports = { 'plugin:jest/recommended', 'plugin:react/recommended', 'plugin:import/typescript', - 'prettier/react', + 'plugin:markdown/recommended', ], env: { browser: true, @@ -20,7 +20,7 @@ module.exports = { }, }, parser: '@typescript-eslint/parser', - plugins: ['markdown', 'react', 'babel', 'jest', '@typescript-eslint', 'react-hooks', 'unicorn'], + plugins: ['react', 'babel', 'jest', '@typescript-eslint', 'react-hooks', 'unicorn', 'markdown'], // https://github.com/typescript-eslint/typescript-eslint/issues/46#issuecomment-470486034 overrides: [ { @@ -32,7 +32,28 @@ module.exports = { }, }, { - files: ['*.md'], + // In v2, explicitly apply eslint-plugin-markdown's `markdown` + // processor on any Markdown files you want to lint. + files: ['components/*/demo/*.md'], + processor: 'markdown/markdown', + }, + { + // In v2, configuration for fenced code blocks is separate from the + // containing Markdown file. Each code block has a virtual filename + // appended to the Markdown file's path. + files: [ + 'components/*/demo/*.md/*.ts', + 'components/*/demo/*.md/*.tsx', + 'components/*/demo/*.md/*.js', + 'components/*/demo/*.md/*.jsx', + ], + // Configuration for fenced code blocks goes with the override for + // the code block's virtual filename, for example: + parserOptions: { + ecmaFeatures: { + impliedStrict: true, + }, + }, globals: { React: true, ReactDOM: true, @@ -44,10 +65,12 @@ module.exports = { 'no-plusplus': 0, 'eol-last': 0, 'no-script-url': 0, + 'default-case': 0, 'prefer-rest-params': 0, 'react/no-access-state-in-setstate': 0, 'react/destructuring-assignment': 0, 'react/no-multi-comp': 0, + 'react/no-array-index-key': 0, 'jsx-a11y/href-no-hash': 0, 'import/no-extraneous-dependencies': 0, 'jsx-a11y/control-has-associated-label': 0, diff --git a/components/anchor/demo/customizeHighlight.md b/components/anchor/demo/customizeHighlight.md index 525e3af833..a28285b4bc 100644 --- a/components/anchor/demo/customizeHighlight.md +++ b/components/anchor/demo/customizeHighlight.md @@ -18,9 +18,7 @@ import { Anchor } from 'antd'; const { Link } = Anchor; -const getCurrentAnchor = () => { - return '#components-anchor-demo-static'; -}; +const getCurrentAnchor = () => '#components-anchor-demo-static'; ReactDOM.render( diff --git a/components/auto-complete/demo/basic.md b/components/auto-complete/demo/basic.md index bf1ad12f92..9ffca6aff5 100644 --- a/components/auto-complete/demo/basic.md +++ b/components/auto-complete/demo/basic.md @@ -17,11 +17,9 @@ Basic Usage, set data source of autocomplete with `options` property. import React, { useState } from 'react'; import { AutoComplete } from 'antd'; -const mockVal = (str: string, repeat: number = 1) => { - return { - value: str.repeat(repeat), - }; -}; +const mockVal = (str: string, repeat: number = 1) => ({ + value: str.repeat(repeat), +}); const Complete: React.FC = () => { const [value, setValue] = useState(''); const [options, setOptions] = useState<{ value: string }[]>([]); diff --git a/components/auto-complete/demo/certain-category.md b/components/auto-complete/demo/certain-category.md index 7be317ddef..d37f8eb48d 100644 --- a/components/auto-complete/demo/certain-category.md +++ b/components/auto-complete/demo/certain-category.md @@ -17,40 +17,36 @@ Demonstration of [Lookup Patterns: Certain Category](https://ant.design/docs/spe import { Input, AutoComplete } from 'antd'; import { UserOutlined } from '@ant-design/icons'; -const renderTitle = (title: string) => { - return ( - - {title} - - more - - - ); -}; +const renderTitle = (title: string) => ( + + {title} + + more + + +); -const renderItem = (title: string, count: number) => { - return { - value: title, - label: ( -

- {title} - - {count} - -
- ), - }; -}; +const renderItem = (title: string, count: number) => ({ + value: title, + label: ( +
+ {title} + + {count} + +
+ ), +}); const options = [ { diff --git a/components/auto-complete/demo/uncertain-category.md b/components/auto-complete/demo/uncertain-category.md index 31116aa7b9..65b6e9a08f 100644 --- a/components/auto-complete/demo/uncertain-category.md +++ b/components/auto-complete/demo/uncertain-category.md @@ -22,8 +22,8 @@ function getRandomInt(max: number, min: number = 0) { return Math.floor(Math.random() * (max - min + 1)) + min; // eslint-disable-line no-mixed-operators } -const searchResult = (query: string) => { - return new Array(getRandomInt(5)) +const searchResult = (query: string) => + new Array(getRandomInt(5)) .join('.') .split('.') .map((_, idx) => { @@ -52,7 +52,6 @@ const searchResult = (query: string) => { ), }; }); -}; const Complete: React.FC = () => { const [options, setOptions] = useState['options']>([]); diff --git a/components/avatar/demo/group.md b/components/avatar/demo/group.md index 9453da8fae..3a8fce98ed 100644 --- a/components/avatar/demo/group.md +++ b/components/avatar/demo/group.md @@ -17,44 +17,40 @@ Avatar group display. import { Avatar, Divider, Tooltip } from 'antd'; import { UserOutlined, AntDesignOutlined } from '@ant-design/icons'; -class Demo extends React.Component { - render() { - return ( - <> - - - K - - } /> - - } /> - - - - - K - - } /> - - } /> - - - - - K - - } /> - - } /> - - - ); - } -} +const Demo = () => ( + <> + + + K + + } /> + + } /> + + + + + K + + } /> + + } /> + + + + + K + + } /> + + } /> + + +); ReactDOM.render(, mountNode); ``` diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 381594e8ea..6588d6ea89 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -235,7 +235,7 @@ const ConfigProvider: React.FC & { ); }; -/** @private internal usage. do not use in your production */ +/** @private internal Usage. do not use in your production */ ConfigProvider.ConfigContext = ConfigContext; ConfigProvider.SizeContext = SizeContext; ConfigProvider.config = setGlobalConfig; diff --git a/components/drawer/demo/config-provider.md b/components/drawer/demo/config-provider.md index 0d9739b0a9..8a913ae707 100644 --- a/components/drawer/demo/config-provider.md +++ b/components/drawer/demo/config-provider.md @@ -28,11 +28,7 @@ const App: React.FC = () => { setVisible(false); }; return ( - { - return domRef.current!; - }} - > + domRef.current!}>