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:45:19 +00:00
|
|
|
public runAfterRender: (wrapperElement: DeesDemoWrapper) => 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:45:19 +00:00
|
|
|
// Check if there are slotted elements and runAfterRender is defined
|
|
|
|
if (this.children.length > 0 && this.runAfterRender) {
|
|
|
|
// Call the runAfterRender function with the wrapper element itself
|
|
|
|
// Note: querySelector/querySelectorAll will work on slotted content
|
|
|
|
// because slotted elements remain in the light DOM as children
|
2025-06-16 13:18:13 +00:00
|
|
|
try {
|
2025-06-16 14:45:19 +00:00
|
|
|
await this.runAfterRender(this);
|
2025-06-16 13:18:13 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.error('Error in runAfterRender:', error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|