extra-map-card 1.0.0 → 1.0.1

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.
@@ -0,0 +1,46 @@
1
+ import { HomeAssistant } from '@types';
2
+ import { LitElement, PropertyValues, CSSResultGroup } from 'lit';
3
+ import { HaMapEntity, HaMapPaths, ThemeMode } from 'types/config';
4
+ export declare class EmcMap extends LitElement {
5
+ hass: HomeAssistant;
6
+ entities?: string[] | HaMapEntity[];
7
+ paths?: HaMapPaths[];
8
+ autoFit: boolean;
9
+ fitZones: boolean;
10
+ zoom: number;
11
+ themeMode: ThemeMode;
12
+ private apiKey;
13
+ private blockMoreInfo;
14
+ private customStyles;
15
+ private _map?;
16
+ private _mapItems;
17
+ private _zoneItems;
18
+ private _mapFocusZones;
19
+ private _mapFocusItems;
20
+ private _mapPaths;
21
+ private _mapHelper;
22
+ private _fitBounds;
23
+ private _loaded;
24
+ private get _darkMode();
25
+ protected render(): import("lit-html").TemplateResult<1>;
26
+ protected firstUpdated(): Promise<void>;
27
+ protected updated(changedProps: PropertyValues): void;
28
+ private _drawEntities;
29
+ private _computePathTooltip;
30
+ private _drawPaths;
31
+ private _setupPointInteraction;
32
+ _fitMap(options?: {
33
+ zoom?: number;
34
+ pad?: number;
35
+ }): void;
36
+ private _initMap;
37
+ private getModeColor;
38
+ private _getInitStyle;
39
+ private _changeControlTheme;
40
+ static get styles(): CSSResultGroup;
41
+ }
42
+ declare global {
43
+ interface HTMLElementTagNameMap {
44
+ 'emc-map': EmcMap;
45
+ }
46
+ }
@@ -1,4 +1,4 @@
1
- function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%c📍 EXTRA-MAP-CARD 🗺️%cv1.0.0","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: https://github.com/ngocjohn/extra-map-card"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);var i,r;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(i||(i={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(r||(r={}));var n=function(e){if(e.time_format===r.language||e.time_format===r.system){var t=e.time_format===r.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===r.am_pm},o=function(e,t){return a(t).format(e)},a=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:n(e)})},s=function(e,t){return l(t).format(e)},l=function(e){return new Intl.DateTimeFormat(e.language,{hour:n(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:n(e)})};function c(e){return e.substr(0,e.indexOf("."))}function u(e){return c(e.entity_id)}class h{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const p=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:n},l=new h(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},d=globalThis,m=d.ShadowRoot&&(void 0===d.ShadyCSS||d.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,f=Symbol(),g=new WeakMap;
1
+ function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%c📍 EXTRA-MAP-CARD 🗺️%cv1.0.1","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: git+https://github.com/ngocjohn/extra-map-card.git"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);var i,r;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(i||(i={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(r||(r={}));var n=function(e){if(e.time_format===r.language||e.time_format===r.system){var t=e.time_format===r.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===r.am_pm},o=function(e,t){return a(t).format(e)},a=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:n(e)})},s=function(e,t){return l(t).format(e)},l=function(e){return new Intl.DateTimeFormat(e.language,{hour:n(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:n(e)})};function c(e){return e.substr(0,e.indexOf("."))}function u(e){return c(e.entity_id)}class h{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const p=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:n},l=new h(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},d=globalThis,m=d.ShadowRoot&&(void 0===d.ShadyCSS||d.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,f=Symbol(),g=new WeakMap;
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
@@ -0,0 +1,45 @@
1
+ import { HomeAssistant, LovelaceCard, LovelaceGridOptions } from '@types';
2
+ import { LitElement, TemplateResult, nothing, PropertyValues } from 'lit';
3
+ import { ExtraMapCardConfig } from 'types/config';
4
+ import './components/emc-map';
5
+ export declare const DEFAULT_HOURS_TO_SHOW = 0;
6
+ export declare const DEFAULT_ZOOM = 14;
7
+ export declare class ExtraMapCard extends LitElement implements LovelaceCard {
8
+ hass: HomeAssistant;
9
+ layout?: string;
10
+ private _config?;
11
+ private _configEntities?;
12
+ private _mapEntities;
13
+ private _colorDict;
14
+ private _colorIndex;
15
+ private _error?;
16
+ private _subscribed?;
17
+ private _stateHistory?;
18
+ private _mapTiler?;
19
+ private _getAllEntities;
20
+ static getStubConfig(hass: HomeAssistant, entities: string[], entitiesFallback: string[]): ExtraMapCardConfig;
21
+ setConfig(config: ExtraMapCardConfig): void;
22
+ getCardSize(): number;
23
+ getGridOptions(): LovelaceGridOptions;
24
+ protected render(): TemplateResult | typeof nothing;
25
+ protected shouldUpdate(changedProps: PropertyValues): boolean;
26
+ protected willUpdate(changedProps: PropertyValues): void;
27
+ connectedCallback(): void;
28
+ disconnectedCallback(): void;
29
+ private _subscribeHistory;
30
+ private _unsubscribeHistory;
31
+ protected updated(changedProps: PropertyValues): void;
32
+ private _computePadding;
33
+ private _getColor;
34
+ private _getMapEntities;
35
+ private _getHistoryPaths;
36
+ static styles: import("lit").CSSResult;
37
+ }
38
+ declare global {
39
+ interface HTMLElementTagNameMap {
40
+ 'extra-map-card': ExtraMapCard;
41
+ }
42
+ interface Window {
43
+ ExtraMapCard: ExtraMapCard;
44
+ }
45
+ }
@@ -0,0 +1 @@
1
+ export * from './extra-map-card';