Skip to content

Commit

Permalink
Support 0.106 create element changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Feb 20, 2020
1 parent a458226 commit 9286c82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "config-template-card",
"version": "1.1.1",
"version": "1.1.2",
"description": "Lovelace config-template-card",
"keywords": [
"home-assistant",
Expand Down
10 changes: 9 additions & 1 deletion src/config-template-card.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LitElement, html, customElement, property, TemplateResult, PropertyValues } from 'lit-element';
import deepClone from 'deep-clone-simple';
import { HomeAssistant, createThing } from 'custom-card-helpers';
Expand All @@ -16,6 +17,7 @@ console.info(
export class ConfigTemplateCard extends LitElement {
@property() public hass?: HomeAssistant;
@property() private _config?: ConfigTemplateConfig;
@property() private _helpers?: any;

public setConfig(config: ConfigTemplateConfig): void {
if (!config) {
Expand All @@ -35,6 +37,8 @@ export class ConfigTemplateCard extends LitElement {
}

this._config = config;

this.loadCardHelpers();
}

protected shouldUpdate(changedProps: PropertyValues): boolean {
Expand Down Expand Up @@ -66,14 +70,18 @@ export class ConfigTemplateCard extends LitElement {
let cardConfig = deepClone(this._config.card);
cardConfig = this._evaluateConfig(cardConfig);

const element = createThing(cardConfig);
const element = this._helpers ? this._helpers.createCardElement(cardConfig) : createThing(cardConfig);
element.hass = this.hass;

return html`
${element}
`;
}

private async loadCardHelpers(): Promise<void> {
this._helpers = await (window as any).loadCardHelpers();
}

/* eslint-disable @typescript-eslint/no-explicit-any */
private _evaluateConfig(config: any): any {
Object.entries(config).forEach(entry => {
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CARD_VERSION = '1.1.1';
export const CARD_VERSION = '1.1.2';
41 changes: 4 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,6 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"

buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

builtin-modules@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484"
Expand Down Expand Up @@ -393,7 +388,7 @@ color-name@1.1.3:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=

commander@^2.20.0, commander@~2.20.3:
commander@~2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
Expand Down Expand Up @@ -1062,7 +1057,7 @@ isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

jest-worker@^24.0.0, jest-worker@^24.6.0:
jest-worker@^24.0.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5"
integrity sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==
Expand Down Expand Up @@ -1543,17 +1538,6 @@ rollup-plugin-serve@^1.0.1:
mime ">=2.0.3"
opener "1"

rollup-plugin-terser@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.1.2.tgz#3e41256205cb75f196fc70d4634227d1002c255c"
integrity sha512-sWKBCOS+vUkRtHtEiJPAf+WnBqk/C402fBD9AVHxSIXMqjsY7MnYWKYEUqGixtr0c8+1DjzUEPlNgOYQPVrS1g==
dependencies:
"@babel/code-frame" "^7.0.0"
jest-worker "^24.6.0"
rollup-pluginutils "^2.8.1"
serialize-javascript "^1.7.0"
terser "^4.1.0"

rollup-plugin-typescript2@^0.24.3:
version "0.24.3"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.24.3.tgz#276fa33a9d584d500da62d3e5400307f4a46bdf2"
Expand Down Expand Up @@ -1625,7 +1609,7 @@ semver@^6.0.0, semver@^6.1.2, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

serialize-javascript@^1.7.0, serialize-javascript@^1.9.0:
serialize-javascript@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb"
integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==
Expand Down Expand Up @@ -1665,20 +1649,12 @@ slice-ansi@^2.1.0:
astral-regex "^1.0.0"
is-fullwidth-code-point "^2.0.0"

source-map-support@~0.5.12:
version "0.5.16"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042"
integrity sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"

source-map@^0.5.0:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=

source-map@^0.6.0, source-map@~0.6.1:
source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
Expand Down Expand Up @@ -1781,15 +1757,6 @@ table@^5.2.3:
slice-ansi "^2.1.0"
string-width "^3.0.0"

terser@^4.1.0:
version "4.3.9"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.9.tgz#e4be37f80553d02645668727777687dad26bbca8"
integrity sha512-NFGMpHjlzmyOtPL+fDw3G7+6Ueh/sz4mkaUYa4lJCxOPTNzd0Uj0aZJOmsDYoSQyfuVoWDMSWTPU3huyOm2zdA==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"

text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
Expand Down

0 comments on commit 9286c82

Please sign in to comment.