<commit_before>import React, { Component } from 'react';
import Checkbox from 'react-checkbox';

export default class ContextualInput extends Component {
    constructor(props){
        super(props);
        this.state = {
            id: '',
            input: '',
            label: '',
            value: ''
        }

        this.handleInput = this.handleInput.bind(this);
        this.handleToggle = this.handleToggle.bind(this);
    }
    componentDidMount(){
        this.setState({
            value: this.props.value
        });
    }
    componentDidUpdate(prevProps){
        if (this.props.value !== prevProps.value){
            this.setState({
                value: this.props.value
            });
        }
    }
    render(){
        switch(this.props.input){
            case 'longText':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <textarea  type="text"
                                className="form-control"
                                id={this.props.id}
                                value={this.state.value}
                                onChange={this.handleInput}
                                disabled={this.props.isTemplate}
                                rows = "4"
                        />
                    </div>
                );
                break;
            case 'number':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <input  type="number"
                                step="any"
                                className="form-control"
                                id={this.props.id}
                                value={this.state.value}
                                onChange={this.handleInput}
                                disabled={this.props.isTemplate}
                        />
                    </div>
                );
                break;
            case 'currency':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <div className="input-group">
                            <span className="input-group-addon">$</span>
                            <input  type="number"
                                    step="any"
                                    className="form-control"
                                    id={this.props.id}
                                    value={this.state.value}
                                    onChange={this.handleInput}
                                    disabled={this.props.isTemplate}
                            />
                        </div>
                    </div>
                );
                break;
            case 'checkbox':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <p>{this.props.label}</p>
                        <button id={this.props.id} className={`btn btn-small ${ this.state.value ? 'btn-success' : 'btn-danger'}`} onClick={this.handleToggle}>{this.state.value.toString()}</button>
                    </div>
                );
                break;<commit_msg>update button input for template<commit_after>import React, { Component } from 'react';
import Checkbox from 'react-checkbox';

export default class ContextualInput extends Component {
    constructor(props){
        super(props);
        this.state = {
            id: '',
            input: '',
            label: '',
            value: ''
        }

        this.handleInput = this.handleInput.bind(this);
        this.handleToggle = this.handleToggle.bind(this);
    }
    componentDidMount(){
        this.setState({
            value: this.props.value
        });
    }
    componentDidUpdate(prevProps){
        if (this.props.value !== prevProps.value){
            this.setState({
                value: this.props.value
            });
        }
    }
    render(){
        switch(this.props.input){
            case 'longText':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <textarea  type="text"
                                className="form-control"
                                id={this.props.id}
                                value={this.state.value}
                                onChange={this.handleInput}
                                disabled={this.props.isTemplate}
                                rows = "4"
                        />
                    </div>
                );
                break;
            case 'number':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <input  type="number"
                                step="any"
                                className="form-control"
                                id={this.props.id}
                                value={this.state.value}
                                onChange={this.handleInput}
                                disabled={this.props.isTemplate}
                        />
                    </div>
                );
                break;
            case 'currency':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <label htmlFor={this.props.id}>{this.props.label}</label>
                        <div className="input-group">
                            <span className="input-group-addon">$</span>
                            <input  type="number"
                                    step="any"
                                    className="form-control"
                                    id={this.props.id}
                                    value={this.state.value}
                                    onChange={this.handleInput}
                                    disabled={this.props.isTemplate}
                            />
                        </div>
                    </div>
                );
                break;
            case 'checkbox':
                return(
                    <div className={`form-group ${this.props.isTemplate && 'isTemplateInput'}`}>
                        <p>{this.props.label}</p>
                        <button disabled={this.props.isTemplate} id={this.props.id} className={`btn btn-small ${ this.state.value ? 'btn-success' : 'btn-danger'}`} onClick={this.handleToggle}>{this.state.value.toString() || 'True / False'}</button>
                    </div>
                );
                break;
{'fraction_non_alphanumeric': 0.11604664075513603, 'fraction_numerical': 0.000277623542476402, 'mean_word_length': 0.9821182943603851, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2877495', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1594, 'n_words': 246}