+
+ ${this.subEntry
+ ? html`
+
+ `
+ : nothing}
+ ${iconPath
+ ? html`
`
+ : this._iconImg
+ ? html`

`
+ : fallbackIconPath
+ ? html`
`
+ : stateObject
+ ? html`
+
+
+ `
+ : nothing}
+
+
${name}
${context && !this.hideContext
? html`${context}`
- : nothing}
+ : this._domainName && this.subEntry
+ ? html`${this._domainName}`
+ : nothing}
${!this.subEntry &&
((entries && (showEntities || showDevices)) || this._domainName)
? html`
- ${showEntities
- ? html`${this.hass.localize(
+ ${showEntities && !this.expand
+ ? html``
- : nothing}
+ )}
+ `
+ : showEntities
+ ? html`
+ ${this.hass.localize(
+ "ui.components.target-picker.entities_count",
+ {
+ count: entries?.referenced_entities.length,
+ }
+ )}
+ `
+ : nothing}
${showDevices
? html`${this.hass.localize(
@@ -204,7 +211,7 @@ export class HaTargetPickerItemRow extends LitElement {
`
: nothing}
- ${!this.subEntry
+ ${!this.expand && !this.subEntry
? html`
- ${this._expanded && entries && entries.referenced_entities
+ ${this.expand && entries && entries.referenced_entities
? this._renderEntries()
: nothing}
`;
@@ -305,31 +312,39 @@ export class HaTargetPickerItemRow extends LitElement {
: [];
return html`
-
- ${rows1.map(
- (itemId, index) => html`
-
- `
- )}
- ${rows2.map(
- (itemId) => html`
-
- `
- )}
-
+
+
+
+ ${rows1.map(
+ (itemId, index) => html`
+
+ `
+ )}
+ ${rows2.map(
+ (itemId, index) => html`
+
+ `
+ )}
+
+
`;
}
@@ -528,76 +543,103 @@ export class HaTargetPickerItemRow extends LitElement {
}
}
- private _toggleExpand() {
- const entries = this.parentEntries || this._entries;
-
- if (
- this.type === "entity" ||
- !entries ||
- entries.referenced_entities.length === 0
- ) {
- return;
- }
- this._expanded = !this._expanded;
+ private _openDetails() {
+ showTargetDetailsDialog(this, {
+ title: this._itemData(this.type, this.itemId).name,
+ type: this.type,
+ itemId: this.itemId,
+ deviceFilter: this.deviceFilter,
+ entityFilter: this.entityFilter,
+ includeDomains: this.includeDomains,
+ includeDeviceClasses: this.includeDeviceClasses,
+ });
}
- static styles = css`
- :host {
- --md-list-item-top-space: 0;
- --md-list-item-bottom-space: 0;
- --md-list-item-leading-space: 8px;
- --md-list-item-trailing-space: 8px;
- --md-list-item-two-line-container-height: 56px;
- }
+ static styles = [
+ buttonLinkStyle,
+ css`
+ :host {
+ --md-list-item-top-space: 0;
+ --md-list-item-bottom-space: 0;
+ --md-list-item-leading-space: 8px;
+ --md-list-item-trailing-space: 8px;
+ --md-list-item-two-line-container-height: 56px;
+ }
- state-badge {
- color: var(--ha-color-on-neutral-quiet);
- }
- img {
- width: 24px;
- height: 24px;
- }
- .expand-button {
- transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
- }
- .expand-button.expanded {
- transform: rotate(180deg);
- }
- ha-icon-button {
- --mdc-icon-button-size: 32px;
- }
- .summary {
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- line-height: var(--ha-line-height-condensed);
- }
- :host([sub-entry]) .summary {
- margin-right: 48px;
- }
- .summary .main {
- font-weight: var(--ha-font-weight-medium);
- }
- .summary .secondary {
- font-size: var(--ha-font-size-s);
- color: var(--secondary-text-color);
- }
- .summary .secondary.domain {
- font-family: var(--ha-font-family-code);
- }
+ :host([expand]:not([sub-entry])) ha-md-list-item {
+ border: 2px solid var(--ha-color-border-neutral-loud);
+ background-color: var(--ha-color-fill-neutral-quiet-resting);
+ border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg));
+ }
- .entries {
- padding: 0;
- padding-left: 40px;
- overflow: hidden;
- transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
- border-bottom: 1px solid var(--ha-color-border-neutral-quiet);
- }
+ state-badge {
+ color: var(--ha-color-on-neutral-quiet);
+ }
+ img {
+ width: 24px;
+ height: 24px;
+ }
+ ha-icon-button {
+ --mdc-icon-button-size: 32px;
+ }
+ .summary {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-end;
+ line-height: var(--ha-line-height-condensed);
+ }
+ :host([sub-entry]) .summary {
+ margin-right: 48px;
+ }
+ .summary .main {
+ font-weight: var(--ha-font-weight-medium);
+ }
+ .summary .secondary {
+ font-size: var(--ha-font-size-s);
+ color: var(--secondary-text-color);
+ }
+ .domain {
+ font-family: var(--ha-font-family-code);
+ }
- :host([sub-entry]) .entries {
- border-bottom: none;
- }
- `;
+ .entries-tree {
+ display: flex;
+ position: relative;
+ }
+
+ .entries-tree .line-wrapper {
+ padding: 20px;
+ }
+
+ .entries-tree .line-wrapper .line {
+ border-left: 2px dashed var(--divider-color);
+ height: 100%;
+ position: absolute;
+ top: 0;
+ }
+
+ :host([sub-entry]) .entries-tree .line-wrapper .line {
+ height: calc(100% + 18px);
+ top: -18px;
+ }
+
+ .entries {
+ padding: 0;
+ --md-item-overflow: visible;
+ }
+
+ .horizontal-line-wrapper {
+ position: relative;
+ }
+ .horizontal-line-wrapper .horizontal-line {
+ position: absolute;
+ top: 11px;
+ margin-inline-start: -28px;
+ width: 29px;
+ border-top: 2px dashed var(--divider-color);
+ }
+ `,
+ ];
}
declare global {
diff --git a/src/translations/en.json b/src/translations/en.json
index cf8f1d20c5..4d5e39a6f4 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -683,6 +683,7 @@
"add_label_id": "Choose label",
"devices_count": "{count} {count, plural,\n one {device}\n other {devices}\n}",
"entities_count": "{count} {count, plural,\n one {entity}\n other {entities}\n}",
+ "overview": "Overview",
"selected": {
"entity": "Entities: {count}",
"device": "Devices: {count}",