@kipk/ha-better-history 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -49,25 +49,32 @@ All properties are camelCase in JS and kebab-case as HTML attributes (for boolea
49
49
 
50
50
  ### Top-level attributes (HTML)
51
51
 
52
- | Attribute | Type | Default | Description |
53
- | -------------------- | --------- | ----------- | --------------------------------------------------------------- |
54
- | `hours` | `number` | `24` | Time range in hours before `endDate` |
55
- | `show-date-picker` | `boolean` | `false` | Show `ha-date-range-picker` above the chart |
56
- | `show-entity-picker` | `boolean` | `false` | Show entity picker + attribute browser |
57
- | `show-import-button` | `boolean` | `false` | Show a JSON import button in the tools panel |
58
- | `show-legend` | `boolean` | `true` | Legend below the chart |
59
- | `show-tooltip` | `boolean` | `true` | Multi-series tooltip on hover |
60
- | `width` | `string` | `"100%"` | CSS width of the component wrapper |
61
- | `height` | `string` | | CSS height; if omitted, computed from graph count |
62
- | `line-mode` | `string` | `"stair"` | Global numeric display mode: `"stair"`, `"line"`, or `"column"` |
63
- | `line-width` | `string` | `"2.5"` | Global SVG stroke width for numeric lines |
64
- | `background-color` | `string` | transparent | CSS background color for the component wrapper |
65
- | `graph-title` | `string` | | Optional title above the chart |
66
- | `title-font-family` | `string` | HA theme | Optional title font-family override |
67
- | `title-font-size` | `string` | HA theme | Optional title font-size override |
68
- | `title-color` | `string` | HA theme | Optional title color override |
69
- | `language` | `string` | HA locale | Language code for labels (`"en"`, `"fr"`, …) |
70
- | `tools-open` | `boolean` | `false` | Open/close the viewer tools panel from outside |
52
+ | Attribute | Type | Default | Description |
53
+ | -------------------------- | --------- | ----------- | --------------------------------------------------------------- |
54
+ | `hours` | `number` | `24` | Time range in hours before `endDate` |
55
+ | `show-date-picker` | `boolean` | `false` | Show `ha-date-range-picker` above the chart |
56
+ | `show-entity-picker` | `boolean` | `false` | Show entity picker + attribute browser |
57
+ | `show-import-button` | `boolean` | `false` | Show a JSON import button in the tools panel |
58
+ | `show-export-button` | `boolean` | `true` | Show the JSON export button in the tools panel |
59
+ | `show-time-range-selector` | `boolean` | `true` | Show the no-refetch range zoom control in the tools panel |
60
+ | `show-line-mode-buttons` | `boolean` | `true` | Show stair/line/column mode buttons in the tools panel |
61
+ | `show-legend` | `boolean` | `true` | Legend below the chart |
62
+ | `show-tooltip` | `boolean` | `true` | Multi-series tooltip on hover |
63
+ | `show-grid` | `boolean` | `true` | Show graph grid lines |
64
+ | `show-scale` | `boolean` | `true` | Show axis spines, ticks, and X/Y labels |
65
+ | `show-controls` | `boolean` | `true` | Show the date/entity picker controls bar when enabled |
66
+ | `width` | `string` | `"100%"` | CSS width of the component wrapper |
67
+ | `height` | `string` | | CSS height; if omitted, computed from graph count |
68
+ | `line-mode` | `string` | `"stair"` | Global numeric display mode: `"stair"`, `"line"`, or `"column"` |
69
+ | `line-width` | `string` | `"2.5"` | Global stroke width for numeric lines |
70
+ | `background-color` | `string` | transparent | CSS background color for the component wrapper |
71
+ | `graph-title` | `string` | — | Optional title above the chart |
72
+ | `title-font-family` | `string` | HA theme | Optional title font-family override |
73
+ | `title-font-size` | `string` | HA theme | Optional title font-size override |
74
+ | `title-color` | `string` | HA theme | Optional title color override |
75
+ | `language` | `string` | HA locale | Language code for labels (`"en"`, `"fr"`, …) |
76
+ | `debug-performance` | `boolean` | `false` | Enable verbose performance logs for profiling |
77
+ | `tools-open` | `boolean` | `false` | Open/close the viewer tools panel from outside |
71
78
 
72
79
  ### JS-only properties
73
80
 
@@ -97,8 +104,13 @@ interface BetterHistoryConfig {
97
104
  showDatePicker?: boolean; // default: false
98
105
  showEntityPicker?: boolean; // default: false
99
106
  showImportButton?: boolean; // default: false
107
+ showExportButton?: boolean; // default: true
108
+ showTimeRangeSelector?: boolean; // default: true
109
+ showLineModeButtons?: boolean; // default: true
100
110
  showLegend?: boolean; // default: true
101
111
  showTooltip?: boolean; // default: true
112
+ showGrid?: boolean; // default: true
113
+ showScale?: boolean; // default: true
102
114
  width?: string; // default: "100%"
103
115
  height?: string;
104
116
  lineMode?: "stair" | "line" | "column"; // default: "stair"
@@ -113,6 +125,7 @@ interface BetterHistoryConfig {
113
125
  series?: SeriesConfig[]; // explicit series list
114
126
  defaultEntities?: string[]; // shown in entity picker when enabled
115
127
  disableClimateOverlay?: boolean; // default: false
128
+ debugPerformance?: boolean; // default: false; verbose perf logs
116
129
 
117
130
  // Attribute units
118
131
  attributeUnits?: AttributeUnitMap; // map attribute dot-paths to display units
@@ -311,9 +324,9 @@ The entity picker lets users browse entity attributes and add/remove series at r
311
324
 
312
325
  The viewer toolbar appears above the graph when `tools-open` is `true`. It includes:
313
326
 
314
- - a time range selector that zooms inside the already loaded history range without refetching data;
315
- - a display mode switch for stair, line, and column rendering;
316
- - a JSON export button;
327
+ - a time range selector that zooms inside the already loaded history range without refetching data, unless `show-time-range-selector` or `config.showTimeRangeSelector` is `false`;
328
+ - a display mode switch for stair, line, and column rendering, unless `show-line-mode-buttons` or `config.showLineModeButtons` is `false`;
329
+ - a JSON export button, unless `show-export-button` or `config.showExportButton` is `false`;
317
330
  - an optional JSON import button when `show-import-button` or `config.showImportButton` is `true`.
318
331
 
319
332
  Drag the highlighted range selection to pan the zoomed graph through the loaded period while keeping the same visible duration. A minimum drag target stays available even when the visible range is tiny, and the minimum zoom span adapts to the loaded range.
@@ -12,6 +12,8 @@ export interface ResolveConfigOpts {
12
12
  showEntityPicker?: boolean;
13
13
  showLegend?: boolean;
14
14
  showTooltip?: boolean;
15
+ showGrid?: boolean;
16
+ showScale?: boolean;
15
17
  width?: string;
16
18
  height?: string;
17
19
  lineMode?: BetterHistoryLineMode;
@@ -798,8 +798,13 @@ var fe = e`
798
798
  }
799
799
 
800
800
  .chart-surface {
801
+ box-sizing: border-box;
802
+ display: flex;
803
+ flex-direction: column;
804
+ justify-content: center;
801
805
  position: relative;
802
806
  overflow-y: auto;
807
+ padding-block: 16px;
803
808
  flex: 1;
804
809
  min-height: 0;
805
810
  }
@@ -852,7 +857,7 @@ var fe = e`
852
857
 
853
858
  .line {
854
859
  fill: none;
855
- stroke-width: 2.5;
860
+ stroke-width: var(--better-history-line-width, 2.5);
856
861
  stroke-linecap: round;
857
862
  stroke-linejoin: round;
858
863
  vector-effect: non-scaling-stroke;
@@ -923,10 +928,11 @@ var fe = e`
923
928
  display: flex;
924
929
  flex-wrap: wrap;
925
930
  gap: 6px;
926
- margin-top: 6px;
931
+ margin: 6px calc(40 / 720 * 100%) 0;
927
932
  padding: 0 6px 8px 6px;
928
933
  font-size: 12px;
929
934
  color: var(--better-history-muted-color, var(--secondary-text-color, #888));
935
+ box-sizing: border-box;
930
936
  }
931
937
 
932
938
  .legend-item {
@@ -1030,8 +1036,8 @@ var fe = e`
1030
1036
  flex-wrap: wrap;
1031
1037
  align-items: center;
1032
1038
  gap: 8px;
1033
- margin-bottom: 8px;
1034
- width: 100%;
1039
+ margin: 0 calc(40 / 720 * 100%) 8px;
1040
+ box-sizing: border-box;
1035
1041
  }
1036
1042
 
1037
1043
  .tool-icon-button,
@@ -1062,30 +1068,32 @@ var fe = e`
1062
1068
 
1063
1069
  .tools-panel {
1064
1070
  display: block;
1065
- margin-bottom: 8px;
1071
+ margin: 0 calc(40 / 720 * 100%) 8px;
1066
1072
  padding: 7px 8px;
1067
1073
  border: 1px solid var(--better-history-border-color, var(--divider-color, #444));
1068
1074
  border-radius: var(--better-history-radius, 8px);
1069
1075
  background: color-mix(in srgb, var(--better-history-bg, var(--card-background-color, #1e1e2e)) 96%, var(--primary-text-color, #fff) 4%);
1076
+ box-sizing: border-box;
1070
1077
  }
1071
1078
 
1072
1079
  .tool-range {
1073
1080
  min-width: 0;
1074
1081
  }
1075
1082
 
1076
- .tool-range-head,
1083
+ .tool-range-row,
1077
1084
  .tool-actions,
1078
1085
  .range-values {
1079
1086
  display: flex;
1080
1087
  align-items: center;
1081
1088
  }
1082
1089
 
1083
- .tool-range-head {
1084
- display: grid;
1085
- grid-template-columns: minmax(0, 1fr) auto auto;
1086
- align-items: center;
1090
+ .tool-range-row {
1087
1091
  gap: 8px;
1088
- margin-bottom: 4px;
1092
+ }
1093
+
1094
+ .tool-range-control {
1095
+ flex: 1 1 auto;
1096
+ min-width: 120px;
1089
1097
  }
1090
1098
 
1091
1099
  .tool-label {
@@ -1179,22 +1187,21 @@ var fe = e`
1179
1187
 
1180
1188
  .range-selection-hit {
1181
1189
  position: absolute;
1182
- top: 50%;
1183
- width: max(36px, 8%);
1184
- height: 22px;
1190
+ left: 2px;
1191
+ right: 2px;
1192
+ top: 0;
1193
+ bottom: 0;
1194
+ min-width: 18px;
1185
1195
  border-radius: 999px;
1186
- background: color-mix(in srgb, var(--better-history-info-color, var(--info-color, var(--primary-color, #03a9f4))) 8%, transparent);
1196
+ background: transparent;
1187
1197
  cursor: grab;
1188
1198
  pointer-events: auto;
1189
1199
  touch-action: none;
1190
- transform: translate(-50%, -50%);
1191
1200
  z-index: 1;
1192
1201
  }
1193
1202
 
1194
1203
  .range-selection-hit::before {
1195
- left: 12px;
1196
- right: 12px;
1197
- opacity: 0.42;
1204
+ display: none;
1198
1205
  }
1199
1206
 
1200
1207
  .range-selection-hit[dragging] {
@@ -1277,6 +1284,7 @@ var fe = e`
1277
1284
  height: 30px;
1278
1285
  border: 0;
1279
1286
  border-right: 1px solid var(--better-history-border-color, var(--divider-color, #444));
1287
+ transition: background-color 120ms ease;
1280
1288
  }
1281
1289
 
1282
1290
  .mode-button:last-child {
@@ -1290,6 +1298,16 @@ var fe = e`
1290
1298
  border-radius: var(--better-history-radius, 8px);
1291
1299
  color: var(--better-history-text-color, var(--primary-text-color, #fff));
1292
1300
  font-size: 12px;
1301
+ transition: background-color 120ms ease;
1302
+ }
1303
+
1304
+ .mode-button:hover,
1305
+ .tool-action-button:not(:disabled):hover {
1306
+ background: color-mix(in srgb, var(--primary-color, #03a9f4) 12%, transparent);
1307
+ }
1308
+
1309
+ .tool-reset-button {
1310
+ flex: 0 0 auto;
1293
1311
  }
1294
1312
 
1295
1313
  .tool-action-button:disabled {
@@ -1301,12 +1319,20 @@ var fe = e`
1301
1319
  }
1302
1320
 
1303
1321
  @container (max-width: 360px) {
1304
- .tool-range-head {
1305
- grid-template-columns: minmax(0, 1fr) auto;
1322
+ .tool-range-row {
1323
+ flex-wrap: wrap;
1324
+ }
1325
+
1326
+ .tool-range-control {
1327
+ flex: 1 1 0;
1328
+ min-width: 0;
1329
+ }
1330
+
1331
+ .tool-actions {
1332
+ flex: 1 1 100%;
1306
1333
  }
1307
1334
 
1308
1335
  .tool-actions {
1309
- grid-column: 1 / -1;
1310
1336
  justify-content: flex-end;
1311
1337
  }
1312
1338
  }
@@ -1350,8 +1376,7 @@ var fe = e`
1350
1376
  }
1351
1377
 
1352
1378
  .range-selection-hit {
1353
- width: max(44px, 12%);
1354
- height: 30px;
1379
+ min-width: 24px;
1355
1380
  }
1356
1381
 
1357
1382
  .range-slider::-webkit-slider-thumb {
package/dist/define.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./ha-better-history-Bf_QcE8w.js";
1
+ import { t as e } from "./ha-better-history-PA3nPDOW.js";
2
2
  //#region src/define.ts
3
3
  customElements.get("ha-better-history") || customElements.define("ha-better-history", e);
4
4
  //#endregion