- Introduced async demo functionality in the README, allowing for asynchronous data preparation before rendering components. - Updated WccDashboard, WccProperties, and WccSidebar to support Promise-based template factories. - Implemented resolveTemplateFactory to handle both synchronous and asynchronous template results. - Added tests for resolveTemplateFactory to ensure correct behavior for both sync and async templates. - Updated pnpm workspace configuration.
24 lines
690 B
TypeScript
24 lines
690 B
TypeScript
import { WccDashboard } from './elements/wcc-dashboard.js';
|
|
import { LitElement } from 'lit';
|
|
import type { TTemplateFactory } from './elements/wcctools.helpers.js';
|
|
|
|
const setupWccTools = (
|
|
elementsArg?: { [key: string]: LitElement },
|
|
pagesArg?: Record<string, TTemplateFactory>
|
|
) => {
|
|
let hasRun = false;
|
|
const runWccToolsSetup = async () => {
|
|
if (document.readyState === 'complete' && !hasRun) {
|
|
hasRun = true;
|
|
const wccTools = new WccDashboard(elementsArg as any, pagesArg);
|
|
document.querySelector('body').append(wccTools);
|
|
}
|
|
};
|
|
document.addEventListener('readystatechange', runWccToolsSetup);
|
|
runWccToolsSetup();
|
|
};
|
|
|
|
export {
|
|
setupWccTools
|
|
};
|