<commit_before>import React, { useState, useRef, useEffect } from 'react';
import PropTypes from 'prop-types';

const EXTRA_SPACE = 5;

const inputTextSizerStyle = {
	fontWeight: 400,
	fontSize: '1.6rem',
	visibility: 'hidden',
	position: 'absolute',
};

const placeholderSizerStyle = {
	...inputTextSizerStyle,
	fontStyle: 'oblique',
};

function InputSizer({ placeholder, inputText, children }) {
	const [width, setWidth] = useState(0);
	const sizerRef = useRef(null);

	useEffect(() => {
		setWidth(sizerRef.current.getBoundingClientRect().width);
	}, [inputText, placeholder]);

	const style = inputText ? inputTextSizerStyle : placeholderSizerStyle;
	const text = inputText || placeholder;
	return (
		<React.Fragment>
			{children(width + EXTRA_SPACE)}
			<span style={style} ref={sizerRef}>
				{text}
			</span>
		</React.Fragment><commit_msg>fix issue with initial size of input (#2508)<commit_after>import React, { useState, useRef, useEffect } from 'react';
import PropTypes from 'prop-types';

const EXTRA_SPACE = 5;

const inputTextSizerStyle = {
	fontWeight: 400,
	fontSize: '1.6rem',
	visibility: 'hidden',
	position: 'absolute',
};

const placeholderSizerStyle = {
	...inputTextSizerStyle,
	fontStyle: 'oblique',
};

function InputSizer({ placeholder, inputText, children }) {
	const [width, setWidth] = useState(0);
	const sizerRef = useRef(null);

	useEffect(() => {
		setWidth(sizerRef.current.getBoundingClientRect().width);
	});

	const style = inputText ? inputTextSizerStyle : placeholderSizerStyle;
	const text = inputText || placeholder;
	return (
		<React.Fragment>
			{children(width + EXTRA_SPACE)}
			<span style={style} ref={sizerRef}>
				{text}
			</span>
		</React.Fragment>
{'fraction_non_alphanumeric': 0.1411833626244874, 'fraction_numerical': 0.01054481546572935, 'mean_word_length': 5.143884892086331, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '2773254', 'n_tokens_mistral': 595, 'n_tokens_neox': 566, 'n_words': 132}