From 317c6469a25416da51070fd33e3d81dba1dab866 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: Sun, 28 Feb 2021 11:00:44 +0800 Subject: [PATCH] Revert "feat: add api for transfer (#29288)" (#29541) This reverts commit 15580483cef01e3ddd7fe30376e898bdf8ab09cb. --- .../__tests__/__snapshots__/demo.test.js.snap | 15 +++++++++- components/transfer/__tests__/index.test.js | 28 ------------------- components/transfer/demo/advanced.md | 12 ++++---- components/transfer/index.en-US.md | 2 +- components/transfer/index.tsx | 10 ++----- components/transfer/index.zh-CN.md | 2 +- components/transfer/list.tsx | 26 ++--------------- 7 files changed, 26 insertions(+), 69 deletions(-) diff --git a/components/transfer/__tests__/__snapshots__/demo.test.js.snap b/components/transfer/__tests__/__snapshots__/demo.test.js.snap index d51998010a..1df48d93d4 100644 --- a/components/transfer/__tests__/__snapshots__/demo.test.js.snap +++ b/components/transfer/__tests__/__snapshots__/demo.test.js.snap @@ -216,7 +216,7 @@ exports[`renders ./components/transfer/demo/advanced.md correctly 1`] = `
+ `; diff --git a/components/transfer/__tests__/index.test.js b/components/transfer/__tests__/index.test.js index 379cbcd660..fbb5a6ccb8 100644 --- a/components/transfer/__tests__/index.test.js +++ b/components/transfer/__tests__/index.test.js @@ -558,31 +558,3 @@ describe('immutable data', () => { expect(wrapper).toMatchRenderedSnapshot(); }); }); - -describe('footer render source and target', () => { - // https://github.com/ant-design/ant-design/issues/28082 - it('currently render footer', () => { - const differentFooter = () => ({ - source: ( - - ), - target: ( - - ), - }); - const defaultFooter = () => ( - - ); - const wrapper = mount(); - const wrapper2 = mount(); - expect(wrapper.exists('.sourceFooter')).toEqual(true); - expect(wrapper.exists('.targetFooter')).toEqual(true); - expect(wrapper2.exists('.defaultFooter')).toEqual(true); - }); -}); diff --git a/components/transfer/demo/advanced.md b/components/transfer/demo/advanced.md index 33ac2d0585..670e85fe6d 100644 --- a/components/transfer/demo/advanced.md +++ b/components/transfer/demo/advanced.md @@ -50,13 +50,11 @@ class App extends React.Component { this.setState({ targetKeys }); }; - renderFooter = () => ({ - source: ( - - ), - }); + renderFooter = () => ( + + ); render() { return ( diff --git a/components/transfer/index.en-US.md b/components/transfer/index.en-US.md index 2431f9096a..866c6be96a 100644 --- a/components/transfer/index.en-US.md +++ b/components/transfer/index.en-US.md @@ -24,7 +24,7 @@ One or more elements can be selected from either column, one click on the proper | dataSource | Used for setting the source data. The elements that are part of this array will be present the left column. Except the elements whose keys are included in `targetKeys` prop | [RecordType extends TransferItem = TransferItem](https://git.io/vMM64)\[] | \[] | | | disabled | Whether disabled transfer | boolean | false | | | filterOption | A function to determine whether an item should show in search result list | (inputValue, option): boolean | - | | -| footer | A function used for rendering the footer | (props) => ReactNode \| { source: ReactNode, target: ReactNode } | - | { source: ReactNode, target: ReactNode }: 4.12.3 | +| footer | A function used for rendering the footer | (props) => ReactNode | - | | | listStyle | A custom CSS style used for rendering the transfer columns | object \| ({direction: `left` \| `right`}) => object | - | | | locale | The i18n text including filter, empty text, item unit, etc | { itemUnit: string; itemsUnit: string; searchPlaceholder: string; notFoundContent: ReactNode; } | { itemUnit: `item`, itemsUnit: `items`, notFoundContent: `The list is empty`, searchPlaceholder: `Search here` } | | | oneWay | Display as single direction style | boolean | false | 4.3.0 | diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 4c91afd515..3e6136b6ac 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -58,6 +58,7 @@ export interface TransferLocale { removeAll: string; removeCurrent: string; } + export interface TransferProps { prefixCls?: string; className?: string; @@ -76,14 +77,7 @@ export interface TransferProps { showSearch?: boolean; filterOption?: (inputValue: string, item: RecordType) => boolean; locale?: Partial; - footer?: ( - props: TransferListProps, - ) => - | React.ReactNode - | { - source?: React.ReactNode; - target?: React.ReactNode; - }; + footer?: (props: TransferListProps) => React.ReactNode; rowKey?: (record: RecordType) => string; onSearch?: (direction: TransferDirection, value: string) => void; onScroll?: (direction: TransferDirection, e: React.SyntheticEvent) => void; diff --git a/components/transfer/index.zh-CN.md b/components/transfer/index.zh-CN.md index 96270659e1..e010047229 100644 --- a/components/transfer/index.zh-CN.md +++ b/components/transfer/index.zh-CN.md @@ -27,7 +27,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/QAXskNI4G/Transfer.svg | dataSource | 数据源,其中的数据将会被渲染到左边一栏中,`targetKeys` 中指定的除外 | [RecordType extends TransferItem = TransferItem](https://git.io/vMM64)\[] | \[] | | | disabled | 是否禁用 | boolean | false | | | filterOption | 接收 `inputValue` `option` 两个参数,当 `option` 符合筛选条件时,应返回 true,反之则返回 false | (inputValue, option): boolean | - | | -| footer | 底部渲染函数 | (props) => ReactNode \| { source: ReactNode, target: ReactNode } | - | { source: ReactNode, target: ReactNode }: 4.12.3 | +| footer | 底部渲染函数 | (props) => ReactNode | - | | | listStyle | 两个穿梭框的自定义样式 | object\|({direction: `left` \| `right`}) => object | - | | | locale | 各种语言 | { itemUnit: string; itemsUnit: string; searchPlaceholder: string; notFoundContent: ReactNode; } | { itemUnit: `项`, itemsUnit: `项`, searchPlaceholder: `请输入搜索内容` } | | | oneWay | 展示为单向样式 | boolean | false | 4.3.0 | diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index d62a0e607d..5ce325c4ad 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -39,10 +39,7 @@ export interface RenderedItem { } type RenderListFunction = (props: TransferListBodyProps) => React.ReactNode; -type FooterRender = { - source?: React.ReactNode; - target?: React.ReactNode; -}; + export interface TransferListProps extends TransferLocale { prefixCls: string; titleText: React.ReactNode; @@ -62,7 +59,7 @@ export interface TransferListProps extends TransferLocale { itemUnit: string; itemsUnit: string; renderList?: RenderListFunction; - footer?: (props: TransferListProps) => React.ReactNode | FooterRender; + footer?: (props: TransferListProps) => React.ReactNode; onScroll: (e: React.UIEvent) => void; disabled?: boolean; direction: TransferDirection; @@ -315,27 +312,10 @@ export default class TransferList< showSelectAll, showRemove, pagination, - direction, } = this.props; // Custom Layout - // Distinguish different footer - const tempDom = footer && footer(this.props); - let footerDom; - function isFooterRender(obj: any): obj is FooterRender { - return obj.source || obj.target; - } - if (tempDom) { - if (isFooterRender(tempDom)) { - if (direction === 'left') { - footerDom = tempDom.source; - } else { - footerDom = tempDom.target; - } - } else { - footerDom = tempDom; - } - } + const footerDom = footer && footer(this.props); const listCls = classNames(prefixCls, { [`${prefixCls}-with-pagination`]: pagination,