myio-js-library 0.1.164 → 0.1.165

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.js CHANGED
@@ -20527,7 +20527,7 @@ function renderModal(container, state, modalId, error) {
20527
20527
  const contentMaxHeight = isMaximized ? "100vh" : "95vh";
20528
20528
  const contentBorderRadius = isMaximized ? "0" : "10px";
20529
20529
  container.innerHTML = `
20530
- <div class="myio-temp-modal-overlay" style="
20530
+ <div class="myio-temp-modal-overlay myio-modal-scope" style="
20531
20531
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
20532
20532
  background: rgba(0, 0, 0, 0.5); z-index: 9998;
20533
20533
  display: flex; justify-content: center; align-items: center;
@@ -20782,6 +20782,22 @@ function renderModal(container, state, modalId, error) {
20782
20782
  background: rgba(255, 255, 255, 0.1) !important;
20783
20783
  color: white !important;
20784
20784
  }
20785
+
20786
+ /* DateRangePicker styles */
20787
+ ${CSS_TOKENS}
20788
+ ${DATERANGEPICKER_STYLES}
20789
+
20790
+ /* Fix DateRangePicker buttons alignment */
20791
+ .myio-modal-scope .daterangepicker .drp-buttons {
20792
+ display: flex;
20793
+ justify-content: flex-end;
20794
+ align-items: center;
20795
+ gap: 8px;
20796
+ }
20797
+ .myio-modal-scope .daterangepicker .drp-buttons .btn {
20798
+ display: inline-block;
20799
+ margin-left: 0;
20800
+ }
20785
20801
  </style>
20786
20802
  `;
20787
20803
  }
