Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/entity/ha-entities-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class HaEntitiesPickerLight extends LitElement {

static override styles = css`
ha-entity-picker {
display: block;
margin-top: 8px;
}
`;
Expand Down
12 changes: 9 additions & 3 deletions src/components/ha-selector/ha-selector-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class HaNumberSelector extends LitElement {

@property() public label?: string;

@property({ type: Boolean }) public required = true;

@property({ type: Boolean }) public disabled = false;

protected render() {
Expand All @@ -29,6 +31,7 @@ export class HaNumberSelector extends LitElement {
.value=${this._value}
.step=${this.selector.number.step ?? 1}
.disabled=${this.disabled}
.required=${this.required}
pin
ignore-bar-touch
@change=${this._handleSliderChange}
Expand All @@ -43,9 +46,10 @@ export class HaNumberSelector extends LitElement {
class=${classMap({ single: this.selector.number.mode === "box" })}
.min=${this.selector.number.min}
.max=${this.selector.number.max}
.value=${this.value}
.value=${this.value || ""}
.step=${this.selector.number.step ?? 1}
.disabled=${this.disabled}
.required=${this.required}
.suffix=${this.selector.number.unit_of_measurement}
type="number"
autoValidate
Expand All @@ -56,14 +60,16 @@ export class HaNumberSelector extends LitElement {
}

private get _value() {
return this.value ?? 0;
return this.value ?? (this.selector.number.min || 0);
}

private _handleInputChange(ev) {
ev.stopPropagation();
const value =
ev.target.value === "" || isNaN(ev.target.value)
? undefined
? this.required
? this.selector.number.min || 0
: undefined
: Number(ev.target.value);
if (this.value === value) {
return;
Expand Down
25 changes: 11 additions & 14 deletions src/panels/config/areas/dialog-area-registry-detail.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import "@material/mwc-button";
import "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { property, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import { createCloseHeading } from "../../../components/ha-dialog";
import "../../../components/ha-alert";
import "../../../components/ha-textfield";
import "../../../components/ha-picture-upload";
import type { HaPictureUpload } from "../../../components/ha-picture-upload";
import { AreaRegistryEntryMutableParams } from "../../../data/area_registry";
Expand Down Expand Up @@ -69,7 +69,7 @@ class DialogAreaDetail extends LitElement {
>
<div>
${this._error
? html` <ha-alert alert-type="error">${this._error}</ha-alert> `
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: ""}
<div class="form">
${entry
Expand All @@ -83,17 +83,16 @@ class DialogAreaDetail extends LitElement {
`
: ""}

<paper-input
<ha-textfield
.value=${this._name}
@value-changed=${this._nameChanged}
@keyup=${this._handleKeyup}
@input=${this._nameChanged}
.label=${this.hass.localize("ui.panel.config.areas.editor.name")}
.errorMessage=${this.hass.localize(
"ui.panel.config.areas.editor.name_required"
)}
.invalid=${nameInvalid}
dialogInitialFocus
></paper-input>
></ha-textfield>
<ha-picture-upload
.hass=${this.hass}
.value=${this._picture}
Expand Down Expand Up @@ -132,15 +131,9 @@ class DialogAreaDetail extends LitElement {
return this._name.trim() !== "";
}

private _handleKeyup(ev: KeyboardEvent) {
if (ev.keyCode === 13 && this._isNameValid() && !this._submitting) {
this._updateEntry();
}
}

private _nameChanged(ev: PolymerChangedEvent<string>) {
private _nameChanged(ev) {
this._error = undefined;
this._name = ev.detail.value;
this._name = ev.target.value;
}

private _pictureChanged(ev: PolymerChangedEvent<string | null>) {
Expand Down Expand Up @@ -188,6 +181,10 @@ class DialogAreaDetail extends LitElement {
.form {
padding-bottom: 24px;
}
ha-textfield {
display: block;
margin-bottom: 16px;
}
`,
];
}
Expand Down
11 changes: 7 additions & 4 deletions src/panels/config/automation/manual-automation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class HaManualAutomationEditor extends LitElement {
.label=${this.hass.localize(
"ui.panel.config.automation.editor.modes.label"
)}
.value=${this.config.mode ? MODES.indexOf(this.config.mode) : 0}
.value=${this.config.mode}
@selected=${this._modeChanged}
fixedMenuPosition
>
Expand All @@ -115,14 +115,15 @@ export class HaManualAutomationEditor extends LitElement {
</mwc-select>
${this.config.mode && MODES_MAX.includes(this.config.mode)
? html`
<ha-textfield
<br /><ha-textfield
.label=${this.hass.localize(
`ui.panel.config.automation.editor.max.${this.config.mode}`
)}
type="number"
name="max"
.value=${this.config.max || "10"}
@change=${this._valueChanged}
class="max"
>
</ha-textfield>
`
Expand Down Expand Up @@ -357,8 +358,10 @@ export class HaManualAutomationEditor extends LitElement {
ha-entity-toggle {
margin-right: 8px;
}
mwc-select {
margin-top: 8px;
mwc-select,
.max {
margin-top: 16px;
width: 200px;
}
`,
];
Expand Down
34 changes: 20 additions & 14 deletions src/panels/config/blueprint/dialog-import-blueprint.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "@material/mwc-button";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import { CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state, query } from "lit/decorators";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/ha-circular-progress";
import { createCloseHeading } from "../../../components/ha-dialog";
import "../../../components/ha-expansion-panel";
import "../../../components/ha-markdown";
import "../../../components/ha-textfield";
import type { HaTextField } from "../../../components/ha-textfield";
import {
BlueprintImportResult,
importBlueprint,
Expand All @@ -32,7 +32,7 @@ class DialogImportBlueprint extends LitElement {

@state() private _url?: string;

@query("#input") private _input?: PaperInputElement;
@query("#input") private _input?: HaTextField;

public showDialog(params): void {
this._params = params;
Expand Down Expand Up @@ -90,13 +90,13 @@ class DialogImportBlueprint extends LitElement {
</ul>
`
: html`
<paper-input
<ha-textfield
id="input"
.value=${this._result.suggested_filename}
.value=${this._result.suggested_filename || ""}
.label=${this.hass.localize(
"ui.panel.config.blueprint.add.file_name"
)}
></paper-input>
></ha-textfield>
`}
<ha-expansion-panel
.header=${this.hass.localize(
Expand All @@ -116,14 +116,14 @@ class DialogImportBlueprint extends LitElement {
"ui.panel.config.blueprint.add.community_forums"
)}</a
>`
)}<paper-input
)}<ha-textfield
id="input"
.label=${this.hass.localize(
"ui.panel.config.blueprint.add.url"
)}
.value=${this._url}
.value=${this._url || ""}
dialogInitialFocus
></paper-input>`}
></ha-textfield>`}
</div>
${!this._result
? html`<mwc-button
Expand Down Expand Up @@ -212,9 +212,15 @@ class DialogImportBlueprint extends LitElement {
}
}

static get styles(): CSSResultGroup {
return haStyleDialog;
}
static styles = [
haStyleDialog,
css`
ha-textfield {
display: block;
margin-top: 8px;
}
`,
];
}

declare global {
Expand Down
21 changes: 11 additions & 10 deletions src/panels/config/core/ha-config-name-form.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import "@material/mwc-button/mwc-button";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../components/ha-card";
import { ConfigUpdateValues, saveCoreConfig } from "../../../data/core";
import type { PolymerChangedEvent } from "../../../polymer-types";
import type { HomeAssistant } from "../../../types";
import "../../../components/ha-textfield";
import type { HaTextField } from "../../../components/ha-textfield";

@customElement("ha-config-name-form")
class ConfigNameForm extends LitElement {
Expand Down Expand Up @@ -34,16 +33,15 @@ class ConfigNameForm extends LitElement {
</p>
`
: ""}
<paper-input
<ha-textfield
class="flex"
.label=${this.hass.localize(
"ui.panel.config.core.section.core.core_config.location_name"
)}
name="name"
.disabled=${disabled}
.value=${this._nameValue}
@value-changed=${this._handleChange}
></paper-input>
@changed=${this._handleChange}
></ha-textfield>
</div>
<div class="card-actions">
<mwc-button @click=${this._save} .disabled=${disabled}>
Expand All @@ -62,9 +60,9 @@ class ConfigNameForm extends LitElement {
: this.hass.config.location_name;
}

private _handleChange(ev: PolymerChangedEvent<string>) {
const target = ev.currentTarget as PaperInputElement;
this[`_${target.name}`] = target.value;
private _handleChange(ev) {
const target = ev.currentTarget as HaTextField;
this._name = target.value;
}

private async _save() {
Expand All @@ -85,6 +83,9 @@ class ConfigNameForm extends LitElement {
.card-actions {
text-align: right;
}
ha-textfield {
display: block;
}
`;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import "@material/mwc-button/mwc-button";
import "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-area-picker";
import "../../../../components/ha-dialog";
Comment thread
bramkragten marked this conversation as resolved.
import type { HaSwitch } from "../../../../components/ha-switch";
import "../../../../components/ha-textfield";
import { computeDeviceName } from "../../../../data/device_registry";
import { PolymerChangedEvent } from "../../../../polymer-types";
import { haStyle, haStyleDialog } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
import { DeviceRegistryDetailDialogParams } from "./show-dialog-device-registry-detail";
Expand Down Expand Up @@ -57,16 +56,18 @@ class DialogDeviceRegistryDetail extends LitElement {
.heading=${computeDeviceName(device, this.hass)}
>
<div>
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
${this._error
? html`<ha-alert alert-type="error">${this._error}</ha-alert> `
: ""}
<div class="form">
<paper-input
<ha-textfield
.value=${this._nameByUser}
@value-changed=${this._nameChanged}
@input=${this._nameChanged}
.label=${this.hass.localize("ui.panel.config.devices.name")}
.placeholder=${device.name || ""}
.disabled=${this._submitting}
dialogInitialFocus
></paper-input>
></ha-textfield>
<ha-area-picker
.hass=${this.hass}
.value=${this._areaId}
Expand Down Expand Up @@ -132,9 +133,9 @@ class DialogDeviceRegistryDetail extends LitElement {
`;
}

private _nameChanged(ev: PolymerChangedEvent<string>): void {
private _nameChanged(ev): void {
this._error = undefined;
this._nameByUser = ev.detail.value;
this._nameByUser = ev.target.value;
}

private _areaPicked(event: CustomEvent): void {
Expand Down Expand Up @@ -174,8 +175,9 @@ class DialogDeviceRegistryDetail extends LitElement {
mwc-button.warning {
margin-right: auto;
}
.error {
color: var(--error-color);
ha-textfield {
display: block;
margin-bottom: 16px;
}
ha-switch {
margin-right: 16px;
Expand Down
Loading