java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<InputMask,String>
com.vaadin.flow.component.AbstractSinglePropertyField<InputMask,String>
com.vaadin.componentfactory.addons.inputmask.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

@Tag("input-mask") @NpmPackage(value="imask", version="7.1.3") @JsModule("./src/input-mask.js") public class InputMask extends com.vaadin.flow.component.AbstractSinglePropertyField<InputMask,String> implements com.vaadin.flow.component.HasValidation
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

    Constructors
    Constructor
    Description
    InputMask(String mask, boolean evalMask, InputMaskOption... options)
    Creates an InputMask with the given mask and IMask options.
    InputMask(String mask, InputMaskOption... options)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    extend(com.vaadin.flow.component.Component component)
     
     
    void
    getMaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer)
     
    void
    getUnmaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer)
     
    boolean
     
    boolean
     
    void
     
    void
    setAllowWhitespace(boolean allowWhitespace)
    Allows whitespace characters to be entered into the field from the keyboard or pasted from the clipboard.
    void
    setErrorMessage(String errorMessage)
     
    void
    setInvalid(boolean invalid)
     
    void
    Replaces the active mask while keeping every other option (such as overwrite or lazy) and the current binding to the host component.
    void
    setMask(String mask, boolean evalMask)
    Replaces the active mask, optionally evaluating it as a JavaScript expression.
    void
    setMask(String mask, boolean evalMask, InputMaskOption... options)
    Replaces the active mask and the auxiliary IMask options.
    protected void
    setPresentationValue(String newPresentationValue)
     

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals

    Methods 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, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.component.HasValue

    clear, getOptionalValue

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
  • Constructor Details

    • InputMask

      public InputMask(String mask, InputMaskOption... options)
    • InputMask

      public InputMask(String mask, boolean evalMask, InputMaskOption... options)
      Creates an InputMask with the given mask and IMask options.

      Security warning: when evalMask is true, the mask string is passed to JavaScript eval() 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 - true to 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

      public void setMask(String mask)
      Replaces the active mask while keeping every other option (such as overwrite or lazy) and the current binding to the host component. Safe to call before or after extend(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 by InputMask(String, InputMaskOption...).
    • setMask

      public void setMask(String mask, boolean evalMask)
      Replaces the active mask, optionally evaluating it as a JavaScript expression. The auxiliary options passed to the constructor are kept.

      Security warning: when evalMask is true, the mask string is passed to JavaScript eval() 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 - true to evaluate the mask string as a JavaScript expression on the client (e.g. for regex masks like "/^\\d+$/" or built-ins like "Number"), false to send it as a plain string. This value MUST NOT come from untrusted input.
      See Also:
    • setMask

      public void setMask(String mask, boolean evalMask, InputMaskOption... options)
      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 evalMask is true, the mask string is passed to JavaScript eval() 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 - true to 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

      public void getUnmaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer)
    • getMaskedValue

      public void getMaskedValue(com.vaadin.flow.function.SerializableConsumer<String> consumer)
    • 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 to true, the wrapper does not intercept space, and IMask decides whether the character is accepted based on the configured mask.

      Parameters:
      allowWhitespace - true to allow whitespace input, false to keep the default behaviour.
    • isAllowWhitespace

      public boolean isAllowWhitespace()
      Returns:
      true if whitespace input is currently allowed.
      See Also:
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.HasValidation
    • getErrorMessage

      public String getErrorMessage()
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.HasValidation
    • setInvalid

      public void setInvalid(boolean invalid)
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface com.vaadin.flow.component.HasValidation
    • setPresentationValue

      protected void setPresentationValue(String newPresentationValue)
      Overrides:
      setPresentationValue in class com.vaadin.flow.component.AbstractSinglePropertyField<InputMask,String>