import { BaseInputElement } from "./index";
import { ElementType } from "../../../constants/UIKitConstants";
/**
 * Represents a text input element.
 */
export class TextInputElement extends BaseInputElement {
    /** The label of the input element. */
    label;
    /** The maximum number of lines for a multi-line text input element. */
    maxLines = 1;
    /** The placeholder text to display in the input element. */
    placeholder = {
        text: "Enter text here..."
    };
    /**
     * The default value in text input.
     */
    defaultValue;
    /**
     * Creates a new instance of the TextInputElement class.
     * @param {string} elementId - The unique identifier of the form element.
     * @param {string} label - The label of the input element.
     */
    constructor(elementId, label) {
        super(elementId, ElementType.text);
        this.label = label || "";
    }
    /**
     * Returns the label of the input element.
     * @returns {string} The label of the input element.
     */
    getLabel() {
        return this.label;
    }
    /**
     * Returns the maximum number of lines for a multi-line text input element.
     * @returns {number} The maximum number of lines for a multi-line text input element.
     */
    getMaxLines() {
        return this.maxLines;
    }
    /**
     * Sets the maximum number of lines for a multi-line text input element.
     * @param {number} maxLines - The maximum number of lines for a multi-line text input element.
     */
    setMaxLines(maxLines) {
        this.maxLines = maxLines;
    }
    /**
     * Returns the placeholder text to display in the input element.
     * @returns {string} The placeholder text to display in the input element.
     */
    getPlaceholder() {
        return this?.placeholder?.text;
    }
    /**
     * Sets the placeholder text to display in the input element.
     * @param {string} placeholder - The placeholder text to display in the input element.
     */
    setPlaceholder(placeholder) {
        this.placeholder = {
            text: placeholder
        };
    }
    /**
     * Returns the default value in text input.
     * @returns {string} The default value in text input.
     */
    getDefaultValue() {
        return this.defaultValue;
    }
    /**
     * Sets the default value in text input.
     * @param {string} defaultValue - The default value in text input.
     * @returns {string} The default value in text input.
     */
    setDefaultValue(defaultValue) {
        this.defaultValue = defaultValue;
    }
    static fromJSON(json) {
        const textInput = new TextInputElement(json.elementId, json.label);
        if (json.maxLines)
            textInput.setMaxLines(json.maxLines);
        if (json.placeholder && json.placeholder.text)
            textInput.setPlaceholder(json.placeholder?.text);
        if (json.defaultValue)
            textInput.setDefaultValue(json.defaultValue);
        return textInput;
    }
}
//# sourceMappingURL=TextInputElement.js.map