@universal-material/web
Version:
Material web components
46 lines • 1.44 kB
JavaScript
import { __decorate } from "tslib";
import { property } from 'lit/decorators.js';
import { UmButtonWrapper } from '../shared/button-wrapper.js';
import { styles } from './button-base.styles.js';
export class UmButtonBase extends UmButtonWrapper {
static { this.formAssociated = true; }
static { this.styles = [UmButtonWrapper.styles, styles]; }
get form() {
return this.#elementInternals.form;
}
#elementInternals;
constructor() {
super();
this.type = 'submit';
this.value = '';
this.#elementInternals = this.attachInternals();
}
handleClick(_) {
if (this.type === 'button' || !!this.href) {
return;
}
if (!this.form) {
return;
}
this.#elementInternals.setFormValue(this.value);
if (this.type === 'reset') {
this.form.reset();
return;
}
this.form.addEventListener('submit', submitEvent => {
Object.defineProperty(submitEvent, 'submitter', {
configurable: true,
enumerable: true,
get: () => this,
});
}, { capture: true, once: true });
this.form.requestSubmit();
}
}
__decorate([
property()
], UmButtonBase.prototype, "type", void 0);
__decorate([
property({ reflect: true })
], UmButtonBase.prototype, "value", void 0);
//# sourceMappingURL=button-base.js.map