Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 1x 1x 1x 1x 1x | import CustomElement from "../../custom-element/CustomElement";
import defineCustomElement from "../../custom-element/helpers/defineCustomElement";
import LoadableMixin from "../../custom-element/mixins/data/LoadableMixin";
import html from "../../renderer/html";
import { NodePatchingData } from "../../renderer/NodePatcher";
/**
* Wrapper to allow loading data for a child component
*/
export default class Loader extends
LoadableMixin(
CustomElement
) {
render(): NodePatchingData {
return html`<div style="position: relative;">
${this.renderLoading()}
<slot id="data-holder"></slot>
</div>`;
}
didMountCallback() {
// Bind to the data property of the child (assuming a single child)
this.dataHolder = this.document.getElementById('data-holder')
.assignedElements({ flatten: false })[0]; // Only include elements
super.didMountCallback?.();
}
handleLoadedData(data) {
this.dataHolder.data = data.payload || data;
}
}
defineCustomElement('gcl-loader', Loader); |