<commit_before>import React from 'react'
import TextBox from './TextBox.jsx'

const DecimalSeparator = '.';

let parseAndCheckImplicitDecimal = (valueString) => {
	let value = parseFloat(valueString);
	value = !isNaN(value) ? value : 0

	let isExplicitDecimal = value % 1 !== 0;
	let isImplicitDecimal = !isExplicitDecimal && valueString.endsWith(DecimalSeparator);

	return { value, isImplicitDecimal };
};

class NumberBox extends TextBox {
	constructor(props) {
		super(props);

		this.state = { isImplicitDecimal: false }; 
	}

	formatValueToDisplay(value) {
		return this.state.isImplicitDecimal
		? '' + value + DecimalSeparator
		: value;
	}

	formatNewValueToReport(newValue) {
		let { value, isImplicitDecimal } = parseAndCheckImplicitDecimal(newValue);

		if (isImplicitDecimal !== this.state.isImplicitDecimal) {
			this.setState({ isImplicitDecimal });
		}

		return value;
	}
};

export default NumberBox;
<commit_msg>NumberBox now handles comma as decimal separator<commit_after>import React from 'react'
import TextBox from './TextBox.jsx'

const DecimalSeparator = '.';
const NotSupportedDecimalSeparator = ',';

let parseAndCheckImplicitDecimal = (valueString) => {
	valueString = valueString.replace(NotSupportedDecimalSeparator, DecimalSeparator);

	let value = parseFloat(valueString);
	value = !isNaN(value) ? value : 0;

	let isExplicitDecimal = value % 1 !== 0;
	let isImplicitDecimal = !isExplicitDecimal && valueString.endsWith(DecimalSeparator);

	return { value, isImplicitDecimal };
};

class NumberBox extends TextBox {
	constructor(props) {
		super(props);

		this.state = { isImplicitDecimal: false }; 
	}

	formatValueToDisplay(value) {
		return this.state.isImplicitDecimal
		? '' + value + DecimalSeparator
		: value;
	}

	formatNewValueToReport(newValue) {
		let { value, isImplicitDecimal } = parseAndCheckImplicitDecimal(newValue);

		if (isImplicitDecimal !== this.state.isImplicitDecimal) {
			this.setState({ isImplicitDecimal });
		}

		return value;
	}
};

export default NumberBox;

{'fraction_non_alphanumeric': 0.10815939278937381, 'fraction_numerical': 0.0028462998102466793, 'mean_word_length': 4.081927710843374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3613405', 'n_tokens_mistral': 691, 'n_tokens_neox': 636, 'n_words': 135}