import ConfigProvider from '../config-provider';
import React, { Component } from 'react';
import cls from 'classnames';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { Tree as NextTree } from '@alifd/next';
class Tree extends Component {
    render() {
        const { prefix = 'next-', className, isNodeBlock, size = 'medium', type = '', showLine } = this.props;
        let defaultPaddingLeft = 16;
        let indent = type === 'document' ? 16 : 20;
        if (typeof isNodeBlock === 'object') {
            const nodeBlock = isNodeBlock;
            defaultPaddingLeft = parseInt(nodeBlock.defaultPaddingLeft || 16);
            indent = type === 'document' ? parseInt(nodeBlock.indent || 16) : parseInt(nodeBlock.indent || 20);
        }
        // 带线条模式
        if (type === 'document') {
            return (React.createElement(NextTree, Object.assign({}, this.props, { isNodeBlock: isNodeBlock ? { defaultPaddingLeft, indent } : false, prefix: prefix, className: cls(className, {
                    [`${prefix}small`]: size === 'small',
                    [`${prefix}medium`]: size === 'medium',
                    [`${prefix}document`]: type === 'document',
                }) })));
        }
        if (!showLine) { // 三角模式
            return React.createElement(NextTree, Object.assign({}, this.props, { isNodeBlock: isNodeBlock ? { defaultPaddingLeft, indent } : false, prefix: prefix, className: cls(className, {
                    [`${prefix}small`]: size === 'small',
                    [`${prefix}medium`]: size === 'medium',
                }) }));
        }
        return React.createElement(NextTree, Object.assign({}, this.props, { prefix: prefix, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
            }) }));
    }
}
Tree.Node = NextTree.Node;
hoistNonReactStatics(Tree, NextTree);
export default ConfigProvider.config(Tree);
