@@ -11,13 +11,12 @@ import { findEntities } from "../common/find-entities";
1111import type { LovelaceElement , LovelaceElementConfig } from "../elements/types" ;
1212import type { LovelaceCard , LovelaceCardEditor } from "../types" ;
1313import { createStyledHuiElement } from "./picture-elements/create-styled-hui-element" ;
14- import type { PictureElementsCardConfig } from "./types" ;
14+ import {
15+ PREVIEW_CLICK_CALLBACK ,
16+ type PictureElementsCardConfig ,
17+ } from "./types" ;
1518import type { PersonEntity } from "../../../data/person" ;
1619
17- // Symbol for preview click callback - preserved through spreads, not serialized
18- // This allows the editor to attach a callback that only exists on the edited card's config
19- export const PREVIEW_CLICK_CALLBACK = Symbol ( "previewClickCallback" ) ;
20-
2120export type PreviewClickCallback = ( x : number , y : number ) => void ;
2221
2322@customElement ( "hui-picture-elements-card" )
@@ -230,23 +229,16 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
230229 }
231230
232231 private _handleImageClick ( ev : MouseEvent ) : void {
233- if (
234- ! this . preview ||
235- ! this . _config ||
236- ! ( this . _config as any ) [ PREVIEW_CLICK_CALLBACK ]
237- ) {
232+ if ( ! this . preview || ! this . _config ?. [ PREVIEW_CLICK_CALLBACK ] ) {
238233 return ;
239234 }
240235
241236 const rect = ( ev . currentTarget as HTMLElement ) . getBoundingClientRect ( ) ;
242237 const x = ( ( ev . clientX - rect . left ) / rect . width ) * 100 ;
243238 const y = ( ( ev . clientY - rect . top ) / rect . height ) * 100 ;
244239
245- // Call the callback if present on config (only the edited card has this)
246- const callback = ( this . _config as any ) [
247- PREVIEW_CLICK_CALLBACK
248- ] as PreviewClickCallback ;
249- callback ( x , y ) ;
240+ // only the edited card has this callback
241+ this . _config [ PREVIEW_CLICK_CALLBACK ] ( x , y ) ;
250242 }
251243}
252244
0 commit comments