Skip to content

Commit

Permalink
feat(antd): transfer compat label/value
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jul 9, 2021
1 parent 1c12f54 commit 2be3a10
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
8 changes: 4 additions & 4 deletions designable/antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions designable/setters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 20 additions & 4 deletions packages/antd/src/transfer/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down

0 comments on commit 2be3a10

Please sign in to comment.