Skip to content

Commit 3feedb7

Browse files
Multi textfield helper (#23649)
Co-authored-by: Bram Kragten <[email protected]>
1 parent fc29002 commit 3feedb7

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/components/ha-multi-textfield.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { mdiDeleteOutline, mdiPlus } from "@mdi/js";
22
import type { CSSResultGroup } from "lit";
3-
import { LitElement, css, html } from "lit";
3+
import { LitElement, css, html, nothing } from "lit";
44
import { customElement, property } from "lit/decorators";
55
import { fireEvent } from "../common/dom/fire_event";
66
import { haStyle } from "../resources/styles";
77
import type { HomeAssistant } from "../types";
88
import "./ha-button";
99
import "./ha-icon-button";
1010
import "./ha-textfield";
11+
import "./ha-input-helper-text";
1112
import type { HaTextField } from "./ha-textfield";
1213

1314
@customElement("ha-multi-textfield")
@@ -20,6 +21,8 @@ class HaMultiTextField extends LitElement {
2021

2122
@property() public label?: string;
2223

24+
@property({ attribute: false }) public helper?: string;
25+
2326
@property({ attribute: false }) public inputType?: string;
2427

2528
@property({ attribute: false }) public inputSuffix?: string;
@@ -69,12 +72,21 @@ class HaMultiTextField extends LitElement {
6972
</div>
7073
`;
7174
})}
72-
<div class="layout horizontal center-center">
75+
<div class="layout horizontal">
7376
<ha-button @click=${this._addItem} .disabled=${this.disabled}>
74-
${this.addLabel ?? this.hass?.localize("ui.common.add") ?? "Add"}
77+
${this.addLabel ??
78+
(this.label
79+
? this.hass?.localize("ui.components.multi-textfield.add_item", {
80+
item: this.label,
81+
})
82+
: this.hass?.localize("ui.common.add")) ??
83+
"Add"}
7584
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
7685
</ha-button>
7786
</div>
87+
${this.helper
88+
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
89+
: nothing}
7890
`;
7991
}
8092

src/components/ha-selector/ha-selector-text.ts

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class HaTextSelector extends LitElement {
5050
.inputType=${this.selector.text?.type}
5151
.inputSuffix=${this.selector.text?.suffix}
5252
.inputPrefix=${this.selector.text?.prefix}
53+
.helper=${this.helper}
5354
.autocomplete=${this.selector.text?.autocomplete}
5455
@value-changed=${this._handleChange}
5556
>

src/translations/en.json

+3
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,9 @@
11151115
"last_updated": "Last updated",
11161116
"remaining_time": "Remaining time",
11171117
"install_status": "Install status"
1118+
},
1119+
"multi-textfield": {
1120+
"add_item": "Add {item}"
11181121
}
11191122
},
11201123
"dialogs": {

0 commit comments

Comments
 (0)