Update cookcli-card.js

This commit is contained in:
TheThomaas 2026-09-16 15:37:15 +02:00
parent e3935f5822
commit 8647330024

66
dist/cookcli-card.js vendored
View file

@ -188,7 +188,71 @@ class CookCliCardEditor extends LitElement {
this._config = config || {}; this._config = config || {};
} }
configChanged(newConfig) {
const event = new Event("config-changed", {
bubbles: true,
composed: true,
});
event.detail = { config: newConfig };
this.dispatchEvent(event);
}
static getConfigForm() { 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 { return {
schema: [ schema: [
{ {
@ -229,7 +293,7 @@ class CookCliCardEditor extends LitElement {
} }
}, },
}; };
} }*/
} }