<commit_before>class Lanes.Components.FieldSet extends Lanes.React.Component

    getDefaultProps: ->
        speed: 0.4

    propTypes:
        title: React.PropTypes.string.isRequired
        speed: React.PropTypes.number
        collapsed: React.PropTypes.bool

    getInitialState: ->
        state = {
            expanded: !@props.collapsed,
            icon: if @props.collapsed then 'plus' else 'minus'
        }
        state.height = 30 if @props.collapsed
        state

    getClientHeight: ->
        _.max(
            _.pluck(@refs.body.getDOMNode().children, 'clientHeight')
        ) + 45


    toggleExpanded: ->
        if @state.expanded
            if ! @state.hasExpanded
                @setState( hasExpanded: true, height: @getClientHeight() )
                _.defer @toggleExpanded
                return
            @setState expanded: false, height: 30
        else
            @setState expanded: true, height: @getClientHeight()

        _.delay( =>
            if @isMounted()
                @setState(icon: if @state.expanded then 'minus' else 'plus')
        , @props.speed * 1000)

    render: ->
        colProps = _.omit(@props, 'name')
        <BS.Col {...colProps}>
            <fieldset className={
                _.classnames("collapsible", @props.className, @state.icon
                {expanded: @state.expanded, collapsed: !@state.expanded})
            }
            style={
                maxHeight: @state.height
                transition: "max-height #{@props.speed}s ease-in-out";
            }>
                <legend onClick={@toggleExpanded}>
                    {@props.title}
                </legend>
                <div ref="body" className="fieldset-fields">
                    {@props.children}
                </div>
            </fieldset>
        </BS.Col>
<commit_msg>Use Collapse component vs own logic<commit_after>class Lanes.Components.FieldSet extends Lanes.React.Component

    getDefaultProps: ->
        expanded: true

    propTypes:
        title: React.PropTypes.string.isRequired
        expanded: React.PropTypes.bool

    getInitialState: ->
        expanded: @props.expanded

    componentWillReceiveProps: (nextProps) ->
        @setState(expanded: nextProps.expanded) if nextProps.expanded?

    toggleExpanded: ->
        @setState(expanded: not @state.expanded)

    render: ->
        colProps = _.omit(@props, 'name')
        <BS.Col {...colProps}>
            <fieldset className={
                _.classnames("collapsible", @props.className, @state.icon
                    {expanded: @state.expanded, collapsed: !@state.expanded})
            }>
                <legend onClick={@toggleExpanded}>
                    {@props.title}
                </legend>
                <BS.Collapse in={@state.expanded}>
                    <div ref="body" className="fieldset-fields">
                        {@props.children}
                    </div>
                </BS.Collapse>
            </fieldset>
        </BS.Col>

{'fraction_non_alphanumeric': 0.11760797342192691, 'fraction_numerical': 0.003986710963455149, 'mean_word_length': 1.6159860990443093, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7548124', 'n_tokens_mistral': 847, 'n_tokens_neox': 804, 'n_words': 163}