/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { BASE_FIELD_CONSTANTS } from './base-field-constants';
export class BaseFieldFoundation {
    get _hasValue() {
        return this._adapter.hasValue;
    }
    get _hasPlaceholder() {
        return this._adapter.hasPlaceholder;
    }
    constructor(_adapter) {
        this._adapter = _adapter;
        this._labelPosition = BASE_FIELD_CONSTANTS.defaults.DEFAULT_LABEL_POSITION;
        this._labelAlignment = BASE_FIELD_CONSTANTS.defaults.DEFAULT_LABEL_ALIGNMENT;
        this._invalid = false;
        this._required = false;
        this._optional = false;
        this._disabled = false;
        this._variant = BASE_FIELD_CONSTANTS.defaults.DEFAULT_VARIANT;
        this._theme = BASE_FIELD_CONSTANTS.defaults.DEFAULT_THEME;
        this._shape = BASE_FIELD_CONSTANTS.defaults.DEFAULT_SHAPE;
        this._density = BASE_FIELD_CONSTANTS.defaults.DEFAULT_DENSITY;
        this._dense = false;
        this._popoverIcon = false;
        this._supportTextInset = BASE_FIELD_CONSTANTS.defaults.DEFAULT_SUPPORT_TEXT_INSET;
        this._permanentlyFloatLabel = false;
    }
    click() {
        this._adapter.click();
    }
    applyLabel(value) {
        this._adapter.applyLabel(value);
    }
    floatLabelWithoutAnimation(value) {
        this._adapter.floatLabelWithoutAnimation(this._hasValue || this._hasPlaceholder || value);
    }
    _tryFloatLabel(force) {
        if (this._permanentlyFloatLabel) {
            return;
        }
        if (this._labelPosition !== 'inset') {
            this._adapter.tryFloatLabel(false);
            return;
        }
        this._adapter.tryFloatLabel(force);
    }
    get labelPosition() {
        return this._labelPosition;
    }
    set labelPosition(value) {
        if (this._labelPosition !== value) {
            this._labelPosition = value;
            this._adapter.setFieldProperty('labelPosition', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.LABEL_POSITION, value);
        }
    }
    get labelAlignment() {
        return this._labelAlignment;
    }
    set labelAlignment(value) {
        if (this._labelAlignment !== value) {
            this._labelAlignment = value;
            this._adapter.setFieldProperty('labelAlignment', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.LABEL_ALIGNMENT, value);
        }
    }
    get invalid() {
        return this._invalid;
    }
    set invalid(value) {
        if (this._invalid !== value) {
            this._invalid = value;
            this._adapter.setFieldProperty('invalid', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.INVALID, value);
        }
    }
    get required() {
        return this._required;
    }
    set required(value) {
        if (this._required !== value) {
            this._required = value;
            this._adapter.setFieldProperty('required', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.REQUIRED, value);
        }
    }
    get optional() {
        return this._optional;
    }
    set optional(value) {
        if (this._optional !== value) {
            this._optional = value;
            this._adapter.setFieldProperty('optional', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.OPTIONAL, value);
        }
    }
    get disabled() {
        return this._disabled;
    }
    set disabled(value) {
        if (this._disabled !== value) {
            this._disabled = value;
            this._adapter.setFieldProperty('disabled', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.DISABLED, value);
        }
    }
    get permanentlyFloatLabel() {
        return this._permanentlyFloatLabel;
    }
    set permanentlyFloatLabel(value) {
        if (this._permanentlyFloatLabel !== value) {
            this._permanentlyFloatLabel = value;
            this._adapter.setFieldProperty('floatLabel', value || this._hasValue || this._hasPlaceholder);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.FLOAT_LABEL, value);
        }
    }
    get variant() {
        return this._variant;
    }
    set variant(value) {
        if (this._variant !== value) {
            this._variant = value;
            this._adapter.setFieldProperty('variant', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.VARIANT, value);
        }
    }
    get theme() {
        return this._theme;
    }
    set theme(value) {
        if (this._theme !== value) {
            this._theme = value;
            this._adapter.setFieldProperty('theme', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.THEME, value);
        }
    }
    get shape() {
        return this._shape;
    }
    set shape(value) {
        if (this._shape !== value) {
            this._shape = value;
            this._adapter.setFieldProperty('shape', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.SHAPE, value);
        }
    }
    get density() {
        return this._density;
    }
    set density(value) {
        if (this._density !== value) {
            this._density = value;
            this._adapter.setFieldProperty('density', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.DENSITY, value);
        }
    }
    get dense() {
        return this._dense;
    }
    set dense(value) {
        if (this._dense !== value) {
            this._dense = value;
            this._adapter.setFieldProperty('dense', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.DENSE, value);
        }
    }
    get popoverIcon() {
        return this._popoverIcon;
    }
    set popoverIcon(value) {
        if (this._popoverIcon !== value) {
            this._popoverIcon = value;
            this._adapter.setFieldProperty('popoverIcon', value);
            this._adapter.toggleHostAttribute(BASE_FIELD_CONSTANTS.attributes.POPOVER_ICON, value);
        }
    }
    get supportTextInset() {
        return this._supportTextInset;
    }
    set supportTextInset(value) {
        if (this._supportTextInset !== value) {
            this._supportTextInset = value;
            this._adapter.setFieldProperty('supportTextInset', value);
            this._adapter.setHostAttribute(BASE_FIELD_CONSTANTS.attributes.SUPPORT_TEXT_INSET, value);
        }
    }
}
