|
1 | 1 | /* eslint-disable jsx-a11y/anchor-is-valid */ |
2 | 2 | import React, { useState, useRef } from 'react'; |
3 | 3 | import { Tabs } from 'antd'; |
4 | | -import { DndProvider, useDrag, useDrop } from 'react-dnd'; |
5 | | -import { HTML5Backend } from 'react-dnd-html5-backend'; |
6 | 4 | import Core from '../../index'; |
7 | 5 |
|
8 | 6 | const { TabPane } = Tabs; |
@@ -52,40 +50,6 @@ const DraggableTabNode = ({ index, children, moveNode }) => { |
52 | 50 | ); |
53 | 51 | }; |
54 | 52 |
|
55 | | -const DraggableTabs = props => { |
56 | | - const { children, changeList, displayList } = props; |
57 | | - |
58 | | - const moveTabNode = (dragKey, hoverKey) => { |
59 | | - let newDisplayList = displayList.slice(); |
60 | | - newDisplayList.splice(dragKey, 1); |
61 | | - newDisplayList.splice(hoverKey, 0, displayList[dragKey]); |
62 | | - |
63 | | - changeList(newDisplayList); |
64 | | - }; |
65 | | - |
66 | | - const renderTabBar = (tabBarProps, DefaultTabBar) => ( |
67 | | - <DefaultTabBar {...tabBarProps}> |
68 | | - {node => ( |
69 | | - <DraggableTabNode |
70 | | - key={node.key} |
71 | | - index={node.key} |
72 | | - moveNode={moveTabNode} |
73 | | - > |
74 | | - {node} |
75 | | - </DraggableTabNode> |
76 | | - )} |
77 | | - </DefaultTabBar> |
78 | | - ); |
79 | | - |
80 | | - return ( |
81 | | - <DndProvider backend={HTML5Backend}> |
82 | | - <Tabs renderTabBar={renderTabBar} {...props}> |
83 | | - {children} |
84 | | - </Tabs> |
85 | | - </DndProvider> |
86 | | - ); |
87 | | -}; |
88 | | - |
89 | 53 | const TabList = ({ |
90 | 54 | displayList = [], |
91 | 55 | listData, |
@@ -122,27 +86,7 @@ const TabList = ({ |
122 | 86 | : `${tabName || '项目'} ${idx + 1}`; |
123 | 87 | }; |
124 | 88 |
|
125 | | - return draggable ? ( |
126 | | - <DraggableTabs |
127 | | - type={type || 'line'} |
128 | | - onChange={setActiveKey} |
129 | | - activeKey={activeKey} |
130 | | - onEdit={onEdit} |
131 | | - changeList={changeList} |
132 | | - displayList={displayList} |
133 | | - {...restProps} |
134 | | - > |
135 | | - {displayList.map((item, idx) => { |
136 | | - const fieldsProps = getFieldsProps(idx); |
137 | | - fieldsProps.displayType = displayType; |
138 | | - return ( |
139 | | - <TabPane tab={getCurrentTabPaneName(idx)} key={`${idx}`}> |
140 | | - <Core {...fieldsProps} /> |
141 | | - </TabPane> |
142 | | - ); |
143 | | - })} |
144 | | - </DraggableTabs> |
145 | | - ) : ( |
| 89 | + return ( |
146 | 90 | <Tabs |
147 | 91 | type={type || 'line'} |
148 | 92 | onChange={setActiveKey} |
|
0 commit comments