2020-03-09 21:26:39 +08:00
|
|
|
import Selection from "./lib/selection.js";
|
2020-03-09 05:11:46 +08:00
|
|
|
|
2020-03-09 16:26:10 +08:00
|
|
|
export class HasApp extends HTMLElement {
|
|
|
|
get _app() { return this.closest("cyp-app"); }
|
|
|
|
get _mpd() { return this._app.mpd; }
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class Component extends HasApp {
|
2020-03-09 05:11:46 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
2020-03-09 21:26:39 +08:00
|
|
|
this.selection = new Selection(this);
|
|
|
|
}
|
2020-03-09 05:11:46 +08:00
|
|
|
|
2020-03-09 21:26:39 +08:00
|
|
|
connectedCallback() {
|
2020-03-09 16:26:10 +08:00
|
|
|
this._app.addEventListener("load", _ => this._onAppLoad());
|
|
|
|
this._app.addEventListener("component-change", _ => {
|
|
|
|
const component = this._app.getAttribute("component");
|
|
|
|
const isThis = (this.nodeName.toLowerCase() == `cyp-${component}`);
|
|
|
|
this._onComponentChange(component, isThis);
|
2020-03-09 05:11:46 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-09 16:26:10 +08:00
|
|
|
_onComponentChange(_component, _isThis) {}
|
|
|
|
_onAppLoad() {}
|
2020-03-09 01:06:54 +08:00
|
|
|
}
|