//Button const smButton = document.createElement('template') smButton.innerHTML = `
`; customElements.define('sm-button', class extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }).append(smButton.content.cloneNode(true)); } static get observedAttributes() { return ['disabled']; } get disabled() { return this.hasAttribute('disabled'); } set disabled(value) { if (value) { this.setAttribute('disabled', ''); } else { this.removeAttribute('disabled'); } } focusIn() { this.focus(); } handleKeyDown(e) { if (!this.hasAttribute('disabled') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); this.click(); } } connectedCallback() { if (!this.hasAttribute('disabled')) { this.setAttribute('tabindex', '0'); } this.setAttribute('role', 'button'); this.addEventListener('keydown', this.handleKeyDown); } attributeChangedCallback(name) { if (name === 'disabled') { if (this.hasAttribute('disabled')) { this.removeAttribute('tabindex'); } else { this.setAttribute('tabindex', '0'); } this.setAttribute('aria-disabled', this.hasAttribute('disabled')); } } })