Skip to content

Commit

Permalink
feat(fr):v1.13.6
Browse files Browse the repository at this point in the history
  • Loading branch information
siyi98 committed Jun 17, 2022
1 parent a4e8995 commit 1c8536d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const CardList = ({
className={`fr-card-item ${
displayType === 'row' ? 'fr-card-item-row' : ''
}`}
key={Date.now()}
key={idx}
>
<div className="fr-card-index">{idx + 1}</div>
<Core {...fieldsProps} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React, { useState, useRef } from 'react';
import { Tabs } from 'antd';
import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import Core from '../../index';

const { TabPane } = Tabs;
Expand Down Expand Up @@ -52,40 +50,6 @@ const DraggableTabNode = ({ index, children, moveNode }) => {
);
};

const DraggableTabs = props => {
const { children, changeList, displayList } = props;

const moveTabNode = (dragKey, hoverKey) => {
let newDisplayList = displayList.slice();
newDisplayList.splice(dragKey, 1);
newDisplayList.splice(hoverKey, 0, displayList[dragKey]);

changeList(newDisplayList);
};

const renderTabBar = (tabBarProps, DefaultTabBar) => (
<DefaultTabBar {...tabBarProps}>
{node => (
<DraggableTabNode
key={node.key}
index={node.key}
moveNode={moveTabNode}
>
{node}
</DraggableTabNode>
)}
</DefaultTabBar>
);

return (
<DndProvider backend={HTML5Backend}>
<Tabs renderTabBar={renderTabBar} {...props}>
{children}
</Tabs>
</DndProvider>
);
};

const TabList = ({
displayList = [],
listData,
Expand Down Expand Up @@ -122,27 +86,7 @@ const TabList = ({
: `${tabName || '项目'} ${idx + 1}`;
};

return draggable ? (
<DraggableTabs
type={type || 'line'}
onChange={setActiveKey}
activeKey={activeKey}
onEdit={onEdit}
changeList={changeList}
displayList={displayList}
{...restProps}
>
{displayList.map((item, idx) => {
const fieldsProps = getFieldsProps(idx);
fieldsProps.displayType = displayType;
return (
<TabPane tab={getCurrentTabPaneName(idx)} key={`${idx}`}>
<Core {...fieldsProps} />
</TabPane>
);
})}
</DraggableTabs>
) : (
return (
<Tabs
type={type || 'line'}
onChange={setActiveKey}
Expand Down

0 comments on commit 1c8536d

Please sign in to comment.