@@ -23896,18 +23912,11 @@ function getWidgetStyles(theme, primaryColor) {
23896
23912
 
23897
23913
  .myio-chart-widget-title {
23898
23914
  margin: 0;
23899
- font-size: 16px;
23915
+ font-size: 14px;
23900
23916
  font-weight: 600;
23901
23917
  color: ${colors.text};
23902
23918
  }
23903
23919
 
23904
- .myio-chart-widget-controls {
23905
- display: flex;
23906
- align-items: center;
23907
- gap: 12px;
23908
- flex-wrap: wrap;
23909
- }
23910
-
23911
23920
  .myio-chart-widget-tabs {
23912
23921
  display: flex;
23913
23922
  gap: 2px;
@@ -23927,6 +23936,20 @@ function getWidgetStyles(theme, primaryColor) {
23927
23936
  border-radius: 6px;
23928
23937
  transition: all 0.2s;
23929
23938
  white-space: nowrap;
23939
+ display: flex;
23940
+ align-items: center;
23941
+ justify-content: center;
23942
+ gap: 4px;
23943
+ }
23944
+
23945
+ .myio-chart-widget-tab.icon-only {
23946
+ padding: 6px 10px;
23947
+ }
23948
+
23949
+ .myio-chart-widget-tab svg {
23950
+ width: 16px;
23951
+ height: 16px;
23952
+ pointer-events: none;
23930
23953
  }
23931
23954
 
23932
23955
  .myio-chart-widget-tab:hover {
@@ -24060,7 +24083,7 @@ function getWidgetStyles(theme, primaryColor) {
24060
24083
  background: ${colors.chartBackground};
24061
24084
  border-radius: 10px;
24062
24085
  width: 90%;
24063
- max-width: 600px;
24086
+ max-width: 860px;
24064
24087
  max-height: 90vh;
24065
24088
  display: flex;
24066
24089
  flex-direction: column;
@@ -24077,7 +24100,7 @@ function getWidgetStyles(theme, primaryColor) {
24077
24100
  overflow-y: auto;
24078
24101
  display: flex;
24079
24102
  flex-direction: column;
24080
- gap: 20px;
24103
+ gap: 12px;
24081
24104
  }
24082
24105
 
24083
24106
  .myio-settings-section {
@@ -24120,10 +24143,10 @@ function getWidgetStyles(theme, primaryColor) {
24120
24143
 
24121
24144
  .myio-settings-input,
24122
24145
  .myio-settings-select {
24123
- padding: 10px 14px;
24146
+ padding: 8px 12px;
24124
24147
  border: 1px solid ${colors.border};
24125
24148
  border-radius: 8px;
24126
- font-size: 14px;
24149
+ font-size: 12px;
24127
24150
  background: ${colors.chartBackground};
24128
24151
  color: ${colors.text};
24129
24152
  width: 100%;
@@ -24155,6 +24178,10 @@ function getWidgetStyles(theme, primaryColor) {
24155
24178
  border-radius: 6px;
24156
24179
  transition: all 0.2s;
24157
24180
  white-space: nowrap;
24181
+ display: flex;
24182
+ align-items: center;
24183
+ justify-content: center;
24184
+ gap: 6px;
24158
24185
  }
24159
24186
 
24160
24187
  .myio-settings-tab:hover {
@@ -24212,13 +24239,17 @@ function getWidgetStyles(theme, primaryColor) {
24212
24239
  }
24213
24240
 
24214
24241
  .myio-settings-context-group {
24215
- margin-bottom: 8px;
24242
+ margin-bottom: 12px;
24216
24243
  }
24217
24244
 
24218
24245
  .myio-settings-context-group:last-child {
24219
24246
  margin-bottom: 0;
24220
24247
  }
24221
24248
 
24249
+ .myio-settings-section + .myio-settings-section {
24250
+ margin-top: 12px;
24251
+ }
24252
+
24222
24253
  /* Dropdown styles */
24223
24254
  .myio-settings-dropdown-container {
24224
24255
  position: relative;
@@ -24322,6 +24353,23 @@ function getWidgetStyles(theme, primaryColor) {
24322
24353
  opacity: 1 !important;
24323
24354
  transform: scale(1.2);
24324
24355
  }
24356
+
24357
+ /* DateRangePicker styles (CSS tokens + premium styling) */
24358
+ ${CSS_TOKENS}
24359
+ ${DATERANGEPICKER_STYLES}
24360
+
24361
+ /* Fix DateRangePicker buttons alignment */
24362
+ .myio-modal-scope .daterangepicker .drp-buttons {
24363
+ display: flex;
24364
+ justify-content: flex-end;
24365
+ align-items: center;
24366
+ gap: 8px;
24367
+ }
24368
+
24369
+ .myio-modal-scope .daterangepicker .drp-buttons .btn {
24370
+ display: inline-block;
24371
+ margin-left: 0;
24372
+ }
24325
24373
  `;
24326
24374
  }
24327
24375
  function createConsumptionChartWidget(config) {
@@ -24331,6 +24379,7 @@ function createConsumptionChartWidget(config) {
24331
24379
  let styleElement = null;
24332
24380
  let settingsModalElement = null;
24333
24381
  let settingsHeaderInstance = null;
24382
+ let dateRangePickerInstance = null;
24334
24383
  let currentTheme = config.theme ?? "light";
24335
24384
  let currentChartType = config.defaultChartType ?? "line";
24336
24385
  let currentVizMode = config.defaultVizMode ?? "total";
@@ -24342,6 +24391,8 @@ function createConsumptionChartWidget(config) {
24342
24391
  let tempVizMode = currentVizMode;
24343
24392
  let tempTheme = currentTheme;
24344
24393
  let tempIdealRange = currentIdealRange;
24394
+ let tempStartDate = null;
24395
+ let tempEndDate = null;
24345
24396
  let currentSuggestion = null;
24346
24397
  const domainCfg = DOMAIN_CONFIG4[config.domain] || DOMAIN_CONFIG4.energy;
24347
24398
  const primaryColor = config.colors?.primary || domainCfg.color;
@@ -24357,6 +24408,10 @@ function createConsumptionChartWidget(config) {
24357
24408
  return `${domainName} dos \xFAltimos ${currentPeriod} dias`;
24358
24409
  }
24359
24410
  function renderHTML() {
24411
+ const consolidadoIcon = `<svg viewBox="0 0 16 16" fill="currentColor"><rect x="3" y="3" width="10" height="10" rx="2"/></svg>`;
24412
+ const porShoppingIcon = `<svg viewBox="0 0 16 16" fill="currentColor"><rect x="1" y="1" width="6" height="6" rx="1"/><rect x="9" y="1" width="6" height="6" rx="1"/><rect x="1" y="9" width="6" height="6" rx="1"/><rect x="9" y="9" width="6" height="6" rx="1"/></svg>`;
24413
+ const lineChartIcon = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="2,12 5,7 9,9 14,3"/></svg>`;
24414
+ const barChartIcon = `<svg viewBox="0 0 16 16" fill="currentColor"><rect x="1" y="9" width="3" height="6" rx="0.5"/><rect x="6" y="5" width="3" height="10" rx="0.5"/><rect x="11" y="7" width="3" height="8" rx="0.5"/></svg>`;
24360
24415
  return `
24361
24416
  <div id="${widgetId}" class="myio-chart-widget ${currentTheme === "dark" ? "dark" : ""} ${config.className || ""}">
24362
24417
  <div class="myio-chart-widget-header">
@@ -24365,18 +24420,16 @@ function createConsumptionChartWidget(config) {
24365
24420
  <button id="${widgetId}-settings-btn" class="myio-chart-widget-btn" title="Configura\xE7\xF5es">\u2699\uFE0F</button>
24366
24421
  ` : ""}
24367
24422
  <h4 id="${widgetId}-title" class="myio-chart-widget-title">${getTitle()}</h4>
24368
- </div>
24369
- <div class="myio-chart-widget-controls">
24370
24423
  ${showVizModeTabs ? `
24371
24424
  <div class="myio-chart-widget-tabs" id="${widgetId}-viz-tabs">
24372
- <button class="myio-chart-widget-tab ${currentVizMode === "total" ? "active" : ""}" data-viz="total">Consolidado</button>
24373
- <button class="myio-chart-widget-tab ${currentVizMode === "separate" ? "active" : ""}" data-viz="separate">Por Shopping</button>
24425
+ <button class="myio-chart-widget-tab icon-only ${currentVizMode === "total" ? "active" : ""}" data-viz="total" title="Consolidado">${consolidadoIcon}</button>
24426
+ <button class="myio-chart-widget-tab icon-only ${currentVizMode === "separate" ? "active" : ""}" data-viz="separate" title="Por Shopping">${porShoppingIcon}</button>
24374
24427
  </div>
24375
24428
  ` : ""}
24376
24429
  ${showChartTypeTabs ? `
24377
24430
  <div class="myio-chart-widget-tabs" id="${widgetId}-type-tabs">
24378
- <button class="myio-chart-widget-tab ${currentChartType === "line" ? "active" : ""}" data-type="line">Linhas</button>
24379
- <button class="myio-chart-widget-tab ${currentChartType === "bar" ? "active" : ""}" data-type="bar">Barras</button>
24431
+ <button class="myio-chart-widget-tab icon-only ${currentChartType === "line" ? "active" : ""}" data-type="line" title="Gr\xE1fico de Linhas">${lineChartIcon}</button>
24432
+ <button class="myio-chart-widget-tab icon-only ${currentChartType === "bar" ? "active" : ""}" data-type="bar" title="Gr\xE1fico de Barras">${barChartIcon}</button>
24380
24433
  </div>
24381
24434
  ` : ""}
24382
24435
  ${showMaximizeButton ? `
@@ -24413,19 +24466,22 @@ function createConsumptionChartWidget(config) {
24413
24466
  function renderSettingsModal() {
24414
24467
  const unit = config.unit ?? "";
24415
24468
  const isTemperature = config.domain === "temperature";
24469
+ const consolidadoIcon = `<svg viewBox="0 0 16 16" fill="currentColor" style="width:14px;height:14px;pointer-events:none"><rect x="3" y="3" width="10" height="10" rx="2"/></svg>`;
24470
+ const porShoppingIcon = `<svg viewBox="0 0 16 16" fill="currentColor" style="width:14px;height:14px;pointer-events:none"><rect x="1" y="1" width="6" height="6" rx="1"/><rect x="9" y="1" width="6" height="6" rx="1"/><rect x="1" y="9" width="6" height="6" rx="1"/><rect x="9" y="9" width="6" height="6" rx="1"/></svg>`;
24471
+ const lineChartIcon = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:14px;height:14px;pointer-events:none"><polyline points="2,12 5,7 9,9 14,3"/></svg>`;
24472
+ const barChartIcon = `<svg viewBox="0 0 16 16" fill="currentColor" style="width:14px;height:14px;pointer-events:none"><rect x="1" y="9" width="3" height="6" rx="0.5"/><rect x="6" y="5" width="3" height="10" rx="0.5"/><rect x="11" y="7" width="3" height="8" rx="0.5"/></svg>`;
24416
24473
  settingsHeaderInstance = createModalHeader({
24417
24474
  id: `${widgetId}-settings`,
24418
24475
  title: "Configura\xE7\xF5es",
24419
24476
  icon: "\u2699\uFE0F",
24420
24477
  theme: tempTheme,
24421
- backgroundColor: primaryColor,
24422
24478
  showThemeToggle: false,
24423
24479
  showMaximize: false,
24424
24480
  showClose: true,
24425
24481
  onClose: () => closeSettingsModal()
24426
24482
  });
24427
24483
  return `
24428
- <div id="${widgetId}-settings-overlay" class="myio-settings-overlay hidden">
24484
+ <div id="${widgetId}-settings-overlay" class="myio-settings-overlay myio-modal-scope hidden">
24429
24485
  <div class="myio-settings-card">
24430
24486
  ${settingsHeaderInstance.render()}
24431
24487
  <div class="myio-settings-body">
@@ -24436,13 +24492,8 @@ function createConsumptionChartWidget(config) {
24436
24492
  <div class="myio-settings-section-label">\u{1F4C5} Per\xEDodo</div>
24437
24493
  <div class="myio-settings-row">
24438
24494
  <div class="myio-settings-field" style="flex: 1;">
24439
- <select id="${widgetId}-settings-period" class="myio-settings-select">
24440
- <option value="7" ${tempPeriod === 7 ? "selected" : ""}>\xDAltimos 7 dias</option>
24441
- <option value="14" ${tempPeriod === 14 ? "selected" : ""}>\xDAltimos 14 dias</option>
24442
- <option value="30" ${tempPeriod === 30 ? "selected" : ""}>\xDAltimos 30 dias</option>
24443
- <option value="60" ${tempPeriod === 60 ? "selected" : ""}>\xDAltimos 60 dias</option>
24444
- <option value="90" ${tempPeriod === 90 ? "selected" : ""}>\xDAltimos 90 dias</option>
24445
- </select>
24495
+ <input type="text" id="${widgetId}-settings-daterange" class="myio-settings-input"
24496
+ readonly placeholder="Selecione o per\xEDodo..." style="cursor: pointer;">
24446
24497
  </div>
24447
24498
  </div>
24448
24499
  </div>
@@ -24571,8 +24622,8 @@ function createConsumptionChartWidget(config) {
24571
24622
  <div class="myio-settings-field" style="flex: 1; min-width: 180px;">
24572
24623
  <label class="myio-settings-field-label">Tipo de Gr\xE1fico</label>
24573
24624
  <div class="myio-settings-tabs" id="${widgetId}-settings-chart-type">
24574
- <button class="myio-settings-tab ${tempChartType === "line" ? "active" : ""}" data-type="line">\u{1F4C8} Linhas</button>
24575
- <button class="myio-settings-tab ${tempChartType === "bar" ? "active" : ""}" data-type="bar">\u{1F4CA} Barras</button>
24625
+ <button class="myio-settings-tab ${tempChartType === "line" ? "active" : ""}" data-type="line">${lineChartIcon} Linhas</button>
24626
+ <button class="myio-settings-tab ${tempChartType === "bar" ? "active" : ""}" data-type="bar">${barChartIcon} Barras</button>
24576
24627
  </div>
24577
24628
  </div>
24578
24629
 
@@ -24580,8 +24631,8 @@ function createConsumptionChartWidget(config) {
24580
24631
  <div class="myio-settings-field" style="flex: 1; min-width: 200px;">
24581
24632
  <label class="myio-settings-field-label">Agrupamento</label>
24582
24633
  <div class="myio-settings-tabs" id="${widgetId}-settings-viz-mode">
24583
- <button class="myio-settings-tab ${tempVizMode === "total" ? "active" : ""}" data-viz="total">\u{1F517} Consolidado</button>
24584
- <button class="myio-settings-tab ${tempVizMode === "separate" ? "active" : ""}" data-viz="separate">\u{1F3EC} Por Shopping</button>
24634
+ <button class="myio-settings-tab ${tempVizMode === "total" ? "active" : ""}" data-viz="total">${consolidadoIcon} Consolidado</button>
24635
+ <button class="myio-settings-tab ${tempVizMode === "separate" ? "active" : ""}" data-viz="separate">${porShoppingIcon} Por Shopping</button>
24585
24636
  </div>
24586
24637
  </div>
24587
24638
 
@@ -24723,18 +24774,21 @@ function createConsumptionChartWidget(config) {
24723
24774
  peakDateEl.textContent = peakDate;
24724
24775
  }
24725
24776
  }
24726
- function openSettingsModal() {
24777
+ async function openSettingsModal() {
24727
24778
  tempPeriod = currentPeriod;
24728
24779
  tempChartType = currentChartType;
24729
24780
  tempVizMode = currentVizMode;
24730
24781
  tempTheme = currentTheme;
24731
24782
  tempIdealRange = currentIdealRange ? { ...currentIdealRange } : null;
24783
+ dateRangePickerInstance = null;
24732
24784
  if (!settingsModalElement) {
24733
24785
  settingsModalElement = document.createElement("div");
24734
24786
  settingsModalElement.innerHTML = renderSettingsModal();
24735
24787
  document.body.appendChild(settingsModalElement.firstElementChild);
24736
24788
  settingsModalElement = document.getElementById(`${widgetId}-settings-overlay`);
24737
- setupSettingsModalListeners();
24789
+ await setupSettingsModalListeners();
24790
+ } else {
24791
+ await setupSettingsModalListeners();
24738
24792
  }
24739
24793
  updateSettingsModalValues();
24740
24794
  updateIdealRangeSuggestionTooltip();
@@ -24742,6 +24796,10 @@ function createConsumptionChartWidget(config) {
24742
24796
  }
24743
24797
  function closeSettingsModal() {
24744
24798
  settingsModalElement?.classList.add("hidden");
24799
+ if (dateRangePickerInstance) {
24800
+ dateRangePickerInstance.destroy();
24801
+ dateRangePickerInstance = null;
24802
+ }
24745
24803
  }
24746
24804
  function updateSettingsModalValues() {
24747
24805
  const periodSelect = document.getElementById(`${widgetId}-settings-period`);
@@ -24851,8 +24909,46 @@ function createConsumptionChartWidget(config) {
24851
24909
  label: "Faixa Sugerida"
24852
24910
  };
24853
24911
  }
24854
- function setupSettingsModalListeners() {
24912
+ async function setupSettingsModalListeners() {
24855
24913
  settingsHeaderInstance?.attachListeners();
24914
+ const dateRangeInput = document.getElementById(`${widgetId}-settings-daterange`);
24915
+ if (dateRangeInput && !dateRangePickerInstance) {
24916
+ try {
24917
+ const endDate = /* @__PURE__ */ new Date();
24918
+ const startDate = /* @__PURE__ */ new Date();
24919
+ startDate.setDate(endDate.getDate() - tempPeriod);
24920
+ const presetStart = tempStartDate || startDate.toISOString();
24921
+ const presetEnd = tempEndDate || endDate.toISOString();
24922
+ dateRangePickerInstance = await createDateRangePicker2(dateRangeInput, {
24923
+ presetStart,
24924
+ presetEnd,
24925
+ includeTime: true,
24926
+ timePrecision: "hour",
24927
+ maxRangeDays: 90,
24928
+ locale: "pt-BR",
24929
+ parentEl: document.getElementById(`${widgetId}-settings-overlay`),
24930
+ onApply: (result) => {
24931
+ tempStartDate = result.startISO;
24932
+ tempEndDate = result.endISO;
24933
+ const start = new Date(result.startISO);
24934
+ const end = new Date(result.endISO);
24935
+ const diffTime = Math.abs(end.getTime() - start.getTime());
24936
+ const diffHours = diffTime / (1e3 * 60 * 60);
24937
+ const diffDays = Math.ceil(diffTime / (1e3 * 60 * 60 * 24));
24938
+ tempPeriod = diffDays || 7;
24939
+ const granularitySelect = document.getElementById(`${widgetId}-settings-granularity`);
24940
+ if (granularitySelect && diffHours <= 48) {
24941
+ granularitySelect.value = "1h";
24942
+ const dayPeriodField = document.getElementById(`${widgetId}-settings-dayperiod-field`);
24943
+ if (dayPeriodField) dayPeriodField.style.display = "block";
24944
+ }
24945
+ console.log("[ConsumptionChartWidget] Date range applied:", { start: result.startISO, end: result.endISO, hours: diffHours, days: tempPeriod });
24946
+ }
24947
+ });
24948
+ } catch (error) {
24949
+ console.warn("[ConsumptionChartWidget] DateRangePicker initialization failed:", error);
24950
+ }
24951
+ }
24856
24952
  document.getElementById(`${widgetId}-settings-overlay`)?.addEventListener("click", (e) => {
24857
24953
  if (e.target.classList.contains("myio-settings-overlay")) {
24858
24954
  closeSettingsModal();
@@ -24940,13 +25036,56 @@ function createConsumptionChartWidget(config) {
24940
25036
  updateSettingsModalTabs();
24941
25037
  }
24942
25038
  });
24943
- document.getElementById(`${widgetId}-settings-reset`)?.addEventListener("click", () => {
25039
+ document.getElementById(`${widgetId}-settings-reset`)?.addEventListener("click", async () => {
24944
25040
  tempPeriod = config.defaultPeriod ?? 7;
24945
25041
  tempChartType = config.defaultChartType ?? "line";
24946
25042
  tempVizMode = config.defaultVizMode ?? "total";
24947
25043
  tempTheme = config.theme ?? "light";
24948
25044
  tempIdealRange = config.idealRange ?? null;
24949
- const granularitySelect = document.getElementById(`${widgetId}-settings-granularity`);
25045
+ tempStartDate = null;
25046
+ tempEndDate = null;
25047
+ if (dateRangePickerInstance) {
25048
+ dateRangePickerInstance.destroy();
25049
+ dateRangePickerInstance = null;
25050
+ }
25051
+ const dateRangeInput2 = document.getElementById(`${widgetId}-settings-daterange`);
25052
+ if (dateRangeInput2) {
25053
+ const endDate = /* @__PURE__ */ new Date();
25054
+ const startDate = /* @__PURE__ */ new Date();
25055
+ startDate.setDate(endDate.getDate() - tempPeriod);
25056
+ try {
25057
+ dateRangePickerInstance = await createDateRangePicker2(dateRangeInput2, {
25058
+ presetStart: startDate.toISOString(),
25059
+ presetEnd: endDate.toISOString(),
25060
+ includeTime: true,
25061
+ timePrecision: "hour",
25062
+ maxRangeDays: 90,
25063
+ locale: "pt-BR",
25064
+ parentEl: document.getElementById(`${widgetId}-settings-overlay`),
25065
+ onApply: (result) => {
25066
+ tempStartDate = result.startISO;
25067
+ tempEndDate = result.endISO;
25068
+ const start = new Date(result.startISO);
25069
+ const end = new Date(result.endISO);
25070
+ const diffTime = Math.abs(end.getTime() - start.getTime());
25071
+ const diffHours = diffTime / (1e3 * 60 * 60);
25072
+ const diffDays = Math.ceil(diffTime / (1e3 * 60 * 60 * 24));
25073
+ tempPeriod = diffDays || 7;
25074
+ const granularitySelect2 = document.getElementById(`${widgetId}-settings-granularity`);
25075
+ if (granularitySelect2 && diffHours <= 48) {
25076
+ granularitySelect2.value = "1h";
25077
+ const dayPeriodField2 = document.getElementById(`${widgetId}-settings-dayperiod-field`);
25078
+ if (dayPeriodField2) dayPeriodField2.style.display = "block";
25079
+ }
25080
+ }
25081
+ });
25082
+ } catch (error) {
25083
+ console.warn("[ConsumptionChartWidget] DateRangePicker reset failed:", error);
25084
+ }
25085
+ }
25086
+ const granularitySelect = document.getElementById(
25087
+ `${widgetId}-settings-granularity`
25088
+ );
24950
25089
  if (granularitySelect) granularitySelect.value = "1d";
24951
25090
  const dayPeriodField = document.getElementById(`${widgetId}-settings-dayperiod-field`);
24952
25091
  if (dayPeriodField) dayPeriodField.style.display = "none";
@@ -25092,6 +25231,10 @@ function createConsumptionChartWidget(config) {
25092
25231
  }
25093
25232
  settingsHeaderInstance?.destroy();
25094
25233
  settingsHeaderInstance = null;
25234
+ if (dateRangePickerInstance) {
25235
+ dateRangePickerInstance.destroy();
25236
+ dateRangePickerInstance = null;
25237
+ }
25095
25238
  if (settingsModalElement) {
25096
25239
  settingsModalElement.remove();
25097
25240
  settingsModalElement = null;