feat(services): introduce DeesServiceLibLoader to lazy-load heavy client libraries from CDN and update components to use it
This commit is contained in:
@@ -11,7 +11,8 @@ import { demoFunc } from './demo.js';
|
||||
import { chartAreaStyles } from './styles.js';
|
||||
import { renderChartArea } from './template.js';
|
||||
|
||||
import ApexCharts from 'apexcharts';
|
||||
import type ApexCharts from 'apexcharts';
|
||||
import { DeesServiceLibLoader } from '../../../services/index.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@@ -150,7 +151,10 @@ export class DeesChartArea extends DeesElement {
|
||||
|
||||
public async firstUpdated() {
|
||||
await this.domtoolsPromise;
|
||||
|
||||
|
||||
// Load ApexCharts from CDN
|
||||
const ApexChartsLib = await DeesServiceLibLoader.getInstance().loadApexCharts();
|
||||
|
||||
// Wait for next animation frame to ensure layout is complete
|
||||
await new Promise(resolve => requestAnimationFrame(resolve));
|
||||
|
||||
@@ -353,7 +357,7 @@ export class DeesChartArea extends DeesElement {
|
||||
};
|
||||
|
||||
try {
|
||||
this.chart = new ApexCharts(this.shadowRoot.querySelector('.chartContainer'), options);
|
||||
this.chart = new ApexChartsLib(this.shadowRoot.querySelector('.chartContainer'), options);
|
||||
await this.chart.render();
|
||||
|
||||
// Give the chart a moment to fully initialize before resizing
|
||||
|
||||
Reference in New Issue
Block a user