<commit_before>//TODO Label should move above the field on focus. Directly above for now
//TODO Not reviewed during 2.0 refact

class RcdMaterialField extends RcdDivElement {
    constructor(labelText) {
        super();
        this.label = new RcdTextElement(labelText).init().
            addClass('rcd-material-textfield-label');
    }

    init() {
        return this.addClass('rcd-material-field').
            addChild(this.label);
    }
}

class RcdMaterialTextField extends RcdMaterialField {
    constructor(labelText, placeholder) {
        super(labelText);
        this.input = new RcdInputElement().init()
            .setPlaceholder(placeholder)
            .addClass('rcd-material-field-input')
            .addClass('rcd-material-textfield-input');
    }

    init() {
        return this.addClass('rcd-material-textfield').
            addChild(this.input);
    }

    getValue() {
        return this.input.getValue();
    }

    setValue(value) {
        this.input.setValue(value);
        return this;
    }

    focus() {
        this.input.focus();
        return this;
    }

    select() {
        this.input.select();
        return this;
    }
    
    setPattern(pattern) {
        this.input.setAttribute('pattern', pattern);
        return this;
    }

    addInputListener(listener) {
        this.input.addInputListener(listener);
        return this;
    }

    removeInputListener(listener) {
        this.input.removeInputListener(listener);
        return this;
    }
}

class RcdMaterialDropdown extends RcdMaterialField {
    constructor(labelText, options) {
        super(labelText);
        this.select = new RcdSelectElement().init().
            addOptions(options).
            addClass('rcd-material-dropdown-select').
            addClass('rcd-material-field-input');
    }

    init() {
        return super.init().<commit_msg>Check validity method on text fields<commit_after>//TODO Label should move above the field on focus. Directly above for now
//TODO Not reviewed during 2.0 refact

class RcdMaterialField extends RcdDivElement {
    constructor(labelText) {
        super();
        this.label = new RcdTextElement(labelText).init().
            addClass('rcd-material-textfield-label');
    }

    init() {
        return this.addClass('rcd-material-field').
            addChild(this.label);
    }
}

class RcdMaterialTextField extends RcdMaterialField {
    constructor(labelText, placeholder) {
        super(labelText);
        this.input = new RcdInputElement().init()
            .setPlaceholder(placeholder)
            .addClass('rcd-material-field-input')
            .addClass('rcd-material-textfield-input');
    }

    init() {
        return this.addClass('rcd-material-textfield').
            addChild(this.input);
    }

    getValue() {
        return this.input.getValue();
    }

    setValue(value) {
        this.input.setValue(value);
        return this;
    }

    focus() {
        this.input.focus();
        return this;
    }

    select() {
        this.input.select();
        return this;
    }
    
    setPattern(pattern) {
        this.input.setAttribute('pattern', pattern);
        return this;
    }
    
    checkValidity() {
        return this.input.domElement.checkValidity();
    }

    addInputListener(listener) {
        this.input.addInputListener(listener);
        return this;
    }

    removeInputListener(listener) {
        this.input.removeInputListener(listener);
        return this;
    }
}

class RcdMaterialDropdown extends RcdMaterialField {
    constructor(labelText, options) {
        super(labelText);
        this.select = new RcdSelectElement().init().
            addOptions(options).
            addClass('rcd-material-dropdown-select').
            addClass('rcd-material-field-input');
    }

    init() {
        return super.init().
{'fraction_non_alphanumeric': 0.11548420507509062, 'fraction_numerical': 0.0010357327809425167, 'mean_word_length': 2.19520264681555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '934053', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1063, 'n_words': 195}