| | |
| | | import React, { Component } from 'react' |
| | | import { Tabs } from 'antd' |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | |
| | | // Drag & Drop node |
| | |
| | | const newOrder = this.state.order.slice() |
| | | const { children } = this.props |
| | | |
| | | if (dragKey === 'tool' || hoverKey === 'tool') return |
| | | |
| | | React.Children.forEach(children, c => { |
| | | if (newOrder.indexOf(c.key) === -1) { |
| | | newOrder.push(c.key) |
| | |
| | | |
| | | newOrder.splice(dragIndex, 1) |
| | | newOrder.splice(hoverIndex, 0, dragKey) |
| | | let _order = newOrder.filter(item => item !== 'tool') |
| | | |
| | | this.setState({ |
| | | order: [..._order, 'tool'] |
| | | order: newOrder |
| | | }) |
| | | this.props.tabsMove(_order) |
| | | this.props.tabsMove(newOrder) |
| | | } |
| | | |
| | | renderTabBar = (props, DefaultTabBar) => ( |
| | |
| | | </DefaultTabBar> |
| | | ) |
| | | |
| | | 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 |
| | | } |
| | | |
| | | render() { |
| | | const { order } = this.state |
| | | const { children } = this.props |
| | | |
| | | const tabs = [] |
| | | React.Children.forEach(children, c => { |
| | | tabs.push(c) |