Compare commits

..
Author SHA1 Message Date
Lazizbek Ergashev 459a48b51f Keep picture glance icons visible when tap action is none (#56239) 2026-11-29 08:39:40 +02:00
renovate[bot] c148beafd3 Update dependency @versatiles/style to v9.1.3 (#56241)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 08:34:46 +02:00
renovate[bot] 696c3fb093 Update dependency @vvo/tzdb to v6.207.0 (#56242)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 08:34:36 +02:00
5 changed files with 72 additions and 150 deletions

No files matched your search

+2 -2
View File
@@ -79,9 +79,9 @@
"@swc/helpers": "0.5.24",
"@tsparticles/engine": "4.5.4",
"@tsparticles/preset-links": "4.5.4",
"@versatiles/style": "9.1.2",
"@versatiles/style": "9.1.3",
"@vibrant/color": "4.0.4",
"@vvo/tzdb": "6.204.0",
"@vvo/tzdb": "6.207.0",
"@webcomponents/scoped-custom-element-registry": "0.0.11",
"barcode-detector": "3.2.4",
"cally": "0.9.2",
+10 -10
View File
@@ -316,14 +316,14 @@ importers:
specifier: 4.5.4
version: 4.5.4
'@versatiles/style':
specifier: 9.1.2
version: 9.1.2([email protected])
specifier: 9.1.3
version: 9.1.3([email protected])
'@vibrant/color':
specifier: 4.0.4
version: 4.0.4
'@vvo/tzdb':
specifier: 6.204.0
version: 6.204.0
specifier: 6.207.0
version: 6.207.0
'@webcomponents/scoped-custom-element-registry':
specifier: 0.0.11
version: 0.0.11
@@ -3838,8 +3838,8 @@ packages:
cpu: [x64]
os: [win32]
'@versatiles/[email protected].2':
resolution: {integrity: sha512-rXk/BXFw/s3cSY58gPlbxQRKR+316VGaSG2hbxn/uVwqPe/NJTRPTTU/3UNq3kFpAqgTgT1s2GfP9oP42BlPjQ==}
'@versatiles/[email protected].3':
resolution: {integrity: sha512-VSSGaTL5kJIaZyf/vC3BLu17T3dLLbkZ/d7IMMhcvqYgkmfJ2ru+l1P37QV7xcfyY38YkbFD2fO48gNMVorbig==}
engines: {node: '>=20'}
peerDependencies:
maplibre-gl: '>=5.5.0'
@@ -3917,8 +3917,8 @@ packages:
'@vscode/[email protected]':
resolution: {integrity: sha512-2ZUIRfhofZ/npLlf872EBnPmn27Kt4M2UssmQIfnJvgGgMYZJ5fvtHEDnttBBf2hnVtBgNCqZMVHJA+wsFVqTA==}
'@vvo/[email protected]4.0':
resolution: {integrity: sha512-GC7i3D4rCs6l5jnf6NofoRRumZwVHS1cBNhgbenDLLyJNqJOrTo/8zrWovIrJl5BujiFurqn0Ayj10wysmOKrQ==}
'@vvo/[email protected]7.0':
resolution: {integrity: sha512-HPwl5q8rkCmkHSpYiYt/V3KDmyIfz7ZvYHEaSuX0L9g48cWFDwFR/P3BWgGL11NyGToHvykrC2fCXj7mb4gl1w==}
'@web/[email protected]':
resolution: {integrity: sha512-XVKH79pk4d3EHRhofete8eAnqto1e8mCRAqPV00KLNFzCWSe8sWmLnqKCqkPNARC6nksMaGrATnA5sPDRllMpQ==}
@@ -11670,7 +11670,7 @@ snapshots:
'@unrs/[email protected]':
optional: true
'@versatiles/[email protected].2([email protected])':
'@versatiles/[email protected].3([email protected])':
dependencies:
'@maplibre/maplibre-gl-style-spec': 26.9.0
optionalDependencies:
@@ -11764,7 +11764,7 @@ snapshots:
'@vscode/[email protected]': {}
'@vvo/[email protected]4.0': {}
'@vvo/[email protected]7.0': {}
'@web/[email protected]':
dependencies:
+32 -78
View File
@@ -67,7 +67,7 @@ import type {
import { isMac } from "../../util/is_mac";
import "../chips/ha-assist-chip";
import "../ha-icon-button";
import { RANGE_MIN_WIDTH, ZOOM_SLIDER_HEIGHT } from "./ha-chart-zoom-slider";
import { ZOOM_SLIDER_HEIGHT } from "./ha-chart-zoom-slider";
import { formatTimeLabel } from "./axis-label";
import type { ChartSonification } from "./chart-sonification";
import { canSonifyChart, sonifyChart } from "./chart-sonification";
@@ -546,10 +546,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
if (changedProps.has("options")) {
chartOptions = { ...chartOptions, ...this._createOptions() };
this._disposeSonification();
const [start, end] = this._zoomRange;
if (!this._getZoomAxis() && (start !== 0 || end !== 100)) {
this._setZoomRange(0, 100);
}
}
let legendChanged = false;
if (changedProps.has("options") || changedProps.has("data")) {
@@ -1076,7 +1072,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
private _updateDragToZoom() {
const active =
!this._touchInput &&
this._getZoomAxis() !== undefined &&
this._hasZoomableXAxis() &&
this.selectMode !== "range";
if (!this.chart || active === this._dragToZoom) {
return;
@@ -1213,34 +1209,31 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
}
}
// Horizontal bar charts zoom their categories, which rescales the values
private _getZoomAxis(): "x" | "y" | undefined {
private _hasZoomableXAxis() {
const xAxis = ensureArray(this.options?.xAxis)?.[0] as
XAXisOption | undefined;
const yAxis = ensureArray(this.options?.yAxis)?.[0] as
YAXisOption | undefined;
if (!xAxis || xAxis.show === false || this.options?.dataZoom) {
return undefined;
}
return xAxis.type === "value" && yAxis?.type === "category" ? "y" : "x";
}
private _hasZoomableXAxis() {
return this._getZoomAxis() === "x";
return Boolean(
xAxis &&
xAxis.show !== false &&
!this.options?.dataZoom &&
// vertical data zoom doesn't work well in this case and horizontal is pointless
!(xAxis.type === "value" && yAxis?.type === "category")
);
}
private _getDataZoomConfig(): DataZoomComponentOption[] | undefined {
const zoomAxis = this._getZoomAxis();
if (!zoomAxis) {
if (!this._hasZoomableXAxis()) {
return undefined;
}
return [
{
id: "dataZoom",
type: "inside",
orient: "horizontal",
filterMode: this._getDataZoomFilterMode() as any,
xAxisIndex: zoomAxis === "x" ? 0 : undefined,
yAxisIndex: zoomAxis === "y" ? 0 : undefined,
xAxisIndex: 0,
// Panning is left to the slider and horizontal scrolling
moveOnMouseMove: false,
preventDefaultMouseMove: false,
@@ -1250,18 +1243,9 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
private _showZoomSlider() {
const [start, end] = this._zoomRange;
const zoomAxis = this._getZoomAxis();
// A short chart leaves a vertical slider no room to move
const fits =
zoomAxis === "x" ||
(zoomAxis === "y" &&
(this.chart?.getHeight() ?? 0) -
ZOOM_RESET_OFFSET -
X_AXIS_LABEL_SPACE >=
2 * RANGE_MIN_WIDTH);
return (
this.zoomSlider !== "never" &&
fits &&
this._hasZoomableXAxis() &&
(this.zoomSlider === "always" ||
this._zoomSliderHeld ||
start !== 0 ||
@@ -1273,12 +1257,11 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
const resetLabel = this._i18n.localize(
"ui.components.history_charts.zoom_reset"
);
const vertical = this._getZoomAxis() === "y";
return html`
${
this._isZoomed
? html`<ha-icon-button
class="slider-reset ${classMap({ vertical })}"
class="slider-reset"
.path=${mdiRestart}
.label=${resetLabel}
@click=${this._handleZoomReset}
@@ -1287,7 +1270,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
}
<ha-chart-zoom-slider
class="zoom-slider"
.vertical=${vertical}
.start=${this._zoomRange[0]}
.end=${this._zoomRange[1]}
@zoom-slider-changed=${this._handleZoomSliderChanged}
@@ -1331,11 +1313,10 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
return grid;
}
const [first, ...rest] = ensureArray(grid);
const room =
this._getZoomAxis() === "y"
? { right: (Number(first.right) || 0) + ZOOM_SLIDER_SPACE }
: { bottom: this._getGridBottom() + this._getZoomSliderSpace() };
return [{ ...first, ...room }, ...rest];
return [
{ ...first, bottom: this._getGridBottom() + this._getZoomSliderSpace() },
...rest,
];
}
private _getGridBottom() {
@@ -1414,7 +1395,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
l.type === "custom" ? { show: false } : l
);
}
const verticalZoom = this._getZoomAxis() === "y";
const options = {
animation: !this._reducedMotion,
animationDuration: 500,
@@ -1427,8 +1407,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
feature: {
dataZoom: {
show: true,
xAxisIndex: verticalZoom ? false : undefined,
yAxisIndex: verticalZoom ? undefined : false,
yAxisIndex: false,
filterMode: "none",
showTitle: false,
},
@@ -1756,10 +1735,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
}
const replaceMerge = options.series ? ["series"] : [];
// A bar chart turned into a pie drops its zoom
if ("dataZoom" in options) {
replaceMerge.push("dataZoom");
}
this.chart.setOption(options, { replaceMerge });
}
@@ -1788,16 +1763,14 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
return;
}
}
const zoomAxis = this._getZoomAxis();
if (!zoomAxis) {
if (!this._hasZoomableXAxis()) {
return;
}
const position =
zoomAxis === "y"
? e.offsetY / this.chart.getHeight()
: e.offsetX / this.chart.getWidth();
// Kept within the axis, as ECharts does, so the datazoom event matches it
const start = Math.min(Math.max(position * 100 - 15, 0), 70);
const start = Math.min(
Math.max((e.offsetX / this.chart.getWidth()) * 100 - 15, 0),
70
);
const range = this._isZoomed ? [0, 100] : [start, start + 30];
this.chart.dispatchAction({
type: "dataZoom",
@@ -1825,11 +1798,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
ev.stopPropagation();
// Not _isZoomed, which a Sankey roam sets without an axis to pan
const [start, end] = this._zoomRange;
if (
!this.chart ||
!this._hasZoomableXAxis() ||
(start === 0 && end === 100)
) {
if (!this.chart || (start === 0 && end === 100)) {
return;
}
const delta = ev.shiftKey ? ev.deltaX || ev.deltaY : ev.deltaX;
@@ -1855,7 +1824,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
return;
}
const [start, end] = this._zoomRange;
const shift = (pixels * (end - start)) / this._getZoomAxisLength();
const shift = (pixels * (end - start)) / this._getXAxisPixelWidth();
const clamped = Math.max(-start, Math.min(100 - end, shift));
if (clamped) {
this._setZoomWindow(start + clamped, end + clamped);
@@ -2057,18 +2026,15 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
});
}
private _getZoomAxisLength(): number {
const vertical = this._getZoomAxis() === "y";
private _getXAxisPixelWidth(): number {
const axisModel = this.chart
// @ts-ignore private method but no public way to get the axis extent
?.getModel()
.getComponent(vertical ? "yAxis" : "xAxis", 0) as
.getComponent("xAxis", 0) as
{ axis?: { getExtent(): [number, number] } } | undefined;
const extent = axisModel?.axis?.getExtent();
const length = extent ? Math.abs(extent[1] - extent[0]) : 0;
return (
length || (vertical ? this.chart!.getHeight() : this.chart!.getWidth())
);
const width = extent ? Math.abs(extent[1] - extent[0]) : 0;
return width || this.chart!.getWidth();
}
private _setZoomRange(start: number, end: number) {
@@ -2090,7 +2056,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
[start, end] = dataZoom?.getPercentRange() ?? [0, 100];
const [prevStart, prevEnd] = this._zoomRange;
const pixels =
((end - start) / (prevEnd - prevStart)) * this._getZoomAxisLength();
((end - start) / (prevEnd - prevStart)) * this._getXAxisPixelWidth();
if (pixels < MIN_DRAG_ZOOM_WIDTH) {
this.chart!.dispatchAction(
{
@@ -2343,18 +2309,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
right: 0;
bottom: ${ZOOM_SLIDER_BOTTOM}px;
}
.slider-reset.vertical {
left: auto;
right: ${ZOOM_SLIDER_BOTTOM + ZOOM_SLIDER_HEIGHT / 2 - ZOOM_RESET_SIZE / 2}px;
top: 0;
bottom: auto;
}
.zoom-slider[vertical] {
left: auto;
right: ${ZOOM_SLIDER_BOTTOM}px;
top: ${ZOOM_RESET_OFFSET}px;
bottom: ${X_AXIS_LABEL_SPACE}px;
}
.slider-reset,
.zoom-slider {
animation: zoom-slider-fade-in var(--ha-animation-duration-normal)
+27 -59
View File
@@ -17,8 +17,7 @@ export const ZOOM_SLIDER_HEIGHT = 24;
const THUMB_SIZE = 20;
const THUMB_INSET = (ZOOM_SLIDER_HEIGHT - THUMB_SIZE) / 2;
// Leaves room to grab the range between its thumbs, however small it gets
export const RANGE_MIN_WIDTH =
2 * (THUMB_INSET + THUMB_SIZE) + ZOOM_SLIDER_HEIGHT;
const RANGE_MIN_WIDTH = 2 * (THUMB_INSET + THUMB_SIZE) + ZOOM_SLIDER_HEIGHT;
// The smallest visible range the thumbs can be dragged to, in percent
const MIN_RANGE = 1;
// A press this soon after a tap's release shows the full range again
@@ -34,31 +33,24 @@ export class HaChartZoomSlider extends LitElement {
@property({ type: Number }) public end = 100;
// Top to bottom, for charts that zoom a category axis drawn top down
@property({ type: Boolean, reflect: true }) public vertical = false;
@state()
@consume({ context: internationalizationContext, subscribe: true })
private _i18n!: HomeAssistantInternationalization;
private _pressPosition?: number;
private _pressX?: number;
private _lastTapTime?: number;
private _drag?: {
pointerId: number;
part: SliderPart;
position: number;
x: number;
range: [number, number];
};
protected render() {
const { start, end } = this;
const { localize, locale } = this._i18n;
const [offset, size] = this.vertical
? ["top", "height"]
: ["left", "width"];
const orientation = this.vertical ? "vertical" : "horizontal";
const at = (percent: number) =>
`calc((100% - ${RANGE_MIN_WIDTH}px) * ${percent / 100})`;
const percent = (value: number) =>
@@ -78,7 +70,7 @@ export class HaChartZoomSlider extends LitElement {
class="range"
data-part="range"
role="slider"
aria-orientation=${orientation}
aria-orientation="horizontal"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow=${Math.round(start)}
@@ -86,8 +78,8 @@ export class HaChartZoomSlider extends LitElement {
aria-label=${localize("ui.components.history_charts.zoom_range")}
tabindex="0"
style=${styleMap({
[offset]: at(start),
[size]: `calc(${at(end - start)} + ${RANGE_MIN_WIDTH}px)`,
left: at(start),
width: `calc(${at(end - start)} + ${RANGE_MIN_WIDTH}px)`,
})}
@pointerdown=${this._handlePointerDown}
@pointermove=${this._handlePointerMove}
@@ -101,7 +93,7 @@ export class HaChartZoomSlider extends LitElement {
class="thumb"
data-part=${part}
role="slider"
aria-orientation=${orientation}
aria-orientation="horizontal"
aria-valuemin=${
part === "start"
? 0
@@ -117,7 +109,7 @@ export class HaChartZoomSlider extends LitElement {
aria-label=${localize(`ui.components.history_charts.zoom_${part}`)}
tabindex="0"
style=${styleMap({
[offset]:
left:
part === "start"
? `calc(${at(start)} + ${THUMB_INSET}px)`
: `calc(${at(end)} + ${RANGE_MIN_WIDTH - THUMB_INSET - THUMB_SIZE}px)`,
@@ -137,12 +129,7 @@ export class HaChartZoomSlider extends LitElement {
// Percent of the full range per pixel along the track
private _getScale() {
const length = this.vertical ? this.clientHeight : this.clientWidth;
return 100 / Math.max(length - RANGE_MIN_WIDTH, 1);
}
private _getPosition(ev: PointerEvent) {
return this.vertical ? ev.clientY : ev.clientX;
return 100 / Math.max(this.clientWidth - RANGE_MIN_WIDTH, 1);
}
// Pressing the track beside the visible range centers the range there.
@@ -159,19 +146,18 @@ export class HaChartZoomSlider extends LitElement {
ev.timeStamp - this._lastTapTime < DOUBLE_PRESS_TIME
) {
this._lastTapTime = undefined;
this._pressPosition = undefined;
this._pressX = undefined;
this._drag = undefined;
// The press ends here, so the chart does not keep holding the slider open
ev.stopPropagation();
fireEvent(this, "zoom-slider-reset");
return;
}
this._pressPosition = this._getPosition(ev);
this._pressX = ev.clientX;
if (ev.target !== ev.currentTarget) {
return;
}
const offset = this.vertical ? ev.offsetY : ev.offsetX;
const position = (offset - RANGE_MIN_WIDTH / 2) * this._getScale();
const position = (ev.offsetX - RANGE_MIN_WIDTH / 2) * this._getScale();
this._move(
"range",
[this.start, this.end],
@@ -187,10 +173,10 @@ export class HaChartZoomSlider extends LitElement {
}
const tapped =
ev.type === "pointerup" &&
this._pressPosition !== undefined &&
Math.abs(this._getPosition(ev) - this._pressPosition) <= TAP_MAX_DISTANCE;
this._pressX !== undefined &&
Math.abs(ev.clientX - this._pressX) <= TAP_MAX_DISTANCE;
this._lastTapTime = tapped ? ev.timeStamp : undefined;
this._pressPosition = undefined;
this._pressX = undefined;
}
private _handlePointerDown(
@@ -203,7 +189,7 @@ export class HaChartZoomSlider extends LitElement {
this._drag = {
pointerId: ev.pointerId,
part: ev.currentTarget.dataset.part as SliderPart,
position: this._getPosition(ev),
x: ev.clientX,
range: [this.start, this.end],
};
}
@@ -217,12 +203,8 @@ export class HaChartZoomSlider extends LitElement {
this._drag = undefined;
return;
}
const { part, position, range } = this._drag;
this._move(
part,
range,
(this._getPosition(ev) - position) * this._getScale()
);
const { part, x, range } = this._drag;
this._move(part, range, (ev.clientX - x) * this._getScale());
}
private _handlePointerUp(ev: PointerEvent) {
@@ -236,19 +218,20 @@ export class HaChartZoomSlider extends LitElement {
) {
const part = ev.currentTarget.dataset.part as SliderPart;
const span = this.end - this.start;
const decrease =
ev.key === "ArrowLeft" ||
ev.key === (this.vertical ? "ArrowUp" : "ArrowDown");
const decrease = ev.key === "ArrowLeft" || ev.key === "ArrowDown";
// A ninth of a shrunk span undoes a tenth of the original one
const step =
part !== "range" && (part === "start") === decrease
? span / 9
: span / 10;
const shift = ev.key.startsWith("Arrow")
? decrease
? -step
: step
: { Home: -100, End: 100 }[ev.key];
const shift = {
ArrowLeft: -step,
ArrowDown: -step,
ArrowRight: step,
ArrowUp: step,
Home: -100,
End: 100,
}[ev.key];
if (shift === undefined) {
return;
}
@@ -335,21 +318,6 @@ export class HaChartZoomSlider extends LitElement {
--mdc-icon-size: ${THUMB_SIZE}px;
cursor: ew-resize;
}
:host([vertical]) {
width: ${ZOOM_SLIDER_HEIGHT}px;
height: auto;
}
:host([vertical]) .range {
left: 0;
right: 0;
}
:host([vertical]) .thumb {
left: ${THUMB_INSET}px;
cursor: ns-resize;
}
:host([vertical]) ha-svg-icon {
transform: rotate(90deg);
}
.range:focus-visible,
.thumb:focus-visible {
outline: 2px solid var(--primary-color);
@@ -387,7 +387,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
}
ha-icon-button {
--ha-icon-button-size: 40px;
--disabled-text-color: currentColor;
--ha-color-on-disabled-quiet: currentColor;
color: var(--ha-picture-icon-button-color, #a9a9a9);
}
ha-icon-button.state-on {