| | |
| | | |
| | | if (dragKey === hoverKey) { |
| | | return; |
| | | } else if (!dragKey) { |
| | | monitor.getItem().added = true |
| | | props.tabsDrop(hoverKey) |
| | | } |
| | | |
| | | props.moveTabNode(dragKey, hoverKey) |
| | |
| | | } |
| | | } |
| | | |
| | | const WrapTabNode = DropTarget('DND_NODE', cardTarget, connect => ({ |
| | | const WrapTabNode = DropTarget('menu', cardTarget, connect => ({ |
| | | connectDropTarget: connect.dropTarget(), |
| | | }))( |
| | | DragSource('DND_NODE', cardSource, (connect, monitor) => ({ |
| | | DragSource('menu', cardSource, (connect, monitor) => ({ |
| | | connectDragSource: connect.dragSource(), |
| | | isDragging: monitor.isDragging(), |
| | | }))(TabNode) |
| | |
| | | const dragIndex = newOrder.indexOf(dragKey) |
| | | const hoverIndex = newOrder.indexOf(hoverKey) |
| | | |
| | | if (dragIndex === -1) { |
| | | this.props.tabsDrop(hoverKey, dragKey) |
| | | return |
| | | } |
| | | |
| | | newOrder.splice(dragIndex, 1) |
| | | newOrder.splice(hoverIndex, 0, dragKey) |
| | | |
| | |
| | | renderTabBar = (props, DefaultTabBar) => ( |
| | | <DefaultTabBar {...props}> |
| | | {node => ( |
| | | <WrapTabNode key={node.key} index={node.key} moveTabNode={this.moveTabNode}> |
| | | <WrapTabNode key={node.key} index={node.key} moveTabNode={this.moveTabNode} tabsDrop={this.props.tabsDrop}> |
| | | {node} |
| | | </WrapTabNode> |
| | | )} |
| | |
| | | ) |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) || |
| | | !is(fromJS(nextProps.children), fromJS(this.props.children)) || |
| | | nextProps.tabPosition !== this.props.tabPosition || |
| | | nextProps.type !== this.props.type |
| | | return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(nextProps.children), fromJS(this.props.children)) |
| | | } |
| | | |
| | | render() { |