<commit_before>import { useState } from 'react';

const FOCUSSED_CLASS = 'focussed';
const BLURRED_CLASS = 'blured';
const DIRTY_CLASS = 'dirty';
const PRISTINE_CLASS = 'dirty';

const DEFAULT_STATE = { focussed: false, blurred: false, dirty: false, pristine: true };

const useInput = (initialState = DEFAULT_STATE, prefix = 'field') => {
    const [status, changeStatus] = useState(initialState);
    const change = () => !status.dirty && changeStatus({ ...status, dirty: true, pristine: false });
    const blur = () => !status.blurred && changeStatus({ ...status, blurred: true, pristine: false });
    const focus = () => !status.focussed && changeStatus({ ...status, focussed: true, pristine: false });
    const reset = () => changeStatus({ ...DEFAULT_STATE });
    const classes = [];

    if (status.pristine) {
        classes.push(PRISTINE_CLASS);
    } else {
        status.focussed && classes.push(`${prefix}-${FOCUSSED_CLASS}`);
        status.blurred && classes.push(`${prefix}-${BLURRED_CLASS}`);
        status.dirty && classes.push(`${prefix}-${DIRTY_CLASS}`);
    }

    return {
        status,
        statusClasses: classes.join(' '),
        change, blur, focus, reset
    }
};

export default useInput;<commit_msg>Hotfix pristine class<commit_after>import { useState } from 'react';

const FOCUSSED_CLASS = 'focussed';
const BLURRED_CLASS = 'blured';
const DIRTY_CLASS = 'dirty';
const PRISTINE_CLASS = 'pristine';

const DEFAULT_STATE = { focussed: false, blurred: false, dirty: false, pristine: true };

const useInput = (initialState = DEFAULT_STATE, prefix = 'field') => {
    const [status, changeStatus] = useState(initialState);
    const change = () => !status.dirty && changeStatus({ ...status, dirty: true, pristine: false });
    const blur = () => !status.blurred && changeStatus({ ...status, blurred: true, pristine: false });
    const focus = () => !status.focussed && changeStatus({ ...status, focussed: true, pristine: false });
    const reset = () => changeStatus({ ...DEFAULT_STATE });
    const classes = [];

    if (status.pristine) {
        classes.push(PRISTINE_CLASS);
    } else {
        status.focussed && classes.push(`${prefix}-${FOCUSSED_CLASS}`);
        status.blurred && classes.push(`${prefix}-${BLURRED_CLASS}`);
        status.dirty && classes.push(`${prefix}-${DIRTY_CLASS}`);
    }

    return {
        status,
        statusClasses: classes.join(' '),
        change,
        blur,
        focus,
        reset
    };
};

export default useInput;

{'fraction_non_alphanumeric': 0.1658051689860835, 'fraction_numerical': 0.0, 'mean_word_length': 3.4452296819787986, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3219002', 'n_tokens_mistral': 789, 'n_tokens_neox': 750, 'n_words': 181}