All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.flow.component.textfield.HasAutocapitalize Maven / Gradle / Ivy

There is a newer version: 24.4.12
Show newest version
/**
 * Copyright 2000-2024 Vaadin Ltd.
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  {@literal }  for the full
 * license.
 */
package com.vaadin.flow.component.textfield;

import com.vaadin.flow.component.HasElement;

/**
 * Mixin interface for fields with {@code autocapitalize} attribute.
 */
public interface HasAutocapitalize extends HasElement {

    /**
     * Name of @{code autocapitalize} attribute.
     */
    String AUTOCAPITALIZE_ATTRIBUTE = "autocapitalize";

    /**
     * Sets the {@link Autocapitalize} attribute for indicating whether the
     * value of this component can be automatically completed by the browser.
     * 

* If not set, devices may apply their own default. *

* Note: * This attribute doesn't affect behavior when typing on a physical * keyboard. Instead, it affects the behavior of other input mechanisms, * such as virtual keyboards on mobile devices and voice input. It is only * supported by Chrome and Safari. * * @param autocapitalize * the {@code autocapitalize} value, or {@code null} to unset */ default void setAutocapitalize(Autocapitalize autocapitalize) { if (autocapitalize == null) { getElement().removeAttribute(AUTOCAPITALIZE_ATTRIBUTE); } else { getElement().setAttribute(AUTOCAPITALIZE_ATTRIBUTE, autocapitalize.value); } } /** * Gets the {@link Autocapitalize} for indicating whether the value of this * component can be automatically completed by the browser. * * @return the {@code autocapitalize} value, or {@code null} if not set */ default Autocapitalize getAutocapitalize() { String autocapitalize = getElement() .getAttribute(AUTOCAPITALIZE_ATTRIBUTE); if (autocapitalize == null) { // Not set, may inherit behavior from parent form. return null; } else if ("".equals(autocapitalize)) { // Default behavior for empty attribute. return Autocapitalize.SENTENCES; } else { return Autocapitalize.valueOf(autocapitalize.toUpperCase()); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy