@universal-material/web
Version:
Material web components
59 lines • 1.67 kB
JavaScript
import { __decorate } from "tslib";
import { property } from 'lit/decorators.js';
import { UmTextFieldBase } from '../text-field-base/text-field-base.js';
export class UmNativeTextFieldWrapper extends UmTextFieldBase {
constructor() {
super(...arguments);
this._value = '';
this.role = null;
}
get value() {
return this._value;
}
set value(value) {
this._value = value;
this.empty = !value;
this.elementInternals.setFormValue(value);
this.#updateCounter();
}
#maxlength;
get maxlength() {
return this.#maxlength;
}
set maxlength(value) {
this.#maxlength = value;
this.#updateCounter();
}
focus() {
this.input.focus();
}
_handleKeyDown(e) {
if (e.key === 'Enter') {
this.elementInternals.form?.requestSubmit();
}
}
_handleInput() {
this.value = this.input.value;
this.#updateCounter();
}
#updateCounter() {
if (this.maxlength) {
this._innerCounter = `${this.value.length}/${this.maxlength}`;
return;
}
this._innerCounter = undefined;
}
}
__decorate([
property()
], UmNativeTextFieldWrapper.prototype, "value", null);
__decorate([
property({ reflect: true })
], UmNativeTextFieldWrapper.prototype, "autocomplete", void 0);
__decorate([
property({ type: Number, reflect: true })
], UmNativeTextFieldWrapper.prototype, "maxlength", null);
__decorate([
property({ reflect: true })
], UmNativeTextFieldWrapper.prototype, "role", void 0);
//# sourceMappingURL=native-text-field-wrapper.js.map