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

META-INF.resources.frontend.vaadin-big-decimal-field.js Maven / Gradle / Ivy

There is a newer version: 24.4.12
Show newest version
/*
 * Copyright (C) 2024 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See {@literal }  for the full
 * license.
 */
(function() {

  let memoizedTemplate;

  customElements.whenDefined('vaadin-text-field').then(() => {

    class BigDecimalFieldElement extends customElements.get('vaadin-text-field') {

      static get template() {
        if (!memoizedTemplate) {
          memoizedTemplate = super.template.cloneNode(true);
          memoizedTemplate.innerHTML +=
            ``;
        }
        return memoizedTemplate;
      }

      static get is() {
        return 'vaadin-big-decimal-field';
      }

      static get properties() {
        return {
          _decimalSeparator: {
            type: String,
            value: '.',
            observer: '__decimalSeparatorChanged'
          }
        }
      }

      ready() {
        super.ready();
        this.inputElement.setAttribute('inputmode', 'decimal');
      }

      __decimalSeparatorChanged(separator, oldSeparator) {
        this._enabledCharPattern = '[\\d-+' + separator + ']';

        if (this.value && oldSeparator) {
          this.value = this.value.split(oldSeparator).join(separator);
        }
      }

    }

    customElements.define(BigDecimalFieldElement.is, BigDecimalFieldElement);

  });
})();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy