You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
781 lines
46 KiB
781 lines
46 KiB
"use strict";(self.webpackChunkantd=self.webpackChunkantd||[]).push([[474],{827398:function(p,l,n){n.r(l);var g=n(502143),_=n(968521),h=n(720719),y=n(28840),a=n(759907),o=n(828089),f=n(825673),v=n(902068),Z=n(574399),b=n(863942),k=n(316073),K=n(24628),T=n(719260),S=n(956140),s=n(127179),i=n(905388),w=n(40428),C=n(606965),D=n(268696),x=n(587302),r=n(424128),E=n(249706),P=n(795127),M=n(116846),A=n(212039),O=n(73024),I=n(553913),c=n(606641),d=n(667294),e=n(370917);function u(){var m=(0,c.eL)(),t=m.texts;return(0,e.tZ)(c.dY,null,(0,e.tZ)(d.Fragment,null,(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("p",null,t[0].value),(0,e.tZ)("h2",{id:"when-to-use"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#when-to-use",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"When To Use"),(0,e.tZ)("ul",null,(0,e.tZ)("li",null,t[1].value),(0,e.tZ)("li",null,t[2].value)),(0,e.tZ)("p",null,t[3].value),(0,e.tZ)("p",null,t[4].value,(0,e.tZ)("code",null,t[5].value),t[6].value,(0,e.tZ)("code",null,t[7].value),t[8].value,(0,e.tZ)("code",null,t[9].value),t[10].value),(0,e.tZ)("blockquote",null,(0,e.tZ)("p",null,t[11].value)),(0,e.tZ)("h2",{id:"examples"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#examples",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Examples")),(0,e.tZ)(i.Z,{items:[{demo:{id:"components-transfer-demo-basic"},previewerProps:{title:"Basic",filename:"components/transfer/demo/basic.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { Transfer } from 'antd';
|
|
const mockData = Array.from({
|
|
length: 20,
|
|
}).map((_, i) => ({
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
}));
|
|
const initialTargetKeys = mockData.filter((item) => Number(item.key) > 10).map((item) => item.key);
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState(initialTargetKeys);
|
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
const onChange = (nextTargetKeys, direction, moveKeys) => {
|
|
console.log('targetKeys:', nextTargetKeys);
|
|
console.log('direction:', direction);
|
|
console.log('moveKeys:', moveKeys);
|
|
setTargetKeys(nextTargetKeys);
|
|
};
|
|
const onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
|
|
console.log('sourceSelectedKeys:', sourceSelectedKeys);
|
|
console.log('targetSelectedKeys:', targetSelectedKeys);
|
|
setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]);
|
|
};
|
|
const onScroll = (direction, e) => {
|
|
console.log('direction:', direction);
|
|
console.log('target:', e.target);
|
|
};
|
|
return (
|
|
<Transfer
|
|
dataSource={mockData}
|
|
titles={['Source', 'Target']}
|
|
targetKeys={targetKeys}
|
|
selectedKeys={selectedKeys}
|
|
onChange={onChange}
|
|
onSelectChange={onSelectChange}
|
|
onScroll={onScroll}
|
|
render={(item) => item.title}
|
|
/>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>The most basic usage of <code>Transfer</code> involves providing the source data and target keys arrays, plus the rendering and some callback functions.</p>"}},{demo:{id:"components-transfer-demo-oneway"},previewerProps:{title:"One Way",filename:"components/transfer/demo/oneWay.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { Switch, Transfer } from 'antd';
|
|
const mockData = Array.from({
|
|
length: 20,
|
|
}).map((_, i) => ({
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
disabled: i % 3 < 1,
|
|
}));
|
|
const oriTargetKeys = mockData.filter((item) => Number(item.key) % 3 > 1).map((item) => item.key);
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState(oriTargetKeys);
|
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
const [disabled, setDisabled] = useState(false);
|
|
const handleChange = (newTargetKeys, direction, moveKeys) => {
|
|
setTargetKeys(newTargetKeys);
|
|
console.log('targetKeys: ', newTargetKeys);
|
|
console.log('direction: ', direction);
|
|
console.log('moveKeys: ', moveKeys);
|
|
};
|
|
const handleSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
|
|
setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]);
|
|
console.log('sourceSelectedKeys: ', sourceSelectedKeys);
|
|
console.log('targetSelectedKeys: ', targetSelectedKeys);
|
|
};
|
|
const handleScroll = (direction, e) => {
|
|
console.log('direction:', direction);
|
|
console.log('target:', e.target);
|
|
};
|
|
const handleDisable = (checked) => {
|
|
setDisabled(checked);
|
|
};
|
|
return (
|
|
<>
|
|
<Transfer
|
|
dataSource={mockData}
|
|
titles={['Source', 'Target']}
|
|
targetKeys={targetKeys}
|
|
selectedKeys={selectedKeys}
|
|
onChange={handleChange}
|
|
onSelectChange={handleSelectChange}
|
|
onScroll={handleScroll}
|
|
render={(item) => item.title}
|
|
disabled={disabled}
|
|
oneWay
|
|
style={{
|
|
marginBottom: 16,
|
|
}}
|
|
/>
|
|
<Switch
|
|
unCheckedChildren="disabled"
|
|
checkedChildren="disabled"
|
|
checked={disabled}
|
|
onChange={handleDisable}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Use <code>oneWay</code> to makes Transfer to one way style.</p>"}},{demo:{id:"components-transfer-demo-search"},previewerProps:{title:"Search",filename:"components/transfer/demo/search.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useEffect, useState } from 'react';
|
|
import { Transfer } from 'antd';
|
|
const App = () => {
|
|
const [mockData, setMockData] = useState([]);
|
|
const [targetKeys, setTargetKeys] = useState([]);
|
|
const getMock = () => {
|
|
const tempTargetKeys = [];
|
|
const tempMockData = [];
|
|
for (let i = 0; i < 20; i++) {
|
|
const data = {
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
chosen: i % 2 === 0,
|
|
};
|
|
if (data.chosen) {
|
|
tempTargetKeys.push(data.key);
|
|
}
|
|
tempMockData.push(data);
|
|
}
|
|
setMockData(tempMockData);
|
|
setTargetKeys(tempTargetKeys);
|
|
};
|
|
useEffect(() => {
|
|
getMock();
|
|
}, []);
|
|
const filterOption = (inputValue, option) => option.description.indexOf(inputValue) > -1;
|
|
const handleChange = (newTargetKeys) => {
|
|
setTargetKeys(newTargetKeys);
|
|
};
|
|
const handleSearch = (dir, value) => {
|
|
console.log('search:', dir, value);
|
|
};
|
|
return (
|
|
<Transfer
|
|
dataSource={mockData}
|
|
showSearch
|
|
filterOption={filterOption}
|
|
targetKeys={targetKeys}
|
|
onChange={handleChange}
|
|
onSearch={handleSearch}
|
|
render={(item) => item.title}
|
|
/>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Transfer with a search box.</p>"}},{demo:{id:"components-transfer-demo-advanced"},previewerProps:{title:"Advanced",filename:"components/transfer/demo/advanced.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useEffect, useState } from 'react';
|
|
import { Button, Transfer } from 'antd';
|
|
const App = () => {
|
|
const [mockData, setMockData] = useState([]);
|
|
const [targetKeys, setTargetKeys] = useState([]);
|
|
const getMock = () => {
|
|
const tempTargetKeys = [];
|
|
const tempMockData = [];
|
|
for (let i = 0; i < 20; i++) {
|
|
const data = {
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
chosen: i % 2 === 0,
|
|
};
|
|
if (data.chosen) {
|
|
tempTargetKeys.push(data.key);
|
|
}
|
|
tempMockData.push(data);
|
|
}
|
|
setMockData(tempMockData);
|
|
setTargetKeys(tempTargetKeys);
|
|
};
|
|
useEffect(() => {
|
|
getMock();
|
|
}, []);
|
|
const handleChange = (newTargetKeys) => {
|
|
setTargetKeys(newTargetKeys);
|
|
};
|
|
const renderFooter = (_, { direction }) => {
|
|
if (direction === 'left') {
|
|
return (
|
|
<Button
|
|
size="small"
|
|
style={{
|
|
float: 'left',
|
|
margin: 5,
|
|
}}
|
|
onClick={getMock}
|
|
>
|
|
Left button reload
|
|
</Button>
|
|
);
|
|
}
|
|
return (
|
|
<Button
|
|
size="small"
|
|
style={{
|
|
float: 'right',
|
|
margin: 5,
|
|
}}
|
|
onClick={getMock}
|
|
>
|
|
Right button reload
|
|
</Button>
|
|
);
|
|
};
|
|
return (
|
|
<Transfer
|
|
dataSource={mockData}
|
|
showSearch
|
|
listStyle={{
|
|
width: 250,
|
|
height: 300,
|
|
}}
|
|
operations={['to right', 'to left']}
|
|
targetKeys={targetKeys}
|
|
onChange={handleChange}
|
|
render={(item) => \`\${item.title}-\${item.description}\`}
|
|
footer={renderFooter}
|
|
/>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:`<p>Advanced Usage of Transfer.</p>
|
|
<p>You can customize the labels of the transfer buttons, the width and height of the columns, and what should be displayed in the footer.</p>`}},{demo:{id:"components-transfer-demo-custom-item"},previewerProps:{title:"Custom datasource",filename:"components/transfer/demo/custom-item.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useEffect, useState } from 'react';
|
|
import { Transfer } from 'antd';
|
|
const App = () => {
|
|
const [mockData, setMockData] = useState([]);
|
|
const [targetKeys, setTargetKeys] = useState([]);
|
|
const getMock = () => {
|
|
const tempTargetKeys = [];
|
|
const tempMockData = [];
|
|
for (let i = 0; i < 20; i++) {
|
|
const data = {
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
chosen: i % 2 === 0,
|
|
};
|
|
if (data.chosen) {
|
|
tempTargetKeys.push(data.key);
|
|
}
|
|
tempMockData.push(data);
|
|
}
|
|
setMockData(tempMockData);
|
|
setTargetKeys(tempTargetKeys);
|
|
};
|
|
useEffect(() => {
|
|
getMock();
|
|
}, []);
|
|
const handleChange = (newTargetKeys, direction, moveKeys) => {
|
|
console.log(newTargetKeys, direction, moveKeys);
|
|
setTargetKeys(newTargetKeys);
|
|
};
|
|
const renderItem = (item) => {
|
|
const customLabel = (
|
|
<span className="custom-item">
|
|
{item.title} - {item.description}
|
|
</span>
|
|
);
|
|
return {
|
|
label: customLabel,
|
|
// for displayed item
|
|
value: item.title, // for title and filter matching
|
|
};
|
|
};
|
|
|
|
return (
|
|
<Transfer
|
|
dataSource={mockData}
|
|
listStyle={{
|
|
width: 300,
|
|
height: 300,
|
|
}}
|
|
targetKeys={targetKeys}
|
|
onChange={handleChange}
|
|
render={renderItem}
|
|
/>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Custom each Transfer Item, and in this way you can render a complex datasource.</p>"}},{demo:{id:"components-transfer-demo-large-data"},previewerProps:{title:"Pagination",filename:"components/transfer/demo/large-data.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useEffect, useState } from 'react';
|
|
import { Switch, Transfer } from 'antd';
|
|
const App = () => {
|
|
const [oneWay, setOneWay] = useState(false);
|
|
const [mockData, setMockData] = useState([]);
|
|
const [targetKeys, setTargetKeys] = useState([]);
|
|
useEffect(() => {
|
|
const newTargetKeys = [];
|
|
const newMockData = [];
|
|
for (let i = 0; i < 2000; i++) {
|
|
const data = {
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
chosen: i % 2 === 0,
|
|
};
|
|
if (data.chosen) {
|
|
newTargetKeys.push(data.key);
|
|
}
|
|
newMockData.push(data);
|
|
}
|
|
setTargetKeys(newTargetKeys);
|
|
setMockData(newMockData);
|
|
}, []);
|
|
const onChange = (newTargetKeys, direction, moveKeys) => {
|
|
console.log(newTargetKeys, direction, moveKeys);
|
|
setTargetKeys(newTargetKeys);
|
|
};
|
|
return (
|
|
<>
|
|
<Transfer
|
|
dataSource={mockData}
|
|
targetKeys={targetKeys}
|
|
onChange={onChange}
|
|
render={(item) => item.title}
|
|
oneWay={oneWay}
|
|
pagination
|
|
/>
|
|
<br />
|
|
<Switch
|
|
unCheckedChildren="one way"
|
|
checkedChildren="one way"
|
|
checked={oneWay}
|
|
onChange={setOneWay}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>large count of items with pagination.</p>"}},{demo:{id:"components-transfer-demo-table-transfer"},previewerProps:{title:"Table Transfer",filename:"components/transfer/demo/table-transfer.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { Space, Switch, Table, Tag, Transfer } from 'antd';
|
|
import difference from 'lodash/difference';
|
|
// Customize Table Transfer
|
|
const TableTransfer = ({ leftColumns, rightColumns, ...restProps }) => (
|
|
<Transfer {...restProps}>
|
|
{({
|
|
direction,
|
|
filteredItems,
|
|
onItemSelectAll,
|
|
onItemSelect,
|
|
selectedKeys: listSelectedKeys,
|
|
disabled: listDisabled,
|
|
}) => {
|
|
const columns = direction === 'left' ? leftColumns : rightColumns;
|
|
const rowSelection = {
|
|
getCheckboxProps: (item) => ({
|
|
disabled: listDisabled || item.disabled,
|
|
}),
|
|
onSelectAll(selected, selectedRows) {
|
|
const treeSelectedKeys = selectedRows
|
|
.filter((item) => !item.disabled)
|
|
.map(({ key }) => key);
|
|
const diffKeys = selected
|
|
? difference(treeSelectedKeys, listSelectedKeys)
|
|
: difference(listSelectedKeys, treeSelectedKeys);
|
|
onItemSelectAll(diffKeys, selected);
|
|
},
|
|
onSelect({ key }, selected) {
|
|
onItemSelect(key, selected);
|
|
},
|
|
selectedRowKeys: listSelectedKeys,
|
|
};
|
|
return (
|
|
<Table
|
|
rowSelection={rowSelection}
|
|
columns={columns}
|
|
dataSource={filteredItems}
|
|
size="small"
|
|
style={{
|
|
pointerEvents: listDisabled ? 'none' : undefined,
|
|
}}
|
|
onRow={({ key, disabled: itemDisabled }) => ({
|
|
onClick: () => {
|
|
if (itemDisabled || listDisabled) return;
|
|
onItemSelect(key, !listSelectedKeys.includes(key));
|
|
},
|
|
})}
|
|
/>
|
|
);
|
|
}}
|
|
</Transfer>
|
|
);
|
|
const mockTags = ['cat', 'dog', 'bird'];
|
|
const mockData = Array.from({
|
|
length: 20,
|
|
}).map((_, i) => ({
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
disabled: i % 4 === 0,
|
|
tag: mockTags[i % 3],
|
|
}));
|
|
const originTargetKeys = mockData
|
|
.filter((item) => Number(item.key) % 3 > 1)
|
|
.map((item) => item.key);
|
|
const leftTableColumns = [
|
|
{
|
|
dataIndex: 'title',
|
|
title: 'Name',
|
|
},
|
|
{
|
|
dataIndex: 'tag',
|
|
title: 'Tag',
|
|
render: (tag) => <Tag>{tag}</Tag>,
|
|
},
|
|
{
|
|
dataIndex: 'description',
|
|
title: 'Description',
|
|
},
|
|
];
|
|
const rightTableColumns = [
|
|
{
|
|
dataIndex: 'title',
|
|
title: 'Name',
|
|
},
|
|
];
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState(originTargetKeys);
|
|
const [disabled, setDisabled] = useState(false);
|
|
const [showSearch, setShowSearch] = useState(false);
|
|
const onChange = (nextTargetKeys) => {
|
|
setTargetKeys(nextTargetKeys);
|
|
};
|
|
const triggerDisable = (checked) => {
|
|
setDisabled(checked);
|
|
};
|
|
const triggerShowSearch = (checked) => {
|
|
setShowSearch(checked);
|
|
};
|
|
return (
|
|
<>
|
|
<TableTransfer
|
|
dataSource={mockData}
|
|
targetKeys={targetKeys}
|
|
disabled={disabled}
|
|
showSearch={showSearch}
|
|
onChange={onChange}
|
|
filterOption={(inputValue, item) =>
|
|
item.title.indexOf(inputValue) !== -1 || item.tag.indexOf(inputValue) !== -1
|
|
}
|
|
leftColumns={leftTableColumns}
|
|
rightColumns={rightTableColumns}
|
|
/>
|
|
<Space
|
|
style={{
|
|
marginTop: 16,
|
|
}}
|
|
>
|
|
<Switch
|
|
unCheckedChildren="disabled"
|
|
checkedChildren="disabled"
|
|
checked={disabled}
|
|
onChange={triggerDisable}
|
|
/>
|
|
<Switch
|
|
unCheckedChildren="showSearch"
|
|
checkedChildren="showSearch"
|
|
checked={showSearch}
|
|
onChange={triggerShowSearch}
|
|
/>
|
|
</Space>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Customize render list with Table component.</p>",style:`#components-transfer-demo-table-transfer .ant-table td {
|
|
background: transparent;
|
|
}`}},{demo:{id:"components-transfer-demo-tree-transfer"},previewerProps:{title:"Tree Transfer",filename:"components/transfer/demo/tree-transfer.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { Transfer, Tree, theme } from 'antd';
|
|
// Customize Table Transfer
|
|
const isChecked = (selectedKeys, eventKey) => selectedKeys.includes(eventKey);
|
|
const generateTree = (treeNodes = [], checkedKeys = []) =>
|
|
treeNodes.map(({ children, ...props }) => ({
|
|
...props,
|
|
disabled: checkedKeys.includes(props.key),
|
|
children: generateTree(children, checkedKeys),
|
|
}));
|
|
const TreeTransfer = ({ dataSource, targetKeys, ...restProps }) => {
|
|
const { token } = theme.useToken();
|
|
const transferDataSource = [];
|
|
function flatten(list = []) {
|
|
list.forEach((item) => {
|
|
transferDataSource.push(item);
|
|
flatten(item.children);
|
|
});
|
|
}
|
|
flatten(dataSource);
|
|
return (
|
|
<Transfer
|
|
{...restProps}
|
|
targetKeys={targetKeys}
|
|
dataSource={transferDataSource}
|
|
className="tree-transfer"
|
|
render={(item) => item.title}
|
|
showSelectAll={false}
|
|
>
|
|
{({ direction, onItemSelect, selectedKeys }) => {
|
|
if (direction === 'left') {
|
|
const checkedKeys = [...selectedKeys, ...targetKeys];
|
|
return (
|
|
<div
|
|
style={{
|
|
padding: token.paddingXS,
|
|
}}
|
|
>
|
|
<Tree
|
|
blockNode
|
|
checkable
|
|
checkStrictly
|
|
defaultExpandAll
|
|
checkedKeys={checkedKeys}
|
|
treeData={generateTree(dataSource, targetKeys)}
|
|
onCheck={(_, { node: { key } }) => {
|
|
onItemSelect(key, !isChecked(checkedKeys, key));
|
|
}}
|
|
onSelect={(_, { node: { key } }) => {
|
|
onItemSelect(key, !isChecked(checkedKeys, key));
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}}
|
|
</Transfer>
|
|
);
|
|
};
|
|
const treeData = [
|
|
{
|
|
key: '0-0',
|
|
title: '0-0',
|
|
},
|
|
{
|
|
key: '0-1',
|
|
title: '0-1',
|
|
children: [
|
|
{
|
|
key: '0-1-0',
|
|
title: '0-1-0',
|
|
},
|
|
{
|
|
key: '0-1-1',
|
|
title: '0-1-1',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: '0-2',
|
|
title: '0-2',
|
|
},
|
|
{
|
|
key: '0-3',
|
|
title: '0-3',
|
|
},
|
|
{
|
|
key: '0-4',
|
|
title: '0-4',
|
|
},
|
|
];
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState([]);
|
|
const onChange = (keys) => {
|
|
setTargetKeys(keys);
|
|
};
|
|
return <TreeTransfer dataSource={treeData} targetKeys={targetKeys} onChange={onChange} />;
|
|
};
|
|
export default App;
|
|
`,description:"<p>Customize render list with Tree component.</p>",style:`.tree-transfer .ant-transfer-list:first-child {
|
|
flex: none;
|
|
width: 50%;
|
|
}`}},{demo:{id:"components-transfer-demo-status"},previewerProps:{title:"Status",filename:"components/transfer/demo/status.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { Space, Transfer } from 'antd';
|
|
const App = () => (
|
|
<Space direction="vertical">
|
|
<Transfer status="error" />
|
|
<Transfer status="warning" showSearch />
|
|
</Space>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Add status to Transfer with <code>status</code>, which could be <code>error</code> or <code>warning</code>.</p>"}},{demo:{id:"components-transfer-demo-custom-select-all-labels"},previewerProps:{debug:!0,title:"Custom Select All Labels",filename:"components/transfer/demo/custom-select-all-labels.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { Transfer } from 'antd';
|
|
const mockData = Array.from({
|
|
length: 10,
|
|
}).map((_, i) => ({
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
}));
|
|
const oriTargetKeys = mockData.filter((item) => Number(item.key) % 3 > 1).map((item) => item.key);
|
|
const selectAllLabels = [
|
|
'Select All',
|
|
({ selectedCount, totalCount }) => \`\${selectedCount}/\${totalCount}\`,
|
|
];
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState(oriTargetKeys);
|
|
return (
|
|
<Transfer
|
|
dataSource={mockData}
|
|
targetKeys={targetKeys}
|
|
onChange={setTargetKeys}
|
|
render={(item) => item.title}
|
|
selectAllLabels={selectAllLabels}
|
|
/>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Custom the labels for select all checkboxes.</p>"}},{demo:{id:"components-transfer-demo-component-token"},previewerProps:{debug:!0,title:"Component Token",filename:"components/transfer/demo/component-token.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import { ConfigProvider, Space, Switch, Table, Tag, Transfer } from 'antd';
|
|
import difference from 'lodash/difference';
|
|
import React, { useState } from 'react';
|
|
// Customize Table Transfer
|
|
const TableTransfer = ({ leftColumns, rightColumns, ...restProps }) => (
|
|
<Transfer {...restProps}>
|
|
{({
|
|
direction,
|
|
filteredItems,
|
|
onItemSelectAll,
|
|
onItemSelect,
|
|
selectedKeys: listSelectedKeys,
|
|
disabled: listDisabled,
|
|
}) => {
|
|
const columns = direction === 'left' ? leftColumns : rightColumns;
|
|
const rowSelection = {
|
|
getCheckboxProps: (item) => ({
|
|
disabled: listDisabled || item.disabled,
|
|
}),
|
|
onSelectAll(selected, selectedRows) {
|
|
const treeSelectedKeys = selectedRows
|
|
.filter((item) => !item.disabled)
|
|
.map(({ key }) => key);
|
|
const diffKeys = selected
|
|
? difference(treeSelectedKeys, listSelectedKeys)
|
|
: difference(listSelectedKeys, treeSelectedKeys);
|
|
onItemSelectAll(diffKeys, selected);
|
|
},
|
|
onSelect({ key }, selected) {
|
|
onItemSelect(key, selected);
|
|
},
|
|
selectedRowKeys: listSelectedKeys,
|
|
};
|
|
return (
|
|
<Table
|
|
rowSelection={rowSelection}
|
|
columns={columns}
|
|
dataSource={filteredItems}
|
|
size="small"
|
|
style={{
|
|
pointerEvents: listDisabled ? 'none' : undefined,
|
|
}}
|
|
onRow={({ key, disabled: itemDisabled }) => ({
|
|
onClick: () => {
|
|
if (itemDisabled || listDisabled) return;
|
|
onItemSelect(key, !listSelectedKeys.includes(key));
|
|
},
|
|
})}
|
|
/>
|
|
);
|
|
}}
|
|
</Transfer>
|
|
);
|
|
const mockTags = ['cat', 'dog', 'bird'];
|
|
const mockData = Array.from({
|
|
length: 20,
|
|
}).map((_, i) => ({
|
|
key: i.toString(),
|
|
title: \`content\${i + 1}\`,
|
|
description: \`description of content\${i + 1}\`,
|
|
disabled: i % 4 === 0,
|
|
tag: mockTags[i % 3],
|
|
}));
|
|
const leftTableColumns = [
|
|
{
|
|
dataIndex: 'title',
|
|
title: 'Name',
|
|
},
|
|
{
|
|
dataIndex: 'tag',
|
|
title: 'Tag',
|
|
render: (tag) => <Tag>{tag}</Tag>,
|
|
},
|
|
{
|
|
dataIndex: 'description',
|
|
title: 'Description',
|
|
},
|
|
];
|
|
const rightTableColumns = [
|
|
{
|
|
dataIndex: 'title',
|
|
title: 'Name',
|
|
},
|
|
];
|
|
const initialTargetKeys = mockData.filter((item) => Number(item.key) > 10).map((item) => item.key);
|
|
const App = () => {
|
|
const [targetKeys, setTargetKeys] = useState(initialTargetKeys);
|
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
const onChange = (nextTargetKeys, direction, moveKeys) => {
|
|
console.log('targetKeys:', nextTargetKeys);
|
|
console.log('direction:', direction);
|
|
console.log('moveKeys:', moveKeys);
|
|
setTargetKeys(nextTargetKeys);
|
|
};
|
|
const onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
|
|
console.log('sourceSelectedKeys:', sourceSelectedKeys);
|
|
console.log('targetSelectedKeys:', targetSelectedKeys);
|
|
setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]);
|
|
};
|
|
const onScroll = (direction, e) => {
|
|
console.log('direction:', direction);
|
|
console.log('target:', e.target);
|
|
};
|
|
const [disabled, setDisabled] = useState(false);
|
|
const [showSearch, setShowSearch] = useState(false);
|
|
const secondOnChange = (nextTargetKeys) => {
|
|
setTargetKeys(nextTargetKeys);
|
|
};
|
|
const triggerDisable = (checked) => {
|
|
setDisabled(checked);
|
|
};
|
|
const triggerShowSearch = (checked) => {
|
|
setShowSearch(checked);
|
|
};
|
|
return (
|
|
<ConfigProvider
|
|
theme={{
|
|
components: {
|
|
Transfer: {
|
|
listWidth: 40,
|
|
listWidthLG: 50,
|
|
listHeight: 30,
|
|
itemHeight: 20,
|
|
itemPaddingBlock: 10,
|
|
headerHeight: 18,
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
<Transfer
|
|
dataSource={mockData}
|
|
titles={['Source', 'Target']}
|
|
targetKeys={targetKeys}
|
|
selectedKeys={selectedKeys}
|
|
onChange={onChange}
|
|
onSelectChange={onSelectChange}
|
|
onScroll={onScroll}
|
|
render={(item) => item.title}
|
|
/>
|
|
<Transfer status="error" />
|
|
<Transfer status="warning" showSearch />
|
|
<TableTransfer
|
|
dataSource={mockData}
|
|
targetKeys={targetKeys}
|
|
disabled={disabled}
|
|
showSearch={showSearch}
|
|
onChange={secondOnChange}
|
|
filterOption={(inputValue, item) =>
|
|
item.title.indexOf(inputValue) !== -1 || item.tag.indexOf(inputValue) !== -1
|
|
}
|
|
leftColumns={leftTableColumns}
|
|
rightColumns={rightTableColumns}
|
|
/>
|
|
<Space
|
|
style={{
|
|
marginTop: 16,
|
|
}}
|
|
>
|
|
<Switch
|
|
unCheckedChildren="disabled"
|
|
checkedChildren="disabled"
|
|
checked={disabled}
|
|
onChange={triggerDisable}
|
|
/>
|
|
<Switch
|
|
unCheckedChildren="showSearch"
|
|
checkedChildren="showSearch"
|
|
checked={showSearch}
|
|
onChange={triggerShowSearch}
|
|
/>
|
|
</Space>
|
|
</ConfigProvider>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Component Token Debug.</p>"}}]}),(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("h2",{id:"api"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#api",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"API"),(0,e.tZ)(o.Z,{className:"component-api-table"},(0,e.tZ)("thead",null,(0,e.tZ)("tr",null,(0,e.tZ)("th",null,t[12].value),(0,e.tZ)("th",null,t[13].value),(0,e.tZ)("th",null,t[14].value),(0,e.tZ)("th",null,t[15].value),(0,e.tZ)("th",null,t[16].value))),(0,e.tZ)("tbody",null,(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[17].value),(0,e.tZ)("td",null,t[18].value,(0,e.tZ)("code",null,t[19].value),t[20].value),(0,e.tZ)("td",null,(0,e.tZ)(r.Z,{href:"https://github.com/ant-design/ant-design/blob/1bf0bab2a7bc0a774119f501806e3e0e3a6ba283/components/transfer/index.tsx#L12",sourceType:"a"},t[21].value),t[22].value),(0,e.tZ)("td",null,t[23].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[24].value),(0,e.tZ)("td",null,t[25].value),(0,e.tZ)("td",null,t[26].value),(0,e.tZ)("td",null,t[27].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[28].value),(0,e.tZ)("td",null,t[29].value),(0,e.tZ)("td",null,t[30].value),(0,e.tZ)("td",null,t[31].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[32].value),(0,e.tZ)("td",null,t[33].value),(0,e.tZ)("td",null,t[34].value),(0,e.tZ)("td",null,t[35].value),(0,e.tZ)("td",null,t[36].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[37].value),(0,e.tZ)("td",null,t[38].value),(0,e.tZ)("td",null,t[39].value,(0,e.tZ)("code",null,t[40].value),t[41].value,(0,e.tZ)("code",null,t[42].value),t[43].value),(0,e.tZ)("td",null,t[44].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[45].value),(0,e.tZ)("td",null,t[46].value),(0,e.tZ)("td",null,t[47].value),(0,e.tZ)("td",null,t[48].value,(0,e.tZ)("code",null,t[49].value),t[50].value,(0,e.tZ)("code",null,t[51].value),t[52].value,(0,e.tZ)("code",null,t[53].value),t[54].value,(0,e.tZ)("code",null,t[55].value),t[56].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[57].value),(0,e.tZ)("td",null,t[58].value),(0,e.tZ)("td",null,t[59].value),(0,e.tZ)("td",null,t[60].value),(0,e.tZ)("td",null,t[61].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[62].value),(0,e.tZ)("td",null,t[63].value),(0,e.tZ)("td",null,t[64].value),(0,e.tZ)("td",null,t[65].value,(0,e.tZ)("code",null,t[66].value),t[67].value,(0,e.tZ)("code",null,t[68].value),t[69].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[70].value),(0,e.tZ)("td",null,t[71].value),(0,e.tZ)("td",null,t[72].value),(0,e.tZ)("td",null,t[73].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[74].value),(0,e.tZ)("td",null,t[75].value),(0,e.tZ)("td",null,t[76].value),(0,e.tZ)("td",null,t[77].value),(0,e.tZ)("td",null,t[78].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[79].value),(0,e.tZ)("td",null,t[80].value,(0,e.tZ)("code",null,t[81].value),t[82].value,(0,e.tZ)("code",null,t[83].value),t[84].value,(0,e.tZ)("code",null,t[85].value),t[86].value,(0,e.tZ)("code",null,t[87].value),t[88].value),(0,e.tZ)("td",null,t[89].value),(0,e.tZ)("td",null,t[90].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[91].value),(0,e.tZ)("td",null,t[92].value),(0,e.tZ)("td",null,t[93].value),(0,e.tZ)("td",null,t[94].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[95].value),(0,e.tZ)("td",null,t[96].value),(0,e.tZ)("td",null,t[97].value),(0,e.tZ)("td",null,t[98].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[99].value),(0,e.tZ)("td",null,t[100].value),(0,e.tZ)("td",null,t[101].value),(0,e.tZ)("td",null,t[102].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[103].value),(0,e.tZ)("td",null,t[104].value),(0,e.tZ)("td",null,t[105].value),(0,e.tZ)("td",null,t[106].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[107].value),(0,e.tZ)("td",null,t[108].value),(0,e.tZ)("td",null,t[109].value),(0,e.tZ)("td",null,t[110].value),(0,e.tZ)("td",null,t[111].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[112].value),(0,e.tZ)("td",null,t[113].value),(0,e.tZ)("td",null,t[114].value),(0,e.tZ)("td",null,t[115].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[116].value),(0,e.tZ)("td",null,t[117].value),(0,e.tZ)("td",null,t[118].value),(0,e.tZ)("td",null,t[119].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[120].value),(0,e.tZ)("td",null,t[121].value),(0,e.tZ)("td",null,t[122].value),(0,e.tZ)("td",null,t[123].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[124].value),(0,e.tZ)("td",null,t[125].value),(0,e.tZ)("td",null,t[126].value),(0,e.tZ)("td",null,t[127].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[128].value),(0,e.tZ)("td",null,t[129].value),(0,e.tZ)("td",null,t[130].value,(0,e.tZ)("code",null,t[131].value),t[132].value,(0,e.tZ)("code",null,t[133].value),t[134].value),(0,e.tZ)("td",null,t[135].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[136].value),(0,e.tZ)("td",null,t[137].value),(0,e.tZ)("td",null,t[138].value),(0,e.tZ)("td",null,t[139].value),(0,e.tZ)("td",null)))),(0,e.tZ)("h3",{id:"render-props"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#render-props",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Render Props"),(0,e.tZ)("p",null,t[140].value,(0,e.tZ)("code",null,t[141].value),t[142].value),(0,e.tZ)(o.Z,{className:"component-api-table"},(0,e.tZ)("thead",null,(0,e.tZ)("tr",null,(0,e.tZ)("th",null,t[143].value),(0,e.tZ)("th",null,t[144].value),(0,e.tZ)("th",null,t[145].value),(0,e.tZ)("th",null,t[146].value))),(0,e.tZ)("tbody",null,(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[147].value),(0,e.tZ)("td",null,t[148].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,t[149].value),t[150].value,(0,e.tZ)("code",null,t[151].value)),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[152].value),(0,e.tZ)("td",null,t[153].value),(0,e.tZ)("td",null,t[154].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[155].value),(0,e.tZ)("td",null,t[156].value),(0,e.tZ)("td",null,t[157].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[158].value),(0,e.tZ)("td",null,t[159].value),(0,e.tZ)("td",null,t[160].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[161].value),(0,e.tZ)("td",null,t[162].value),(0,e.tZ)("td",null,t[163].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,t[164].value),(0,e.tZ)("td",null,t[165].value),(0,e.tZ)("td",null,t[166].value),(0,e.tZ)("td",null)))),(0,e.tZ)("h4",{id:"example"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#example",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"example"),(0,e.tZ)(a.Z,{lang:"jsx"},t[167].value),(0,e.tZ)("h2",{id:"warning"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#warning",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Warning"),(0,e.tZ)("p",null,t[168].value,(0,e.tZ)(r.Z,{href:"http://facebook.github.io/react/docs/lists-and-keys.html#keys",sourceType:"a"},t[169].value),t[170].value,(0,e.tZ)("code",null,t[171].value),t[172].value,(0,e.tZ)("code",null,t[173].value),t[174].value),(0,e.tZ)("p",null,t[175].value,(0,e.tZ)("code",null,t[176].value),t[177].value,(0,e.tZ)("code",null,t[178].value),t[179].value),(0,e.tZ)(a.Z,{lang:"jsx"},t[180].value),(0,e.tZ)("h2",{id:"design-token"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#design-token",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Design Token")),(0,e.tZ)(s.Z,{component:"Transfer"}),(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("h2",{id:"faq"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#faq",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"FAQ"),(0,e.tZ)("h3",{id:"how-to-support-fetch-and-present-data-from-a-remote-server-in-transfer-column"},(0,e.tZ)(r.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#how-to-support-fetch-and-present-data-from-a-remote-server-in-transfer-column",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"How to support fetch and present data from a remote server in Transfer column."),(0,e.tZ)("p",null,t[181].value,(0,e.tZ)(r.Z,{href:"https://codesandbox.io/s/objective-wing-6iqbx",sourceType:"a"},t[182].value)))))}l.default=u}}]);
|
|
|