com.vaadin.flow.component.textfield.GeneratedVaadinTextField Maven / Gradle / Ivy
/**
* 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 java.util.stream.Collectors;
import java.util.stream.Stream;
import com.vaadin.flow.component.AbstractSinglePropertyField;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.DomEvent;
import com.vaadin.flow.component.Focusable;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.HasTheme;
import com.vaadin.flow.component.NotSupported;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.NpmPackage;
import com.vaadin.flow.dom.Element;
import com.vaadin.flow.function.SerializableBiFunction;
import com.vaadin.flow.function.SerializableFunction;
import com.vaadin.flow.shared.Registration;
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* {@code } is a Web Component for text field control in
* forms.
*
*
* <vaadin-text-field label="First Name">
* </vaadin-text-field>
*
* Prefixes and suffixes
*
* These are child elements of a {@code } that are displayed
* inline with the input, before or after. In order for an element to be
* considered as a prefix, it must have the slot attribute set to {@code prefix}
* (and similarly for {@code suffix}).
*
*
* <vaadin-text-field label="Email address"> <div
* slot="prefix">Sent to:</div> <div
* slot="suffix">@vaadin.com</div> </vaadin-text-area>
*
* Styling
*
* The following custom properties are available for styling:
*
*
*
*
* Custom property
* Description
* Default
*
*
*
* {@code --vaadin-text-field-default-width}
* Set the default width of the input field
* {@code 12em}
*
*
*
*
* The following shadow DOM parts are available for styling:
*
*
*
*
* Part name
* Description
*
*
*
* {@code label}
* The label element
*
*
* {@code input-field}
* The element that wraps prefix, value and suffix
*
*
* {@code value}
* The text value element inside the {@code input-field} element
*
*
* {@code error-message}
* The error message element
*
*
*
*
* The following state attributes are available for styling:
*
*
*
*
* Attribute
* Description
* Part name
*
*
*
* {@code disabled}
* Set to a disabled text field
* :host
*
*
* {@code has-value}
* Set when the element has a value
* :host
*
*
* {@code has-label}
* Set when the element has a label
* :host
*
*
* {@code invalid}
* Set when the element is invalid
* :host
*
*
* {@code input-prevented}
* Temporarily set when invalid input is prevented
* :host
*
*
* {@code focused}
* Set when the element is focused
* :host
*
*
* {@code focus-ring}
* Set when the element is keyboard focused
* :host
*
*
* {@code readonly}
* Set to a readonly text field
* :host
*
*
*
*
* See
* ThemableMixin
* – how to apply styles for shadow parts
*
*/
@Tag("vaadin-text-field")
@NpmPackage(value = "@vaadin/vaadin-text-field", version = "2.10.0")
@JsModule("@vaadin/vaadin-text-field/src/vaadin-text-field.js")
public abstract class GeneratedVaadinTextField, T>
extends AbstractSinglePropertyField
implements HasStyle, Focusable, HasTheme {
/**
* Adds theme variants to the component.
*
* @param variants
* theme variants to add
*/
public void addThemeVariants(TextFieldVariant... variants) {
getThemeNames().addAll(
Stream.of(variants).map(TextFieldVariant::getVariantName)
.collect(Collectors.toList()));
}
/**
* Removes theme variants from the component.
*
* @param variants
* theme variants to remove
*/
public void removeThemeVariants(TextFieldVariant... variants) {
getThemeNames().removeAll(
Stream.of(variants).map(TextFieldVariant::getVariantName)
.collect(Collectors.toList()));
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specify that this control should have input focus when the page loads.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code autofocus} property from the webcomponent
*/
protected boolean isAutofocusBoolean() {
return getElement().getProperty("autofocus", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specify that this control should have input focus when the page loads.
*
*
* @param autofocus
* the boolean value to set
*/
protected void setAutofocus(boolean autofocus) {
getElement().setProperty("autofocus", autofocus);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* If true, the user cannot interact with this element.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code disabled} property from the webcomponent
*/
protected boolean isDisabledBoolean() {
return getElement().getProperty("disabled", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* If true, the user cannot interact with this element.
*
*
* @param disabled
* the boolean value to set
*/
protected void setDisabled(boolean disabled) {
getElement().setProperty("disabled", disabled);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Whether the value of the control can be automatically completed by the
* browser. List of available options at:
* https://developer.mozilla.org/en/docs
* /Web/HTML/Element/input#attr-autocomplete
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code autocomplete} property from the webcomponent
*/
protected String getAutocompleteString() {
return getElement().getProperty("autocomplete");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Whether the value of the control can be automatically completed by the
* browser. List of available options at:
* https://developer.mozilla.org/en/docs
* /Web/HTML/Element/input#attr-autocomplete
*
*
* @param autocomplete
* the String value to set
*/
protected void setAutocomplete(String autocomplete) {
getElement().setProperty("autocomplete",
autocomplete == null ? "" : autocomplete);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This is a property supported by Safari that is used to control whether
* autocorrection should be enabled when the user is entering/editing the
* text. Possible values are: on: Enable autocorrection. off: Disable
* autocorrection.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code autocorrect} property from the webcomponent
*/
protected String getAutocorrectString() {
return getElement().getProperty("autocorrect");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This is a property supported by Safari that is used to control whether
* autocorrection should be enabled when the user is entering/editing the
* text. Possible values are: on: Enable autocorrection. off: Disable
* autocorrection.
*
*
* @param autocorrect
* the String value to set
*/
protected void setAutocorrect(String autocorrect) {
getElement().setProperty("autocorrect",
autocorrect == null ? "" : autocorrect);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This is a property supported by Safari and Chrome that is used to control
* whether autocapitalization should be enabled when the user is
* entering/editing the text. Possible values are: characters: Characters
* capitalization. words: Words capitalization. sentences: Sentences
* capitalization. none: No capitalization.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code autocapitalize} property from the webcomponent
*/
protected String getAutocapitalizeString() {
return getElement().getProperty("autocapitalize");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This is a property supported by Safari and Chrome that is used to control
* whether autocapitalization should be enabled when the user is
* entering/editing the text. Possible values are: characters: Characters
* capitalization. words: Words capitalization. sentences: Sentences
* capitalization. none: No capitalization.
*
*
* @param autocapitalize
* the String value to set
*/
protected void setAutocapitalize(String autocapitalize) {
getElement().setProperty("autocapitalize",
autocapitalize == null ? "" : autocapitalize);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specify that the value should be automatically selected when the field
* gains focus.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code autoselect} property from the webcomponent
*/
protected boolean isAutoselectBoolean() {
return getElement().getProperty("autoselect", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specify that the value should be automatically selected when the field
* gains focus.
*
*
* @param autoselect
* the boolean value to set
*/
protected void setAutoselect(boolean autoselect) {
getElement().setProperty("autoselect", autoselect);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Set to true to display the clear icon which clears the input.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code clearButtonVisible} property from the webcomponent
*/
protected boolean isClearButtonVisibleBoolean() {
return getElement().getProperty("clearButtonVisible", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Set to true to display the clear icon which clears the input.
*
*
* @param clearButtonVisible
* the boolean value to set
*/
protected void setClearButtonVisible(boolean clearButtonVisible) {
getElement().setProperty("clearButtonVisible", clearButtonVisible);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Error to show when the input value is invalid.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code errorMessage} property from the webcomponent
*/
protected String getErrorMessageString() {
return getElement().getProperty("errorMessage");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Error to show when the input value is invalid.
*
*
* @param errorMessage
* the String value to set
*/
protected void setErrorMessage(String errorMessage) {
getElement().setProperty("errorMessage",
errorMessage == null ? "" : errorMessage);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* String used for the label element.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code label} property from the webcomponent
*/
protected String getLabelString() {
return getElement().getProperty("label");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* String used for the label element.
*
*
* @param label
* the String value to set
*/
protected void setLabel(String label) {
getElement().setProperty("label", label == null ? "" : label);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Maximum number of characters (in Unicode code points) that the user can
* enter.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code maxlength} property from the webcomponent
*/
protected double getMaxlengthDouble() {
return getElement().getProperty("maxlength", 0.0);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Maximum number of characters (in Unicode code points) that the user can
* enter.
*
*
* @param maxlength
* the double value to set
*/
protected void setMaxlength(double maxlength) {
getElement().setProperty("maxlength", maxlength);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Minimum number of characters (in Unicode code points) that the user can
* enter.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code minlength} property from the webcomponent
*/
protected double getMinlengthDouble() {
return getElement().getProperty("minlength", 0.0);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Minimum number of characters (in Unicode code points) that the user can
* enter.
*
*
* @param minlength
* the double value to set
*/
protected void setMinlength(double minlength) {
getElement().setProperty("minlength", minlength);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* The name of the control, which is submitted with the form data.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code name} property from the webcomponent
*/
protected String getNameString() {
return getElement().getProperty("name");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* The name of the control, which is submitted with the form data.
*
*
* @param name
* the String value to set
*/
protected void setName(String name) {
getElement().setProperty("name", name == null ? "" : name);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* A hint to the user of what can be entered in the control.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code placeholder} property from the webcomponent
*/
protected String getPlaceholderString() {
return getElement().getProperty("placeholder");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* A hint to the user of what can be entered in the control.
*
*
* @param placeholder
* the String value to set
*/
protected void setPlaceholder(String placeholder) {
getElement().setProperty("placeholder",
placeholder == null ? "" : placeholder);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This attribute indicates that the user cannot modify the value of the
* control.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code readonly} property from the webcomponent
*/
protected boolean isReadonlyBoolean() {
return getElement().getProperty("readonly", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This attribute indicates that the user cannot modify the value of the
* control.
*
*
* @param readonly
* the boolean value to set
*/
protected void setReadonly(boolean readonly) {
getElement().setProperty("readonly", readonly);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specifies that the user must fill in a value.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code required} property from the webcomponent
*/
protected boolean isRequiredBoolean() {
return getElement().getProperty("required", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specifies that the user must fill in a value.
*
*
* @param required
* the boolean value to set
*/
protected void setRequired(boolean required) {
getElement().setProperty("required", required);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This property is set to true when the control value is invalid.
*
*
* @return the {@code invalid} property from the webcomponent
*/
protected boolean isInvalidBoolean() {
return getElement().getProperty("invalid", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This property is set to true when the control value is invalid.
*
*
* @param invalid
* the boolean value to set
*/
protected void setInvalid(boolean invalid) {
getElement().setProperty("invalid", invalid);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* When set to true, user is prevented from typing a value that conflicts
* with the given {@code pattern}, {@code maxlength} or {@code minlength}
* properties.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code preventInvalidInput} property from the webcomponent
*/
protected boolean isPreventInvalidInputBoolean() {
return getElement().getProperty("preventInvalidInput", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* When set to true, user is prevented from typing a value that conflicts
* with the given {@code pattern}, {@code maxlength} or {@code minlength}
* properties.
*
*
* @param preventInvalidInput
* the boolean value to set
*/
protected void setPreventInvalidInput(boolean preventInvalidInput) {
getElement().setProperty("preventInvalidInput", preventInvalidInput);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Identifies a list of pre-defined options to suggest to the user. The
* value must be the id of a