<commit_before>/**
 * @file GroupList component
 * @author liangxiaojun(<EMAIL>)
 */

import React, {Component} from 'react';
import PropTypes from 'prop-types';

import List from '../List';
import Theme from '../Theme';
import Tip from '../Tip';

import Util from '../_vendors/Util';
import Event from '../_vendors/Event';
import SelectMode from '../_statics/SelectMode';
import LIST_SEPARATOR from '../_statics/ListSeparator';

export default class GroupList extends Component {

    static SelectMode = SelectMode;
    static LIST_SEPARATOR = LIST_SEPARATOR;

    constructor(props, ...restArgs) {

        super(props, ...restArgs);

        this.state = {
            value: this.initValue(props)
        };

        this.initValue = ::this.initValue;
        Event.wheelHandler = this::Event.wheelHandler;

    }

    initValue(props) {

        if (!props) {
            return;
        }

        const {value, selectMode} = props;

        if (!selectMode) {
            return;
        }

        if (value) {
            return value;
        }

        switch (selectMode) {
            case GroupList.SelectMode.MULTI_SELECT:
                return [];
            case GroupList.SelectMode.SINGLE_SELECT:
                return null;
            default:
                return value;
        }

    }

    componentWillReceiveProps(nextProps) {
        if (nextProps.value !== this.state.value) {
            this.setState({
                value: this.initValue(nextProps)
            });
        }
    }

    render() {

        const {

                children, className, style, data, disabled,

                ...restProps

            } = this.props,
            {value} = this.state,

            listClassName = (className ? ' ' + className : '');

        return (
            <div className={'group-list' + listClassName}
                 style={style}
                 disabled={disabled}
                 onWheel={Event.wheelHandler}>

                {
                    data && data.length > 0 ?
                        data.map((item, index) => {

                            if (item === LIST_SEPARATOR) {
                                return <div key={index}
                                            className="list-separator"></div>;
                            }

                            return (
                                <div key={index}>
                                    <div className="group-list-group-title">{item.name}</div>
                                    <List {...restProps}
                                          data={item.children}/>
                                </div>
                            );

                        })
                        :<commit_msg>update GroupList<commit_after>/**
 * @file GroupList component
 * @author liangxiaojun(<EMAIL>)
 */

import React, {Component} from 'react';
import PropTypes from 'prop-types';

import List from '../List';
import Theme from '../Theme';
import Tip from '../Tip';

import Util from '../_vendors/Util';
import Event from '../_vendors/Event';
import SelectMode from '../_statics/SelectMode';
import LIST_SEPARATOR from '../_statics/ListSeparator';

export default class GroupList extends Component {

    static SelectMode = SelectMode;
    static LIST_SEPARATOR = LIST_SEPARATOR;

    constructor(props, ...restArgs) {

        super(props, ...restArgs);

        this.state = {
            value: this.initValue(props)
        };

        this.initValue = ::this.initValue;

    }

    initValue(props) {

        if (!props) {
            return;
        }

        const {value, selectMode} = props;

        if (!selectMode) {
            return;
        }

        if (value) {
            return value;
        }

        switch (selectMode) {
            case GroupList.SelectMode.MULTI_SELECT:
                return [];
            case GroupList.SelectMode.SINGLE_SELECT:
                return null;
            default:
                return value;
        }

    }

    componentWillReceiveProps(nextProps) {
        if (nextProps.value !== this.state.value) {
            this.setState({
                value: this.initValue(nextProps)
            });
        }
    }

    render() {

        const {

                children, className, style, data, disabled,

                ...restProps

            } = this.props,
            {value} = this.state,

            listClassName = (className ? ' ' + className : '');

        return (
            <div className={'group-list' + listClassName}
                 style={style}
                 disabled={disabled}
                 onWheel={e => {
                     Event.wheelHandler(e, this.props);
                 }}>

                {
                    data && data.length > 0 ?
                        data.map((item, index) => {

                            if (item === LIST_SEPARATOR) {
                                return <div key={index}
                                            className="list-separator"></div>;
                            }

                            return (
                                <div key={index}>
                                    <div className="group-list-group-title">{item.name}</div>
                                    <List {...restProps}
                                          data={item.children}/>
                                </div>
                            );

                        })
                        :
{'fraction_non_alphanumeric': 0.11143428467551354, 'fraction_numerical': 0.00036357025995273584, 'mean_word_length': 1.1568012544100352, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1522884', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1307, 'n_words': 285}