<commit_before>import React from "react";
import styled from "styled-components";
import { sendRoomMessage } from "../room/roomActions";
import { connect } from "react-redux";
import {
	hideEmoticonPicker,
	selectRightInEmoticonPicker,
	searchEmoticonPicker,
	showEmoticonPicker,
	selectLeftInEmoticonPicker,
	selectDownInEmoticonPicker,
	selectUpInEmoticonPicker
} from "../emoticon/emoticonPickerActions";

const InputBox = styled.textarea`
	border-radius: 0;
	resize: none;
	white-space: nowrap;

	&.form-control:focus {
		outline: none;
		box-shadow: none;
	}
`;

const mapStateToProps = state => ({
	emoticonPickerVisible: !!state.emoticonPicker.target,
	selectedEmoticon: state.emoticonPicker.selected
});

const mapDispatchToProps = dispatch => ({
	searchEmoticonPicker: text => {
		dispatch(searchEmoticonPicker(text));
	},
	showEmoticonPicker: target => {
		dispatch(showEmoticonPicker(target));
	},
	hideEmoticonPicker: () => {
		dispatch(hideEmoticonPicker());
	},
	selectLeftEmoticonPicker: () => {
		dispatch(selectLeftInEmoticonPicker());
	},
	selectRightEmoticonPicker: () => {
		dispatch(selectRightInEmoticonPicker());
	},
	selectUpEmoticonPicker: () => {
		dispatch(selectUpInEmoticonPicker());
	},
	selectDownEmoticonPicker: () => {
		dispatch(selectDownInEmoticonPicker());
	},
	send: (roomId, text) => {
		dispatch(sendRoomMessage(roomId, text));
	}
});

class ChatInput extends React.PureComponent {
	constructor(props) {
		super(props);
		this.state = {
			ref: React.createRef(),
			text: ""
		};
	}

	onInputChange = event => {
		const text = event.target.value;

		if (this.props.emoticonPickerVisible) {
			const match = /:(\w+)$/.exec(text);
			if (match) {
				this.props.searchEmoticonPicker(match[1]);
			}
		}

		this.setState({ text });
	};

	onKeyDown = event => {
		if (event.key === "Enter") {
			event.preventDefault();

			if (this.props.emoticonPickerVisible) {<commit_msg>close emoticon picker when doing a space<commit_after>import React from "react";
import styled from "styled-components";
import { sendRoomMessage } from "../room/roomActions";
import { connect } from "react-redux";
import {
	hideEmoticonPicker,
	selectRightInEmoticonPicker,
	searchEmoticonPicker,
	showEmoticonPicker,
	selectLeftInEmoticonPicker,
	selectDownInEmoticonPicker,
	selectUpInEmoticonPicker
} from "../emoticon/emoticonPickerActions";

const InputBox = styled.textarea`
	border-radius: 0;
	resize: none;
	white-space: nowrap;

	&.form-control:focus {
		outline: none;
		box-shadow: none;
	}
`;

const mapStateToProps = state => ({
	emoticonPickerVisible: !!state.emoticonPicker.target,
	selectedEmoticon: state.emoticonPicker.selected
});

const mapDispatchToProps = dispatch => ({
	searchEmoticonPicker: text => {
		dispatch(searchEmoticonPicker(text));
	},
	showEmoticonPicker: target => {
		dispatch(showEmoticonPicker(target));
	},
	hideEmoticonPicker: () => {
		dispatch(hideEmoticonPicker());
	},
	selectLeftEmoticonPicker: () => {
		dispatch(selectLeftInEmoticonPicker());
	},
	selectRightEmoticonPicker: () => {
		dispatch(selectRightInEmoticonPicker());
	},
	selectUpEmoticonPicker: () => {
		dispatch(selectUpInEmoticonPicker());
	},
	selectDownEmoticonPicker: () => {
		dispatch(selectDownInEmoticonPicker());
	},
	send: (roomId, text) => {
		dispatch(sendRoomMessage(roomId, text));
	}
});

class ChatInput extends React.PureComponent {
	constructor(props) {
		super(props);
		this.state = {
			ref: React.createRef(),
			text: ""
		};
	}

	onInputChange = event => {
		const text = event.target.value;

		if (this.props.emoticonPickerVisible) {
			const match = /:(.+)$/.exec(text);
			if (match) {
				this.props.searchEmoticonPicker(match[1]);
			}
		}

		this.setState({ text });
	};

	onKeyDown = event => {
		if (event.key === "Enter") {
			event.preventDefault();

			if (this.props.emoticonPickerVisible) {
{'fraction_non_alphanumeric': 0.14545454545454545, 'fraction_numerical': 0.001038961038961039, 'mean_word_length': 4.989113530326594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '2993009', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1310, 'n_words': 214}