From 2be3a10d50c30c6e6391c237249470c38b82deeb Mon Sep 17 00:00:00 2001 From: janrywang Date: Fri, 9 Jul 2021 23:08:01 +0800 Subject: [PATCH] feat(antd): transfer compat label/value --- designable/antd/package.json | 8 ++++---- designable/setters/package.json | 6 +++--- packages/antd/src/transfer/index.tsx | 24 ++++++++++++++++++++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/designable/antd/package.json b/designable/antd/package.json index 4276a09e5a0..d6d8f781997 100644 --- a/designable/antd/package.json +++ b/designable/antd/package.json @@ -30,7 +30,7 @@ "start": "webpack-dev-server --config playground/webpack.dev.ts" }, "devDependencies": { - "@designable/react-settings-form": "^0.3.28", + "@designable/react-settings-form": "^0.3.29", "autoprefixer": "^9.0", "file-loader": "^5.0.2", "fs-extra": "^8.1.0", @@ -56,9 +56,9 @@ "react-is": ">=16.8.0 || >=17.0.0" }, "dependencies": { - "@designable/core": "^0.3.28", - "@designable/formily": "^0.3.28", - "@designable/react": "^0.3.28", + "@designable/core": "^0.3.29", + "@designable/formily": "^0.3.29", + "@designable/react": "^0.3.29", "@formily/antd": "2.0.0-beta.76", "@formily/core": "2.0.0-beta.76", "@formily/react": "2.0.0-beta.76", diff --git a/designable/setters/package.json b/designable/setters/package.json index 14e7239c96a..5eb917d0c6a 100644 --- a/designable/setters/package.json +++ b/designable/setters/package.json @@ -40,9 +40,9 @@ "react-is": ">=16.8.0 || >=17.0.0" }, "dependencies": { - "@designable/core": "^0.3.28", - "@designable/formily": "^0.3.28", - "@designable/react": "^0.3.28", + "@designable/core": "^0.3.29", + "@designable/formily": "^0.3.29", + "@designable/react": "^0.3.29", "@formily/antd": "2.0.0-beta.76", "@formily/core": "2.0.0-beta.76", "@formily/react": "2.0.0-beta.76", diff --git a/packages/antd/src/transfer/index.tsx b/packages/antd/src/transfer/index.tsx index 7227ff0519d..02ed9f4fb4b 100644 --- a/packages/antd/src/transfer/index.tsx +++ b/packages/antd/src/transfer/index.tsx @@ -1,12 +1,28 @@ import { connect, mapProps } from '@formily/react' import { Transfer as AntdTransfer } from 'antd' +import { isVoidField } from '@formily/core' export const Transfer = connect( AntdTransfer, - mapProps({ - value: 'targetKeys', - dataSource: true, - }) + mapProps( + { + value: 'targetKeys', + }, + (props, field) => { + if (isVoidField(field)) return props + return { + ...props, + dataSource: + field.dataSource?.map((item) => { + return { + ...item, + title: item.title || item.label, + key: item.key || item.value, + } + }) || [], + } + } + ) ) Transfer.defaultProps = {