Skip to content

Commit

Permalink
Update dependencies + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
malmeloo committed Oct 14, 2024
1 parent bcbc09b commit c59cd85
Show file tree
Hide file tree
Showing 5 changed files with 1,838 additions and 1,739 deletions.
35 changes: 16 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,33 @@
"author": "Ian Richardson <iantrich@gmail.com>",
"license": "MIT",
"dependencies": {
"deep-clone-simple": "^1.1.1",
"custom-card-helpers": "^1.7.2",
"home-assistant-js-websocket": "^5.11.1",
"lit": "^2.0.0-rc.2"
"deep-clone-simple": "^1.1.1",
"lit": "^3.2.1"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@rollup/plugin-json": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"rollup": "^2.58.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-uglify": "^6.0.4",
"typescript": "^4.4.3"
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"rollup-plugin-serve": "^1.1.1",
"rollup-plugin-typescript2": "^0.36.0",
"typescript": "~5.5.0"
},
"scripts": {
"start": "rollup -c rollup.config.dev.js --watch",
"start": "rollup -c rollup.config.dev.mjs --watch",
"build": "npm run lint && npm run rollup",
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.dev.js → rollup.config.dev.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import serve from 'rollup-plugin-serve';

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import resolve from "rollup-plugin-node-resolve";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "rollup-plugin-typescript2";

export default {
Expand Down
36 changes: 18 additions & 18 deletions src/config-template-card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LitElement, html, customElement, property, TemplateResult, PropertyValues, state } from 'lit-element';
import { LitElement, html, TemplateResult, PropertyValues } from 'lit-element';
import { customElement, property, state } from 'lit-element/decorators.js';
import deepClone from 'deep-clone-simple';
import { computeCardSize, HomeAssistant, LovelaceCard } from 'custom-card-helpers';

Expand All @@ -16,6 +17,7 @@ console.info(
export class ConfigTemplateCard extends LitElement {
@property({ attribute: false }) public hass?: HomeAssistant;
@state() private _config?: ConfigTemplateConfig;
/* eslint-disable @typescript-eslint/no-explicit-any */
@state() private _helpers?: any;
private _initialized = false;

Expand Down Expand Up @@ -52,27 +54,28 @@ export class ConfigTemplateCard extends LitElement {
}

private getLovelacePanel() {
const ha = document.querySelector("home-assistant");
const ha = document.querySelector('home-assistant');

if (ha && ha.shadowRoot) {
const haMain = ha.shadowRoot.querySelector("home-assistant-main");
const haMain = ha.shadowRoot.querySelector('home-assistant-main');

if (haMain && haMain.shadowRoot) {
return haMain.shadowRoot.querySelector('ha-panel-lovelace');
}
}

return null
return null;
}

private getLovelaceConfig() {
/* eslint-disable @typescript-eslint/no-explicit-any */
const panel = this.getLovelacePanel() as any;

if (panel && panel.lovelace && panel.lovelace.config && panel.lovelace.config.config_template_card_vars) {
return panel.lovelace.config.config_template_card_vars
return panel.lovelace.config.config_template_card_vars;
}

return {}
return {};
}

protected shouldUpdate(changedProps: PropertyValues): boolean {
Expand Down Expand Up @@ -126,8 +129,8 @@ export class ConfigTemplateCard extends LitElement {
let config = this._config.card
? deepClone(this._config.card)
: this._config.row
? deepClone(this._config.row)
: deepClone(this._config.element);
? deepClone(this._config.row)
: deepClone(this._config.element);

let style = this._config.style ? deepClone(this._config.style) : {};

Expand All @@ -139,28 +142,24 @@ export class ConfigTemplateCard extends LitElement {
const element = this._config.card
? this._helpers.createCardElement(config)
: this._config.row
? this._helpers.createRowElement(config)
: this._helpers.createHuiElement(config);
? this._helpers.createRowElement(config)
: this._helpers.createHuiElement(config);
element.hass = this.hass;

if (this._config.element) {
if (style) {
Object.keys(style).forEach(prop => {
Object.keys(style).forEach((prop) => {
this.style.setProperty(prop, style[prop]);
});
}
if (config.style) {
Object.keys(config.style).forEach(prop => {
Object.keys(config.style).forEach((prop) => {
element.style.setProperty(prop, config.style[prop]);
});
}
}

return html`
<div id="card">
${element}
</div>
`;
return html`<div id="card">${element}</div>`;
}

private _initialize(): void {
Expand All @@ -171,12 +170,13 @@ export class ConfigTemplateCard extends LitElement {
}

private async loadCardHelpers(): Promise<void> {
/* eslint-disable @typescript-eslint/no-explicit-any */
this._helpers = await (window as any).loadCardHelpers();
}

/* eslint-disable @typescript-eslint/no-explicit-any */
private _evaluateConfig(config: any): any {
Object.entries(config).forEach(entry => {
Object.entries(config).forEach((entry) => {
const key = entry[0];
const value = entry[1];

Expand Down
Loading

0 comments on commit c59cd85

Please sign in to comment.