From 7ddd378b9a9878a46ee5c123d7685331377fcc5f Mon Sep 17 00:00:00 2001 From: xiaoshi <115949669+xiaoshi930@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:22:06 +0800 Subject: [PATCH] Create xiaoshi-device-consumables-card.js --- xiaoshi-device-consumables-card.js | 1115 ++++++++++++++++++++++++++++ 1 file changed, 1115 insertions(+) create mode 100644 xiaoshi-device-consumables-card.js diff --git a/xiaoshi-device-consumables-card.js b/xiaoshi-device-consumables-card.js new file mode 100644 index 0000000..11643d7 --- /dev/null +++ b/xiaoshi-device-consumables-card.js @@ -0,0 +1,1115 @@ +import { LitElement, html, css } from "https://unpkg.com/lit-element@2.4.0/lit-element.js?module"; + +class XiaoshiConsumablesCardEditor extends LitElement { + static get properties() { + return { + hass: { type: Object }, + config: { type: Object }, + _searchTerm: { type: String }, + _filteredEntities: { type: Array }, + _showEntityList: { type: Boolean } + }; + } + + static get styles() { + return css` + .form { + display: flex; + flex-direction: column; + gap: 10px; + min-height: 500px; + } + .form-group { + display: flex; + flex-direction: column; + gap: 5px; + } + label { + font-weight: bold; + } + select, input, textarea { + padding: 8px; + border: 1px solid #ddd; + border-radius: 4px; + } + textarea { + min-height: 80px; + resize: vertical; + } + .help-text { + font-size: 0.85em; + color: #666; + margin-top: 4px; + } + + .entity-selector { + position: relative; + } + + .entity-search-input { + width: 100%; + padding: 8px; + border: 1px solid #ddd; + border-radius: 4px; + box-sizing: border-box; + } + + .entity-dropdown { + position: absolute; + top: 100%; + left: 0; + right: 0; + height: 300px; + overflow-y: auto; + background: white; + border: 1px solid #ddd; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0,0,0,0.1); + z-index: 1000; + margin-top: 2px; + } + + .entity-option { + display: flex; + align-items: center; + justify-content: space-between; + padding: 8px 12px; + cursor: pointer; + border-bottom: 1px solid #eee; + } + + .entity-option:hover { + background: #f5f5f5; + } + + .entity-option.selected { + background: #e3f2fd; + } + + .entity-info { + display: flex; + align-items: center; + gap: 8px; + flex: 1; + justify-content: space-between; + } + + .entity-details { + flex: 1; + } + + .entity-name { + font-weight: 500; + font-size: 14px; + color: #000; + } + + .entity-id { + font-size: 12px; + color: #000; + font-family: monospace; + } + + .check-icon { + color: #4CAF50; + } + + .no-results { + padding: 12px; + text-align: center; + color: #666; + font-style: italic; + } + + .selected-entities { + margin-top: 8px; + } + + .selected-label { + font-size: 12px; + font-weight: bold; + margin-bottom: 4px; + color: #333; + } + + .selected-entity-config { + margin-bottom: 8px; + border: 1px solid #ddd; + border-radius: 4px; + padding: 8px; + background: #f9f9f9; + } + + .selected-entity { + display: flex; + align-items: center; + gap: 4px; + margin-bottom: 8px; + font-size: 12px; + color: #000; + justify-content: space-between; + } + + .attribute-config { + margin-top: 4px; + display: flex; + flex-direction: column; + gap: 4px; + } + + .attribute-input { + width: 100%; + padding: 4px 8px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 12px; + box-sizing: border-box; + } + + .override-config { + display: flex; + align-items: center; + gap: 4px; + margin-top: 2px; + } + + .override-checkbox { + margin-right: 4px; + } + + .override-input { + flex: 1; + padding: 2px 6px; + border: 1px solid #ddd; + border-radius: 3px; + font-size: 11px; + box-sizing: border-box; + } + + .override-label { + font-size: 11px; + color: #666; + white-space: nowrap; + } + + .remove-btn { + background: none; + border: none; + cursor: pointer; + padding: 0; + display: flex; + align-items: center; + color: #666; + margin-left: auto; + } + + .remove-btn:hover { + color: #f44336; + } + `; + } + + render() { + if (!this.hass) return html``; + + return html` +