From 8647330024247fe4c7b8a6b1a58225350caf64c8 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Wed, 16 Sep 2026 15:37:15 +0200 Subject: [PATCH] Update cookcli-card.js --- dist/cookcli-card.js | 66 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/dist/cookcli-card.js b/dist/cookcli-card.js index 36d0f6d..d3e8e2b 100644 --- a/dist/cookcli-card.js +++ b/dist/cookcli-card.js @@ -188,7 +188,71 @@ class CookCliCardEditor extends LitElement { this._config = config || {}; } + configChanged(newConfig) { + const event = new Event("config-changed", { + bubbles: true, + composed: true, + }); + event.detail = { config: newConfig }; + this.dispatchEvent(event); + } + static getConfigForm() { + return { + schema: [ + { name: "label", selector: { label: {} } }, + { name: "entity", required: true, selector: { entity: {} } }, + { + type: "grid", + name: "", + schema: [ + { name: "name", selector: { text: {} } }, + { + name: "icon", + selector: { + icon: {}, + }, + context: { + icon_entity: "entity", + }, + }, + { + name: "attribute", + selector: { + attribute: {}, + }, + context: { + filter_entity: "entity", + }, + }, + { name: "unit", selector: { text: {} } }, + { name: "theme", selector: { theme: {} } }, + { name: "state_color", selector: { boolean: {} } }, + ], + }, + ], + computeLabel: (schema) => { + if (schema.name === "icon") return "Special Icon"; + return undefined; + }, + computeHelper: (schema) => { + switch (schema.name) { + case "entity": + return "This text describes the function of the entity selector"; + case "unit": + return "The unit of measurement for this card"; + } + return undefined; + }, + assertConfig: (config) => { + if (config.other_option) { + throw new Error("'other_option' is unexpected."); + } + }, + }; + } + + /*static getConfigForm() { return { schema: [ { @@ -229,7 +293,7 @@ class CookCliCardEditor extends LitElement { } }, }; - } + }*/ }