Class InputMask
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<InputMask,,String>, String> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<InputMask,,String>, String> Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionInputMask(String mask, boolean evalMask, InputMaskOption... options) Creates anInputMaskwith the given mask and IMask options.InputMask(String mask, InputMaskOption... options) -
Method Summary
Modifier and TypeMethodDescriptionvoidextend(com.vaadin.flow.component.Component component) voidgetMaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer) voidgetUnmaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer) booleanbooleanvoidremove()voidsetAllowWhitespace(boolean allowWhitespace) Allows whitespace characters to be entered into the field from the keyboard or pasted from the clipboard.voidsetErrorMessage(String errorMessage) voidsetInvalid(boolean invalid) voidReplaces the active mask while keeping every other option (such asoverwriteorlazy) and the current binding to the host component.voidReplaces the active mask, optionally evaluating it as a JavaScript expression.voidsetMask(String mask, boolean evalMask, InputMaskOption... options) Replaces the active mask and the auxiliary IMask options.protected voidsetPresentationValue(String newPresentationValue) Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
Constructor Details
-
InputMask
-
InputMask
Creates anInputMaskwith the given mask and IMask options.Security warning: when
evalMaskistrue, themaskstring is passed to JavaScripteval()on the client. Only pass developer-authored, trusted mask strings ? never values coming from end-user input or any other untrusted source ? or arbitrary JavaScript will run in the browser.- Parameters:
mask- the mask pattern.evalMask-trueto evaluate the mask as a JavaScript expression (e.g. for regex masks like"/^\\d+$/"or built-ins like"Number"). This value MUST NOT come from untrusted input.options- additional IMask options.
-
-
Method Details
-
setMask
Replaces the active mask while keeping every other option (such asoverwriteorlazy) and the current binding to the host component. Safe to call before or afterextend(Component); when the wrapper has already been extended onto a component, the new mask is pushed to the client and applied in place without recreating the<input-mask>element.- Parameters:
mask- the new mask pattern, in the same format accepted byInputMask(String, InputMaskOption...).
-
setMask
Replaces the active mask, optionally evaluating it as a JavaScript expression. The auxiliary options passed to the constructor are kept.Security warning: when
evalMaskistrue, themaskstring is passed to JavaScripteval()on the client. Only pass developer-authored, trusted mask strings ? never values coming from end-user input or any other untrusted source ? or arbitrary JavaScript will run in the browser.- Parameters:
mask- the new mask pattern.evalMask-trueto evaluate the mask string as a JavaScript expression on the client (e.g. for regex masks like"/^\\d+$/"or built-ins like"Number"),falseto send it as a plain string. This value MUST NOT come from untrusted input.- See Also:
-
setMask
Replaces the active mask and the auxiliary IMask options. The previous auxiliary options (e.g.overwrite,lazy) are discarded; only the supplied ones are applied alongside the new mask.Security warning: when
evalMaskistrue, themaskstring is passed to JavaScripteval()on the client. Only pass developer-authored, trusted mask strings ? never values coming from end-user input or any other untrusted source ? or arbitrary JavaScript will run in the browser.- Parameters:
mask- the new mask pattern.evalMask-trueto evaluate the mask as a JavaScript expression on the client. This value MUST NOT come from untrusted input.options- replacement auxiliary options.- See Also:
-
extend
public void extend(com.vaadin.flow.component.Component component) -
remove
public void remove() -
getUnmaskedValue
-
getMaskedValue
-
setAllowWhitespace
public void setAllowWhitespace(boolean allowWhitespace) Allows whitespace characters to be entered into the field from the keyboard or pasted from the clipboard.When set to
false(the default), the wrapper intercepts the space bar in two situations: pressing space when the caret is at position 0 is cancelled, and pressing space while the whole value is selected clears the field. When set totrue, the wrapper does not intercept space, and IMask decides whether the character is accepted based on the configured mask.- Parameters:
allowWhitespace-trueto allow whitespace input,falseto keep the default behaviour.
-
isAllowWhitespace
public boolean isAllowWhitespace()- Returns:
trueif whitespace input is currently allowed.- See Also:
-
setErrorMessage
- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
getErrorMessage
- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
setInvalid
public void setInvalid(boolean invalid) - Specified by:
setInvalidin interfacecom.vaadin.flow.component.HasValidation
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation
-
setPresentationValue
-