<commit_before>import React from "react";

export class DecimalChecker extends React.Component {
    onKeyPress(e){
        var nextValue = e.target.value + e.key;
        var decimal = nextValue.match(/\./g);
        var decimalCount = decimal ? decimal.length : 0;
        if(e.key === "." && decimalCount > 1) e.preventDefault();

        if(this.props.onKeyPress) this.props.onKeyPress(e);
    }
}

class ExchangeInput extends DecimalChecker {
    constructor(){
        super();
    }

    render(){
        return <input type="number" {...this.props} onKeyPress={this.onKeyPress.bind(this)} />;
    }<commit_msg>Make sure exchange input only allows numbers, does not allow negative values, only allows a single decimal, cannot be changed with mouse wheel (#572)<commit_after>import React from "react";

export class DecimalChecker extends React.Component {
    onKeyPress(e){
        var nextValue = e.target.value + e.key;
        var decimal = nextValue.match(/\./g);
        var decimalCount = decimal ? decimal.length : 0;
        if(e.key === "." && decimalCount > 1) e.preventDefault();
        if(parseFloat(nextValue) != nextValue) e.preventDefault();

        if(this.props.onKeyPress) this.props.onKeyPress(e);
    }
}

class ExchangeInput extends DecimalChecker {
    constructor(){
        super();
    }

    render(){
        return <input type="text" {...this.props} onKeyPress={this.onKeyPress.bind(this)} />;
    }
{'fraction_non_alphanumeric': 0.13639526791927628, 'fraction_numerical': 0.0048712595685455815, 'mean_word_length': 2.9397260273972603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6527975', 'n_tokens_mistral': 426, 'n_tokens_neox': 417, 'n_words': 107}