META-INF.resources.frontend.vaadin-big-decimal-field.js Maven / Gradle / Ivy
/*
* 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);
});
})();