From e3935f58220aea726507571aa706fb4db701bfb3 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Wed, 16 Sep 2026 15:34:55 +0200 Subject: [PATCH] Update cookcli-card.js --- dist/cookcli-card.js | 101 ++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/dist/cookcli-card.js b/dist/cookcli-card.js index 32c35a0..36d0f6d 100644 --- a/dist/cookcli-card.js +++ b/dist/cookcli-card.js @@ -183,79 +183,54 @@ class CookCliCard extends HTMLElement { } } -class CookCliCardEditor extends HTMLElement { +class CookCliCardEditor extends LitElement { setConfig(config) { this._config = config || {}; } - set hass(hass) { - this._hass = hass; - } - - // Définit le schéma du formulaire (une entrée par champ configurable) - get _schema() { - return [ - { - name: "title", - selector: { text: {} }, + static getConfigForm() { + return { + schema: [ + { + name: "title", + selector: { text: {} }, + }, + { + name: "dashboard_path", + selector: { text: {} }, + helper: "Laisser vide pour naviguer dans le dashboard courant", + }, + { + name: "entry_id", + selector: { text: {} }, + helper: "Optionnel — ID d'entrée si plusieurs serveurs CookCLI", + }, + ], + computeLabel: (schema) => { + const labels = { + title: "Titre", + dashboard_path: "Chemin du dashboard", + entry_id: "Entry ID", + }; + return labels[schema.name] || schema.name; }, - { - name: "dashboard_path", - selector: { text: {} }, - helper: "Laisser vide pour naviguer dans le dashboard courant", + 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; }, - { - name: "entry_id", - selector: { text: {} }, - helper: "Optionnel — ID d'entrée si plusieurs serveurs CookCLI", + assertConfig: (config) => { + if (config.other_option) { + throw new Error("'other_option' is unexpected."); + } }, - ]; - } - - // Fournit les libellés des champs - _computeLabel(schema) { - const labels = { - title: "Titre", - dashboard_path: "Chemin du dashboard", - entry_id: "Entry ID", }; - return labels[schema.name] || schema.name; } - // Gère les changements dans le formulaire - _valueChanged(ev) { - if (!this._config || !this._hass) { - return; - } - const newConfig = { ...this._config, ...ev.detail.value }; - - this._config = newConfig; - - const event = new CustomEvent("config-changed", { - detail: { config: newConfig }, - bubbles: true, - composed: true, - }); - this.dispatchEvent(event); - } - - render() { - if (!this._hass) return; - - this.innerHTML = ` - - `; - } - - connectedCallback() { - this.render(); - } } customElements.define("cookcli-card", CookCliCard);