@kipk/ha-better-history 0.1.3 → 0.1.5

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
@@ -32,6 +32,14 @@ If this component helps you, you can support development on
32
32
 
33
33
  ## Quick start
34
34
 
35
+ Install from npm:
36
+
37
+ ```bash
38
+ npm install @kipk/ha-better-history
39
+ ```
40
+
41
+ Package page: [@kipk/ha-better-history on npm](https://www.npmjs.com/package/@kipk/ha-better-history)
42
+
35
43
  ```html
36
44
  <ha-better-history></ha-better-history>
37
45
 
@@ -49,25 +57,32 @@ All properties are camelCase in JS and kebab-case as HTML attributes (for boolea
49
57
 
50
58
  ### Top-level attributes (HTML)
51
59
 
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 |
60
+ | Attribute | Type | Default | Description |
61
+ | -------------------------- | --------- | ----------- | --------------------------------------------------------------- |
62
+ | `hours` | `number` | `24` | Time range in hours before `endDate` |
63
+ | `show-date-picker` | `boolean` | `false` | Show `ha-date-range-picker` above the chart |
64
+ | `show-entity-picker` | `boolean` | `false` | Show entity picker + attribute browser |
65
+ | `show-import-button` | `boolean` | `false` | Show a JSON import button in the tools panel |
66
+ | `show-export-button` | `boolean` | `true` | Show the JSON export button in the tools panel |
67
+ | `show-time-range-selector` | `boolean` | `true` | Show the no-refetch range zoom control in the tools panel |
68
+ | `show-line-mode-buttons` | `boolean` | `true` | Show stair/line/column mode buttons in the tools panel |
69
+ | `show-legend` | `boolean` | `true` | Legend below the chart |
70
+ | `show-tooltip` | `boolean` | `true` | Multi-series tooltip on hover |
71
+ | `show-grid` | `boolean` | `true` | Show graph grid lines |
72
+ | `show-scale` | `boolean` | `true` | Show axis spines, ticks, and X/Y labels |
73
+ | `show-controls` | `boolean` | `true` | Show the date/entity picker controls bar when enabled |
74
+ | `width` | `string` | `"100%"` | CSS width of the component wrapper |
75
+ | `height` | `string` | | CSS height; if omitted, computed from graph count |
76
+ | `line-mode` | `string` | `"stair"` | Global numeric display mode: `"stair"`, `"line"`, or `"column"` |
77
+ | `line-width` | `string` | `"2.5"` | Global stroke width for numeric lines |
78
+ | `background-color` | `string` | transparent | CSS background color for the component wrapper |
79
+ | `graph-title` | `string` | — | Optional title above the chart |
80
+ | `title-font-family` | `string` | HA theme | Optional title font-family override |
81
+ | `title-font-size` | `string` | HA theme | Optional title font-size override |
82
+ | `title-color` | `string` | HA theme | Optional title color override |
83
+ | `language` | `string` | HA locale | Language code for labels (`"en"`, `"fr"`, …) |
84
+ | `debug-performance` | `boolean` | `false` | Enable verbose performance logs for profiling |
85
+ | `tools-open` | `boolean` | `false` | Open/close the viewer tools panel from outside |
71
86
 
72
87
  ### JS-only properties
73
88
 
@@ -97,8 +112,13 @@ interface BetterHistoryConfig {
97
112
  showDatePicker?: boolean; // default: false
98
113
  showEntityPicker?: boolean; // default: false
99
114
  showImportButton?: boolean; // default: false
115
+ showExportButton?: boolean; // default: true
116
+ showTimeRangeSelector?: boolean; // default: true
117
+ showLineModeButtons?: boolean; // default: true
100
118
  showLegend?: boolean; // default: true
101
119
  showTooltip?: boolean; // default: true
120
+ showGrid?: boolean; // default: true
121
+ showScale?: boolean; // default: true
102
122
  width?: string; // default: "100%"
103
123
  height?: string;
104
124
  lineMode?: "stair" | "line" | "column"; // default: "stair"
@@ -113,6 +133,7 @@ interface BetterHistoryConfig {
113
133
  series?: SeriesConfig[]; // explicit series list
114
134
  defaultEntities?: string[]; // shown in entity picker when enabled
115
135
  disableClimateOverlay?: boolean; // default: false
136
+ debugPerformance?: boolean; // default: false; verbose perf logs
116
137
 
117
138
  // Attribute units
118
139
  attributeUnits?: AttributeUnitMap; // map attribute dot-paths to display units
@@ -311,9 +332,9 @@ The entity picker lets users browse entity attributes and add/remove series at r
311
332
 
312
333
  The viewer toolbar appears above the graph when `tools-open` is `true`. It includes:
313
334
 
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;
335
+ - 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`;
336
+ - a display mode switch for stair, line, and column rendering, unless `show-line-mode-buttons` or `config.showLineModeButtons` is `false`;
337
+ - a JSON export button, unless `show-export-button` or `config.showExportButton` is `false`;
317
338
  - an optional JSON import button when `show-import-button` or `config.showImportButton` is `true`.
318
339
 
319
340
  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.
@@ -402,7 +423,7 @@ Releases are created by pushing a version tag that matches `package.json` exactl
402
423
  ```bash
403
424
  npm version 1.0.0 --no-git-tag-version
404
425
  git tag 1.0.0
405
- git push origin maater --tags
426
+ git push origin master --tags
406
427
  ```
407
428
 
408
429
  Accepted tag formats are `1.0.0`, `1.0.0-rc1`, and `1.0.0-beta1`. Stable tags publish to the npm `latest` dist-tag; release candidates publish to `rc`; beta releases publish to `beta`.
@@ -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;
@@ -766,7 +766,7 @@ var fe = e`
766
766
  display: flex;
767
767
  flex-direction: column;
768
768
  container-type: inline-size;
769
- min-height: 360px;
769
+ min-height: var(--better-history-min-height, 360px);
770
770
  font-family: var(--better-history-font-family, inherit);
771
771
  user-select: none;
772
772
  -webkit-user-select: none;
@@ -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
- overflow-y: auto;
806
+ overflow-y: var(--better-history-surface-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-ClqQAeug.js";
2
2
  //#region src/define.ts
3
3
  customElements.get("ha-better-history") || customElements.define("ha-better-history", e);
4
4
  //#endregion