myio-js-library 0.1.167 → 0.1.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +23 -18
- package/dist/index.d.cts +5 -0
- package/dist/index.js +23 -18
- package/dist/myio-js-library.umd.js +26 -22
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23559,9 +23559,15 @@ function createConsumption7DaysChart(config) {
|
|
|
23559
23559
|
const canvas = validateCanvas();
|
|
23560
23560
|
if (!canvas) return;
|
|
23561
23561
|
try {
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
|
|
23562
|
+
if (config.initialData) {
|
|
23563
|
+
log("log", "Using initial data (instant display)");
|
|
23564
|
+
cachedData = config.initialData;
|
|
23565
|
+
cachedData.fetchTimestamp = cachedData.fetchTimestamp || Date.now();
|
|
23566
|
+
} else {
|
|
23567
|
+
log("log", `Fetching ${currentPeriod} days of data...`);
|
|
23568
|
+
cachedData = await config.fetchData(currentPeriod);
|
|
23569
|
+
cachedData.fetchTimestamp = Date.now();
|
|
23570
|
+
}
|
|
23565
23571
|
if (config.onBeforeRender) {
|
|
23566
23572
|
cachedData = config.onBeforeRender(cachedData);
|
|
23567
23573
|
}
|
|
@@ -23731,7 +23737,7 @@ function createConsumptionModal(config) {
|
|
|
23731
23737
|
let currentTheme = config.theme ?? "light";
|
|
23732
23738
|
let currentChartType = config.defaultChartType ?? "line";
|
|
23733
23739
|
let currentVizMode = config.defaultVizMode ?? "total";
|
|
23734
|
-
|
|
23740
|
+
const isMaximized = true;
|
|
23735
23741
|
const domainCfg = DOMAIN_CONFIG3[config.domain] || { name: config.domain, icon: "\u{1F4CA}" };
|
|
23736
23742
|
const title = config.title || `${domainCfg.name} - Hist\xF3rico de Consumo`;
|
|
23737
23743
|
function getThemeColors3() {
|
|
@@ -23750,7 +23756,10 @@ function createConsumptionModal(config) {
|
|
|
23750
23756
|
title,
|
|
23751
23757
|
icon: domainCfg.icon,
|
|
23752
23758
|
theme: currentTheme,
|
|
23753
|
-
isMaximized,
|
|
23759
|
+
isMaximized: true,
|
|
23760
|
+
// Modal is always fullscreen
|
|
23761
|
+
showMaximize: false,
|
|
23762
|
+
// Hide maximize button - modal is already fullscreen
|
|
23754
23763
|
exportFormats,
|
|
23755
23764
|
onExport: (format) => {
|
|
23756
23765
|
if (config.onExport) {
|
|
@@ -23768,10 +23777,6 @@ function createConsumptionModal(config) {
|
|
|
23768
23777
|
chartInstance?.setTheme(currentTheme);
|
|
23769
23778
|
updateModal();
|
|
23770
23779
|
},
|
|
23771
|
-
onMaximize: (maximized) => {
|
|
23772
|
-
isMaximized = maximized;
|
|
23773
|
-
updateModal();
|
|
23774
|
-
},
|
|
23775
23780
|
onClose: () => {
|
|
23776
23781
|
instance.close();
|
|
23777
23782
|
}
|
|
@@ -23979,7 +23984,7 @@ function createConsumptionModal(config) {
|
|
|
23979
23984
|
typeBarBtn.style.color = currentChartType === "bar" ? "white" : colors.text;
|
|
23980
23985
|
}
|
|
23981
23986
|
}
|
|
23982
|
-
function updateModal() {
|
|
23987
|
+
async function updateModal() {
|
|
23983
23988
|
if (!modalElement) return;
|
|
23984
23989
|
const cachedData = chartInstance?.getCachedData();
|
|
23985
23990
|
headerInstance?.destroy();
|
|
@@ -23992,9 +23997,11 @@ function createConsumptionModal(config) {
|
|
|
23992
23997
|
containerId: `${modalId}-chart`,
|
|
23993
23998
|
theme: currentTheme,
|
|
23994
23999
|
defaultChartType: currentChartType,
|
|
23995
|
-
defaultVizMode: currentVizMode
|
|
24000
|
+
defaultVizMode: currentVizMode,
|
|
24001
|
+
initialData: cachedData
|
|
24002
|
+
// RFC-0098: Use initialData for instant re-render
|
|
23996
24003
|
});
|
|
23997
|
-
chartInstance.
|
|
24004
|
+
await chartInstance.render();
|
|
23998
24005
|
}
|
|
23999
24006
|
}
|
|
24000
24007
|
const instance = {
|
|
@@ -24010,13 +24017,11 @@ function createConsumptionModal(config) {
|
|
|
24010
24017
|
containerId: `${modalId}-chart`,
|
|
24011
24018
|
theme: currentTheme,
|
|
24012
24019
|
defaultChartType: currentChartType,
|
|
24013
|
-
defaultVizMode: currentVizMode
|
|
24020
|
+
defaultVizMode: currentVizMode,
|
|
24021
|
+
// RFC-0098: Pass initialData to chart config for instant display
|
|
24022
|
+
initialData: config.initialData
|
|
24014
24023
|
});
|
|
24015
|
-
|
|
24016
|
-
chartInstance.update(config.initialData);
|
|
24017
|
-
} else {
|
|
24018
|
-
await chartInstance.render();
|
|
24019
|
-
}
|
|
24024
|
+
await chartInstance.render();
|
|
24020
24025
|
},
|
|
24021
24026
|
close() {
|
|
24022
24027
|
if (modalElement) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2574,6 +2574,11 @@ interface Consumption7DaysConfig {
|
|
|
2574
2574
|
* @returns Promise resolving to consumption data
|
|
2575
2575
|
*/
|
|
2576
2576
|
fetchData: (period: number) => Promise<Consumption7DaysData>;
|
|
2577
|
+
/**
|
|
2578
|
+
* Initial data to display (skips fetch if provided)
|
|
2579
|
+
* Useful for modal/fullscreen views that reuse cached data
|
|
2580
|
+
*/
|
|
2581
|
+
initialData?: Consumption7DaysData;
|
|
2577
2582
|
/** Large unit for values above threshold (MWh, etc.) - null to disable */
|
|
2578
2583
|
unitLarge?: string | null;
|
|
2579
2584
|
/** Threshold value to switch to large unit (1000 for kWh->MWh) */
|
package/dist/index.js
CHANGED
|
@@ -23418,9 +23418,15 @@ function createConsumption7DaysChart(config) {
|
|
|
23418
23418
|
const canvas = validateCanvas();
|
|
23419
23419
|
if (!canvas) return;
|
|
23420
23420
|
try {
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23421
|
+
if (config.initialData) {
|
|
23422
|
+
log("log", "Using initial data (instant display)");
|
|
23423
|
+
cachedData = config.initialData;
|
|
23424
|
+
cachedData.fetchTimestamp = cachedData.fetchTimestamp || Date.now();
|
|
23425
|
+
} else {
|
|
23426
|
+
log("log", `Fetching ${currentPeriod} days of data...`);
|
|
23427
|
+
cachedData = await config.fetchData(currentPeriod);
|
|
23428
|
+
cachedData.fetchTimestamp = Date.now();
|
|
23429
|
+
}
|
|
23424
23430
|
if (config.onBeforeRender) {
|
|
23425
23431
|
cachedData = config.onBeforeRender(cachedData);
|
|
23426
23432
|
}
|
|
@@ -23590,7 +23596,7 @@ function createConsumptionModal(config) {
|
|
|
23590
23596
|
let currentTheme = config.theme ?? "light";
|
|
23591
23597
|
let currentChartType = config.defaultChartType ?? "line";
|
|
23592
23598
|
let currentVizMode = config.defaultVizMode ?? "total";
|
|
23593
|
-
|
|
23599
|
+
const isMaximized = true;
|
|
23594
23600
|
const domainCfg = DOMAIN_CONFIG3[config.domain] || { name: config.domain, icon: "\u{1F4CA}" };
|
|
23595
23601
|
const title = config.title || `${domainCfg.name} - Hist\xF3rico de Consumo`;
|
|
23596
23602
|
function getThemeColors3() {
|
|
@@ -23609,7 +23615,10 @@ function createConsumptionModal(config) {
|
|
|
23609
23615
|
title,
|
|
23610
23616
|
icon: domainCfg.icon,
|
|
23611
23617
|
theme: currentTheme,
|
|
23612
|
-
isMaximized,
|
|
23618
|
+
isMaximized: true,
|
|
23619
|
+
// Modal is always fullscreen
|
|
23620
|
+
showMaximize: false,
|
|
23621
|
+
// Hide maximize button - modal is already fullscreen
|
|
23613
23622
|
exportFormats,
|
|
23614
23623
|
onExport: (format) => {
|
|
23615
23624
|
if (config.onExport) {
|
|
@@ -23627,10 +23636,6 @@ function createConsumptionModal(config) {
|
|
|
23627
23636
|
chartInstance?.setTheme(currentTheme);
|
|
23628
23637
|
updateModal();
|
|
23629
23638
|
},
|
|
23630
|
-
onMaximize: (maximized) => {
|
|
23631
|
-
isMaximized = maximized;
|
|
23632
|
-
updateModal();
|
|
23633
|
-
},
|
|
23634
23639
|
onClose: () => {
|
|
23635
23640
|
instance.close();
|
|
23636
23641
|
}
|
|
@@ -23838,7 +23843,7 @@ function createConsumptionModal(config) {
|
|
|
23838
23843
|
typeBarBtn.style.color = currentChartType === "bar" ? "white" : colors.text;
|
|
23839
23844
|
}
|
|
23840
23845
|
}
|
|
23841
|
-
function updateModal() {
|
|
23846
|
+
async function updateModal() {
|
|
23842
23847
|
if (!modalElement) return;
|
|
23843
23848
|
const cachedData = chartInstance?.getCachedData();
|
|
23844
23849
|
headerInstance?.destroy();
|
|
@@ -23851,9 +23856,11 @@ function createConsumptionModal(config) {
|
|
|
23851
23856
|
containerId: `${modalId}-chart`,
|
|
23852
23857
|
theme: currentTheme,
|
|
23853
23858
|
defaultChartType: currentChartType,
|
|
23854
|
-
defaultVizMode: currentVizMode
|
|
23859
|
+
defaultVizMode: currentVizMode,
|
|
23860
|
+
initialData: cachedData
|
|
23861
|
+
// RFC-0098: Use initialData for instant re-render
|
|
23855
23862
|
});
|
|
23856
|
-
chartInstance.
|
|
23863
|
+
await chartInstance.render();
|
|
23857
23864
|
}
|
|
23858
23865
|
}
|
|
23859
23866
|
const instance = {
|
|
@@ -23869,13 +23876,11 @@ function createConsumptionModal(config) {
|
|
|
23869
23876
|
containerId: `${modalId}-chart`,
|
|
23870
23877
|
theme: currentTheme,
|
|
23871
23878
|
defaultChartType: currentChartType,
|
|
23872
|
-
defaultVizMode: currentVizMode
|
|
23879
|
+
defaultVizMode: currentVizMode,
|
|
23880
|
+
// RFC-0098: Pass initialData to chart config for instant display
|
|
23881
|
+
initialData: config.initialData
|
|
23873
23882
|
});
|
|
23874
|
-
|
|
23875
|
-
chartInstance.update(config.initialData);
|
|
23876
|
-
} else {
|
|
23877
|
-
await chartInstance.render();
|
|
23878
|
-
}
|
|
23883
|
+
await chartInstance.render();
|
|
23879
23884
|
},
|
|
23880
23885
|
close() {
|
|
23881
23886
|
if (modalElement) {
|
|
@@ -23236,9 +23236,15 @@ ${rangeText}`;
|
|
|
23236
23236
|
const canvas = validateCanvas();
|
|
23237
23237
|
if (!canvas) return;
|
|
23238
23238
|
try {
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23239
|
+
if (config.initialData) {
|
|
23240
|
+
log("log", "Using initial data (instant display)");
|
|
23241
|
+
cachedData = config.initialData;
|
|
23242
|
+
cachedData.fetchTimestamp = cachedData.fetchTimestamp || Date.now();
|
|
23243
|
+
} else {
|
|
23244
|
+
log("log", `Fetching ${currentPeriod} days of data...`);
|
|
23245
|
+
cachedData = await config.fetchData(currentPeriod);
|
|
23246
|
+
cachedData.fetchTimestamp = Date.now();
|
|
23247
|
+
}
|
|
23242
23248
|
if (config.onBeforeRender) {
|
|
23243
23249
|
cachedData = config.onBeforeRender(cachedData);
|
|
23244
23250
|
}
|
|
@@ -23408,7 +23414,6 @@ ${rangeText}`;
|
|
|
23408
23414
|
let currentTheme = config.theme ?? "light";
|
|
23409
23415
|
let currentChartType = config.defaultChartType ?? "line";
|
|
23410
23416
|
let currentVizMode = config.defaultVizMode ?? "total";
|
|
23411
|
-
let isMaximized = false;
|
|
23412
23417
|
const domainCfg = DOMAIN_CONFIG3[config.domain] || { name: config.domain, icon: "\u{1F4CA}" };
|
|
23413
23418
|
const title = config.title || `${domainCfg.name} - Hist\xF3rico de Consumo`;
|
|
23414
23419
|
function getThemeColors3() {
|
|
@@ -23427,7 +23432,10 @@ ${rangeText}`;
|
|
|
23427
23432
|
title,
|
|
23428
23433
|
icon: domainCfg.icon,
|
|
23429
23434
|
theme: currentTheme,
|
|
23430
|
-
isMaximized,
|
|
23435
|
+
isMaximized: true,
|
|
23436
|
+
// Modal is always fullscreen
|
|
23437
|
+
showMaximize: false,
|
|
23438
|
+
// Hide maximize button - modal is already fullscreen
|
|
23431
23439
|
exportFormats,
|
|
23432
23440
|
onExport: (format) => {
|
|
23433
23441
|
if (config.onExport) {
|
|
@@ -23445,10 +23453,6 @@ ${rangeText}`;
|
|
|
23445
23453
|
chartInstance?.setTheme(currentTheme);
|
|
23446
23454
|
updateModal();
|
|
23447
23455
|
},
|
|
23448
|
-
onMaximize: (maximized) => {
|
|
23449
|
-
isMaximized = maximized;
|
|
23450
|
-
updateModal();
|
|
23451
|
-
},
|
|
23452
23456
|
onClose: () => {
|
|
23453
23457
|
instance.close();
|
|
23454
23458
|
}
|
|
@@ -23517,10 +23521,10 @@ ${rangeText}`;
|
|
|
23517
23521
|
">
|
|
23518
23522
|
<div class="myio-consumption-modal-content" style="
|
|
23519
23523
|
background: ${colors.chartBackground};
|
|
23520
|
-
border-radius: ${
|
|
23521
|
-
width: ${
|
|
23522
|
-
max-width: ${
|
|
23523
|
-
height: ${
|
|
23524
|
+
border-radius: ${"0" };
|
|
23525
|
+
width: ${"100%" };
|
|
23526
|
+
max-width: ${"100%" };
|
|
23527
|
+
height: ${"100%" };
|
|
23524
23528
|
display: flex;
|
|
23525
23529
|
flex-direction: column;
|
|
23526
23530
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
@@ -23656,7 +23660,7 @@ ${rangeText}`;
|
|
|
23656
23660
|
typeBarBtn.style.color = currentChartType === "bar" ? "white" : colors.text;
|
|
23657
23661
|
}
|
|
23658
23662
|
}
|
|
23659
|
-
function updateModal() {
|
|
23663
|
+
async function updateModal() {
|
|
23660
23664
|
if (!modalElement) return;
|
|
23661
23665
|
const cachedData = chartInstance?.getCachedData();
|
|
23662
23666
|
headerInstance?.destroy();
|
|
@@ -23669,9 +23673,11 @@ ${rangeText}`;
|
|
|
23669
23673
|
containerId: `${modalId}-chart`,
|
|
23670
23674
|
theme: currentTheme,
|
|
23671
23675
|
defaultChartType: currentChartType,
|
|
23672
|
-
defaultVizMode: currentVizMode
|
|
23676
|
+
defaultVizMode: currentVizMode,
|
|
23677
|
+
initialData: cachedData
|
|
23678
|
+
// RFC-0098: Use initialData for instant re-render
|
|
23673
23679
|
});
|
|
23674
|
-
chartInstance.
|
|
23680
|
+
await chartInstance.render();
|
|
23675
23681
|
}
|
|
23676
23682
|
}
|
|
23677
23683
|
const instance = {
|
|
@@ -23687,13 +23693,11 @@ ${rangeText}`;
|
|
|
23687
23693
|
containerId: `${modalId}-chart`,
|
|
23688
23694
|
theme: currentTheme,
|
|
23689
23695
|
defaultChartType: currentChartType,
|
|
23690
|
-
defaultVizMode: currentVizMode
|
|
23696
|
+
defaultVizMode: currentVizMode,
|
|
23697
|
+
// RFC-0098: Pass initialData to chart config for instant display
|
|
23698
|
+
initialData: config.initialData
|
|
23691
23699
|
});
|
|
23692
|
-
|
|
23693
|
-
chartInstance.update(config.initialData);
|
|
23694
|
-
} else {
|
|
23695
|
-
await chartInstance.render();
|
|
23696
|
-
}
|
|
23700
|
+
await chartInstance.render();
|
|
23697
23701
|
},
|
|
23698
23702
|
close() {
|
|
23699
23703
|
if (modalElement) {
|