mirror of
https://github.com/jlengrand/open-wc.git
synced 2026-03-10 08:31:19 +00:00
40 lines
771 B
JavaScript
40 lines
771 B
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
import { LitElement, html } from 'lit-element';
|
|
|
|
// @ts-ignore
|
|
export class FakeInput extends LitElement {
|
|
static get properties() {
|
|
return {
|
|
focused: { type: Boolean, reflect: true },
|
|
};
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
this.focused = false;
|
|
}
|
|
|
|
_requestUpdate(name, oldValue) {
|
|
// @ts-ignore
|
|
super._requestUpdate(name, oldValue);
|
|
|
|
if (name === 'focused') {
|
|
this.dispatchEvent(new Event('focused-changed'));
|
|
}
|
|
}
|
|
|
|
focusin() {
|
|
this.focused = true;
|
|
}
|
|
|
|
focusout() {
|
|
this.focused = false;
|
|
}
|
|
|
|
render() {
|
|
return html` <input type="text" @focusin=${this.focusin} @focusout=${this.focusout} /> `;
|
|
}
|
|
}
|
|
|
|
customElements.define('fake-input', FakeInput);
|