2025-06-16 13:18:13 +00:00
|
|
|
import { DeesElement, customElement, html, css, property, type TemplateResult } from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
@customElement('dees-demowrapper')
|
|
|
|
export class DeesDemoWrapper extends DeesElement {
|
|
|
|
@property({ attribute: false })
|
2025-06-16 14:35:28 +00:00
|
|
|
public runAfterRender: (children: HTMLCollection) => void | Promise<void>;
|
2025-06-16 13:18:13 +00:00
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
css`
|
|
|
|
:host {
|
|
|
|
display: contents;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
];
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<slot></slot>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async firstUpdated() {
|
|
|
|
await this.updateComplete;
|
|
|
|
|
|
|
|
// Wait a bit for slotted content to render
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 50));
|
|
|
|
|
2025-06-16 14:35:28 +00:00
|
|
|
// Get all slotted elements
|
2025-06-16 13:18:13 +00:00
|
|
|
const slottedElements = this.children;
|
|
|
|
if (slottedElements.length > 0 && this.runAfterRender) {
|
2025-06-16 14:35:28 +00:00
|
|
|
// Call the runAfterRender function with all slotted elements
|
2025-06-16 13:18:13 +00:00
|
|
|
try {
|
2025-06-16 14:35:28 +00:00
|
|
|
await this.runAfterRender(slottedElements);
|
2025-06-16 13:18:13 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.error('Error in runAfterRender:', error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|